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()
39 # an assembly of a box, a cylinder and a truncated cone meshed with tetrahedral.
58 box = geompy.MakeBox(-cote, -cote, -cote, +cote, +cote, +cote)
63 pt1 = geompy.MakeVertex(0, 0, cote/3)
64 di1 = geompy.MakeVectorDXDYDZ(0, 0, 1)
65 cyl = geompy.MakeCylinder(pt1, di1, section, size)
67 # Build a truncated cone
68 # ----------------------
70 pt2 = geompy.MakeVertex(0, 0, size)
71 cone = geompy.MakeCone(pt2, di1, radius_1, radius_2, height)
76 box_cyl = geompy.MakeFuse(box, cyl)
77 piece = geompy.MakeFuse(box_cyl, cone)
82 geompy.addToStudy(piece, name)
84 # Create a group of faces
85 # -----------------------
87 group = geompy.CreateGroup(piece, geompy.ShapeType["FACE"])
89 group_name = name + "_grp"
90 geompy.addToStudy(group, group_name)
91 group.SetName(group_name)
93 # Add faces in the group
94 # ----------------------
96 faces = geompy.SubShapeAllIDs(piece, geompy.ShapeType["FACE"])
98 geompy.UnionIDs(group, faces)
103 # Define a mesh on a geometry
104 # ---------------------------
106 tetra = smesh.Mesh(piece, name)
108 # Define 1D hypothesis
109 # --------------------
111 algo1d = tetra.Segment()
112 algo1d.LocalLength(10)
114 # Define 2D hypothesis
115 # --------------------
117 algo2d = tetra.Triangle()
118 algo2d.LengthFromEdges()
120 # Define 3D hypothesis
121 # --------------------
123 algo3d = tetra.Tetrahedron(smeshBuilder.NETGEN)
124 algo3d.MaxElementVolume(100)
131 # Create a groupe of faces
132 # ------------------------
136 # Update object browser
137 # ---------------------
139 salome.sg.updateObjBrowser()