00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GU_TPSurf_h__
00022 #define __GU_TPSurf_h__
00023
00024 #include "GU_API.h"
00025 #include <GEO/GEO_TPSurf.h>
00026 #include "GU_Prim.h"
00027
00028 class UT_FloatArray;
00029 class UT_Vector2;
00030 class UT_Vector3;
00031 class UT_Vector3Array;
00032 class UT_Vector4Array;
00033 class UT_LinkList;
00034 class GD_Primitive;
00035 class GEO_Face;
00036 class GEO_Curve;
00037 class GU_TPSurfCache;
00038 class GU_PrimPoly;
00039 class GU_RayCache;
00040 class GU_RayInfo;
00041 class GU_Detail;
00042 class GU_TPSurf;
00043 class GU_ConvertMethod;
00044 class GU_IsectCurveSet;
00045
00046
00047 typedef int (GU_TPSurf::*GU_PFP)(UT_Vector3 &, float&, float&,
00048 const UT_Vector3 &);
00049
00050 class GU_API GU_ProjectParms
00051 {
00052 public:
00053 GU_ProjectParms();
00054
00055 int type;
00056
00057 UT_Vector3 axis;
00058 int fnorm;
00059 int side;
00060 int sdivs;
00061 float rtol;
00062 float ftol;
00063 float uvgap;
00064 int sharp;
00065 int order;
00066 int ignoretrim;
00067 int algebraic;
00068
00069 UT_Axis3::axis uaxis;
00070 UT_Axis3::axis vaxis;
00071 int range;
00072 float umin;
00073 float umax;
00074 float vmin;
00075 float vmax;
00076 int unif;
00077 };
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 class GU_API GU_TPSurf : public GU_Primitive
00088 {
00089 public:
00090 ~GU_TPSurf();
00091
00092
00093
00094 GEO_Primitive *convert(GU_ConvertParms &parms,
00095 GB_PointGroup *usedpts = 0);
00096 GEO_Primitive *convertNew(GU_ConvertParms &parms);
00097
00098 virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
00099 float tmax = 1E17F, float tol = 1E-12F,
00100 float *distance = 0, UT_Vector3 *pos = 0,
00101 UT_Vector3 *nml = 0, int accurate = 0,
00102 float *u = 0, float *v = 0,
00103 int ignoretrim = 1) const;
00104 int intersectSurf(GU_Primitive &prim,
00105 GU_IsectCurveSet &curveset,
00106 float worldtol = 1e-4F,
00107 float domaintol = 1e-2F,
00108 int steps = 100,
00109 int docompact = 1);
00110 int doesIntersect(GU_Primitive &prim,
00111 float worldtol = 1e-4F, int nontrivial = 0);
00112
00113
00114
00115
00116
00117 int rayHit(const UT_Vector3 &o, const UT_Vector3 &dir,
00118 GU_RayInfo &hitinfo) const;
00119
00120
00121
00122
00123 virtual GEO_Hull *reconfigure(unsigned type, int orderu, int orderv,
00124 int openu, int openv,
00125 int endsu, int endsv) const = 0;
00126
00127 void normal(int noff) const;
00128 void normal(UT_Vector3Array &output) const;
00129
00130
00131
00132 virtual GEO_Curve *buildRowCurve(int appendPoints = 1,
00133 GU_Detail *parent = 0) const = 0;
00134 virtual GEO_Curve *buildColCurve(int appendPoints = 1,
00135 GU_Detail *parent = 0) const = 0;
00136
00137
00138
00139
00140
00141 GEO_Curve *extractUIsoparm(float u, int uoffset=-1,
00142 GU_Detail *parent=0) const;
00143 GEO_Curve *extractUIsoparmWAttrib(float u,
00144 const GB_FloatOffsets &foffsets,
00145 int uoffset=-1) const;
00146 GEO_Curve *extractUIsoparm(float u, GEO_AttributeHandleList &hl,
00147 int uoffset=-1, GU_Detail *parent=0) const;
00148 GEO_Curve *extractVIsoparm(float v, int voffset=-1,
00149 GU_Detail *parent=0) const;
00150 GEO_Curve *extractVIsoparmWAttrib(float v,
00151 const GB_FloatOffsets &foffsets,
00152 int voffset=-1) const;
00153 GEO_Curve *extractVIsoparm(float u, GEO_AttributeHandleList &hl,
00154 int uoffset=-1, GU_Detail *parent=0) const;
00155
00156
00157 GEO_Curve *extractU(float unitu, GU_Detail *parent=0);
00158 GEO_Curve *extractV(float unitv, GU_Detail *parent=0);
00159
00160
00161
00162
00163
00164
00165 int project(const GEO_Face &f, const GU_ProjectParms &p);
00166 int project(const GB_PrimitiveGroup &faces,
00167 const GU_ProjectParms &p, GU_Detail *gdp = 0);
00168
00169
00170
00171
00172
00173
00174
00175
00176 GEO_Curve *extract(const GD_Primitive &profile, int smooth = 1,
00177 int sdivs = 20, float tol = 0.001F,
00178 int sharp = 1, int order = 4,
00179 int only_first_visible_part = 0) const;
00180 GEO_Face *extract(const GD_Primitive &profile, float z=0) const;
00181
00182
00183 virtual GU_DisplayCache *getDisplayCache(void) const;
00184 virtual int buildDisplayCache(GU_CacheParms &parms);
00185
00186 virtual GU_DisplayMesh *getDisplayMesh(int, float);
00187
00188 virtual GU_RayIntersect *getRayCache(void) const;
00189 virtual int buildRayCache(void);
00190
00191
00192
00193 virtual GU_RayIntersect *createRayCache(int &persistent);
00194
00195 virtual void destroyCache(void);
00196 virtual void notifyCache(int type);
00197 virtual void notifyCache(int type, const GEO_Point &ppt);
00198 virtual void notifyCache(int type, const GB_PointGroup &grp);
00199 virtual void notifyCache(int type, const UT_Matrix4 &xform,
00200 int push);
00201 virtual void notifyCache(int type, const UT_Vector3 &delta);
00202
00203 static void compute4PtNormal(UT_Vector4 &p1,UT_Vector4 &p2,
00204 UT_Vector4 &p3,UT_Vector4 &p4,
00205 UT_Vector3 &n1,UT_Vector3 &n2,
00206 UT_Vector3 &n3,UT_Vector3 &n4);
00207
00208
00209
00210
00211
00212
00213
00214
00215 virtual GU_TPSurf *cutU(float u1, float u2, int &ind1, int &ind2,
00216 int keep) = 0;
00217
00218 virtual GU_TPSurf *cutV(float v1, float v2, int &ind1, int &ind2,
00219 int keep) = 0;
00220
00221
00222 virtual void openAtU(float u) = 0;
00223 virtual void openAtV(float v) = 0;
00224
00225
00226
00227 int elevateOrderU(int order);
00228 int elevateOrderV(int order);
00229
00230
00231
00232
00233
00234 int findMins(const GEO_Face &face, int numdivs,
00235 UT_Vector3Array &domain,
00236 const GEO_Face *dface = 0,
00237 UT_Vector4Array *displaces = 0);
00238
00239
00240
00241
00242 int findProjects(GEO_Face& face, int numdivs,
00243 const UT_Vector3 &projdir,
00244 UT_Vector3Array &domain,
00245 const GEO_Face *dface = 0,
00246 UT_Vector4Array *displaces = 0);
00247
00248
00249
00250 int interpretBreakpoint(int uidx, int vidx, UT_Vector3 &p);
00251
00252
00253 protected:
00254
00255 GU_TPSurf() : GU_Primitive() { theDisplayCache = 0; theRayCache = 0;}
00256
00257
00258 int create(GEO_TPSurf *tp, int rows, int cols,
00259 GEO_SurfaceType type, int wrapu, int wrapv,
00260 int appendPoints = 1);
00261
00262
00263 void setSurface(GEO_TPSurf *tp) { theSurf = tp; }
00264
00265 public:
00266 GEO_TPSurf *getSurface(void) const { return theSurf; }
00267 protected:
00268
00269 static void compute2PtNormal(UT_Vector4 &p1,
00270 UT_Vector4 &p2,
00271 UT_Vector3 &nml)
00272 {
00273 nml.x() += (p1.z() + p2.z()) * (p2.y() - p1.y());
00274 nml.y() += (p1.x() + p2.x()) * (p2.z() - p1.z());
00275 nml.z() += (p1.y() + p2.y()) * (p2.x() - p1.x());
00276 }
00277
00278
00279
00280 void evaluationInterval(float lodu, float lodv,
00281 float &ustart, float &ustop, int &nu,
00282 float &vstart, float &vstop, int &nv) const;
00283
00284
00285
00286 public:
00287 int evaluateSurface(GU_ConvertMethod &method,
00288 UT_Vector4Array &pos,
00289 int &nu, int &nv,
00290 UT_FloatArray *uval = 0,
00291 UT_FloatArray *vval = 0) const;
00292 protected:
00293 int evaluateSurface(GU_ConvertMethod &method,
00294 UT_Vector4Array &pos,
00295 GB_AttributeData *&aptdata,
00296 GB_AttributeData *&avtxdata,
00297 int &nu, int &nv) const;
00298
00299 void compute2PtNormal(GEO_Point *p1,
00300 GEO_Point *p2, UT_Vector3 &nml) const;
00301
00302 void quadNormal(GEO_Point *p1, GEO_Point *p2,GEO_Point *p3,
00303 GEO_Point *p4, int noff) const;
00304 void quadNormal(GEO_Point *p1, GEO_Point *p2,GEO_Point *p3,
00305 GEO_Point *p4, UT_Vector3Array &output) const;
00306
00307 private:
00308
00309 GEO_TPSurf *theSurf;
00310 GU_TPSurfCache *theDisplayCache;
00311 GU_RayCache *theRayCache;
00312
00313 GEO_Primitive *convertToPoly(GU_ConvertParms &parms);
00314
00315
00316 GU_PrimPoly *projectOnePoint(const UT_Vector3 &orig,
00317 const UT_Vector3 &dir, float uvgap,
00318 GU_RayInfo &hitinfo, GU_Detail &polygdp,
00319 float &pdot, int &pclose, int &projcount,
00320 GU_PrimPoly *&poly,
00321 GU_PrimPoly *&pfirst, GU_PrimPoly *&nfirst,
00322 const GEO_Face &face, int cridx, int lod,
00323 int numdiv=4);
00324 GU_PrimPoly *projectOnePoint(const UT_Vector3 &orig,
00325 const UT_Vector3 &dir, float uvgap,
00326 GU_RayInfo &hitinfo, GU_Detail &polygdp,
00327 UT_LinkList &polys, int &projcount);
00328 int projectOnSide(const UT_Vector4Array &pos,
00329 const UT_Vector3 &dir, const UT_Vector3 &ndir,
00330 int myfar, float rtol, float uvgap, int cls,
00331 GU_Detail &pgdp, const GEO_Face &face, int lod,
00332 int algebraic, int ignoretrim);
00333 int projectOnAllSides(const UT_Vector4Array &pos,
00334 const UT_Vector3 &dir, const UT_Vector3 &ndir,
00335 float rtol, float uvgap, int cls,
00336 GU_Detail &pgdp, const GEO_Face &face, int lod,
00337 int algebraic, int ignoretrim);
00338 int projectAlongMinimum(const UT_Vector4Array &pos,
00339 int closed, float uvgap,
00340 GU_Detail &polygdp);
00341 void processSideHit(GU_PrimPoly *pinpoly,
00342 GU_PrimPoly *&poutpoly, GU_PrimPoly *&pfirst,
00343 GU_PrimPoly *ninpoly, GU_PrimPoly *&noutpoly,
00344 GU_PrimPoly *&nfirst, float uvgap,
00345 GU_Detail &polygdp, int &pstartidx,
00346 int &nstartidx, int cridx);
00347 void processEndHit(GU_Detail &polygdp, GU_PrimPoly &poly,
00348 GU_PrimPoly *first, float uvgap, int close);
00349 void joinHits(GU_PrimPoly &apoly, GU_PrimPoly &bpoly,
00350 GU_PrimPoly *&pfirst, GU_PrimPoly *&nfirst);
00351 int connectToEdge(GU_PrimPoly *poly, GU_Detail &polygdp,
00352 float uvgap, int isfirst);
00353 int projectAddBisectPoints(GU_PrimPoly *poly,
00354 GU_Detail &polygdp, const GEO_Face &face,
00355 int lod, int index, int isfirst,
00356 const UT_Vector3 &dir, GU_RayInfo &hitinfo,
00357 float uvgap, float pdot, int numdiv);
00358
00359
00360 int minimumFunction(UT_Vector3 &from, float &u, float &v,
00361 const UT_Vector3 &);
00362 int projectFunction(UT_Vector3 &from, float &u, float &v,
00363 const UT_Vector3 &projdir);
00364
00365
00366
00367
00368 int findMinsOrProj(GU_PFP fp, const GEO_Face &face,
00369 int numdivs, const UT_Vector3 &projdir,
00370 UT_Vector3Array &domain,
00371 const GEO_Face *dface = 0,
00372 UT_Vector4Array *displaces = 0);
00373
00374 };
00375
00376 #endif