removed the (useless) template parameter to Per[XXX]DeleteAttribute

This commit is contained in:
ganovelli 2009-03-20 10:24:13 +00:00
parent 917343b0f5
commit 7378ad68a3
1 changed files with 57 additions and 41 deletions

View File

@ -13,44 +13,60 @@ class MyVertex : public vcg::VertexSimp2< MyVertex, MyEdge, MyFace, vcg::vertex
class MyFace : public vcg::FaceSimp2< MyVertex, MyEdge, MyFace, vcg::face::VertexRef, vcg::face::Normal3f> {}; class MyFace : public vcg::FaceSimp2< MyVertex, MyEdge, MyFace, vcg::face::VertexRef, vcg::face::Normal3f> {};
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {}; class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
float Irradiance(MyMesh::VertexType v){ float Irradiance(MyMesh::VertexType v){
// ..... // .....
return 1.0; return 1.0;
} }
int main() int main()
{ {
MyMesh m;
//...here m is filled
MyMesh m;
// add a per-vertex attribute with type float named "Irradiance" //...here m is filled
MyMesh::PerVertexAttributeHandle<float> ih = vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<float> (m,std::string("Irradiance"));
// add a per-vertex attribute with type float named "Irradiance"
// add a per-vertex attribute with type float named "Radiosity" MyMesh::PerVertexAttributeHandle<float> ih = vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<float> (m,std::string("Irradiance"));
vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<float> (m,std::string("Radiosity"));
// add a per-vertex attribute with type float named "Radiosity"
// add a per-vertex attribute with type bool and no name specified vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<float> (m,std::string("Radiosity"));
MyMesh::PerVertexAttributeHandle<bool> blocked_h = vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<bool> (m);
// add a per-vertex attribute with type bool and no name specified
MyMesh::VertexIterator vi; int i = 0; MyMesh::PerVertexAttributeHandle<bool> blocked_h = vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<bool> (m);
for(vi = m.vert.begin(); vi != m.vert.end(); ++vi,++i){
ih[vi] = Irradiance(*vi); // [] operator takes a iterator // add a per-vertex attribute with type bool and no name specified
ih[*vi] = Irradiance(*vi); // or a MyMesh::VertexType object MyMesh::PerFaceAttributeHandle<bool> blocked_hf = vcg::tri::Allocator<MyMesh>::AddPerFaceAttribute<bool> (m);
ih[&*vi]= Irradiance(*vi); // or a pointer to it
ih[i] = Irradiance(*vi); // or an integer index MyMesh::VertexIterator vi; int i = 0;
} for(vi = m.vert.begin(); vi != m.vert.end(); ++vi,++i){
ih[vi] = Irradiance(*vi); // [] operator takes a iterator
// Once created with AddPerVertexAttribute, an handle to the attribute can be obtained as follows ih[*vi] = Irradiance(*vi); // or a MyMesh::VertexType object
MyMesh::PerVertexAttributeHandle<float> rh = vcg::tri::Allocator<MyMesh>::GetPerVertexAttribute<float>(m,"Radiosity"); ih[&*vi]= Irradiance(*vi); // or a pointer to it
ih[i] = Irradiance(*vi); // or an integer index
// you can query if an attribute is present or not }
bool hasRadiosity = vcg::tri::HasPerVertexAttribute(m,"Radiosity");
// Once created with AddPerVertexAttribute, an handle to the attribute can be obtained as follows
// you can delete an attibute by name MyMesh::PerVertexAttributeHandle<float> rh = vcg::tri::Allocator<MyMesh>::GetPerVertexAttribute<float>(m,"Radiosity");
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute<float>(m,"Radiosity");
// you can query if an attribute is present or not
// you can delete an attibute by handle bool hasRadiosity = vcg::tri::HasPerVertexAttribute(m,"Radiosity");
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute<bool>(m,blocked_h);
} // you can delete an attibute by name
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,"Radiosity");
// you can delete an attibute by handle
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,blocked_h);
bool res ;
res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,ih);printf("%d\n",res);
res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,blocked_hf);printf("%d\n",res);
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,ih);
vcg::tri::Allocator<MyMesh>::DeletePerFaceAttribute(m,blocked_hf);
res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,ih);printf("%d\n",res);
res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,blocked_hf);printf("%d\n",res);
}