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