HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
POP_ParticleIterator.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 __POP_ParticleIterator_h__
9 #define __POP_ParticleIterator_h__
10 
11 #include "POP_API.h"
12 #include <GEO/GEO_PrimPart.h>
13 
15 {
16 public:
18  {
19  myPart = part;
20  myGdp = myPart->getParent();
21  myNumPt = myPart->getNumParticles();
22  myIdx = GA_Index(0);
23  if (!atEnd())
24  myPtOff = myPart->vertexPoint(myIdx);
25  }
26 
27  bool atEnd() const
28  {
29  return myIdx >= myNumPt;
30  }
31  void advance()
32  {
33  myIdx++;
34  if (!atEnd())
35  {
36  myPtOff = myPart->vertexPoint(myIdx);
37  }
38  }
39  POP_ParticleIterator &operator++() { advance(); return *this; }
40  // No post increment as it is dangerous.
41 
43  {
44  if (atEnd())
45  return false;
46  start = myPtOff;
47  end = start+1;
48  while (1)
49  {
50  advance();
51  if (atEnd())
52  return true;
53  if (myPtOff == end)
54  {
55  // still contiguous, make sure pages match.
56  if ((end >> GA_PAGE_BITS) == (start >> GA_PAGE_BITS))
57  {
58  end++;
59  continue;
60  }
61  }
62  // Not the same, so return where we are.
63  // The current myPtOff will be picked up as the start
64  // of the next block
65  return true;
66  }
67  }
68 
69  GA_Offset getOffset() const { return myPtOff; }
70  GA_Offset operator*() const { return myPtOff; }
71 
72 protected:
78 };
79 
80 
81 #endif
POP_ParticleIterator(GEO_PrimParticle *part)
GA_Offset getOffset() const
#define POP_API
Definition: POP_API.h:10
GLuint start
Definition: glcorearb.h:474
SYS_FORCE_INLINE GEO_Detail * getParent() const
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
GA_Size GA_Offset
Definition: GA_Types.h:617
GLuint GLuint end
Definition: glcorearb.h:474
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
GA_Offset operator*() const
#define GA_PAGE_BITS
Attributes may paritition their data in pages of GA_PAGE_SIZE offsets.
Definition: GA_Types.h:199
bool blockAdvance(GA_Offset &start, GA_Offset &end)
POP_ParticleIterator & operator++()
GEO_PrimParticle * myPart