HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_TrimBasePatch.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 subpatch tesselator.
9  *
10  */
11 
12 #ifndef __GU_TrimBasePatch_h__
13 #define __GU_TrimBasePatch_h__
14 
15 #include "GU_API.h"
16 #include <GA/GA_KnotVector.h>
17 
18 class GD_TrimLoop;
19 class GEO_TPSurf;
20 class GU_TrimCells;
22 
23 // Notes on terminology:
24 // left/right is increasing u values.
25 // top/bot is increasing v values.
26 // +---+---+
27 // | | | has two u divisions.
28 
30 {
31 public:
32  float u, v; // Parameteric value of point.
33  union {
36  const void *myPointer;
37  };
38  float dist(const GU_TrimBasePoint &point) const
39  { return SYSsqrt((u-point.u)*(u-point.u) +
40  (v-point.v)*(v-point.v)); }
41 };
42 
44 {
48  GU_TrimExteriorPointType = 3 // Outside of domain!
49 };
50 
52 {
53 public:
54  GU_TrimPatchPoint *next; // Next point along line.
55  // These are specific to crossing points, and null for curve
56  // tesselation points.
57  GU_TrimPatchPoint *above, *below; // prev/next on isoparm.
58  // Above is greater u/v, below is lower.
59  int increasing; // Whether crosses in increasing
60  // direction
62  int marker; // Last cell id to touch this.
63 };
64 
66 {
67 public:
68 };
69 
70 //
71 // Base class for tesselating on trim surfaces.
72 //
74 {
75 public:
78 
79  // Prepare tesselator for tesselation:
80  virtual void reset() = 0;
81 
82  // Add points in counter clockwise order
83  virtual void startPoly() = 0;
84  virtual void endPoly() = 0;
85  virtual void cancelPoly() = 0;
86  virtual void addPolyPoint(GU_TrimBasePoint *point) = 0;
87 
88  // Add points two at a time:
89  virtual void startTStrip() = 0;
90  virtual void endTStrip() = 0;
91  virtual void addTStripPoints(GU_TrimBasePoint *p1,
92  GU_TrimBasePoint *p2) = 0;
93 };
94 
96 {
97 public:
99  virtual ~GU_TrimBaseRegion() {}
100 
101  // Begins a new curve. Closed determines if we should insert the
102  // first point or assume the curve will loop back there.
103  virtual GU_TrimBaseRegion *newCurve(GU_TrimPatchPoint *point,
104  int closed = 0) = 0;
105  // Add the segment point to point->next to any edge lists it crosses.
106  virtual GU_TrimBaseRegion *addSegment(GU_TrimPatchPoint *point) = 0;
107  virtual GU_TrimBaseRegion *addSegment(GU_TrimPatchPoint *point,
108  int newi, int newj) = 0;
109  virtual int endCurve(GU_TrimPatchPoint *point,
110  int closed = 0) = 0;
111 
112  void setOtherRegion(GU_TrimBaseRegion *other);
113 
114  virtual void tesselate(GU_TrimBaseTesselator *tesselator)
115  = 0;
116 
117  virtual void getCurrentIJ(int &i, int &j) = 0;
118 protected:
119  virtual void setCurrentIJ(int i, int j) = 0;
120 
122  // Has current curve crossed a boundary line?
124 };
125 
126 
128 {
129 public:
131  virtual ~GU_TrimCoreRegion();
132 
133  virtual int64 getMemoryUsage(bool inclusive) const;
134 
135  // Begins a new curve. Closed determines if we should insert the
136  // first point or assume the curve will loop back there.
138  int closed = 0);
139  // Add the segment point to point->next to any edge lists it crosses.
142  int forcei, int forcej);
143  // Returns true if curve has crossed.
144  virtual int endCurve(GU_TrimPatchPoint *point,
145  int closed = 0);
146 
147  virtual void tesselate(GU_TrimBaseTesselator *tesselator);
148 
149  void init(GU_TrimPatchPoint **edges,
150  GU_TrimCornerPoint *corners,
151  float *uisos, float *visos,
152  int divu, int divv,
153  GD_TrimLoop *origloops);
154 
155  virtual void getCurrentIJ(int &i, int &j)
156  { i = curI; j = curJ; }
157 
158  // For cells of type 0, 2, 3 determines whether trimmed in (1) or
159  // trimmed out (0)
160  int getCellState(int ucell, int vcell);
161  // For the corner at the specified isoparms, determines if the corner
162  // is trimmed in (1) or trimmed out (0)
163  int getTrimStateAt(int uiso, int viso);
164 protected:
165  virtual void setCurrentIJ(int i, int j);
166 
167 private:
168  // Adds intersection to specified edge list (U or V edges). Position
169  // is i/j, new isect point created & inserted between point & point->next.
170  // Increasing set appropriately.
171  void insertUIsection(int i, int j,
172  GU_TrimPatchPoint *point, float v,
173  int uincrease = -1);
174  void insertVIsection(int i, int j,
175  GU_TrimPatchPoint *point, float u,
176  int vincrease = -1);
177 
178  // Returns intersection of point to point->next with i or jth isoparm.
179  float findUIsection(int i,
180  GU_TrimPatchPoint *point,
181  float *d = 0);
182  float findVIsection(int j,
183  GU_TrimPatchPoint *point,
184  float *d = 0);
185 
186  // Handles tesselation of cell w/ edges present:
187  // u/vtrimmed in set to 1 if bot/right has a present edge.
188  void tesselateCell(
189  GU_TrimBaseTesselator *tesselator,
190  int topedge, int leftedge,
191  int topleftcorner, int &utrimmedin,
192  int &vtrimmedin, int i, int j);
193 
194  // Finds next inbound point not tagged with marker in counter clockwise
195  // direction of first/side. If first NULL, looks from the end.
196  // If tesselator given, adds corner points to tesselator.
197  // Sides: 0 top, 1: left, 2: bot, 3: right
198  GU_TrimPatchPoint *findInboundPoint(int marker,
199  int topedge, int leftedge,
200  int topleftcorner, int side = 0,
202  GU_TrimBaseTesselator *tesselator = 0,
203  int *utrimmed = 0, int *vtrimmed = 0);
204 
205  // top row of edges is at 0, bottom starts at vdiv*udiv.
206  // So for edge on u isoparm i, and to right of v isoparm j,
207  // i*udiv + j is appropriate entry.
208  GU_TrimPatchPoint **myUEdges;
209 
210  // top row of edges is at 0, bottom starts at (vdiv+1)*(udiv-1).
211  // So for edge on v isoparm j, and below u isoparm i,
212  // i*(udiv+1) + j is appropriate entry.
213  GU_TrimPatchPoint **myVEdges;
214 
215  // List of all corners, see base patch for layout.
216  GU_TrimCornerPoint *myCorners;
217 
218  int curI, curJ; // Current cell number.
219  // u isoparm i, and v isoparm j give top/left edges.
220  int myUDiv, myVDiv;
221 
222  // Our strips.
223  GU_TrimCells *myCells;
224 
225  // We do not own these:
226  float *myUIsoparms, *myVIsoparms;
227  GD_TrimLoop *myOriginalTrimLoops;
228 };
229 
231 {
232 public:
234  virtual ~GU_TrimBasePatch();
235 
236  virtual int64 getMemoryUsage(bool inclusive) const;
237 
238  // Traces & preps for tesselation
239  void trace( const GA_KnotVector &ubreaks,
240  const GA_KnotVector &vbreaks,
241  int uinteriordiv, int vinteriordiv,
242  float lodc = -1);
243 
244  // Performs tesselation
245  void tesselate(GU_TrimBaseTesselator *tesselator);
246 
247  // Sets this' trim loops. This owns these.
248  int setTrimLoops(GD_TrimLoop *loops, float umin,
249  float vmin, float umax, float vmax);
250  // Updates all points lying in certain cell boundaries.
251  virtual void refreshCells(GEO_AttributeHandleList *hlist,
252  const GEO_TPSurf *surf, int umin, int umax,
253  int vmin, int vmax) = 0;
254 
255 protected:
256  // Initializes worlddata of given point:
257  virtual void fillPoint(GU_TrimPatchPoint *p) = 0;
258 
259  // Calls fill point for all normal curve values
260  virtual void fillCurvePoints();
261 
262  // Does fwd differencing of corner values:
263  virtual void fillCornerPoints() = 0;
264 
265  // Does fwd differencing of edge values (As along isoparms, can
266  // optimize...)
267  virtual void fillEdgePoints();
268 
269  // Allocates / initializes corner points/edge arrays.
270  void initCells();
271  void freeCells();
272  void freeCurves();
273 
274  // Follows a curve:
275  void traceCurve(GD_TrimLoop *loop, float curvelod);
276 
278 
279  // First ucorediv*(vcorediv+1) are edges along U isoparms,
280  // next (ucorediv+1)*vcorediv are along V isoparms. See TrimCoreRegion
281  // for order within there.
283 
284  // (vcorediv+1)*(ucorediv+1) points. The intersection of the u isoparm
285  // i with the v isoparm j is at index i*(ucorediv+1) + j
286  // The actual values will be filled out by GU_TrimCoreRegion.
288 
289  // Starting points of curves, linked via above pointers.
291 
292  // We own the following:
293  float *myUIsoparms, *myVIsoparms;
294 
297 
298  int myUDiv, myVDiv;
299  int myULod, myVLod;
300 };
301 #endif
302 
GLint first
Definition: glcorearb.h:404
GU_TrimPatchPoint * myCurveStarts
GU_TrimPatchPoint * below
GU_TrimCornerPoint * myCornerPointArray
virtual void tesselate(GU_TrimBaseTesselator *tesselator)=0
const GLdouble * v
Definition: glcorearb.h:836
virtual int endCurve(GU_TrimPatchPoint *point, int closed=0)=0
GD_TrimLoop * myTrimLoops
png_uint_32 i
Definition: png.h:2877
const void * myPointer
long long int64
Definition: SYS_Types.h:106
virtual void getCurrentIJ(int &i, int &j)
GU_TrimPatchPointType
virtual GU_TrimBaseRegion * addSegment(GU_TrimPatchPoint *point)=0
double fpreal64
Definition: SYS_Types.h:191
#define GU_API
Definition: GU_API.h:11
virtual void setCurrentIJ(int i, int j)=0
GU_TrimPatchPoint ** myEdgeListArray
virtual GU_TrimBaseRegion * newCurve(GU_TrimPatchPoint *point, int closed=0)=0
GU_TrimCoreRegion * myCoreRegion
GU_TrimPatchPointType type
virtual ~GU_TrimBaseRegion()
GU_TrimBaseRegion * myOtherRegion
GU_TrimPatchPoint * next
GD_TrimLoop * myOriginalTrimLoops
virtual ~GU_TrimBaseTesselator()
float dist(const GU_TrimBasePoint &point) const