00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GU_Cookie__
00021 #define __GU_Cookie__
00022
00023 #include "GU_API.h"
00024 #include <UT/UT_PtrArray.h>
00025 #include <UT/UT_RefArray.h>
00026
00027 class GU_Detail;
00028 class GU_RayIntersect;
00029 class GB_PrimitiveGroup;
00030 class GB_PointGroup;
00031 class GEO_Vertex;
00032 class GEO_PrimPoly;
00033 class UT_Vector2;
00034 class UT_Thing;
00035 class UT_HashTable;
00036 class UT_Hash;
00037 class UT_SampleQuad2D;
00038 class UT_SampleTri2D;
00039
00040 class guTrimInfo;
00041 class guTrimProjection;
00042 class GU_API guIsectVal
00043 {
00044 public:
00045 int dir;
00046 UT_Vector3 pos;
00047 float loc;
00048 };
00049
00050 class GU_API GU_Cookie
00051 {
00052 public:
00053 GU_Cookie();
00054 virtual ~GU_Cookie();
00055
00056 GU_Detail *getDetail() const { return myGdp; }
00057
00058 void setGroups(const GB_PrimitiveGroup *agrp,
00059 const GB_PrimitiveGroup *bgrp,
00060 GB_PointGroup *aptgrp,
00061 GB_PointGroup *bptgrp)
00062 {
00063 myGrpA = agrp;
00064 myGrpB = bgrp;
00065 myPtGrpA = aptgrp;
00066 myPtGrpB = bptgrp;
00067 }
00068 float getTolerance() { return myTol; }
00069 void setTolerance(float tol) { myTol = tol; }
00070 void setAutoJoin(int aj) { myAutoJoin = aj; }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 void cookie(GU_Detail &gdp,
00087 int generatecrease,
00088 GB_PrimitiveGroup &aingrp,
00089 GB_PrimitiveGroup &aoutgrp,
00090 GB_PrimitiveGroup &aoverlapgrp,
00091 int aclosed,
00092 GB_PrimitiveGroup &bingrp,
00093 GB_PrimitiveGroup &boutgrp,
00094 GB_PrimitiveGroup &boverlapgrp,
00095 int bclosed,
00096 int insidetest);
00097
00098
00099
00100
00101
00102
00103 void performIsect(int primIdA, int primIdB);
00104
00105
00106
00107 void buildTrimSegments(GEO_PrimPoly *dst,
00108 GEO_PrimPoly *src);
00109 void buildTrimSegmentsCoplanar(GEO_PrimPoly *dst,
00110 GEO_PrimPoly *src,
00111 bool reverse);
00112
00113
00114 void addPointToGroup(GEO_Point *pt, GEO_PrimPoly *poly);
00115
00116
00117 GEO_Vertex *createEdgeVertex(guTrimInfo *base,
00118 int edge, float t, int dir);
00119 GEO_Vertex *createInteriorVertex(guTrimInfo *base,
00120 const UT_Vector3 &pt);
00121
00122 GEO_PrimPoly *createPoly(guTrimInfo *base,
00123 const UT_PtrArray<GEO_Vertex *> &vtxes,
00124 bool closed,
00125 bool preserve_groups = true);
00126
00127
00128
00129 void punchHole(GEO_PrimPoly *base, GEO_PrimPoly *hole);
00130
00131
00132 UT_IntArray * buildConnectivityGraph();
00133
00134 void classifyPolygons(const GB_PrimitiveGroup &originalgrp,
00135 GB_PrimitiveGroup &ingrp,
00136 GB_PrimitiveGroup &outgrp,
00137 GB_PrimitiveGroup &overlapgrp,
00138 UT_IntArray *edges,
00139 const GB_PrimitiveGroup &othergrp,
00140 GU_RayIntersect *&inter,
00141 bool insidetest,
00142 bool inter_closed);
00143
00144 protected:
00145 GU_Detail *myGdp;
00146 UT_PtrArray<guTrimInfo *> myTrimInfo;
00147
00148 UT_HashTable *myEdgeTable;
00149
00150
00151
00152
00153 GB_PointGroup *myPtGrpA, *myPtGrpB;
00154
00155 const GB_PrimitiveGroup *myGrpA, *myGrpB;
00156
00157
00158
00159
00160 UT_RefArray<guIsectVal> myIsects;
00161
00162 int myAutoJoin;
00163
00164 float myTol;
00165 };
00166
00167 #endif