00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GU_PrimPoly_h__
00022 #define __GU_PrimPoly_h__
00023
00024 #include "GU_API.h"
00025 #include <UT/UT_Vector3.h>
00026 #include <GEO/GEO_PrimPoly.h>
00027 #include <GEO/GEO_PrimRBezCurve.h>
00028 #include <GEO/GEO_PrimNURBCurve.h>
00029 #include "GU_Detail.h"
00030 #include "GU_Prim.h"
00031
00032 class GEO_PrimCircle;
00033 class GEO_PrimTriBezier;
00034 class GU_PolyCache;
00035 class GU_RayCache;
00036 class GU_RayInfoHit;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class GU_API GU_PrimPoly : public GEO_PrimPoly, public GU_Primitive
00051 {
00052 public:
00053
00054 GU_PrimPoly(GU_Detail *gdp) : GEO_PrimPoly(gdp), GU_Primitive()
00055 {
00056 myDisplayCache = 0;
00057 myRayCache = 0;
00058 myPolyRayCache = 0;
00059 }
00060
00061 virtual ~GU_PrimPoly();
00062
00063 virtual void *castTo (void) const;
00064 virtual const GEO_Primitive *castToGeo(void) const;
00065
00066
00067
00068 GEO_Primitive *convert(GU_ConvertParms &parms,
00069 GB_PointGroup *usedpts = 0);
00070
00071 GEO_Primitive *convertNew(GU_ConvertParms &parms);
00072
00073 GEO_Hull *convertToSurfNew(GU_ConvertParms &parms);
00074 GEO_Hull *convertToPotatoChip(void);
00075 GEO_Hull *convertToTrim(GU_ConvertParms &parms);
00076
00077 GEO_PrimRBezCurve *convertToBezierNew(int order, int interphull = 1);
00078 GEO_PrimNURBCurve *convertToNURBNew(int order, int interphull = 1);
00079 GEO_PrimCircle *convertToCircleNew();
00080
00081
00082 GEO_PrimTriBezier *convertToTriBezier();
00083
00084
00085
00086
00087
00088
00089
00090 GU_PrimPoly *cut(float u1, float u2,
00091 int &ind1, int &ind2, int keep);
00092
00093
00094 void openAt(float u);
00095
00096
00097
00098
00099 GEO_Face *reconfigure(unsigned type, int order, int open,
00100 int nonrational) const;
00101
00102
00103 virtual void normal(const GB_AttributeRef &noff) const;
00104 virtual void normal(UT_Vector3Array &output) const;
00105
00106
00107 int isPlanar(float tolerance = 0.0001F) const;
00108
00109
00110 bool isConvex(float tolerance = 0.0001F) const;
00111
00112 virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
00113 float tmax = 1E17F, float tol = 1E-12F,
00114 float *distance = 0, UT_Vector3 *pos = 0,
00115 UT_Vector3 *nml = 0, int accurate = 0,
00116 float *u = 0, float *v = 0,
00117 int ignoretrim=1) const;
00118
00119
00120
00121
00122 virtual int intersect(GU_Primitive &prim,
00123 UT_RefArray<GU_RayInfoHit> &hitList,
00124 float tol = 0.01F, int ignoretrim=1);
00125
00126 virtual void clip(UT_Vector3 &normal, float d=0, int normalize=1,
00127 GEO_Primitive *prim=0,
00128 GB_PrimitiveGroup *clipgrp = 0);
00129
00130 void crease(UT_Vector3 &normal, float d=0, int normalize=1,
00131 int outputGroups=0,
00132 GB_PrimitiveGroup*above=0,
00133 GB_PrimitiveGroup*below=0);
00134
00135
00136
00137
00138 static GU_PrimPoly *build(GU_Detail *gudp, int npts,
00139 int open=GU_POLY_CLOSED,
00140 int appendPts=1);
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 int removeEdges(const UT_BitArray &edgemap,
00151 UT_IntArray &, bool del_bridges = true)
00152 {
00153 GEO_Face *dummy;
00154 return removeEdges(edgemap, dummy, del_bridges);
00155 }
00156
00157
00158
00159
00160 int removeEdges(const UT_BitArray &edgemap,
00161 GEO_Face *&newpoly,
00162 bool del_bridges=true);
00163
00164
00165 int removeEdges(const UT_BitArray &edgemap,
00166 UT_PtrArray<GEO_Face*> &newpoly,
00167 bool del_bridges=true);
00168
00169
00170 virtual GU_DisplayCache *getDisplayCache() const;
00171 virtual int buildDisplayCache(GU_CacheParms &parms);
00172 virtual void destroyCache();
00173 virtual void notifyCache(int type);
00174 virtual void notifyCache(int type, const GEO_Point &ppt);
00175 virtual void notifyCache(int type, const GB_PointGroup &g);
00176 virtual void notifyCache(int type, const UT_Matrix4 &xform,
00177 int push);
00178 virtual void notifyCache(int type, const UT_Vector3 &delta);
00179
00180 virtual GU_DisplayMesh *getDisplayMesh(const GB_AttributeRef &noff,
00181 float lod);
00182
00183
00184
00185 virtual GU_RayIntersect *createRayCache(int &persistent);
00186 virtual GU_RayIntersect *getRayCache() const;
00187 virtual int buildRayCache(void);
00188
00189 virtual GU_RayIntersect *createPolyRayCache(int &persistent);
00190 virtual GU_RayIntersect *getPolyRayCache() const;
00191 virtual int buildPolyRayCache(void);
00192
00193
00194
00195
00196
00197 int isWindingReversed(const GEO_PrimPoly &poly);
00198
00199 private:
00200 void create (int npts, int isopen=GU_POLY_CLOSED, int appendPts=1);
00201
00202
00203
00204 void makeClippedPoly(const UT_Vector3 &n, float d,
00205 int *vtxsides,
00206 int bothSides=0,
00207 int outputGroups = 0,
00208 GB_PrimitiveGroup *above = 0,
00209 GB_PrimitiveGroup *below = 0,
00210 GB_PrimitiveGroup *delgrp = 0);
00211
00212 void computeVertices(GEO_Face &face) const;
00213
00214 GU_PolyCache *myDisplayCache;
00215 GU_RayCache *myRayCache;
00216 GU_RayCache *myPolyRayCache;
00217 };
00218
00219 #endif