HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  ~GU_TrimCoreRegion() override;
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) override;
139  // Add the segment point to point->next to any edge lists it crosses.
142  int forcei, int forcej) override;
143  // Returns true if curve has crossed.
144  int endCurve(GU_TrimPatchPoint *point,
145  int closed = 0) override;
146 
147  void tesselate(
148  GU_TrimBaseTesselator *tesselator) override;
149 
150  void init(GU_TrimPatchPoint **edges,
151  GU_TrimCornerPoint *corners,
152  float *uisos, float *visos,
153  int divu, int divv,
154  GD_TrimLoop *origloops);
155 
156  void getCurrentIJ(int &i, int &j) override
157  { i = curI; j = curJ; }
158 
159  // For cells of type 0, 2, 3 determines whether trimmed in (1) or
160  // trimmed out (0)
161  int getCellState(int ucell, int vcell);
162  // For the corner at the specified isoparms, determines if the corner
163  // is trimmed in (1) or trimmed out (0)
164  int getTrimStateAt(int uiso, int viso);
165 protected:
166  void setCurrentIJ(int i, int j) override;
167 
168 private:
169  // Adds intersection to specified edge list (U or V edges). Position
170  // is i/j, new isect point created & inserted between point & point->next.
171  // Increasing set appropriately.
172  void insertUIsection(int i, int j,
173  GU_TrimPatchPoint *point, float v,
174  int uincrease = -1);
175  void insertVIsection(int i, int j,
176  GU_TrimPatchPoint *point, float u,
177  int vincrease = -1);
178 
179  // Returns intersection of point to point->next with i or jth isoparm.
180  float findUIsection(int i,
181  GU_TrimPatchPoint *point,
182  float *d = 0);
183  float findVIsection(int j,
184  GU_TrimPatchPoint *point,
185  float *d = 0);
186 
187  // Handles tesselation of cell w/ edges present:
188  // u/vtrimmed in set to 1 if bot/right has a present edge.
189  void tesselateCell(
190  GU_TrimBaseTesselator *tesselator,
191  int topedge, int leftedge,
192  int topleftcorner, int &utrimmedin,
193  int &vtrimmedin, int i, int j);
194 
195  // Finds next inbound point not tagged with marker in counter clockwise
196  // direction of first/side. If first NULL, looks from the end.
197  // If tesselator given, adds corner points to tesselator.
198  // Sides: 0 top, 1: left, 2: bot, 3: right
199  GU_TrimPatchPoint *findInboundPoint(int marker,
200  int topedge, int leftedge,
201  int topleftcorner, int side = 0,
203  GU_TrimBaseTesselator *tesselator = 0,
204  int *utrimmed = 0, int *vtrimmed = 0);
205 
206  // top row of edges is at 0, bottom starts at vdiv*udiv.
207  // So for edge on u isoparm i, and to right of v isoparm j,
208  // i*udiv + j is appropriate entry.
209  GU_TrimPatchPoint **myUEdges;
210 
211  // top row of edges is at 0, bottom starts at (vdiv+1)*(udiv-1).
212  // So for edge on v isoparm j, and below u isoparm i,
213  // i*(udiv+1) + j is appropriate entry.
214  GU_TrimPatchPoint **myVEdges;
215 
216  // List of all corners, see base patch for layout.
217  GU_TrimCornerPoint *myCorners;
218 
219  int curI, curJ; // Current cell number.
220  // u isoparm i, and v isoparm j give top/left edges.
221  int myUDiv, myVDiv;
222 
223  // Our strips.
224  GU_TrimCells *myCells;
225 
226  // We do not own these:
227  float *myUIsoparms, *myVIsoparms;
228  GD_TrimLoop *myOriginalTrimLoops;
229 };
230 
232 {
233 public:
235  virtual ~GU_TrimBasePatch();
236 
237  virtual int64 getMemoryUsage(bool inclusive) const;
238 
239  // Traces & preps for tesselation
240  void trace( const GA_KnotVector &ubreaks,
241  const GA_KnotVector &vbreaks,
242  int uinteriordiv, int vinteriordiv,
243  float lodc = -1);
244 
245  // Performs tesselation
246  void tesselate(GU_TrimBaseTesselator *tesselator);
247 
248  // Sets this' trim loops. This owns these.
249  int setTrimLoops(GD_TrimLoop *loops, float umin,
250  float vmin, float umax, float vmax);
251  // Updates all points lying in certain cell boundaries.
252  virtual void refreshCells(GEO_AttributeHandleList *hlist,
253  const GEO_TPSurf *surf, int umin, int umax,
254  int vmin, int vmax) = 0;
255 
256 protected:
257  // Initializes worlddata of given point:
258  virtual void fillPoint(GU_TrimPatchPoint *p) = 0;
259 
260  // Calls fill point for all normal curve values
261  virtual void fillCurvePoints();
262 
263  // Does fwd differencing of corner values:
264  virtual void fillCornerPoints() = 0;
265 
266  // Does fwd differencing of edge values (As along isoparms, can
267  // optimize...)
268  virtual void fillEdgePoints();
269 
270  // Allocates / initializes corner points/edge arrays.
271  void initCells();
272  void freeCells();
273  void freeCurves();
274 
275  // Follows a curve:
276  void traceCurve(GD_TrimLoop *loop, float curvelod);
277 
279 
280  // First ucorediv*(vcorediv+1) are edges along U isoparms,
281  // next (ucorediv+1)*vcorediv are along V isoparms. See TrimCoreRegion
282  // for order within there.
284 
285  // (vcorediv+1)*(ucorediv+1) points. The intersection of the u isoparm
286  // i with the v isoparm j is at index i*(ucorediv+1) + j
287  // The actual values will be filled out by GU_TrimCoreRegion.
289 
290  // Starting points of curves, linked via above pointers.
292 
293  // We own the following:
294  float *myUIsoparms, *myVIsoparms;
295 
298 
299  int myUDiv, myVDiv;
300  int myULod, myVLod;
301 };
302 #endif
303 
GLint first
Definition: glcorearb.h:405
void getCurrentIJ(int &i, int &j) override
GU_TrimPatchPoint * myCurveStarts
GU_TrimPatchPoint * below
GU_TrimCornerPoint * myCornerPointArray
virtual void tesselate(GU_TrimBaseTesselator *tesselator)=0
const GLdouble * v
Definition: glcorearb.h:837
virtual int endCurve(GU_TrimPatchPoint *point, int closed=0)=0
GD_TrimLoop * myTrimLoops
const void * myPointer
double fpreal64
Definition: SYS_Types.h:201
GLboolean reset
Definition: glad.h:5138
GU_TrimPatchPointType
virtual GU_TrimBaseRegion * addSegment(GU_TrimPatchPoint *point)=0
long long int64
Definition: SYS_Types.h:116
#define GU_API
Definition: GU_API.h:14
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
GLint j
Definition: glad.h:2733
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