libMesh::TetGenWrapper Class Reference
#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 |
Detailed Description
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 & Destructor Documentation
| libMesh::TetGenWrapper::TetGenWrapper | ( | ) |
Constructor.
Definition at line 34 of file mesh_tetgen_wrapper.C.
References tetgen_data, and tetgen_output.
00035 { 00036 tetgen_output = new tetgenio; 00037 00038 this->tetgen_data.mesh_dim = 3; 00039 this->tetgen_data.numberofpointattributes = 0; 00040 this->tetgen_data.firstnumber = 0; 00041 }
| libMesh::TetGenWrapper::~TetGenWrapper | ( | ) |
Destructor. Empty.
Definition at line 45 of file mesh_tetgen_wrapper.C.
References tetgen_output.
00046 { 00047 delete tetgen_output; 00048 }
Member Function Documentation
| 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 301 of file mesh_tetgen_wrapper.C.
References libMesh::err, set_facet_numberofholes(), set_facet_numberofpolygons(), and tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
00302 { 00303 this->set_facet_numberofpolygons(i, numofpolygons); 00304 this->set_facet_numberofholes(i, 0); 00305 00306 // Don't try to create an array of size zero, this isn't portable 00307 if (numofpolygons > 0) 00308 { 00309 // Is there previously-allocated memory here? 00310 if (this->tetgen_data.facetlist[i].polygonlist != NULL) 00311 { 00312 libMesh::err << "Cannot allocate on top of previously allocated memory!" << std::endl; 00313 libmesh_error(); 00314 } 00315 00316 // We allocate memory here, the tetgenio destructor cleans it up. 00317 this->tetgen_data.facetlist[i].polygonlist = new tetgenio::polygon[numofpolygons]; 00318 00319 for (int j=0; j<this->tetgen_data.facetlist[i].numberofpolygons; j++) 00320 this->tetgen_data.init(&(this->tetgen_data.facetlist[i].polygonlist[j])); 00321 } 00322 }
| void libMesh::TetGenWrapper::allocate_facetlist | ( | int | numoffacets, | |
| int | numofholes | |||
| ) |
Method allocates memory, sets number of facets, holes in TetGen input.
Definition at line 223 of file mesh_tetgen_wrapper.C.
References libMesh::err, set_numberoffacets(), set_numberofholes(), and tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
00224 { 00225 // These are both stored as ints in TetGen 00226 this->set_numberoffacets(numoffacets); 00227 this->set_numberofholes(numofholes); 00228 00229 // Don't try to allocate an array of size zero, this is not portable... 00230 if (this->tetgen_data.numberoffacets > 0) 00231 { 00232 // Is there previously-allocated memory here? 00233 if (this->tetgen_data.facetlist != NULL) 00234 { 00235 libMesh::err << "Cannot allocate on top of previously allocated memory!" << std::endl; 00236 libmesh_error(); 00237 } 00238 00239 // We allocate memory here, the tetgenio destructor cleans it up. 00240 this->tetgen_data.facetlist = new tetgenio::facet[this->tetgen_data.numberoffacets]; 00241 00242 for (int i=0; i<numoffacets; i++) 00243 this->tetgen_data.init(&(this->tetgen_data.facetlist[i])); 00244 } 00245 00246 00247 // Don't try to allocate an array of size zero, this is not portable... 00248 if (this->tetgen_data.numberofholes > 0) 00249 { 00250 // Is there previously-allocated memory here? 00251 if (this->tetgen_data.holelist != NULL) 00252 { 00253 libMesh::err << "Cannot allocate on top of previously allocated memory!" << std::endl; 00254 libmesh_error(); 00255 } 00256 00257 this->tetgen_data.holelist = new REAL[this->tetgen_data.numberofholes * 3]; 00258 } 00259 }
| void libMesh::TetGenWrapper::allocate_pointlist | ( | int | numofpoints | ) |
Method allocates memory, sets number of nodes in TetGen input.
Definition at line 144 of file mesh_tetgen_wrapper.C.
References libMesh::err, set_numberofpoints(), and tetgen_data.
Referenced by libMesh::TetGenMeshInterface::fill_pointlist().
00145 { 00146 // This is stored as an int in tetgen, so we store it that way as well. 00147 this->set_numberofpoints(numofpoints); 00148 00149 // Don't try to allocate an array of size zero, this is not portable... 00150 if (this->tetgen_data.numberofpoints > 0) 00151 { 00152 // Is there previously-allocated memory here? 00153 if (this->tetgen_data.pointlist != NULL) 00154 { 00155 libMesh::err << "Cannot allocate on top of previously allocated memory!" << std::endl; 00156 libmesh_error(); 00157 } 00158 00159 // We allocate memory here, the tetgenio destructor will delete it. 00160 this->tetgen_data.pointlist = new REAL[this->tetgen_data.numberofpoints * 3]; 00161 } 00162 }
| 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 334 of file mesh_tetgen_wrapper.C.
References libMesh::err, set_polygon_numberofvertices(), and tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
00335 { 00336 this->set_polygon_numberofvertices(i, j, numofvertices); 00337 00338 // Don't try to create an array of size zero, this isn't portable 00339 if (numofvertices > 0) 00340 { 00341 // Is there previously-allocated memory here? 00342 if (this->tetgen_data.facetlist[i].polygonlist[j].vertexlist != NULL) 00343 { 00344 libMesh::err << "Cannot allocate on top of previously allocated memory!" << std::endl; 00345 libmesh_error(); 00346 } 00347 00348 // We allocate memory here, the tetgenio destructor cleans it up. 00349 this->tetgen_data.facetlist[i].polygonlist[j].vertexlist = new int[numofvertices]; 00350 } 00351 }
| void libMesh::TetGenWrapper::allocate_regionlist | ( | int | numofregions | ) |
Method allocates memory, sets number of regions in TetGen input.
Definition at line 263 of file mesh_tetgen_wrapper.C.
References libMesh::err, set_numberofregions(), and tetgen_data.
00264 { 00265 this->set_numberofregions(numofregions); 00266 00267 // Don't try to allocate an array of size zero, this is not portable... 00268 if (this->tetgen_data.numberofregions > 0) 00269 { 00270 // Is there previously-allocated memory here? 00271 if (this->tetgen_data.regionlist != NULL) 00272 { 00273 libMesh::err << "Cannot allocate on top of previously allocated memory!" << std::endl; 00274 libmesh_error(); 00275 } 00276 00277 // We allocate memory here, the tetgenio destructor cleans it up. 00278 this->tetgen_data.regionlist = new REAL[this->tetgen_data.numberofregions * 5]; 00279 } 00280 }
| REAL libMesh::TetGenWrapper::get_element_attribute | ( | unsigned | i | ) |
Method returns attribute of element i in TetGen output.
Definition at line 136 of file mesh_tetgen_wrapper.C.
References tetgen_output.
00137 { 00138 libmesh_assert(tetgen_output->numberoftetrahedronattributes>0); 00139 return tetgen_output->tetrahedronattributelist[tetgen_output->numberoftetrahedronattributes*i]; 00140 }
| 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 122 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::TetGenMeshInterface::triangulate_pointset().
00123 { 00124 return tetgen_output->tetrahedronlist[i*4+j]; 00125 }
| int libMesh::TetGenWrapper::get_numberofpoints | ( | ) |
Method returns number of nodes in TetGen output.
Definition at line 115 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
00116 { 00117 return tetgen_output->numberofpoints; 00118 }
| int libMesh::TetGenWrapper::get_numberoftetrahedra | ( | ) |
Method returns number of tetrahedra in TetGen output.
Definition at line 101 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::TetGenMeshInterface::triangulate_pointset().
00102 { 00103 return tetgen_output->numberoftetrahedra; 00104 }
| int libMesh::TetGenWrapper::get_numberoftrifaces | ( | ) |
Method returns number of triangle surface elts. in TetGen output.
Definition at line 108 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::pointset_convexhull().
00109 { 00110 return tetgen_output->numberoftrifaces; 00111 }
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().
00081 { 00082 // Bounds checking... 00083 if (i >= static_cast<unsigned>(tetgen_output->numberofpoints)) 00084 { 00085 std::cerr << "Error, requested point " 00086 << i 00087 << ", but there are only " 00088 << tetgen_output->numberofpoints 00089 << " points available." 00090 << std::endl; 00091 libmesh_error(); 00092 } 00093 00094 x = tetgen_output->pointlist[3*i]; 00095 y = tetgen_output->pointlist[3*i+1]; 00096 z = tetgen_output->pointlist[3*i+2]; 00097 }
| 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 129 of file mesh_tetgen_wrapper.C.
References tetgen_output.
Referenced by libMesh::TetGenMeshInterface::pointset_convexhull().
00130 { 00131 return tetgen_output->trifacelist[i*3+j]; 00132 }
| void libMesh::TetGenWrapper::run_tetgen | ( | ) |
Method starts triangulization.
Definition at line 191 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().
00192 { 00193 // Call tetrahedralize from the TetGen library. 00194 tetrahedralize(&tetgen_be, &tetgen_data, tetgen_output); 00195 }
| void libMesh::TetGenWrapper::set_facet_numberofholes | ( | unsigned | i, | |
| int | num | |||
| ) |
Method sets number of holes for facet i in TetGen input.
Definition at line 292 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_facet_polygonlist().
00293 { 00294 // numberofholes is stored as an int in TetGen 00295 this->tetgen_data.facetlist[i].numberofholes = num; 00296 }
| void libMesh::TetGenWrapper::set_facet_numberofpolygons | ( | unsigned | i, | |
| int | num | |||
| ) |
Method sets number of polygons for facet i in TetGen input.
Definition at line 284 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_facet_polygonlist().
00285 { 00286 // numberofpolygons is stored as an int in TetGen 00287 this->tetgen_data.facetlist[i].numberofpolygons = num; 00288 }
Method sets coordinates of hole i in TetGen input.
Definition at line 62 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
00063 { 00064 unsigned index = i*3; 00065 tetgen_data.holelist[index++] = x; 00066 tetgen_data.holelist[index++] = y; 00067 tetgen_data.holelist[index++] = z; 00068 }
Method sets coordinates of point i in TetGen input.
Definition at line 52 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by libMesh::TetGenMeshInterface::fill_pointlist().
00053 { 00054 unsigned index = i*3; 00055 tetgen_data.pointlist[index++] = x; 00056 tetgen_data.pointlist[index++] = y; 00057 tetgen_data.pointlist[index++] = z; 00058 }
| void libMesh::TetGenWrapper::set_numberoffacets | ( | int | i | ) |
Method sets number of facets in TetGen input.
Definition at line 199 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_facetlist().
00200 { 00201 // This is stored as an int in TetGen 00202 this->tetgen_data.numberoffacets = i; 00203 }
| void libMesh::TetGenWrapper::set_numberofholes | ( | int | i | ) |
Method sets number of holes in TetGen input.
Definition at line 207 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_facetlist().
00208 { 00209 // This is stored as an int in TetGen 00210 this->tetgen_data.numberofholes = i; 00211 }
| 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().
00073 { 00074 // This is an int in tetgen, so use an int here even though it should be unsigned 00075 tetgen_data.numberofpoints = i; 00076 }
| void libMesh::TetGenWrapper::set_numberofregions | ( | int | i | ) |
Method sets number of regions in TetGen input.
Definition at line 215 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_regionlist().
00216 { 00217 // This is stored as an int in TetGen 00218 this->tetgen_data.numberofregions = i; 00219 }
| 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 326 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by allocate_polygon_vertexlist().
00327 { 00328 // numberofvertices is stored as an int in TetGen 00329 this->tetgen_data.facetlist[i].polygonlist[j].numberofvertices = num; 00330 }
| 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 364 of file mesh_tetgen_wrapper.C.
References tetgen_data.
00366 { 00367 unsigned index = i*5; 00368 tetgen_data.regionlist[index++] = x; 00369 tetgen_data.regionlist[index++] = y; 00370 tetgen_data.regionlist[index++] = z; 00371 tetgen_data.regionlist[index++] = attribute; 00372 tetgen_data.regionlist[index++] = vol_constraint; 00373 }
| 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 166 of file mesh_tetgen_wrapper.C.
References libMesh::err, libMesh::out, and tetgen_be.
Referenced by libMesh::TetGenMeshInterface::pointset_convexhull(), libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole(), and libMesh::TetGenMeshInterface::triangulate_pointset().
00167 { 00168 // A temporary buffer for passing to the C API, it requires 00169 // a char*, not a const char*... 00170 char buffer[256]; 00171 00172 // Make sure char buffer has enough room 00173 if (s.size() >= sizeof(buffer)-1) 00174 { 00175 libMesh::err << "Fixed size buffer of length " 00176 << sizeof(buffer) 00177 << " not large enough to hold TetGen switches." 00178 << std::endl; 00179 libmesh_error(); 00180 } 00181 00182 // Copy the string, don't forget to NULL-terminate! 00183 buffer[ s.copy( buffer , sizeof( buffer ) - 1 ) ] = '\0' ; 00184 00185 if (!tetgen_be.parse_commandline(buffer)) 00186 libMesh::out << "TetGen replies: Wrong switches!" << std::endl; 00187 }
| 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 356 of file mesh_tetgen_wrapper.C.
References tetgen_data.
Referenced by libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
00357 { 00358 // vertexlist entries are stored as ints in TetGen 00359 this->tetgen_data.facetlist[i].polygonlist[j].vertexlist[k] = nodeindex; 00360 }
Member Data Documentation
| 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().
The documentation for this class was generated from the following files:
Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:29 UTC
Hosted By: