Salome HOME
Updated copyright comment
[modules/hexablock.git] / src / TEST_PY / test_unit / test_piquage.py
1 # -*- coding: latin-1 -*-
2 # Copyright (C) 2009-2024  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 os
24 import hexablock
25 geompy = hexablock.geompy
26
27 #---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
28
29 use_paraview = False
30
31 # ======================================================= test_pipes
32 def test_piquage () :
33
34     name = "piquage"
35     doc  = hexablock.addDocument (name)
36
37     orig = doc.addVertex ( 8, 0, 0)
38     vx   = doc.addVector ( 1 ,0, 0)
39     vy   = doc.addVector ( 0, 1, 0)
40     vz   = doc.addVector ( 0, 0, 1)
41
42     size_x   = 5
43     size_y   = 5
44     size_z   = 3
45     size_cyl = 12
46
47     rint     = 2
48     rext     = 3
49     angle    = 360
50     haut     = 1
51     nr       = 1
52     nh       = 1
53
54     grid = doc.makeCartesianTop (size_x, size_y, size_z)
55     pipe = doc.makePipeUni  (orig, vx, vz, rint, rext, angle,
56                              haut, nr, size_cyl, nh) 
57
58     c1 = grid.getVertexIJK (2, 1, size_z)
59     c2 = grid.getVertexIJK (3, 1, size_z)
60
61     p1 = pipe.getVertexIJK (1, 7, 1)
62     p2 = pipe.getVertexIJK (1, 8, 1)
63
64     qpattern = []
65     qtarget  = []
66     for na in range (size_cyl) :
67        quad = pipe.getQuadIJ (0, na, 1)
68        quad.setColor (2)
69        qpattern.append (quad)
70
71     for ni in range (1, size_x-1) :
72         for nj in range (1, size_y-1) :
73             quad = grid.getQuadIJ (ni, nj, size_z)
74             quad.setColor (2)
75             qtarget.append (quad)
76
77     c1.setColor (6)
78     c2.setColor (4)
79
80     p1.setColor (6)
81     p2.setColor (4)
82     if use_paraview :
83        doc.saveVtk ("replace0.vtk")
84
85     doc.replace (qpattern, qtarget, p1,c1, p2,c2)
86     if use_paraview :
87        doc.saveVtk ("replace1.vtk")
88
89     pipe.remove()
90     if use_paraview :
91        doc.saveVtk ("replace2.vtk")
92     return doc
93
94 # ================================================================= Begin
95
96 doc = test_piquage  ()
97
98 doc.addLaws (0.9, True)
99
100 mesh_hexas = hexablock.mesh (doc, "maillage:hexas")