00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GDT_PrimitiveList_h__
00021 #define __GDT_PrimitiveList_h__
00022
00023 #include "GDT_API.h"
00024 #include "GDT_TokenList.h"
00025
00026 #include <GEO/GEO_Detail.h>
00027 #include "GDT_Transform.h"
00028
00029 class GB_PrimitiveGroup;
00030
00031
00032 class GDT_API GDT_PrimitiveList : public GDT_TokenList
00033 {
00034 public:
00035 GDT_PrimitiveList() : myTransform(0) {}
00036 GDT_PrimitiveList(const GDT_PrimitiveList &other);
00037 virtual ~GDT_PrimitiveList();
00038
00039
00040 virtual void applyDeltas(GEO_Detail &gdp, bool inverse=false) const;
00041
00042
00043 void mergePrimitiveDeltas(const GDT_PrimitiveList &other,
00044 bool inverse = false);
00045
00046
00047
00048 void beginPrimitiveTransformChange(const UT_Matrix3 &mat);
00049 void endPrimitiveTransformChange(const UT_Matrix3 &mat,
00050 unsigned int index);
00051
00052
00053 #if 0
00054 bool takeTransformSnapshot(const GEO_Detail &beforegdp,
00055 const GEO_Detail &aftergdp,
00056 const GB_PrimitiveGroup *grp=0)
00057 { return false; }
00058 #endif
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 virtual unsigned int getElementCount(const GEO_Detail &gdp) const
00070 { return gdp.primitives().entries(); }
00071
00072 virtual void initIterate() const { myLastIndex = -1; }
00073 virtual GB_AttributeElem *getNextAttributeElement(GEO_Detail &gdp) const
00074 { return gdp.primitives()(++myLastIndex); }
00075 virtual GB_AttributeElem *getAttributeElement(GEO_Detail &gdp,
00076 unsigned int index) const
00077 { return gdp.primitives()(index); }
00078
00079
00080 virtual GB_AttributeDict &getAttributeDict(GEO_Detail &gdp) const
00081 { return gdp.primitiveAttribs(); }
00082
00083
00084 virtual int appendGdpAttribute(GEO_Detail &gdp,
00085 const char *name, int size,
00086 GB_AttribType type,
00087 const void *defvalue) const
00088 {
00089 return gdp.primitiveAttribs().append(
00090 name, size, type, defvalue);
00091 }
00092
00093 virtual int growGdpAttribute(GEO_Detail &gdp,
00094 const char *name, int oldsize,
00095 GB_AttribType type,
00096 unsigned int addedsize) const
00097 {
00098 return gdp.primitiveAttribs().grow(
00099 name, oldsize, type, addedsize);
00100 }
00101
00102 virtual bool hasChange() const;
00103 virtual bool haveAttributesChanged() const
00104 { return GDT_TokenList::hasChange(); }
00105 bool hasTransformChanged() const
00106 {
00107 return (myTransform &&
00108 myTransform->changed() > 0);
00109 }
00110
00111 virtual unsigned int entries() const;
00112
00113 virtual int saveTrans(ostream &os, int binary = 0) const;
00114 virtual bool loadTrans(UT_IStream &is, uint numtotal);
00115
00116
00117 virtual void zeroDeltas();
00118
00119 virtual void clearDeltas();
00120
00121 virtual void destroy();
00122
00123
00124 protected:
00125 virtual void getAttributeElements(const GEO_Detail &beforegdp,
00126 const GEO_Detail &aftergdp,
00127 unsigned int before_elem_index,
00128 unsigned int after_elem_index,
00129 const GB_AttributeElem *&beforeelem,
00130 const GB_AttributeElem *&afterelem) const
00131 {
00132 beforeelem=beforegdp.primitives()(before_elem_index);
00133 afterelem =aftergdp.primitives()(after_elem_index);
00134 }
00135
00136
00137 private:
00138
00139
00140 GDT_Transform *myTransform;
00141
00142 mutable int myLastIndex;
00143 };
00144 #endif