diff --git a/Gui/DataView/GeoMapper.cpp b/Gui/DataView/GeoMapper.cpp index e14622e54b69f74d538190ca4415e4a29219418a..2605f3618efa1ddce44983b963019855a913642c 100644 --- a/Gui/DataView/GeoMapper.cpp +++ b/Gui/DataView/GeoMapper.cpp @@ -87,7 +87,7 @@ std::vector<GeoLib::Polyline*>* copyPolylinesVector(const std::vector<GeoLib::Po } -void GeoMapper::advancedMapOnMesh(const MeshLib::Mesh* mesh) +void GeoMapper::advancedMapOnMesh(const MeshLib::Mesh* mesh, std::string &new_geo_name) { // copy geometry (and set z=0 for all points) const std::vector<GeoLib::Point*> *points (this->_geo_objects.getPointVec(this->_geo_name)); @@ -178,25 +178,22 @@ void GeoMapper::advancedMapOnMesh(const MeshLib::Mesh* mesh) if (intersection) // intersection found { intersection_count++; - std::size_t pos = insertPointInLine((*new_lines)[l], intersection, node_index_in_ply+index_offset-1, line_segment_map[l]); + std::size_t pos = getPointPosInLine((*new_lines)[l], intersection, node_index_in_ply+index_offset-1, line_segment_map[l]); if (pos) { const std::size_t pnt_pos (new_points->size()); - new_points->push_back(new GeoLib::Point(intersection->getCoords())); + new_points->push_back(intersection); (*new_lines)[l]->insertPoint(pos, pnt_pos); line_segment_map[l].insert(line_segment_map[l].begin()+pos, node_index_in_ply+index_offset-1); - } - delete intersection; } } } } } - std::string name ("new_geometry"); - this->_geo_objects.addPointVec(new_points, name); - this->_geo_objects.addPolylineVec(new_lines, name); + this->_geo_objects.addPointVec(new_points, new_geo_name); + this->_geo_objects.addPolylineVec(new_lines, new_geo_name); } GeoLib::Point* GeoMapper::calcIntersection(GeoLib::Point const*const p1, GeoLib::Point const*const p2, GeoLib::Point const*const q1, GeoLib::Point const*const q2) const @@ -222,7 +219,7 @@ GeoLib::Point* GeoMapper::calcIntersection(GeoLib::Point const*const p1, GeoLib: return NULL; } -std::size_t GeoMapper::insertPointInLine(GeoLib::Polyline const*const line, GeoLib::Point const*const point, unsigned line_segment, const std::vector<unsigned> &line_segment_map) const +std::size_t GeoMapper::getPointPosInLine(GeoLib::Polyline const*const line, GeoLib::Point const*const point, unsigned line_segment, const std::vector<unsigned> &line_segment_map) const { const std::size_t nPoints (line->getNumberOfPoints()); const GeoLib::Point* start (line->getPoint(line_segment)); @@ -259,11 +256,9 @@ double GeoMapper::getMaxSegmentLength(const std::vector<GeoLib::Polyline*> &line { const GeoLib::Polyline* line = lines[i]; const std::size_t nPlyPoints = line->getNumberOfPoints(); - double old_length (0); for (size_t j=1; j<nPlyPoints; ++j) { - double dist = (line->getLength(j)-old_length); - old_length = line->getLength(j); + const double dist (line->getLength(j)-line->getLength(j-1)); if (dist>max_segment_length) max_segment_length=dist; } diff --git a/Gui/DataView/GeoMapper.h b/Gui/DataView/GeoMapper.h index 4864acf9f6b4dc9a693026a4647c116554b58d54..9e48f877e4c277ad4baaf05b4054e2be3a0fa761 100644 --- a/Gui/DataView/GeoMapper.h +++ b/Gui/DataView/GeoMapper.h @@ -44,7 +44,7 @@ public: void mapOnMesh(const std::string &file_name); void mapOnMesh(const MeshLib::Mesh* mesh); - void advancedMapOnMesh(const MeshLib::Mesh* mesh); + void advancedMapOnMesh(const MeshLib::Mesh* mesh, std::string &new_geo_name); private: void mapData(MeshLib::Mesh const*const mesh = NULL); @@ -56,7 +56,7 @@ private: GeoLib::Point* calcIntersection(GeoLib::Point const*const p1, GeoLib::Point const*const p2, GeoLib::Point const*const q1, GeoLib::Point const*const q2) const; bool isNodeOnLine(GeoLib::Point const*const p1, GeoLib::Point const*const q1, GeoLib::Point const*const q2) const; bool isPntInBoundingBox(double ax, double ay, double bx, double by, double px, double py) const; - std::size_t insertPointInLine(GeoLib::Polyline const*const line, GeoLib::Point const*const point, unsigned line_segment, const std::vector<unsigned> &line_segment_map) const; + std::size_t getPointPosInLine(GeoLib::Polyline const*const line, GeoLib::Point const*const point, unsigned line_segment, const std::vector<unsigned> &line_segment_map) const; GeoLib::GEOObjects& _geo_objects; const std::string& _geo_name; diff --git a/Gui/mainwindow.cpp b/Gui/mainwindow.cpp index aebd41c5ddf77933f2e3989a0d1774722970bfe2..07ea7cd069c527e08074b0d0e8fedbb62937fc05 100644 --- a/Gui/mainwindow.cpp +++ b/Gui/mainwindow.cpp @@ -1189,7 +1189,7 @@ void MainWindow::FEMTestStart() { std::string name("TestExample"); GeoMapper mapper(*this->_geoModels, name); - mapper.advancedMapOnMesh(this->_project.getMesh(name)); + mapper.advancedMapOnMesh(this->_project.getMesh(name), std::string("new_geometry")); /* const double dir[3] = {0, 0, 1}; const MeshLib::Mesh* mesh = this->_project.getMesh("ketzin_2012_11_11_tets");