HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BV_LeafIterator.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: BV_LeafIterator.h
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __BV_LeafIterator_h__
12 #define __BV_LeafIterator_h__
13 
14 #include "BV_API.h"
15 #include <UT/UT_Vector3.h>
16 #include <UT/UT_Vector4.h>
17 
18 /// Iterator for leaves to be enclosed by bounding volume.
19 /// Iterator retrieves info about each leaf:
20 /// - a set of vertices forming a bounding volume for the leaf
21 /// - barycenter (centroid) of leaf
22 ///
23 /// Optionally, the iterator may be able to skip duplicate vertices - i.e.,
24 /// if leaves in the set share vertices.
26 {
27 public:
29  virtual ~BV_LeafIterator();
30 
31  /// Advance iterator to next leaf
32  void advance()
33  { advanceSubclass(); }
34  /// Random access: jump to given leaf id
35  void jump(int leafId)
36  { jumpSubclass(leafId); }
37  /// Test to see if we've passed the last leaf.
38  /// Note: returns false on the last leaf, and true if we've advanced
39  /// *past* the last leaf.
40  bool atEnd() const
41  { return atEndSubclass(); }
42  /// Reset to first leaf
43  void rewind()
44  { rewindSubclass(); }
45 
46  /// Get id of current leaf
47  int getLeafId() const
48  { return getLeafIdSubclass(); }
49  /// Get barycenter of current leaf
51  { return calcBarycenterSubclass(); }
52  /// Test if the current leaf is disabled.
53  bool isDisabled() const
54  { return isDisabledSubclass(); }
55 
56 
57  // Sub-iterator: iterate over vertices within leaf
58 
59  /// Get number of vertices bounding current leaf
61  { advanceVertexSubclass(); }
62  bool atEndVertex() const
63  { return atEndVertexSubclass(); }
64  void rewindVertex()
65  { rewindVertexSubclass(); }
66  /// Get given bounding vertex of current leaf
68  { return getVertexSubclass(); }
69  /// Gets radius to expand each vertex for calculation of the bounding
70  /// volume.
71  virtual fpreal getVertexRadius() const
72  { return 0.0f; }
73  /// Flag: hint to skip duplicate points when iterating over vertices of
74  /// leaves.
75  /// TODO: this is obsolete and possibly broken; it's also dangerous
76  /// when combined with a non-zero vertex radius. Remove it.
77  void setSkipDupVerts(bool flag)
78  { mySkipDups = flag; setSkipDupVertsSubclass(flag); }
79  bool getSkipDupVerts() const
80  { return mySkipDups; }
81 
82 
83 protected:
84  virtual void advanceSubclass() = 0;
85  virtual void jumpSubclass(int leafId) = 0;
86  virtual bool atEndSubclass() const = 0;
87  virtual void rewindSubclass() = 0;
88  virtual int getLeafIdSubclass() const = 0;
89 
90  virtual UT_Vector3 calcBarycenterSubclass() const = 0;
91  virtual bool isDisabledSubclass() const;
92 
93  virtual void advanceVertexSubclass() = 0;
94  virtual bool atEndVertexSubclass() const = 0;
95  virtual void rewindVertexSubclass() = 0;
96  virtual UT_Vector4 getVertexSubclass() const = 0;
97 
98  virtual void setSkipDupVertsSubclass(bool flag) = 0;
99 
100 private:
101  /// Disallowed.
102  /// @{
104  BV_LeafIterator &operator=(const BV_LeafIterator &);
105  /// @}
106 
107  bool mySkipDups;
108 };
109 
110 #endif
void advance()
Advance iterator to next leaf.
bool getSkipDupVerts() const
void advanceVertex()
Get number of vertices bounding current leaf.
UT_Vector4 getVertex() const
Get given bounding vertex of current leaf.
void rewind()
Reset to first leaf.
virtual fpreal getVertexRadius() const
bool isDisabled() const
Test if the current leaf is disabled.
bool atEnd() const
bool atEndVertex() const
double fpreal
Definition: SYS_Types.h:263
#define BV_API
Definition: BV_API.h:10
void jump(int leafId)
Random access: jump to given leaf id.
void setSkipDupVerts(bool flag)
int getLeafId() const
Get id of current leaf.
png_infop png_uint_32 flag
Definition: png.h:2242
UT_Vector3 calcBarycenter() const
Get barycenter of current leaf.