HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_TrimPatch.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: GU library (C++)
7  *
8  * COMMENTS: Trimmed patch tesselator.
9  *
10  */
11 
12 #ifndef __GU_TrimPatch_h__
13 #define __GU_TrimPatch_h__
14 
15 #include "GU_API.h"
16 #include <UT/UT_Array.h>
17 #include <UT/UT_ValArray.h>
18 #include <UT/UT_IntArray.h>
19 #include <UT/UT_Convex.h>
20 #include "GU_TrimBasePatch.h"
21 
22 class GD_TrimLoop;
23 class GU_TPSurfCache;
24 class GEO_TPSurf;
25 
26 //
27 // Classes for storing polys/strips
28 //
30 {
31 public:
32  int operator==( const GU_TrimTriangle &tri )
33  {
34  return (myP[0] == tri.myP[0] &&
35  myP[1] == tri.myP[1] &&
36  myP[2] == tri.myP[2]);
37  }
38  int myP[3];
39 };
40 
42 {
43 public:
44  int operator==( const GU_TrimStrip &strip )
45  {
46  return (myP == strip.myP);
47  }
49 };
50 
51 
52 //
53 // Class for collecting tesselated surfaces & convexing the polys.
54 //
56  protected UT_Convex {
57 public:
59  virtual ~GU_TrimTesselator();
60 
61  virtual int64 getMemoryUsage(bool inclusive) const;
62 
63 // These are required by the TrimBaseTesselator:
64  virtual void reset();
65 
66  // Add points in counter clockwise order
67  virtual void startPoly();
68  virtual void endPoly();
69  virtual void cancelPoly();
70  virtual void addPolyPoint(GU_TrimBasePoint *point);
71 
72  // Add points two at a time:
73  virtual void startTStrip();
74  virtual void endTStrip();
75  virtual void addTStripPoints(GU_TrimBasePoint *p1,
76  GU_TrimBasePoint *p2);
77 
78 // And these by the convexer:
79  virtual int getPointCount() const;
80  virtual void getPoint(int num, float &x, float &y) const;
81 
82  virtual void beginPolygon(int npoint, bool lastone);
83  virtual void polyVertex(int num);
84  virtual void endPolygon();
85 
86 // And these by ourselves:
87  // Restart the retrieval of polygons
88  void resetRetrieval();
89 
90  // Retrieve triangles from this list: Returns 0 if non left.
91  // Returns the indices. Invoke the cache to translate into
92  // points.
93  int getTriangle(int &p1, int &p2, int &p3);
94 
95  // Returns strips.
96  int getStrip();
97  int getStripPointCount();
98  int getStripPoints(int &p1, int &p2);
99  void getStripPoint(int idx, int &p1, int &p2);
100  int nextStrip();
101 protected:
102  // Where we collect points:
104  GU_TrimBasePoint *myLastPolyPoint, *myFirstPolyPoint;
105 
106  // Where we collect triangles:
109 
110  // Where to fetch next quad/triangle from
111  int myTriIdx, myStripIdx;
113  // Used by the convexer to track state:
114  int myCurVertex, myCurPoly;
115 };
116 
117 //
118 // Tesselating a base patch.
119 //
121 {
122 public:
123  GU_TrimPatch(GU_TPSurfCache *parent, const GEO_TPSurf *surf);
124  virtual ~GU_TrimPatch();
125 
126  virtual int64 getMemoryUsage(bool inclusive) const
127  {
128  int64 mem = inclusive ? sizeof(*this) : 0;
129  mem += GU_TrimBasePatch::getMemoryUsage(false);
130  return mem;
131  }
132 
133  // Updates all points lying in certain cell boundaries.
134  virtual void refreshCells(GEO_AttributeHandleList *hlist,
135  const GEO_TPSurf *surf,
136  int umin, int umax, int vmin, int vmax);
137 
138  // Allows wire frame renderer to pull isoparms:
139  void startUIsoWalk(int uiso);
140  int getUIsoSpan(int &trimtype);
141  int getUIsoSpanPoint(int &point);
142 
143  void startVIsoWalk(int viso);
144  int getVIsoSpan(int &trimtype);
145  int getVIsoSpanPoint(int &point);
146 
147  void startTrimCurveWalk();
148  int getTrimCurveSpan();
149  int getTrimCurveSpanPoint(int &point);
150 
151 protected:
152  // Initializes worlddata of given point:
153  virtual void fillPoint(GU_TrimPatchPoint *p);
154 
155  // Calls fill point for all normal curve values
156  // virtual void fillCurvePoints();
157 
158  // Does fwd differencing of corner values:
159  virtual void fillCornerPoints();
160 
161  // Does fwd differencing of edge values (As along isoparms, can
162  // optimize...)
163  // virtual void fillEdgePoints();
164 
165 protected:
166  // Parent cache:
169 
170  // State variables for isoparm walker:
171  int myCurIsoIdx, myCurIsoOffset, myCurIsoTrim;
172  int mySpanStart, myLastWasEnd;
174  // State variables used by trim curve walker:
176  // This is the actual start, minus exterior points.
178 };
179 
180 #endif
181 
virtual void fillCornerPoints()=0
UT_IntArray myP
Definition: GU_TrimPatch.h:48
UT_ValArray< GU_TrimBasePoint * > myPolyPoints
Definition: GU_TrimPatch.h:103
virtual void addTStripPoints(GU_TrimBasePoint *p1, GU_TrimBasePoint *p2)=0
GU_TrimPatchPoint * myCurTrimCurveStart
Definition: GU_TrimPatch.h:177
virtual void endTStrip()=0
virtual void polyVertex(int num)=0
GLint y
Definition: glcorearb.h:102
virtual void endPoly()=0
virtual void beginPolygon(int npoints, bool lastone)=0
beginPolygon will be told when the last polygon is being added
virtual int64 getMemoryUsage(bool inclusive) const
int operator==(const GU_TrimTriangle &tri)
Definition: GU_TrimPatch.h:32
virtual void fillPoint(GU_TrimPatchPoint *p)=0
virtual void refreshCells(GEO_AttributeHandleList *hlist, const GEO_TPSurf *surf, int umin, int umax, int vmin, int vmax)=0
long long int64
Definition: SYS_Types.h:100
virtual void getPoint(int num, float &x, float &y) const =0
virtual void startPoly()=0
UT_Array< GU_TrimStrip > myStrips
Definition: GU_TrimPatch.h:108
GU_TrimPatchPoint * myCurIsoPoint
Definition: GU_TrimPatch.h:173
#define GU_API
Definition: GU_API.h:11
int operator==(const GU_TrimStrip &strip)
Definition: GU_TrimPatch.h:44
virtual void cancelPoly()=0
virtual void endPolygon()=0
GU_TrimBasePoint * myLastPolyPoint
Definition: GU_TrimPatch.h:104
UT_Array< GU_TrimTriangle > myTriangles
Definition: GU_TrimPatch.h:107
virtual void reset()=0
virtual void startTStrip()=0
virtual int64 getMemoryUsage(bool inclusive) const
Definition: GU_TrimPatch.h:126
GU_TrimPatchPoint * myTrimCurvePoint
Definition: GU_TrimPatch.h:175
GLint GLenum GLint x
Definition: glcorearb.h:408
virtual int64 getMemoryUsage(bool inclusive) const
const GEO_TPSurf * mySurf
Definition: GU_TrimPatch.h:168
png_infop png_uint_32 int num
Definition: png.h:2158
GU_TPSurfCache * myParent
Definition: GU_TrimPatch.h:167
virtual void addPolyPoint(GU_TrimBasePoint *point)=0
virtual int getPointCount() const =0
It's the sub-class responsibility to fill these out...