From 18bdec8670c66943ef37de016fb2f02044c6ed71 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 2 Jun 2014 09:11:51 +0400 Subject: [PATCH] Problem with blinking segment during feature movement --- .../SketchSolver_ConstraintGroup.cpp | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index 6d053d8c2..ce1d5f87e 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -627,6 +627,7 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vectorptA, aConstrIter->ptB, aConstrIter->entityA, aConstrIter->entityB}; + std::vector anIndexes; // Go through the groupped entities and find even one of entities of current constraint std::vector< std::set >::iterator aGrEntIter; for (aGrEntIter = aGroupsEntities.begin(); aGrEntIter != aGroupsEntities.end(); aGrEntIter++) @@ -636,18 +637,10 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vectorfind(aConstrEnt[i]) != aGrEntIter->end()); if (isFound) - { - for (int i = 0; i < 4; i++) - if (aConstrEnt[i] != 0) - aGrEntIter->insert(aConstrEnt[i]); - aGroupsConstr[aGrEntIter - aGroupsEntities.begin()].insert(aConstrIter->h); - if (aGrEntIter->size() > aGroupsEntities[aMaxNbEntities].size()) - aMaxNbEntities = aGrEntIter - aGroupsEntities.begin(); - break; - } + anIndexes.push_back(aGrEntIter - aGroupsEntities.begin()); } // Add new group if no one is found - if (aGrEntIter == aGroupsEntities.end()) + if (anIndexes.empty()) { std::set aNewGrEnt; for (int i = 0; i < 4; i++) @@ -661,6 +654,36 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector aGroupsEntities[aMaxNbEntities].size()) aMaxNbEntities = aGroupsEntities.size() - 1; } + else if (anIndexes.size() == 1) + { // Add entities indexes into the found group + for (int i = 0; i < 4; i++) + if (aConstrEnt[i] != 0) + aGrEntIter->insert(aConstrEnt[i]); + aGroupsConstr[aGrEntIter - aGroupsEntities.begin()].insert(aConstrIter->h); + if (aGrEntIter->size() > aGroupsEntities[aMaxNbEntities].size()) + aMaxNbEntities = aGrEntIter - aGroupsEntities.begin(); + } + else + { // There are found several connected groups, merge them + std::vector< std::set >::iterator aFirstGroup = + aGroupsEntities.begin() + anIndexes.front(); + std::vector< std::set >::iterator aFirstConstr = + aGroupsConstr.begin() + anIndexes.front(); + std::vector::iterator anInd = anIndexes.begin(); + for (++anInd; anInd != anIndexes.end(); anInd++) + { + aFirstGroup->insert(aGroupsEntities[*anInd].begin(), aGroupsEntities[*anInd].end()); + aFirstConstr->insert(aGroupsConstr[*anInd].begin(), aGroupsConstr[*anInd].end()); + } + if (aFirstGroup->size() > aGroupsEntities[aMaxNbEntities].size()) + aMaxNbEntities = anIndexes.front(); + // Remove merged groups + for (anInd = anIndexes.end() - 1; anInd != anIndexes.begin(); anInd--) + { + aGroupsEntities.erase(aGroupsEntities.begin() + (*anInd)); + aGroupsConstr.erase(aGroupsConstr.begin() + (*anInd)); + } + } } if (aGroupsEntities.size() <= 1) -- 2.39.2