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 primtives.
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 public:
25  GT_RefineList();
26  ~GT_RefineList();
27 
28  /// Return the number of primitives in the list
29  int entries() const { return myList.entries(); }
30 
31  /// Return a given primitive from the list
32  const GT_PrimitiveHandle &getPrimitive(int i) const { return myList(i); }
33 
34  /// Refine a primitive, adding primitives to the list
35  bool refine(GT_Primitive *prim, const GT_RefineParms *parms)
36  { return prim->refine(myRefiner, parms); }
37 
38  /// Clear all primitives from the list
39  void clear();
40 
42  {
43  public:
45  : myOwner(NULL), myCurr(0) {}
47  { *this = src; }
48  ~iterator() {}
49 
51  {
52  return myOwner->getPrimitive(myCurr);
53  }
54  int getCurr() const
55  {
56  return myCurr;
57  }
58 
59  void rewind() { myCurr = 0; }
60  void advance() { myCurr++; }
61  bool atEnd() const { return myCurr >= myOwner->entries(); }
62 
63  iterator &operator++() { advance(); return *this; }
64  // No post increment as it is dangerous.
65  const iterator &operator=(const iterator &src)
66  {
67  myOwner = src.myOwner;
68  myCurr = src.myCurr;
69  return *this;
70  }
71 
72  private:
73  iterator(const GT_RefineList *list)
74  : myOwner(list)
75  , myCurr(0) {}
76 
77  const GT_RefineList *myOwner;
78  int myCurr;
79  friend class GT_RefineList;
80  };
81  iterator begin() const { return iterator(this); }
82 
83 private:
84  class refiner : public GT_Refine {
85  public:
86  refiner(GT_RefineList &l)
87  : myOwner(l) {}
88  ~refiner() {}
89  virtual void addPrimitive(const GT_PrimitiveHandle &p)
90  { myOwner.myList.append(p); }
91  GT_RefineList &myOwner;
92  };
93 
94  refiner myRefiner;
96 };
97 
98 #endif
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
#define GT_API
Definition: GT_API.h:11
int entries() const
Return the number of primitives in the list.
Definition: GT_RefineList.h:29
iterator begin() const
Definition: GT_RefineList.h:81
png_uint_32 i
Definition: png.h:2877
const iterator & operator=(const iterator &src)
Definition: GT_RefineList.h:65
bool refine(GT_Primitive *prim, const GT_RefineParms *parms)
Refine a primitive, adding primitives to the list.
Definition: GT_RefineList.h:35
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
iterator(const iterator &src)
Definition: GT_RefineList.h:46
const GT_PrimitiveHandle getPrimitive() const
Definition: GT_RefineList.h:50
const GT_PrimitiveHandle & getPrimitive(int i) const
Return a given primitive from the list.
Definition: GT_RefineList.h:32
GLenum src
Definition: glcorearb.h:1792