00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GDT_VertexList_h__
00021 #define __GDT_VertexList_h__
00022
00023 #include "GDT_API.h"
00024 #include "GDT_TokenList.h"
00025
00026 #include <UT/UT_IntArray.h>
00027 #include <UT/UT_PtrArray.h>
00028 #include <GEO/GEO_Detail.h>
00029
00030
00031 class GDT_API GDT_VertexList : public GDT_TokenList
00032 {
00033 public:
00034 GDT_VertexList();
00035 GDT_VertexList(const GDT_VertexList &other);
00036 virtual ~GDT_VertexList() {}
00037
00038
00039 void mergeVertexDeltas(const GDT_VertexList &other,
00040 bool inverse = false);
00041
00042
00043 void applyScaledDelta(GEO_Detail &gdp, GEO_Primitive &prim,
00044 int vtxidx, float scale) const;
00045
00046
00047
00048
00049 void endVertexAttributeChange(const GB_AttributeData &data,
00050 unsigned int prim_index,
00051 unsigned int linear_index_in_prim);
00052
00053
00054
00055
00056 void updateVertexOffsets(const GEO_Detail &gdp);
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 virtual unsigned int getElementCount(const GEO_Detail &gdp) const;
00069 virtual void initIterate() const;
00070 virtual GB_AttributeElem *getNextAttributeElement(GEO_Detail &gdp) const;
00071 virtual GB_AttributeElem *getAttributeElement(GEO_Detail &gdp,
00072 unsigned int index) const;
00073
00074
00075
00076 virtual GB_AttributeDict &getAttributeDict(GEO_Detail &gdp) const
00077 { return gdp.vertexAttribs(); }
00078
00079
00080 virtual GB_AttributeRef appendGdpAttribute(GEO_Detail &gdp,
00081 const char *name, int size,
00082 GB_AttribType type,
00083 const void *defvalue) const
00084 {
00085 return gdp.vertexAttribs().append(
00086 name, size, type, defvalue);
00087 }
00088
00089 virtual GB_AttributeRef growGdpAttribute(GEO_Detail &gdp,
00090 const char *name, int oldsize,
00091 GB_AttribType type,
00092 unsigned int addedsize) const
00093 {
00094 return gdp.vertexAttribs().grow(
00095 name, oldsize, type, addedsize);
00096 }
00097
00098 virtual int saveAttribs(ostream &os, int binary = 0) const;
00099 bool loadOffsets(UT_JSONParser &p);
00100 virtual bool legacyLoadAttribs(UT_IStream &is, uint size);
00101
00102
00103 virtual void destroy();
00104
00105 protected:
00106
00107 virtual void getAttributeElements(const GEO_Detail &beforegdp,
00108 const GEO_Detail &aftergdp,
00109 unsigned int before_elem_index,
00110 unsigned int after_elem_index,
00111 const GB_AttributeElem *&beforeelem,
00112 const GB_AttributeElem *&afterelem) const;
00113
00114
00115
00116 void buildOffsetArray(const GEO_Detail &gdp,
00117 UT_IntArray &array);
00118
00119
00120
00121
00122
00123 bool calculatePrimVertex(unsigned int idx,
00124 const UT_IntArray &offsets,
00125 unsigned int &primidx,
00126 unsigned int &vertexidx,
00127 int start=0,
00128 int end=-1) const;
00129
00130 private:
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 UT_IntArray myOffsets;
00149
00150
00151
00152
00153
00154
00155
00156
00157 UT_IntArray myTempOffsets;
00158
00159
00160
00161 mutable unsigned int myNextPrim;
00162 mutable unsigned int myNextVertex;
00163 };
00164 #endif