Salome HOME
20140612_1537 clone to HYBRIDPLUGIN Modify files contents [('GHS3DPLUGIN', 'HYBRIDPLU...
[plugins/hybridplugin.git] / doc / salome / examples / hybrid_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 hybridMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh")
29 # create a BLSurf algorithm for faces
30 hybridMesh.Triangle(algo=smeshBuilder.BLSURF)
31 # compute the mesh
32 hybridMesh.Compute()
33
34 # Make a copy of the 2D mesh
35 hybridMesh_wo_geometry = smesh.CopyMesh( hybridMesh, 'Ghs3D wo geometry', 0, 0)
36
37 # create a Ghs3D algorithm and hypothesis and assign them to the mesh
38 HYBRID = smesh.CreateHypothesis('HYBRID_3D', 'HYBRIDEngine')
39 HYBRID_Parameters = smesh.CreateHypothesis('HYBRID_Parameters', 'HYBRIDEngine')
40 hybridMesh.AddHypothesis( HYBRID )
41 hybridMesh.AddHypothesis( HYBRID_Parameters )
42 # Create the enforced vertex
43 HYBRID_Parameters.SetEnforcedVertex( 50, 50, 100, 2) # no group
44 # Compute the mesh
45 hybridMesh.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 HYBRID hypothesis and assign it to the mesh without geometry
52 HYBRID_Parameters_wo_geometry = smesh.CreateHypothesis('HYBRID_Parameters', 'HYBRIDEngine')
53 hybridMesh_wo_geometry.AddHypothesis( HYBRID )
54 hybridMesh_wo_geometry.AddHypothesis( HYBRID_Parameters_wo_geometry )
55
56 # Create the enforced vertex
57 p1 = geompy.MakeVertex(150, 150, 100)
58 geompy.addToStudy(p1, "p1")
59 HYBRID_Parameters_wo_geometry.SetEnforcedVertexGeomWithGroup( p1, 5 , "My special nodes")
60 #HYBRID_Parameters.SetEnforcedVertexGeom( p1, 5 ) # no group
61
62 # compute the mesh
63 hybridMesh_wo_geometry.Compute()
64
65 # Erase all enforced vertices
66 HYBRID_Parameters.ClearEnforcedVertices()
67
68 # End of script