Salome HOME
Merge from BR_plugins_pbyacs 03/04/2013
[plugins/ghs3dplugin.git] / doc / salome / examples / ghs3d_enfvert.py
1
2 # An enforced vertex can be added via:
3 # - the coordinates x,y,z
4 # - a GEOM vertex or compound (No geometry, TUI only)
5 #
6 # The created enforced nodes can also be stored in
7 # a group.
8 #
9 # This feature is available only on meshes without geometry.
10
11 # Ex1: Add one enforced vertex with coordinates (50,50,100) 
12 #      and physical size 2.
13
14 import salome
15 salome.salome_init()
16 import GEOM
17 from salome.geom import geomBuilder
18 geompy = geomBuilder.New(salome.myStudy)
19
20 import SMESH, SALOMEDS
21 from salome.smesh import smeshBuilder
22 smesh =  smeshBuilder.New(salome.myStudy)
23
24 # create a box
25 box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
26 geompy.addToStudy(box, "box")
27 # create a mesh on the box
28 ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh")
29 # create a BLSurf algorithm for faces
30 ghs3dMesh.Triangle(algo=smeshBuilder.BLSURF)
31 # compute the mesh
32 ghs3dMesh.Compute()
33
34 # Make a copy of the 2D mesh
35 ghs3dMesh_wo_geometry = smesh.CopyMesh( ghs3dMesh, 'Ghs3D wo geometry', 0, 0)
36
37 # create a Ghs3D algorithm and hypothesis and assign them to the mesh
38 GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine')
39 GHS3D_Parameters = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
40 ghs3dMesh.AddHypothesis( GHS3D )
41 ghs3dMesh.AddHypothesis( GHS3D_Parameters )
42 # Create the enforced vertex
43 GHS3D_Parameters.SetEnforcedVertex( 50, 50, 100, 2) # no group
44 # Compute the mesh
45 ghs3dMesh.Compute()
46
47
48 # Ex2: Add one vertex enforced by a GEOM vertex at (50,50,100) 
49 #      with physical size 5 and add it to a group called "My special nodes"
50
51 # Create another GHS3D hypothesis and assign it to the mesh without geometry
52 GHS3D_Parameters_wo_geometry = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
53 ghs3dMesh_wo_geometry.AddHypothesis( GHS3D )
54 ghs3dMesh_wo_geometry.AddHypothesis( GHS3D_Parameters_wo_geometry )
55
56 # Create the enforced vertex
57 p1 = geompy.MakeVertex(150, 150, 100)
58 geompy.addToStudy(p1, "p1")
59 GHS3D_Parameters_wo_geometry.SetEnforcedVertexGeomWithGroup( p1, 5 , "My special nodes")
60 #GHS3D_Parameters.SetEnforcedVertexGeom( p1, 5 ) # no group
61
62 # compute the mesh
63 ghs3dMesh_wo_geometry.Compute()
64
65 # Erase all enforced vertices
66 GHS3D_Parameters.ClearEnforcedVertices()
67
68 # End of script