1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2015 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(salome.myStudy)
32 import SMESH, SALOMEDS
33 from salome.smesh import smeshBuilder
34 smesh = smeshBuilder.New(salome.myStudy)
39 # A twice holed cube build by points, edges, faces and solids
59 piecePoint1 = geompy.MakeVertex(ox , oy, oz)
60 piecePoint2 = geompy.MakeVertex(ox+longueur, oy, oz)
61 piecePoint3 = geompy.MakeVertex(ox+longueur, oy, oz+largeur)
62 piecePoint4 = geompy.MakeVertex(ox , oy, oz+largeur)
66 cylPoint1 = geompy.MakeVertex(ox+cylindre , oy, cz-rayon)
67 cylPoint2 = geompy.MakeVertex(ox+longueur-cylindre, oy, cz-rayon)
68 cylPoint3 = geompy.MakeVertex(ox+longueur-cylindre, oy, cz+rayon)
69 cylPoint4 = geompy.MakeVertex(ox+cylindre , oy, cz+rayon)
74 pieceEdge1 = geompy.MakeEdge(piecePoint1, piecePoint4)
75 pieceEdge2 = geompy.MakeEdge(piecePoint1, cylPoint1)
76 pieceEdge3 = geompy.MakeEdge(piecePoint4, cylPoint4)
78 pieceEdge4 = geompy.MakeEdge(piecePoint2, piecePoint3)
79 pieceEdge5 = geompy.MakeEdge(piecePoint2, cylPoint2)
80 pieceEdge6 = geompy.MakeEdge(piecePoint3, cylPoint3)
82 pieceEdge7 = geompy.MakeEdge(cylPoint1, cylPoint2)
83 pieceEdge8 = geompy.MakeEdge(cylPoint3, cylPoint4)
85 cylEdge1 = geompy.MakeArc(cylPoint1, geompy.MakeVertex(ox+cylindre-rayon , oy, cz), cylPoint4)
86 cylEdge2 = geompy.MakeArc(cylPoint1, geompy.MakeVertex(ox+cylindre+rayon , oy, cz), cylPoint4)
87 cylEdge3 = geompy.MakeArc(cylPoint2, geompy.MakeVertex(ox+longueur-cylindre-rayon, oy, cz), cylPoint3)
88 cylEdge4 = geompy.MakeArc(cylPoint2, geompy.MakeVertex(ox+longueur-cylindre+rayon, oy, cz), cylPoint3)
93 pieceFace1 = geompy.MakeQuad4Vertices(piecePoint1, piecePoint2, cylPoint2 , cylPoint1 )
94 pieceFace2 = geompy.MakeQuad (pieceEdge1 , pieceEdge2 , cylEdge1 , pieceEdge3)
95 pieceFace3 = geompy.MakeQuad4Vertices(piecePoint3, piecePoint4, cylPoint4 , cylPoint3 )
96 pieceFace4 = geompy.MakeQuad (pieceEdge4 , pieceEdge5 , cylEdge4 , pieceEdge6)
97 pieceFace5 = geompy.MakeQuad (pieceEdge7 , cylEdge3 , pieceEdge8, cylEdge2 )
102 pieceVector = geompy.MakeVectorDXDYDZ(0, 1, 0)
104 pieceSolid1 = geompy.MakePrismVecH(pieceFace1, pieceVector, hauteur)
105 pieceSolid2 = geompy.MakePrismVecH(pieceFace2, pieceVector, hauteur)
106 pieceSolid3 = geompy.MakePrismVecH(pieceFace3, pieceVector, hauteur)
107 pieceSolid4 = geompy.MakePrismVecH(pieceFace4, pieceVector, hauteur)
108 pieceSolid5 = geompy.MakePrismVecH(pieceFace5, pieceVector, hauteur)
113 c_cpd = geompy.MakeCompound([pieceSolid1, pieceSolid2, pieceSolid3, pieceSolid4, pieceSolid5])
115 piece = geompy.MakeGlueFaces(c_cpd, 1.e-5)
120 piece_id = geompy.addToStudy(piece, "ex08_hole2build")
125 # Create a hexahedral mesh
126 # ------------------------
128 hexa = smesh.Mesh(piece, "ex08_hole2build:hexa")
130 algo = hexa.Segment()
131 algo.NumberOfSegments(7)
142 # Update object browser
143 # ---------------------
145 salome.sg.updateObjBrowser(1)