Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / SketchPlugin / Test / TestTrimArc07.py
1 ## Copyright (C) 2014-2017  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 from salome.shaper import model
22
23 from ModelAPI import *
24 from GeomDataAPI import *
25 from ModelGeomAlgo import ModelGeomAlgo_Point2D
26 from salome.shaper import geom
27 import math
28
29 TOLERANCE = 1.e-7
30
31 SketchLineId = 'SketchLine'
32 SketchArcId = 'SketchArc'
33 SketchConstraintCoincidenceId = 'SketchConstraintCoincidence'
34 SketchConstraintEqualId = 'SketchConstraintEqual'
35
36 aSession = ModelAPI_Session.get()
37 model.begin()
38 partSet = model.moduleDocument()
39 Part = model.addPart(partSet)
40 Part_doc = Part.document()
41
42 # Test1:begin split on arc with coincident point and intersection line : smaller part
43 Sketch = model.addSketch(Part_doc, model.defaultPlane("XOY"))
44 SketchArc_1 = Sketch.addArc(50, 50, 30, 50, 50, 70, False)
45 SketchArc_2 = Sketch.addArc(75, 80, 50, 70, 100, 100, True)
46 SketchLine = Sketch.addLine(60, 31, 60, 130)
47 SketchLine_2 = Sketch.addLine(10, 40, 90, 40)
48
49 # correct start point of SketchLine to belong the arc for trim
50 Intersected_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_1.feature(), FeatureList([SketchLine.feature()]))
51 assert(len(Intersected_Points) == 2)
52 if Intersected_Points[0].y() < Intersected_Points[1].y():
53   IntersectionPoint = Intersected_Points[0]
54 else:
55   IntersectionPoint = Intersected_Points[1]
56
57 SketchLine.startPoint().setValue(IntersectionPoint.x(), IntersectionPoint.y())
58
59 SketchConstraintCoincidence_1_1 = Sketch.setCoincident(SketchArc_1.endPoint(), SketchArc_2.startPoint())
60 SketchConstraintCoincidence_1_2 = Sketch.setCoincident(SketchArc_1.results()[1], SketchLine.startPoint())
61 model.do()
62
63
64 #find point on arc, where to perform trim
65 SketchLine_intersecting = Sketch.addLine(50, 50, 100, 0)
66 Geom_Points = ModelGeomAlgo_Point2D.getSetOfPntIntersectedShape(SketchArc_1.feature(), FeatureList([SketchLine_intersecting.feature()]))
67 assert(len(Geom_Points) == 1)
68 ModelAPI.removeFeaturesAndReferences(FeatureSet([SketchLine_intersecting.feature()]))
69 model.do()
70 GeomPoint = Geom_Points[0]
71
72 model.do()
73 SketchTrim = Sketch.addTrim(SketchArc_1, Sketch.to2D(GeomPoint))
74 SketchTrim.execute()
75
76 model.end()
77
78 assert(model.checkPythonDump())