2 # -*- coding: iso-8859-1 -*-
3 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # ==================================
42 base = geo.MakeVertex(0, 0, 0)
43 direction = geo.MakeVectorDXDYDZ(0, 0, 1)
45 cylinder = geo.MakeCylinder(base, direction, radius, height)
47 geo.addToStudy(cylinder, "cylinder")
54 box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
55 box_axis = geo.MakeLine(base, direction)
56 box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
58 hole = geo.MakeCut(cylinder, box)
62 plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
63 plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
65 blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
66 blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
67 blocks_all = geo.MakeCompound(blocks_list)
68 blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
70 geo.addToStudy(blocks, "cylinder:blocks")
72 # Build geometric groups
73 # ----------------------
75 def group(name, shape, type, base=None, direction=None):
76 t = geo.ShapeType[type]
77 g = geo.CreateGroup(shape, t)
79 geo.addToStudy(g, name)
83 l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
88 group_a = group("baseA", blocks, "FACE", base, direction)
90 base_b = geo.MakeVertex(0, 0, height)
91 group_b = group("baseB", blocks, "FACE", base_b, direction)
93 group_1 = group("limit", blocks, "SOLID")
94 group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
95 geo.UnionIDs(group_1, group_1_all)
96 group_1_box = geo.GetBlockNearPoint(blocks, base)
97 geo.DifferenceList(group_1, [group_1_box])
99 # Mesh the blocks with hexahedral
100 # -------------------------------
102 def discretize(x, y, z, n, s=blocks):
103 p = geo.MakeVertex(x, y, z)
104 e = geo.GetEdgeNearPoint(s, p)
106 a.NumberOfSegments(n)
109 hexa = smesh.Mesh(blocks)
111 hexa_1d = hexa.Segment()
112 hexa_1d.NumberOfSegments(1)
114 discretize(+radius , +radius, 0, 5)
115 discretize(-radius , +radius, 0, 8)
116 discretize((radius+size)/2, 0, 0, 10)
117 discretize( +radius, 0, height/2, 20)