Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00032 #include<vcg/complex/complex.h>
00033 class MyEdge;
00034 class MyFace;
00035 class MyVertex;
00036 struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex> ::AsVertexType,
00037 vcg::Use<MyFace> ::AsFaceType>{};
00038
00039 class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f,vcg::vertex::Normal3f>{};
00040 class MyFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f> {};
00041
00042 class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
00043
00044 int main()
00045 {
00046 MyMesh m;
00048
00049 MyMesh::PerVertexAttributeHandle<float> named_hv = vcg::tri::Allocator<MyMesh>:: GetPerVertexAttribute<float> (m,std::string("Irradiance"));
00051
00052
00053 vcg::tri::Allocator<MyMesh>:: GetPerVertexAttribute<float> (m,std::string("Radiosity"));
00054
00055
00056 MyMesh::PerVertexAttributeHandle<bool> anon_hv = vcg::tri::Allocator<MyMesh>:: GetPerVertexAttribute<bool> (m);
00057
00058
00059 MyMesh::PerFaceAttributeHandle<bool> anon_hf = vcg::tri::Allocator<MyMesh>:: GetPerFaceAttribute<bool> (m);
00060
00062 MyMesh::VertexIterator vi; int i;
00063 for(i=0, vi = m.vert.begin(); vi != m.vert.end(); ++vi,++i){
00064 named_hv[vi] = 1.0f;
00065 named_hv[*vi] = 1.0f;
00066 named_hv[&*vi]= 1.0f;
00067 named_hv[i] = 1.0f;
00068 }
00070
00071 vcg::tri::Allocator<MyMesh>::ClearPerVertexAttribute<float>(m,named_hv);
00072
00073
00074 bool hasRadiosity = vcg::tri::HasPerVertexAttribute(m,"Radiosity");
00075
00076
00077 MyMesh::PerVertexAttributeHandle<float> ret_hv = vcg::tri::Allocator<MyMesh>:: FindPerVertexAttribute<float>(m,"Radiosity");
00078
00080
00081 MyMesh::PerMeshAttributeHandle<int> hm = vcg::tri::Allocator<MyMesh>:: GetPerMeshAttribute<int> (m,std::string("ADummyIntegerAttribute"));
00082
00083 hm() = 10;
00085
00087
00088 vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m, "Radiosity");
00089
00090
00091 vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m, anon_hv);
00093
00094 bool res;
00095 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,named_hv); printf("Is Valid: %s\n",res?"Yes":"No");
00096 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,anon_hf); printf("Is Valid: %s\n",res?"Yes":"No");
00097 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,hm); printf("Is Valid: %s\n",res?"Yes":"No");
00098 vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,ret_hv);
00099 vcg::tri::Allocator<MyMesh>::DeletePerFaceAttribute(m,anon_hf);
00100 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,named_hv); printf("Is Valid: %s\n",res?"Yes":"No");
00101 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,anon_hf); printf("Is Valid: %s\n",res?"Yes":"No");
00102 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,hm); printf("Is Valid: %s\n",res?"Yes":"No");
00103 }