HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_GetAttributes.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_GetAttributes_h__
19 #define __HUSD_GetAttributes_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 #include "HUSD_TimeCode.h"
24 #include <UT/UT_StringHolder.h>
25 
26 enum class HUSD_TimeSampling;
27 
28 
30 {
31 public:
34 
35  /// @{ Obtains attribute or primvar value.
36  template<typename UtValueType>
37  bool getAttribute(const UT_StringRef &primpath,
38  const UT_StringRef &attribname,
39  UtValueType &value,
40  const HUSD_TimeCode &timecode) const;
41 
42  template<typename UtValueType>
43  bool getPrimvar(const UT_StringRef &primpath,
44  const UT_StringRef &primvarname,
45  UtValueType &value,
46  const HUSD_TimeCode &timecode,
47  bool allow_inheritance = false) const;
48 
49  template<typename UtValueType>
50  bool getAttributeOrPrimvar(const UT_StringRef &primpath,
51  const UT_StringRef &name,
52  UtValueType &value,
53  const HUSD_TimeCode &timecode,
54  bool flatten_primvar = false) const;
55  /// @}
56 
57 
58  /// @{ Obtains attribute or primvar array value.
59  // The following methods perform exactly the same thing as the aboves,
60  // but accept the subclasses from the UT_Array.
61  template<typename UtValueType>
62  bool getAttributeArray(const UT_StringRef &primpath,
63  const UT_StringRef &attribname,
64  UT_Array<UtValueType> &value,
65  const HUSD_TimeCode &timecode) const
66  { return getAttribute(primpath, attribname, value, timecode); }
67 
68  template<typename UtValueType>
69  bool getPrimvarArray(const UT_StringRef &primpath,
70  const UT_StringRef &primvarname,
71  UT_Array<UtValueType> &value,
72  const HUSD_TimeCode &timecode,
73  bool allow_inheritance = false) const
74  { return getPrimvar(primpath, primvarname, value, timecode,
75  allow_inheritance); }
76 
77  template<typename UtValueType>
79  const UT_StringRef &name,
80  UT_Array<UtValueType> &value,
81  const HUSD_TimeCode &timecode,
82  bool flatten_primvar = false) const
83  {
84  return getAttributeOrPrimvar(
85  primpath, name, value, timecode, flatten_primvar);
86  }
87  /// @}
88 
89  /// Obtains the size of an array attribute (0 if the attribute
90  /// is not an array)
91  bool getAttributeArraySize(const UT_StringRef &primpath,
92  const UT_StringRef &attribname,
93  size_t &arraylength,
94  const HUSD_TimeCode &timecode) const;
95 
96  /// Returns the interpolation style of an attribute.
97  /// This is only valid for certain attributes, e.g. UsdGeomPoints 'widths'.
98  UT_StringHolder getAttributeInterpolation(const UT_StringRef &primpath,
99  const UT_StringRef &primvarname) const;
100 
101  /// Obtains array value of a flattened primvar.
102  template<typename UtValueType>
103  bool getFlattenedPrimvar(const UT_StringRef &primpath,
104  const UT_StringRef &primvarname,
105  UT_Array<UtValueType> &value,
106  const HUSD_TimeCode &timecode,
107  bool allow_inheritance = false) const;
108 
109  /// Returns true if the primvar is indexed.
110  bool isPrimvarIndexed(const UT_StringRef &primpath,
111  const UT_StringRef &primvarname,
112  bool allow_inheritance = false) const;
113 
114  /// Returns the index array for indexed primvars.
115  bool getPrimvarIndices(const UT_StringRef &primpath,
116  const UT_StringRef &primvarname,
118  const HUSD_TimeCode &timecode,
119  bool allow_inheritance = false) const;
120 
121  /// Returns the interpolation style of a primvar.
122  UT_StringHolder getPrimvarInterpolation(const UT_StringRef &primpath,
123  const UT_StringRef &primvarname,
124  bool allow_inheritance = false) const;
125 
126  /// Returns the element size of a primvar.
127  exint getPrimvarElementSize(const UT_StringRef &primpath,
128  const UT_StringRef &primvarname,
129  bool allow_inheritance = false) const;
130 
131 
132  /// Returns true if any attribute we have fetched has many time samples.
133  bool getIsTimeVarying() const;
134 
135  /// Returns the overal sampling of fethced attributes.
137  { return myTimeSampling; }
138 
139 private:
140  HUSD_AutoAnyLock &myAnyLock;
141  mutable HUSD_TimeSampling myTimeSampling;
142 };
143 #endif
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
int64 exint
Definition: SYS_Types.h:125
#define HUSD_API
Definition: HUSD_API.h:32
bool getPrimvarArray(const UT_StringRef &primpath, const UT_StringRef &primvarname, UT_Array< UtValueType > &value, const HUSD_TimeCode &timecode, bool allow_inheritance=false) const
Obtains attribute or primvar array value.
HUSD_TimeSampling getTimeSampling() const
Returns the overal sampling of fethced attributes.
bool getAttributeOrPrimvarArray(const UT_StringRef &primpath, const UT_StringRef &name, UT_Array< UtValueType > &value, const HUSD_TimeCode &timecode, bool flatten_primvar=false) const
Obtains attribute or primvar array value.
HUSD_TimeSampling
Definition: HUSD_Utils.h:99
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: core.h:1131
bool getAttributeArray(const UT_StringRef &primpath, const UT_StringRef &attribname, UT_Array< UtValueType > &value, const HUSD_TimeCode &timecode) const
Obtains attribute or primvar array value.