3 # There is a series of Extrusion Along Line methods added at different times;
4 # a fully functional method is ExtrusionSweepObjects()
9 salome.salome_init_without_session()
12 from salome.smesh import smeshBuilder
14 smesh_builder = smeshBuilder.New()
16 # create an empty mesh
17 mesh = smesh_builder.Mesh()
20 mesh.AddNode( 0.,0.,0. )
22 # extrude a node into a line of 10 segments along the X axis
23 ids = mesh.GetNodesId()
24 stepVector = [1.,0.,0.]
26 mesh.ExtrusionSweep( ids, stepVector, nbSteps, IsNodes=True )
29 lastNode = mesh.GetNodesId()[-1]
30 lastNodeGroup = mesh.MakeGroupByIds( "node %s"% lastNode, SMESH.NODE, [lastNode])
31 lineGroup = mesh.MakeGroupByIds( "line", SMESH.EDGE, mesh.GetElementsId() )
33 # rotate the segments around the first node to get a mesh of a disk quarter
34 axisZ = [0.,0.,0., 0.,0.,1.]
35 groups = mesh.RotationSweepObject( lineGroup, axisZ, math.pi/2., 10, 1e-3, MakeGroups=True, TotalAngle=True )
37 # extrude all faces into volumes
39 stepVector = [0.,0.,-1.]
41 groups = mesh.ExtrusionSweepObject2D( obj, stepVector, nbSteps, MakeGroups=True )
43 # remove all segments created by the last command
45 if g.GetType() == SMESH.EDGE:
46 mesh.RemoveGroupWithContents( g )
48 # extrude all segments into faces along Z
50 stepVector = [0.,0.,1.]
51 mesh.ExtrusionSweepObject1D( obj, stepVector, nbSteps )
54 obj = mesh.GetGroupByName( "line_extruded", SMESH.FACE )[0]
55 stepVector = [0,-5.,0.]
57 mesh.ExtrusionSweepObject( obj, stepVector, nbSteps )
59 # extrude all nodes and triangle faces of the disk quarter, applying a scale factor
60 diskGroup = mesh.GetGroupByName( "line_rotated", SMESH.FACE )[0]
61 crit = [ smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_TRIANGLE ),
62 smesh_builder.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=', diskGroup )]
63 trianglesFilter = smesh_builder.GetFilterFromCriteria( crit )
67 faces = [ trianglesFilter ]
70 mesh.ExtrusionSweepObjects( nodes, edges, faces, stepVector, nbSteps, scaleFactors=[0.5], linearVariation=True )
72 # extrude a cylindrical group of faces by normal
74 for g in mesh.GetGroups( SMESH.FACE ):
75 if g.GetName().startswith("node "):
82 mesh.ExtrusionByNormal( elements, stepSize, nbSteps )