From: azv Date: Wed, 2 Sep 2015 11:27:22 +0000 (+0300) Subject: Update the procedure of removing entities not used by constraints (issue #883) X-Git-Tag: V_1.4.0_beta4~151 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d6a9daa7ee8173b47058a9aea1ea6554bcd21988;p=modules%2Fshaper.git Update the procedure of removing entities not used by constraints (issue #883) --- diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 30d3f5790..6dce96f4c 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -225,7 +225,33 @@ void SketchSolver_Storage::removeUnusedEntities() } std::set::const_iterator anEntIt = anUnusedEntities.begin(); - for (; anEntIt != anUnusedEntities.end(); ++anEntIt) { + while (anEntIt != anUnusedEntities.end()) { + int aPos = Search(*anEntIt, myEntities); + if (aPos < 0 && aPos >= (int)myEntities.size()) + continue; + Slvs_Entity anEntity = myEntities[aPos]; + // Remove entity if and only if all its parameters unused + bool isUsed = false; + if (anEntity.distance != SLVS_E_UNKNOWN && + anUnusedEntities.find(anEntity.distance) == anUnusedEntities.end()) + isUsed = true; + for (int i = 0; i < 4 && !isUsed; i++) + if (anEntity.point[i] != SLVS_E_UNKNOWN && + anUnusedEntities.find(anEntity.point[i]) == anUnusedEntities.end()) + isUsed = true; + if (isUsed) { + anUnusedEntities.erase(anEntity.distance); + for (int i = 0; i < 4; i++) + if (anEntity.point[i] != SLVS_E_UNKNOWN) + anUnusedEntities.erase(anEntity.point[i]); + std::set::iterator aRemoveIt = anEntIt++; + anUnusedEntities.erase(aRemoveIt); + continue; + } + ++anEntIt; + } + + for (anEntIt = anUnusedEntities.begin(); anEntIt != anUnusedEntities.end(); ++anEntIt) { int aPos = Search(*anEntIt, myEntities); if (aPos >= 0 && aPos < (int)myEntities.size()) { // Remove entity and its parameters