HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_SetAttributes.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_SetAttributes_h__
19 #define __HUSD_SetAttributes_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 #include "HUSD_TimeCode.h"
24 #include <UT/UT_StringHolder.h>
25 
27 {
28 public:
31 
32  /// @{ Create an attribute or primvar on a primitive.
33  bool addAttribute(const UT_StringRef &primpath,
34  const UT_StringRef &attrname,
35  const UT_StringRef &type) const;
36 
37  bool addPrimvar(const UT_StringRef &primpath,
38  const UT_StringRef &primvarname,
39  const UT_StringRef &interpolation,
40  const UT_StringRef &type) const;
41  /// @}
42 
43  /// @{ Set an attribute or primvar value on a primitive.
44  template<typename UtValueType>
45  bool setAttribute(const UT_StringRef &primpath,
46  const UT_StringRef &attrname,
47  const UtValueType &value,
48  const HUSD_TimeCode &timecode,
49  const UT_StringRef &valueType =
51 
52  template<typename UtValueType>
53  bool setPrimvar(const UT_StringRef &primpath,
54  const UT_StringRef &primvarname,
55  const UT_StringRef &interpolation,
56  const UtValueType &value,
57  const HUSD_TimeCode &timecode,
58  const UT_StringRef &valueType =
60  int elementsize = 1) const;
61  /// @}
62 
63 
64  /// @{ Set an attribute or primvar value on a primitive,
65  /// but accept the *subclasses* of the UT_Array.
66  template<typename UtValueType>
67  bool setAttributeArray(const UT_StringRef &primpath,
68  const UT_StringRef &attrname,
69  const UT_Array<UtValueType> &value,
70  const HUSD_TimeCode &timecode,
71  const UT_StringRef &valueType =
73  { return setAttribute(primpath, attrname,
74  value, timecode, valueType); }
75 
76  template<typename UtValueType>
77  bool setPrimvarArray(const UT_StringRef &primpath,
78  const UT_StringRef &primvarname,
79  const UT_StringRef &interpolation,
80  const UT_Array<UtValueType> &value,
81  const HUSD_TimeCode &timecode,
82  const UT_StringRef &valueType =
84  int elementsize = 1) const
85  { return setPrimvar(primpath, primvarname,
86  interpolation, value, timecode, valueType,
87  elementsize); }
88  /// @}
89 
90  /// @{ Blocks an attribute or primvar.
91  bool blockAttribute(const UT_StringRef &primpath,
92  const UT_StringRef &attrname) const;
93  bool blockPrimvar(const UT_StringRef &primpath,
94  const UT_StringRef &primvarname) const;
95  bool blockPrimvarIndices(const UT_StringRef &primpath,
96  const UT_StringRef &primvarname) const;
97  /// @}
98 
99  /// Sets primvar's indices, making it an indexed primvar.
100  bool setPrimvarIndices( const UT_StringRef &primpath,
101  const UT_StringRef &primvar_name,
102  const UT_ExintArray &indices,
103  const HUSD_TimeCode &timecode) const;
104 
105  /// @{ Returns effective time code at which the value should be set.
106  /// Eg, if attribute has time samples and the given time code is default,
107  /// it needs to be "promoted" to time code for the specific frame/time.
108  /// Otherwise, setting value at default time will not take effect, if
109  /// there is already a value at that specific frame/time.
110  /// This ensures that getAttribute() returns the same value as set here.
111  HUSD_TimeCode getAttribEffectiveTimeCode(
112  const UT_StringRef &primpath,
113  const UT_StringRef &attribname,
114  const HUSD_TimeCode &timecode) const;
115  HUSD_TimeCode getPrimvarEffectiveTimeCode(
116  const UT_StringRef &primpath,
117  const UT_StringRef &primvarname,
118  const HUSD_TimeCode &timecode) const;
119  HUSD_TimeCode getPrimvarIndicesEffectiveTimeCode(
120  const UT_StringRef &primpath,
121  const UT_StringRef &primvarname,
122  const HUSD_TimeCode &timecode) const;
123  /// @}
124 
125 private:
126  HUSD_AutoWriteLock &myWriteLock;
127 };
128 
129 #endif
#define HUSD_API
Definition: HUSD_API.h:32
GLuint GLuint GLsizei GLenum const void * indices
Definition: glew.h:1253
bool setAttributeArray(const UT_StringRef &primpath, const UT_StringRef &attrname, const UT_Array< UtValueType > &value, const HUSD_TimeCode &timecode, const UT_StringRef &valueType=UT_String::getEmptyString()) const
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
bool setPrimvarArray(const UT_StringRef &primpath, const UT_StringRef &primvarname, const UT_StringRef &interpolation, const UT_Array< UtValueType > &value, const HUSD_TimeCode &timecode, const UT_StringRef &valueType=UT_String::getEmptyString(), int elementsize=1) const
static const UT_String & getEmptyString()
GLsizei const GLfloat * value
Definition: glew.h:1849