6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New()
10 from salome.smesh import smeshBuilder
11 smesh = smeshBuilder.New()
13 # create a face to be meshed
14 px = geompy.MakeVertex(100., 0. , 0. )
15 py = geompy.MakeVertex(0. , 100., 0. )
16 pz = geompy.MakeVertex(0. , 0. , 100.)
18 vxy = geompy.MakeVector(px, py)
19 arc = geompy.MakeArc(py, pz, px)
21 wire = geompy.MakeWire([vxy, arc])
24 face1 = geompy.MakeFace(wire, isPlanarFace)
25 id_face1 = geompy.addToStudy(face1, "Face1")
27 # create a circle to be an extrusion path
28 px1 = geompy.MakeVertex( 100., 100., 0.)
29 py1 = geompy.MakeVertex(-100., -100., 0.)
30 pz1 = geompy.MakeVertex( 0., 0., 50.)
32 circle = geompy.MakeCircleThreePnt(py1, pz1, px1)
33 id_circle = geompy.addToStudy(circle, "Path")
35 # create a 2D mesh on the face
36 trias = smesh.Mesh(face1, "Face : 2D mesh")
38 algo1D = trias.Segment()
39 algo1D.NumberOfSegments(6)
40 algo2D = trias.Triangle()
41 algo2D.LengthFromEdges()
45 # create a group of all triangles currently present in the mesh
46 faceTriGroup = trias.Group( face1, "face triangles" )
49 circlemesh = smesh.Mesh(circle, "Path mesh")
50 algo = circlemesh.Segment()
51 algo.NumberOfSegments(10)
54 # extrusion of the mesh
55 trias.ExtrusionAlongPath([], circlemesh, circle, 1, MakeGroups=True )
57 # get a group "opposite" to faceTriGroup within the generated prismatic mesh
58 oppositeGroup = trias.GetGroupByName( faceTriGroup.GetName() + "_top" )[0]
60 # get edges of the groups
61 edgeGroup = trias.CreateDimGroup([ faceTriGroup, oppositeGroup ], SMESH.EDGE, "face edges")
63 # merge nodes of the groups only
64 print("Number of nodes before MergeNodes:", end=' ')
67 array_of_nodes_groups = trias.FindCoincidentNodesOnPart([faceTriGroup, oppositeGroup], tolerance)
69 trias.MergeNodes(array_of_nodes_groups)
71 print("Number of nodes after MergeNodes:", trias.NbNodes())
73 print("Number of elements before MergeEqualElements:")
74 print("Edges : ", trias.NbEdges())
75 print("Faces : ", trias.NbFaces())
76 print("Volumes : ", trias.NbVolumes())
78 # merge elements of the groups
79 equalFaces = trias.FindEqualElements( [faceTriGroup, oppositeGroup, edgeGroup] )
80 trias.MergeElements( equalFaces )
81 print("Number of elements after MergeEqualElements:")
82 print("Edges : ", trias.NbEdges())
83 print("Faces : ", trias.NbFaces())
84 print("Volumes : ", trias.NbVolumes())
86 salome.sg.updateObjBrowser()