HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_VertexGroupIterator.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_VertexGroupIterator.h (GA Library, C++)
7  *
8  * COMMENTS: Allows iteration through a vertex group in primitive order,
9  * with fast access to the number of the current vertex
10  * within the current primitive.
11  *
12  */
13 
14 #ifndef __GA_VertexGroupIterator_h__
15 #define __GA_VertexGroupIterator_h__
16 
17 #include "GA_API.h"
18 
19 #include "GA_Types.h"
20 #include <UT/UT_Array.h>
21 
22 class GA_Detail;
23 class GA_Primitive;
24 class GA_VertexGroup;
25 
27 {
28 public:
30  {
31  setGroup(grp);
32  }
34 
35  void setGroup(const GA_VertexGroup *grp);
36 
37  /// @{
38  /// Interface to iteration
39  void rewind()
40  {
41  myCurrentIndex = 0;
42  }
43  bool atEnd() const
44  {
45  return myCurrentIndex >= myPrimitives.size();
46  }
47  void advance()
48  {
49  ++myCurrentIndex;
50  }
51  GA_VertexGroupIterator &operator++() { advance(); return *this; }
52  // No post inc as it is harmful.
53  /// @}
54 
55  /// Accessor to get the current primitive
56  const GA_Primitive *getPrimitive() const;
57 
58  /// Accessor to get the current primitive offset
60  {
61  return myPrimitives(myCurrentIndex);
62  }
63 
64  /// The number for the current vertex within the current primitive.
65  /// For example, the vertex offset is, @code
66  /// it.getPrimitive()->getVertexOffset(it.getPrimVertexNum());
67  /// @endcode
69  {
70  return myPrimVertexNums(myCurrentIndex);
71  }
72 
73 private:
74  const GA_Detail *myDetail;
75  UT_Array<GA_Offset> myPrimitives;
76  UT_Array<GA_Size> myPrimVertexNums;
77  exint myCurrentIndex;
78 };
79 
80 #endif
GA_Offset getPrimitiveOffset() const
Accessor to get the current primitive offset.
#define GA_API
Definition: GA_API.h:12
GA_Size getPrimVertexNum() const
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
GA_VertexGroupIterator & operator++()
GA_Size GA_Offset
Definition: GA_Types.h:617
int64 exint
Definition: SYS_Types.h:116
void setGroup(PointDataTree &tree, const PointIndexTree &indexTree, const std::vector< short > &membership, const Name &group, const bool remove=false)
Sets group membership from a PointIndexTree-ordered vector.
Definition: PointGroup.h:691
GA_VertexGroupIterator(const GA_VertexGroup *grp)
Container class for all geometry.
Definition: GA_Detail.h:95