2013-05-28 22:39:28 +06:00
|
|
|
# Duplicate nodes or/and elements
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
|
2013-02-12 20:37:44 +06:00
|
|
|
import salome
|
2013-04-04 13:08:19 +06:00
|
|
|
salome.salome_init()
|
2013-05-28 22:39:28 +06:00
|
|
|
|
2013-04-04 13:08:19 +06:00
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
|
|
|
geompy = geomBuilder.New(salome.myStudy)
|
|
|
|
|
2013-05-28 22:39:28 +06:00
|
|
|
import SMESH
|
2013-04-04 13:08:19 +06:00
|
|
|
from salome.smesh import smeshBuilder
|
|
|
|
smesh = smeshBuilder.New(salome.myStudy)
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2013-02-28 21:07:35 +06:00
|
|
|
# Create a box
|
|
|
|
|
|
|
|
box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
|
|
|
|
|
|
|
|
# Define hexa mesh on a box
|
|
|
|
mesh = smesh.Mesh(box, "Mesh")
|
|
|
|
mesh.Segment().NumberOfSegments(7)
|
|
|
|
mesh.Quadrangle()
|
|
|
|
mesh.Hexahedron()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Compute mesh
|
|
|
|
mesh.Compute()
|
|
|
|
|
2013-05-28 22:39:28 +06:00
|
|
|
# Duplicate nodes only
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Nodes to duplicate
|
2013-04-04 13:08:19 +06:00
|
|
|
nodes1 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes1' )
|
2013-02-28 21:07:35 +06:00
|
|
|
nodes1.Add( [ 119, 125, 131, 137 ] )
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Group of faces to replace nodes with new ones
|
2013-04-04 13:08:19 +06:00
|
|
|
faces1 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces1' )
|
2013-02-28 21:07:35 +06:00
|
|
|
faces1.Add( [ 144, 151, 158 ] )
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Duplicate nodes
|
|
|
|
print "\nMesh before the first nodes duplication:"
|
2013-02-28 21:07:35 +06:00
|
|
|
print "Nodes : ", mesh.NbNodes()
|
|
|
|
print "Edges : ", mesh.NbEdges()
|
|
|
|
print "Quadrangles : ", mesh.NbQuadrangles()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
groupOfCreatedNodes = mesh.DoubleNodeGroup(nodes1, faces1, theMakeGroup=True)
|
|
|
|
print "New nodes:", groupOfCreatedNodes.GetIDs()
|
|
|
|
|
|
|
|
print "\nMesh after the first nodes duplication:"
|
2013-02-28 21:07:35 +06:00
|
|
|
print "Nodes : ", mesh.NbNodes()
|
|
|
|
print "Edges : ", mesh.NbEdges()
|
|
|
|
print "Quadrangles : ", mesh.NbQuadrangles()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2013-05-28 22:39:28 +06:00
|
|
|
# Duplicate nodes and border elements
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Edges to duplicate
|
2013-04-04 13:08:19 +06:00
|
|
|
edges = mesh.CreateEmptyGroup( SMESH.EDGE, 'edges' )
|
2013-02-28 21:07:35 +06:00
|
|
|
edges.Add( [ 32, 33, 34 ] )
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Nodes not to duplicate
|
2013-04-04 13:08:19 +06:00
|
|
|
nodes2 = mesh.CreateEmptyGroup( SMESH.NODE, 'nodes2' )
|
2013-02-28 21:07:35 +06:00
|
|
|
nodes2.Add( [ 35, 38 ] )
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Group of faces to replace nodes with new ones
|
2013-04-04 13:08:19 +06:00
|
|
|
faces2 = mesh.CreateEmptyGroup( SMESH.FACE, 'faces2' )
|
2013-02-28 21:07:35 +06:00
|
|
|
faces2.Add( [ 141, 148, 155 ] )
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
# Duplicate nodes
|
|
|
|
print "\nMesh before the second nodes duplication:"
|
2013-02-28 21:07:35 +06:00
|
|
|
print "Nodes : ", mesh.NbNodes()
|
|
|
|
print "Edges : ", mesh.NbEdges()
|
|
|
|
print "Quadrangles : ", mesh.NbQuadrangles()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
|
|
|
groupOfNewEdges = mesh.DoubleNodeElemGroup( edges, nodes2, faces2, theMakeGroup=True )
|
|
|
|
print "New edges:", groupOfNewEdges.GetIDs()
|
|
|
|
|
|
|
|
print "\nMesh after the second nodes duplication:"
|
2013-02-28 21:07:35 +06:00
|
|
|
print "Nodes : ", mesh.NbNodes()
|
|
|
|
print "Edges : ", mesh.NbEdges()
|
|
|
|
print "Quadrangles : ", mesh.NbQuadrangles()
|
2013-02-12 20:37:44 +06:00
|
|
|
|
2013-05-28 22:39:28 +06:00
|
|
|
|
|
|
|
# Duplicate elements only
|
|
|
|
|
|
|
|
# Duplicate all faces and make a group of new faces.
|
|
|
|
# If a mesh is given to DoubleElements(), all elements of the greatest dimension are duplicated
|
|
|
|
newFacesGroup = mesh.DoubleElements( mesh, "newFacesGroup" )
|
|
|
|
|
|
|
|
# Duplicate edges contained in the group "edges" and add new edges to this group
|
|
|
|
mesh.DoubleElements( edges, edges.GetName() )
|
|
|
|
|
|
|
|
# Duplicate two first edges of the mesh
|
|
|
|
mesh.DoubleElements([ 1, 2 ])
|
|
|
|
|
2013-02-12 20:37:44 +06:00
|
|
|
# Update object browser
|
|
|
|
if salome.sg.hasDesktop():
|
|
|
|
salome.sg.updateObjBrowser(0)
|