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 
26 class UT_Options;
27 class HUSD_FindPrims;
28 
30 {
31 public:
34 
35  /// @{ Create an attribute or primvar on a primitive.
36  bool addAttribute(const UT_StringRef &primpath,
37  const UT_StringRef &attrname,
38  const UT_StringRef &type,
39  bool custom = true) const;
40 
41  bool addPrimvar(const UT_StringRef &primpath,
42  const UT_StringRef &primvarname,
43  const UT_StringRef &interpolation,
44  const UT_StringRef &type) const;
45  /// @}
46 
47  /// @{ Set an attribute or primvar value on a primitive.
48  template<typename UtValueType>
49  bool setAttribute(const UT_StringRef &primpath,
50  const UT_StringRef &attrname,
51  const UtValueType &value,
52  const HUSD_TimeCode &timecode,
53  const UT_StringRef &valueType =
55  bool custom = true,
56  bool clear_existing = true) const;
57 
58  template<typename UtValueType>
59  bool setPrimvar(const UT_StringRef &primpath,
60  const UT_StringRef &primvarname,
61  const UT_StringRef &interpolation,
62  const UtValueType &value,
63  const HUSD_TimeCode &timecode,
64  const UT_StringRef &valueType =
66  int elementsize = 1,
67  bool clear_existing = true) const;
68  /// @}
69 
70 
71  /// @{ Set an attribute or primvar value on a primitive,
72  /// but accept the *subclasses* of the UT_Array.
73  template<typename UtValueType>
74  bool setAttributeArray(const UT_StringRef &primpath,
75  const UT_StringRef &attrname,
76  const UT_Array<UtValueType> &value,
77  const HUSD_TimeCode &timecode,
78  const UT_StringRef &valueType =
80  bool custom = true,
81  bool clear_existing = true) const
82  { return setAttribute(primpath, attrname,
83  value, timecode, valueType,
84  custom, clear_existing); }
85 
86  template<typename UtValueType>
87  bool setPrimvarArray(const UT_StringRef &primpath,
88  const UT_StringRef &primvarname,
89  const UT_StringRef &interpolation,
90  const UT_Array<UtValueType> &value,
91  const HUSD_TimeCode &timecode,
92  const UT_StringRef &valueType =
94  int elementsize = 1,
95  bool clear_existing = true) const
96  { return setPrimvar(primpath, primvarname,
97  interpolation, value, timecode,
98  valueType, elementsize, clear_existing); }
99  /// @}
100 
101  /// @{ Set attributes for every entry in a UT_Options object.
102  bool setAttributes(const UT_StringRef &primpath,
103  const UT_Options &options,
104  const HUSD_TimeCode &timecode,
105  const UT_StringRef &attrnamespace =
107  bool clear_existing = true) const;
108  /// @}
109 
110  /// @{ Blocks an attribute or primvar.
111  bool blockAttribute(const UT_StringRef &primpath,
112  const UT_StringRef &attrname) const;
113  bool blockPrimvar(const UT_StringRef &primpath,
114  const UT_StringRef &primvarname) const;
115  bool blockPrimvarIndices(const UT_StringRef &primpath,
116  const UT_StringRef &primvarname) const;
117  /// @}
118 
119  /// @{ Disconnects an input attribute from its source.
120  bool disconnect(const UT_StringRef &primpath,
121  const UT_StringRef &attrname) const;
122  bool disconnectIfConnected(const UT_StringRef &primpath,
123  const UT_StringRef &attrname) const;
124  bool isConnected(const UT_StringRef &primpath,
125  const UT_StringRef &attrname) const;
126  /// @}
127 
128 
129  /// Sets primvar's indices, making it an indexed primvar.
130  bool setPrimvarIndices( const UT_StringRef &primpath,
131  const UT_StringRef &primvar_name,
132  const UT_ExintArray &indices,
133  const HUSD_TimeCode &timecode,
134  bool clear_existing = true) const;
135 
136  /// @{ Returns effective time code at which the value should be set.
137  /// Eg, if attribute has time samples and the given time code is default,
138  /// it needs to be "promoted" to time code for the specific frame/time.
139  /// Otherwise, setting value at default time will not take effect, if
140  /// there is already a value at that specific frame/time.
141  /// This ensures that getAttribute() returns the same value as set here.
142  HUSD_TimeCode getAttribEffectiveTimeCode(
143  const UT_StringRef &primpath,
144  const UT_StringRef &attribname,
145  const HUSD_TimeCode &timecode) const;
146  HUSD_TimeCode getPrimvarEffectiveTimeCode(
147  const UT_StringRef &primpath,
148  const UT_StringRef &primvarname,
149  const HUSD_TimeCode &timecode) const;
150  HUSD_TimeCode getPrimvarIndicesEffectiveTimeCode(
151  const UT_StringRef &primpath,
152  const UT_StringRef &primvarname,
153  const HUSD_TimeCode &timecode) const;
154  /// @}
155 
156  /// Copies an attribute from one primitive to another. This method will
157  /// copy all values and time samples, ensure matching data types, etc.
158  bool copyProperty(
159  const UT_StringRef &srcprimpath,
160  const UT_StringRef &srcpropertyname,
161  const HUSD_FindPrims &finddestprims,
162  const UT_StringRef &destpropertyname,
163  bool copymetadata,
164  bool blocksource);
165 
166 private:
167  HUSD_AutoWriteLock &myWriteLock;
168 };
169 
170 #endif
bool setAttributeArray(const UT_StringRef &primpath, const UT_StringRef &attrname, const UT_Array< UtValueType > &value, const HUSD_TimeCode &timecode, const UT_StringRef &valueType=UT_StringHolder::theEmptyString, bool custom=true, bool clear_existing=true) const
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
#define HUSD_API
Definition: HUSD_API.h:32
static const UT_StringHolder theEmptyString
A map of string to various well defined value types.
Definition: UT_Options.h:84
Definition: core.h:1131
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_StringHolder::theEmptyString, int elementsize=1, bool clear_existing=true) const
type
Definition: core.h:1059