1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2011 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
24 # =======================================
33 # A not centered holed cube build by boolean geometric operations
55 def triangle(p1, p2, p3):
57 l.append(MakeEdge(p1, p2))
58 l.append(MakeEdge(p2, p3))
59 l.append(MakeEdge(p3, p1))
66 basePoint111 = MakeVertex(ox-longueur1, oy, oz-largeur1)
67 basePoint211 = MakeVertex(ox+longueur2, oy, oz-largeur1)
68 basePoint112 = MakeVertex(ox-longueur1, oy, oz+largeur2)
69 basePoint212 = MakeVertex(ox+longueur2, oy, oz+largeur2)
71 holePoint = MakeVertex(ox, oy, oz)
76 baseFace1 = triangle(basePoint111, basePoint211, holePoint)
77 baseFace2 = triangle(basePoint211, basePoint212, holePoint)
78 baseFace3 = triangle(basePoint212, basePoint112, holePoint)
79 baseFace4 = triangle(basePoint112, basePoint111, holePoint)
84 baseVector = MakeVectorDXDYDZ(0, 1, 0)
86 baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur)
87 baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur)
88 baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur)
89 baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur)
91 holeSolid = MakeCylinder(holePoint, baseVector, rayon, hauteur)
96 baseHexa1 = MakeCut(baseSolid1, holeSolid)
97 baseHexa2 = MakeCut(baseSolid2, holeSolid)
98 baseHexa3 = MakeCut(baseSolid3, holeSolid)
99 baseHexa4 = MakeCut(baseSolid4, holeSolid)
101 # Compound, glue and repair
102 # -------------------------
105 c_l.append(baseHexa1)
106 c_l.append(baseHexa2)
107 c_l.append(baseHexa3)
108 c_l.append(baseHexa4)
110 c_cpd = MakeCompound(c_l)
111 c_glu = MakeGlueFaces(c_cpd, 1.e-5)
112 piece = RemoveExtraEdges(c_glu, doUnionFaces=True)
117 piece_id = addToStudy(piece, "ex06_hole1boolean")
122 smesh.SetCurrentStudy(salome.myStudy)
124 # Create a hexahedral mesh
125 # ------------------------
127 hexa = smesh.Mesh(piece, "ex06_hole1boolean:hexa")
129 algo = hexa.Segment()
131 algo.NumberOfSegments(11)
137 # Create local hypothesis
138 # -----------------------
140 edge1 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz-largeur1))
141 algo1 = hexa.Segment(edge1)
142 algo1.NumberOfSegments(3)
145 edge2 = GetEdgeNearPoint(piece, MakeVertex(ox-longueur1, oy, oz))
146 algo2 = hexa.Segment(edge2)
147 algo2.NumberOfSegments(5)
150 edge3 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz+largeur2))
151 algo3 = hexa.Segment(edge3)
152 algo3.NumberOfSegments(7)
155 edge4 = GetEdgeNearPoint(piece, MakeVertex(ox+longueur2, oy, oz))
156 algo4 = hexa.Segment(edge4)
157 algo4.NumberOfSegments(9)