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  const GA_VertexGroup *parseVertexGroups(const char *pat,
93  const GEO_Detail *pgdp,
94  bool ordered,
95  bool strict,
96  GA_Index prim_offset);
97 
98  const GA_Group *parseAllGroups(const char *pattern,
99  const GroupCreator &creator,
100  bool allow_numeric,
101  bool ordered,
103  GA_GroupType bestguess);
104  //
105  // Similar to above, except the caller is free to modify its contents
106  //
107 
108  GA_PrimitiveGroup *parsePrimitiveGroupsCopy(const char *pat,
109  const GroupCreator &creator,
110  bool numok = true,
111  bool ordered = false,
112  bool strict = false);
113 
114  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)
115  GA_PrimitiveGroup *parsePrimitiveGroupsCopy(const char *pat,
116  GEO_Detail *pgdp,
117  int numok = 1,
118  int ordered = 1,
119  bool strict = false,
120  bool detached = false);
121 
122  GA_PointGroup *parsePointGroupsCopy(const char *pat,
123  const GroupCreator &creator,
124  bool numok = true,
125  bool ordered = false,
126  bool strict = false);
127 
128  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)
129  GA_PointGroup *parsePointGroupsCopy(const char *pat,
130  GEO_Detail *pgdp,
131  int numok = 1,
132  int ordered = 1,
133  bool strict = false,
134  bool detached = false);
135 
136  GA_EdgeGroup *parseEdgeGroupsCopy(const char *pat,
137  const GEO_Detail *pgdp,
138  bool strict = true,
139  GA_Index prim_offset = GA_Index(0),
140  GA_Index point_offset = GA_Index(0));
141 
142  GA_BreakpointGroup *parseBreakpointGroupsCopy(const char *pat,
143  const GEO_Detail *pgdp);
144 
145  // Always returns a detached group.
146  GA_VertexGroup *parseVertexGroupsCopy(const char *pat,
147  const GEO_Detail *pgdp,
148  bool ordered = false);
149 
150  GA_Group *parseAllGroupsCopy(const char *pattern,
151  const GroupCreator &creator,
152  bool allow_numeric,
153  bool ordered,
155  GA_GroupType bestguess);
156 
157 
158  /// Parse a guaranteed copy group suitable for
159  /// writing to. Must be done on a writable geometry.
160  /// Can replace cookInputAllGroups with allow reference false
161  /// on your own geometry.
162  GA_Group *parseGroupCopy(const char *pat,
163  GA_GroupType grouptype,
164  GEO_Detail *pgdp,
165  bool forceexistence,
166  bool ordered,
167  bool defaultprim,
168  bool &success);
169  /// Parse detached, unordered, groups.
170  /// If forceexistence is true, will always return a valid group pointer
171  /// by creating an empty group if necessary.
172  /// Success will be set to false if the group failed to be created.
173  /// The returned group may be an alias of an existing group
174  /// if the group naming is trivial
175  /// @{
176  const GA_PrimitiveGroup *parsePrimitiveDetached(const char *pat,
177  const GEO_Detail *pgdp,
178  bool forceexistence,
179  bool &success);
180  const GA_PrimitiveGroup *parsePrimitiveDetached(const char *pat,
181  const GEO_Detail *pgdp,
182  bool forceexistence,
183  bool ordered,
184  bool &success);
185  const GA_PointGroup *parsePointDetached(const char *pat,
186  const GEO_Detail *pgdp,
187  bool forceexistence,
188  bool &success);
189  const GA_PointGroup *parsePointDetached(const char *pat,
190  const GEO_Detail *pgdp,
191  bool forceexistence,
192  bool ordered,
193  bool &success);
194  const GA_EdgeGroup *parseEdgeDetached(const char *pat,
195  const GEO_Detail *pgdp,
196  bool forceexistence,
197  bool &success);
198  const GA_VertexGroup *parseVertexDetached(const char *pat,
199  const GEO_Detail *pgdp,
200  bool forceexistence,
201  bool &success);
202  const GA_VertexGroup *parseVertexDetached(const char *pat,
203  const GEO_Detail *pgdp,
204  bool forceexistence,
205  bool ordered,
206  bool &success);
207  const GA_Group *parseGroupDetached(const char *pat,
208  GA_GroupType grouptype,
209  const GEO_Detail *pgdp,
210  bool forceexistence,
211  bool defaultprim,
212  bool &success);
213  /// @}
214 
215  /// Parse detached, ordered, groups.
216  /// If forceexistence is true, will always return a valid group pointer
217  /// by creating an empty group if necessary.
218  /// Success will be set to false if the group failed to be created.
219  /// The returned group may be an alias of an existing group
220  /// if the group naming is trivial
221  /// @{
222  const GA_PrimitiveGroup *parseOrderedPrimitiveDetached(const char *pat,
223  const GEO_Detail *pgdp,
224  bool forceexistence,
225  bool &success);
226  const GA_PointGroup *parseOrderedPointDetached(const char *pat,
227  const GEO_Detail *pgdp,
228  bool forceexistence,
229  bool &success);
230  const GA_VertexGroup *parseOrderedVertexDetached(const char *pat,
231  const GEO_Detail *pgdp,
232  bool forceexistence,
233  bool &success);
234  /// @}
235 
236  void expandGroupMask(const char *pattern,
237  UT_String &outNames,
239  const GEO_Detail *gdp);
240 
241  // Create an ahdoc (internal) group and add it to the list of adhoc groups:
242  GA_PrimitiveGroup *createPrimitiveGroup(GEO_Detail &gdp,
243  const char *name = "adhoc",
244  bool detached = false);
245  GA_PointGroup *createPointGroup (GEO_Detail &gdp,
246  const char *name = "adhoc",
247  bool detached = false);
248  GA_EdgeGroup *createEdgeGroup (GEO_Detail &gdp,
249  const char *name = "adhoc");
250  GA_BreakpointGroup *createBreakpointGroup(const GEO_Detail &gdp,
251  const char *name = NULL);
252  GA_VertexGroup *createVertexGroup (GEO_Detail &gdp,
253  const char *name = "adhoc",
254  bool detached = false);
255 
256  // Create detached internal groups that are held by this.
257  GA_PrimitiveGroup *createDetachedPrimitiveGroup(const GEO_Detail &gdp);
258  GA_PointGroup *createDetachedPointGroup (const GEO_Detail &gdp);
259  GA_EdgeGroup *createDetachedEdgeGroup (const GEO_Detail &gdp);
260  GA_BreakpointGroup *createDetachedBreakpointGroup(const GEO_Detail &gdp);
261  GA_VertexGroup *createDetachedVertexGroup (const GEO_Detail &gdp);
262 
263  // Will return oldgroup if it is already of type newtype.
264  // May return 0 if conversion impossible.
265  // Result will be a correctly typed element group, possibly a new
266  // one created as an optionally detached group.
267  const GA_ElementGroup *convertGroupToType(GEO_Detail &gdp,
268  GA_AttributeOwner newtype,
269  const GA_Group *oldgroup,
270  bool detached = false);
271 
272  // Remove an adhoc group or all adhocs from the list and delete them:
273  int destroyAdhocGroup (const GA_Group *group);
274  void destroyAdhocGroups();
275 
276  // This will destroy all the adhoc groups that match the given gdp.
277  void destroyAdhocGroups(const GEO_Detail *gdp);
278 
279  // Remove an adhoc group or all adhocs from the list.
280  // Usually you want to call the destroy methods above to avoid headaches.
281  int removeAdhocGroup (const GA_Group *group);
282  void removeAdhocGroups();
283 
284  // TODO: These 2 functions should only be called by the parsers... should we
285  // make them private and make them friends. It doesn't really
286  // do any harm here though.
287  GA_Group *lastAdhocGroup();
288  void appendAdhocGroup(GA_Group *group, bool willbeownedbyme);
289  template <typename GroupT>
291  {
292  auto group = group_ptr.release();
293  myGroupList.append(GOP_AdhocGroup(group, /*pass_ownership*/true));
294  return group;
295  }
296 
297  // Given a base name, create a unique group name from that.
298  static void getUniqueGroupName(const char *base, UT_String &name);
299 
300  int64 getMemoryUsage(bool inclusive) const;
301 
302 private:
303  UT_Array<GOP_AdhocGroup> myGroupList;
304 };
305 
306 #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
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
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:647
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:167
GOP_GroupParse::ParseInfo ParseInfo
Definition: GOP_Manager.h:34
GroupT * appendAdhocGroup(UT_UniquePtr< GroupT > group_ptr)
Definition: GOP_Manager.h:290
GA_GroupMaskType
Definition: GA_Types.h:182