1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2024 CEA, EDF, 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_testExtrusion2D.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 #----------------------------------GEOM
42 p1 = geompy.MakeVertex(100, 0, 0)
43 p2 = geompy.MakeVertex(100, 0, 100)
44 p3 = geompy.MakeVertex(0, 0, 0)
45 p4 = geompy.MakeVertex(0, 100, 0)
49 vector1 = geompy.MakeVector(p1,p2)
50 vector2 = geompy.MakeVector(p3,p4)
53 ellipse1 = geompy.MakeEllipse(p1,vector1,50,25)
54 ellipse2 = geompy.MakeEllipse(p3,vector2,300,50)
56 # publish circular face and second circle
57 id_ellipse1 = geompy.addToStudy(ellipse1, "Ellips 1")
58 id_ellipse2 = geompy.addToStudy(ellipse2, "Ellips 2")
61 #---------------------------------SMESH
63 # create the path mesh
64 mesh1 = smesh.Mesh(ellipse1, "Path Mesh")
66 algoReg1 = mesh1.Segment()
67 algoReg1.SetName("Regular_1D")
68 hypNbSeg1 = algoReg1.NumberOfSegments(18)
69 smesh.SetName(hypNbSeg1, "NumberOfSegments 1")
71 # create the tool mesh
72 mesh2 = smesh.Mesh(ellipse2, "Tool Mesh")
73 algoReg2 = mesh2.Segment()
74 algoReg2.SetName("Regular_1D")
75 hypNbSeg2 = algoReg2.NumberOfSegments(34)
76 smesh.SetName(hypNbSeg2, "NumberOfSegments 2")
79 isDone = mesh1.Compute()
81 raise Exception("Error when computing Mesh")
83 isDone = mesh2.Compute()
85 raise Exception("Error when computing Mesh")
88 # ---- udate object browser
89 salome.sg.updateObjBrowser()