Salome HOME
Adjust test cases for the Trim feature
[modules/shaper.git] / src / SketchPlugin / Test / TestTrimArc07.py
1 from salome.shaper import model
2
3 from ModelAPI import *
4 from GeomDataAPI import *
5 from ModelGeomAlgo import ModelGeomAlgo_Point2D
6 from salome.shaper import geom
7 import math
8
9 TOLERANCE = 1.e-7
10
11 SketchLineId = 'SketchLine'
12 SketchArcId = 'SketchArc'
13 SketchConstraintCoincidenceId = 'SketchConstraintCoincidence'
14 SketchConstraintEqualId = 'SketchConstraintEqual'
15
16 aSession = ModelAPI_Session.get()
17 model.begin()
18 partSet = model.moduleDocument()
19 Part = model.addPart(partSet)
20 Part_doc = Part.document()
21
22 # Test1:begin split on arc with coincident point and intersection line : smaller part
23 Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY"))
24 SketchArc_1 = Sketch.addArc(50, 50, 30, 50, 50, 70, False)
25 SketchArc_2 = Sketch.addArc(75, 80, 50, 70, 100, 100, True)
26 SketchLine = Sketch.addLine(60, 31, 60, 130)
27 SketchLine_2 = Sketch.addLine(10, 40, 90, 40)
28
29 # correct start point of SketchLine to belong the arc for trim
30 Intersected_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_1.feature(), FeatureList([SketchLine.feature()]))
31 assert(len(Intersected_Points) == 2)
32 if Intersected_Points[0].y() < Intersected_Points[1].y():
33   IntersectionPoint = Intersected_Points[0]
34 else:
35   IntersectionPoint = Intersected_Points[1]
36
37 SketchLine.startPoint().setValue(IntersectionPoint.x(), IntersectionPoint.y())
38
39 SketchConstraintCoincidence_1_1 = Sketch.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint())
40 SketchConstraintCoincidence_1_2 = Sketch.setCoincident(SketchArc_1.results()[1], SketchLine.startPoint())
41 model.do()
42
43
44 #find point on arc, where to perform trim
45 SketchLine_intersecting = Sketch.addLine(50, 50, 100, 0)
46 Geom_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_1.feature(), FeatureList([SketchLine_intersecting.feature()]))
47 assert(len(Geom_Points) == 1)
48 ModelAPI.removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()]))
49 model.do()
50 GeomPoint = Geom_Points[0]
51
52 model.do()
53 SketchTrim = Sketch.addTrim(SketchArc_1, Sketch.to2D(GeomPoint))
54 SketchTrim.execute()
55
56 model.end()
57
58 assert(model.checkPythonDump())