HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GOP_Manager.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  */
7 
8 #ifndef __GOP_Manager_h__
9 #define __GOP_Manager_h__
10 
11 #include "GOP_API.h"
12 #include "GOP_AdhocGroup.h"
13 #include "GOP_GroupParse.h"
14 #include <UT/UT_Array.h>
15 #include <SYS/SYS_Deprecated.h>
16 
17 class GEO_Detail;
18 class GA_BreakpointGroup;
19 class GA_EdgeGroup;
20 class GA_PointGroup;
21 class GA_PrimitiveGroup;
22 class GA_VertexGroup;
23 
25 {
26 
27 public:
30  {
31  destroyAdhocGroups();
32  }
33 
36 
37  const GA_PrimitiveGroup *parsePrimitiveGroups(const char *pat,
38  const GroupCreator &creator,
39  bool numok = true,
40  bool ordered = false,
41  bool strict = false,
42  GA_Index prim_offset = GA_Index(0),
43  ParseInfo *info = 0);
44  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo and be careful since defaults have changed)
45  const GA_PrimitiveGroup *parsePrimitiveGroups(const char *pat,
46  GEO_Detail *pgdp,
47  int numok = 1,
48  int ordered = 1,
49  bool strict = false,
50  int prim_offset = 0,
51  bool allowdetached = false,
52  ParseInfo *info = 0);
53 
54  const GA_PointGroup *parsePointGroups(const char *pat,
55  const GroupCreator &creator,
56  bool numok = true,
57  bool ordered = false,
58  bool strict = false,
59  GA_Index point_offset = GA_Index(0),
60  ParseInfo *info = 0);
61  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo and be careful since defaults have changed)
62  const GA_PointGroup *parsePointGroups(const char *pat,
63  GEO_Detail *pgdp,
64  int numok = 1,
65  int ordered = 1,
66  bool strict = false,
67  int point_offset = 0,
68  bool allowdetached = false,
69  ParseInfo *info = 0);
70 
71  const GA_EdgeGroup *parseEdgeGroups(const char *pat,
72  const GEO_Detail *pgdp,
73  bool strict = true,
74  GA_Index prim_offset = GA_Index(0),
75  GA_Index point_offset = GA_Index(0),
76  ParseInfo *info = 0);
77 
78  const GA_BreakpointGroup *parseBreakpointGroups(const char *pat,
79  const GEO_Detail *pgdp,
80  bool strict = true,
81  GA_Index prim_offset = GA_Index(0));
82 
83  // Always returns a detached group.
84  const GA_VertexGroup *parseVertexGroups(const char *pat,
85  const GEO_Detail *pgdp,
86  bool strict = true,
87  GA_Index prim_offset = GA_Index(0));
88  const GA_VertexGroup *parseVertexGroups(const char *pat,
89  const GEO_Detail *pgdp,
90  bool strict,
91  int prim_offset);
92 
93  const GA_Group *parseAllGroups(const char *pattern,
94  const GroupCreator &creator,
95  bool allow_numeric,
96  bool ordered,
98  GA_GroupType bestguess);
99  //
100  // Similar to above, except the caller is free to modify its contents
101  //
102 
103  GA_PrimitiveGroup *parsePrimitiveGroupsCopy(const char *pat,
104  const GroupCreator &creator,
105  bool numok = true,
106  bool ordered = false,
107  bool strict = false);
108 
109  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo and be careful since defaults have changed)
110  GA_PrimitiveGroup *parsePrimitiveGroupsCopy(const char *pat,
111  GEO_Detail *pgdp,
112  int numok = 1,
113  int ordered = 1,
114  bool strict = false,
115  bool detached = false);
116 
117  GA_PointGroup *parsePointGroupsCopy(const char *pat,
118  const GroupCreator &creator,
119  bool numok = true,
120  bool ordered = false,
121  bool strict = false);
122 
123  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo and be careful since defaults have changed)
124  GA_PointGroup *parsePointGroupsCopy(const char *pat,
125  GEO_Detail *pgdp,
126  int numok = 1,
127  int ordered = 1,
128  bool strict = false,
129  bool detached = false);
130 
131  GA_EdgeGroup *parseEdgeGroupsCopy(const char *pat,
132  const GEO_Detail *pgdp,
133  bool strict = true,
134  GA_Index prim_offset = GA_Index(0),
135  GA_Index point_offset = GA_Index(0));
136 
137  GA_BreakpointGroup *parseBreakpointGroupsCopy(const char *pat,
138  const GEO_Detail *pgdp);
139 
140  // Always returns a detached group.
141  GA_VertexGroup *parseVertexGroupsCopy(const char *pat,
142  const GEO_Detail *pgdp);
143 
144  GA_Group *parseAllGroupsCopy(const char *pattern,
145  const GroupCreator &creator,
146  bool allow_numeric,
147  bool ordered,
149  GA_GroupType bestguess);
150 
151 
152  /// Parse a guaranteed copy group suitable for
153  /// writing to. Must be done on a writable geometry.
154  /// Can replace cookInputAllGroups with allow reference false
155  /// on your own geometry.
156  GA_Group *parseGroupCopy(const char *pat,
157  GA_GroupType grouptype,
158  GEO_Detail *pgdp,
159  bool forceexistence,
160  bool ordered,
161  bool defaultprim,
162  bool &success);
163  /// Parse detached, unordered, groups.
164  /// If forceexistence is true, will always return a valid group pointer
165  /// by creating an empty group if necessary.
166  /// Success will be set to false if the group failed to be created.
167  /// The returned group may be an alias of an existing group
168  /// if the group naming is trivial
169  /// @{
170  const GA_PrimitiveGroup *parsePrimitiveDetached(const char *pat,
171  const GEO_Detail *pgdp,
172  bool forceexistence,
173  bool &success);
174  const GA_PrimitiveGroup *parsePrimitiveDetached(const char *pat,
175  const GEO_Detail *pgdp,
176  bool forceexistence,
177  bool ordered,
178  bool &success);
179  const GA_PointGroup *parsePointDetached(const char *pat,
180  const GEO_Detail *pgdp,
181  bool forceexistence,
182  bool &success);
183  const GA_PointGroup *parsePointDetached(const char *pat,
184  const GEO_Detail *pgdp,
185  bool forceexistence,
186  bool ordered,
187  bool &success);
188  const GA_EdgeGroup *parseEdgeDetached(const char *pat,
189  const GEO_Detail *pgdp,
190  bool forceexistence,
191  bool &success);
192  const GA_VertexGroup *parseVertexDetached(const char *pat,
193  const GEO_Detail *pgdp,
194  bool forceexistence,
195  bool &success);
196  const GA_Group *parseGroupDetached(const char *pat,
197  GA_GroupType grouptype,
198  const GEO_Detail *pgdp,
199  bool forceexistence,
200  bool defaultprim,
201  bool &success);
202  /// @}
203 
204  /// Parse detached, ordered, groups.
205  /// If forceexistence is true, will always return a valid group pointer
206  /// by creating an empty group if necessary.
207  /// Success will be set to false if the group failed to be created.
208  /// The returned group may be an alias of an existing group
209  /// if the group naming is trivial
210  /// @{
211  const GA_PrimitiveGroup *parseOrderedPrimitiveDetached(const char *pat,
212  const GEO_Detail *pgdp,
213  bool forceexistence,
214  bool &success);
215  const GA_PointGroup *parseOrderedPointDetached(const char *pat,
216  const GEO_Detail *pgdp,
217  bool forceexistence,
218  bool &success);
219  /// NB: Vertex groups are always unordered.
220  const GA_VertexGroup *parseOrderedVertexDetached(const char *pat,
221  const GEO_Detail *pgdp,
222  bool forceexistence,
223  bool &success);
224  /// @}
225 
226  void expandGroupMask(const char *pattern,
227  UT_String &outNames,
229  const GEO_Detail *gdp);
230 
231  // Create an ahdoc (internal) group and add it to the list of adhoc groups:
232  GA_PrimitiveGroup *createPrimitiveGroup(GEO_Detail &gdp,
233  const char *name = "adhoc",
234  bool detached = false);
235  GA_PointGroup *createPointGroup (GEO_Detail &gdp,
236  const char *name = "adhoc",
237  bool detached = false);
238  GA_EdgeGroup *createEdgeGroup (GEO_Detail &gdp,
239  const char *name = "adhoc");
240  GA_BreakpointGroup *createBreakpointGroup(const GEO_Detail &gdp,
241  const char *name = NULL);
242  GA_VertexGroup *createVertexGroup (GEO_Detail &gdp,
243  const char *name = "adhoc",
244  bool detached = false);
245 
246  // Create detached internal groups that are held by this.
247  GA_PrimitiveGroup *createDetachedPrimitiveGroup(const GEO_Detail &gdp);
248  GA_PointGroup *createDetachedPointGroup (const GEO_Detail &gdp);
249  GA_EdgeGroup *createDetachedEdgeGroup (const GEO_Detail &gdp);
250  GA_BreakpointGroup *createDetachedBreakpointGroup(const GEO_Detail &gdp);
251  GA_VertexGroup *createDetachedVertexGroup (const GEO_Detail &gdp);
252 
253  // Will return oldgroup if it is already of type newtype.
254  // May return 0 if conversion impossible.
255  // Result will be a correctly typed element group, possibly a new
256  // one created as an optionally detached group.
257  const GA_ElementGroup *convertGroupToType(GEO_Detail &gdp,
258  GA_AttributeOwner newtype,
259  const GA_Group *oldgroup,
260  bool detached = false);
261 
262  // Remove an adhoc group or all adhocs from the list and delete them:
263  int destroyAdhocGroup (const GA_Group *group);
264  void destroyAdhocGroups();
265 
266  // This will destroy all the adhoc groups that match the given gdp.
267  void destroyAdhocGroups(const GEO_Detail *gdp);
268 
269  // Remove an adhoc group or all adhocs from the list.
270  // Usually you want to call the destroy methods above to avoid headaches.
271  int removeAdhocGroup (const GA_Group *group);
272  void removeAdhocGroups();
273 
274  // TODO: These 2 functions should only be called by the parsers... should we
275  // make them private and make them friends. It doesn't really
276  // do any harm here though.
277  GA_Group *lastAdhocGroup();
278  void appendAdhocGroup(GA_Group *group, bool willbeownedbyme);
279  template <typename GroupT>
281  {
282  auto group = group_ptr.release();
283  myGroupList.append(GOP_AdhocGroup(group, /*pass_ownership*/true));
284  return group;
285  }
286 
287  // Given a base name, create a unique group name from that.
288  static void getUniqueGroupName(const char *base, UT_String &name);
289 
290  int64 getMemoryUsage(bool inclusive) const;
291 
292 private:
293  UT_Array<GOP_AdhocGroup> myGroupList;
294 };
295 
296 #endif
GOP_GroupParse::GroupCreator GroupCreator
Definition: GOP_Manager.h:35
#define SYS_DEPRECATED_HDK_REPLACE(__V__, __R__)
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
#define GOP_API
Definition: GOP_API.h:10
SYS_FORCE_INLINE const X * cast(const InstancablePtr *o)
GLint GLuint mask
Definition: glcorearb.h:124
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
GLushort pattern
Definition: glad.h:2583
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:640
GT_API const UT_StringHolder version
GA_AttributeOwner
Definition: GA_Types.h:35
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:161
GOP_GroupParse::ParseInfo ParseInfo
Definition: GOP_Manager.h:34
GroupT * appendAdhocGroup(UT_UniquePtr< GroupT > group_ptr)
Definition: GOP_Manager.h:280
GA_GroupMaskType
Definition: GA_Types.h:175
type
Definition: core.h:1059