1 # Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # An enforced vertex can be added via:
21 # - the coordinates x,y,z
22 # - a GEOM vertex or compound (No geometry, TUI only)
24 # The created enforced nodes can also be stored in
27 # This feature is available only on meshes without geometry.
29 # Ex1: Add one enforced vertex with coordinates (50,50,100)
30 # and physical size 2.
35 from salome.geom import geomBuilder
36 geompy = geomBuilder.New(salome.myStudy)
39 from salome.smesh import smeshBuilder
40 smesh = smeshBuilder.New(salome.myStudy)
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)
52 # Make a copy of the 2D mesh
53 mgtetraMesh_wo_geometry = smesh.CopyMesh( mgtetraMesh, 'MG-Tetra w/o geometry', 0, 0)
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
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"
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 )
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
79 mgtetraMesh_wo_geometry.Compute()
81 # Erase all enforced vertices
82 MG_Tetra_Parameters.ClearEnforcedVertices()