$extrastylesheet
#include <mesh_tetgen_wrapper.h>
Public Member Functions | |
| TetGenWrapper () | |
| ~TetGenWrapper () | |
| void | set_switches (const std::string &s) |
| void | run_tetgen () |
| int | get_numberoftetrahedra () |
| int | get_numberoftrifaces () |
| void | set_numberofpoints (int i) |
| int | get_numberofpoints () |
| void | set_numberoffacets (int i) |
| void | set_numberofholes (int i) |
| void | set_numberofregions (int i) |
| void | allocate_pointlist (int numofpoints) |
| void | allocate_facetlist (int numoffacets, int numofholes) |
| void | allocate_regionlist (int numofregions) |
| void | set_node (unsigned i, REAL x, REAL y, REAL z) |
| void | get_output_node (unsigned i, REAL &x, REAL &y, REAL &z) |
| int | get_element_node (unsigned i, unsigned j) |
| int | get_triface_node (unsigned i, unsigned j) |
| REAL | get_element_attribute (unsigned i) |
| void | set_hole (unsigned i, REAL x, REAL y, REAL z) |
| void | set_facet_numberofpolygons (unsigned i, int num) |
| void | set_facet_numberofholes (unsigned i, int num) |
| void | allocate_facet_polygonlist (unsigned i, int numofpolygons) |
| void | set_polygon_numberofvertices (unsigned i, unsigned j, int num) |
| void | allocate_polygon_vertexlist (unsigned i, unsigned j, int numofvertices) |
| void | set_vertex (unsigned i, unsigned j, unsigned k, int nodeindex) |
| void | set_region (unsigned i, REAL x, REAL y, REAL z, REAL attribute, REAL vol_constraint) |
Public Attributes | |
| tetgenio | tetgen_data |
| tetgenio * | tetgen_output |
| tetgenmesh | tetgen_mesh |
| tetgenbehavior | tetgen_be |
The TetGenWrapper provides an interface for basic access to TetGen data structures and methods.
Definition at line 41 of file mesh_tetgen_wrapper.h.
Constructor.
Definition at line 34 of file mesh_tetgen_wrapper.C.
References tetgen_data, and tetgen_output.
{
tetgen_output = new tetgenio;
this->tetgen_data.mesh_dim = 3;
this->tetgen_data.numberofpointattributes = 0;
this->tetgen_data.firstnumber = 0;
}
Destructor. Empty.
Definition at line 45 of file mesh_tetgen_wrapper.C.
References tetgen_output.
{
delete tetgen_output;
}
| void libMesh::TetGenWrapper::allocate_facet_polygonlist | ( | unsigned | i, |
| int | numofpolygons | ||
| ) |
Method allocates memory, sets number of polygons for facet i in TetGen input.
Definition at line 281 of file mesh_tetgen_wrapper.C.
References set_facet_numberofholes(), set_facet_numberofpolygons(), and tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
{
this->set_facet_numberofpolygons(i, numofpolygons);
this->set_facet_numberofholes(i, 0);
// Don't try to create an array of size zero, this isn't portable
if (numofpolygons > 0)
{
// Is there previously-allocated memory here?
if (this->tetgen_data.facetlist[i].polygonlist != NULL)
libmesh_error_msg("Cannot allocate on top of previously allocated memory!");
// We allocate memory here, the tetgenio destructor cleans it up.
this->tetgen_data.facetlist[i].polygonlist = new tetgenio::polygon[numofpolygons];
for (int j=0; j<this->tetgen_data.facetlist[i].numberofpolygons; j++)
this->tetgen_data.init(&(this->tetgen_data.facetlist[i].polygonlist[j]));
}
}
| void libMesh::TetGenWrapper::allocate_facetlist | ( | int | numoffacets, |
| int | numofholes | ||
| ) |
Method allocates memory, sets number of facets, holes in TetGen input.
Definition at line 212 of file mesh_tetgen_wrapper.C.
References set_numberoffacets(), set_numberofholes(), and tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
{
// These are both stored as ints in TetGen
this->set_numberoffacets(numoffacets);
this->set_numberofholes(numofholes);
// Don't try to allocate an array of size zero, this is not portable...
if (this->tetgen_data.numberoffacets > 0)
{
// Is there previously-allocated memory here?
if (this->tetgen_data.facetlist != NULL)
libmesh_error_msg("Cannot allocate on top of previously allocated memory!");
// We allocate memory here, the tetgenio destructor cleans it up.
this->tetgen_data.facetlist = new tetgenio::facet[this->tetgen_data.numberoffacets];
for (int i=0; i<numoffacets; i++)
this->tetgen_data.init(&(this->tetgen_data.facetlist[i]));
}
// Don't try to allocate an array of size zero, this is not portable...
if (this->tetgen_data.numberofholes > 0)
{
// Is there previously-allocated memory here?
if (this->tetgen_data.holelist != NULL)
libmesh_error_msg("Cannot allocate on top of previously allocated memory!");
this->tetgen_data.holelist = new REAL[this->tetgen_data.numberofholes * 3];
}
}
| void libMesh::TetGenWrapper::allocate_pointlist | ( | int | numofpoints | ) |
Method allocates memory, sets number of nodes in TetGen input.
Definition at line 140 of file mesh_tetgen_wrapper.C.
References set_numberofpoints(), and tetgen_data.
Referenced by libMesh::TetGenMeshInterface::fill_pointlist().
{
// This is stored as an int in tetgen, so we store it that way as well.
this->set_numberofpoints(numofpoints);
// Don't try to allocate an array of size zero, this is not portable...
if (this->tetgen_data.numberofpoints > 0)
{
// Is there previously-allocated memory here?
if (this->tetgen_data.pointlist != NULL)
libmesh_error_msg("Cannot allocate on top of previously allocated memory!");
// We allocate memory here, the tetgenio destructor will delete it.
this->tetgen_data.pointlist = new REAL[this->tetgen_data.numberofpoints * 3];
}
}
| void libMesh::TetGenWrapper::allocate_polygon_vertexlist | ( | unsigned | i, |
| unsigned | j, | ||
| int | numofvertices | ||
| ) |
Method allocates memory, sets number of vertices for polygon j, facet i in TetGen input.
Definition at line 311 of file mesh_tetgen_wrapper.C.
References set_polygon_numberofvertices(), and tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
{
this->set_polygon_numberofvertices(i, j, numofvertices);
// Don't try to create an array of size zero, this isn't portable
if (numofvertices > 0)
{
// Is there previously-allocated memory here?
if (this->tetgen_data.facetlist[i].polygonlist[j].vertexlist != NULL)
libmesh_error_msg("Cannot allocate on top of previously allocated memory!");
// We allocate memory here, the tetgenio destructor cleans it up.
this->tetgen_data.facetlist[i].polygonlist[j].vertexlist = new int[numofvertices];
}
}
| void libMesh::TetGenWrapper::allocate_regionlist | ( | int | numofregions | ) |
Method allocates memory, sets number of regions in TetGen input.
Definition at line 246 of file mesh_tetgen_wrapper.C.
References set_numberofregions(), and tetgen_data.
{
this->set_numberofregions(numofregions);
// Don't try to allocate an array of size zero, this is not portable...
if (this->tetgen_data.numberofregions > 0)
{
// Is there previously-allocated memory here?
if (this->tetgen_data.regionlist != NULL)
libmesh_error_msg("Cannot allocate on top of previously allocated memory!");
// We allocate memory here, the tetgenio destructor cleans it up.
this->tetgen_data.regionlist = new REAL[this->tetgen_data.numberofregions * 5];
}
}
| REAL libMesh::TetGenWrapper::get_element_attribute | ( | unsigned | i | ) |
Method returns attribute of element i in TetGen output.
Definition at line 132 of file mesh_tetgen_wrapper.C.
References libMesh::libmesh_assert(), and tetgen_output.
{
libmesh_assert(tetgen_output->numberoftetrahedronattributes>0);
return tetgen_output->tetrahedronattributelist[tetgen_output->numberoftetrahedronattributes*i];
}
| int libMesh::TetGenWrapper::get_element_node | ( | unsigned | i, |
| unsigned | j | ||
| ) |
Method returns index of jth node from element i in TetGen output.
Definition at line 118 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::TetGenMeshInterface::triangulate_pointset().
{
return tetgen_output->tetrahedronlist[i*4+j];
}
Method returns number of nodes in TetGen output.
Definition at line 111 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
{
return tetgen_output->numberofpoints;
}
Method returns number of tetrahedra in TetGen output.
Definition at line 97 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::TetGenMeshInterface::triangulate_pointset().
{
return tetgen_output->numberoftetrahedra;
}
Method returns number of triangle surface elts. in TetGen output.
Definition at line 104 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::pointset_convexhull().
{
return tetgen_output->numberoftrifaces;
}
| void libMesh::TetGenWrapper::get_output_node | ( | unsigned | i, |
| REAL & | x, | ||
| REAL & | y, | ||
| REAL & | z | ||
| ) |
Method returns coordinates of point i in TetGen output.
Definition at line 80 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
{
// Bounds checking...
if (i >= static_cast<unsigned>(tetgen_output->numberofpoints))
libmesh_error_msg("Error, requested point " \
<< i \
<< ", but there are only " \
<< tetgen_output->numberofpoints \
<< " points available.");
x = tetgen_output->pointlist[3*i];
y = tetgen_output->pointlist[3*i+1];
z = tetgen_output->pointlist[3*i+2];
}
| int libMesh::TetGenWrapper::get_triface_node | ( | unsigned | i, |
| unsigned | j | ||
| ) |
Method returns index of jth node from surface triangle i in TetGen output.
Definition at line 125 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::pointset_convexhull().
{
return tetgen_output->trifacelist[i*3+j];
}
| void libMesh::TetGenWrapper::run_tetgen | ( | ) |
Method starts triangulization.
Definition at line 180 of file mesh_tetgen_wrapper.C.
References tetgen_be, tetgen_data, and tetgen_output.
Referenced by libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::TetGenMeshInterface::triangulate_pointset().
{
// Call tetrahedralize from the TetGen library.
tetrahedralize(&tetgen_be, &tetgen_data, tetgen_output);
}
| void libMesh::TetGenWrapper::set_facet_numberofholes | ( | unsigned | i, |
| int | num | ||
| ) |
Method sets number of holes for facet i in TetGen input.
Definition at line 272 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_facet_polygonlist().
{
// numberofholes is stored as an int in TetGen
this->tetgen_data.facetlist[i].numberofholes = num;
}
| void libMesh::TetGenWrapper::set_facet_numberofpolygons | ( | unsigned | i, |
| int | num | ||
| ) |
Method sets number of polygons for facet i in TetGen input.
Definition at line 264 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_facet_polygonlist().
{
// numberofpolygons is stored as an int in TetGen
this->tetgen_data.facetlist[i].numberofpolygons = num;
}
| void libMesh::TetGenWrapper::set_hole | ( | unsigned | i, |
| REAL | x, | ||
| REAL | y, | ||
| REAL | z | ||
| ) |
Method sets coordinates of hole i in TetGen input.
Definition at line 62 of file mesh_tetgen_wrapper.C.
References tetgen_data, and libMesh::x.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
{
unsigned index = i*3;
tetgen_data.holelist[index++] = x;
tetgen_data.holelist[index++] = y;
tetgen_data.holelist[index++] = z;
}
| void libMesh::TetGenWrapper::set_node | ( | unsigned | i, |
| REAL | x, | ||
| REAL | y, | ||
| REAL | z | ||
| ) |
Method sets coordinates of point i in TetGen input.
Definition at line 52 of file mesh_tetgen_wrapper.C.
References tetgen_data, and libMesh::x.
Referenced by libMesh::TetGenMeshInterface::fill_pointlist().
{
unsigned index = i*3;
tetgen_data.pointlist[index++] = x;
tetgen_data.pointlist[index++] = y;
tetgen_data.pointlist[index++] = z;
}
| void libMesh::TetGenWrapper::set_numberoffacets | ( | int | i | ) |
Method sets number of facets in TetGen input.
Definition at line 188 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_facetlist().
{
// This is stored as an int in TetGen
this->tetgen_data.numberoffacets = i;
}
| void libMesh::TetGenWrapper::set_numberofholes | ( | int | i | ) |
Method sets number of holes in TetGen input.
Definition at line 196 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_facetlist().
{
// This is stored as an int in TetGen
this->tetgen_data.numberofholes = i;
}
| void libMesh::TetGenWrapper::set_numberofpoints | ( | int | i | ) |
Method sets number of nodes in TetGen input.
Definition at line 72 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_pointlist().
{
// This is an int in tetgen, so use an int here even though it should be unsigned
tetgen_data.numberofpoints = i;
}
| void libMesh::TetGenWrapper::set_numberofregions | ( | int | i | ) |
Method sets number of regions in TetGen input.
Definition at line 204 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_regionlist().
{
// This is stored as an int in TetGen
this->tetgen_data.numberofregions = i;
}
| void libMesh::TetGenWrapper::set_polygon_numberofvertices | ( | unsigned | i, |
| unsigned | j, | ||
| int | num | ||
| ) |
Method sets number of vertices for polygon j, facet i in TetGen input.
Definition at line 303 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_polygon_vertexlist().
{
// numberofvertices is stored as an int in TetGen
this->tetgen_data.facetlist[i].polygonlist[j].numberofvertices = num;
}
| void libMesh::TetGenWrapper::set_region | ( | unsigned | i, |
| REAL | x, | ||
| REAL | y, | ||
| REAL | z, | ||
| REAL | attribute, | ||
| REAL | vol_constraint | ||
| ) |
Method sets coordinates, attribute and volume constraint for region i in TetGen input. Note that coordinates and attributes will only be considered if the corresponding switches are enabled. See TetGen documentation for more details.
Definition at line 338 of file mesh_tetgen_wrapper.C.
References tetgen_data, and libMesh::x.
{
unsigned index = i*5;
tetgen_data.regionlist[index++] = x;
tetgen_data.regionlist[index++] = y;
tetgen_data.regionlist[index++] = z;
tetgen_data.regionlist[index++] = attribute;
tetgen_data.regionlist[index++] = vol_constraint;
}
| void libMesh::TetGenWrapper::set_switches | ( | const std::string & | s | ) |
Method to set TetGen commandline switches -p Tetrahedralizes a piecewise linear complex (.poly or .smesh file). -q Quality mesh generation. A minimum radius-edge ratio may be specified (default 2.0). -a Applies a maximum tetrahedron volume constraint. -A Assigns attributes to identify tetrahedra in certain regions. -r Reconstructs and Refines a previously generated mesh. -Y Suppresses boundary facets/segments splitting. -i Inserts a list of additional points into mesh. -M Does not merge coplanar facets. -T Set a tolerance for coplanar test (default 1e-8). -d Detect intersections of PLC facets. -z Numbers all output items starting from zero. -o2 Generates second-order subparametric elements. -f Outputs faces (including non-boundary faces) to .face file. -e Outputs subsegments to .edge file. -n Outputs tetrahedra neighbors to .neigh file. -g Outputs mesh to .mesh file for viewing by Medit. -G Outputs mesh to .msh file for viewing by Gid. -O Outputs mesh to .off file for viewing by Geomview. -J No jettison of unused vertices from output .node file. -B Suppresses output of boundary information. -N Suppresses output of .node file. -E Suppresses output of .ele file. -F Suppresses output of .face file. -I Suppresses mesh iteration numbers. -C Checks the consistency of the final mesh. -Q Quiet: No terminal output except errors. -V Verbose: Detailed information, more terminal output. -v Prints the version information. -h Help: A brief instruction for using TetGen.
Definition at line 159 of file mesh_tetgen_wrapper.C.
References libMesh::out, and tetgen_be.
Referenced by libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::TetGenMeshInterface::triangulate_pointset().
{
// A temporary buffer for passing to the C API, it requires
// a char*, not a const char*...
char buffer[256];
// Make sure char buffer has enough room
if (s.size() >= sizeof(buffer)-1)
libmesh_error_msg("Fixed size buffer of length " \
<< sizeof(buffer) \
<< " not large enough to hold TetGen switches.");
// Copy the string, don't forget to NULL-terminate!
buffer[ s.copy( buffer , sizeof( buffer ) - 1 ) ] = '\0' ;
if (!tetgen_be.parse_commandline(buffer))
libMesh::out << "TetGen replies: Wrong switches!" << std::endl;
}
| void libMesh::TetGenWrapper::set_vertex | ( | unsigned | i, |
| unsigned | j, | ||
| unsigned | k, | ||
| int | nodeindex | ||
| ) |
Method sets index of ith facet, jth polygon, kth vertex in TetGen input.
Definition at line 330 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
{
// vertexlist entries are stored as ints in TetGen
this->tetgen_data.facetlist[i].polygonlist[j].vertexlist[k] = nodeindex;
}
| tetgenbehavior libMesh::TetGenWrapper::tetgen_be |
TetGen control class (from the TetGen library).
Definition at line 234 of file mesh_tetgen_wrapper.h.
Referenced by run_tetgen(), and set_switches().
| tetgenio libMesh::TetGenWrapper::tetgen_data |
TetGen input structure.
Definition at line 219 of file mesh_tetgen_wrapper.h.
Referenced by allocate_facet_polygonlist(), allocate_facetlist(), allocate_pointlist(), allocate_polygon_vertexlist(), allocate_regionlist(), run_tetgen(), set_facet_numberofholes(), set_facet_numberofpolygons(), set_hole(), set_node(), set_numberoffacets(), set_numberofholes(), set_numberofpoints(), set_numberofregions(), set_polygon_numberofvertices(), set_region(), set_vertex(), and TetGenWrapper().
| tetgenmesh libMesh::TetGenWrapper::tetgen_mesh |
TetGen mesh structure (from the TetGen library).
Definition at line 229 of file mesh_tetgen_wrapper.h.
| tetgenio* libMesh::TetGenWrapper::tetgen_output |
TetGen output structure.
Definition at line 224 of file mesh_tetgen_wrapper.h.
Referenced by get_element_attribute(), get_element_node(), get_numberofpoints(), get_numberoftetrahedra(), get_numberoftrifaces(), get_output_node(), get_triface_node(), run_tetgen(), TetGenWrapper(), and ~TetGenWrapper().