Salome HOME
40b4dc53773b5fdf668065b4e2d999139205668c
[modules/hexablock.git] / src / TEST_PY / test_unit / test_transfo.py
1 # -*- coding: latin-1 -*-
2 # Copyright (C) 2009-2023  CEA, EDF
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 # Hexa : Creation d'hexaedres 
22
23 import hexablock
24 import os
25
26 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
27
28
29 # ======================================================= make_grid
30 def make_grid (doc) :
31
32     ori  = doc.addVertex ( 0, 0, 0)
33     vz   = doc.addVector ( 0, 0, 1)
34     vx   = doc.addVector ( 1 ,0, 0)
35
36     dr = 1
37     da = 360
38     dl = 1
39
40     nr = 1
41     na = 6
42     nl = 1
43     grid = doc.makeCylindrical (ori, vx,vz, dr,da,dl, nr,na,nl, False)
44     doc .saveVtk ("transfo1.vtk")
45     return grid
46
47 # ======================================================= test_translation
48 def test_translation () :
49
50     doc  = hexablock.addDocument ("default")
51     grid = make_grid (doc)
52
53     devant = doc.addVector (10, 0, 0)
54     grid2  = doc.makeTranslation (grid, devant)
55
56     doc .saveVtk ("transfo2.vtk")
57     return doc
58
59 # ======================================================= test_scale
60 def test_scale () :
61
62     doc  = hexablock.addDocument ("default")
63     grid = make_grid (doc)
64
65     dest   = doc.addVertex (15, 0, 0)
66     grid2  = doc.makeScale (grid, dest, 0.5)
67
68     doc .saveVtk ("transfo3.vtk")
69     return doc
70
71 # ======================================================= test_sym_point
72 def test_sym_point () :
73
74     doc  = hexablock.addDocument ("default")
75     grid = make_grid (doc)
76
77     orig  = doc.addVertex (5, 0, 0)
78     grid2 = doc.makeSymmetryPoint (grid, orig)
79
80     doc .saveVtk ("transfo4.vtk")
81     return doc
82
83 # ======================================================= test_sym_line
84 def test_sym_line () :
85
86     doc  = hexablock.addDocument ("default")
87     grid = make_grid (doc)
88
89     orig  = doc.addVertex (5, 0, 0)
90     dir   = doc.addVector (0, 0, 1);
91     grid2 = doc.makeSymmetryLine (grid, orig, dir)
92
93     doc .saveVtk ("transfo5.vtk")
94     return doc
95
96 # ======================================================= test_sym_plan
97 def test_sym_plan () :
98
99     doc  = hexablock.addDocument ("default")
100     grid = make_grid (doc)
101
102     orig  = doc.addVertex (5, 0, 0)
103     dir   = doc.addVector (1, 0, 0);
104     grid2 = doc.makeSymmetryPlane (grid, orig, dir)
105
106     doc .saveVtk ("transfo6.vtk")
107     return doc
108
109 # ================================================================= Begin
110
111 ### doc = test_translation  ()
112 doc = test_scale  ()
113 ### doc = test_sym_point  ()
114 ### doc = test_sym_line  ()
115 ### doc = test_sym_plan  ()
116
117 law = doc.addLaw("Uniform", 4)
118
119 for j in range(doc.countPropagation()):
120     propa = doc.getPropagation(j)
121     propa.setLaw(law) 
122
123 mesh_hexas = hexablock.mesh(doc, "maillage:hexas")
124