Changed the semantic and the return value of the generic DeleteAttribute (e.g. the one that does not take a type)
** It must not crash if you try to delete a non existing attribute, because you do not have a way of asking for a handle of an attribute for which you do not know the type.
This commit is contained in:
parent
e5842d71d8
commit
2ab3b3ab5b
|
@ -989,14 +989,18 @@ public:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generic DeleteAttribute.
|
||||||
|
// It must not crash if you try to delete a non existing attribute,
|
||||||
|
// because you do not have a way of asking for a handle of an attribute for which you do not know the type.
|
||||||
static
|
static
|
||||||
void DeletePerVertexAttribute( MeshType & m, std::string name){
|
bool DeletePerVertexAttribute( MeshType & m, std::string name){
|
||||||
AttrIterator i;
|
AttrIterator i;
|
||||||
PointerToAttribute h1; h1._name = name;
|
PointerToAttribute h1; h1._name = name;
|
||||||
i = m.vert_attr.find(h1);
|
i = m.vert_attr.find(h1);
|
||||||
assert(i!=m.vert_attr.end());
|
if(i==m.vert_attr.end()) return false;
|
||||||
delete ((SimpleTempDataBase*)(*i)._handle);
|
delete ((SimpleTempDataBase*)(*i)._handle);
|
||||||
m.vert_attr.erase(i);
|
m.vert_attr.erase(i);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1077,14 +1081,18 @@ public:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generic DeleteAttribute.
|
||||||
|
// It must not crash if you try to delete a non existing attribute,
|
||||||
|
// because you do not have a way of asking for a handle of an attribute for which you do not know the type.
|
||||||
static
|
static
|
||||||
void DeletePerEdgeAttribute( MeshType & m, std::string name){
|
bool DeletePerEdgeAttribute( MeshType & m, std::string name){
|
||||||
AttrIterator i;
|
AttrIterator i;
|
||||||
PointerToAttribute h1; h1._name = name;
|
PointerToAttribute h1; h1._name = name;
|
||||||
i = m.edge_attr.find(h1);
|
i = m.edge_attr.find(h1);
|
||||||
assert(i!=m.edge_attr.end());
|
if(i==m.edge_attr.end()) return false;
|
||||||
delete ((SimpleTempDataBase*)(*i)._handle);
|
delete ((SimpleTempDataBase*)(*i)._handle);
|
||||||
m.edge_attr.erase(i);
|
m.edge_attr.erase(i);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Per Face Attributes
|
/// Per Face Attributes
|
||||||
|
@ -1176,14 +1184,18 @@ public:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generic DeleteAttribute.
|
||||||
|
// It must not crash if you try to delete a non existing attribute,
|
||||||
|
// because you do not have a way of asking for a handle of an attribute for which you do not know the type.
|
||||||
static
|
static
|
||||||
void DeletePerFaceAttribute( MeshType & m, std::string name){
|
bool DeletePerFaceAttribute( MeshType & m, std::string name){
|
||||||
AttrIterator i;
|
AttrIterator i;
|
||||||
PointerToAttribute h1; h1._name = name;
|
PointerToAttribute h1; h1._name = name;
|
||||||
i = m.face_attr.find(h1);
|
i = m.face_attr.find(h1);
|
||||||
assert(i!=m.face_attr.end());
|
if(i==m.face_attr.end()) return false;
|
||||||
delete ((SimpleTempDataBase*)(*i)._handle);
|
delete ((SimpleTempDataBase*)(*i)._handle);
|
||||||
m.face_attr.erase(i);
|
m.face_attr.erase(i);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Per Mesh Attributes
|
/// Per Mesh Attributes
|
||||||
|
|
Loading…
Reference in New Issue