HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_GBIterators.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_GBIterators.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GA_GBIterators__
12 #define __GA_GBIterators__
13 
14 #include "GA_API.h"
15 #include "GA_Iterator.h"
16 #include "GA_Range.h"
17 
18 class GA_Detail;
19 class GA_IndexMap;
20 class GA_Primitive;
21 class GA_PrimitiveGroup;
22 
23 
24 namespace GA_PrimCompat { class TypeMask; }
25 
26 
27 /// @file GA_GBIterators.h
28 /// @brief Contains iterators to help backward compatibility with GB library.
29 /// The constructors will initialize the iterator for the first iteration (i.e.
30 /// getPrimitive(), getNextPrimitive() will return the first and second
31 /// primitive in the iteration. advance() will advance the iterator.
32 /// @see GA_GBMacros.h
33 
35 {
36 public:
37  /// Iterate over all primitives
38  explicit GA_GBPrimitiveIterator(const GA_Detail &gdp);
41 
42  /// Iterate over all points from the given prim till the last in the list
44  const GA_Detail &gdp, const GA_Primitive *first,
45  const GA_Primitive *last);
46 
47  /// Iterate over all primitives in group (group is optional)
49  const GA_Detail &gdp, const GA_PrimitiveGroup *group);
51  const GA_Detail &gdp, const GA_PrimitiveGroup *group,
53 
54  /// Iterate over all primitives whose obsolete primitive ids match the
55  /// given mask
57  const GA_Detail &gdp, const GA_PrimCompat::TypeMask &mask);
58 
59 #if 0
60  /// Iterate over all primitives included by the family mask
61  /// This also allows the GB macros to be mis-used. For example: @code
62  /// GA_FOR_MASK_PRIMITIVES(gdp, prim, GEO_PRIMPOLY)
63  /// @endcode
64  /// which is obviously invalid code.
65  GA_GBPrimitiveIterator(const GA_Detail &gdp, uint family_mask);
66 #endif
67 
68  /// Iterate over pairs of primitives - groups are optional
70  const GA_Detail &gdp1, const GA_PrimitiveGroup *group1,
71  const GA_Detail &gdp2, const GA_PrimitiveGroup *group2);
72 
73  /// Destructor
75 
76  /// Return the current primitive (NULL if complete)
77  GA_Primitive *getPrimitive() const { return myP1; }
78  /// Return the next primitive (NULL if no valid primitive)
79  GA_Primitive *getNextPrimitive() const { return myN1; }
80 
81  /// Return the current primitive from the 2nd detail (NULL if complete)
82  GA_Primitive *getPrimitive2() const { return myP2; }
83  /// Return the next primitive from the 2nd detail
84  GA_Primitive *getNextPrimitive2() const { return myN2; }
85 
86  /// Advance to next iteration
87  void advance();
88 
89  /// Increment operator calls advance() to move to the next element
90  GA_GBPrimitiveIterator &operator++() { advance(); return *this; }
91 
92  // No post inc as it is harmful.
93 
94 private:
95  void setNext();
96  bool atEnd() const
97  {
98  return myI1.atEnd() ||
99  (myI2.isValid() && myI2.atEnd());
100  }
101  const GA_IndexMap *myIndex1, *myIndex2;
102  GA_Iterator myI1, myI2; // Iterators
103  GA_Primitive *myP1, *myP2; // Current primitive
104  GA_Primitive *myN1, *myN2; // Next primitives
105 };
106 
107 #endif
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
GLint first
Definition: glcorearb.h:405
GA_Primitive * getNextPrimitive2() const
Return the next primitive from the 2nd detail.
Iteration over a range of elements.
Definition: GA_Iterator.h:29
GA_GBPrimitiveIterator & operator++()
Increment operator calls advance() to move to the next element.
#define GA_API
Definition: GA_API.h:14
GA_Primitive * getPrimitive() const
Return the current primitive (NULL if complete)
GLint GLuint mask
Definition: glcorearb.h:124
GA_Primitive * getNextPrimitive() const
Return the next primitive (NULL if no valid primitive)
Container class for all geometry.
Definition: GA_Detail.h:96
unsigned int uint
Definition: SYS_Types.h:45
GA_Primitive * getPrimitive2() const
Return the current primitive from the 2nd detail (NULL if complete)