Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchPlugin / Test / TestTrimArc07.py
1 # Copyright (C) 2014-2023  CEA/DEN, EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from salome.shaper import model
21
22 from ModelAPI import *
23 from GeomDataAPI import *
24 from ModelGeomAlgo import ModelGeomAlgo_Point2D
25 from salome.shaper import geom
26 import math
27
28 TOLERANCE = 1.e-7
29
30 SketchLineId = 'SketchLine'
31 SketchArcId = 'SketchArc'
32 SketchConstraintCoincidenceId = 'SketchConstraintCoincidence'
33 SketchConstraintEqualId = 'SketchConstraintEqual'
34
35 aSession = ModelAPI_Session.get()
36 model.begin()
37 partSet = model.moduleDocument()
38 Part = model.addPart(partSet)
39 Part_doc = Part.document()
40
41 # Test1:begin split on arc with coincident point and intersection line : smaller part
42 Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY"))
43 SketchArc_1 = Sketch.addArc(50, 50, 30, 50, 50, 70, False)
44 SketchArc_2 = Sketch.addArc(75, 80, 50, 70, 100, 100, True)
45 SketchLine = Sketch.addLine(60, 31, 60, 130)
46 SketchLine_2 = Sketch.addLine(10, 40, 90, 40)
47
48 # correct start point of SketchLine to belong the arc for trim
49 Intersected_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_1.feature(), FeatureList([SketchLine.feature()]))
50 assert(len(Intersected_Points) == 2)
51 if Intersected_Points[0].y() < Intersected_Points[1].y():
52   IntersectionPoint = Intersected_Points[0]
53 else:
54   IntersectionPoint = Intersected_Points[1]
55
56 SketchLine.startPoint().setValue(IntersectionPoint.x(), IntersectionPoint.y())
57
58 SketchConstraintCoincidence_1_1 = Sketch.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint())
59 SketchConstraintCoincidence_1_2 = Sketch.setCoincident(SketchArc_1.results()[1], SketchLine.startPoint())
60 model.do()
61
62
63 #find point on arc, where to perform trim
64 SketchLine_intersecting = Sketch.addLine(50, 50, 100, 0)
65 Geom_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_1.feature(), FeatureList([SketchLine_intersecting.feature()]))
66 assert(len(Geom_Points) == 1)
67 ModelAPI.removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()]))
68 model.do()
69 GeomPoint = Geom_Points[0]
70
71 model.do()
72 SketchTrim = Sketch.addTrim(SketchArc_1, Sketch.to2D(GeomPoint))
73 SketchTrim.execute()
74
75 model.end()
76
77 assert(model.checkPythonDump())