#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)
{
} 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();
+}
model.do()
Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "PartSet/Sketch_1")], model.selection("EDGE", "PartSet/Sketch_1/Edge-SketchLine_1"), 360, 0)
Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face_5"))
+SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "PartSet/Origin"))
SketchLine_86 = Sketch_4.addLine(0, -13.49999999999519, 3.1, -13.49999999999519)
SketchLine_87 = Sketch_4.addLine(model.selection("EDGE", "PartSet/OZ"))
SketchConstraintCoincidence_51 = Sketch_4.setCoincident(SketchLine_86.startPoint(), SketchLine_87.result())
SketchConstraintMirror_2 = Sketch_4.addMirror(SketchLine_87.result(), [SketchLine_86.result(), SketchLine_88.result()])
[SketchLine_90, SketchLine_91] = SketchConstraintMirror_2.mirrored()
SketchArc_62 = Sketch_4.addArc(0, 0, 3.1, -10.55414610473955, -3.100000000000001, -10.55414610473344, False)
+SketchConstraintCoincidence_54 = Sketch_4.setCoincident(SketchPoint_4.coordinates(), SketchArc_62.center())
SketchConstraintCoincidence_55 = Sketch_4.setCoincident(SketchLine_87.startPoint(), SketchArc_62.center())
SketchConstraintCoincidence_56 = Sketch_4.setCoincident(SketchArc_62.startPoint(), SketchLine_88.result())
SketchConstraintCoincidence_57 = Sketch_4.setCoincident(SketchArc_62.endPoint(), SketchLine_91.result())