diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index d2c076a31..4f99c7844 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -97,20 +97,19 @@ void Sketch::clear(void) } int Sketch::setUpSketch(const std::vector &GeoList, const std::vector &ConstraintList, - bool withDiagnose) -{ - return setUpSketch(GeoList, std::vector(0), ConstraintList); -} - -int Sketch::setUpSketch(const std::vector &GeoList, const std::vector &ExternalGeoList, - const std::vector &ConstraintList, bool withDiagnose) + bool withDiagnose, int extGeoCount) { clear(); - addGeometry(GeoList); + std::vector intGeoList, extGeoList; + for (int i=0; i < int(GeoList.size())-extGeoCount; i++) + intGeoList.push_back(GeoList[i]); + for (int i=int(GeoList.size())-extGeoCount; i < GeoList.size(); i++) + extGeoList.push_back(GeoList[i]); + + addGeometry(intGeoList); int extStart=Geoms.size(); - std::vector reversedExternalGeoList(ExternalGeoList.rbegin(),ExternalGeoList.rend()); - addGeometry(reversedExternalGeoList, true); + addGeometry(extGeoList, true); int extEnd=Geoms.size()-1; for (int i=extStart; i <= extEnd; i++) Geoms[i].external = true; diff --git a/src/Mod/Sketcher/App/Sketch.h b/src/Mod/Sketcher/App/Sketch.h index 830f1e3c7..8746ff226 100644 --- a/src/Mod/Sketcher/App/Sketch.h +++ b/src/Mod/Sketcher/App/Sketch.h @@ -55,9 +55,7 @@ public: void clear(void); /// set the sketch up with geoms and constraints int setUpSketch(const std::vector &GeoList, const std::vector &ConstraintList, - bool withDiagnose=true); - int setUpSketch(const std::vector &GeoList, const std::vector &ExternalGeoList, - const std::vector &ConstraintList, bool withDiagnose=true); + bool withDiagnose=true, int extGeoCount=0); /// return the actual geometry of the sketch a TopoShape Part::TopoShape toShape(void) const; /// add unspecified geometry diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 6b4a1eff1..904b8b063 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -92,7 +92,8 @@ App::DocumentObjectExecReturn *SketchObject::execute(void) // setup and diagnose the sketch rebuildExternalGeometry(); Sketch sketch; - int dofs = sketch.setUpSketch(getInternalGeometry(), getExternalGeometry(), Constraints.getValues()); + int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(), + true, getExternalGeometryCount()); if (dofs < 0) { // over-constrained sketch std::string msg="Over-constrained sketch\n"; appendConflictMsg(sketch.getConflicting(), msg); @@ -122,7 +123,8 @@ int SketchObject::hasConflicts(void) const { // set up a sketch (including dofs counting and diagnosing of conflicts) Sketch sketch; - int dofs = sketch.setUpSketch(getInternalGeometry(), getExternalGeometry(), Constraints.getValues()); + int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(), + true, getExternalGeometryCount()); if (dofs < 0) // over-constrained sketch return -2; if (sketch.hasConflicts()) // conflicting constraints @@ -159,7 +161,8 @@ int SketchObject::setDatum(int ConstrId, double Datum) // set up a sketch (including dofs counting and diagnosing of conflicts) Sketch sketch; - int dofs = sketch.setUpSketch(getInternalGeometry(), getExternalGeometry(), Constraints.getValues()); + int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(), + true, getExternalGeometryCount()); int err=0; if (dofs < 0) // over-constrained sketch err = -3; @@ -184,7 +187,8 @@ int SketchObject::setDatum(int ConstrId, double Datum) int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative) { Sketch sketch; - int dofs = sketch.setUpSketch(getInternalGeometry(), getExternalGeometry(), Constraints.getValues()); + int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(), + true, getExternalGeometryCount()); if (dofs < 0) // over-constrained sketch return -1; if (sketch.hasConflicts()) // conflicting constraints @@ -1176,7 +1180,7 @@ void SketchObject::rebuildExternalGeometry(void) } -std::vector SketchObject::getCompleteGeometry(void) +std::vector SketchObject::getCompleteGeometry(void) const { std::vector vals=getInternalGeometry(); vals.insert(vals.end(), ExternalGeo.rbegin(), ExternalGeo.rend()); // in reverse order diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index bf635acb7..e3ae6b800 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -96,7 +96,7 @@ public: int getExternalGeometryCount(void) const { return ExternalGeo.size(); } /// retrieves a vector containing both normal and external Geometry (including the sketch axes) - std::vector getCompleteGeometry(void); + std::vector getCompleteGeometry(void) const; /// returns non zero if the sketch contains conflicting constraints int hasConflicts(void) const;