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)
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' )
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)
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")
56 # Create the 2D algo: MG-CADSurf with geometrical mesh
57 Mesh_mghexa_sd3.Triangle(algo=smeshBuilder.MG_CADSurf).SetGeometricMesh( 1 )
59 # Create the 3D algo: MG-Hexa with:
63 Mesh_mghexa_sd3.Hexahedron(algo=smeshBuilder.MG_Hexa).SetMinMaxHexes(4, 8).SetHexoticSdMode( 3 )
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 ))
74 Mesh_mghexa_sd3.Compute()