00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GD_Detail_h__
00021 #define __GD_Detail_h__
00022
00023 #include "GD_API.h"
00024 #include <UT/UT_PtrArray.h>
00025 #include <UT/UT_BoundingRect.h>
00026 #include <GB/GB_Detail.h>
00027 #include "GD_Point.h"
00028 #include "GD_Primitive.h"
00029 #include "GD_PointList.h"
00030 #include "GD_PrimList.h"
00031 #include "GD_Macros.h"
00032
00033 #include <UT/UT_VectorTypes.h>
00034 class GD_Vertex;
00035 class GD_TrimRegion;
00036 class GD_TrimLoop;
00037
00038 class GD_API GD_Detail : public GB_Detail
00039 {
00040 public:
00041 GD_Detail();
00042 virtual ~GD_Detail();
00043
00044
00045
00046
00047 virtual void clearAndDestroy();
00048
00049
00050
00051
00052 virtual int save(ostream& os, int binary,
00053 const UT_Options *options) const;
00054 virtual bool load(UT_IStream &is, const UT_Options *options);
00055
00056
00057
00058
00059 void merge (const GD_Detail &src,
00060 int onlyvisible = 0);
00061 void mergePoints(const GD_Detail &src);
00062
00063
00064
00065
00066
00067
00068
00069 void transform(const UT_Matrix3 &matx,
00070 GB_PrimitiveGroup *primgroup = 0,
00071 GB_PointGroup *pointclosure = 0);
00072 void translate(const UT_Vector2 &delta,
00073 GB_PrimitiveGroup *primgroup = 0,
00074 GB_PointGroup *pointclosure = 0);
00075
00076
00077
00078
00079 void transformPoints(const UT_Matrix3 &matx,
00080 GB_PointGroup *pointgroup = 0);
00081 void translatePoints(const UT_Vector2 &delta,
00082 GB_PointGroup *pointGroup = 0);
00083
00084
00085
00086
00087
00088
00089 GD_Point *insertPoint(const GD_Point *before = 0);
00090 GD_Point *appendPoint() { return insertPoint(0); }
00091 GD_Point *insertPoint(const UT_Vector3 &pos,
00092 const GD_Point *before = 0);
00093 GD_Point *appendPoint(const UT_Vector3 &pos)
00094 { return insertPoint(pos); }
00095
00096
00097
00098
00099
00100
00101
00102 GD_Primitive *insertPrimitive(unsigned type,
00103 const GD_Primitive *before = 0);
00104 GD_Primitive *appendPrimitive(unsigned type)
00105 {
00106 return insertPrimitive(type, 0);
00107 }
00108 GD_Primitive *insertPrimitive(GD_Primitive *prim,
00109 const GD_Primitive *before = 0);
00110 GD_Primitive *appendPrimitive(GD_Primitive *prim)
00111 {
00112 return insertPrimitive(prim, 0);
00113 }
00114 virtual void deletePrimitive(GB_Primitive &p, int andpoints = 0);
00115 virtual void deletePrimitive(unsigned int num, int andpoints = 0);
00116
00117
00118
00119
00120
00121 GD_TrimRegion *appendTrimRegion(int opencasual = 0);
00122 void deleteTrimRegion(GD_TrimRegion ®ion);
00123 void deleteTrimRegion(unsigned int num);
00124 GD_TrimLoop *generateTrimLoops(const UT_BoundingRect &brect,
00125 float offset=1e-4F,
00126 float tol=1e-4F);
00127 void destroyTrimRegions(int deletecurves=1);
00128 void createTrimRegion(GD_TrimLoop *loop);
00129
00130
00131
00132
00133
00134
00135 virtual int getPointBBox(UT_BoundingBox *bbox,
00136 const GB_PointGroup *g = 0) const;
00137 virtual int getPointBBox(UT_BoundingBox& bbox, const UT_Matrix4& transform,
00138 const GB_PointGroup *g=0) const;
00139 virtual int getPointBSphere(UT_BoundingSphere *bsphere,
00140 const GB_PointGroup *g = 0,
00141 int updateRequired = 0) const;
00142
00143
00144
00145
00146
00147 virtual void getDomainBBox(float &u0, float &v0,
00148 float &u1, float &v1) const = 0;
00149
00150
00151 int getNumFaces(int *visible = 0) const;
00152
00153
00154
00155
00156 int hasTrimLoops(void) const;
00157
00158
00159
00160 int hasTrimRegions(void) const;
00161
00162
00163 const UT_PtrArray<GD_TrimRegion*> &trimRegions(void) const
00164 { return myTrimRegions; }
00165
00166
00167
00168
00169
00170 GD_TrimRegion *appendOuterLoop(float tol = 0, int checkduplicate = 1);
00171
00172
00173
00174 int altitude(void ) const { return myAltitude; }
00175 void altitude(int a) { myAltitude = a; }
00176
00177
00178 GD_PointList &points() { return (GD_PointList&)ptList; }
00179 GD_PrimList &primitives() { return (GD_PrimList&) primList; }
00180 const GD_PointList &points() const { return (const GD_PointList&)ptList; }
00181 const GD_PrimList &primitives() const
00182 { return (const GD_PrimList&)primList; }
00183
00184 UT_PtrArray<GD_TrimRegion*> &trimRegions(void) { return myTrimRegions; }
00185
00186 protected:
00187 virtual GD_Primitive *newPrimitive(unsigned type);
00188
00189
00190 virtual GB_Primitive *appendNewPrimitive(unsigned type);
00191
00192
00193 virtual unsigned getPrimitiveType(const char *name) const;
00194 virtual const char *getPrimitiveName(unsigned type) const;
00195
00196
00197 virtual int save(const char *, int binary,
00198 const UT_Options *options) const;
00199 virtual int load(const char *, const UT_Options *options);
00200
00201 private:
00202 UT_PtrArray<GD_TrimRegion*> myTrimRegions;
00203 int myAltitude;
00204
00205
00206 bool loadTrimRegions(int n, UT_IStream &is);
00207 int saveTrimRegions(int n, ostream &os, int b=0) const;
00208
00209
00210 friend ostream &operator<<(ostream &os, const GD_Detail &d)
00211 {
00212 d.save(os, 0, 0);
00213 return os;
00214 }
00215 };
00216
00217 #endif