X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FPlaneGCSSolver%2FPlaneGCSSolver_UpdateCoincidence.cpp;h=4ed6b81e992743639bcd0e6c310473ba7e71a9c5;hb=0db912d7f004c9858b06e590a895420780ae73fc;hp=bad62522a08fc57b1d689c9865e1d93b8a0f4819;hpb=5bb66eafc931be045b2da1407c88b3c08f759c40;p=modules%2Fshaper.git diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp index bad62522a..4ed6b81e9 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp @@ -1,8 +1,21 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PlaneGCSSolver_UpdateCoincidence.cpp -// Created: 17 Feb 2017 -// Author: Artem ZHIDKOV +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include #include @@ -13,6 +26,10 @@ #include #include +static bool hasSamePoint(const std::set& theList, + const EntityWrapperPtr& thePoint); + + void PlaneGCSSolver_UpdateCoincidence::attach(SketchSolver_Constraint* theObserver, const std::string& theType) { @@ -72,17 +89,21 @@ bool PlaneGCSSolver_UpdateCoincidence::addCoincidence( } else if (aFound[0] == aFound[1]) { // same group => already coincident isAccepted = false; } else { // merge two groups - EntityWrapperPtr anEntityToAdd = theEntity1; - if (theEntity1->isExternal()) { // swap found groups; - anEntityToAdd = theEntity2; - std::list::iterator aTempIt = aFound[0]; - aFound[0] = aFound[1]; - aFound[1] = aTempIt; + // first check the external points are equal + EntityWrapperPtr anExternal0 = aFound[0]->externalPoint(); + EntityWrapperPtr anExternal1 = aFound[1]->externalPoint(); + if (anExternal0 && anExternal1) { + std::set anExtList; + anExtList.insert(anExternal0); + if (hasSamePoint(anExtList, anExternal1)) { + // no need to add coincidence, because all points are + // already coincident to correct external points + isAccepted = false; + } } - aFound[1]->remove(anEntityToAdd); + // merge aFound[0]->merge(*aFound[1]); - isAccepted = aFound[0]->add(anEntityToAdd); myCoincident.erase(aFound[1]); } @@ -126,9 +147,7 @@ bool PlaneGCSSolver_UpdateCoincidence::addToGroupOfCoincidence( { if (theGroup.isExist(theEntity)) return false; - - theGroup.add(theEntity); - return true; + return theGroup.add(theEntity); } @@ -157,8 +176,8 @@ static bool hasSamePoint(const std::set& theList, const GCS::P return false; } -static bool hasSamePoint(const std::set& theList, - const EntityWrapperPtr& thePoint) +bool hasSamePoint(const std::set& theList, + const EntityWrapperPtr& thePoint) { return hasSamePoint(theList, toPoint(thePoint)); } @@ -225,3 +244,8 @@ bool PlaneGCSSolver_UpdateCoincidence::CoincidentEntities::isExist( { return hasSamePoint(myExternalPoints, thePoint) || hasSamePoint(myPoints, thePoint); } + +EntityWrapperPtr PlaneGCSSolver_UpdateCoincidence::CoincidentEntities::externalPoint() const +{ + return myExternalPoints.empty() ? EntityWrapperPtr() : *myExternalPoints.begin(); +}