Salome HOME
Fix for the issue #2115
[modules/shaper.git] / src / SketchPlugin / Test / Test2115.py
1 """
2     Test1061.py
3     Test case for issue #1061 "Distance constraint using for points with equal coordinates"
4 """
5
6 from salome.shaper import model
7 from ModelAPI import *
8
9 model.begin()
10 partSet = model.moduleDocument()
11 Part_1 = model.addPart(partSet)
12 Part_1_doc = Part_1.document()
13
14 # Create a centered rectangle (from the 2115 issue description)
15 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
16 SketchLine_1 = Sketch_1.addLine(132.9002660287441, 132.9002660287441, -132.9002660287441, 132.9002660287441)
17 SketchLine_2 = Sketch_1.addLine(-132.9002660287441, 132.9002660287441, -132.9002660287441, -132.9002660287441)
18 SketchLine_3 = Sketch_1.addLine(-132.9002660287441, -132.9002660287441, 132.9002660287441, -132.9002660287441)
19 SketchLine_4 = Sketch_1.addLine(132.9002660287441, -132.9002660287441, 132.9002660287441, 132.9002660287441)
20 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
21 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
22 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
23 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
24 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
25 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
26 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
27 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
28 SketchLine_5 = Sketch_1.addLine(-132.9002660287441, -132.9002660287441, 132.9002660287441, 132.9002660287441)
29 SketchLine_5.setAuxiliary(True)
30 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_5.startPoint())
31 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint())
32 SketchLine_6 = Sketch_1.addLine(-132.9002660287441, 132.9002660287441, 132.9002660287441, -132.9002660287441)
33 SketchLine_6.setAuxiliary(True)
34 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_6.startPoint())
35 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_6.endPoint())
36 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
37 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_5.result())
38 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_6.result())
39 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_1.result(), SketchLine_2.result())
40
41 # create a circle by 3 points of this rectangle (to make the last as a line later)
42 circle = Sketch_1.addCircle(SketchLine_2.startPoint().pnt(), SketchLine_1.startPoint().pnt(), SketchLine_3.endPoint().pnt())
43
44 # create by the real references
45 circle.feature().refattr("first_point_ref").setAttr(SketchLine_2.startPoint())
46 circle.feature().refattr("second_point_ref").setAttr(SketchLine_1.startPoint())
47 circle.feature().refattr("third_point_ref").setObject(SketchLine_6.feature().firstResult())
48 # here there was a crash in the issue (actually, sketch is overconstrained, so, assertion is not used, just call for validators)
49 aFactory = ModelAPI_Session.get().validators()
50 aFactory.validate(circle.feature())
51 model.end()