Salome HOME
bos #29483 Merge branch 'eap/29483_gmsh_sub'
[plugins/gmshplugin.git] / tests / basicGroup.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2012-2015  ALNEOS
3 # Copyright (C) 2016-2022  EDF R&D
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.alneos.com/ or email : contact@alneos.fr
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #
22
23 ###
24 ### This file is generated automatically by SALOME v8.5.0 with dump python functionality
25 ###
26
27 import sys
28 import salome
29
30 salome.salome_init()
31
32 ###
33 ### GEOM component
34 ###
35
36 import GEOM
37 from salome.geom import geomBuilder
38 import math
39 import SALOMEDS
40
41
42 geompy = geomBuilder.New()
43
44 O = geompy.MakeVertex(0, 0, 0)
45 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
46 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
47 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
48 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
49 Cylinder_1 = geompy.MakeCylinderRH(100, 300)
50 Sphere_1 = geompy.MakeSphereR(100)
51 Fuse_1 = geompy.MakeFuseList([Box_1, Cylinder_1, Sphere_1], True, True)
52 Group_1 = geompy.CreateGroup(Fuse_1, geompy.ShapeType["FACE"])
53 geompy.UnionIDs(Group_1, [46, 37])
54 geompy.addToStudy( O, 'O' )
55 geompy.addToStudy( OX, 'OX' )
56 geompy.addToStudy( OY, 'OY' )
57 geompy.addToStudy( OZ, 'OZ' )
58 geompy.addToStudy( Box_1, 'Box_1' )
59 geompy.addToStudy( Cylinder_1, 'Cylinder_1' )
60 geompy.addToStudy( Sphere_1, 'Sphere_1' )
61 geompy.addToStudy( Fuse_1, 'Fuse_1' )
62 geompy.addToStudyInFather( Fuse_1, Group_1, 'Group_1' )
63
64 ###
65 ### SMESH component
66 ###
67
68 import  SMESH, SALOMEDS
69 from salome.smesh import smeshBuilder
70
71 smesh = smeshBuilder.New()
72 Mesh_1 = smesh.Mesh(Fuse_1)
73 GMSH = Mesh_1.Tetrahedron(algo=smeshBuilder.GMSH)
74 Gmsh_Parameters = GMSH.Parameters()
75 Gmsh_Parameters.Set2DAlgo( 0 )
76 Gmsh_Parameters.SetMinSize( 1 )
77 Gmsh_Parameters.SetMaxSize( 20 )
78 Gmsh_Parameters.SetIs2d( 0 )
79 Gmsh_Parameters.SetCompoundOnShape(Group_1)
80 isDone = Mesh_1.Compute()
81
82
83 ## Set names of Mesh objects
84 smesh.SetName(GMSH.GetAlgorithm(), 'GMSH')
85 smesh.SetName(Gmsh_Parameters, 'Gmsh Parameters')
86 smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
87
88
89 if salome.sg.hasDesktop():
90   salome.sg.updateObjBrowser()