- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# Doc/Tutorial/09-persistence/generate_cube.hh

    00001 #ifndef GENERATE_CUBE_HH
    00002 #define GENERATE_CUBE_HH
    00003
    00004 template <typename MeshType>
    00005 size_t generate_cube( MeshType& mesh )
    00006 {
    00007   typedef typename MeshType::VertexHandle VertexHandle;
    00008   typedef typename MeshType::Point Point;
    00009
    00010   typename MeshType::VertexHandle vhandle[8];
    00011
    00012   vhandle[0] = mesh.add_vertex(Point(-1, -1,  1));
    00013   vhandle[1] = mesh.add_vertex(Point( 1, -1,  1));
    00014   vhandle[2] = mesh.add_vertex(Point( 1,  1,  1));
    00015   vhandle[3] = mesh.add_vertex(Point(-1,  1,  1));
    00016   vhandle[4] = mesh.add_vertex(Point(-1, -1, -1));
    00017   vhandle[5] = mesh.add_vertex(Point( 1, -1, -1));
    00018   vhandle[6] = mesh.add_vertex(Point( 1,  1, -1));
    00019   vhandle[7] = mesh.add_vertex(Point(-1,  1, -1));
    00020
    00021   // generate (quadrilateral) faces
    00022
    00023   std::vector< VertexHandle >  face_vhandles;
    00024
    00025   face_vhandles.clear();
    00026   face_vhandles.push_back(vhandle[0]);
    00027   face_vhandles.push_back(vhandle[1]);
    00028   face_vhandles.push_back(vhandle[2]);
    00029   face_vhandles.push_back(vhandle[3]);
    00030   mesh.add_face(face_vhandles);
    00031
    00032   face_vhandles.clear();
    00033   face_vhandles.push_back(vhandle[7]);
    00034   face_vhandles.push_back(vhandle[6]);
    00035   face_vhandles.push_back(vhandle[5]);
    00036   face_vhandles.push_back(vhandle[4]);
    00037   mesh.add_face(face_vhandles);
    00038
    00039   face_vhandles.clear();
    00040   face_vhandles.push_back(vhandle[1]);
    00041   face_vhandles.push_back(vhandle[0]);
    00042   face_vhandles.push_back(vhandle[4]);
    00043   face_vhandles.push_back(vhandle[5]);
    00044   mesh.add_face(face_vhandles);
    00045
    00046   face_vhandles.clear();
    00047   face_vhandles.push_back(vhandle[2]);
    00048   face_vhandles.push_back(vhandle[1]);
    00049   face_vhandles.push_back(vhandle[5]);
    00050   face_vhandles.push_back(vhandle[6]);
    00051   mesh.add_face(face_vhandles);
    00052
    00053   face_vhandles.clear();
    00054   face_vhandles.push_back(vhandle[3]);
    00055   face_vhandles.push_back(vhandle[2]);
    00056   face_vhandles.push_back(vhandle[6]);
    00057   face_vhandles.push_back(vhandle[7]);
    00058   mesh.add_face(face_vhandles);
    00059
    00060   face_vhandles.clear();
    00061   face_vhandles.push_back(vhandle[0]);
    00062   face_vhandles.push_back(vhandle[3]);
    00063   face_vhandles.push_back(vhandle[7]);
    00064   face_vhandles.push_back(vhandle[4]);
    00065   mesh.add_face(face_vhandles);
    00066
    00067   return mesh.n_vertices();
    00068 };
    00069
    00070 #endif