Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/hexablock.git] / src / TEST_PY / test_unit / test_transfo.py
1 # -*- coding: latin-1 -*-
2 # Copyright (C) 2009-2012  CEA/DEN, EDF R&D
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.
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 import geompy
26
27 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
28
29
30 # ======================================================= make_grid
31 def make_grid (doc) :
32
33     ori  = doc.addVertex ( 0, 0, 0)
34     vz   = doc.addVector ( 0, 0, 1)
35     vx   = doc.addVector ( 1 ,0, 0)
36
37     dr = 1
38     da = 360
39     dl = 1
40
41     nr = 1
42     na = 6
43     nl = 1
44     grid = doc.makeCylindrical (ori, vx,vz, dr,da,dl, nr,na,nl, False)
45     doc .saveVtk ("transfo1.vtk")
46     return grid
47
48 # ======================================================= test_translation
49 def test_translation () :
50
51     doc  = hexablock.addDocument ("default")
52     grid = make_grid (doc)
53
54     devant = doc.addVector (10, 0, 0)
55     grid2  = doc.makeTranslation (grid, devant)
56
57     doc .saveVtk ("transfo2.vtk")
58     return doc
59
60 # ======================================================= test_scale
61 def test_scale () :
62
63     doc  = hexablock.addDocument ("default")
64     grid = make_grid (doc)
65
66     dest   = doc.addVertex (15, 0, 0)
67     grid2  = doc.makeScale (grid, dest, 0.5)
68
69     doc .saveVtk ("transfo3.vtk")
70     return doc
71
72 # ======================================================= test_sym_point
73 def test_sym_point () :
74
75     doc  = hexablock.addDocument ("default")
76     grid = make_grid (doc)
77
78     orig  = doc.addVertex (5, 0, 0)
79     grid2 = doc.makeSymmetryPoint (grid, orig)
80
81     doc .saveVtk ("transfo4.vtk")
82     return doc
83
84 # ======================================================= test_sym_line
85 def test_sym_line () :
86
87     doc  = hexablock.addDocument ("default")
88     grid = make_grid (doc)
89
90     orig  = doc.addVertex (5, 0, 0)
91     dir   = doc.addVector (0, 0, 1);
92     grid2 = doc.makeSymmetryLine (grid, orig, dir)
93
94     doc .saveVtk ("transfo5.vtk")
95     return doc
96
97 # ======================================================= test_sym_plan
98 def test_sym_plan () :
99
100     doc  = hexablock.addDocument ("default")
101     grid = make_grid (doc)
102
103     orig  = doc.addVertex (5, 0, 0)
104     dir   = doc.addVector (1, 0, 0);
105     grid2 = doc.makeSymmetryPlane (grid, orig, dir)
106
107     doc .saveVtk ("transfo6.vtk")
108     return doc
109
110 # ================================================================= Begin
111
112 ### doc = test_translation  ()
113 doc = test_scale  ()
114 ### doc = test_sym_point  ()
115 ### doc = test_sym_line  ()
116 ### doc = test_sym_plan  ()
117
118 law = doc.addLaw("Uniform", 4)
119
120 for j in range(doc.countPropagation()):
121     propa = doc.getPropagation(j)
122     propa.setLaw(law) 
123
124 mesh_hexas = hexablock.mesh(doc, "maillage:hexas")
125