Salome HOME
f8ba666a44ba9fb5f5d698f354dd6e3ed421bb14
[plugins/ghs3dplugin.git] / doc / salome / examples / ghs3d_enfvert.py
1 # Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # An enforced vertex can be added via:
21 # - the coordinates x,y,z
22 # - a GEOM vertex or compound (No geometry, TUI only)
23 #
24 # The created enforced nodes can also be stored in
25 # a group.
26 #
27 # This feature is available only on meshes without geometry.
28
29 # Ex1: Add one enforced vertex with coordinates (50,50,100) 
30 #      and physical size 2.
31
32 import salome
33 salome.salome_init()
34
35 from salome.geom import geomBuilder
36 geompy = geomBuilder.New(salome.myStudy)
37
38 import SMESH
39 from salome.smesh import smeshBuilder
40 smesh =  smeshBuilder.New(salome.myStudy)
41
42 # create a box
43 box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
44 geompy.addToStudy(box, "box")
45 # create a mesh on the box
46 mgtetraMesh = smesh.Mesh(box,"box: MG-Tetra and MG-CADSurf mesh")
47 # create a MG-CADSurf algorithm for faces
48 mgtetraMesh.Triangle(algo=smeshBuilder.MG_CADSurf)
49 # compute the mesh
50 mgtetraMesh.Compute()
51
52 # Make a copy of the 2D mesh
53 mgtetraMesh_wo_geometry = smesh.CopyMesh( mgtetraMesh, 'MG-Tetra w/o geometry', 0, 0)
54
55 # create a MG_Tetra algorithm and hypothesis and assign them to the mesh
56 MG_Tetra = mgtetraMesh.Tetrahedron( smeshBuilder.MG_Tetra )
57 MG_Tetra_Parameters = MG_Tetra.Parameters()
58 # Create the enforced vertex
59 MG_Tetra_Parameters.SetEnforcedVertex( 50, 50, 100, 2) # no group
60 # Compute the mesh
61 mgtetraMesh.Compute()
62
63
64 # Ex2: Add one vertex enforced by a GEOM vertex at (50,50,100) 
65 #      with physical size 5 and add it to a group called "My special nodes"
66
67 # Create another MG_Tetra hypothesis and assign it to the mesh without geometry
68 MG_Tetra_Parameters_wo_geometry = smesh.CreateHypothesis('MG-Tetra Parameters', 'GHS3DEngine')
69 mgtetraMesh_wo_geometry.AddHypothesis( MG_Tetra )
70 mgtetraMesh_wo_geometry.AddHypothesis( MG_Tetra_Parameters_wo_geometry )
71
72 # Create the enforced vertex
73 p1 = geompy.MakeVertex(150, 150, 100)
74 geompy.addToStudy(p1, "p1")
75 MG_Tetra_Parameters_wo_geometry.SetEnforcedVertexGeomWithGroup( p1, 5 , "My special nodes")
76 #MG_Tetra_Parameters.SetEnforcedVertexGeom( p1, 5 ) # no group
77
78 # compute the mesh
79 mgtetraMesh_wo_geometry.Compute()
80
81 # Erase all enforced vertices
82 MG_Tetra_Parameters.ClearEnforcedVertices()
83
84 # End of script