1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # =======================================
29 from salome.geom import geomBuilder
30 geompy = geomBuilder.New(salome.myStudy)
32 import SMESH, SALOMEDS
33 from salome.smesh import smeshBuilder
34 smesh = smeshBuilder.New(salome.myStudy)
39 # Create the hexahedrical block geometry of a holed parallelepipede.
40 # The hole has a T form composed by 2 cylinders with different radius, and their axis are normal.
41 # This piece is meshed in hexahedrical.
62 p_boite = geompy.MakeBox(gx-g_dx, gy-g_dy, gz-g_dz, gx+g_dx, gy+g_dy, gz+g_dz)
67 g_base = geompy.MakeVertex(gx-g_dx, gy, gz)
68 g_dir = geompy.MakeVectorDXDYDZ(1, 0, 0)
69 g_cyl = geompy.MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2)
74 b_boite = geompy.MakeCut(p_boite , g_cyl)
79 p_base = geompy.MakeVertex(gx, gy, gz)
83 p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, 1 , 0 ), g_trim))
84 p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, g_dz, g_dy), g_trim))
85 p_tools.append(geompy.MakePlane(p_base, geompy.MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim))
87 p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim))
88 p_tools.append(geompy.MakePlane(geompy.MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim))
90 p_piece = geompy.MakePartition([b_boite], p_tools, [], [], geompy.ShapeType["SOLID"])
95 c_cyl = geompy.MakeCylinder(p_base, geompy.MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz)
100 d_element = geompy.SubShapeAllSorted(p_piece, geompy.ShapeType["SOLID"])
102 d_element[ 8] = geompy.MakeCut(d_element[ 8], c_cyl)
103 d_element[10] = geompy.MakeCut(d_element[10], c_cyl)
108 piece = geompy.RemoveExtraEdges(geompy.MakeCompound(d_element))
109 piece = geompy.MakeGlueFaces(piece, 1e-07)
114 piece_id = geompy.addToStudy(piece, "ex16_cyl2complementary")
119 # Create a hexahedral mesh
120 # ------------------------
122 hexa = smesh.Mesh(piece, "ex16_cyl2complementary:hexa")
124 algo = hexa.Segment()
125 algo.NumberOfSegments(12)
131 # Define local hypothesis
132 # -----------------------
134 def local(x, y, z, d):
135 edge = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(x, y, z))
136 algo = hexa.Segment(edge)
137 algo.NumberOfSegments(d)
140 local(gx , gy+g_dy, gz+g_dz, 7)
141 local(gx+g_dx, gy+g_dy, gz , 21)
142 local(gx+g_dx, gy-g_dy, gz , 21)
149 # Update object browser
150 # ---------------------
152 salome.sg.updateObjBrowser(1)