Salome HOME
e52715e1e22ca53bbf17f80391598e7320fc5306
[modules/hexablock.git] / doc / pyplots / test_join_quads.py
1 # Copyright (C) 2009-2023  CEA, EDF
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
22 # exemple repris de test_hexa1.cxx (test_joint())
23
24 import os
25 import GEOM
26 import SALOMEDS
27 import hexablock
28
29 print("test join...")
30 doc = hexablock.addDocument()
31
32 orig1 = doc.addVertex(0, 0, 0)
33 dx = doc.addVector(1, 0, 0)
34 dy = doc.addVector(0, 1, 0)
35 dz = doc.addVector(0, 0, 1)
36
37 dimx = 11
38 dimy = 11
39 dimz = 2
40 grid1 = doc.makeCartesian(orig1, dx, dy, dz, dimx, dimy, dimz)
41
42 orig2 = doc.addVertex(dimx/2.0, 0, 8)
43 grid2 = doc.makeCylindrical(orig2, dx, dy, 1, 180, 1, dimz, dimy,
44                             dimx, False)
45
46 mx = dimx/2
47 my = dimy/2
48 prems = grid1.getQuadIJ(mx, my, dimz)
49 cible = grid2.getQuadJK(dimz, mx, my)
50
51 # @todo reference = test_hexa1.cxx ou ModelTest.cxx ?
52 v1 = prems.getVertex(0)
53 v2 = cible.getVertex(0)
54 v3 = prems.getVertex(1)
55 v4 = cible.getVertex(3)
56
57 liste = [prems]
58 liste.extend([grid1.getQuadIJ(nx, my, dimz) for nx in range(dimx) if nx != mx])
59 liste.extend([grid1.getQuadIJ(mx, ny, dimz) for ny in range(dimy) if ny != my])
60
61 height = 5
62
63 elts = doc.joinQuads(liste, cible, v1, v2, v3, v4, height) 
64
65 ## indispensable ???
66 nbr_joint_vertex = elts.countVertex()
67 nbr_surf_vertex = nbr_joint_vertex/(height + 1)
68
69 ind0 = elts.findVertex(v1)
70 for nh in range(nbr_surf_vertex):
71     elts.getVertex(nh).setScalar(5)
72 for nh in range(height):
73     elts.getVertex(nh*nbr_surf_vertex).setScalar(3)
74
75
76 file_name = os.path.join(os.environ['TMP'], 'joint.vtk')
77 ####  elts.saveVtk(file_name)
78
79 print("...test join OK")