gp_Pnt2d anArrangePoint(theArrangePoint->x(), theArrangePoint->y());
gp_Pnt2d anInterPnt = theIntersectionAlgo->Point(1).Value();
aDistance = anArrangePoint.SquareDistance(anInterPnt);
- // get solution nearest to theArrangePoint
+ int aNbMergedPoints = 1;
+ // get solution nearest to theArrangePoint,
+ // if there are several point near each other, calculate average coordinates
for (int i = 2; i <= theIntersectionAlgo->NbPoints(); ++i) {
const IntAna2d_IntPoint& aPnt = theIntersectionAlgo->Point(i);
double aSqDist = aPnt.Value().SquareDistance(anArrangePoint);
- if (aSqDist < aDistance) {
+ if (aSqDist - aDistance < -Precision::Confusion() * aDistance) {
aDistance = aSqDist;
anInterPnt = aPnt.Value();
+ aNbMergedPoints = 1;
+ } else if (aSqDist - aDistance < Precision::Confusion() * aDistance) {
+ anInterPnt.ChangeCoord() =
+ (anInterPnt.XY() * aNbMergedPoints + aPnt.Value().XY()) / (aNbMergedPoints + 1);
+ ++aNbMergedPoints;
}
}
{
IntAna2d_AnaIntersection anInter(theCircle->impl<gp_Circ2d>(), IntAna2d_Conic(*MY_ELLIPSE));
Extrema_ExtElC2d anExtema(theCircle->impl<gp_Circ2d>(), *MY_ELLIPSE);
- GeomPnt2dPtr aCircleStart;
- theCircle->D0(0.0, aCircleStart);
- return extrema(&anInter, &anExtema, aCircleStart, thePointOnCircle, thePointOnMe);
+ return extrema(&anInter, &anExtema, firstFocus(), thePointOnCircle, thePointOnMe);
}
double GeomAPI_Ellipse2d::distance(const std::shared_ptr<GeomAPI_Ellipse2d>& theEllipse,
NB_LINES = 3
NB_ELLIPSES = 1
NB_ELLIPTIC_ARCS = 0
-NB_COINCIDENCES = 5
+NB_COINCIDENCES = 6
NB_EQUALS = 0
TOLERANCE = 1.e-6
SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchEllipse_1.result())
SketchLine_2 = Sketch_1.addLine(-16.85909682653373, 35.30399198463829, 20.9032928583277, -19.27802168426675)
SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
-SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchEllipse_1.result())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchEllipse_1.result())
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchEllipse_1.result())
SketchLine_3 = Sketch_1.addLine(34.69765676551338, 36.08465583643841, 35.0422024535432, -17.96612629290852)
-SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchEllipse_1.result())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchEllipse_1.result())
model.do()
checkFeaturesQuantity(Sketch_1)
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Circle.h>
#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_ConstraintCoincidenceInternal.h>
#include <SketchPlugin_ConstraintMiddle.h>
#include <cmath>
for (std::set<AttributePtr>::const_iterator anIt = aRefs.begin(); anIt != aRefs.end(); ++anIt) {
FeaturePtr aRef = ModelAPI_Feature::feature((*anIt)->owner());
if (aRef && (aRef->getKind() == SketchPlugin_ConstraintCoincidence::ID() ||
+ aRef->getKind() == SketchPlugin_ConstraintCoincidenceInternal::ID() ||
aRef->getKind() == SketchPlugin_ConstraintMiddle::ID())) {
for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) {
AttributeRefAttrPtr aRefAttr = aRef->refattr(SketchPlugin_Constraint::ATTRIBUTE(i));