00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GP_Domain_h__
00021 #define __GP_Domain_h__
00022
00023 #include "GP_API.h"
00024 #include <iostream.h>
00025 #include <UT/UT_BoundingRect.h>
00026 #include "GP_FrameHierarchy.h"
00027 #include "GP_Node.h"
00028
00029 class UT_IStream;
00030 class GP_FrameHierarchy;
00031 class GP_DomainDAG;
00032 class GP_NodeList;
00033
00034
00035 class GP_API GP_Domain : public GP_Node
00036 {
00037 public:
00038
00039 GP_Domain(void);
00040 GP_Domain(const UT_BoundingRect &original,
00041 const GP_XformHandle &xform,
00042 int key = 0);
00043 GP_Domain(const GP_Domain &d);
00044 virtual ~GP_Domain(void);
00045
00046
00047
00048 virtual GP_Node *copy(void) const;
00049
00050
00051 virtual int save(ostream &os, int binary = 0) const;
00052 virtual bool load(UT_IStream &is);
00053
00054
00055
00056 virtual void findParents(GP_NodeList &stack, GP_NodeList &parns)=0;
00057 virtual void findParent (GP_Domain &parent)=0;
00058
00059
00060 virtual GP_Domain *spawn(const UT_BoundingRect &brect,
00061 float ubwidth = 0, float vbwidth = 0,
00062 int ubdivs = 2, int vbdivs = 2,
00063 int newkey = 0) = 0;
00064
00065
00066
00067
00068 virtual int modifyBasis(int (*apply)(void *tpsurf, void *d),
00069 void *data = 0, int standalone = 1) = 0;
00070
00071
00072 GP_FrameHierarchy *frames(void) const
00073 {
00074 return myFrames;
00075 }
00076 void frames(GP_FrameHierarchy *f)
00077 {
00078 if (myFrames && myOwnFrames) delete myFrames;
00079 myFrames = f;
00080 myOwnFrames = 0;
00081 }
00082
00083
00084 GP_DomainDAG *dag(void) const;
00085
00086
00087 void update(void);
00088
00089
00090 void polygon(GP_Point &p1, GP_Point &p2, GP_Point &p3,
00091 GP_Point &p4)
00092 {
00093 update();
00094 p1 = myWorldPoly[0];
00095 p2 = myWorldPoly[1];
00096 p3 = myWorldPoly[2];
00097 p4 = myWorldPoly[3];
00098 }
00099
00100
00101 GP_Domain *parentDomain(void) const
00102 {
00103 return (myFrames && myFrames->parent())
00104 ? myFrames->parent()->domain() : 0;
00105 }
00106
00107
00108
00109
00110
00111 int fromWorld(GP_Point &p) const;
00112
00113
00114
00115 int contains(const GP_Point &worldp, int quick=0) const;
00116
00117
00118
00119 int contains(const GP_Domain &d, int quick = 0) const;
00120
00121
00122
00123 int intersects(const GP_Domain &d, int quick = 0) const;
00124
00125
00126
00127
00128 float intersect(const GP_Point &a, const GP_Point &b) const;
00129
00130
00131 int isFeature() const { return myFrames->parent() != 0; }
00132
00133
00134 GP_Domain *relative(void) const { return myRelative; }
00135 void relative(GP_Domain *d) { myRelative = d; }
00136
00137
00138
00139
00140 const UT_BoundingRect &originalBRect() const { return myOriginal; }
00141 void originalBRect(const UT_BoundingRect &brect)
00142 {
00143 myOriginal = brect;
00144 updatePolygon();
00145 }
00146
00147
00148 void safeOriginalBRect(const UT_BoundingRect &);
00149
00150
00151
00152 const UT_BoundingRect &worldBRect() const { return myWorldRect; }
00153 const UT_BoundingRect &worldBRect() { update(); return myWorldRect; }
00154
00155
00156 protected:
00157
00158
00159
00160 void updatePolygon(void);
00161
00162
00163 private:
00164 GP_FrameHierarchy *myFrames;
00165 UT_BoundingRect myOriginal;
00166 UT_BoundingRect myWorldRect;
00167 GP_Point myWorldPoly[4];
00168 int myOwnFrames;
00169
00170 GP_Domain *myRelative;
00171 };
00172
00173 #endif