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 # =======================================
32 # A not centered holed cube build by boolean geometric operations
54 def triangle(p1, p2, p3):
56 l.append(MakeEdge(p1, p2))
57 l.append(MakeEdge(p2, p3))
58 l.append(MakeEdge(p3, p1))
65 basePoint111 = MakeVertex(ox-longueur1, oy, oz-largeur1)
66 basePoint211 = MakeVertex(ox+longueur2, oy, oz-largeur1)
67 basePoint112 = MakeVertex(ox-longueur1, oy, oz+largeur2)
68 basePoint212 = MakeVertex(ox+longueur2, oy, oz+largeur2)
70 holePoint = MakeVertex(ox, oy, oz)
75 baseFace1 = triangle(basePoint111, basePoint211, holePoint)
76 baseFace2 = triangle(basePoint211, basePoint212, holePoint)
77 baseFace3 = triangle(basePoint212, basePoint112, holePoint)
78 baseFace4 = triangle(basePoint112, basePoint111, holePoint)
83 baseVector = MakeVectorDXDYDZ(0, 1, 0)
85 baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur)
86 baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur)
87 baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur)
88 baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur)
90 holeSolid = MakeCylinder(holePoint, baseVector, rayon, hauteur)
95 baseHexa1 = MakeCut(baseSolid1, holeSolid)
96 baseHexa2 = MakeCut(baseSolid2, holeSolid)
97 baseHexa3 = MakeCut(baseSolid3, holeSolid)
98 baseHexa4 = MakeCut(baseSolid4, holeSolid)
100 # Compound, glue and repair
101 # -------------------------
104 c_l.append(baseHexa1)
105 c_l.append(baseHexa2)
106 c_l.append(baseHexa3)
107 c_l.append(baseHexa4)
109 c_cpd = MakeCompound(c_l)
110 c_glu = MakeGlueFaces(c_cpd, 1.e-5)
111 piece = RemoveExtraEdges(c_glu)
116 piece_id = addToStudy(piece, "ex06_hole1boolean")
121 smesh.SetCurrentStudy(salome.myStudy)
123 # Create a hexahedral mesh
124 # ------------------------
126 hexa = smesh.Mesh(piece, "ex06_hole1boolean:hexa")
128 algo = hexa.Segment()
130 algo.NumberOfSegments(11)
136 # Create local hypothesis
137 # -----------------------
139 edge1 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz-largeur1))
140 algo1 = hexa.Segment(edge1)
141 algo1.NumberOfSegments(3)
144 edge2 = GetEdgeNearPoint(piece, MakeVertex(ox-longueur1, oy, oz))
145 algo2 = hexa.Segment(edge2)
146 algo2.NumberOfSegments(5)
149 edge3 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz+largeur2))
150 algo3 = hexa.Segment(edge3)
151 algo3.NumberOfSegments(7)
154 edge4 = GetEdgeNearPoint(piece, MakeVertex(ox+longueur2, oy, oz))
155 algo4 = hexa.Segment(edge4)
156 algo4.NumberOfSegments(9)