00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _GQ_Detail_h_
00019 #define _GQ_Detail_h_
00020
00021 #include "GQ_API.h"
00022 #include <UT/UT_PtrArray.h>
00023 #include <UT/UT_IntArray.h>
00024 #include <UT/UT_Plane.h>
00025 #include <UT/UT_FloatArray.h>
00026 #include <UT/UT_RefArray.h>
00027
00028 #include <GEO/GEO_Primitive.h>
00029 #include <GU/GU_RayIntersect.h>
00030 #include <GU/GU_PrimPoly.h>
00031 #include <GU/GU_Types.h>
00032 #include "GQ_Error.h"
00033
00034 class GU_Detail;
00035 class GQ_Edge;
00036 class GQ_Face;
00037 class GQ_Point;
00038 class GEO_Point;
00039 class GEO_PrimPoly;
00040 class GB_PrimitiveGroup;
00041 class GB_Edge;
00042 class GB_EdgeGroup;
00043 class UT_Vector3;
00044 class GQ_StitchParms;
00045 class GQ_SubdivideParms;
00046
00047 enum GQ_BooleanOpType {
00048 GQ_BOOLEAN_INTERSECT = 0,
00049 GQ_BOOLEAN_UNION = 1,
00050 GQ_BOOLEAN_A_MINUS_B = 2,
00051 GQ_BOOLEAN_B_MINUS_A = 3,
00052 GQ_BOOLEAN_A_EDGE = 4,
00053 GQ_BOOLEAN_B_EDGE = 5
00054 };
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 class GQ_API GQ_Detail {
00066 public:
00067 GQ_Detail(GU_Detail *gdp,
00068 GB_PrimitiveGroup * = 0,
00069 float super_point_tolerance = 1E-6);
00070 ~GQ_Detail();
00071
00072 void clearAndDestroy(void);
00073
00074 void cusp(float angle);
00075
00076
00077 void cusp(const GB_EdgeGroup &edges,
00078 bool do_cut = false);
00079
00080
00081 void clip(UT_Vector3 &norm, float distance,
00082 int normalize);
00083 int crease(UT_Vector3 &norm, float distance,
00084 int normalize, int outputGroups,
00085 GB_PrimitiveGroup *primitive_above=0,
00086 GB_PrimitiveGroup *primitive_below=0);
00087 void bricker(float sizex = 1.0, float sizey = 1.0,
00088 float sizez = 1.0, float offx = 0.0,
00089 float offy = 0.0, float offz = 0.0,
00090 float anglex = 0.0, float angley = 0.0,
00091 float anglez = 0.0);
00092 void doBoolean(const GU_Detail *A,
00093 const GU_Detail *B,
00094 GQ_BooleanOpType op,
00095 const int outputGroups = 0,
00096 const char *AgroupName = 0,
00097 const char *BgroupName = 0,
00098 int accurateAttrib = 0,
00099 int trials = 5);
00100 void smooth(int divisions, float relativeSize,
00101 float weight);
00102
00103
00104
00105
00106
00107
00108 void smoothPolygons(int iterations,
00109 GU_WeightingType type,
00110 float lambda, float mu,
00111 bool useptattrib = false,
00112 int attriboffset = -1,
00113 int attribsize = 0);
00114
00115
00116 void createEdgeWeights();
00117
00118
00119
00120
00121 void setCreaseWeight(const GEO_PrimPoly &poly,
00122 float weight);
00123
00124
00125
00126
00127 void setCreaseWeight(const GEO_PrimPoly &poly,
00128 int vtxoff=-1, int primoff=-1);
00129
00130
00131
00132 void setCreaseWeight(const GB_Edge &edge,
00133 float weight);
00134
00135
00136
00137
00138 void setCreaseWeight(const GB_Edge &gedge,
00139 int vtxoff=-1, int primoff=-1);
00140
00141
00142 float getEdgeWeight(const GB_Edge &edge);
00143 void subdivide(const GQ_SubdivideParms &parms,
00144 GB_PrimitiveGroup *nonsubdivprims);
00145 void dual();
00146 void stitch(const GQ_StitchParms &parms);
00147 int stitchEdges(GU_PrimPoly &polya,
00148 const UT_PtrArray<GU_PrimPoly *> &facea,
00149 GU_PrimPoly &polyb,
00150 const UT_PtrArray<GU_PrimPoly *> &faceb,
00151 GB_PrimitiveGroup &changedpolys,
00152 float tol, int clamp, int consolidate);
00153 void makeWire(float radius, int doSpheres,
00154 int doCaps);
00155 void buildGeometry();
00156 void buildCreases(GB_PrimitiveGroup *group = 0);
00157 void copyEdgeWeightToVertex();
00158 void unHole(int maintain);
00159 void boundary();
00160 void createCuspGroup(float, GB_PrimitiveGroup*grp);
00161 void createBoundaryGroup(GB_PrimitiveGroup &grp);
00162 void createBoundaryGroup(GB_PointGroup &grp,
00163 UT_IntArray *arr);
00164 void createBoundaryGroup(const GEO_Point *ppt,
00165 GB_PointGroup &pointgroup);
00166 void createBoundaryGroup(const GB_Edge &edge,
00167 GB_PointGroup &grp,
00168 GEO_PrimPoly *&poly);
00169
00170
00171
00172
00173 void groupEdgePoints(const GEO_Point *ppt,
00174 int depth,
00175 GB_PointGroup &point_group);
00176
00177 int isClose();
00178
00179
00180
00181
00182 void deleteAllShareEdges();
00183
00184
00185 GQ_Point *appendPoint(const GQ_Point *src=0);
00186 GQ_Edge *appendEdge();
00187 GQ_Face *appendFace(GEO_PrimPoly *poly);
00188 void removePoint(GQ_Point *p);
00189 void removePoint(int i);
00190 void removeEdge(GQ_Edge *e);
00191 void removeEdge(int i);
00192 void removeFace(GQ_Face *f);
00193 void removeFace(int i);
00194 void collapseEdgeList() { myEdges.collapse(); }
00195 void collapseFaceList() { myFaces.collapse(); }
00196 UT_PtrArray<GQ_Point *> &getPointList() { return myPoints; }
00197 const UT_PtrArray<GQ_Point *>&getPointList() const { return myPoints; }
00198 UT_PtrArray<GQ_Edge *> &getEdgeList() { return myEdges; }
00199 const UT_PtrArray<GQ_Edge *>&getEdgeList() const{ return myEdges; }
00200 UT_FloatArray &getEdgeWeights() { return myEdgeWeights; }
00201 const UT_FloatArray &getEdgeWeights() const { return myEdgeWeights; }
00202 UT_PtrArray<GQ_Face *> &getFaceList() { return myFaces; }
00203 const UT_PtrArray<GQ_Face *>&getFaceList() const{ return myFaces; }
00204 GU_Detail *getGdp() { return myGdp; }
00205 const GU_Detail *getGdp() const { return myGdp; }
00206 GU_RayIntersect *getRay() { return myRay; }
00207 void buildRay()
00208 {
00209 if (myRay) delete myRay;
00210 myRay = new GU_RayIntersect(myGdp, myGroup);
00211 }
00212 UT_IntArray &getOffsets() { return myOffsets; }
00213
00214
00215 GQ_Point *splitEdge(GQ_Edge *edge, float t);
00216 void splitEdge(GQ_Edge *edge, GQ_Detail *B);
00217 GQ_Edge *splitEdge(GQ_Edge *, GQ_Point &pt);
00218 void deleteShareEdge(GQ_Edge *edge,
00219 GB_PrimitiveGroup *deletePrimGroup=0);
00220
00221 void wireEdge(GQ_Edge *edge, float radius,
00222 int doCaps);
00223 void pointSphere(GQ_Point *pt, float radius);
00224
00225 int nEdges(void) const { return myEdges.entries();}
00226 int nFaces(void) const { return myFaces.entries();}
00227 int nPoints(void) const{return myPoints.entries();}
00228 GU_Detail *getDetail(void) const { return myGdp; }
00229
00230 int aboveOrBelow(GQ_Face *face);
00231 void markPoints(GQ_Detail *B);
00232 void markEdges(GQ_Detail *B);
00233 void markFaces(GQ_Detail *B);
00234 void markFace(GQ_Face *f, GQ_Detail *B);
00235 void markComponent(GQ_Face *f, unsigned mark);
00236 void markComponent();
00237 void buildAllSplitFaces(GQ_Detail *B);
00238 void buildSplitFaces(GQ_Face *face,
00239 GQ_Edge *edge, GQ_Detail *B);
00240 void traceIntersectEdges();
00241 void traceIntersectEdges(GQ_Edge *edge);
00242 void cleanOffsets();
00243 void setupOffsets();
00244 void deleteAllFaces(GB_PrimitiveGroup *);
00245 void deleteAllMaskFaces(unsigned mask,
00246 GB_PrimitiveGroup *);
00247 void correctAllFaceMarkings();
00248 void flipAllFaceNormals();
00249
00250
00251 void simpleDecimate(int targetPolys);
00252 void meshOptimize(float tol = 1E-5);
00253 void decCollapse(GQ_Edge *e, GB_PrimitiveGroup *);
00254 void decSplit(GQ_Edge *e);
00255 void decSwap(GQ_Edge *e);
00256
00257
00258 void save(ostream &os) const;
00259 friend ostream &operator<<(ostream &os, const GQ_Detail &d)
00260 { d.save(os); return os; }
00261
00262
00263
00264 GQ_Edge *findEdge(const GB_Edge *edge);
00265 GQ_Edge *findEdge(const GQ_Point *org, const GQ_Point *dest);
00266 GEO_Point *stepForward(const GB_Edge *edge);
00267
00268
00269
00270 GEO_Point *pickArbitraryConnectedPoint(const GEO_Point *org);
00271
00272
00273
00274 GEO_Point *rotateAboutOrigin(GB_Edge &edge, int dir);
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 GQ_Detail *duplicate() const
00296 { return new GQ_Detail(*this); }
00297
00298
00299 GEO_PrimPoly *adjacentFace(const GEO_Face &face, int edge);
00300
00301 private:
00302
00303 GQ_Detail(const GQ_Detail &);
00304
00305
00306
00307
00308 GQ_Detail &operator=(const GQ_Detail &);
00309
00310
00311 void snapToPlane(UT_Vector3 &norm, float dist);
00312 void buildSuperPoints(float distance);
00313 GQ_Edge *findEdgeToShare(GQ_Point *org, GQ_Point *dest);
00314 GB_PrimitiveGroup *convertToQuadEdge(GB_PrimitiveGroup *,
00315 float sp_tol=0.001F);
00316 void addEdgeToPt(GQ_Edge *e, GQ_Point *p);
00317 void cleanEdgeToPt(GQ_Point *p);
00318 int buildFace(GQ_Face *face);
00319 int getVertexNum(const GQ_Face *face,
00320 const GEO_Point *prevPt,
00321 const GEO_Point *pt) const;
00322 void creaseFace(GQ_Face *face, UT_Vector3 &norm,
00323 float dist,
00324 int outputGroups,
00325 GB_PrimitiveGroup *prim_above = 0,
00326 GB_PrimitiveGroup *prim_below = 0);
00327 void createCreaseFace(GQ_Edge *edge,
00328 UT_Vector3 &norm, float dist,
00329 int outputGroups,
00330 GB_PrimitiveGroup *prim_above = 0,
00331 GB_PrimitiveGroup *prim_below = 0);
00332 void addIntersectEdges(GQ_Face *face,
00333 UT_Vector3 &normal);
00334 void removeAllPossibleBridges(GQ_Face *face);
00335 GQ_Edge * removePossibleBridge(GQ_Edge *bridgeEdge,
00336 int depth = 0);
00337 void reBridge(UT_PtrArray<GQ_Edge *> &bridges);
00338 void reBridgeForCrease(UT_PtrArray<GQ_Edge *>
00339 &intersectBridges);
00340 UT_PtrArray<GQ_Face *> *split(UT_Vector3 &normal, float distance,
00341 int outputGroups = 0,
00342 GB_PrimitiveGroup *prim_above = 0,
00343 GB_PrimitiveGroup *prim_below = 0);
00344 void expandPoint(GQ_Point *pt);
00345 void plugGap(GQ_Edge *edge);
00346 void shrinkFace(GQ_Face *face, float a, float b);
00347 void unHole(GQ_Face *face, int maintain);
00348 GQ_Edge * unBridge(GQ_Edge *bridgeEdge, int maintain);
00349 void changeGeoPoint(GQ_Face *face, GEO_Point *opt,
00350 GEO_Point *npt, int all);
00351 void uniqueEdge(GQ_Edge *edge);
00352 void uniquePoint(GQ_Point *point);
00353 void cleanFace(GQ_Face *face);
00354 int twoFacesShareAllEdges(GQ_Edge *edge,
00355 GB_PrimitiveGroup *deletePrimGroup);
00356
00357
00358 void calcFacePoints(int numfaces);
00359 void calcEdgePoints(int numedges,
00360 GEO_Vertex **oldEdgeAttribs,
00361 bool smoothvertex);
00362 void calcVertexPoints(int numpoints,
00363 GEO_Vertex **oldEdgeAttribs,
00364 GB_AttributeData *newVertexAttribs,
00365 bool smoothvertex);
00366
00367
00368
00369 void copyVertexAttributeByPoint(int numpoints,
00370 GB_AttributeData *newVertexAttribs);
00371 void calcEdgeAttribs(int numedge);
00372
00373
00374 void flagVertexBoundaries();
00375 void subdivideEdges(int numedges, bool linear);
00376 void subdivideFaces(int numfaces);
00377
00378
00379 void copyVertexAttributes(int numedges);
00380
00381 void splitPolysWithMultipleHoles(GB_PrimitiveGroup *,
00382 UT_PtrArray<GQ_Point *> &);
00383 GEO_PrimPoly *findNonSubDivPolyWithEdge(const GEO_Point *,
00384 const GEO_Point *, GB_PrimitiveGroup *, int &,
00385 int &);
00386 GEO_PrimPoly *findNonSubDivPolyWithEdge(const GEO_Point *,
00387 const GEO_Point *, GB_PrimitiveGroup *);
00388 GQ_Edge *findBoundEdge(const GQ_Point *, const GQ_Point *,
00389 UT_Vector4 &, UT_Vector4 &, int &);
00390 int addSubDivBoundaryPoints(GQ_Edge *, const GQ_Point *,
00391 GB_PointGroup *);
00392 void createVirtualEdgePoints(const UT_Vector4 &,
00393 const UT_Vector4 &, GB_PointGroup *,
00394 UT_Vector4Array &);
00395 void createActualEdgePoints(const UT_Vector4 &,
00396 const UT_Vector4 &, GB_PointGroup *,
00397 GB_PointGroup *);
00398 void triangulateNonSubDivPoly(GEO_PrimPoly *,
00399 GB_PointGroup *, GB_PrimitiveGroup *,
00400 GEO_Point *, GEO_Point *, GEO_Point *, GEO_Point *,
00401 int);
00402 GEO_PrimPoly *dividePolygonContainingEdge(GB_PointGroup *,
00403 const GEO_Point *, const GEO_Point *,
00404 GB_PrimitiveGroup *, int,
00405 GEO_Point *&, GEO_Point *&);
00406 void pullHolesUsingBias(GB_PointGroup *,
00407 UT_Vector4Array &, float);
00408 void stitchHoles(GB_PointGroup *, GB_PointGroup *,
00409 GEO_PrimPoly *, int);
00410 void pullToEndPoints(GB_PointGroup *, GEO_Point *,
00411 GEO_Point *);
00412 void closeHolesAfterSubdivide(UT_PtrArray<GQ_Point *> &,
00413 GB_PrimitiveGroup *, const GQ_SubdivideParms &);
00414
00415
00416 UT_PtrArray<GQ_Edge *> myEdges;
00417 UT_FloatArray myEdgeWeights;
00418 UT_PtrArray<GQ_Point *> myEdgePoints;
00419 UT_PtrArray<GQ_Face *> myFaces;
00420 UT_PtrArray<GQ_Point *> myPoints;
00421 UT_IntArray myOffsets;
00422 GB_PrimitiveGroup *myGroup;
00423 GU_Detail *myGdp;
00424 GU_RayIntersect *myRay;
00425
00426
00427
00428
00429
00430 UT_PtrArray<GEO_Vertex *> myEdgeAttribs;
00431 UT_PtrArray<GEO_Vertex *> myFaceAttribs;
00432 };
00433
00434 #endif