Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / src / ConstructionPlugin / Test / TestPlane.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 """
22 Test case for Construction Plane feature. Written on High API.
23 """
24 from ModelAPI import *
25 from GeomAPI import *
26
27 from salome.shaper import model
28
29 # Get session
30 aSession = ModelAPI_Session.get()
31
32 # Create a part
33 aDocument = aSession.activeDocument()
34 aSession.startOperation()
35 model.addPart(aDocument)
36 aDocument = aSession.activeDocument()
37 aSession.finishOperation()
38
39 # Test a plane by general equation
40 aSession.startOperation()
41 aPlane = model.addPlane(aDocument, 1, 1, 1, 0)
42 aSession.finishOperation()
43 assert (len(aPlane.results()) > 0)
44
45 # Create a point 1
46 aSession.startOperation()
47 aPoint1 = model.addPoint(aDocument, 0, 0, 0)
48 aSession.finishOperation()
49
50 # Create a point 2
51 aSession.startOperation()
52 aPoint2 = model.addPoint(aDocument, 100, 0, 0)
53 aSession.finishOperation()
54
55 # Create a point 3
56 aSession.startOperation()
57 aPoint3 = model.addPoint(aDocument, 50, 50, 50)
58 aSession.finishOperation()
59
60 # Test a plane by three points
61 aSession.startOperation()
62 aPlane = model.addPlane(aDocument, aPoint1.result(), aPoint2.result(), aPoint3.result())
63 aSession.finishOperation()
64 assert (len(aPlane.results()) > 0)
65
66 # Create an axis
67 aSession.startOperation()
68 anAxis = model.addAxis(aDocument, 0, 0, 100)
69 aSession.finishOperation()
70
71 # Test a plane by line and point
72 aSession.startOperation()
73 aPlane = model.addPlane(aDocument, anAxis.result(), aPoint3.result(), True)
74 aSession.finishOperation()
75 assert (len(aPlane.results()) > 0)
76
77 # Test a plane by distance from other
78 aSession.startOperation()
79 aPlane = model.addPlane(aDocument, aPlane.result(), 50, False)
80 aSession.finishOperation()
81 assert (len(aPlane.results()) > 0)
82
83 # Test a plane by coincidence to point
84 aSession.startOperation()
85 aCoincidentPlane = model.addPlane(aDocument, aPlane.result(), aPoint2.result())
86 aSession.finishOperation()
87 assert (len(aCoincidentPlane.results()) > 0)
88
89 # Create an axis
90 aSession.startOperation()
91 anAxis = model.addAxis(aDocument, 100, 0, 0)
92 aSession.finishOperation()
93
94 # Test a plane by rotation
95 aSession.startOperation()
96 aRotatedPlane = model.addPlane(aDocument, aCoincidentPlane.result(), anAxis.result(), 45)
97 aSession.finishOperation()
98 assert (len(aRotatedPlane.results()) > 0)
99
100 # Test plane by two parallel planes
101 aSession.startOperation()
102 aPlane = model.addPlane(aDocument, aCoincidentPlane.result(), aPlane.result())
103 aSession.finishOperation()
104 assert (len(aPlane.results()) > 0)
105
106 assert(model.checkPythonDump())