00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GEO_Primitive_H__
00023 #define __GEO_Primitive_H__
00024
00025 #include "GEO_API.h"
00026 #include <iostream.h>
00027 #include <UT/UT_Matrix4.h>
00028 #include <GB/GB_Primitive.h>
00029 #include <GB/GB_Attribute.h>
00030 #include "GEO_Point.h"
00031
00032 class GB_FloatOffsets;
00033 class GB_Edge;
00034 class GEO_Detail;
00035 class GEO_Vertex;
00036 class GEO_VertexAttribDict;
00037 class GEO_MetaPrim;
00038 class GEO_AttributeHandleList;
00039
00040 typedef void (* GEO_EdgeApplyFunc)(GEO_Primitive &prim, GEO_Point &a,
00041 GEO_Point &b, void *data);
00042 typedef void (* GEO_EdgeApplyIndexFunc)(GEO_Primitive &prim, int v1,
00043 int v2, void *data);
00044
00045 class GEO_API GEO_Primitive : public GB_Primitive, public GB_AttributeElem
00046 {
00047 public:
00048 GEO_Primitive(GEO_Detail *d);
00049 virtual ~GEO_Primitive();
00050
00051 virtual int isPrimary(void) const;
00052
00053
00054
00055 void copyAttributesAndGroups(const GEO_Primitive &src,
00056 bool copy_groups=true)
00057 {
00058 copyAttributeData(src);
00059 if (copy_groups)
00060 copyGroupMembership(src);
00061 }
00062
00063
00064
00065 void copyAttributeData(const GEO_Primitive &src);
00066
00067
00068
00069 void copyGroupMembership(const GEO_Primitive &src);
00070
00071
00072 void SYS_DEPRECATED copyAttributeData(const GEO_Primitive *src, int asize);
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 virtual void copyPrimitive(const GEO_Primitive *src,
00085 GEO_Point **ptredirect)=0;
00086 virtual GEO_Primitive *copy(int preserve_shared_pts = 0) const;
00087
00088
00089
00090
00091
00092 virtual void transform(const UT_Matrix4 &);
00093
00094
00095
00096 virtual void realToUnitPair(float ureal, float vreal,
00097 float &uunit, float &vunit) const;
00098
00099
00100 virtual void unitToRealPair(float uunit, float vunit,
00101 float &ureal, float &vreal) const;
00102
00103
00104
00105 virtual void unitLengthToUnitPair(float ulength, float vlength,
00106 float &uparm, float &vparm)const;
00107
00108 virtual void unitToUnitLengthPair(float uparm, float vparm,
00109 float &ulength, float &vlength)
00110 const;
00111
00112
00113
00114 virtual bool evaluateBaryCenter(GEO_Vertex &result,
00115 GEO_AttributeHandleList &gah)
00116 const = 0;
00117
00118
00119
00120
00121 virtual bool evaluatePoint(GEO_Vertex &result,
00122 GEO_AttributeHandleList &gah,
00123 fpreal u, fpreal v=0,
00124 uint du=0, uint dv=0) const = 0;
00125
00126
00127
00128
00129 virtual int evaluatePoint( UT_Vector4 &pos, float u, float v = 0,
00130 unsigned du=0, unsigned dv=0) const;
00131 virtual int SYS_DEPRECATED evaluatePointWAttrib(UT_Vector4 &pos,
00132 GB_AttributeData &adata,
00133 const GB_FloatOffsets &foffsets,
00134 float u, float v = 0, unsigned du = 0,
00135 unsigned dv = 0) const;
00136 virtual int evaluateNormalVector(UT_Vector3 &nml, float u,
00137 float v = 0) const;
00138
00139
00140
00141
00142
00143
00144
00145 virtual bool evaluateInteriorPoint(GEO_Vertex &result,
00146 GEO_AttributeHandleList &hlist,
00147 fpreal u, fpreal v) const;
00148 virtual int evaluateInteriorPoint(UT_Vector4 &pos,
00149 float u, float v) const;
00150 virtual int SYS_DEPRECATED evaluateInteriorPointWAttrib
00151 (UT_Vector4 &pos,
00152 GB_AttributeData &adata,
00153 const GB_FloatOffsets &foffsets,
00154 float u, float v) const;
00155
00156 GEO_Detail *getParent() const { return (GEO_Detail*)parent; }
00157 static unsigned getPrimitiveType(const char *name);
00158 static const char *getPrimitiveName(unsigned type);
00159 static unsigned getPrimitiveMask(const char *maskstr);
00160
00161 virtual void *castTo() const;
00162
00163 virtual int hasEdge(const GEO_Point &a, const GEO_Point &b) const;
00164 virtual int hasEdge(const GB_Edge &edge) const;
00165 virtual int hasGuideEdge(int edgeid, UT_Vector4 &a,
00166 UT_Vector4 &b) const;
00167 virtual int hasXsectPoint(int pointid, UT_Vector4 &p) const;
00168
00169 virtual void edgeApply(GEO_EdgeApplyFunc apply , void *data = 0);
00170 virtual void edgeApplyIndex(GEO_EdgeApplyIndexFunc apply,
00171 void *data = 0);
00172
00173 virtual const GEO_Vertex &getVertex(unsigned index) const = 0;
00174 virtual GEO_Vertex &getVertex(unsigned index) = 0;
00175
00176
00177
00178 virtual GEO_MetaPrim *castToMetaPrim(void);
00179 virtual const GEO_MetaPrim *castToMetaPrim(void) const;
00180
00181
00182
00183
00184 virtual int parametricBBox(float u, float v,
00185 float *u0, float *u1,
00186 float *v0, float *v1);
00187
00188
00189
00190 virtual float uvDist(float u1, float v1, float u2, float v2) const;
00191
00192
00193 virtual void stashed(int onoff);
00194
00195
00196
00197 int bboxIntersectRay(const UT_Vector3 &rayorig,
00198 const UT_Vector3 &raydir,
00199 int maxtries = 10,
00200 float tmax = 1E17F,
00201 float *distance = 0,
00202 UT_Vector3 *nml=0) const;
00203
00204
00205 virtual float calcVolume(UT_Vector3 &refpt) const { return 0; }
00206 virtual float calcArea() const { return 0; }
00207 virtual float calcPerimeter() const { return 0; }
00208
00209
00210 virtual bool isQuadric() const { return false; }
00211
00212 protected:
00213 virtual void copyOffsetPrimitive(const GEO_Primitive *src,
00214 int basept) = 0;
00215 void copyBasePrimitive(const GEO_Primitive *src,
00216 GEO_Point **ptredirect);
00217 void copyOffsetBasePrimitive(const GEO_Primitive *src,
00218 int basept);
00219
00220 private:
00221 friend class GEO_Detail;
00222
00223 friend ostream &operator<<(ostream &os, const GEO_Primitive &d)
00224 {
00225 d.save(os, 0);
00226 return os;
00227 }
00228 };
00229 #endif