00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __GU_IsectCurveSet_h__
00024 #define __GU_IsectCurveSet_h__
00025
00026 #include "GU_API.h"
00027 #include <UT/UT_PtrArray.h>
00028 #include <UT/UT_Vector4.h>
00029
00030 class UT_BoundingRect;
00031 class GB_PrimitiveGroup;
00032 class GEO_Face;
00033 class GEO_Profiles;
00034 class GEO_TPSurf;
00035 class GD_TrimLoop;
00036 class GU_IsectNode;
00037 class GU_IsectCurveSet;
00038 class GU_IsectPoint;
00039 class GU_TPSurf;
00040 class GU_Detail;
00041
00042 class GU_API GU_IsectCurve
00043 {
00044 public:
00045 GU_IsectCurve();
00046 GU_IsectCurve(int surface, GD_TrimLoop *loop);
00047 ~GU_IsectCurve();
00048
00049
00050 void append(const UT_Vector4 &point);
00051
00052
00053 void append(GU_IsectCurve &curve);
00054 void appendReverse(GU_IsectCurve &curve);
00055
00056 void prepend(GU_IsectCurve &curve);
00057 void prependReverse(GU_IsectCurve &curve);
00058
00059 void appendCopy(GU_IsectCurve &curve);
00060
00061
00062
00063 void reparameterize(const UT_Vector4 &start,
00064 const UT_Vector4 &length);
00065
00066
00067 void getArea(float &areaxy, float &areazw, int dir) const;
00068
00069
00070 void getLength(float &lengthxy, float &lengthzw) const;
00071
00072
00073
00074 float getLength(int surface) const;
00075
00076 int numPoints() const { return myNumPts; }
00077
00078
00079 void linkInto(GU_IsectCurveSet &curveset, const UT_Vector4 &tol);
00080
00081 void unLink() { myNodes[0] = myNodes[1] = 0; }
00082
00083
00084
00085 void empty();
00086
00087
00088 int isClosed() const
00089 { return (myNodes[0] && (myNodes[0] == myNodes[1])); }
00090
00091 UT_Vector4 &operator()(int i);
00092 UT_Vector4 operator()(int i) const;
00093
00094
00095
00096 int operator==(const GU_IsectCurve &curve)
00097 { return myPoints[0] == curve.myPoints[0]; }
00098
00099 GU_IsectNode *getNode(int idx) const { return myNodes[idx]; }
00100 void setNode(int idx, GU_IsectNode *node) {myNodes[idx] = node;}
00101 int getEndPoint(int idx, UT_Vector4 &pt) const;
00102 int setEndPoint(int idx, const UT_Vector4 &pt);
00103
00104
00105 void findDirection(const GU_TPSurf &surfxy,
00106 const GU_TPSurf &surfzw,
00107 int signxy = 1, int signzw = 1);
00108
00109
00110
00111
00112 int getDirection(int surfside) const
00113 { return myDirection[surfside]; }
00114 void setDirection(int surfside, int dir)
00115 { myDirection[surfside] = dir; }
00116
00117
00118
00119 GEO_Face *createSpaceCurve(GU_Detail *gdp, int surface,
00120 GEO_TPSurf *surf,
00121 GEO_TPSurf *base1, GEO_TPSurf *base2,
00122 GEO_Face *&edge1, GEO_Face *&edge2,
00123 GEO_Face *&prof1, GEO_Face *&prof2,
00124 float tol = 1e-3F) const;
00125
00126
00127
00128
00129 void createProfile(int surface, int direction,
00130 GEO_Profiles &profs,
00131 GB_PrimitiveGroup *profgroup = 0,
00132 float tol = 1e-3F) const;
00133
00134
00135 GD_TrimLoop *createTrimmedProfile(int surface, int direction,
00136 GEO_Profiles &profs,
00137 GB_PrimitiveGroup *profgroup = 0,
00138 float tol = 1e-3F) const;
00139
00140
00141 GD_TrimLoop *createTrimLoop(int surface, int direction, int parameter,
00142 float tol = 1e-3F) const;
00143
00144 private:
00145
00146 GU_IsectPoint *myPoints[2];
00147 GU_IsectPoint *myLastPoint;
00148 int myLastIndex;
00149
00150 GU_IsectNode *myNodes[2];
00151
00152
00153 int myDirection[2];
00154 int myNumPts;
00155 };
00156
00157 class GU_API GU_IsectCurveSet
00158 {
00159 protected:
00160
00161
00162
00163 int verifyNetwork() const;
00164 public:
00165 GU_IsectCurveSet();
00166 ~GU_IsectCurveSet();
00167
00168
00169
00170
00171 void merge(GU_IsectCurve *curve);
00172
00173 void merge(GU_IsectCurveSet &curveset);
00174
00175 void merge(GU_IsectCurve &curve);
00176
00177 void mergeCopy(GU_IsectCurve *curve);
00178 void mergeCopy(const GU_IsectCurveSet &curveset);
00179
00180 int isEmpty() const
00181 { return (myCurves.entries()) ? 0 : 1; }
00182 int numCurves() const { return (int)myCurves.entries(); }
00183
00184
00185 void reset();
00186 void setSurfaces(GU_TPSurf *surfxy, GU_TPSurf *surfzw)
00187 { mySurfXY = surfxy; mySurfZW = surfzw; }
00188
00189
00190
00191 void reparameterize(const UT_Vector4 &start, const UT_Vector4 &length);
00192
00193
00194
00195 GU_IsectCurve *&operator()(int i) { return myCurves((unsigned)i); }
00196 GU_IsectCurve *operator()(int i) const { return myCurves((unsigned)i); }
00197
00198
00199
00200 int operator==(const GU_IsectCurveSet &curveSet)
00201 { return myCurves == curveSet.myCurves; }
00202
00203 GU_IsectNode *findNode(const UT_Vector4 &p,
00204 const UT_Vector4 &tol) const;
00205 GU_IsectNode *findNearestNode(const UT_Vector4 &p, int surface,
00206 float tol, GU_IsectNode *ignore) const;
00207 GU_IsectNode *createNode(const UT_Vector4 &p);
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 void compact(const UT_Vector4 &tol, float looptolxy,
00218 float looptolzw, int ignoredir=1);
00219
00220
00221
00222
00223 int resolveTachnodes(int surface, float tol);
00224
00225
00226 void findCurveDirections(int signxy = 1, int signzw = 1);
00227
00228
00229
00230
00231
00232
00233
00234
00235 void generateProfiles(int surface, int trim = 0,
00236 int direction = 1,
00237 GB_PrimitiveGroup *profgroup = 0,
00238 float tol = 1e-3F,
00239 int *buildloop = 0) const;
00240
00241 #if 0
00242 void generateTrimProfs(const UT_BoundingRect &brect,
00243 int surface, int direction,
00244 float tol = 1e-3F) const;
00245 #endif
00246
00247
00248 void stretchToDomain(int surface,
00249 const UT_BoundingRect &rect, float tol);
00250
00251
00252 void cutByTrimLoops(int surface, const GD_TrimLoop *cutter,
00253 int inside = 1);
00254 private:
00255
00256 void clearNodeList();
00257
00258
00259 void buildNodeList(const UT_Vector4 &tol);
00260
00261
00262 int mergeLoops(float looptolxy, float looptolzw);
00263
00264
00265 int joinAdjacent(int ignoredir);
00266
00267
00268 UT_PtrArray<GU_IsectCurve *> myCurves;
00269
00270 GU_IsectNode *myNodes;
00271
00272 GU_TPSurf *mySurfXY, *mySurfZW;
00273 };
00274
00275 #endif