Salome HOME
d7341b660ee58737a7486a64e571951221e73c91
[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-2013  CEA/DEN, EDF R&D
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.
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 import geompy
26
27 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
28
29
30 doc  = hexablock.addDocument ("test_cone")
31
32 orig = doc.addVertex (0, 0, 0)
33 ori2 = doc.addVertex (0, 0, 10)
34 vz   = doc.addVector (0, 0, 1)
35 vx   = doc.addVector (1 ,0, 0)
36
37 rad1   = 2.0
38 rad2   = 1.0
39 height = 5.0
40 angle  = 270.0
41 hollow = False
42
43 nr = 2
44 na = 8
45 nl = 1
46
47 c1 = doc.makeCylindrical (orig, vx,vz, rad1, angle, height, nr,na,nl, hollow)
48 c2 = doc.makeCylindrical (ori2, vx,vz, rad2, angle, height, nr,na,nl, hollow)
49
50 vh0 = c2.getVertexIJK (0, 0, 0)
51 vh1 = c2.getVertexIJK (1, 0, 0)
52
53 vb0 = c1.getVertexIJK (0, 0, nl)
54 vb1 = c1.getVertexIJK (1, 0, nl)
55
56 qcible = c2.getQuadIJ (0, 0, 0)
57 qliste = []
58 for ni in range (nr) :
59     for nj in range (na) :
60         quad = c1.getQuadIJ (ni, nj, nl)
61         qliste.append (quad)
62
63                           ## Join quads to make a cone between the 2 cylinders
64 doc.joinQuads  (qliste, qcible, vb0, vh0, vb1, vh1, 1)
65
66              ### -------------------- Mesh 
67
68 law = doc.addLaw ("Uniform", 4)
69
70 for np in range(doc.countPropagation()):
71     propa = doc.getPropagation (np)
72     propa.setLaw (law) 
73
74 mesh_hexas = hexablock.mesh(doc)
75