HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_GBPrimitiveList.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: GA_GBPrimitiveList.h ( GA Library, C++)
7  *
8  * COMMENTS: Backward compatible class to represent lists of elements
9  */
10 
11 #ifndef __GA_GBPrimitiveList__
12 #define __GA_GBPrimitiveList__
13 
14 #include "GA_API.h"
15 #include "GA_ElementGroupOrder.h"
16 #include "GA_IndexMap.h"
17 #include "GA_Types.h"
18 
19 
20 class GA_ElementGroup;
21 class GA_IndexMap;
22 class GA_Primitive;
24 
26 
28 {
29 public:
30  SYS_DEPRECATED_HDK(13.0)
31  GA_GBPrimitiveList(const GA_IndexMap &index_map);
32  SYS_DEPRECATED_HDK(13.0)
33  ~GA_GBPrimitiveList();
34 
35  //----------------------------------------------------------
36  // Methods inherited from UT_ValArray
37  //----------------------------------------------------------
38  SYS_DEPRECATED_HDK(13.0)
39  GA_Size entries() const { return myIndexMap.indexSize(); }
40 
41  //----------------------------------------------------------
42  // Methods inherited from GB_PrimitiveList
43  //----------------------------------------------------------
44  SYS_DEPRECATED_HDK(13.0)
45  void clearAndDestroy();
46 
47  SYS_DEPRECATED_HDK(13.0)
48  const GA_Primitive *rawEntry(GA_Size n) const;
49  SYS_DEPRECATED_HDK(13.0)
50  GA_Primitive *rawEntry(GA_Size n);
51 
52  SYS_DEPRECATED_HDK(13.0)
53  const GA_Primitive *rawHead() const
54  { return myIndexMap.indexSize() == 0 ? 0:rawEntry(0); }
55  SYS_DEPRECATED_HDK(13.0)
56  const GA_Primitive *rawTail() const
57  {
58  GA_Size n = myIndexMap.indexSize();
59  return n ? rawEntry(n-1) : 0;
60  }
61  SYS_DEPRECATED_HDK(13.0)
62  GA_Primitive *rawHead()
63  { return myIndexMap.indexSize() == 0 ? 0:rawEntry(0); }
64  SYS_DEPRECATED_HDK(13.0)
65  GA_Primitive *rawTail()
66  {
67  GA_Size n = myIndexMap.indexSize();
68  return n ? rawEntry(n-1) : 0;
69  }
70 
71  SYS_DEPRECATED_HDK(13.0)
72  const GA_Primitive *rawHead(const GA_ElementGroup &g) const;
73  SYS_DEPRECATED_HDK(13.0)
74  const GA_Primitive *rawTail(const GA_ElementGroup &g) const;
75  SYS_DEPRECATED_HDK(13.0)
76  GA_Primitive *rawHead(const GA_ElementGroup &g);
77  SYS_DEPRECATED_HDK(13.0)
78  GA_Primitive *rawTail(const GA_ElementGroup &g);
79 
80  /// The group overloads of rawNext()/rawPrev() have O(n^2) behavior with
81  /// ordered groups. Use the GroupIterationCache overloads to avoid this.
82 
83  const GA_Primitive *rawNext(const GA_Primitive *i) const;
84  const GA_Primitive *rawNext(const GA_Primitive *i,
85  const GA_ElementGroup &g) const;
86  GA_Primitive *rawNext(GA_Primitive *i);
87  GA_Primitive *rawNext(GA_Primitive *i, const GA_ElementGroup &g);
88 
89  const GA_Primitive *rawPrev(const GA_Primitive *i) const;
90  const GA_Primitive *rawPrev(const GA_Primitive *i,
91  const GA_ElementGroup &g) const;
92  GA_Primitive *rawPrev(GA_Primitive *i);
93  GA_Primitive *rawPrev(GA_Primitive *i, const GA_ElementGroup &g);
94 
95  /// The group overloads of rawNextMix()/rawPrevMix() have O(n^2) behavior
96  /// with ordered groups. Use the GroupIterationCache overloads to avoid
97  /// this.
98 
99  int rawHeadMix(const GA_ElementGroup &group,
100  const GA_Primitive *&elem,
101  const GA_Primitive *&sec) const;
102  int rawTailMix(const GA_ElementGroup &group,
103  const GA_Primitive *&elem,
104  const GA_Primitive *&sec) const;
105  int rawNextMix(const GA_ElementGroup &group,
106  const GA_Primitive *&elem,
107  const GA_Primitive *&sec,
108  const GA_Primitive *&newelem,
109  const GA_Primitive *&newsec) const;
110  int rawPrevMix(const GA_ElementGroup &group,
111  const GA_Primitive *&elem,
112  const GA_Primitive *&sec,
113  const GA_Primitive *&newelem,
114  const GA_Primitive *&newsec) const;
115 
116  int rawHeadMix(const GA_ElementGroup &group,
117  GA_Primitive *&elem,
118  GA_Primitive *&sec);
119  int rawTailMix(const GA_ElementGroup &group,
120  GA_Primitive *&elem,
121  GA_Primitive *&sec);
122  int rawNextMix(const GA_ElementGroup &group,
123  GA_Primitive *&elem,
124  GA_Primitive *&sec,
125  GA_Primitive *&newelem,
126  GA_Primitive *&newsec);
127  int rawPrevMix(const GA_ElementGroup &group,
128  GA_Primitive *&elem,
129  GA_Primitive *&sec,
130  GA_Primitive *&newelem,
131  GA_Primitive *&newsec);
132 
133  /// Class used to avoid O(n^2) traversal of ordered groups.
135  {
136  public:
137  GroupIterationCache() : myLastGroupIndex(-1) {}
138 
139  private:
140  /// @{
141  /// Not implemented/supported.
142  GroupIterationCache(const GroupIterationCache &);
143  GroupIterationCache &operator=(const GroupIterationCache &);
144  bool operator==(const GroupIterationCache &);
145  /// @}
146  //
147  inline bool isValid(const GA_ElementGroupOrder *,
148  const GA_Primitive *) const;
149  inline bool isValid(const GA_ElementGroupOrder *,
150  const GA_Primitive *,
151  const GA_Primitive *) const;
152 
153  GA_ElementGroupOrderIndex myLastGroupIndex;
154 
155  friend class GA_GBPrimitiveList;
156  };
157 
158  const GA_Primitive *rawHead(const GA_ElementGroup &g,
159  GroupIterationCache &cache) const;
160  const GA_Primitive *rawTail(const GA_ElementGroup &g,
161  GroupIterationCache &cache) const;
163  GroupIterationCache &cache);
165  GroupIterationCache &cache);
166 
167  const GA_Primitive *rawNext(const GA_Primitive *i,
168  const GA_ElementGroup &g,
169  GroupIterationCache &cache) const;
171  GroupIterationCache &cache);
172  const GA_Primitive *rawPrev(const GA_Primitive *i,
173  const GA_ElementGroup &g,
174  GroupIterationCache &cache) const;
176  GroupIterationCache &cache);
177 
178  int rawHeadMix(const GA_ElementGroup &group,
179  const GA_Primitive *&elem,
180  const GA_Primitive *&sec,
181  GroupIterationCache &cache) const;
182  int rawTailMix(const GA_ElementGroup &group,
183  const GA_Primitive *&elem,
184  const GA_Primitive *&seci,
185  GroupIterationCache &cache) const;
186  int rawNextMix(const GA_ElementGroup &group,
187  const GA_Primitive *&elem,
188  const GA_Primitive *&sec,
189  const GA_Primitive *&newelem,
190  const GA_Primitive *&newsec,
191  GroupIterationCache &cache) const;
192  int rawPrevMix(const GA_ElementGroup &group,
193  const GA_Primitive *&elem,
194  const GA_Primitive *&sec,
195  const GA_Primitive *&newelem,
196  const GA_Primitive *&newsec,
197  GroupIterationCache &cache) const;
198 
199  int rawHeadMix(const GA_ElementGroup &group,
200  GA_Primitive *&elem,
201  GA_Primitive *&sec,
202  GroupIterationCache &cache);
203  int rawTailMix(const GA_ElementGroup &group,
204  GA_Primitive *&elem,
205  GA_Primitive *&sec,
206  GroupIterationCache &cache);
207  int rawNextMix(const GA_ElementGroup &group,
208  GA_Primitive *&elem,
209  GA_Primitive *&sec,
210  GA_Primitive *&newelem,
211  GA_Primitive *&newsec,
212  GroupIterationCache &cache);
213  int rawPrevMix(const GA_ElementGroup &group,
214  GA_Primitive *&elem,
215  GA_Primitive *&sec,
216  GA_Primitive *&newelem,
217  GA_Primitive *&newsec,
218  GroupIterationCache &cache);
219 
220 private:
221  const GA_Primitive *getEntryByOffset(GA_Offset offset) const;
222  GA_Primitive *getEntryByOffset(GA_Offset offset);
223  bool getMixEntryByOffset(GA_Offset offset,
224  const GA_SecondaryLookupInfo *info,
225  const GA_Primitive *&elem,
226  const GA_Primitive *&sec) const;
227  bool getMixEntryByOffset(GA_Offset offset,
228  const GA_SecondaryLookupInfo *info,
229  GA_Primitive *&elem,
230  GA_Primitive *&sec);
231 
232  const GA_IndexMap &myIndexMap;
233 };
234 
235 /// T must be a sub-class of GA_Primitive
236 template <typename T>
238 {
239 public:
240  SYS_DEPRECATED_HDK(13.0)
241  explicit GA_GBPrimitiveListT(const GA_IndexMap &index_map)
242  : GA_GBPrimitiveList(index_map) {}
243 
244  //----------------------------------------------------------
245  // Methods inherited from GEO_PrimList/GD_PrimList
246  //----------------------------------------------------------
247 
248  SYS_DEPRECATED_HDK(13.0)
249  const T *entry(GA_Size n) const { return cast(rawEntry(n)); }
250  SYS_DEPRECATED_HDK(13.0)
251  T *entry(GA_Size n) { return cast(rawEntry(n)); }
252 
253  SYS_DEPRECATED_HDK(13.0)
254  const T *head() const { return cast(rawHead()); }
255  SYS_DEPRECATED_HDK(13.0)
256  T *head() { return cast(rawHead()); }
257  SYS_DEPRECATED_HDK(13.0)
258  const T *tail() const { return cast(rawTail()); }
259  SYS_DEPRECATED_HDK(13.0)
260  T *tail() { return cast(rawTail()); }
261 
262  SYS_DEPRECATED_HDK(13.0)
263  const T *head(const GA_ElementGroup &group) const
264  { return cast(rawHead(group)); }
265  SYS_DEPRECATED_HDK(13.0)
266  T *head(const GA_ElementGroup &group)
267  { return cast(rawHead(group)); }
268  SYS_DEPRECATED_HDK(13.0)
269  const T *tail(const GA_ElementGroup &group) const
270  { return cast(rawTail(group)); }
271  SYS_DEPRECATED_HDK(13.0)
272  T *tail(const GA_ElementGroup &group)
273  { return cast(rawTail(group)); }
274 
275  SYS_DEPRECATED_HDK(13.0)
276  const T *head(const GA_ElementGroup &group,
277  GroupIterationCache &cache) const
278  { return cast(rawHead(group, cache)); }
279  SYS_DEPRECATED_HDK(13.0)
280  T *head(const GA_ElementGroup &group,
281  GroupIterationCache &cache)
282  { return cast(rawHead(group, cache)); }
283  SYS_DEPRECATED_HDK(13.0)
284  const T *tail(const GA_ElementGroup &group,
285  GroupIterationCache &cache) const
286  { return cast(rawTail(group, cache)); }
287  SYS_DEPRECATED_HDK(13.0)
288  T *tail(const GA_ElementGroup &group,
289  GroupIterationCache &cache)
290  { return cast(rawTail(group, cache)); }
291 
292  /// The group overloads of next()/prev() have O(n^2) behavior with ordered
293  /// groups. Use the GroupIterationCache overloads to avoid this.
294 
295  SYS_DEPRECATED_HDK(13.0)
296  const T *next(const GA_Primitive *i) const
297  { return cast(rawNext(i)); }
298  SYS_DEPRECATED_HDK(13.0)
300  { return cast(rawNext(i)); }
301  SYS_DEPRECATED_HDK(13.0)
302  const T *next(const GA_Primitive *i, const GA_ElementGroup &g)
303  const { return cast(rawNext(i, g)); }
304  SYS_DEPRECATED_HDK(13.0)
306  { return cast(rawNext(i, g)); }
307 
308  SYS_DEPRECATED_HDK(13.0)
309  const T *next(const GA_Primitive *i, const GA_ElementGroup &g,
310  GroupIterationCache &cache) const
311  { return cast(rawNext(i, g, cache)); }
312  SYS_DEPRECATED_HDK(13.0)
314  GroupIterationCache &cache)
315  { return cast(rawNext(i, g, cache)); }
316 
317  SYS_DEPRECATED_HDK(13.0)
318  const T *prev(const GA_Primitive *i) const
319  { return cast(rawPrev(i)); }
320  SYS_DEPRECATED_HDK(13.0)
322  { return cast(rawPrev(i)); }
323  SYS_DEPRECATED_HDK(13.0)
324  const T *prev(const GA_Primitive *i, const GA_ElementGroup &g)
325  const { return cast(rawPrev(i, g)); }
326  SYS_DEPRECATED_HDK(13.0)
328  { return cast(rawPrev(i, g)); }
329 
330  SYS_DEPRECATED_HDK(13.0)
331  const T *prev(const GA_Primitive *i, const GA_ElementGroup &g,
332  GroupIterationCache &cache) const
333  { return cast(rawPrev(i, g, cache)); }
334  SYS_DEPRECATED_HDK(13.0)
336  GroupIterationCache &cache)
337  { return cast(rawPrev(i, g, cache)); }
338 
339  SYS_DEPRECATED_HDK(13.0)
340  const T *operator()(GA_Size i) const
341  { return cast(rawEntry(i)); }
342  SYS_DEPRECATED_HDK(13.0)
343  T *operator()(GA_Size i)
344  { return cast(rawEntry(i)); }
345  SYS_DEPRECATED_HDK(13.0)
346  const T *operator[](GA_Size i) const
347  { return cast(rawEntry(i)); }
348  SYS_DEPRECATED_HDK(13.0)
349  T *operator[](GA_Size i)
350  { return cast(rawEntry(i)); }
351 
352 private:
353  const T *cast(const GA_Primitive *e) const
354  { return reinterpret_cast<const T *>(e); }
355  T *cast(GA_Primitive *e) const
356  { return reinterpret_cast<T *>(e); }
357 };
358 
359 /// Both T and SEC_T must be sub-classes of GA_Primitive. Moreover, given the
360 /// use of reinterpret_cast, both classes must have the GA_Primitive portion
361 /// laid out in memory with no offset. That is, casting either T * or SEC_T *
362 /// to a GA_Primitive * should not offset the memory address.
363 template <typename T, typename SEC_T>
365 {
366 public:
367  SYS_DEPRECATED_HDK(13.0)
368  explicit GA_GBPrimitiveListWMixT(const GA_IndexMap &index_map)
369  : GA_GBPrimitiveListT<T>(index_map) {}
370 
371  //----------------------------------------------------------
372  // Methods inherited from GEO_PrimList
373  //----------------------------------------------------------
374  SYS_DEPRECATED_HDK(13.0)
376  const T *&elem, const SEC_T *&sec) const
377  { return this->rawHeadMix(group, rcast(elem), sec_rcast(sec)); }
378  SYS_DEPRECATED_HDK(13.0)
379  int headMix(const GA_ElementGroup &group, T *&elem, SEC_T *&sec)
380  { return this->rawHeadMix(group, rcast(elem), sec_rcast(sec)); }
381  SYS_DEPRECATED_HDK(13.0)
383  const T *&elem, const SEC_T *&sec) const
384  { return this->rawTailMix(group, rcast(elem), sec_rcast(sec)); }
385  SYS_DEPRECATED_HDK(13.0)
386  int tailMix(const GA_ElementGroup &group, T *&elem, SEC_T *&sec)
387  { return this->rawTailMix(group, rcast(elem), sec_rcast(sec)); }
388  SYS_DEPRECATED_HDK(13.0)
390  const T *&elem, const SEC_T *&sec,
392  { return this->rawHeadMix(group, rcast(elem), sec_rcast(sec),c); }
393  SYS_DEPRECATED_HDK(13.0)
394  int headMix(const GA_ElementGroup &group, T *&elem, SEC_T *&sec,
396  { return this->rawHeadMix(group, rcast(elem), sec_rcast(sec),c); }
397  SYS_DEPRECATED_HDK(13.0)
399  const T *&elem, const SEC_T *&sec,
401  { return this->rawTailMix(group, rcast(elem), sec_rcast(sec),c); }
402  SYS_DEPRECATED_HDK(13.0)
403  int tailMix(const GA_ElementGroup &group, T *&elem, SEC_T *&sec,
405  { return this->rawTailMix(group, rcast(elem), sec_rcast(sec),c); }
406  /// The group overloads of nextMix()/prevMix() have O(n^2) behavior with
407  /// ordered groups. Use the GroupIterationCache overloads to avoid this.
408  SYS_DEPRECATED_HDK(13.0)
410  const T *&elem, const SEC_T *&sec,
411  const T *&newelem, const SEC_T *&newsec) const
412  { return this->rawNextMix(group, rcast(elem), sec_rcast(sec),
413  rcast(newelem), sec_rcast(newsec)); }
414  SYS_DEPRECATED_HDK(13.0)
416  T *&elem, SEC_T *&sec, T *&newelem, SEC_T *&newsec)
417  { return this->rawNextMix(group, rcast(elem), sec_rcast(sec),
418  rcast(newelem), sec_rcast(newsec)); }
419  SYS_DEPRECATED_HDK(13.0)
421  const T *&elem, const SEC_T *&sec,
422  const T *&newelem, const SEC_T *&newsec) const
423  { return this->rawPrevMix(group, rcast(elem), sec_rcast(sec),
424  rcast(newelem), sec_rcast(newsec)); }
425  SYS_DEPRECATED_HDK(13.0)
427  T *&elem, SEC_T *&sec, T *&newelem, SEC_T *&newsec)
428  { return this->rawPrevMix(group, rcast(elem), sec_rcast(sec),
429  rcast(newelem), sec_rcast(newsec)); }
430  SYS_DEPRECATED_HDK(13.0)
432  const T *&elem, const SEC_T *&sec,
433  const T *&newelem, const SEC_T *&newsec,
435  { return this->rawNextMix(group, rcast(elem), sec_rcast(sec),
436  rcast(newelem), sec_rcast(newsec), c); }
437  SYS_DEPRECATED_HDK(13.0)
439  T *&elem, SEC_T *&sec, T *&newelem, SEC_T *&newsec,
441  { return this->rawNextMix(group, rcast(elem), sec_rcast(sec),
442  rcast(newelem), sec_rcast(newsec), c); }
443  SYS_DEPRECATED_HDK(13.0)
445  const T *&elem, const SEC_T *&sec,
446  const T *&newelem, const SEC_T *&newsec,
448  { return this->rawPrevMix(group, rcast(elem), sec_rcast(sec),
449  rcast(newelem), sec_rcast(newsec), c); }
450  SYS_DEPRECATED_HDK(13.0)
452  T *&elem, SEC_T *&sec, T *&newelem, SEC_T *&newsec,
454  { return this->rawPrevMix(group, rcast(elem), sec_rcast(sec),
455  rcast(newelem), sec_rcast(newsec), c); }
456 
457 
458 private:
459  /// @{
460  /// Any code instantiating this template class should ensure that the
461  /// relative memory alignment of the GA_Primitive derived types allows
462  /// the following reinterpret_cast<> usage.
463  /// TODO: Rewrite using temporaries and safer static_cast<> uses.
464  const GA_Primitive *&rcast(const T *&e) const
465  { return reinterpret_cast<const GA_Primitive *&>(e); }
466  GA_Primitive *&rcast(T *&e) const
467  { return reinterpret_cast<GA_Primitive *&>(e); }
468  const GA_Primitive *&sec_rcast(const SEC_T *&e) const
469  { return reinterpret_cast<const GA_Primitive *&>(e); }
470  GA_Primitive *&sec_rcast(SEC_T *&e) const
471  { return reinterpret_cast<GA_Primitive *&>(e); }
472  /// @}
473 };
474 
476 
477 #endif
478 
int rawTailMix(const GA_ElementGroup &group, const GA_Primitive *&elem, const GA_Primitive *&sec) const
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
const GA_Primitive * rawNext(const GA_Primitive *i) const
const GA_Primitive * rawEntry(GA_Size n) const
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:623
void
Definition: png.h:1083
const T * entry(GA_Size n) const
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
const T * head() const
GLboolean GLboolean g
Definition: glcorearb.h:1222
T must be a sub-class of GA_Primitive.
int rawNextMix(const GA_ElementGroup &group, const GA_Primitive *&elem, const GA_Primitive *&sec, const GA_Primitive *&newelem, const GA_Primitive *&newsec) const
#define GA_API
Definition: GA_API.h:14
Information necessary to lookup a secondary primitive.
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
const GA_Primitive * rawHead() const
const GA_Primitive * rawPrev(const GA_Primitive *i) const
GA_Size GA_Offset
Definition: GA_Types.h:646
int rawHeadMix(const GA_ElementGroup &group, const GA_Primitive *&elem, const GA_Primitive *&sec) const
GLdouble n
Definition: glcorearb.h:2008
GLintptr offset
Definition: glcorearb.h:665
GA_Size GA_ElementGroupOrderIndex
Class used to avoid O(n^2) traversal of ordered groups.
const T * prev(const GA_Primitive *i) const
const T * tail() const
const T * next(const GA_Primitive *i) const
int tailMix(const GA_ElementGroup &group, const T *&elem, const SEC_T *&sec) const
int rawPrevMix(const GA_ElementGroup &group, const GA_Primitive *&elem, const GA_Primitive *&sec, const GA_Primitive *&newelem, const GA_Primitive *&newsec) const
#define SYS_DEPRECATED_HDK(__V__)
int nextMix(const GA_ElementGroup &group, const T *&elem, const SEC_T *&sec, const T *&newelem, const SEC_T *&newsec) const
LeafData & operator=(const LeafData &)=delete
int prevMix(const GA_ElementGroup &group, const T *&elem, const SEC_T *&sec, const T *&newelem, const SEC_T *&newsec) const
int headMix(const GA_ElementGroup &group, const T *&elem, const SEC_T *&sec) const
const GA_Primitive * rawTail() const
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542