OGS
|
class TetGenInterface is used to read file formats used by TetGen. Currently supported formats are: poly - Geometric point and surface definition node - mesh node / geometric point definition ele - mesh element definition
Definition at line 40 of file TetGenInterface.h.
#include <TetGenInterface.h>
Public Member Functions | |
TetGenInterface () | |
bool | readTetGenGeometry (std::string const &geo_fname, GeoLib::GEOObjects &geo_objects) |
MeshLib::Mesh * | readTetGenMesh (std::string const &nodes_fname, std::string const &ele_fname) |
bool | writeTetGenSmesh (const std::string &file_name, const MeshLib::Mesh &mesh, std::vector< MeshLib::Node > &attribute_points) const |
Static Public Member Functions | |
static bool | writeTetGenSmesh (const std::string &file_name, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name, const std::vector< GeoLib::Point > &attribute_points) |
Private Member Functions | |
std::size_t | getNFacets (std::ifstream &input) |
Returns the declared number of facets in the poly file. | |
bool | parseSmeshFacets (std::ifstream &input, std::vector< GeoLib::Surface * > &surfaces, const std::vector< GeoLib::Point * > &points, const std::vector< std::size_t > &pnt_id_map) |
bool | readNodesFromStream (std::ifstream &ins, std::vector< MeshLib::Node * > &nodes) |
bool | parseNodes (std::ifstream &ins, std::vector< MeshLib::Node * > &nodes, std::size_t n_nodes, std::size_t dim) |
bool | readElementsFromStream (std::ifstream &ins, std::vector< MeshLib::Element * > &elements, std::vector< int > &materials, const std::vector< MeshLib::Node * > &nodes) const |
bool | parseElements (std::ifstream &ins, std::vector< MeshLib::Element * > &elements, std::vector< int > &materials, const std::vector< MeshLib::Node * > &nodes, std::size_t n_tets, std::size_t n_nodes_per_tet, bool region_attribute) const |
void | write2dElements (std::ofstream &out, const MeshLib::Mesh &mesh) const |
void | write3dElements (std::ofstream &out, const MeshLib::Mesh &mesh, std::vector< MeshLib::Node > &attribute_points) const |
Static Private Member Functions | |
static bool | parseNodesFileHeader (std::string const &line, std::size_t &n_nodes, std::size_t &dim, std::size_t &n_attributes, bool &boundary_markers) |
static bool | parseElementsFileHeader (std::string &line, std::size_t &n_tets, std::size_t &n_nodes_per_tet, bool ®ion_attribute) |
static void | writeElementToFacets (std::ofstream &out, const MeshLib::Element &element, unsigned &element_count, std::string const &matId) |
Writes facet information from a 2D element to the stream and increments the total element count accordingly. | |
Private Attributes | |
bool | _zero_based_idx {false} |
the value is true if the indexing is zero based, else false | |
bool | _boundary_markers {false} |
true if boundary markers are set, false otherwise | |
|
default |
|
private |
Returns the declared number of facets in the poly file.
Definition at line 93 of file TetGenInterface.cpp.
References _boundary_markers, ERR(), BaseLib::simplify(), BaseLib::splitString(), and BaseLib::str2number().
Referenced by parseSmeshFacets().
|
private |
Method parses the tetrahedras and put them in the element vector of the mesh class.
ins | the input stream |
elements | the elements vector to be filled |
materials | the vector containing material ids to be filled |
nodes | the node information needed for creating elements |
n_tets | the number of tetrahedras that should be read |
n_nodes_per_tet | the number of nodes per tetrahedron |
region_attribute | if region attribute is true, region information is read |
Definition at line 504 of file TetGenInterface.cpp.
References _zero_based_idx, ERR(), and BaseLib::str2number().
Referenced by readElementsFromStream().
|
staticprivate |
Method parses the header of the elements file created by TetGen
line | the header is in this string (input) |
n_tets | the number of tets to read (input) |
n_nodes_per_tet | the number of nodes per tets (input) |
region_attribute | is on output true, if there |
Definition at line 465 of file TetGenInterface.cpp.
References ERR(), and BaseLib::str2number().
Referenced by readElementsFromStream().
|
private |
method parses the lines reading the nodes from TetGen nodes file
ins | the input stream (input) |
nodes | the nodes vector to be filled (input) |
n_nodes | the number of nodes to read (input) |
dim | the spatial dimension of the node (input) |
Definition at line 342 of file TetGenInterface.cpp.
References _zero_based_idx, ERR(), and BaseLib::str2number().
Referenced by readNodesFromStream().
|
staticprivate |
Method parses the header of the nodes file created by TetGen
line | the header is in this string (input) |
n_nodes | number of nodes in the file (output) |
dim | the spatial dimension of the node (output) |
n_attributes | the number of attributes for each node (output) |
boundary_markers | have the nodes boundary information (output) |
Definition at line 311 of file TetGenInterface.cpp.
References ERR(), BaseLib::splitString(), and BaseLib::str2number().
Referenced by readNodesFromStream().
|
private |
Method parses the lines reading the facets from TetGen smesh file
input | the input stream (input) |
surfaces | the vector of surfaces to be filled (output) |
points | the point vector needed for creating surfaces (input) |
pnt_id_map | the id map to compensate for possibly changed point ids after adding the point vector to GEOObjects |
Definition at line 124 of file TetGenInterface.cpp.
References _boundary_markers, _zero_based_idx, ERR(), getNFacets(), BaseLib::simplify(), BaseLib::splitString(), and BaseLib::str2number().
Referenced by readTetGenGeometry().
|
private |
Method reads the elements from stream and stores them in an element vector. For this purpose it uses methods parseElementsFileHeader() and parseElements().
ins | the input stream |
elements | the elements vector to be filled |
materials | the vector containing material ids to be filled |
nodes | the node information needed for creating elements |
Definition at line 421 of file TetGenInterface.cpp.
References parseElements(), parseElementsFileHeader(), and BaseLib::simplify().
Referenced by readTetGenMesh().
|
private |
Method reads the nodes from stream and stores them in a node vector. For this purpose it uses methods parseNodesFileHeader() and parseNodes().
ins | the input stream |
nodes | output vector of nodes. |
Definition at line 276 of file TetGenInterface.cpp.
References parseNodes(), parseNodesFileHeader(), and BaseLib::simplify().
Referenced by readTetGenGeometry(), and readTetGenMesh().
bool FileIO::TetGenInterface::readTetGenGeometry | ( | std::string const & | geo_fname, |
GeoLib::GEOObjects & | geo_objects ) |
Method reads geometry from a TetGen poly or smesh file.
geo_fname | file name of the poly file |
geo_objects | where the geometry is written to |
Definition at line 46 of file TetGenInterface.cpp.
References GeoLib::GEOObjects::addPointVec(), GeoLib::GEOObjects::addSurfaceVec(), BaseLib::cleanupVectorElements(), FileIO::constructPointsFromNodes(), ERR(), BaseLib::extractBaseNameWithoutExtension(), BaseLib::getFileExtension(), GeoLib::PointVec::getIDMap(), GeoLib::GEOObjects::getPointVec(), GeoLib::GEOObjects::getPointVecObj(), parseSmeshFacets(), and readNodesFromStream().
Referenced by MainWindow::loadFile().
MeshLib::Mesh * FileIO::TetGenInterface::readTetGenMesh | ( | std::string const & | nodes_fname, |
std::string const & | ele_fname ) |
Method reads the TetGen mesh from node file and element file.
nodes_fname | file name of the nodes file |
ele_fname | file name of the elements file |
Definition at line 220 of file TetGenInterface.cpp.
References MeshLib::Cell, BaseLib::cleanupVectorElements(), MeshLib::Properties::createNewPropertyVector(), ERR(), BaseLib::extractBaseNameWithoutExtension(), readElementsFromStream(), and readNodesFromStream().
Referenced by MainWindow::loadFile().
|
private |
Writes the elements from a 2D mesh to a TetGen smesh-file.
out | the output stream the information is written to. |
mesh | mesh containing the subsurface boundary representation used for meshing. |
Definition at line 751 of file TetGenInterface.cpp.
References MeshLib::Properties::existsPropertyVector(), MeshLib::Mesh::getElements(), MeshToolsLib::MeshInformation::getNumberOfElementTypes(), MeshLib::Mesh::getProperties(), MeshLib::Properties::getPropertyVector(), MeshLib::QUAD, MeshLib::TRIANGLE, and writeElementToFacets().
Referenced by writeTetGenSmesh().
|
private |
Writes the elements from a 3D mesh to a TetGen smesh-file.
out | the output stream the information is written to. |
mesh | the 3D mesh. |
attribute_points | attribute points containing material IDs (emptied when called and then filled with correct values). |
Definition at line 782 of file TetGenInterface.cpp.
References MeshLib::getCenterOfGravity(), MeshLib::Mesh::getElements(), MeshLib::Element::getID(), MeshLib::Mesh::getProperties(), MeshLib::Properties::getPropertyVector(), and writeElementToFacets().
Referenced by writeTetGenSmesh().
|
staticprivate |
Writes facet information from a 2D element to the stream and increments the total element count accordingly.
Definition at line 841 of file TetGenInterface.cpp.
References MeshLib::Element::getGeomType(), MeshLib::QUAD, and MeshLib::TRIANGLE.
Referenced by write2dElements(), and write3dElements().
|
static |
Writes the geometry of a given name to TetGen smesh-file.
file_name | file name of the new smesh file. |
geo_objects | the container for the geometry. |
geo_name | the name for the geometry containing the subsurface boundary representation used for meshing. |
attribute_points | attribute points containing material IDs (if the vector is empty no attributes are written). |
Definition at line 610 of file TetGenInterface.cpp.
References ERR(), GeoLib::GEOObjects::getPointVec(), GeoLib::GEOObjects::getSurfaceVec(), INFO(), and WARN().
Referenced by MeshLayerEditDialog::createTetMesh(), MeshView::exportToTetGen(), and main().
bool FileIO::TetGenInterface::writeTetGenSmesh | ( | const std::string & | file_name, |
const MeshLib::Mesh & | mesh, | ||
std::vector< MeshLib::Node > & | attribute_points ) const |
Writes the geometry of a given name to TetGen smesh-file.
file_name | file name of the new smesh file. |
mesh | mesh containing the subsurface boundary representation used for meshing. |
attribute_points | attribute points containing material IDs (if the vector is empty no attributes are written). |
Definition at line 690 of file TetGenInterface.cpp.
References MeshLib::Mesh::getDimension(), MeshLib::Mesh::getNodes(), MeshLib::Mesh::getNumberOfElements(), INFO(), write2dElements(), and write3dElements().
|
private |
true if boundary markers are set, false otherwise
Definition at line 219 of file TetGenInterface.h.
Referenced by getNFacets(), and parseSmeshFacets().
|
private |
the value is true if the indexing is zero based, else false
Definition at line 216 of file TetGenInterface.h.
Referenced by parseElements(), parseNodes(), and parseSmeshFacets().