1 #ifndef GENERATE_CUBE_HH
2 #define GENERATE_CUBE_HH
4 template <
typename MeshType>
5 size_t generate_cube( MeshType& mesh )
7 typedef typename MeshType::VertexHandle VertexHandle;
8 typedef typename MeshType::Point Point;
10 typename MeshType::VertexHandle vhandle[8];
12 vhandle[0] = mesh.add_vertex(Point(-1, -1, 1));
13 vhandle[1] = mesh.add_vertex(Point( 1, -1, 1));
14 vhandle[2] = mesh.add_vertex(Point( 1, 1, 1));
15 vhandle[3] = mesh.add_vertex(Point(-1, 1, 1));
16 vhandle[4] = mesh.add_vertex(Point(-1, -1, -1));
17 vhandle[5] = mesh.add_vertex(Point( 1, -1, -1));
18 vhandle[6] = mesh.add_vertex(Point( 1, 1, -1));
19 vhandle[7] = mesh.add_vertex(Point(-1, 1, -1));
23 std::vector< VertexHandle > face_vhandles;
25 face_vhandles.clear();
26 face_vhandles.push_back(vhandle[0]);
27 face_vhandles.push_back(vhandle[1]);
28 face_vhandles.push_back(vhandle[2]);
29 face_vhandles.push_back(vhandle[3]);
30 mesh.add_face(face_vhandles);
32 face_vhandles.clear();
33 face_vhandles.push_back(vhandle[7]);
34 face_vhandles.push_back(vhandle[6]);
35 face_vhandles.push_back(vhandle[5]);
36 face_vhandles.push_back(vhandle[4]);
37 mesh.add_face(face_vhandles);
39 face_vhandles.clear();
40 face_vhandles.push_back(vhandle[1]);
41 face_vhandles.push_back(vhandle[0]);
42 face_vhandles.push_back(vhandle[4]);
43 face_vhandles.push_back(vhandle[5]);
44 mesh.add_face(face_vhandles);
46 face_vhandles.clear();
47 face_vhandles.push_back(vhandle[2]);
48 face_vhandles.push_back(vhandle[1]);
49 face_vhandles.push_back(vhandle[5]);
50 face_vhandles.push_back(vhandle[6]);
51 mesh.add_face(face_vhandles);
53 face_vhandles.clear();
54 face_vhandles.push_back(vhandle[3]);
55 face_vhandles.push_back(vhandle[2]);
56 face_vhandles.push_back(vhandle[6]);
57 face_vhandles.push_back(vhandle[7]);
58 mesh.add_face(face_vhandles);
60 face_vhandles.clear();
61 face_vhandles.push_back(vhandle[0]);
62 face_vhandles.push_back(vhandle[3]);
63 face_vhandles.push_back(vhandle[7]);
64 face_vhandles.push_back(vhandle[4]);
65 mesh.add_face(face_vhandles);
67 return mesh.n_vertices();