Salome HOME
Correction in BLSurf script: geometrical object must be published in study to be...
[modules/smesh.git] / doc / salome / gui / SMESH / input / tui_defining_blsurf_hypotheses.doc
1 /*!
2
3 \page tui_defining_blsurf_hypotheses_page Defining Hypotheses for BLSurf Algorithm
4
5 \anchor tui_blsurf
6 <h2>Construction of Mesh using BLSurf algorithm</h2>
7
8 \code
9 import geompy
10 import smesh
11 import BLSURFPlugin
12
13 # create a box
14 box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
15 geompy.addToStudy(box, "box")
16
17 # get subshapes
18 Face_1   = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0]
19 Edge_1   = geompy.SubShapeAllSorted(box, geompy.ShapeType["EDGE"])[0]
20 Vertex_1 = geompy.SubShapeAllSorted(box, geompy.ShapeType["VERTEX"])[0]
21
22 # /!\ Geom object with sizemaps on them must be published in study
23 geompy.addToStudyInFather(box,Face_1, "Face_1")
24 geompy.addToStudyInFather(box,Edge_1, "Edge_1")
25 geompy.addToStudyInFather(box,Vertex_1, "Vertex_1")
26
27 # create a mesh on the box
28 blsurfMesh = smesh.Mesh(box,"box: BLSurf mesh")
29
30 # create a BLSurf algorithm for faces
31 BLSURF = blsurfMesh.Triangle(algo=smesh.BLSURF)
32
33 # get BLSurf algorithm hypothesis
34 BLSURF_Parameters = BLSURF.Parameters()
35
36 # set physical mesh to 2 = Size Map
37 BLSURF_Parameters.SetPhysicalMesh( 2 )
38
39 # set global mesh size
40 BLSURF_Parameters.SetPhySize( 34.641 )
41
42 # set size on Face_1
43 BLSURF_Parameters.SetSizeMap(Face_1, 'def f(u,v): return 10' )
44 # set size on Edge_1
45 BLSURF_Parameters.SetSizeMap(Edge_1, 'def f(t): return 5' )
46 # set size on Vertex_1
47 BLSURF_Parameters.SetSizeMap(Vertex_1, 'def f(): return 2' )
48
49 # compute the mesh
50 blsurfMesh.Compute()
51
52 # Add enforced vertex for Face_1 on (50, 50, 50)
53 # The projection coordinates will be (50, 50, 0)
54 BLSURF_Parameters.SetEnforcedVertex(Face_1, 50, 50, 50)
55
56 # Add another enforced vertex on (150, 150, 150)
57 BLSURF_Parameters.SetEnforcedVertex(Face_1, 150, 150, 150)
58
59 # Retrieve and print the list of enforced vertices defines on Face_1
60 enfList = BLSURF_Parameters.GetEnforcedVertices(Face_1)
61 print "List of enforced vertices for Face_1: "
62 print enfList
63
64 # compute the mesh
65 blsurfMesh.Compute()
66
67 # Remove an enforced vertex and print the list
68 BLSURF_Parameters.UnsetEnforcedVertex(Face_1, 50, 50, 50)
69 enfList = BLSURF_Parameters.GetEnforcedVertices(Face_1)
70 print "List of enforced vertices for Face_1: "
71 print enfList
72
73 # compute the mesh
74 blsurfMesh.Compute()
75
76 # Remove all enforced vertices defined on Face_1
77 BLSURF_Parameters.UnsetEnforcedVertices(Face_1)
78
79 # compute the mesh
80 blsurfMesh.Compute()
81
82 # End of script
83
84 \endcode
85
86 */