-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File: PlaneGCSSolver_UpdateCoincidence.cpp
-// Created: 17 Feb 2017
-// Author: Artem ZHIDKOV
+// Copyright (C) 2014-2024 CEA, EDF
+//
+// 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 <PlaneGCSSolver_UpdateCoincidence.h>
#include <PlaneGCSSolver_EdgeWrapper.h>
#include <SketchSolver_Constraint.h>
#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_ConstraintCoincidenceInternal.h>
#include <SketchPlugin_ConstraintCollinear.h>
#include <SketchPlugin_ConstraintMiddle.h>
+static bool hasSamePoint(const std::set<EntityWrapperPtr>& theList,
+ const EntityWrapperPtr& thePoint);
+
+
void PlaneGCSSolver_UpdateCoincidence::attach(SketchSolver_Constraint* theObserver,
const std::string& theType)
{
void PlaneGCSSolver_UpdateCoincidence::update(const FeaturePtr& theFeature)
{
if (theFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID() ||
+ theFeature->getKind() == SketchPlugin_ConstraintCoincidenceInternal::ID() ||
theFeature->getKind() == SketchPlugin_ConstraintMiddle::ID() ||
theFeature->getKind() == SketchPlugin_ConstraintCollinear::ID()) {
myCoincident.clear();
} 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<CoincidentEntities>::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<EntityWrapperPtr> 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]);
}
{
if (theGroup.isExist(theEntity))
return false;
-
- theGroup.add(theEntity);
- return true;
+ return theGroup.add(theEntity);
}
return false;
}
-static bool hasSamePoint(const std::set<EntityWrapperPtr>& theList,
- const EntityWrapperPtr& thePoint)
+bool hasSamePoint(const std::set<EntityWrapperPtr>& theList,
+ const EntityWrapperPtr& thePoint)
{
return hasSamePoint(theList, toPoint(thePoint));
}
{
return hasSamePoint(myExternalPoints, thePoint) || hasSamePoint(myPoints, thePoint);
}
+
+EntityWrapperPtr PlaneGCSSolver_UpdateCoincidence::CoincidentEntities::externalPoint() const
+{
+ return myExternalPoints.empty() ? EntityWrapperPtr() : *myExternalPoints.begin();
+}