diff --git a/FileIO/TetGenInterface.cpp b/FileIO/TetGenInterface.cpp index 5f7aa3a7c274130af389df8885af1275d6f99c09..dea69f3086245e30b9b6583e5af0efa428086c03 100644 --- a/FileIO/TetGenInterface.cpp +++ b/FileIO/TetGenInterface.cpp @@ -55,7 +55,7 @@ bool TetGenInterface::readTetGenPoly (std::string const& poly_fname, } std::vector<MeshLib::Node*> nodes; - if (!readNodesFromStream (poly_stream, nodes)) + if (!readNodesFromStream (poly_stream, nodes)) { // remove nodes read until now for (std::size_t k(0); k<nodes.size(); ++k) @@ -65,7 +65,7 @@ bool TetGenInterface::readTetGenPoly (std::string const& poly_fname, const std::size_t nNodes (nodes.size()); std::vector<GeoLib::Point*> *points = new std::vector<GeoLib::Point*>; points->reserve(nNodes); - for (std::size_t k(0); k<nNodes; ++k) + for (std::size_t k(0); k<nNodes; ++k) { points->push_back(new GeoLib::Point(nodes[k]->getCoords())); delete nodes[k]; @@ -110,7 +110,7 @@ std::size_t TetGenInterface::getNFacets(std::ifstream &input) const return false; } -bool TetGenInterface::parseFacets(std::ifstream &input, +bool TetGenInterface::parseFacets(std::ifstream &input, std::vector<GeoLib::Surface*> &surfaces, std::vector<GeoLib::Point*> &points) { @@ -229,7 +229,7 @@ MeshLib::Mesh* TetGenInterface::readTetGenMesh (std::string const& nodes_fname, return new MeshLib::Mesh(mesh_name, nodes, elements); } -bool TetGenInterface::readNodesFromStream (std::ifstream &ins, +bool TetGenInterface::readNodesFromStream (std::ifstream &ins, std::vector<MeshLib::Node*> &nodes) { std::string line; @@ -259,10 +259,10 @@ bool TetGenInterface::readNodesFromStream (std::ifstream &ins, return false; } -bool TetGenInterface::parseNodesFileHeader(std::string &line, - std::size_t &n_nodes, +bool TetGenInterface::parseNodesFileHeader(std::string &line, + std::size_t &n_nodes, std::size_t &dim, - std::size_t &n_attributes, + std::size_t &n_attributes, bool &boundary_markers) const { std::size_t pos_beg, pos_end; @@ -298,9 +298,9 @@ bool TetGenInterface::parseNodesFileHeader(std::string &line, return true; } -bool TetGenInterface::parseNodes(std::ifstream &ins, - std::vector<MeshLib::Node*> &nodes, - std::size_t n_nodes, +bool TetGenInterface::parseNodes(std::ifstream &ins, + std::vector<MeshLib::Node*> &nodes, + std::size_t n_nodes, std::size_t dim) { std::size_t pos_beg, pos_end, id; @@ -308,10 +308,10 @@ bool TetGenInterface::parseNodes(std::ifstream &ins, double* coordinates (static_cast<double*> (alloca (sizeof(double) * dim))); nodes.reserve(n_nodes); - for (std::size_t k(0); k < n_nodes && !ins.fail(); k++) + for (std::size_t k(0); k < n_nodes && !ins.fail(); k++) { getline(ins, line); - if (ins.fail()) + if (ins.fail()) { ERR("TetGenInterface::parseNodes(): Error reading node %d.", k); return false; @@ -356,8 +356,8 @@ bool TetGenInterface::parseNodes(std::ifstream &ins, return true; } -bool TetGenInterface::readElementsFromStream(std::ifstream &ins, - std::vector<MeshLib::Element*> &elements, +bool TetGenInterface::readElementsFromStream(std::ifstream &ins, + std::vector<MeshLib::Element*> &elements, const std::vector<MeshLib::Node*> &nodes) { std::string line; @@ -421,10 +421,10 @@ bool TetGenInterface::parseElementsFileHeader(std::string &line, return true; } -bool TetGenInterface::parseElements(std::ifstream& ins, - std::vector<MeshLib::Element*> &elements, - const std::vector<MeshLib::Node*> &nodes, - std::size_t n_tets, +bool TetGenInterface::parseElements(std::ifstream& ins, + std::vector<MeshLib::Element*> &elements, + const std::vector<MeshLib::Node*> &nodes, + std::size_t n_tets, std::size_t n_nodes_per_tet, bool region_attribute) { @@ -452,7 +452,7 @@ bool TetGenInterface::parseElements(std::ifstream& ins, k--; continue; } - + if (pos_beg != std::string::npos && pos_end != std::string::npos) id = BaseLib::str2number<size_t>(line.substr(pos_beg, pos_end - pos_beg)); else { @@ -498,8 +498,8 @@ bool TetGenInterface::parseElements(std::ifstream& ins, return true; } -bool TetGenInterface::writeTetGenPoly(const std::string &file_name, - const GeoLib::GEOObjects &geo_objects, +bool TetGenInterface::writeTetGenPoly(const std::string &file_name, + const GeoLib::GEOObjects &geo_objects, const std::string &geo_name) const { std::vector<GeoLib::Point*> const*const points = geo_objects.getPointVec(geo_name); @@ -533,7 +533,7 @@ bool TetGenInterface::writeTetGenPoly(const std::string &file_name, for (std::size_t j=0; j<nTriangles; ++j) { const GeoLib::Triangle &tri = *(*(*surfaces)[i])[j]; - out << "3 " << tri[0] << " " << tri[1] << " " << tri[2] << "\n"; + out << "3 " << tri[0] << " " << tri[1] << " " << tri[2] << "\n"; } } out << "0\n"; // the polygon holes list diff --git a/FileIO/TetGenInterface.h b/FileIO/TetGenInterface.h index 0555213a61bf6070c987c3d3bbd133f988268f4b..43c15c999b3fffbac3fb30651824ff9b92661595 100644 --- a/FileIO/TetGenInterface.h +++ b/FileIO/TetGenInterface.h @@ -67,9 +67,9 @@ public: * @param geo_name the name for the geometry. * @return returns true on success and false otherwise. */ - bool writeTetGenPoly(const std::string &file_name, - const GeoLib::GEOObjects &geo_objects, - const std::string &geo_name) const; + bool writeTetGenPoly(const std::string &file_name, + const GeoLib::GEOObjects &geo_objects, + const std::string &geo_name) const; private: /** @@ -78,11 +78,11 @@ private: * @param input the input stream * @return true, if all information is read, false if the method detects an error */ - bool readFacetsFromStream(std::ifstream &input, + bool readFacetsFromStream(std::ifstream &input, std::vector<GeoLib::Point*> &points); /// Returns the declared number of facets in the poly file. - std::size_t getNFacets(std::ifstream &input) const; + std::size_t getNFacets(std::ifstream &input) const; /** * Method parses the lines reading the facets from TetGen poly file @@ -91,7 +91,7 @@ private: * @param points the point vector needed for creating surfaces (input) * @return true, if the facets have been read correctly, false if the method detects an error */ - bool parseFacets(std::ifstream &input, + bool parseFacets(std::ifstream &input, std::vector<GeoLib::Surface*> &surfaces, std::vector<GeoLib::Point*> &points); @@ -101,7 +101,7 @@ private: * @param input the input stream * @return true, if all information is read, false if the method detects an error */ - bool readNodesFromStream(std::ifstream &input, + bool readNodesFromStream(std::ifstream &input, std::vector<MeshLib::Node*> &nodes); /** @@ -113,11 +113,11 @@ private: * @param boundary_markers have the nodes boundary information (output) * @return true, if the file header is read, false if the method detects an error */ - bool parseNodesFileHeader(std::string &line, - std::size_t &n_nodes, - std::size_t &dim, - std::size_t &n_attributes, - bool &boundary_markers) const; + bool parseNodesFileHeader(std::string &line, + std::size_t &n_nodes, + std::size_t &dim, + std::size_t &n_attributes, + bool &boundary_markers) const; /** * method parses the lines reading the nodes from TetGen nodes file * @param ins the input stream (input) @@ -126,9 +126,9 @@ private: * @param dim the spatial dimension of the node (input) * @return true, if the nodes are read, false if the method detects an error */ - bool parseNodes(std::ifstream &ins, - std::vector<MeshLib::Node*> &nodes, - std::size_t n_nodes, + bool parseNodes(std::ifstream &ins, + std::vector<MeshLib::Node*> &nodes, + std::size_t n_nodes, std::size_t dim); /** @@ -139,9 +139,9 @@ private: * @param nodes the node information needed for creating elements * @return true, if all information is read, false if the method detects an error */ - bool readElementsFromStream(std::ifstream &input, - std::vector<MeshLib::Element*> &elements, - const std::vector<MeshLib::Node*> &nodes); + bool readElementsFromStream(std::ifstream &input, + std::vector<MeshLib::Element*> &elements, + const std::vector<MeshLib::Node*> &nodes) const; /** * Method parses the header of the elements file created by TetGen * @param line the header is in this string (input) @@ -150,8 +150,8 @@ private: * @param region_attribute is on output true, if there * @return */ - bool parseElementsFileHeader(std::string &line, - std::size_t &n_tets, + bool parseElementsFileHeader(std::string &line, + std::size_t &n_tets, std::size_t &n_nodes_per_tet, bool ®ion_attribute) const; /** @@ -164,12 +164,12 @@ private: * @param region_attribute if region attribute is true, region information is read * @return true, if the tetrahedras are read, false if the method detects an error */ - bool parseElements(std::ifstream& ins, - std::vector<MeshLib::Element*> &elements, - const std::vector<MeshLib::Node*> &nodes, - std::size_t n_tets, - std::size_t n_nodes_per_tet, - bool region_attribute); + bool parseElements(std::ifstream& ins, + std::vector<MeshLib::Element*> &elements, + const std::vector<MeshLib::Node*> &nodes, + std::size_t n_tets, + std::size_t n_nodes_per_tet, + bool region_attribute) const; /** * the value is true if the indexing is zero based, else false