00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GEO_Face_H__
00023 #define __GEO_Face_H__
00024
00025 #include "GEO_API.h"
00026 #include <UT/UT_RefArray.h>
00027 #include "GEO_Vertex.h"
00028 #include "GEO_TriMesh.h"
00029
00030 class GB_Edge;
00031 class GD_Face;
00032 class GD_Detail;
00033 class GEO_Detail;
00034
00035 class GEO_API GEO_FaceFlags {
00036 public:
00037 GEO_FaceFlags() { closed = 0; }
00038 unsigned closed:1;
00039 };
00040
00041 #define GEO_FOR_FACE_VERTICES(face, vtx, cnt) \
00042 for (cnt=0; (cnt < face->getFastVertexCount()) && \
00043 (vtx = &((*face)(cnt))); cnt++)
00044
00045 class GEO_API GEO_Face : public GEO_TriMesh {
00046 public:
00047 GEO_Face(GEO_Detail *d);
00048 virtual ~GEO_Face();
00049
00050 virtual unsigned getPrimitiveId() const = 0;
00051 virtual UT_Vector3 computeNormal() const;
00052
00053 virtual int save(ostream &os, int binary) const;
00054 virtual bool load(UT_IStream &is);
00055
00056 virtual void copyPrimitive(const GEO_Primitive *src,
00057 GEO_Point **ptredirect);
00058 virtual GEO_Primitive *copy(int preserve_shared_pts = 0) const;
00059
00060 virtual int isDegenerate() const;
00061
00062 virtual unsigned getOrder(void) const = 0;
00063
00064
00065
00066 virtual void realToUnitPair(float ureal, float vreal,
00067 float &uunit, float &vunit) const;
00068
00069 virtual void unitToRealPair(float uunit, float vunit,
00070 float &ureal, float &vreal) const;
00071
00072
00073
00074 virtual void unitLengthToUnitPair(float ulength, float vlength,
00075 float &uparm, float &vparm)const;
00076 virtual void unitToUnitLengthPair(float uparm, float vparm,
00077 float &ulength, float &vlength)
00078 const;
00079
00080
00081
00082
00083 virtual bool evaluate(fpreal u, GEO_Vertex &result,
00084 GEO_AttributeHandleList &gah,
00085 int du=0, int uOffset=-1) const;
00086 virtual int evaluate(float u, UT_Vector4 &pos,
00087 unsigned du=0, int uOffset=-1) const;
00088 virtual int SYS_DEPRECATED evaluateWAttrib(float u, UT_Vector4 &pos,
00089 GB_AttributeData &adata,
00090 const GB_FloatOffsets &foffsets,
00091 unsigned du=0, int uOffset=-1) const;
00092
00093
00094
00095
00096
00097 virtual bool evaluatePoint(GEO_Vertex &result,
00098 GEO_AttributeHandleList &vtxdata,
00099 fpreal u, fpreal v=0,
00100 uint du=0, uint dv=0) const;
00101 virtual int evaluatePoint( UT_Vector4 &pos, float u_unit, float=0,
00102 unsigned du=0, unsigned dv = 0) const;
00103
00104
00105
00106 virtual int SYS_DEPRECATED evaluatePointWAttrib(UT_Vector4 &pos,
00107 GB_AttributeData &adata,
00108 const GB_FloatOffsets &foffsets,
00109 float u_unit, float=0, unsigned du = 0,
00110 unsigned = 0) const;
00111
00112 virtual int evaluateNormalVector(UT_Vector3 &nml, float u,
00113 float = 0) const;
00114
00115
00116
00117
00118 virtual int evaluateFrenetFrame(UT_Vector3 &x,
00119 UT_Vector3 &t, UT_Vector3 &m, UT_Vector3 &b,
00120 float u, int accurate = 1, int uoffset = -1)
00121 const;
00122
00123
00124
00125
00126
00127
00128
00129
00130 virtual int evaluateBreakSegm(int ustartidx, int ustopidx,
00131 int lod, GEO_Vertex **results,
00132 GEO_AttributeHandleList &hlist, unsigned du=0) const;
00133 virtual int evaluateBreakSegm(int ustartidx, int ustopidx,
00134 int lod, UT_Vector4 *pos, unsigned du=0) const;
00135 virtual int SYS_DEPRECATED evaluateBreakSegmWAttrib(int ustartidx, int ustopidx,
00136 int lod, UT_Vector4 *pos,
00137 GB_AttributeData *adata,
00138 const GB_FloatOffsets &foffsets,
00139 unsigned du=0) const;
00140
00141
00142 virtual int evaluateBreakpoint(int uidx, UT_Vector4 &pos,
00143 int du=0) const = 0;
00144
00145
00146
00147
00148
00149 virtual float breakSegmIndexToDomain(int ustartidx, int ustopidx,
00150 int lod, int index) const;
00151
00152
00153
00154
00155
00156
00157 virtual int removeRepeatedVertices(int check_order = 0,
00158 int count_only = 0);
00159 virtual int removeRepeatedPoints(float tol = 0.001F,
00160 int check_order = 0,
00161 int count_only = 0);
00162
00163
00164
00165
00166
00167 virtual int unroll(int append_pts = 1);
00168
00169
00170
00171
00172
00173
00174 virtual int loft(int newcount, int start=-1, int stop=-1) = 0;
00175
00176
00177
00178
00179
00180
00181 virtual int subdivide(float u, GEO_AttributeHandleList &hl);
00182 virtual int subdivide(float u);
00183 virtual int SYS_DEPRECATED subdivideWAttrib(float u,
00184 const GB_FloatOffsets &foffsets);
00185
00186
00187
00188
00189
00190
00191
00192 virtual int warp(float u, const UT_Vector3 &delta,
00193 GEO_AttributeHandleList &hlist,
00194 float sharpness = 0.0f, float bias = -1.0f) = 0;
00195 virtual int SYS_DEPRECATED warp(float u, const UT_Vector3 &delta,
00196 GB_FloatOffsets *foffsets = 0,
00197 float sharpness = 0.0f, float bias = -1.0f) = 0;
00198
00199
00200
00201 int warpAlongNormal(float u, float distance,
00202 GEO_AttributeHandleList &hlist,
00203 float sharpness, float bias);
00204 int SYS_DEPRECATED warpAlongNormal(float u, float distance,
00205 GB_FloatOffsets *foffsets,
00206 float sharpness, float bias);
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 virtual int attach(const GEO_Face &face, int blend = 1,
00219 float bias = 0.5f, float tolerance = 1.0f,
00220 int unrefine=1, GB_PointGroup *ptgroup=0) = 0;
00221
00222
00223
00224
00225 virtual GD_Face *planar(GD_Detail &dgdp, int copyxy = 0) const = 0;
00226
00227
00228 virtual float unitToRealDomain(float u_unit) const;
00229 virtual float realToUnitDomain(float u_real) const;
00230
00231
00232
00233
00234 virtual float unitLengthToUnitDomain(float ulength,
00235 float tolerance = 1e-04F) const;
00236
00237 virtual float unitToUnitLengthDomain(float uparm ) const;
00238
00239
00240
00241
00242
00243 virtual void unitToRealSequence(float *uunit, float *ureal,
00244 int ulen) const;
00245 static void unitToRealAdjust(float *uunit, float *ureal,
00246 int ulen, int num);
00247
00248
00249
00250 virtual void validInterval(int &a, int &b) const;
00251 virtual void validRange(float &ua, float &ub) const;
00252
00253 unsigned isClosed() const { return flags.closed; }
00254 virtual void close(int rounded = 1, int preserveShape = 0);
00255 virtual void open(int preserveShape = 0, int safe = 0);
00256
00257 virtual int hasEdge(const GEO_Point &a, const GEO_Point &b) const;
00258 virtual int hasEdge(const GB_Edge &edge) const;
00259
00260
00261 virtual void edgeApply(GEO_EdgeApplyFunc apply, void *data = 0);
00262 virtual void edgeApplyIndex(GEO_EdgeApplyIndexFunc apply,
00263 void *data = 0);
00264
00265
00266 int getEdgeCount() const;
00267
00268
00269
00270 virtual void reverse();
00271
00272
00273 void sampleEnds(int n);
00274
00275
00276
00277 virtual int cycle(int amount, int = 1);
00278
00279
00280 float radius() const;
00281
00282
00283
00284
00285
00286 virtual int findEdgePoints(const GEO_Point &a, const GEO_Point &b,
00287 int *pidx0, int *pidx1) const;
00288 virtual int findEdgePoints(const GB_Edge &edge,
00289 int *pidx0, int *pidx1) const;
00290
00291
00292
00293 bool hasDEdge(const GEO_Point &a, const GEO_Point &b) const;
00294
00295
00296
00297 bool isBridge(const GEO_Point &a, const GEO_Point &b) const;
00298
00299
00300
00301
00302
00303 virtual int refine(fpreal k, GEO_AttributeHandleList &gah, int i=0);
00304 virtual int refine (float k, int=0);
00305 virtual int SYS_DEPRECATED refineWAttrib (float k,
00306 const GB_FloatOffsets &foffsets, int=0);
00307
00308
00309
00310
00311 static fpreal getIndices(fpreal c, int &c1, int &c2,
00312 int maxIndex, int wrap);
00313
00314
00315
00316
00317
00318
00319
00320
00321 virtual int pointInFace(const UT_Vector3 &pos,
00322 const UT_Vector3 *normal) const;
00323
00324
00325 virtual float uvDist(float u1, float v1, float u2, float v2) const;
00326
00327
00328 virtual void weights(unsigned short onOff);
00329 virtual int breakCount() const = 0;
00330
00331 virtual float calcVolume(UT_Vector3 &refpt) const;
00332 virtual float calcArea() const;
00333 virtual float calcPerimeter() const;
00334
00335 protected:
00336 virtual void copyOffsetPrimitive(const GEO_Primitive *src, int base);
00337
00338
00339 virtual int savePrivate(ostream &os, int binary) const = 0;
00340 virtual bool loadPrivate(UT_IStream &is) = 0;
00341 virtual int pointCanDelete(GB_Element *) const;
00342 virtual void pointDeleted(GB_Element *pt);
00343
00344
00345
00346 virtual bool validate(void) const;
00347
00348 GEO_FaceFlags flags;
00349
00350
00351 private:
00352
00353 friend ostream &operator<<(ostream &os, const GEO_Face &d)
00354 {
00355 d.save(os, 0);
00356 return os;
00357 }
00358 };
00359 #endif