1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2024 CEA, EDF
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
31 from salome.geom import geomBuilder
36 geompy = geomBuilder.New()
39 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
41 # Create a sphere near the sides of the box
42 sphere_tmp = geompy.MakeSphereR(5)
43 sphere = geompy.MakeTranslation(sphere_tmp, 6, 6, 50)
45 part = geompy.MakePartition([box, sphere])
46 geompy.addToStudy( box, 'box' )
47 geompy.addToStudy( sphere, 'sphere' )
48 geompy.addToStudy( part, 'part' )
50 # Create the groups of faces
51 box_faces = geompy.GetShapesOnBox(box, part, geompy.ShapeType["FACE"], GEOM.ST_ON)
52 gr_box_faces = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
53 geompy.UnionList(gr_box_faces, box_faces)
54 geompy.addToStudyInFather(part, gr_box_faces, "box_faces")
56 all_faces = geompy.SubShapeAll(part, geompy.ShapeType["FACE"])
57 gr_all_faces = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
58 geompy.UnionList(gr_all_faces, all_faces)
60 gr_spheres_faces = geompy.CutGroups(gr_all_faces, gr_box_faces)
61 geompy.addToStudyInFather(part, gr_spheres_faces, "spheres_faces")
67 import SMESH, SALOMEDS
68 from salome.smesh import smeshBuilder
70 smesh = smeshBuilder.New()
71 Mesh_1 = smesh.Mesh(part, "Mesh_part")
72 BLSURF = Mesh_1.Triangle(algo=smeshBuilder.BLSURF)
73 BLSURF_Parameters_1 = BLSURF.Parameters()
74 BLSURF_Parameters_1.SetGradation( 1.2 )
75 BLSURF_Parameters_1.SetGeometricMesh( 1 )
76 BLSURF_Parameters_1.SetPhySize( 20 )
77 #BLSURF_Parameters_1.SetMinSize( 0.1 )
78 BLSURF_Parameters_1.SetMaxSize( 20 )
79 BLSURF_Parameters_1.SetAngleMesh( 8 )
81 # Old way to set proximity (Mesh Gems 1.1)
82 #BLSURF_Parameters_1.SetOptionValue( 'proximity', '1' )
83 #BLSURF_Parameters_1.SetOptionValue( 'prox_ratio', '1.2' )
84 #BLSURF_Parameters_1.SetOptionValue( 'prox_nb_layer', '3' )
86 # New way to set proximity (Mesh Gems >= 1.3)
87 BLSURF_Parameters_1.SetOptionValue( "volume_gradation", "1.2" )
89 isDone = Mesh_1.Compute()
91 raise Exception("Compute mesh ended in error")
93 # Create the groups on the mesh
94 gr_mesh_box = Mesh_1.Group(gr_box_faces)
95 gr_mesh_spheres = Mesh_1.Group(gr_spheres_faces)
97 # Check the minimal area of the box faces to check the proximity
98 min_area, max_area = Mesh_1.GetMinMax(SMESH.FT_Area, gr_mesh_box)
100 print("min_area: ", min_area)
103 raise Exception("Wrong minimal area on box. Proximity has not worked.")
105 if salome.sg.hasDesktop():
106 salome.sg.updateObjBrowser()