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  /// @{ Creates a connection between the given shading (ie, input or output)
120  /// attributes.
121  bool connect(const UT_StringRef &src_primpath,
122  const UT_StringRef &src_attrname,
123  const UT_StringRef &dst_primpath,
124  const UT_StringRef &dst_attrname) const;
125  /// @}
126 
127  /// @{ Disconnects a shading (ie input or output) attribute from its source.
128  bool disconnect(const UT_StringRef &primpath,
129  const UT_StringRef &attrname) const;
130  bool disconnectIfConnected(const UT_StringRef &primpath,
131  const UT_StringRef &attrname) const;
132  bool isConnected(const UT_StringRef &primpath,
133  const UT_StringRef &attrname) const;
134  /// @}
135 
136 
137  /// Sets primvar's indices, making it an indexed primvar.
138  bool setPrimvarIndices( const UT_StringRef &primpath,
139  const UT_StringRef &primvar_name,
140  const UT_ExintArray &indices,
141  const HUSD_TimeCode &timecode,
142  bool clear_existing = true) const;
143 
144  /// @{ Returns effective time code at which the value should be set.
145  /// Eg, if attribute has time samples and the given time code is default,
146  /// it needs to be "promoted" to time code for the specific frame/time.
147  /// Otherwise, setting value at default time will not take effect, if
148  /// there is already a value at that specific frame/time.
149  /// This ensures that getAttribute() returns the same value as set here.
150  HUSD_TimeCode getAttribEffectiveTimeCode(
151  const UT_StringRef &primpath,
152  const UT_StringRef &attribname,
153  const HUSD_TimeCode &timecode) const;
154  HUSD_TimeCode getPrimvarEffectiveTimeCode(
155  const UT_StringRef &primpath,
156  const UT_StringRef &primvarname,
157  const HUSD_TimeCode &timecode) const;
158  HUSD_TimeCode getPrimvarIndicesEffectiveTimeCode(
159  const UT_StringRef &primpath,
160  const UT_StringRef &primvarname,
161  const HUSD_TimeCode &timecode) const;
162  /// @}
163 
164  /// Copies an attribute from one primitive to another. This method will
165  /// copy all values and time samples, ensure matching data types, etc.
166  bool copyProperty(
167  const UT_StringRef &srcprimpath,
168  const UT_StringRef &srcpropertyname,
169  const HUSD_FindPrims &finddestprims,
170  const UT_StringRef &destpropertyname,
171  bool copymetadata,
172  bool blocksource);
173 
174 private:
175  HUSD_AutoWriteLock &myWriteLock;
176 };
177 
178 #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