return aResult.Modulus();
}
+double GeomAPI_XYZ::squareModulus() const
+{
+ return MY_XYZ->SquareModulus();
+}
/// Distance between two triplets
GEOMAPI_EXPORT
double distance(const std::shared_ptr<GeomAPI_XYZ>& theOther) const;
+
+ /// Square length of triplet from the origin
+ GEOMAPI_EXPORT double squareModulus() const;
};
#endif
double thePassedY)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
- compositeFeature()->addFeature(SketchPlugin_Circle::ID());
+ compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theCenterX, theCenterY,
thePassedX, thePassedY));
}
const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
- compositeFeature()->addFeature(SketchPlugin_Circle::ID());
+ compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theCenterPoint, thePassedPoint));
}
double theX3, double theY3)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
- compositeFeature()->addFeature(SketchPlugin_Circle::ID());
+ compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, theX1, theY1,
theX2, theY2,
theX3, theY3));
const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
- compositeFeature()->addFeature(SketchPlugin_Circle::ID());
+ compositeFeature()->addFeature(SketchPlugin_MacroCircle::ID());
return MacroCirclePtr(new SketchAPI_MacroCircle(aFeature, thePoint1, thePoint2, thePoint3));
}
double thePassedX, double thePassedY)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
- compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+ compositeFeature()->addFeature(SketchPlugin_MacroArc::ID());
return MacroArcPtr(new SketchAPI_MacroArc(aFeature,
theStartX, theStartY,
theEndX, theEndY,
const std::shared_ptr<GeomAPI_Pnt2d>& thePassed)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
- compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+ compositeFeature()->addFeature(SketchPlugin_MacroArc::ID());
return MacroArcPtr(new SketchAPI_MacroArc(aFeature, theStart, theEnd, thePassed));
}
bool theInversed)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
- compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+ compositeFeature()->addFeature(SketchPlugin_MacroArc::ID());
return MacroArcPtr(new SketchAPI_MacroArc(
aFeature, theTangentPoint, theEndX, theEndY, theInversed));
}
bool theInversed)
{
std::shared_ptr<ModelAPI_Feature> aFeature =
- compositeFeature()->addFeature(SketchPlugin_Arc::ID());
+ compositeFeature()->addFeature(SketchPlugin_MacroArc::ID());
return MacroArcPtr(new SketchAPI_MacroArc(aFeature, theTangentPoint, theEnd, theInversed));
}
Test1966.py
Test1967.py
Test2095.py
+ Test2115.py
TestTrimArc01.py
TestTrimArc02.py
TestTrimArc03.py
static const double aTolerance = 1.e-7;
std::shared_ptr<GeomAPI_Dir> aLineDir = theLine->direction();
std::shared_ptr<GeomAPI_XYZ> aLineLoc = theLine->location()->xyz();
+
+ std::shared_ptr<GeomAPI_XYZ> aVec1 = thePoint1->xyz()->decreased(aLineLoc);
+ // the first point is on the line
+ if (aVec1->squareModulus() < aTolerance * aTolerance)
+ return false;
std::shared_ptr<GeomAPI_Dir> aDirP1L(new GeomAPI_Dir(thePoint1->xyz()->decreased(aLineLoc)));
+ std::shared_ptr<GeomAPI_XYZ> aVec2 = thePoint1->xyz()->decreased(aLineLoc);
+ // the second point is on the line
+ if (aVec2->squareModulus() < aTolerance * aTolerance)
+ return false;
std::shared_ptr<GeomAPI_Dir> aDirP2L(new GeomAPI_Dir(thePoint2->xyz()->decreased(aLineLoc)));
+
return aLineDir->cross(aDirP1L)->dot(aLineDir->cross(aDirP2L)) > -aTolerance;
}
--- /dev/null
+"""
+ Test1061.py
+ Test case for issue #1061 "Distance constraint using for points with equal coordinates"
+"""
+
+from salome.shaper import model
+from ModelAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+# Create a centered rectangle (from the 2115 issue description)
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchLine_1 = Sketch_1.addLine(132.9002660287441, 132.9002660287441, -132.9002660287441, 132.9002660287441)
+SketchLine_2 = Sketch_1.addLine(-132.9002660287441, 132.9002660287441, -132.9002660287441, -132.9002660287441)
+SketchLine_3 = Sketch_1.addLine(-132.9002660287441, -132.9002660287441, 132.9002660287441, -132.9002660287441)
+SketchLine_4 = Sketch_1.addLine(132.9002660287441, -132.9002660287441, 132.9002660287441, 132.9002660287441)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchLine_5 = Sketch_1.addLine(-132.9002660287441, -132.9002660287441, 132.9002660287441, 132.9002660287441)
+SketchLine_5.setAuxiliary(True)
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_5.startPoint())
+SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint())
+SketchLine_6 = Sketch_1.addLine(-132.9002660287441, 132.9002660287441, 132.9002660287441, -132.9002660287441)
+SketchLine_6.setAuxiliary(True)
+SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_6.startPoint())
+SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_6.endPoint())
+SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
+SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_5.result())
+SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_6.result())
+SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result())
+
+# create a circle by 3 points of this rectangle (to make the last as a line later)
+circle = Sketch_1.addCircle(SketchLine_2.startPoint().pnt(), SketchLine_1.startPoint().pnt(), SketchLine_3.endPoint().pnt())
+
+# create by the real references
+circle.feature().refattr("first_point_ref").setAttr(SketchLine_2.startPoint())
+circle.feature().refattr("second_point_ref").setAttr(SketchLine_1.startPoint())
+circle.feature().refattr("third_point_ref").setObject(SketchLine_6.feature().firstResult())
+# here there was a crash in the issue (actually, sketch is overconstrained, so, assertion is not used, just call for validators)
+aFactory = ModelAPI_Session.get().validators()
+aFactory.validate(circle.feature())
+model.end()