From b0492010d00df54f6d512a61240ba6c3f6daa610 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 8 May 2022 11:27:40 +0200 Subject: [PATCH] Sketcher: SketchObject - Add ability to diagnose constraint redundancy before addition ====================================================================================== It preserves the SketchObject properties. Therefore it does not trigger any property update, redraws, ... --- src/Mod/Sketcher/App/SketchObject.cpp | 18 ++++++++++++++++++ src/Mod/Sketcher/App/SketchObject.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 3d268f2644..fdd946fc2a 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -694,6 +694,24 @@ int SketchObject::setUpSketch() Constraints.touch(); return lastDoF; +} + +int SketchObject::diagnoseAdditionalConstraints(std::vector additionalconstraints) +{ + auto objectconstraints = Constraints.getValues(); + + std::vector allconstraints; + allconstraints.reserve(objectconstraints.size()+additionalconstraints.size()); + + std::copy(objectconstraints.begin(), objectconstraints.end(), back_inserter(allconstraints)); + std::copy(additionalconstraints.begin(), additionalconstraints.end(), back_inserter(allconstraints)); + + lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), allconstraints, + getExternalGeometryCount()); + + retrieveSolverDiagnostics(); + + return lastDoF; } diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 316f1f0ca4..95dde505b9 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -211,6 +211,9 @@ public: */ int setUpSketch(); + /** Performs a full analysis of the addition of additional constraints without adding them to the sketch object */ + int diagnoseAdditionalConstraints(std::vector additionalconstraints); + /** solves the sketch and updates the geometry, but not all the dependent features (does not recompute) When a recompute is necessary, recompute triggers execute() which solves the sketch and updates all dependent features When a solve only is necessary (e.g. DoF changed), solve() solves the sketch and