1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # ==================================
40 base = geo.MakeVertex(0, 0, 0)
41 direction = geo.MakeVectorDXDYDZ(0, 0, 1)
43 cylinder = geo.MakeCylinder(base, direction, radius, height)
45 geo.addToStudy(cylinder, "cylinder")
52 box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
53 box_axis = geo.MakeLine(base, direction)
54 box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
56 hole = geo.MakeCut(cylinder, box)
60 plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
61 plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
63 blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
64 blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
65 blocks_all = geo.MakeCompound(blocks_list)
66 blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
68 geo.addToStudy(blocks, "cylinder:blocks")
70 # Build geometric groups
71 # ----------------------
73 def group(name, shape, type, base=None, direction=None):
74 t = geo.ShapeType[type]
75 g = geo.CreateGroup(shape, t)
77 geo.addToStudy(g, name)
81 l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
86 group_a = group("baseA", blocks, "FACE", base, direction)
88 base_b = geo.MakeVertex(0, 0, height)
89 group_b = group("baseB", blocks, "FACE", base_b, direction)
91 group_1 = group("limit", blocks, "SOLID")
92 group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
93 geo.UnionIDs(group_1, group_1_all)
94 group_1_box = geo.GetBlockNearPoint(blocks, base)
95 geo.DifferenceList(group_1, [group_1_box])
97 # Mesh the blocks with hexahedral
98 # -------------------------------
100 def discretize(x, y, z, n, s=blocks):
101 p = geo.MakeVertex(x, y, z)
102 e = geo.GetEdgeNearPoint(s, p)
104 a.NumberOfSegments(n)
107 hexa = smesh.Mesh(blocks)
109 hexa_1d = hexa.Segment()
110 hexa_1d.NumberOfSegments(1)
112 discretize(+radius , +radius, 0, 5)
113 discretize(-radius , +radius, 0, 8)
114 discretize((radius+size)/2, 0, 0, 10)
115 discretize( +radius, 0, height/2, 20)