Salome HOME
Deleted Study parameter
[plugins/hexoticplugin.git] / doc / salome / examples / hexoticsubdom1.py
1 # Copyright (C) 2013-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 import salome
21 salome.salome_init()
22
23 from salome.geom import geomBuilder
24 geompy = geomBuilder.New()
25
26 import SMESH, SALOMEDS
27 from salome.smesh import smeshBuilder
28 smesh =  smeshBuilder.New()
29
30
31 # Create geometry: a box cut by a holed sphere
32 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
33 Sphere_1 = geompy.MakeSphereR(75)
34 Sphere_2 = geompy.MakeSphereR(25)
35 geompy.TranslateDXDYDZ(Box_1, -100, -100, -100)
36 Cut_1 = geompy.MakeCut(Sphere_1, Sphere_2)
37 Cut_2 = geompy.MakeCut(Box_1, Cut_1)
38 geompy.addToStudy( Box_1, 'Box_1' )
39 geompy.addToStudy( Sphere_1, 'Sphere_1' )
40 geompy.addToStudy( Sphere_2, 'Sphere_2' )
41 geompy.addToStudy( Cut_1, 'Cut_1' )
42 geompy.addToStudy( Cut_2, 'Cut_2' )
43
44 # Create filters
45 # aFilter1: elements inside small sphere
46 aFilter1 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2)
47 # aFilter2: elements inside big sphere and not inside small sphere
48 aFilter2 = smesh.GetFilterFromCriteria([smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalAND),
49                                         smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2, SMESH.FT_LogicalNOT)])
50 # aFilter3: elements not inside big sphere
51 aFilter3 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalNOT)
52
53 # Create mesh of Cut_2 with sd mode 1
54 print "Create mesh of Cut_2 with sd mode 1"
55 Mesh_mghexa_sd1 = smesh.Mesh(Cut_2, "Mesh_mghexa_sd1")
56
57 # Create the 2D algo: MG-CADSurf with geometrical mesh
58 Mesh_mghexa_sd1.Triangle(algo=smeshBuilder.MG_CADSurf).SetGeometricMesh( 1 )
59
60 # Create the 3D algo: MG-Hexa with:
61 # - minl = 4
62 # - maxl = 8
63 # - sd = 1
64 Mesh_mghexa_sd1.Hexahedron(algo=smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 1 )
65
66 # Create the groups on filters
67 g1 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'small sphere', aFilter1 )
68 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
69 g2 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'big sphere - small sphere', aFilter2 )
70 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
71 g3 = Mesh_mghexa_sd1.GroupOnFilter(SMESH.VOLUME, 'box - big sphere', aFilter3 )
72 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
73
74 # Compute
75 Mesh_mghexa_sd1.Compute()
76
77 # End of script