1 # Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 from salome.geom import geomBuilder
24 geompy = geomBuilder.New(salome.myStudy)
26 import SMESH, SALOMEDS
27 from salome.smesh import smeshBuilder
28 smesh = smeshBuilder.New(salome.myStudy)
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' )
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)
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")
57 # Create the 2D algo: MG-CADSurf with geometrical mesh
58 Mesh_mghexa_sd1.Triangle(algo=smeshBuilder.MG_CADSurf).SetGeometricMesh( 1 )
60 # Create the 3D algo: MG-Hexa with:
64 Mesh_mghexa_sd1.Hexahedron(algo=smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 1 )
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 ))
75 Mesh_mghexa_sd1.Compute()