1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2020 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, or (at your option) any later version.
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 # =======================================
29 from salome.geom import geomBuilder
30 geompy = geomBuilder.New()
32 import SMESH, SALOMEDS
33 from salome.smesh import smeshBuilder
34 smesh = smeshBuilder.New()
39 # A not centered holed cube build by boolean geometric operations
61 def triangle(p1, p2, p3):
63 l.append(geompy.MakeEdge(p1, p2))
64 l.append(geompy.MakeEdge(p2, p3))
65 l.append(geompy.MakeEdge(p3, p1))
66 w = geompy.MakeWire(l)
67 return geompy.MakeFace(w, 1)
72 basePoint111 = geompy.MakeVertex(ox-longueur1, oy, oz-largeur1)
73 basePoint211 = geompy.MakeVertex(ox+longueur2, oy, oz-largeur1)
74 basePoint112 = geompy.MakeVertex(ox-longueur1, oy, oz+largeur2)
75 basePoint212 = geompy.MakeVertex(ox+longueur2, oy, oz+largeur2)
77 holePoint = geompy.MakeVertex(ox, oy, oz)
82 baseFace1 = triangle(basePoint111, basePoint211, holePoint)
83 baseFace2 = triangle(basePoint211, basePoint212, holePoint)
84 baseFace3 = triangle(basePoint212, basePoint112, holePoint)
85 baseFace4 = triangle(basePoint112, basePoint111, holePoint)
90 baseVector = geompy.MakeVectorDXDYDZ(0, 1, 0)
92 baseSolid1 = geompy.MakePrismVecH(baseFace1, baseVector, hauteur)
93 baseSolid2 = geompy.MakePrismVecH(baseFace2, baseVector, hauteur)
94 baseSolid3 = geompy.MakePrismVecH(baseFace3, baseVector, hauteur)
95 baseSolid4 = geompy.MakePrismVecH(baseFace4, baseVector, hauteur)
97 holeSolid = geompy.MakeCylinder(holePoint, baseVector, rayon, hauteur)
102 baseHexa1 = geompy.MakeCut(baseSolid1, holeSolid)
103 baseHexa2 = geompy.MakeCut(baseSolid2, holeSolid)
104 baseHexa3 = geompy.MakeCut(baseSolid3, holeSolid)
105 baseHexa4 = geompy.MakeCut(baseSolid4, holeSolid)
107 # Compound, glue and repair
108 # -------------------------
111 c_l.append(baseHexa1)
112 c_l.append(baseHexa2)
113 c_l.append(baseHexa3)
114 c_l.append(baseHexa4)
116 c_cpd = geompy.MakeCompound(c_l)
117 c_glu = geompy.MakeGlueFaces(c_cpd, 1.e-5)
118 piece = geompy.RemoveExtraEdges(c_glu, doUnionFaces=True)
123 piece_id = geompy.addToStudy(piece, "ex06_hole1boolean")
128 # Create a hexahedral mesh
129 # ------------------------
131 hexa = smesh.Mesh(piece, "ex06_hole1boolean:hexa")
133 algo = hexa.Segment()
135 algo.NumberOfSegments(11)
141 # Create local hypothesis
142 # -----------------------
144 edge1 = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(ox, oy, oz-largeur1))
145 algo1 = hexa.Segment(edge1)
146 algo1.NumberOfSegments(3)
149 edge2 = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(ox-longueur1, oy, oz))
150 algo2 = hexa.Segment(edge2)
151 algo2.NumberOfSegments(5)
154 edge3 = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(ox, oy, oz+largeur2))
155 algo3 = hexa.Segment(edge3)
156 algo3.NumberOfSegments(7)
159 edge4 = geompy.GetEdgeNearPoint(piece, geompy.MakeVertex(ox+longueur2, oy, oz))
160 algo4 = hexa.Segment(edge4)
161 algo4.NumberOfSegments(9)
169 # Update object browser
170 # ---------------------
172 salome.sg.updateObjBrowser()