diff --git a/vcg/complex/trimesh/platonic.h b/vcg/complex/trimesh/platonic.h index 727620cc..c9219615 100644 --- a/vcg/complex/trimesh/platonic.h +++ b/vcg/complex/trimesh/platonic.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.4 2004/03/11 18:14:19 tarini +prova + Revision 1.2 2004/03/03 16:11:46 cignoni First working version (tetrahedron!) @@ -37,82 +40,76 @@ First working version (tetrahedron!) #include namespace vcg { namespace tri { -cacca -template -void Tetrahedron(MESH_TYPE &in) + +template +void Tetrahedron(TetraMeshType &in) { in.Clear(); - Allocator::AddVertices(in,4); - Allocator::AddFaces(in,4); + Allocator::AddVertices(in,4); + Allocator::AddFaces(in,4); - MESH_TYPE::VertexPointer ivp[4]; + TetraMeshType::VertexPointer ivp[4]; - MESH_TYPE::VertexIterator vi=in.vert.begin(); - ivp[0]=&*vi;(*vi).P()=MESH_TYPE::CoordType ( 1, 1, 1); ++vi; - ivp[1]=&*vi;(*vi).P()=MESH_TYPE::CoordType (-1, 1,-1); ++vi; - ivp[2]=&*vi;(*vi).P()=MESH_TYPE::CoordType (-1,-1, 1); ++vi; - ivp[3]=&*vi;(*vi).P()=MESH_TYPE::CoordType ( 1,-1,-1); + TetraMeshType::VertexIterator vi=in.vert.begin(); + ivp[0]=&*vi;(*vi).P()=TetraMeshType::CoordType ( 1, 1, 1); ++vi; + ivp[1]=&*vi;(*vi).P()=TetraMeshType::CoordType (-1, 1,-1); ++vi; + ivp[2]=&*vi;(*vi).P()=TetraMeshType::CoordType (-1,-1, 1); ++vi; + ivp[3]=&*vi;(*vi).P()=TetraMeshType::CoordType ( 1,-1,-1); - MESH_TYPE::FaceIterator fi=in.face.begin(); + TetraMeshType::FaceIterator fi=in.face.begin(); (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[1]; (*fi).V(2)=ivp[2]; ++fi; (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[3]; ++fi; (*fi).V(0)=ivp[0]; (*fi).V(1)=ivp[3]; (*fi).V(2)=ivp[1]; ++fi; (*fi).V(0)=ivp[3]; (*fi).V(1)=ivp[2]; (*fi).V(2)=ivp[1]; } -template -void Octahedron(MESH_TYPE &in) +template +void Octahedron(OctMeshType &in) { - in.vn=6; - in.fn=8; - in.vert.clear(); - in.face.clear(); - MESH_TYPE::VertexType tv;tv.Supervisor_Flags()=0; - MESH_TYPE::CoordType tp; - tp=MESH_TYPE::CoordType ( 1, 0, 0); tv.P()=tp; in.vert.push_back(tv); - tp=MESH_TYPE::CoordType ( 0, 1, 0); tv.P()=tp; in.vert.push_back(tv); - tp=MESH_TYPE::CoordType ( 0, 0, 1); tv.P()=tp; in.vert.push_back(tv); - tp=MESH_TYPE::CoordType (-1, 0, 0); tv.P()=tp; in.vert.push_back(tv); - tp=MESH_TYPE::CoordType ( 0,-1, 0); tv.P()=tp; in.vert.push_back(tv); - tp=MESH_TYPE::CoordType ( 0, 0,-1); tv.P()=tp; in.vert.push_back(tv); + in.Clear(); + Allocator::AddVertices(in,6); + Allocator::AddFaces(in,8); - vector index(in.vn); - - MESH_TYPE::face_type f;f.Supervisor_Flags()=0; - - MESH_TYPE::vertex_iterator vi; - int j; - for(j=0,vi=in.vert.begin();j -void Icosahedron(MESH_TYPE &in) +template +void Icosahedron(IcoMeshType &in) { - MESH_TYPE::ScalarType L=(Sqrt(5.0)+1.0)/2.0; - MESH_TYPE::CoordType vv[12]={ - MESH_TYPE::CoordType ( 0, L, 1), - MESH_TYPE::CoordType ( 0, L,-1), - MESH_TYPE::CoordType ( 0,-L, 1), - MESH_TYPE::CoordType ( 0,-L,-1), + IcoMeshType::ScalarType L=IcoMeshType::ScalarType((math::Sqrt(5.0)+1.0)/2.0); + IcoMeshType::CoordType vv[12]={ + IcoMeshType::CoordType ( 0, L, 1), + IcoMeshType::CoordType ( 0, L,-1), + IcoMeshType::CoordType ( 0,-L, 1), + IcoMeshType::CoordType ( 0,-L,-1), - MESH_TYPE::CoordType ( L, 1, 0), - MESH_TYPE::CoordType ( L,-1, 0), - MESH_TYPE::CoordType (-L, 1, 0), - MESH_TYPE::CoordType (-L,-1, 0), + IcoMeshType::CoordType ( L, 1, 0), + IcoMeshType::CoordType ( L,-1, 0), + IcoMeshType::CoordType (-L, 1, 0), + IcoMeshType::CoordType (-L,-1, 0), - MESH_TYPE::CoordType ( 1, 0, L), - MESH_TYPE::CoordType (-1, 0, L), - MESH_TYPE::CoordType ( 1, 0,-L), - MESH_TYPE::CoordType (-1, 0,-L) + IcoMeshType::CoordType ( 1, 0, L), + IcoMeshType::CoordType (-1, 0, L), + IcoMeshType::CoordType ( 1, 0,-L), + IcoMeshType::CoordType (-1, 0,-L) }; int ff[20][3]={ @@ -123,31 +120,24 @@ void Icosahedron(MESH_TYPE &in) {2,5,8},{2,9,7},{3,10,5},{3,7,11} }; - in.vn=12; - in.fn=20; - in.vert.clear(); - in.face.clear(); - MESH_TYPE::VertexType tv;tv.Supervisor_Flags()=0; - MESH_TYPE::CoordType tp; - for(int i=0;i index(in.vn); - - MESH_TYPE::face_type f;f.Supervisor_Flags()=0; - - MESH_TYPE::vertex_iterator vi; - int j; - for(j=0,vi=in.vert.begin();j::AddVertices(in,12); + Allocator::AddFaces(in,20); + IcoMeshType::VertexPointer ivp[12]; + + IcoMeshType::VertexIterator vi; + int i; + for(i=0,vi=in.vert.begin();vi!=in.vert.end();++i,++vi){ + (*vi).P()=vv[i]; + ivp[i]=&*vi; + } + + IcoMeshType::FaceIterator fi; + for(i=0,fi=in.face.begin();fi!=in.face.end();++i,++fi){ + (*fi).V(0)=ivp[ff[i][0]]; + (*fi).V(1)=ivp[ff[i][1]]; + (*fi).V(2)=ivp[ff[i][2]]; } }