Salome HOME
7f66f5c37b1be83d8bb222aa2fc1a35a213a1ef9
[modules/hexablock.git] / src / TEST_PY / test_unit / test_cone.py
1 # -*- coding: latin-1 -*-
2 # Hexa : Creation d'hexaedres 
3
4 # Copyright (C) 2009-2023  CEA, EDF
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 import hexablock
24 import os
25
26 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
27
28
29 doc  = hexablock.addDocument ("test_cone")
30
31 orig = doc.addVertex (0, 0, 0)
32 ori2 = doc.addVertex (0, 0, 10)
33 vz   = doc.addVector (0, 0, 1)
34 vx   = doc.addVector (1 ,0, 0)
35
36 rad1   = 2.0
37 rad2   = 1.0
38 height = 5.0
39 angle  = 270.0
40 hollow = False
41
42 nr = 2
43 na = 8
44 nl = 1
45
46 c1 = doc.makeCylindrical (orig, vx,vz, rad1, angle, height, nr,na,nl, hollow)
47 c2 = doc.makeCylindrical (ori2, vx,vz, rad2, angle, height, nr,na,nl, hollow)
48
49 vh0 = c2.getVertexIJK (0, 0, 0)
50 vh1 = c2.getVertexIJK (1, 0, 0)
51
52 vb0 = c1.getVertexIJK (0, 0, nl)
53 vb1 = c1.getVertexIJK (1, 0, nl)
54
55 qcible = c2.getQuadIJ (0, 0, 0)
56 qliste = []
57 for ni in range (nr) :
58     for nj in range (na) :
59         quad = c1.getQuadIJ (ni, nj, nl)
60         qliste.append (quad)
61
62                           ## Join quads to make a cone between the 2 cylinders
63 doc.joinQuads  (qliste, qcible, vb0, vh0, vb1, vh1, 1)
64
65              ### -------------------- Mesh 
66
67 law = doc.addLaw ("Uniform", 4)
68
69 for np in range(doc.countPropagation()):
70     propa = doc.getPropagation (np)
71     propa.setLaw (law) 
72
73 mesh_hexas = hexablock.mesh(doc)
74