Added type info to the custom attributes

This commit is contained in:
Gianpaolo Palma 2017-12-07 13:52:03 +01:00
parent 6b80ae85f2
commit f961a49248
3 changed files with 8 additions and 1 deletions

View File

@ -1070,6 +1070,7 @@ public:
h._sizeof = sizeof(ATTR_TYPE);
h._padding = 0;
h._handle = new SimpleTempData<VertContainer,ATTR_TYPE>(m.vert);
h._type = typeid(ATTR_TYPE);
m.attrn++;
h.n_attr = m.attrn;
std::pair < AttrIterator , bool> res = m.vert_attr.insert(h);
@ -1211,6 +1212,7 @@ public:
h._padding = 0;
// h._typename = typeid(ATTR_TYPE).name();
h._handle = new SimpleTempData<EdgeContainer,ATTR_TYPE>(m.edge);
h._type = typeid(ATTR_TYPE);
m.attrn++;
h.n_attr = m.attrn;
std::pair < AttrIterator , bool> res = m.edge_attr.insert(h);
@ -1334,6 +1336,7 @@ public:
h._sizeof = sizeof(ATTR_TYPE);
h._padding = 0;
h._handle = new SimpleTempData<FaceContainer,ATTR_TYPE>(m.face);
h._type = typeid(ATTR_TYPE);
m.attrn++;
h.n_attr = m.attrn;
std::pair < AttrIterator , bool> res = m.face_attr.insert(h);
@ -1452,6 +1455,7 @@ public:
h._sizeof = sizeof(ATTR_TYPE);
h._padding = 0;
h._handle = new Attribute<ATTR_TYPE>();
h._type = typeid(ATTR_TYPE);
m.attrn++;
h.n_attr = m.attrn;
std::pair < AttrIterator , bool> res = m.mesh_attr.insert(h);

View File

@ -37,10 +37,12 @@ public:
int _padding; // padding (used only with VMI loading)
int n_attr; // unique ID of the attribute
std::type_index _type;
void Resize(size_t sz){((SimpleTempDataBase *)_handle)->Resize(sz);}
void Reorder(std::vector<size_t> & newVertIndex){((SimpleTempDataBase *)_handle)->Reorder(newVertIndex);}
bool operator<(const PointerToAttribute b) const { return(_name.empty()&&b._name.empty())?(_handle < b._handle):( _name < b._name);}
PointerToAttribute(): _type(typeid(void)) { };
};

View File

@ -39,6 +39,7 @@
#include <stdexcept>
#include <limits>
#include <iterator>
#include <typeindex>
#include <wrap/callback.h>
#include <vcg/complex/exception.h>
#include <vcg/container/simple_temporary_data.h>