From b67dd27b620c9b795029f33a13e13c924cc1fb40 Mon Sep 17 00:00:00 2001 From: Karsten Rink <karsten.rink@ufz.de> Date: Fri, 9 May 2014 10:36:09 +0200 Subject: [PATCH] removed method for parsing poly-files --- FileIO/TetGenInterface.cpp | 90 ++------------------------------------ FileIO/TetGenInterface.h | 13 ------ 2 files changed, 3 insertions(+), 100 deletions(-) diff --git a/FileIO/TetGenInterface.cpp b/FileIO/TetGenInterface.cpp index dc8f094649a..839b98f6f22 100644 --- a/FileIO/TetGenInterface.cpp +++ b/FileIO/TetGenInterface.cpp @@ -58,9 +58,9 @@ bool TetGenInterface::readTetGenGeometry (std::string const& geo_fname, return false; } std::string ext (BaseLib::getFileExtension(geo_fname)); - if (ext.compare("poly") && ext.compare("smesh")) + if (ext.compare("smesh")) { - ERR ("TetGenInterface::readTetGenPoly() - unknown file type (only *.poly or *.smesh supported)."); + ERR ("TetGenInterface::readTetGenPoly() - unknown file type (only *.smesh are supported)."); return false; } @@ -85,12 +85,7 @@ bool TetGenInterface::readTetGenGeometry (std::string const& geo_fname, const std::vector<std::size_t> &id_map (geo_objects.getPointVecObj(geo_name)->getIDMap()); std::vector<GeoLib::Surface*> *surfaces = new std::vector<GeoLib::Surface*>; - bool failed (true); - if (ext.compare("poly") == 0) - failed = !parsePolyFacets(poly_stream, *surfaces, *points, id_map); - else - failed = !parseSmeshFacets(poly_stream, *surfaces, *points, id_map); - if (failed) + if (!parseSmeshFacets(poly_stream, *surfaces, *points, id_map)) { // remove surfaces read until now but keep the points for (std::size_t k=0; k<surfaces->size(); k++) @@ -130,85 +125,6 @@ std::size_t TetGenInterface::getNFacets(std::ifstream &input) return false; } -bool TetGenInterface::parsePolyFacets(std::ifstream &input, - std::vector<GeoLib::Surface*> &surfaces, - const std::vector<GeoLib::Point*> &points, - const std::vector<std::size_t> &pnt_id_map) -{ - const std::size_t nFacets (this->getNFacets(input)); - std::size_t nMultPolys (0); - std::string line; - surfaces.reserve(nFacets); - std::list<std::string>::const_iterator it; - - const unsigned offset = (_zero_based_idx) ? 0 : 1; - for (std::size_t k(0); k<nFacets && !input.fail(); k++) - { - getline (input, line); - if (input.fail()) - { - ERR("TetGenInterface::parseFacets(): Error reading facet %d.", k); - return false; - } - - BaseLib::simplify(line); - if (line.empty() || line.compare(0,1,"#") == 0) - { - k--; - continue; - } - - // read facets - const std::list<std::string> poly_def_fields = BaseLib::splitString(line, ' '); - it = poly_def_fields.begin(); - const std::size_t nPolys = BaseLib::str2number<std::size_t>(*it); - const std::size_t nPolyHoles = (poly_def_fields.size()>1) ? BaseLib::str2number<std::size_t>(*(++it)) : 0; - // here this line also potentially includes a boundary marker which we ignore for now - nMultPolys += (nPolys-1); - - // read polys - for (std::size_t i(0); i<nPolys && !input.fail(); ++i) - { - getline (input, line); - BaseLib::simplify(line); - if (line.empty() || line.compare(0,1,"#") == 0) - { - i--; - continue; - } - - const std::list<std::string> point_fields = BaseLib::splitString(line, ' '); - it = point_fields.begin(); - const std::size_t nPoints = BaseLib::str2number<std::size_t>(*it); - if (point_fields.size() > nPoints) - { - GeoLib::Polyline polyline(points); - for (std::size_t j(0); j<nPoints; ++j) - polyline.addPoint(pnt_id_map[BaseLib::str2number<std::size_t>(*(++it))-offset]); - - polyline.closePolyline(); - surfaces.push_back(GeoLib::Surface::createSurface(polyline)); - } - else - { - ERR("TetGenInterface::parseFacets(): Error reading points for polygon %d of facet %d.", i, k); - return false; - } - } - for (std::size_t j(0); j<nPolyHoles && !input.fail(); ++j) - getline(input, line); - // Here are points defined which are located in holes within the surface. We ignore these as they are not part of the actual geometry. - } - // here the poly-file potentially defines a number of points to mark holes within the volumes defined by the facets, these are ignored for now - // here the poly-file potentially defines a number of region attributes, these are ignored for now - - if (surfaces.size() == nFacets+nMultPolys) - return true; - - ERR ("TetGenInterface::parseFacets(): Number of expected surfaces (%d) does not match number of found surfaces (%d).", nFacets+nMultPolys, surfaces.size()); - return false; -} - bool TetGenInterface::parseSmeshFacets(std::ifstream &input, std::vector<GeoLib::Surface*> &surfaces, const std::vector<GeoLib::Point*> &points, diff --git a/FileIO/TetGenInterface.h b/FileIO/TetGenInterface.h index 2d9d0565bee..8ed6a9b5e13 100644 --- a/FileIO/TetGenInterface.h +++ b/FileIO/TetGenInterface.h @@ -88,19 +88,6 @@ private: /// Returns the declared number of facets in the poly file. std::size_t getNFacets(std::ifstream &input); - /** - * Method parses the lines reading the facets from TetGen poly file - * @param input the input stream (input) - * @param surfaces the vector of surfaces to be filled (output) - * @param points the point vector needed for creating surfaces (input) - * @param pnt_id_map the id map to compensate for possibly changed point ids after adding the point vector to GEOObjects - * @return true, if the facets have been read correctly, false if the method detects an error - */ - bool parsePolyFacets(std::ifstream &input, - std::vector<GeoLib::Surface*> &surfaces, - const std::vector<GeoLib::Point*> &points, - const std::vector<std::size_t> &pnt_id_map); - /** * Method parses the lines reading the facets from TetGen smesh file * @param input the input stream (input) -- GitLab