From 53320b260eb978861321eeb5021d92aaf97dcf46 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Mon, 7 Sep 2015 15:28:33 +0200 Subject: [PATCH] Sketcher: Renaming old get Coincident functions and introducing a extended one ============================================================================== What is this? method getCoincidentPoints actually only included (as indicated in the documentation comment) those points coincident by a single constraint. That is not "all the coincident points". However some methods currently using it are expecting exactly that (coincident points linked by a single constraint). A new method is introduced: const std::map getAllCoincidentPoints(int GeoId, PointPos PosId); that provides all the points coincident with the given one, directly (via a single constraint) or indirectly (via multiple coincident constraints). The old method is renamed to: getDirectlyCoincidentPoints So as to have a more meaningful name to differentiate between both methods. --- src/Mod/Sketcher/App/SketchObject.cpp | 34 +++++++++++++++++++---- src/Mod/Sketcher/App/SketchObject.h | 9 ++++-- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 4 +-- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index b67b4ab4b..7aaa2ab10 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -535,7 +535,7 @@ int SketchObject::delGeometry(int GeoId) std::vector GeoIdList; std::vector PosIdList; for (PointPos PosId = start; PosId != mid; ) { - getCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); + getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); if (GeoIdList.size() > 1) { delConstraintOnPoint(GeoId, PosId, true /* only coincidence */); transferConstraints(GeoIdList[0], PosIdList[0], GeoIdList[1], PosIdList[1]); @@ -820,7 +820,7 @@ int SketchObject::fillet(int GeoId, PointPos PosId, double radius, bool trim) // Find the other geometry Id associated with the coincident point std::vector GeoIdList; std::vector PosIdList; - getCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); + getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); // only coincident points between two (non-external) edges can be filleted if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) { @@ -3163,7 +3163,31 @@ void SketchObject::isCoincidentWithExternalGeometry(int GeoId, bool &start_exter } } -void SketchObject::getCoincidentPoints(int GeoId, PointPos PosId, std::vector &GeoIdList, +const std::map SketchObject::getAllCoincidentPoints(int GeoId, PointPos PosId) { + + const std::vector< std::map > coincidenttree = getCoincidenceGroups(); + + for(std::vector< std::map >::const_iterator it = coincidenttree.begin(); it != coincidenttree.end(); ++it) { + + std::map::const_iterator geoId1iterator; + + geoId1iterator = (*it).find(GeoId); + + if( geoId1iterator != (*it).end()) { + // If GeoId is in this set + + if ((*geoId1iterator).second == PosId) // and posId matches + return (*it); + } + } + + std::map empty; + + return empty; +} + + +void SketchObject::getDirectlyCoincidentPoints(int GeoId, PointPos PosId, std::vector &GeoIdList, std::vector &PosIdList) { const std::vector &constraints = this->Constraints.getValues(); @@ -3191,13 +3215,13 @@ void SketchObject::getCoincidentPoints(int GeoId, PointPos PosId, std::vector &GeoIdList, +void SketchObject::getDirectlyCoincidentPoints(int VertexId, std::vector &GeoIdList, std::vector &PosIdList) { int GeoId; PointPos PosId; getGeoVertexIndex(VertexId, GeoId, PosId); - getCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); + getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); } bool SketchObject::arePointsCoincident(int GeoId1, PointPos PosId1, diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 48119ee7a..854921471 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -181,11 +181,14 @@ public: const std::vector< std::map > getCoincidenceGroups(); // returns if the given geoId is fixed (coincident) with external geometry on any of the possible relevant points void isCoincidentWithExternalGeometry(int GeoId, bool &start_external, bool &mid_external, bool &end_external); - + // returns a map containing all the GeoIds that are coincident with the given point as keys, and the PosIds as values associated + // with the keys. + const std::map getAllCoincidentPoints(int GeoId, PointPos PosId); + /// retrieves for a Vertex number a list with all coincident points (sharing a single coincidence constraint) - void getCoincidentPoints(int GeoId, PointPos PosId, std::vector &GeoIdList, + void getDirectlyCoincidentPoints(int GeoId, PointPos PosId, std::vector &GeoIdList, std::vector &PosIdList); - void getCoincidentPoints(int VertexId, std::vector &GeoIdList, std::vector &PosIdList); + void getDirectlyCoincidentPoints(int VertexId, std::vector &GeoIdList, std::vector &PosIdList); bool arePointsCoincident(int GeoId1, PointPos PosId1, int GeoId2, PointPos PosId2); /// generates a warning message about constraint conflicts and appends it to the given message diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index df5a9b0c5..e4064ba79 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -3981,7 +3981,7 @@ namespace SketcherGui { Sketcher::SketchObject *Sketch = static_cast(object); std::vector GeoIdList; std::vector PosIdList; - Sketch->getCoincidentPoints(VtId, GeoIdList, PosIdList); + Sketch->getDirectlyCoincidentPoints(VtId, GeoIdList, PosIdList); if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) { const Part::Geometry *geom1 = Sketch->getGeometry(GeoIdList[0]); const Part::Geometry *geom2 = Sketch->getGeometry(GeoIdList[1]); @@ -4080,7 +4080,7 @@ public: double radius=-1; std::vector GeoIdList; std::vector PosIdList; - sketchgui->getSketchObject()->getCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); + sketchgui->getSketchObject()->getDirectlyCoincidentPoints(GeoId, PosId, GeoIdList, PosIdList); if (GeoIdList.size() == 2 && GeoIdList[0] >= 0 && GeoIdList[1] >= 0) { const Part::Geometry *geom1 = sketchgui->getSketchObject()->getGeometry(GeoIdList[0]); const Part::Geometry *geom2 = sketchgui->getSketchObject()->getGeometry(GeoIdList[1]);