00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GU_TrimBasePatch_h__
00021 #define __GU_TrimBasePatch_h__
00022
00023 #include "GU_API.h"
00024 #include <UT/UT_RefArray.h>
00025
00026 class UT_BoundingRect;
00027 class GD_TrimLoop;
00028 class GEO_TPSurf;
00029 class GU_TrimCells;
00030 class GB_FloatOffsets;
00031
00032
00033
00034
00035
00036
00037
00038 class GU_API GU_TrimBasePoint {
00039 public:
00040 float u, v;
00041 void *worlddata;
00042
00043 float dist(const GU_TrimBasePoint &point) const
00044 { return SYSsqrt((u-point.u)*(u-point.u) +
00045 (v-point.v)*(v-point.v)); }
00046 };
00047
00048 enum GU_TrimPatchPointType {
00049 GU_TrimNormalPointType = 0,
00050 GU_TrimUXsectionPointType = 1,
00051 GU_TrimVXsectionPointType = 2,
00052 GU_TrimExteriorPointType = 3
00053 };
00054
00055 class GU_API GU_TrimPatchPoint : public GU_TrimBasePoint {
00056 public:
00057 GU_TrimPatchPoint *next;
00058
00059
00060 GU_TrimPatchPoint *above, *below;
00061
00062 int increasing;
00063
00064 GU_TrimPatchPointType type;
00065 int marker;
00066 };
00067
00068 class GU_API GU_TrimCornerPoint : public GU_TrimBasePoint {
00069 public:
00070 };
00071
00072
00073
00074
00075 class GU_API GU_TrimBaseTesselator {
00076 public:
00077 GU_TrimBaseTesselator() {}
00078 virtual ~GU_TrimBaseTesselator() {}
00079
00080
00081 virtual void reset() = 0;
00082
00083
00084 virtual void startPoly() = 0;
00085 virtual void endPoly() = 0;
00086 virtual void cancelPoly() = 0;
00087 virtual void addPolyPoint(GU_TrimBasePoint *point) = 0;
00088
00089
00090 virtual void startTStrip() = 0;
00091 virtual void endTStrip() = 0;
00092 virtual void addTStripPoints(GU_TrimBasePoint *p1,
00093 GU_TrimBasePoint *p2) = 0;
00094 };
00095
00096 class GU_API GU_TrimBaseRegion {
00097 public:
00098 GU_TrimBaseRegion() {}
00099 virtual ~GU_TrimBaseRegion() {}
00100
00101
00102
00103 virtual GU_TrimBaseRegion *newCurve(GU_TrimPatchPoint *point,
00104 int closed = 0) = 0;
00105
00106 virtual GU_TrimBaseRegion *addSegment(GU_TrimPatchPoint *point) = 0;
00107 virtual GU_TrimBaseRegion *addSegment(GU_TrimPatchPoint *point,
00108 int newi, int newj) = 0;
00109 virtual int endCurve(GU_TrimPatchPoint *point,
00110 int closed = 0) = 0;
00111
00112 void setOtherRegion(GU_TrimBaseRegion *other);
00113
00114 virtual void tesselate(GU_TrimBaseTesselator *tesselator)
00115 = 0;
00116
00117 virtual void getCurrentIJ(int &i, int &j) = 0;
00118 protected:
00119 virtual void setCurrentIJ(int i, int j) = 0;
00120
00121 GU_TrimBaseRegion *myOtherRegion;
00122
00123 int hasCrossedLine;
00124 };
00125
00126
00127 class GU_API GU_TrimCoreRegion : public GU_TrimBaseRegion {
00128 public:
00129 GU_TrimCoreRegion();
00130 virtual ~GU_TrimCoreRegion();
00131
00132
00133
00134 virtual GU_TrimBaseRegion *newCurve(GU_TrimPatchPoint *point,
00135 int closed = 0);
00136
00137 virtual GU_TrimBaseRegion *addSegment(GU_TrimPatchPoint *point);
00138 virtual GU_TrimBaseRegion *addSegment(GU_TrimPatchPoint *point,
00139 int forcei, int forcej);
00140
00141 virtual int endCurve(GU_TrimPatchPoint *point,
00142 int closed = 0);
00143
00144 virtual void tesselate(GU_TrimBaseTesselator *tesselator);
00145
00146 void init(GU_TrimPatchPoint **edges,
00147 GU_TrimCornerPoint *corners,
00148 float *uisos, float *visos,
00149 int divu, int divv,
00150 GD_TrimLoop *origloops);
00151
00152 virtual void getCurrentIJ(int &i, int &j)
00153 { i = curI; j = curJ; }
00154
00155
00156
00157 int getCellState(int ucell, int vcell);
00158
00159
00160 int getTrimStateAt(int uiso, int viso);
00161 protected:
00162 virtual void setCurrentIJ(int i, int j);
00163
00164 private:
00165
00166
00167
00168 void insertUIsection(int i, int j,
00169 GU_TrimPatchPoint *point, float v,
00170 int uincrease = -1);
00171 void insertVIsection(int i, int j,
00172 GU_TrimPatchPoint *point, float u,
00173 int vincrease = -1);
00174
00175
00176 float findUIsection(int i,
00177 GU_TrimPatchPoint *point,
00178 float *d = 0);
00179 float findVIsection(int j,
00180 GU_TrimPatchPoint *point,
00181 float *d = 0);
00182
00183
00184
00185 void tesselateCell(
00186 GU_TrimBaseTesselator *tesselator,
00187 int topedge, int leftedge,
00188 int topleftcorner, int &utrimmedin,
00189 int &vtrimmedin, int i, int j);
00190
00191
00192
00193
00194
00195 GU_TrimPatchPoint *findInboundPoint(int marker,
00196 int topedge, int leftedge,
00197 int topleftcorner, int side = 0,
00198 GU_TrimPatchPoint *first = 0,
00199 GU_TrimBaseTesselator *tesselator = 0,
00200 int *utrimmed = 0, int *vtrimmed = 0);
00201
00202
00203
00204
00205 GU_TrimPatchPoint **myUEdges;
00206
00207
00208
00209
00210 GU_TrimPatchPoint **myVEdges;
00211
00212
00213 GU_TrimCornerPoint *myCorners;
00214
00215 int curI, curJ;
00216
00217 int myUDiv, myVDiv;
00218
00219
00220 GU_TrimCells *myCells;
00221
00222
00223 float *myUIsoparms, *myVIsoparms;
00224 GD_TrimLoop *myOriginalTrimLoops;
00225 };
00226
00227 class GU_API GU_TrimBasePatch {
00228 public:
00229 GU_TrimBasePatch();
00230 virtual ~GU_TrimBasePatch();
00231
00232
00233 void trace( UT_FloatArray &ubreaks,
00234 UT_FloatArray &vbreaks,
00235 int uinteriordiv, int vinteriordiv,
00236 float lodc = -1);
00237
00238
00239 void tesselate(GU_TrimBaseTesselator *tesselator);
00240
00241
00242 int setTrimLoops(GD_TrimLoop *loops, float umin,
00243 float vmin, float umax, float vmax);
00244
00245 virtual void SYS_DEPRECATED refreshCells(GB_FloatOffsets *gu_farray, GEO_TPSurf *surf, int umin, int umax,
00246 int vmin, int vmax) = 0;
00247 virtual void refreshCells(GEO_AttributeHandleList *hlist, GEO_TPSurf *surf, int umin, int umax,
00248 int vmin, int vmax) = 0;
00249
00250 protected:
00251
00252 virtual void fillPoint(GU_TrimPatchPoint *p) = 0;
00253
00254
00255 virtual void fillCurvePoints();
00256
00257
00258 virtual void fillCornerPoints() = 0;
00259
00260
00261
00262 virtual void fillEdgePoints();
00263
00264
00265 void initCells();
00266 void freeCells();
00267 void freeCurves();
00268
00269
00270 void traceCurve(GD_TrimLoop *loop, float curvelod);
00271
00272 GU_TrimCoreRegion *myCoreRegion;
00273
00274
00275
00276
00277 GU_TrimPatchPoint **myEdgeListArray;
00278
00279
00280
00281
00282 GU_TrimCornerPoint *myCornerPointArray;
00283
00284
00285 GU_TrimPatchPoint *myCurveStarts;
00286
00287
00288 float *myUIsoparms, *myVIsoparms;
00289
00290 GD_TrimLoop *myTrimLoops;
00291 GD_TrimLoop *myOriginalTrimLoops;
00292
00293 int myUDiv, myVDiv;
00294 int myULod, myVLod;
00295 };
00296 #endif
00297