1 # -*- coding: utf-8 -*-
13 from salome.geom import geomBuilder
18 geompy = geomBuilder.New()
21 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
23 # Create a sphere near the sides of the box
24 sphere_tmp = geompy.MakeSphereR(5)
25 sphere = geompy.MakeTranslation(sphere_tmp, 6, 6, 50)
27 part = geompy.MakePartition([box, sphere])
28 geompy.addToStudy( box, 'box' )
29 geompy.addToStudy( sphere, 'sphere' )
30 geompy.addToStudy( part, 'part' )
32 # Create the groups of faces
33 box_faces = geompy.GetShapesOnBox(box, part, geompy.ShapeType["FACE"], GEOM.ST_ON)
34 gr_box_faces = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
35 geompy.UnionList(gr_box_faces, box_faces)
36 geompy.addToStudyInFather(part, gr_box_faces, "box_faces")
38 all_faces = geompy.SubShapeAll(part, geompy.ShapeType["FACE"])
39 gr_all_faces = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
40 geompy.UnionList(gr_all_faces, all_faces)
42 gr_spheres_faces = geompy.CutGroups(gr_all_faces, gr_box_faces)
43 geompy.addToStudyInFather(part, gr_spheres_faces, "spheres_faces")
49 import SMESH, SALOMEDS
50 from salome.smesh import smeshBuilder
52 smesh = smeshBuilder.New()
53 Mesh_1 = smesh.Mesh(part, "Mesh_part")
54 BLSURF = Mesh_1.Triangle(algo=smeshBuilder.BLSURF)
55 BLSURF_Parameters_1 = BLSURF.Parameters()
56 BLSURF_Parameters_1.SetGradation( 1.2 )
57 BLSURF_Parameters_1.SetGeometricMesh( 1 )
58 BLSURF_Parameters_1.SetPhySize( 20 )
59 #BLSURF_Parameters_1.SetMinSize( 0.1 )
60 BLSURF_Parameters_1.SetMaxSize( 20 )
61 BLSURF_Parameters_1.SetAngleMesh( 8 )
63 # Old way to set proximity (Mesh Gems 1.1)
64 #BLSURF_Parameters_1.SetOptionValue( 'proximity', '1' )
65 #BLSURF_Parameters_1.SetOptionValue( 'prox_ratio', '1.2' )
66 #BLSURF_Parameters_1.SetOptionValue( 'prox_nb_layer', '3' )
68 # New way to set proximity (Mesh Gems >= 1.3)
69 BLSURF_Parameters_1.SetOptionValue( "volume_gradation", "1.2" )
71 isDone = Mesh_1.Compute()
73 raise Exception("Compute mesh ended in error")
75 # Create the groups on the mesh
76 gr_mesh_box = Mesh_1.Group(gr_box_faces)
77 gr_mesh_spheres = Mesh_1.Group(gr_spheres_faces)
79 # Check the minimal area of the box faces to check the proximity
80 min_area, max_area = Mesh_1.GetMinMax(SMESH.FT_Area, gr_mesh_box)
82 print "min_area: ", min_area
85 raise Exception("Wrong minimal area on box. Proximity has not worked.")
87 if salome.sg.hasDesktop():
88 salome.sg.updateObjBrowser()