1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 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.
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
23 # ==================================
41 base = geo.MakeVertex(0, 0, 0)
42 direction = geo.MakeVectorDXDYDZ(0, 0, 1)
44 cylinder = geo.MakeCylinder(base, direction, radius, height)
46 geo.addToStudy(cylinder, "cylinder")
53 box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
54 box_axis = geo.MakeLine(base, direction)
55 box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
57 hole = geo.MakeCut(cylinder, box)
61 plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
62 plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
64 blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
65 blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
66 blocks_all = geo.MakeCompound(blocks_list)
67 blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
69 geo.addToStudy(blocks, "cylinder:blocks")
71 # Build geometric groups
72 # ----------------------
74 def group(name, shape, type, base=None, direction=None):
75 t = geo.ShapeType[type]
76 g = geo.CreateGroup(shape, t)
78 geo.addToStudy(g, name)
82 l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
87 group_a = group("baseA", blocks, "FACE", base, direction)
89 base_b = geo.MakeVertex(0, 0, height)
90 group_b = group("baseB", blocks, "FACE", base_b, direction)
92 group_1 = group("limit", blocks, "SOLID")
93 group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
94 geo.UnionIDs(group_1, group_1_all)
95 group_1_box = geo.GetBlockNearPoint(blocks, base)
96 geo.DifferenceList(group_1, [group_1_box])
98 # Mesh the blocks with hexahedral
99 # -------------------------------
101 def discretize(x, y, z, n, s=blocks):
102 p = geo.MakeVertex(x, y, z)
103 e = geo.GetEdgeNearPoint(s, p)
105 a.NumberOfSegments(n)
108 hexa = smesh.Mesh(blocks)
110 hexa_1d = hexa.Segment()
111 hexa_1d.NumberOfSegments(1)
113 discretize(+radius , +radius, 0, 5)
114 discretize(-radius , +radius, 0, 8)
115 discretize((radius+size)/2, 0, 0, 10)
116 discretize( +radius, 0, height/2, 20)