1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
22 Test case for Construction Plane feature. Written on High API.
24 from ModelAPI import *
27 from salome.shaper import model
30 aSession = ModelAPI_Session.get()
33 aDocument = aSession.activeDocument()
34 aSession.startOperation()
35 model.addPart(aDocument)
36 aDocument = aSession.activeDocument()
37 aSession.finishOperation()
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)
46 aSession.startOperation()
47 aPoint1 = model.addPoint(aDocument, 0, 0, 0)
48 aSession.finishOperation()
51 aSession.startOperation()
52 aPoint2 = model.addPoint(aDocument, 100, 0, 0)
53 aSession.finishOperation()
56 aSession.startOperation()
57 aPoint3 = model.addPoint(aDocument, 50, 50, 50)
58 aSession.finishOperation()
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)
67 aSession.startOperation()
68 anAxis = model.addAxis(aDocument, 0, 0, 100)
69 aSession.finishOperation()
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)
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)
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)
90 aSession.startOperation()
91 anAxis = model.addAxis(aDocument, 100, 0, 0)
92 aSession.finishOperation()
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)
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)
106 assert(model.checkPythonDump())