Salome HOME
Merge branch 'master' into cgt/devCEA
[modules/shaper.git] / test.API / SHAPER / Transformations / TestTranslation.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 Translation feature.
23 Written on High API.
24 """
25 from ModelAPI import *
26 from GeomAPI import *
27
28 from salome.shaper import model
29
30 # Get session
31 aSession = ModelAPI_Session.get()
32
33 # Create a part
34 aDocument = aSession.activeDocument()
35 aSession.startOperation()
36 model.addPart(aDocument)
37 aDocument = aSession.activeDocument()
38 aSession.finishOperation()
39
40 # Create a box
41
42 aSession.startOperation()
43 aBox =  model.addBox(aDocument, 10, 10, 10)
44
45 # Perform a translation by an axis and a distance
46 aSession.startOperation()
47 aTranslation1 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom"), 20).result()
48 aSession.finishOperation()
49 assert (aTranslation1 is not None)
50
51 # Perform a translation by DX, DY, DZ vector
52 aSession.startOperation()
53 aTranslation2 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], 10, 10, 10).result()
54 aSession.finishOperation()
55 assert (aTranslation2 is not None)
56
57 # Perform a translation by two points
58 aSession.startOperation()
59 aPoint1 = model.addPoint(aDocument, 0, 0, 0).result()
60 aPoint2 = model.addPoint(aDocument, 10, 10, 0).result()
61 aTranslation3 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], aPoint1, aPoint2).result()
62 aSession.finishOperation()
63 assert (aTranslation3 is not None)