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