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