HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_RefineList.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: GT_RefineList.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GT_RefineList__
12 #define __GT_RefineList__
13 
14 #include "GT_API.h"
15 #include "GT_Refine.h"
16 #include "GT_Primitive.h"
17 #include <UT/UT_Array.h>
18 
19 /// Refine to a list of primitives.
20 ///
21 /// When refining large numbers of primitives, you may want to refine each
22 /// primitive in turn rather than generating a full list of refined primitives.
24 {
25 public:
26  GT_RefineList();
27  ~GT_RefineList();
28 
29  /// Return the number of primitives in the list
30  int entries() const { return myList.entries(); }
31 
32  /// Return a given primitive from the list
33  const GT_PrimitiveHandle &getPrimitive(int i) const { return myList(i); }
34 
35  /// Refine a primitive, adding primitives to the list
37  { return prim->refine(myRefiner, parms); }
38 
39  /// Clear all primitives from the list
40  void clear();
41 
43  {
44  public:
46  : myOwner(NULL), myCurr(0) {}
48  { *this = src; }
49  ~iterator() {}
50 
52  {
53  return myOwner->getPrimitive(myCurr);
54  }
55  int getCurr() const
56  {
57  return myCurr;
58  }
59 
60  void rewind() { myCurr = 0; }
61  void advance() { myCurr++; }
62  bool atEnd() const { return myCurr >= myOwner->entries(); }
63 
64  iterator &operator++() { advance(); return *this; }
65  // No post increment as it is dangerous.
66  const iterator &operator=(const iterator &src)
67  {
68  myOwner = src.myOwner;
69  myCurr = src.myCurr;
70  return *this;
71  }
72 
73  private:
74  iterator(const GT_RefineList *list)
75  : myOwner(list)
76  , myCurr(0) {}
77 
78  const GT_RefineList *myOwner;
79  int myCurr;
80  friend class GT_RefineList;
81  };
82  iterator begin() const { return iterator(this); }
83 
84 private:
85  class refiner : public GT_Refine
86  {
87  public:
88  refiner(GT_RefineList &l)
89  : myOwner(l) {}
90  ~refiner() override {}
91  void addPrimitive(const GT_PrimitiveHandle &p) override
92  { myOwner.myList.append(p); }
93  GT_RefineList &myOwner;
94  };
95 
96  refiner myRefiner;
98 };
99 
100 #endif
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
#define GT_API
Definition: GT_API.h:13
int entries() const
Return the number of primitives in the list.
Definition: GT_RefineList.h:30
iterator begin() const
Definition: GT_RefineList.h:82
const iterator & operator=(const iterator &src)
Definition: GT_RefineList.h:66
bool refine(GT_Primitive *prim, const GT_RefineParms *parms)
Refine a primitive, adding primitives to the list.
Definition: GT_RefineList.h:36
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
GA_API const UT_StringHolder parms
iterator(const iterator &src)
Definition: GT_RefineList.h:47
const GT_PrimitiveHandle getPrimitive() const
Definition: GT_RefineList.h:51
const GT_PrimitiveHandle & getPrimitive(int i) const
Return a given primitive from the list.
Definition: GT_RefineList.h:33
GLenum src
Definition: glcorearb.h:1793