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