Salome HOME
Copyright update 2022
[modules/shaper.git] / test.API / SHAPER / Transformations / TestTranslation.py
1 # Copyright (C) 2014-2022  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 """
21 Test case for Translation feature.
22 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 # Create a box
40
41 aSession.startOperation()
42 aBox =  model.addBox(aDocument, 10, 10, 10)
43
44 # Perform a translation by an axis and a distance
45 aSession.startOperation()
46 aTranslation1 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], model.selection("EDGE", "Box_1_1/Front&Box_1_1/Bottom"), 20).result()
47 aSession.finishOperation()
48 assert (aTranslation1 is not None)
49
50 # Perform a translation by DX, DY, DZ vector
51 aSession.startOperation()
52 aTranslation2 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], 10, 10, 10).result()
53 aSession.finishOperation()
54 assert (aTranslation2 is not None)
55
56 # Perform a translation by two points
57 aSession.startOperation()
58 aPoint1 = model.addPoint(aDocument, 0, 0, 0).result()
59 aPoint2 = model.addPoint(aDocument, 10, 10, 0).result()
60 aTranslation3 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], aPoint1, aPoint2).result()
61 aSession.finishOperation()
62 assert (aTranslation3 is not None)