diff --git a/src/Mod/Sketcher/App/PropertyConstraintList.cpp b/src/Mod/Sketcher/App/PropertyConstraintList.cpp index ae98ce409..6e9bb35c2 100644 --- a/src/Mod/Sketcher/App/PropertyConstraintList.cpp +++ b/src/Mod/Sketcher/App/PropertyConstraintList.cpp @@ -232,24 +232,41 @@ void PropertyConstraintList::applyValidGeometryKeys(const std::vector &GeoList) { - if (validGeometryKeys.size() != GeoList.size()) { + if (!scanGeometry(GeoList)) { invalidGeometry = true; return; } + //if we made it here, geometry is OK + if (invalidGeometry) { + //geometry was bad, but now it became OK. + invalidGeometry = false; + touch(); + } +} + +/*! + * \brief PropertyConstraintList::scanGeometry tests if the supplied geometry + * is the same (all elements are of the same type as they used to be). + * \param GeoList - new geometry list to be checked + * \return false, if the types have changed. + */ +bool PropertyConstraintList::scanGeometry(const std::vector &GeoList) const +{ + if (validGeometryKeys.size() != GeoList.size()) { + return false; + } + unsigned int i=0; for (std::vector< Part::Geometry * >::const_iterator it=GeoList.begin(); it != GeoList.end(); ++it, i++) { if (validGeometryKeys[i] != (*it)->getTypeId().getKey()) { - invalidGeometry = true; - return; + return false; } } - if (invalidGeometry) { - invalidGeometry = false; - touch(); - } + return true; } + std::vector PropertyConstraintList::_emptyValueList(0); diff --git a/src/Mod/Sketcher/App/PropertyConstraintList.h b/src/Mod/Sketcher/App/PropertyConstraintList.h index df99b4b3f..1726d7500 100644 --- a/src/Mod/Sketcher/App/PropertyConstraintList.h +++ b/src/Mod/Sketcher/App/PropertyConstraintList.h @@ -79,6 +79,9 @@ public: const std::vector &getValues(void) const { return invalidGeometry ? _emptyValueList : _lValueList; } + const std::vector &getValuesForce(void) const {//to suppress check for invalid geometry, to be used for sketch repairing. + return _lValueList; + } virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); @@ -93,6 +96,8 @@ public: void acceptGeometry(const std::vector &GeoList); void checkGeometry(const std::vector &GeoList); + bool scanGeometry(const std::vector &GeoList) const; + bool isGeometryInvalid(){return invalidGeometry;} private: std::vector _lValueList; diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index c7a938aa8..35f6fa0bc 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1756,7 +1756,7 @@ int SketchObject::delExternal(int ExtGeoId) int SketchObject::delConstraintsToExternal() { - const std::vector< Constraint * > &constraints = Constraints.getValues(); + const std::vector< Constraint * > &constraints = Constraints.getValuesForce(); std::vector< Constraint * > newConstraints(0); int GeoId = -3, NullId = -2000; for (std::vector::const_iterator it = constraints.begin(); @@ -2270,7 +2270,7 @@ bool SketchObject::evaluateConstraints() const int extGeoCount = getExternalGeometryCount(); std::vector geometry = getCompleteGeometry(); - const std::vector& constraints = Constraints.getValues(); + const std::vector& constraints = Constraints.getValuesForce(); if (static_cast(geometry.size()) != extGeoCount + intGeoCount) return false; if (geometry.size() < 2) @@ -2282,6 +2282,10 @@ bool SketchObject::evaluateConstraints() const return false; } + if(constraints.size()>0){ + if (!Constraints.scanGeometry(geometry)) return false; + } + return true; }