From 48fc5033642a8a76b603c1cb5312a11685d374ae Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Thu, 21 Dec 2017 00:41:25 +0100 Subject: [PATCH] Sketcher: Blocked Constraint solver level --- src/Mod/Sketcher/App/Constraint.h | 1 + src/Mod/Sketcher/App/Sketch.cpp | 33 ++++++++++++++++++++++++++++++- src/Mod/Sketcher/App/Sketch.h | 4 ++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index e03f2a8410..4ba36c11b0 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -55,6 +55,7 @@ enum ConstraintType { Symmetric = 14, InternalAlignment = 15, SnellsLaw = 16, + Blocked = 17, NumConstraintTypes // must be the last item! }; diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index b9d0870c01..527cf6eb4c 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -128,7 +128,12 @@ int Sketch::setUpSketch(const std::vector &GeoList, for (int i=int(GeoList.size())-extGeoCount; i < int(GeoList.size()); i++) extGeoList.push_back(GeoList[i]); - addGeometry(intGeoList); + std::vector blockedGeometry(intGeoList.size(),false); + + if(!intGeoList.empty()) + getBlockedGeometry(blockedGeometry,ConstraintList); + + addGeometry(intGeoList,blockedGeometry); int extStart=Geoms.size(); addGeometry(extGeoList, true); int extEnd=Geoms.size()-1; @@ -251,6 +256,19 @@ int Sketch::addGeometry(const std::vector &geo, bool fixed) return ret; } +int Sketch::addGeometry(const std::vector &geo, std::vector &blockedGeometry) +{ + assert(geo.size() == blockedGeometry.size()); + + int ret = -1; + std::vector::const_iterator it; + std::vector::iterator bit; + + for (it=geo.begin(),bit=blockedGeometry.begin(); it != geo.end() && bit !=blockedGeometry.end(); ++it,++bit) + ret = addGeometry(*it, *bit); + return ret; +} + int Sketch::addPoint(const Part::GeomPoint &point, bool fixed) { std::vector ¶ms = fixed ? FixParameters : Parameters; @@ -1309,6 +1327,19 @@ int Sketch::addConstraints(const std::vector &ConstraintList) return rtn; } +void Sketch::getBlockedGeometry(std::vector & blockedGeometry, const std::vector &ConstraintList) +{ + + for (std::vector::const_iterator it = ConstraintList.begin();it!=ConstraintList.end();++it) { + if((*it)->Type == Blocked) { + int geoid = (*it)->First; + + if(geoid>=0 && geoid &geo, bool fixed=false); + /// add unspecified geometry, where each element's "fixed" status is given by the blockedGeometry array + int addGeometry(const std::vector &geo, std::vector &blockedGeometry); + /// get boolean list indicating whether the geometry is to be blocked or not + void getBlockedGeometry(std::vector & blockedGeometry, const std::vector &ConstraintList); /// returns the actual geometry std::vector extractGeometry(bool withConstructionElements=true, bool withExternalElements=false) const;