00001
00002 #include<vcg/simplex/vertex/base.h>
00003 #include<vcg/simplex/vertex/component.h>
00004 #include<vcg/simplex/face/base.h>
00005 #include<vcg/simplex/face/component.h>
00006 #include<vcg/complex/trimesh/base.h>
00007 #include<vcg/complex/trimesh/allocate.h>
00008
00009
00010 class MyEdge;
00011 class MyFace;
00012 class MyVertex;
00013 struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex> ::AsVertexType,
00014 vcg::Use<MyFace> ::AsFaceType>{};
00015
00016 class MyVertex : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f,vcg::vertex::Normal3f>{};
00017 class MyFace : public vcg::Face< MyUsedTypes, vcg::face::VertexRef, vcg::face::Normal3f> {};
00018
00019 class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
00020
00021
00022 float Irradiance(MyMesh::VertexType v){
00023
00024 return 1.0;
00025 }
00026
00027 int main()
00028 {
00029
00030
00031 MyMesh m;
00032
00033
00034
00035 MyMesh::PerVertexAttributeHandle<float> ih = vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<float> (m,std::string("Irradiance"));
00036
00037
00038 vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<float> (m,std::string("Radiosity"));
00039
00040
00041 MyMesh::PerVertexAttributeHandle<bool> blocked_h = vcg::tri::Allocator<MyMesh>::AddPerVertexAttribute<bool> (m);
00042
00043
00044 MyMesh::PerFaceAttributeHandle<bool> blocked_hf = vcg::tri::Allocator<MyMesh>::AddPerFaceAttribute<bool> (m);
00045
00046 MyMesh::VertexIterator vi; int i = 0;
00047 for(vi = m.vert.begin(); vi != m.vert.end(); ++vi,++i){
00048 ih[vi] = Irradiance(*vi);
00049 ih[*vi] = Irradiance(*vi);
00050 ih[&*vi]= Irradiance(*vi);
00051 ih[i] = Irradiance(*vi);
00052 }
00053
00054
00055 MyMesh::PerVertexAttributeHandle<float> rh = vcg::tri::Allocator<MyMesh>::GetPerVertexAttribute<float>(m,"Radiosity");
00056
00057
00058 bool hasRadiosity = vcg::tri::HasPerVertexAttribute(m,"Radiosity");
00059
00060
00061 vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,"Radiosity");
00062
00063
00064 vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,blocked_h);
00065
00066 bool res ;
00067
00068 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,ih);printf("%d\n",res);
00069 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,blocked_hf);printf("%d\n",res);
00070 vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,ih);
00071 vcg::tri::Allocator<MyMesh>::DeletePerFaceAttribute(m,blocked_hf);
00072 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,ih);printf("%d\n",res);
00073 res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,blocked_hf);printf("%d\n",res);
00074
00075
00076 }