00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __GU_Prim_h__
00024 #define __GU_Prim_h__
00025
00026 #include "GU_API.h"
00027 #include <UT/UT_RefArray.h>
00028 #include <UT/UT_Vector3Array.h>
00029 #include <GA/GA_Handle.h>
00030 #include <GA/GA_AttributeRef.h>
00031 #include <GA/GA_Detail.h>
00032
00033 class GEO_Point;
00034 class UT_BitArray;
00035 class GEO_Primitive;
00036 class GA_PointGroup;
00037 class GA_PrimitiveGroup;
00038 class GU_DisplayCache;
00039 class GU_CacheParms;
00040 class GU_RayIntersect;
00041 class GU_ConvertParms;
00042 class GU_RayInfoHit;
00043 class GA_ROAttributeRef;
00044 class GA_RWAttributeRef;
00045
00046 class GU_API GU_Primitive
00047 {
00048 public:
00049
00050
00051 GU_Primitive() {}
00052 virtual ~GU_Primitive();
00053
00054
00055
00056
00057
00058
00059 virtual GEO_Primitive *convert(GU_ConvertParms &parms,
00060 GA_PointGroup *usedpts = 0) = 0;
00061
00062
00063
00064
00065 virtual GEO_Primitive *convertNew(GU_ConvertParms &parms) = 0;
00066
00067 virtual const GEO_Primitive *castToGeo(void) const = 0;
00068
00069
00070
00071
00072 class GU_API NormalComp {
00073 public:
00074 virtual ~NormalComp() {}
00075 virtual void add(GA_Offset offset, const UT_Vector3 &nml) {}
00076 virtual void sub(GA_Offset offset, const UT_Vector3 &nml) {}
00077 };
00078
00079
00080
00081 class GU_API NormalCompArray : public NormalComp {
00082 public:
00083 NormalCompArray(const GA_Detail &gdp, UT_Vector3Array &output)
00084 : myGdp(gdp)
00085 , myOutput(output) {}
00086 virtual void add(GA_Offset offset, const UT_Vector3 &nml)
00087 { myOutput(myGdp.pointIndex(offset)) += nml; }
00088 virtual void sub(GA_Offset offset, const UT_Vector3 &nml)
00089 { myOutput(myGdp.pointIndex(offset)) -= nml; }
00090
00091 private:
00092 const GA_Detail &myGdp;
00093 UT_Vector3Array &myOutput;
00094 };
00095
00096
00097 class GU_API NormalCompAttr : public NormalComp {
00098 public:
00099 NormalCompAttr(const GA_RWAttributeRef &attr)
00100 : myAttr(attr)
00101 , myHandle(attr.getAttribute()) {}
00102 virtual void add(GA_Offset offset, const UT_Vector3 &nml)
00103 { myHandle.add(offset, nml); }
00104 virtual void sub(GA_Offset offset, const UT_Vector3 &nml)
00105 { myHandle.add(offset, -nml); }
00106
00107 GA_RWHandleV3 &getHandle() { return myHandle; }
00108
00109 private:
00110 const GA_RWAttributeRef &myAttr;
00111 GA_RWHandleV3 myHandle;
00112 };
00113
00114 virtual void normal(NormalComp &output) const = 0;
00115 virtual void clip(UT_Vector3 &nml, float d = 0, int normalize = 1,
00116 GEO_Primitive *prim=0,
00117 GA_PrimitiveGroup *clipgrp = 0);
00118
00119 virtual int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d,
00120 float tmax = 1E17F, float tol = 1E-12F,
00121 float *distance = 0, UT_Vector3 *pos = 0,
00122 UT_Vector3 *nml = 0, int accurate = 0,
00123 float *u = 0, float *v = 0,
00124 int ignoretrim = 1) const = 0;
00125
00126
00127
00128
00129 virtual int intersect(GU_Primitive &prim,
00130 UT_RefArray<GU_RayInfoHit> &hitList,
00131 float tol = 0.01F, int ignoretrim=1);
00132
00133
00134 virtual int minimum(const UT_Vector3 &p, float distmax = 1E17F,
00135 float *distance = 0, float *u = 0,
00136 float *v = 0, int accurate = 1);
00137
00138
00139 virtual int minimum(GU_Primitive &prim, float distmax = 1E17F,
00140 float *distance = 0, float *u1 = 0,
00141 float *v1 = 0, float *u2 = 0, float *v2 = 0,
00142 int accurate = 1);
00143
00144 virtual GU_DisplayCache *getDisplayCache(void) const;
00145 virtual int buildDisplayCache(GU_CacheParms &parms);
00146
00147 virtual GU_RayIntersect *getRayCache(void) const;
00148 virtual int buildRayCache(void);
00149
00150
00151 virtual GU_RayIntersect *createRayCache(int &persistent) = 0;
00152
00153 virtual void destroyCache(void);
00154 virtual void notifyCache(int type);
00155 virtual void notifyCache(int type, const GEO_Point &ppt);
00156 virtual void notifyCache(int type, const GA_PointGroup &grp);
00157 virtual void notifyCache(int type, const UT_Matrix4 &xform,
00158 int push);
00159 virtual void notifyCache(int type, const UT_Vector3 &delta);
00160
00161 protected:
00162 private:
00163 };
00164
00165 #endif