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 # =======================================
31 # A not centered holed cube build by boolean geometric operations
53 def triangle(p1, p2, p3):
55 l.append(MakeEdge(p1, p2))
56 l.append(MakeEdge(p2, p3))
57 l.append(MakeEdge(p3, p1))
64 basePoint111 = MakeVertex(ox-longueur1, oy, oz-largeur1)
65 basePoint211 = MakeVertex(ox+longueur2, oy, oz-largeur1)
66 basePoint112 = MakeVertex(ox-longueur1, oy, oz+largeur2)
67 basePoint212 = MakeVertex(ox+longueur2, oy, oz+largeur2)
69 holePoint = MakeVertex(ox, oy, oz)
74 baseFace1 = triangle(basePoint111, basePoint211, holePoint)
75 baseFace2 = triangle(basePoint211, basePoint212, holePoint)
76 baseFace3 = triangle(basePoint212, basePoint112, holePoint)
77 baseFace4 = triangle(basePoint112, basePoint111, holePoint)
82 baseVector = MakeVectorDXDYDZ(0, 1, 0)
84 baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur)
85 baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur)
86 baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur)
87 baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur)
89 holeSolid = MakeCylinder(holePoint, baseVector, rayon, hauteur)
94 baseHexa1 = MakeCut(baseSolid1, holeSolid)
95 baseHexa2 = MakeCut(baseSolid2, holeSolid)
96 baseHexa3 = MakeCut(baseSolid3, holeSolid)
97 baseHexa4 = MakeCut(baseSolid4, holeSolid)
99 # Compound, glue and repair
100 # -------------------------
103 c_l.append(baseHexa1)
104 c_l.append(baseHexa2)
105 c_l.append(baseHexa3)
106 c_l.append(baseHexa4)
108 c_cpd = MakeCompound(c_l)
109 c_glu = MakeGlueFaces(c_cpd, 1.e-5)
110 piece = RemoveExtraEdges(c_glu)
115 piece_id = addToStudy(piece, "ex06_hole1boolean")
120 # Create a hexahedral mesh
121 # ------------------------
123 hexa = smesh.Mesh(piece, "ex06_hole1boolean:hexa")
125 algo = hexa.Segment()
127 algo.NumberOfSegments(11)
133 # Create local hypothesis
134 # -----------------------
136 edge1 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz-largeur1))
137 algo1 = hexa.Segment(edge1)
138 algo1.NumberOfSegments(3)
141 edge2 = GetEdgeNearPoint(piece, MakeVertex(ox-longueur1, oy, oz))
142 algo2 = hexa.Segment(edge2)
143 algo2.NumberOfSegments(5)
146 edge3 = GetEdgeNearPoint(piece, MakeVertex(ox, oy, oz+largeur2))
147 algo3 = hexa.Segment(edge3)
148 algo3.NumberOfSegments(7)
151 edge4 = GetEdgeNearPoint(piece, MakeVertex(ox+longueur2, oy, oz))
152 algo4 = hexa.Segment(edge4)
153 algo4.NumberOfSegments(9)