00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GD_Face_H__
00021 #define __GD_Face_H__
00022
00023 #include "GD_API.h"
00024 #include <UT/UT_Vector2.h>
00025 #include <UT/UT_RefArray.h>
00026 #include "GD_Vertex.h"
00027 #include "GD_Primitive.h"
00028
00029 class GD_Detail;
00030 class GD_TrimLoop;
00031 class GD_TrimHitInfo;
00032 class UT_Vector3Array;
00033
00034 class GD_API GD_FaceFlags {
00035 public:
00036 GD_FaceFlags() { closed = 0; }
00037 unsigned closed:1;
00038 };
00039
00040 #define GD_FOR_FACE_VERTICES(face, vtx, cnt) \
00041 for (cnt=0; (cnt < face->getVertexCount()) && \
00042 (vtx = &((*face)(cnt))); cnt++)
00043
00044 class GD_API GD_Face : public GD_Primitive
00045 {
00046 public:
00047 GD_Face(GD_Detail *d);
00048 virtual ~GD_Face();
00049
00050 virtual int getBBox(UT_BoundingBox *bbox) const;
00051 virtual void addToBSphere(UT_BoundingSphere *bsphere) const;
00052 virtual void getBRect(UT_BoundingRect *brect) const;
00053 virtual UT_Vector3 computeNormal() const;
00054 virtual UT_Vector3 baryCenter() const;
00055
00056 virtual int save(ostream &os, int binary) const;
00057 virtual bool load(UT_IStream &is);
00058
00059 virtual GD_Primitive *copy(int preserve_shared_pts = 0) const;
00060 virtual int copy(const GD_Primitive &src, int ptoffset);
00061
00062
00063
00064 virtual int evaluate(float u, UT_Vector3 &pos,
00065 unsigned du=0, int uOffset=-1) const = 0;
00066
00067 virtual void addPointRefToGroup(GB_PointGroup &grp) const;
00068 virtual void changePointRef(GB_Element *from, GB_Element *to);
00069
00070 virtual int isDegenerate() const;
00071
00072 virtual unsigned getOrder(void) const = 0;
00073
00074
00075 void setSize(unsigned int sz);
00076
00077
00078 virtual int detachPoint (GB_Element *ppt, int allVertices=1);
00079 virtual int ifDetachPoint(GB_Element *ppt) const;
00080
00081
00082
00083
00084
00085
00086 virtual int detachPoints (GB_PointGroup &grp);
00087
00088
00089 virtual int removeRepeatedVertices(int check_order = 0);
00090
00091
00092
00093
00094 virtual int insertVertex(GD_Point *ppt, unsigned int where=0);
00095 virtual int appendVertex(GD_Point *ppt);
00096 virtual int deleteVertex(GD_Vertex &vtx);
00097 virtual int deleteVertex(unsigned int num);
00098
00099
00100
00101 virtual unsigned getVertexCount() const;
00102
00103
00104
00105 int find(const GD_Vertex &vtx) const { return myVtxList.find(vtx);}
00106 int find(const GD_Point &ppt) const;
00107
00108
00109 const GD_Vertex &operator()(unsigned i) const { return myVtxList(i); }
00110 GD_Vertex &operator()(unsigned i) { return myVtxList(i); }
00111 const GD_Vertex &operator[](unsigned i) const
00112 {
00113 return (i < myVtxList.entries()) ? myVtxList(i)
00114 : myVtxList(0);
00115 }
00116 GD_Vertex &operator[](unsigned i)
00117 {
00118 return (i < myVtxList.entries()) ? myVtxList(i)
00119 : myVtxList(0);
00120 }
00121 const GD_Vertex &getVertex(unsigned i) const;
00122 GD_Vertex &getVertex(unsigned i);
00123 void setVertex(unsigned int i, GD_Point *pt)
00124 {
00125 if (i < myVtxList.entries())
00126 myVtxList(i).setPt(pt);
00127 }
00128
00129 unsigned isClosed() const { return myFlags.closed; }
00130 virtual void close(int rounded = 1, int preserveShape = 0);
00131 virtual void open(int preserveShape = 0, int safe = 0);
00132
00133 int isClockwise(void) const;
00134
00135 virtual int isPointUsed(GB_Element *pt) const;
00136
00137
00138
00139
00140 virtual int isVisible(void) const;
00141
00142
00143
00144 virtual int visibleBaryCenter(float &uctr, float &vctr) const;
00145
00146
00147 void sampleEnds(int n);
00148
00149
00150 virtual int vertexApply(int (*apply)(GB_Vertex &vtx, void *),
00151 void *data = 0);
00152 virtual int vertexApply(int (*apply)(const GB_Vertex &vtx, void *),
00153 void *data = 0) const;
00154
00155
00156
00157 virtual int cycle(int amount, int = 1);
00158
00159
00160
00161 virtual void reverse();
00162
00163
00164 virtual void validInterval(int &a, int &b ) const;
00165 virtual void validRange (float &ua, float &ub) const;
00166
00167
00168
00169
00170 int visibleRange(float &ua,float &ub, float tol=1E-4F) const;
00171
00172
00173
00174
00175
00176
00177 virtual int evaluateBreakSegm(int ustartidx, int ustopidx,
00178 int lod, UT_Vector3 *pos, unsigned du=0) const;
00179
00180
00181
00182
00183
00184
00185 virtual GD_TrimLoop *trimLoop(float ustart, float ustop) const = 0;
00186
00187
00188 int intersectDomain(UT_RefArray<GD_TrimHitInfo> &hitlist,
00189 float tol = 1E-4F) const;
00190
00191
00192
00193
00194 void homogenize (int startcv = 0, int endcv = -1);
00195 void dehomogenize(int startcv = 0, int endcv = -1);
00196
00197 virtual int breakCount() const = 0;
00198
00199
00200
00201 int getPoints(int numdivs, UT_Vector3Array &domain,
00202 int usebreak);
00203
00204
00205 virtual void weights(unsigned short) {}
00206
00207 protected:
00208
00209 virtual int savePrivate(ostream &os, int binary) const = 0;
00210 virtual bool loadPrivate(UT_IStream &is) = 0;
00211 virtual int pointCanDelete(GB_Element *) const;
00212 virtual void pointDeleted(GB_Element *pt);
00213
00214
00215
00216 virtual bool validate(void) const;
00217
00218
00219 int multipleInsert(unsigned int where,
00220 unsigned int count,
00221 unsigned int appendPoints = 1);
00222
00223
00224 private:
00225 UT_RefArray<GD_Vertex> myVtxList;
00226 GD_FaceFlags myFlags;
00227
00228 friend ostream &operator<<(ostream &os, const GD_Face &d)
00229 {
00230 d.save(os, 0);
00231 return os;
00232 }
00233 };
00234 #endif