diff --git a/Applications/Utils/GeoTools/TriangulatePolyline.cpp b/Applications/Utils/GeoTools/TriangulatePolyline.cpp index eb3aceb767d927cf1df12ae548ee727906152379..e61a8b55fd60058ed752b81dae08733383ddc70b 100644 --- a/Applications/Utils/GeoTools/TriangulatePolyline.cpp +++ b/Applications/Utils/GeoTools/TriangulatePolyline.cpp @@ -46,8 +46,8 @@ int main(int argc, char *argv[]) TCLAP::CmdLine cmd("Triangulates the specified polyline in the given geometry file.", ' ', BaseLib::BuildInfo::git_describe); TCLAP::ValueArg<std::string> input_arg("i", "input", "GML input file (*.gml)", true, "", "string"); - TCLAP::ValueArg<std::string> name_arg("n", "name", "Name of polyline in given file", true, "", "string"); TCLAP::ValueArg<std::string> output_arg("o", "output", "GML output file (*.gml)", true, "", "string"); + TCLAP::ValueArg<std::string> name_arg("n", "name", "Name of polyline in given file", true, "", "string"); cmd.add( input_arg ); cmd.add( name_arg ); cmd.add( output_arg ); @@ -105,10 +105,18 @@ int main(int argc, char *argv[]) geo_objects.addSurfaceVec(new_sfc, geo_names[0]); else geo_objects.appendSurfaceVec(*new_sfc, geo_names[0]); - std::string const surface_name (polyline_name + "_surface"); std::size_t const sfc_id = geo_objects.getSurfaceVec(geo_names[0])->size() - 1; - sfc_vec->setNameForElement(sfc_id, surface_name); - + std::string const surface_name (polyline_name + "_surface"); + for (std::size_t i=1;;++i) + { + std::string const new_surface_name = (i>1) ? (surface_name + std::to_string(i)) : surface_name; + if (sfc_vec->getElementByName(new_surface_name) == nullptr) + { + sfc_vec->setNameForElement(sfc_id, new_surface_name); + break; + } + } + // write new file xml.setNameForExport(geo_names[0]); xml.writeToFile(output_arg.getValue()); diff --git a/GeoLib/Polyline.cpp b/GeoLib/Polyline.cpp index 000d9bce51b6500ec39f4f2723067b5aa557d17e..1436dd1e5d8dd2315642a2233a14b2772f796b26 100644 --- a/GeoLib/Polyline.cpp +++ b/GeoLib/Polyline.cpp @@ -196,18 +196,18 @@ bool Polyline::isClosed() const bool Polyline::isCoplanar() const { std::size_t const n_points (_ply_pnt_ids.size()); - if (n_points > 3) + if (n_points < 4) + return true; + + GeoLib::Point const& p0 (*this->getPoint(0)); + GeoLib::Point const& p1 (*this->getPoint(1)); + GeoLib::Point const& p2 (*this->getPoint(2)); + for (std::size_t i=3; i<n_points; ++i) { - GeoLib::Point const& p0 (*this->getPoint(0)); - GeoLib::Point const& p1 (*this->getPoint(1)); - GeoLib::Point const& p2 (*this->getPoint(2)); - for (std::size_t i=3; i<n_points; ++i) + if (!GeoLib::isCoplanar(p0, p1, p2, *this->getPoint(i))) { - if (!GeoLib::isCoplanar(p0, p1, p2, *this->getPoint(i))) - { - ERR ("Point %d is not coplanar to the first three points of the line.", i); - return false; - } + ERR ("Point %d is not coplanar to the first three points of the line.", i); + return false; } } return true;