023456: EDF 11308 - ExtrusionSweepObjects : link to examples

This commit is contained in:
eap 2017-06-21 14:23:17 +03:00
parent 138a4a27d6
commit f3a96580b4
3 changed files with 94 additions and 20 deletions

View File

@ -1,34 +1,90 @@
# Extrusion
import salome
import salome, math
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import SMESH, SALOMEDS
import SMESH
from salome.smesh import smeshBuilder
smesh = smeshBuilder.New(salome.myStudy)
import SMESH_mechanic
# create an empty mesh
mesh = smesh.Mesh()
#smesh = SMESH_mechanic.smesh
mesh = SMESH_mechanic.mesh
# add a node
mesh.AddNode( 0.,0.,0. )
# select the top face
faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, geompy.ShapeType["FACE"])
face = faces[7]
geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face circular top")
# extrude a node into a line of 10 segments along the X axis
ids = mesh.GetNodesId()
stepVector = [1.,0.,0.]
nbSteps = 10
mesh.ExtrusionSweep( ids, stepVector, nbSteps, IsNodes=True )
# create a vector for extrusion
point = SMESH.PointStruct(0., 0., 5.)
vector = SMESH.DirStruct(point)
# create some groups
lastNode = mesh.GetNodesId()[-1]
lastNodeGroup = mesh.MakeGroupByIds( "node %s"% lastNode, SMESH.NODE, [lastNode])
lineGroup = mesh.MakeGroupByIds( "line", SMESH.EDGE, mesh.GetElementsId() )
# create a group to be extruded
GroupTri = mesh.GroupOnGeom(face, "Group of faces (extrusion)", SMESH.FACE)
# rotate the segments around the first node to get a mesh of a disk quarter
axisZ = [0.,0.,0., 0.,0.,1.]
groups = mesh.RotationSweepObject( lineGroup, axisZ, math.pi/2., 10, 1e-3, MakeGroups=True, TotalAngle=True )
# perform extrusion of the group
mesh.ExtrusionSweepObject(GroupTri, vector, 5)
# extrude all faces into volumes
obj = mesh
stepVector = [0.,0.,-1.]
nbSteps = 5
groups = mesh.ExtrusionSweepObject2D( obj, stepVector, nbSteps, MakeGroups=True )
# remove all segments created by the last command
for g in groups:
if g.GetType() == SMESH.EDGE:
mesh.RemoveGroupWithContents( g )
# extrude all segments into faces along Z
obj = mesh
stepVector = [0.,0.,1.]
mesh.ExtrusionSweepObject1D( obj, stepVector, nbSteps )
# extrude a group
lineExtruded = None
for g in mesh.GetGroups( SMESH.FACE ):
if g.GetName() == "line_extruded":
lineExtruded = g
break
obj = lineExtruded
stepVector = [0,-5.,0.]
nbSteps = 1
mesh.ExtrusionSweepObject( obj, stepVector, nbSteps )
# extrude all nodes and triangle faces of the disk quarter, applying a scale factor
diskGroup = None
for g in mesh.GetGroups( SMESH.FACE ):
if g.GetName() == "line_rotated":
diskGroup = g
break
crit = [ smesh.GetCriterion( SMESH.FACE, SMESH.FT_ElemGeomType,'=',SMESH.Geom_TRIANGLE ),
smesh.GetCriterion( SMESH.FACE, SMESH.FT_BelongToMeshGroup,'=', diskGroup )]
trianglesFilter = smesh.GetFilterFromCriteria( crit )
nodes = [ diskGroup ]
edges = []
faces = [ trianglesFilter ]
stepVector = [0,0,1]
nbSteps = 10
mesh.ExtrusionSweepObjects( nodes, edges, faces, stepVector, nbSteps, scaleFactors=[0.5], linearVariation=True )
# extrude a cylindrical group of faces by normal
cylGroup = None
for g in mesh.GetGroups( SMESH.FACE ):
if g.GetName().startswith("node "):
cylGroup = g
break
elements = cylGroup
stepSize = 5.
nbSteps = 2
mesh.ExtrusionByNormal( elements, stepSize, nbSteps )
salome.sg.updateObjBrowser(True)

View File

@ -103,11 +103,12 @@ INPUT = tmp2/smeshBuilder.py \
tmp2/smesh_algorithm.py \
tmp2/StdMeshersBuilder.py \
tmp2/smeshstudytools.py \
tmp1/smeshBuilder.py
FILE_PATTERNS =
tmp1/smeshBuilder.py \
@CMAKE_CURRENT_SOURCE_DIR@/input
FILE_PATTERNS = tui_*.doc
IMAGE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/images
RECURSIVE = NO
EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/src/SMESH_SWIG
EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/src/SMESH_SWIG @CMAKE_SOURCE_DIR@/doc/salome/examples
#---------------------------------------------------------------------------
#HTML related options
@ -165,3 +166,8 @@ DOT_CLEANUP = YES
#---------------------------------------------------------------------------
GENERATE_TAGFILE = smeshpy_doc.tag
SEARCHENGINE = YES
#---------------------------------------------------------------------------
#Custom commands
#---------------------------------------------------------------------------
ALIASES += tui_script{1}="\include \1 <a href=\"../../examples/SMESH/\1\">Download this script</a>"

View File

@ -3887,6 +3887,7 @@ class Mesh:
# - a GEOM point
# @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion example
def ExtrusionSweepObjects(self, nodes, edges, faces, StepVector, NbOfSteps, MakeGroups=False,
scaleFactors=[], linearVariation=False, basePoint=[] ):
unRegister = genObjUnRegister()
@ -3927,6 +3928,7 @@ class Mesh:
# @param IsNodes is True if elements with given ids are nodes
# @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion example
def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
n,e,f = [],[],[]
if IsNodes: n = IDsOfElements
@ -3953,6 +3955,7 @@ class Mesh:
# @return the list of created groups (SMESH_GroupBase) if \a MakeGroups=True,
# empty list otherwise.
# @ingroup l2_modif_extrurev
# @ref tui_extrusion example
def ExtrusionByNormal(self, Elements, StepSize, NbOfSteps,
ByAverageNormal=False, UseInputElemsOnly=True, MakeGroups=False, Dim = 2):
unRegister = genObjUnRegister()
@ -3982,6 +3985,7 @@ class Mesh:
# @param IsNodes is True if elements to extrude are nodes
# @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion example
def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
n,e,f = [],[],[]
if IsNodes: n = theObject
@ -3998,6 +4002,7 @@ class Mesh:
# @param MakeGroups to generate new groups from existing ones
# @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion example
def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
return self.ExtrusionSweepObjects([],theObject,[], StepVector, NbOfSteps, MakeGroups)
@ -4011,6 +4016,7 @@ class Mesh:
# @param MakeGroups forces the generation of new groups from existing ones
# @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion example
def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
return self.ExtrusionSweepObjects([],[],theObject, StepVector, NbOfSteps, MakeGroups)
@ -4055,6 +4061,7 @@ class Mesh:
# @param MakeGroups forces the generation of new groups from existing ones
# @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error
# @ingroup l2_modif_extrurev
# @ref tui_extrusion_along_path example
def ExtrusionAlongPathObjects(self, Nodes, Edges, Faces, PathMesh, PathShape=None,
NodeStart=1, HasAngles=False, Angles=[], LinearVariation=False,
HasRefPoint=False, RefPoint=[0,0,0], MakeGroups=False):
@ -4098,6 +4105,7 @@ class Mesh:
# @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
# only SMESH::Extrusion_Error otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion_along_path example
def ExtrusionAlongPathX(self, Base, Path, NodeStart,
HasAngles=False, Angles=[], LinearVariation=False,
HasRefPoint=False, RefPoint=[0,0,0], MakeGroups=False,
@ -4130,6 +4138,7 @@ class Mesh:
# @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
# only SMESH::Extrusion_Error otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion_along_path example
def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
HasAngles=False, Angles=[], HasRefPoint=False, RefPoint=[],
MakeGroups=False, LinearVariation=False):
@ -4160,6 +4169,7 @@ class Mesh:
# @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
# only SMESH::Extrusion_Error otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion_along_path example
def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
HasAngles=False, Angles=[], HasRefPoint=False, RefPoint=[],
MakeGroups=False, LinearVariation=False):
@ -4189,6 +4199,7 @@ class Mesh:
# @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
# only SMESH::Extrusion_Error otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion_along_path example
def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
HasAngles=False, Angles=[], HasRefPoint=False, RefPoint=[],
MakeGroups=False, LinearVariation=False):
@ -4218,6 +4229,7 @@ class Mesh:
# @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
# only SMESH::Extrusion_Error otherwise
# @ingroup l2_modif_extrurev
# @ref tui_extrusion_along_path example
def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
HasAngles=False, Angles=[], HasRefPoint=False, RefPoint=[],
MakeGroups=False, LinearVariation=False):