1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2021 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()
41 # A centered holed cube build by build by points, edges, faces and solids
59 basePoint111 = geompy.MakeVertex(ox , oy, oz)
60 basePoint211 = geompy.MakeVertex(ox+longueur, oy, oz)
61 basePoint112 = geompy.MakeVertex(ox , oy, oz+largeur)
62 basePoint212 = geompy.MakeVertex(ox+longueur, oy, oz+largeur)
70 dx = rayon/math.sqrt(1+ll)
71 dz = rayon/math.sqrt(1+1/ll)
73 circlePoint1 = geompy.MakeVertex(cx-dx, cy, cz-dz)
74 circlePoint2 = geompy.MakeVertex(cx+dx, cy, cz-dz)
75 circlePoint3 = geompy.MakeVertex(cx+dx, cy, cz+dz)
76 circlePoint4 = geompy.MakeVertex(cx-dx, cy, cz+dz)
81 squareEdge1 = geompy.MakeEdge(basePoint111, basePoint211)
82 squareEdge2 = geompy.MakeEdge(basePoint211, basePoint212)
83 squareEdge3 = geompy.MakeEdge(basePoint212, basePoint112)
84 squareEdge4 = geompy.MakeEdge(basePoint112, basePoint111)
86 diagEdge1 = geompy.MakeEdge(basePoint111, circlePoint1)
87 diagEdge2 = geompy.MakeEdge(basePoint211, circlePoint2)
88 diagEdge3 = geompy.MakeEdge(basePoint212, circlePoint3)
89 diagEdge4 = geompy.MakeEdge(basePoint112, circlePoint4)
91 arcEdge1 = geompy.MakeArc(circlePoint1, geompy.MakeVertex(cx , cy, cz-rayon), circlePoint2)
92 arcEdge2 = geompy.MakeArc(circlePoint2, geompy.MakeVertex(cx+rayon, cy, cz ), circlePoint3)
93 arcEdge3 = geompy.MakeArc(circlePoint3, geompy.MakeVertex(cx , cy, cz+rayon), circlePoint4)
94 arcEdge4 = geompy.MakeArc(circlePoint4, geompy.MakeVertex(cx-rayon, cy, cz ), circlePoint1)
99 baseFace1 = geompy.MakeQuad(squareEdge1, diagEdge2, arcEdge1, diagEdge1)
100 baseFace2 = geompy.MakeQuad(squareEdge2, diagEdge3, arcEdge2, diagEdge2)
101 baseFace3 = geompy.MakeQuad(squareEdge3, diagEdge4, arcEdge3, diagEdge3)
102 baseFace4 = geompy.MakeQuad(squareEdge4, diagEdge1, arcEdge4, diagEdge4)
107 baseVector = geompy.MakeVectorDXDYDZ(0, 1, 0)
109 baseSolid1 = geompy.MakePrismVecH(baseFace1, baseVector, hauteur)
110 baseSolid2 = geompy.MakePrismVecH(baseFace2, baseVector, hauteur)
111 baseSolid3 = geompy.MakePrismVecH(baseFace3, baseVector, hauteur)
112 baseSolid4 = geompy.MakePrismVecH(baseFace4, baseVector, hauteur)
118 c_l.append(baseSolid1)
119 c_l.append(baseSolid2)
120 c_l.append(baseSolid3)
121 c_l.append(baseSolid4)
123 c_cpd = geompy.MakeCompound(c_l)
124 piece = geompy.MakeGlueFaces(c_cpd, 1.e-5)
129 piece_id = geompy.addToStudy(piece, "ex05_hole1build")
134 # Create a hexahedral mesh
135 # ------------------------
137 hexa = smesh.Mesh(piece, "ex05_hole1build:hexa")
139 algo = hexa.Segment()
141 algo.NumberOfSegments(6, 3)
152 # Update object browser
153 # ---------------------
155 salome.sg.updateObjBrowser()