Salome HOME
Copyright update 2022
[modules/smesh.git] / src / SMESH_SWIG / PAL_MESH_041_mesh.py
1 #  -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
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.
11 #
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.
16 #
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
20 #
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23
24 import salome
25 salome.salome_init()
26 import GEOM
27 from salome.geom import geomBuilder
28 geompy = geomBuilder.New()
29
30 import SMESH, SALOMEDS
31 from salome.smesh import smeshBuilder
32 smesh =  smeshBuilder.New()
33
34
35 #-----------------------------GEOM----------------------------------------
36
37 #----------Vertexes------------
38 p1 = geompy.MakeVertex(20.0,30.0,40.0)
39 p2 = geompy.MakeVertex(90.0,80.0,0.0)
40 p3 = geompy.MakeVertex(30.0,80.0,200.0)
41
42 #----------Edges---------------
43 e1 = geompy.MakeEdge(p1,p2)
44 e2 = geompy.MakeEdge(p2,p3)
45 e3 = geompy.MakeEdge(p3,p1)
46
47 #----------Wire----------------
48 ListOfEdges = []
49 ListOfEdges.append(e3)
50 ListOfEdges.append(e2)
51 ListOfEdges.append(e1)
52 wire1 = geompy.MakeWire(ListOfEdges)
53
54
55 #----------Face----------------
56 WantPlanarFace = 1
57 face1 = geompy.MakeFace(wire1,WantPlanarFace)
58
59 Id_face1 = geompy.addToStudy(face1,"Face1")
60
61
62
63 #-----------------------------SMESH-------------------------------------------
64
65 # -- Init mesh --
66 plane_mesh = salome.IDToObject( Id_face1)
67
68 mesh = smesh.Mesh(plane_mesh, "Mesh_1")
69
70 print("---------------------Hypothesis and Algorithms")
71
72 #---------------- NumberOfSegments
73
74 numberOfSegment = 9
75
76 algoWireDes = mesh.Segment()
77 listHyp = algoWireDes.GetCompatibleHypothesis()
78 print(algoWireDes.GetName())
79 algoWireDes.SetName("Ware descritisation")
80
81 hypNbSeg = algoWireDes.NumberOfSegments(numberOfSegment)
82 print(hypNbSeg.GetName())
83 print(hypNbSeg.GetNumberOfSegments())
84 smesh.SetName(hypNbSeg, "Nb. Segments")
85
86
87 #--------------------------Max. Element Area
88 maxElementArea = 200
89
90 algoMef = mesh.Triangle()
91 listHyp = algoMef.GetCompatibleHypothesis()
92 print(algoMef.GetName())
93 algoMef.SetName("Triangle (Mefisto)")
94
95 hypArea200 = algoMef.MaxElementArea(maxElementArea)
96 print(hypArea200.GetName())
97 print(hypArea200.GetMaxElementArea())
98 smesh.SetName(hypArea200, "Max. Element Area")
99
100
101 print("---------------------Compute the mesh")
102
103 ret = mesh.Compute()
104 print(ret)
105
106 salome.sg.updateObjBrowser()
107