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)
38 import SMESH, SALOMEDS
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 ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh")
47 # create a BLSurf algorithm for faces
48 ghs3dMesh.Triangle(algo=smeshBuilder.BLSURF)
52 # Make a copy of the 2D mesh
53 ghs3dMesh_wo_geometry = smesh.CopyMesh( ghs3dMesh, 'Ghs3D wo geometry', 0, 0)
55 # create a Ghs3D algorithm and hypothesis and assign them to the mesh
56 GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine')
57 GHS3D_Parameters = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
58 ghs3dMesh.AddHypothesis( GHS3D )
59 ghs3dMesh.AddHypothesis( GHS3D_Parameters )
60 # Create the enforced vertex
61 GHS3D_Parameters.SetEnforcedVertex( 50, 50, 100, 2) # no group
66 # Ex2: Add one vertex enforced by a GEOM vertex at (50,50,100)
67 # with physical size 5 and add it to a group called "My special nodes"
69 # Create another GHS3D hypothesis and assign it to the mesh without geometry
70 GHS3D_Parameters_wo_geometry = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine')
71 ghs3dMesh_wo_geometry.AddHypothesis( GHS3D )
72 ghs3dMesh_wo_geometry.AddHypothesis( GHS3D_Parameters_wo_geometry )
74 # Create the enforced vertex
75 p1 = geompy.MakeVertex(150, 150, 100)
76 geompy.addToStudy(p1, "p1")
77 GHS3D_Parameters_wo_geometry.SetEnforcedVertexGeomWithGroup( p1, 5 , "My special nodes")
78 #GHS3D_Parameters.SetEnforcedVertexGeom( p1, 5 ) # no group
81 ghs3dMesh_wo_geometry.Compute()
83 # Erase all enforced vertices
84 GHS3D_Parameters.ClearEnforcedVertices()