HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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:
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  ~GU_TrimTesselator() override;
60 
61  int64 getMemoryUsage(bool inclusive) const override;
62 
63 // These are required by the TrimBaseTesselator:
64  void reset() override;
65 
66  // Add points in counter clockwise order
67  void startPoly() override;
68  void endPoly() override;
69  void cancelPoly() override;
70  void addPolyPoint(GU_TrimBasePoint *point) override;
71 
72  // Add points two at a time:
73  void startTStrip() override;
74  void endTStrip() override;
76  GU_TrimBasePoint *p2) override;
77 
78 // And these by the convexer:
79  int getPointCount() const override;
80  void getPoint(int num, float &x, float &y) const override;
81 
82  void beginPolygon(int npoint, bool lastone) override;
83  void polyVertex(int num) override;
84  void endPolygon() override;
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  ~GU_TrimPatch() override;
125 
126  int64 getMemoryUsage(bool inclusive) const override
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  void refreshCells(
136  const GEO_TPSurf *surf,
137  int umin, int umax,
138  int vmin, int vmax) override;
139 
140  // Allows wire frame renderer to pull isoparms:
141  void startUIsoWalk(int uiso);
142  int getUIsoSpan(int &trimtype);
143  int getUIsoSpanPoint(int &point);
144 
145  void startVIsoWalk(int viso);
146  int getVIsoSpan(int &trimtype);
147  int getVIsoSpanPoint(int &point);
148 
149  void startTrimCurveWalk();
150  int getTrimCurveSpan();
151  int getTrimCurveSpanPoint(int &point);
152 
153 protected:
154  // Initializes worlddata of given point:
155  void fillPoint(GU_TrimPatchPoint *p) override;
156 
157  // Calls fill point for all normal curve values
158  // virtual void fillCurvePoints();
159 
160  // Does fwd differencing of corner values:
161  void fillCornerPoints() override;
162 
163  // Does fwd differencing of edge values (As along isoparms, can
164  // optimize...)
165  // virtual void fillEdgePoints();
166 
167 protected:
168  // Parent cache:
171 
172  // State variables for isoparm walker:
173  int myCurIsoIdx, myCurIsoOffset, myCurIsoTrim;
174  int mySpanStart, myLastWasEnd;
176  // State variables used by trim curve walker:
178  // This is the actual start, minus exterior points.
180 };
181 
182 #endif
183 
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
int64 getMemoryUsage(bool inclusive) const override
Definition: GU_TrimPatch.h:126
GU_TrimPatchPoint * myCurTrimCurveStart
Definition: GU_TrimPatch.h:179
virtual void endTStrip()=0
virtual void polyVertex(int num)=0
GLint y
Definition: glcorearb.h:103
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
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
long long int64
Definition: SYS_Types.h:116
GU_TrimPatchPoint * myCurIsoPoint
Definition: GU_TrimPatch.h:175
#define GU_API
Definition: GU_API.h:14
int operator==(const GU_TrimStrip &strip)
Definition: GU_TrimPatch.h:44
virtual void cancelPoly()=0
virtual void endPolygon()=0
GLint GLenum GLint x
Definition: glcorearb.h:409
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
GU_TrimPatchPoint * myTrimCurvePoint
Definition: GU_TrimPatch.h:177
virtual int64 getMemoryUsage(bool inclusive) const
const GEO_TPSurf * mySurf
Definition: GU_TrimPatch.h:170
string_view OIIO_UTIL_API strip(string_view str, string_view chars=string_view())
GU_TPSurfCache * myParent
Definition: GU_TrimPatch.h:169
virtual void addPolyPoint(GU_TrimBasePoint *point)=0
virtual int getPointCount() const =0
It's the sub-class responsibility to fill these out...