Examples
How to handle the mesh class
back to menu
back to Mesh class
example 1
example 2
Example 1 : loading, expanding and saving a mesh
double scale;
//loading the mesh
Mesh m;
m.load("mesh.off");
//expanding the mesh
for (list<Mpoint*>::iterator i = m._points.begin(); i!=m._points.end(); i++ )
{
Vec normal = (*i)->local_normal();
(*i)->_update_coord = (*i)->get_coord() + (normal * scale);
}
m.update();
//testing for self intersection
if (m.real_self_intersection()) cerr<<"error : mesh is self intersecting"<<endl;
//saving mesh
m.save("output.off");
back to menu
Example 2 : creating a mesh by tesselating a tetrahedron, moving it, and giving a good orientation to triangles
//creating the mesh
Mesh m;
make_mesh_from_tetra(5, m);
double scale_factor = 2;
Pt center(1.5, 2, 3);
Vec translation_vector(0, 13, 5.17);
//translating and rescaling the mesh
m.translation(translation_vector);
m.rescale(scale_factor, center);
//giving a good orientation to triangle
m.reorientate();
//note this is useless here since make_mesh_from_tetra already gives a uniform orientation to the triangles
back to menu