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
MOT_GeometryChannelsManager.h
Go to the documentation of this file.
1
/*
2
* PROPRIETARY INFORMATION. This software is proprietary to
3
* Side Effects Software Inc., and is not to be reproduced,
4
* transmitted, or disclosed in any way without written permission.
5
*
6
* NAME: MOT_GeometryChannelsManager (C++)
7
*
8
* COMMENTS: This class is responsible for scoping geometry channels
9
* from existing sop nodes or geometries into the CH_Manager.
10
*
11
*/
12
13
#ifndef __MOT_GeometryChannelsManager_h__
14
#define __MOT_GeometryChannelsManager_h__
15
16
#include "
MOT_API.h
"
17
18
#include <
CH/CH_EventManager.h
>
19
#include <
GA/GA_Types.h
>
20
#include <
OP/OP_Value.h
>
21
#include <
UT/UT_StringArray.h
>
22
#include <
UT/UT_StringHolder.h
>
23
#include <
UT/UT_StringMap.h
>
24
#include <
UT/UT_Map.h
>
25
26
class
GU_DetailHandle
;
27
class
GU_ConstDetailHandle
;
28
class
OP_Node
;
29
class
SOP_Node
;
30
31
class
MOT_API
MOT_GeometryChannelsManager
32
{
33
public
:
34
MOT_GeometryChannelsManager
();
35
36
/// Extracts geometry channels (channel primitives) from
37
/// the provided sop node, scoping them into the CH_Manager.
38
/// Adds listeners to the node to rescope channels
39
/// when they are modified.
40
/// @node SOP_Node to extract the channel primitives from.
41
/// @param pattern Optional primitive group pattern to extract only
42
/// certain primitives from the node's geometry.
43
/// @return name of the collection
44
UT_StringHolder
scopeGeometryChannels(
45
SOP_Node
*node,
46
const
UT_StringHolder
&
pattern
=
""
);
47
48
/// Extracts geometry channels (channel primitives) from
49
/// the provided geometry handle, scoping them into the CH_Manager.
50
/// @param detail Geometry from which to extract the channel primitives
51
/// @param collection_name Optional name for the collection, used to refer
52
/// to it for later fetching or updating its channels. If not
53
/// provided, a unique name will be created. If a collection with
54
/// the same name already exists, it will be updated instead
55
/// of a new one being created. In this case, dataid's will
56
/// be checked to ensure only modified channels are updated.
57
/// if the name attrib dataid of the detail was changed, the
58
/// existing collection will be destroyed and a new one created from
59
/// scratch.
60
/// @param pattern Optional primitive group pattern to extract only
61
/// certain primitives from the geometry.
62
/// @return name of the collection
63
/// Also see setGeometryChannels for updating an existing collection.
64
UT_StringHolder
scopeGeometryChannels(
65
const
GU_ConstDetailHandle
&detail,
66
const
UT_StringHolder
&collection_name =
""
,
67
const
UT_StringHolder
&
pattern
=
""
);
68
69
/// Unscope geometry channels with the given collection name.
70
void
unscopeGeometryChannels(
const
UT_StringHolder
&collection_name);
71
/// Unscope geometry channels from the given node
72
void
unscopeGeometryChannels(
SOP_Node
*node);
73
74
/// Returns a unique name for a new geometry collection, based on the
75
/// myNextGeometryChannelsId property.
76
/// This is used both internally when scoping new collections, and
77
/// when adding geometry collections to the HOM ChannelList. In this second
78
/// case, the collections are not actually scoped until later setting the
79
/// channel list, but the name should be reserved ahead of time to prevent
80
/// possible conflicts.
81
UT_StringHolder
reserveNewGeometryCollectionName();
82
UT_StringArray
getChannelNames(
83
const
GU_ConstDetailHandle
&gdh,
84
UT_StringHolder
pattern
=
""
);
85
86
int
getCollectionNodeId(
const
UT_StringHolder
&collection_name)
const
;
87
UT_StringHolder
getCollectionPattern(
88
const
UT_StringHolder
&collection_name)
const
;
89
90
/// Write the geometry channels with the given names into the
91
/// provided geometry
92
/// @param gdp The geometry to fill with the geometry channels
93
/// @param collection_name Name of the collection to get the channels from
94
/// @param names Names of the channels to fetch.
95
void
getGeometryChannels(
96
GU_DetailHandle
&gdh,
97
const
UT_StringHolder
&collection_name,
98
const
UT_StringArray
&names)
const
;
99
100
/// Write all geometry channels in the collection into the provided geometry
101
/// @param gdp The geometry to fill with the geometry channels
102
/// @param collection_name Name of the collection to get the channels from
103
void
getGeometryChannels(
104
GU_DetailHandle
&gdh,
105
const
UT_StringHolder
&collection_name)
const
;
106
107
/// Perform a partial update of a given collection, overwriting
108
/// channels which match the pattern with the ones in the provided detail.
109
/// @param gdh The geometry used to update the collection's channels.
110
/// @param pattern The primitive group pattern to determine which channel
111
/// primitives should be updated. Note that this does not overwrite the
112
/// original pattern used to originally construct the collection in
113
/// scopeGeometryChannels
114
/// @param collection name Name of the collection to update.
115
///
116
/// Note that this method ignores name dataid checks, as the detail used to
117
/// set geometry channels may be different from the one the channels were
118
/// originally loaded from.
119
/// If the given collection does not exist, this method instead creates a
120
/// new one, using scopeGeometryChannels.
121
void
setGeometryChannels(
122
const
GU_DetailHandle
&gdh,
123
const
UT_StringHolder
&
pattern
=
""
,
124
const
UT_StringHolder
&collection_name =
""
);
125
126
void
clear();
127
128
protected
:
129
130
private
:
131
static
void
geometryChannelsModified(
OP_Node
*caller,
void
*callee,
132
OP_EventType
type
,
void
*
data
);
133
134
static
void
changeEvent(
void
*data,
CH_CHANGE_TYPE
how,
int
parm_index);
135
136
// Creates a new collection. Called by scopeGeometryChannels
137
UT_StringHolder
createCollection(
138
const
GU_ConstDetailHandle
&detail,
139
UT_StringHolder
collection_name,
140
const
UT_StringHolder
&
pattern
,
141
int
node_id);
142
143
// Populates the channels of a collection. Called by createCollection and
144
// setGeometryChannels.
145
// If update_only is true, skips the name attrib dataid checks and avoids
146
// recreating the collection from scratch, or erasing existing channels,
147
// only updating/adding new ones.
148
void
updateCollection(
149
const
UT_StringHolder
&collection_name,
150
const
GU_ConstDetailHandle
&detail,
151
const
UT_StringHolder
&pattern,
152
bool
update_only =
false
);
153
154
void
reloadGeometryChannels(
SOP_Node
*node);
155
void
handleNodeDeleted(
SOP_Node
*node);
156
157
struct
ScopedGeometry
158
{
159
ScopedGeometry()
160
: myId(-1)
161
, myNodeId(-1)
162
, myPattern(
""
)
163
, myNameDataId(
GA_INVALID_DATAID
)
164
{
165
}
166
ScopedGeometry(
int
id
,
const
UT_StringHolder
&pattern,
int
node_id)
167
: myId(
id
)
168
, myPattern(pattern)
169
, myNodeId(node_id)
170
, myNameDataId(
GA_INVALID_DATAID
)
171
{
172
}
173
174
int
myId;
175
UT_StringHolder
myPattern;
176
int
myNodeId;
177
GA_DataId
myNameDataId;
178
// Mapping of channel name to the primitive offset it was created from
179
UT_StringMap<int64>
myGeometryChannelDataIds;
180
};
181
182
/// Mapping of collection name to scoped data
183
UT_StringMap<ScopedGeometry>
myScopedGeometries;
184
185
// Id to assign to geometry channels. When a name is not specified for a new
186
// collection, this is appended to the default name to ensure uniqueness
187
int
myNextGeometryChannelsId;
188
};
189
190
#endif
UT_StringMap< int64 >
GA_DataId
int64 GA_DataId
Definition:
GA_Types.h:696
CH_EventManager.h
UT_StringArray.h
GA_INVALID_DATAID
#define GA_INVALID_DATAID
Definition:
GA_Types.h:697
MOT_API.h
UT_StringHolder
Definition:
UT_StringHolder.h:999
UT_StringArray
Definition:
UT_StringArray.h:24
UT_Map.h
CH_CHANGE_TYPE
CH_CHANGE_TYPE
Definition:
CH_EventManager.h:42
OP_Node
Definition:
OP_Node.h:503
MOT_API
#define MOT_API
Definition:
MOT_API.h:10
GU_ConstDetailHandle
Definition:
GU_DetailHandle.h:176
pattern
GLushort pattern
Definition:
glad.h:2583
GU_DetailHandle
Definition:
GU_DetailHandle.h:38
UT_StringHolder.h
OP_EventType
OP_EventType
Definition:
OP_Value.h:22
OP_Value.h
GA_Types.h
MOT_GeometryChannelsManager
Definition:
MOT_GeometryChannelsManager.h:31
type
type
Definition:
core.h:1059
UT_StringMap.h
data
Definition:
format.h:895
SOP_Node
Definition:
SOP_Node.h:108
MOT
MOT_GeometryChannelsManager.h
Generated on Sat Dec 21 2024 02:46:54 for HDK by
1.8.6