Different mesh generation tools support different mesh generation tasks. This examples demonstrates the abstract common interface of ViennaMesh.
Simple API example
SomeDomainType hull_domain; SomeOtherSomeType volume_domain; viennamesh::resulf_of::settings< some_mesher_tag > settings; viennamesh::run_algo< some_mesher_tag >( hull_domain, volume_domain, settings );
A more concrete example is given below. At first, a PLC file is read (using a TETGEN .poly file). This PLC is meshed to a hull and than further meshed to a volume mesh using a scalar field for the element size.
PLC to Volume Meshing Example
// simple functor for mesh cell size struct functor { template<typename point_type> double operator() (point_type const & p) const { return p[0] / 10.0 * 2.0 + 0.2; } }; int main() { viennagrid::config::plc_3d_domain plc_domain; // reading a simple cube in the PLC domain viennagrid::io::poly_reader reader; reader(plc_domain, "cube.poly"); viennagrid::config::triangular_3d_domain triangle_domain; // defining the settings for PLC meshing viennamesh::result_of::settings<viennamesh::cgal_plc_3d_mesher_tag>::type plc_settings; // actual PLC -> triangular hull meshing viennamesh::run_algo< viennamesh::cgal_plc_3d_mesher_tag >( plc_domain, triangle_domain, plc_settings ); // defining the settings for tetrahedron volume meshing viennamesh::result_of::settings<viennamesh::cgal_delaunay_tetrahedron_tag>::type tet_settings; // configuring the settings functor f; tet_settings.cell_size = f; // assigning functor is possible... tet_settings.cell_radius_edge_ratio = 1.5; // ... as well as simple double values viennagrid::config::tetrahedral_3d_domain tet_domain; // actual triangular hull -> tetrahedron volume meshing viennamesh::run_algo<viennamesh::cgal_delaunay_tetrahedron_tag>( triangle_domain, tet_domain, tet_settings ); // writing output to VTK file viennagrid::io::vtk_writer<viennagrid::config::tetrahedral_3d_domain, viennagrid::config::tetrahedral_3d_cell> vtk_volume_writer; vtk_volume_writer(tet_domain, "cube_poly_meshed.vtu"); }