HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
HUSD_Cvex.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_Cvex__
19
#define __HUSD_Cvex__
20
21
#include "
HUSD_API.h
"
22
#include "
HUSD_DataHandle.h
"
23
#include "
HUSD_TimeCode.h
"
24
#include "
HUSD_Utils.h
"
25
#include <
UT/UT_UniquePtr.h
>
26
27
class
husd_CvexResults;
28
class
HUSD_CvexBindingMap
;
29
class
HUSD_CvexCode
;
30
class
HUSD_CvexDataCommand
;
31
class
HUSD_CvexDataInputs
;
32
class
HUSD_CvexRunData;
33
class
HUSD_PrimsBucket
;
34
class
HUSD_FacesBucket
;
35
enum class
HUSD_TimeSampling
;
36
class
OP_Caller
;
37
class
UT_StringArray
;
38
class
UT_PathPattern
;
39
40
class
HUSD_API
HUSD_Cvex
41
{
42
public
:
43
HUSD_Cvex
();
44
~
HUSD_Cvex
();
45
46
/// Sets the ID of a node that executes the CVEX script.
47
/// It is used for channels evaluation in VEX as well as error reporting.
48
void
setCwdNodeId(
int
cwd_node_id ) ;
49
50
/// Sets the caller object that keeps track of dependencies on any node
51
/// referenced with the 'op:' syntax in code.
52
void
setOpCaller(
OP_Caller
*caller );
53
54
/// Sets an object that resolves a stage based on handle, which are used
55
/// in calls to VEX functions that operate on USD data (eg, primitives).
56
/// Handles are strings that usually refer to LOP node inputs "opinput:0".
57
void
setDataInputs(
HUSD_CvexDataInputs
*vex_geo_inputs );
58
59
/// Sets an object that processes VEX functions that modify the USD data.
60
void
setDataCommand(
HUSD_CvexDataCommand
*vex_geo_command );
61
62
/// Sets the time code at which attributes are evaluated and/or set.
63
void
setTimeCode(
const
HUSD_TimeCode
&time_code );
64
65
/// Sets the cvex script bindings map (cvex parm -> usd prim attrib).
66
void
setBindingsMap(
const
HUSD_CvexBindingMap
*map );
67
68
/// Set the name of the array attibute whose length should be used
69
/// as a hint about the number of array elements to run cvex on.
70
/// NOTE: This is the lower bound, and the actual number may be higher
71
/// than that if CVEX code references some larger array attribute.
72
void
setArraySizeHintAttrib(
const
UT_StringRef
&attrib_name );
73
74
/// Sets a flag inticating whether or not existing attribute data should
75
/// be cleared before setting a USD attribute value. Defaults to true, and
76
/// gets set to false only when setting multiple tie samples through a
77
/// single HUSD_Cvex object.
78
void
setClearExistingAttribData(
bool
clear_existing );
79
80
/// Runs the CVEX script on the USD primitives, setting their attributes.
81
// TODO: implement ability to use vexpression in addition to command,
82
// ie, use HUSD_CvexCode as parameter type.
83
bool
runOverPrimitives(
HUSD_AutoAnyLock
&lock,
84
const
HUSD_PathSet
&paths,
85
const
UT_StringRef
&cvex_command )
const
;
86
bool
applyRunOverPrimitives(
HUSD_AutoWriteLock
&writelock)
const
;
87
88
/// Runs the CVEX script on the array attribute of USD primitives,
89
/// setting their elements.
90
// TODO: implement ability to use vexpression in addition to command,
91
// ie, use HUSD_CvexCode as parameter type.
92
bool
runOverArrayElements(
HUSD_AutoAnyLock
&lock,
93
const
HUSD_PathSet
&paths,
94
const
UT_StringRef
&cvex_command )
const
;
95
bool
applyRunOverArrayElements(
HUSD_AutoWriteLock
&writelock)
const
;
96
97
/// Gets the primitives for which the given cvex command (ie, its first int
98
/// output) or a vexpression returns a non-zero value.
99
bool
matchPrimitives(
HUSD_AutoAnyLock
&lock,
100
UT_StringArray
&matched_prims_paths,
101
const
HUSD_CvexCode
&code,
102
HUSD_PrimTraversalDemands
demands,
103
const
UT_PathPattern
*pruning_pattern =
nullptr
)
const
;
104
105
/// Partitions the primitives specified by findprims, given
106
/// the CVEX script whose output values are used to define buckets.
107
/// When @p code's return type is void, all outputs are used for
108
/// partitioning; otherwise, the first output of a given type is used
109
/// (converted to a string keyword value).
110
bool
partitionPrimitives(
HUSD_AutoAnyLock
&lock,
111
UT_Array<HUSD_PrimsBucket>
&buckets,
112
const
HUSD_PathSet
&paths,
113
const
HUSD_CvexCode
&code )
const
;
114
115
/// Get the faces for which the given cvex command (ie, its first int
116
/// output) or a vexpression returns a non-zero value.
117
bool
matchFaces(
HUSD_AutoAnyLock
&lock,
118
UT_ExintArray
&matched_faces_indices,
119
const
UT_StringRef
&geo_prim_path,
120
const
UT_ExintArray
*face_indices,
121
const
HUSD_CvexCode
&code )
const
;
122
123
/// Get the faces for which the given cvex command (ie, its first int
124
/// output) or a vexpression returns a non-zero value.
125
bool
matchInstances(
HUSD_AutoAnyLock
&lock,
126
UT_ExintArray
&matched_instance_indices,
127
const
UT_StringRef
&instancer_prim_path,
128
const
UT_ExintArray
*point_indices,
129
const
HUSD_CvexCode
&code )
const
;
130
131
/// Partitions the face set specified by the @p geo_prim_path and
132
/// @p face_indices, given the CVEX script whose output values are used
133
/// to define buckets. When @p code's return type is void, all outputs
134
/// are used for partitioning; otherwise, the first output of a given
135
/// type is used (converted to a string keyword value).
136
/// If @p face_indices is null, then all faces of the prim are partitioned.
137
bool
partitionFaces(
HUSD_AutoAnyLock
&lock,
138
UT_Array<HUSD_FacesBucket>
&buckets,
139
const
UT_StringRef
&geo_prim_path,
140
const
UT_ExintArray
*face_indices,
141
const
HUSD_CvexCode
&code )
const
;
142
143
/// Returns true if any attribute the CVEX has run on has many time samples.
144
bool
getIsTimeVarying()
const
;
145
146
private
:
147
UT_UniquePtr<HUSD_CvexRunData>
myRunData;
148
mutable
UT_Array<UT_UniquePtr<husd_CvexResults>
> myResults;
149
UT_StringHolder
myArraySizeHintAttrib;
150
151
// Max level of sampling among bound attributes.
152
mutable
HUSD_TimeSampling
myTimeSampling;
153
};
154
155
#endif
156
HUSD_API
#define HUSD_API
Definition:
HUSD_API.h:32
HUSD_CvexBindingMap
Definition:
HUSD_CvexBindingMap.h:25
HUSD_CvexDataInputs
Class to query an input on a VEX usd geometry (stage).
Definition:
HUSD_CvexDataInputs.h:28
HUSD_FacesBucket
Definition:
HUSD_Bucket.h:99
UT_StringRef
Definition:
UT_StringHolder.h:188
HUSD_PrimTraversalDemands
HUSD_PrimTraversalDemands
Definition:
HUSD_Utils.h:39
UT_ValArray< exint >
HUSD_AutoWriteLock
Definition:
HUSD_DataHandle.h:261
UT_Array
Definition:
BV_KDOPTree.h:18
UT_UniquePtr
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition:
UT_UniquePtr.h:39
UT_StringHolder
Definition:
UT_StringHolder.h:999
UT_StringArray
Definition:
UT_StringArray.h:24
HUSD_CvexCode
Definition:
HUSD_CvexCode.h:27
HUSD_TimeSampling
HUSD_TimeSampling
Definition:
HUSD_Utils.h:99
HUSD_API.h
HUSD_Cvex
Definition:
HUSD_Cvex.h:40
HUSD_TimeCode
Definition:
HUSD_TimeCode.h:24
HUSD_AutoAnyLock
Definition:
HUSD_DataHandle.h:188
HUSD_CvexDataCommand
Definition:
HUSD_CvexDataCommand.h:39
UT_PathPattern
Definition:
UT_PathPattern.h:35
UT_UniquePtr.h
HUSD_PrimsBucket
Definition:
HUSD_Bucket.h:70
HUSD_PathSet
Definition:
HUSD_PathSet.h:49
HUSD_TimeCode.h
HUSD_DataHandle.h
HUSD_Utils.h
OP_Caller
Definition:
OP_Caller.h:23
HUSD
HUSD_Cvex.h
Generated on Tue Dec 17 2024 03:39:51 for HDK by
1.8.6