Salome HOME
ae1a151f67c49ce012f3c104154b7091c3d111ff
[plugins/hexoticplugin.git] / doc / salome / examples / hexoticsubdom3.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 # Create geometry: a box cut by a holed sphere
31 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
32 Sphere_1 = geompy.MakeSphereR(75)
33 Sphere_2 = geompy.MakeSphereR(25)
34 geompy.TranslateDXDYDZ(Box_1, -100, -100, -100)
35 Cut_1 = geompy.MakeCut(Sphere_1, Sphere_2)
36 Cut_2 = geompy.MakeCut(Box_1, Cut_1)
37 geompy.addToStudy( Box_1, 'Box_1' )
38 geompy.addToStudy( Sphere_1, 'Sphere_1' )
39 geompy.addToStudy( Sphere_2, 'Sphere_2' )
40 geompy.addToStudy( Cut_1, 'Cut_1' )
41 geompy.addToStudy( Cut_2, 'Cut_2' )
42
43 # Create filters
44 # aFilter1: elements inside small sphere
45 aFilter1 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2)
46 # aFilter2: elements inside big sphere and not inside small sphere
47 aFilter2 = smesh.GetFilterFromCriteria([smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalAND),
48                                         smesh.GetCriterion(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_2, SMESH.FT_LogicalNOT)])
49 # aFilter3: elements not inside big sphere
50 aFilter3 = smesh.GetFilter(SMESH.VOLUME,SMESH.FT_BelongToGeom,'=',Sphere_1, SMESH.FT_LogicalNOT)
51
52 # Create mesh of Cut_2 with sd mode 3
53 print("Create mesh of Cut_2 with sd mode 3")
54 Mesh_mghexa_sd3 = smesh.Mesh(Cut_2, "Mesh_mghexa_sd3")
55
56 # Create the 2D algo: MG-CADSurf with geometrical mesh
57 Mesh_mghexa_sd3.Triangle(algo=smeshBuilder.MG_CADSurf).SetGeometricMesh( 1 )
58
59 # Create the 3D algo: MG-Hexa with:
60 # - minl = 4
61 # - maxl = 8
62 # - sd = 3
63 Mesh_mghexa_sd3.Hexahedron(algo=smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 3 )
64
65 # Create the groups on filters
66 g1 = Mesh_mghexa_sd3.GroupOnFilter(SMESH.VOLUME, 'small sphere', aFilter1 )
67 g1.SetColor( SALOMEDS.Color( 1, 0, 0 ))
68 g2 = Mesh_mghexa_sd3.GroupOnFilter(SMESH.VOLUME, 'big sphere - small sphere', aFilter2 )
69 g2.SetColor( SALOMEDS.Color( 0, 1, 0 ))
70 g3 = Mesh_mghexa_sd3.GroupOnFilter(SMESH.VOLUME, 'box - big sphere', aFilter3 )
71 g3.SetColor( SALOMEDS.Color( 0, 0, 1 ))
72
73 # Compute
74 Mesh_mghexa_sd3.Compute()
75
76 # End of script
77