1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2022 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 # File : SMESH_testExtrusion3D.py
26 # Description : Create meshes to test extrusion of mesh elements along path
31 from salome.geom import geomBuilder
32 geompy = geomBuilder.New()
34 import SMESH, SALOMEDS
35 from salome.smesh import smeshBuilder
36 smesh = smeshBuilder.New()
39 # create points to build two circles
40 p1 = geompy.MakeVertex(0, 100, 0)
41 p2 = geompy.MakeVertex(100, 0, 0)
42 p3 = geompy.MakeVertex(0, -100, 0)
43 p4 = geompy.MakeVertex(0, 70, 0)
44 p5 = geompy.MakeVertex(0, 100, 30)
45 p6 = geompy.MakeVertex(0, 130, 0)
48 circle = geompy.MakeCircleThreePnt(p1, p2, p3)
49 cf = geompy.MakeCircleThreePnt(p4, p5, p6)
52 wire = geompy.MakeWire([cf])
53 face = geompy.MakeFace(wire, 1)
55 # publish circular face and second circle
56 idcircle = geompy.addToStudy(circle, "Circle")
57 idface = geompy.addToStudy(face, "Circular face")
60 # init a Mesh with the circular face
61 mesh1 = smesh.Mesh(face, "Mesh on circular face")
63 # set hypotheses and algos to the first mesh
64 numberOfSegments1 = 12
65 algoReg1 = mesh1.Segment()
66 algoReg1.SetName("Regular_1D")
67 hypNbSeg1 = algoReg1.NumberOfSegments(numberOfSegments1)
68 smesh.SetName(hypNbSeg1, "NumberOfSegments_" + str(numberOfSegments1))
72 algoTri = mesh1.Triangle()
73 algoTri.SetName("Triangle")
74 hypArea = algoTri.MaxElementArea(maxElementArea)
75 smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
78 # init a Mesh with the second circle
79 mesh2 = smesh.Mesh(circle, "Mesh on circular edge")
81 numberOfSegments2 = 12
82 algoReg2 = mesh2.Segment()
83 algoReg2.SetName("Regular_1D")
84 hypNbSeg2 = algoReg2.NumberOfSegments(numberOfSegments2)
85 smesh.SetName(hypNbSeg2, "NumberOfSegments_" + str(numberOfSegments2))
89 isDone = mesh1.Compute()
91 raise Exception("Error when computing Mesh")
93 isDone = mesh2.Compute()
95 raise Exception("Error when computing Mesh")
97 # ---- update object browser
98 salome.sg.updateObjBrowser()