doc/docutils/Makefile \
doc/docutils/conf.py \
doc/salome/Makefile \
+ doc/salome/examples/Makefile \
doc/salome/gui/Makefile \
doc/salome/gui/SMESH/Makefile \
doc/salome/gui/SMESH/doxyfile \
# Modified by : Alexander BORODIN (OCN) - autotools usage
# $Header:
#
-SUBDIRS = tui gui
+SUBDIRS = tui gui examples
SUBDIRSTUI = tui
SUBDIRSGUI = gui
--- /dev/null
+# 3d mesh generation
+
+from geompy import *
+import smesh
+
+###
+# Geometry: an assembly of a box, a cylinder and a truncated cone
+# meshed with tetrahedral
+###
+
+# Define values
+name = "ex21_lamp"
+cote = 60
+section = 20
+size = 200
+radius_1 = 80
+radius_2 = 40
+height = 100
+
+# Build a box
+box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote)
+
+# Build a cylinder
+pt1 = MakeVertex(0, 0, cote/3)
+di1 = MakeVectorDXDYDZ(0, 0, 1)
+cyl = MakeCylinder(pt1, di1, section, size)
+
+# Build a truncated cone
+pt2 = MakeVertex(0, 0, size)
+cone = MakeCone(pt2, di1, radius_1, radius_2, height)
+
+# Fuse
+box_cyl = MakeFuse(box, cyl)
+piece = MakeFuse(box_cyl, cone)
+
+# Add to the study
+addToStudy(piece, name)
+
+# Create a group of faces
+group = CreateGroup(piece, ShapeType["FACE"])
+group_name = name + "_grp"
+addToStudy(group, group_name)
+group.SetName(group_name)
+
+# Add faces to the group
+faces = SubShapeAllIDs(piece, ShapeType["FACE"])
+UnionIDs(group, faces)
+
+###
+# Create a mesh
+###
+
+# Define a mesh on a geometry
+tetra = smesh.Mesh(piece, name)
+
+# Define 1D hypothesis
+algo1d = tetra.Segment()
+algo1d.LocalLength(10)
+
+# Define 2D hypothesis
+algo2d = tetra.Triangle()
+algo2d.LengthFromEdges()
+
+# Define 3D hypothesis
+algo3d = tetra.Tetrahedron()
+algo3d.MaxElementVolume(100)
+
+# Compute the mesh
+tetra.Compute()
+
+# Create a groupe of faces
+tetra.Group(group)
--- /dev/null
+# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# File : Makefile
+# Author : Alexander KOVALEV (Open Cascade NN)
+# Modified by :
+# Module : doc
+#
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+pyexamplesdir = $(docdir)/examples/SMESH
+
+BAD_TESTS =
+
+GOOD_TESTS = \
+ 3dmesh.py \
+ cartesian_algo.py \
+ creating_meshes_ex01.py \
+ creating_meshes_ex02.py \
+ creating_meshes_ex03.py \
+ creating_meshes_ex04.py \
+ creating_meshes_ex05.py \
+ creating_meshes_ex06.py \
+ creating_meshes_ex07.py \
+ creating_meshes_ex08.py \
+ defining_hypotheses_ex01.py \
+ defining_hypotheses_ex02.py \
+ defining_hypotheses_ex03.py \
+ defining_hypotheses_ex04.py \
+ defining_hypotheses_ex05.py \
+ defining_hypotheses_ex06.py \
+ defining_hypotheses_ex07.py \
+ defining_hypotheses_ex08.py \
+ defining_hypotheses_ex09.py \
+ defining_hypotheses_ex10.py \
+ defining_hypotheses_ex11.py \
+ defining_hypotheses_ex12.py \
+ defining_hypotheses_ex13.py \
+ defining_hypotheses_ex14.py \
+ defining_hypotheses_ex15.py \
+ defining_hypotheses_ex16.py \
+ defining_hypotheses_ex17.py \
+ filters_ex01.py \
+ filters_ex02.py \
+ filters_ex03.py \
+ filters_ex04.py \
+ filters_ex05.py \
+ filters_ex06.py \
+ filters_ex07.py \
+ filters_ex08.py \
+ filters_ex09.py \
+ filters_ex10.py \
+ filters_ex11.py \
+ filters_ex12.py \
+ filters_ex13.py \
+ filters_ex14.py \
+ filters_ex15.py \
+ filters_ex16.py \
+ filters_ex17.py \
+ filters_ex18.py \
+ filters_ex19.py \
+ filters_ex20.py \
+ filters_ex21.py \
+ filters_ex22.py \
+ filters_ex23.py \
+ filters_ex24.py \
+ filters_ex25.py \
+ filters_ex26.py \
+ filters_ex27.py \
+ filters_ex28.py \
+ filters_ex29.py \
+ filters_ex30.py \
+ filters_ex31.py \
+ filters_ex32.py \
+ filters_ex33.py \
+ filters_ex34.py \
+ filters_ex35.py \
+ filters_ex36.py \
+ generate_flat_elements.py \
+ grouping_elements_ex01.py \
+ grouping_elements_ex02.py \
+ grouping_elements_ex03.py \
+ grouping_elements_ex04.py \
+ grouping_elements_ex05.py \
+ grouping_elements_ex06.py \
+ grouping_elements_ex07.py \
+ grouping_elements_ex08.py \
+ measurements_ex01.py \
+ measurements_ex02.py \
+ modifying_meshes_ex01.py \
+ modifying_meshes_ex02.py \
+ modifying_meshes_ex03.py \
+ modifying_meshes_ex04.py \
+ modifying_meshes_ex05.py \
+ modifying_meshes_ex06.py \
+ modifying_meshes_ex07.py \
+ modifying_meshes_ex08.py \
+ modifying_meshes_ex09.py \
+ modifying_meshes_ex10.py \
+ modifying_meshes_ex11.py \
+ modifying_meshes_ex12.py \
+ modifying_meshes_ex13.py \
+ modifying_meshes_ex14.py \
+ modifying_meshes_ex15.py \
+ modifying_meshes_ex16.py \
+ modifying_meshes_ex17.py \
+ modifying_meshes_ex18.py \
+ modifying_meshes_ex19.py \
+ modifying_meshes_ex20.py \
+ modifying_meshes_ex21.py \
+ modifying_meshes_ex22.py \
+ modifying_meshes_ex23.py \
+ modifying_meshes_ex24.py \
+ modifying_meshes_ex25.py \
+ modifying_meshes_ex26.py \
+ notebook_smesh.py \
+ prism_3d_algo.py \
+ quality_controls_ex01.py \
+ quality_controls_ex02.py \
+ quality_controls_ex03.py \
+ quality_controls_ex04.py \
+ quality_controls_ex05.py \
+ quality_controls_ex06.py \
+ quality_controls_ex07.py \
+ quality_controls_ex08.py \
+ quality_controls_ex09.py \
+ quality_controls_ex10.py \
+ quality_controls_ex11.py \
+ quality_controls_ex12.py \
+ quality_controls_ex13.py \
+ quality_controls_ex14.py \
+ quality_controls_ex15.py \
+ quality_controls_ex16.py \
+ quality_controls_ex17.py \
+ quality_controls_ex18.py \
+ quality_controls_ex19.py \
+ quality_controls_ex20.py \
+ quality_controls_ex21.py \
+ quality_controls_ex22.py \
+ transforming_meshes_ex01.py \
+ transforming_meshes_ex02.py \
+ transforming_meshes_ex03.py \
+ transforming_meshes_ex04.py \
+ transforming_meshes_ex05.py \
+ transforming_meshes_ex06.py \
+ transforming_meshes_ex07.py \
+ transforming_meshes_ex08.py \
+ transforming_meshes_ex09.py \
+ transforming_meshes_ex10.py \
+ transforming_meshes_ex11.py \
+ transforming_meshes_ex12.py \
+ transforming_meshes_ex13.py \
+ use_existing_faces.py \
+ viewing_meshes_ex01.py \
+ viewing_meshes_ex02.py
+
+pyexamples_SCRIPTS = $(BAD_TESTS) $(GOOD_TESTS)
+
+EXTRA_DIST += $(pyexamples_SCRIPTS) testme.py
+
+check-local:
+ @for f in $(GOOD_TESTS) ; do \
+ python $(top_srcdir)/doc/salome/examples/testme.py $(top_srcdir)/doc/salome/examples/$$f || exit 1; \
+ done
--- /dev/null
+# Usage of Body Fitting algorithm
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+# create a sphere
+sphere = geompy.MakeSphereR( 50 )
+geompy.addToStudy( sphere, "sphere" )
+
+# create a mesh and assign a "Body Fitting" algo
+mesh = Mesh( sphere )
+cartAlgo = mesh.BodyFitted()
+
+# define a cartesian grid using Coordinates
+coords = range(-100,100,10)
+cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000)
+
+# compute the mesh
+mesh.Compute()
+print "nb hexahedra",mesh.NbHexas()
+print "nb tetrahedra",mesh.NbTetras()
+print "nb polyhedra",mesh.NbPolyhedrons()
+print
+
+# define the grid by setting constant spacing
+cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000)
+
+mesh.Compute()
+print "nb hexahedra",mesh.NbHexas()
+print "nb tetrahedra",mesh.NbTetras()
+print "nb polyhedra",mesh.NbPolyhedrons()
+
+
+# define the grid by setting different spacing in 2 sub-ranges of geometry
+spaceFuns = ["5","10+10*t"]
+cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 )
+
+mesh.Compute()
+print "nb hexahedra",mesh.NbHexas()
+print "nb tetrahedra",mesh.NbTetras()
+print "nb polyhedra",mesh.NbPolyhedrons()
+print
--- /dev/null
+# Construction of a Mesh
+
+import geompy
+import smesh
+
+# create a box
+box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+tetra = smesh.Mesh(box, "MeshBox")
+
+algo1D = tetra.Segment()
+algo1D.NumberOfSegments(7)
+
+algo2D = tetra.Triangle()
+algo2D.MaxElementArea(800.)
+
+algo3D = tetra.Tetrahedron()
+algo3D.MaxElementVolume(900.)
+
+# compute the mesh
+ret = tetra.Compute()
+if ret == 0:
+ print "problem when computing the mesh"
+else:
+ print "mesh computed"
+ pass
--- /dev/null
+# Construction of a Submesh
+
+from geompy import *
+import smesh
+
+# create a box
+box = MakeBoxDXDYDZ(10., 10., 10.)
+addToStudy(box, "Box")
+
+# select one edge of the box for definition of a local hypothesis
+p5 = MakeVertex(5., 0., 0.)
+EdgeX = GetEdgeNearPoint(box, p5)
+addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
+
+# create a hexahedral mesh on the box
+quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
+
+# create a regular 1D algorithm for the faces
+algo1D = quadra.Segment()
+
+# define "NumberOfSegments" hypothesis to cut
+# all the edges in a fixed number of segments
+algo1D.NumberOfSegments(4)
+
+# create a quadrangle 2D algorithm for the faces
+quadra.Quadrangle()
+
+# construct a submesh on the edge with a local hypothesis
+algo_local = quadra.Segment(EdgeX)
+
+# define "Arithmetic1D" hypothesis to cut the edge in several segments with increasing arithmetic length
+algo_local.Arithmetic1D(1, 4)
+
+# define "Propagation" hypothesis that propagates all other hypotheses
+# on all edges of the opposite side in case of quadrangular faces
+algo_local.Propagation()
+
+# compute the mesh
+quadra.Compute()
--- /dev/null
+# Change priority of submeshes in Mesh
+
+import salome
+import geompy
+import smesh
+import SMESH
+
+Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
+[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"])
+
+# create Mesh object on Box shape
+Mesh_1 = smesh.Mesh(Box_1)
+
+# assign mesh algorithms
+Regular_1D = Mesh_1.Segment()
+Nb_Segments_1 = Regular_1D.NumberOfSegments(20)
+Nb_Segments_1.SetDistrType( 0 )
+MEFISTO_2D = Mesh_1.Triangle()
+Max_Element_Area_1 = MEFISTO_2D.MaxElementArea(1200)
+Tetrahedron = Mesh_1.Tetrahedron()
+Max_Element_Volume_1 = Tetrahedron.MaxElementVolume(40000)
+
+# create submesh and assign algorithms on Face_1
+Regular_1D_1 = Mesh_1.Segment(geom=Face_1)
+Nb_Segments_2 = Regular_1D_1.NumberOfSegments(4)
+Nb_Segments_2.SetDistrType( 0 )
+MEFISTO_2D_1 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_1)
+Length_From_Edges_2D = MEFISTO_2D_1.LengthFromEdges()
+SubMesh_1 = MEFISTO_2D_1.GetSubMesh()
+
+# create submesh and assign algorithms on Face_2
+Regular_1D_2 = Mesh_1.Segment(geom=Face_2)
+Nb_Segments_3 = Regular_1D_2.NumberOfSegments(8)
+Nb_Segments_3.SetDistrType( 0 )
+MEFISTO_2D_2 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_2)
+Length_From_Edges_2D_1 = MEFISTO_2D_2.LengthFromEdges()
+SubMesh_2 = MEFISTO_2D_2.GetSubMesh()
+
+# create submesh and assign algorithms on Face_3
+Regular_1D_3 = Mesh_1.Segment(geom=Face_3)
+Nb_Segments_4 = Regular_1D_3.NumberOfSegments(12)
+Nb_Segments_4.SetDistrType( 0 )
+MEFISTO_2D_3 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_3)
+Length_From_Edges_2D_2 = MEFISTO_2D_3.LengthFromEdges()
+SubMesh_3 = MEFISTO_2D_3.GetSubMesh()
+
+# check exisiting submesh priority order
+[ [ SubMesh_1, SubMesh_3, SubMesh_2 ] ] = Mesh_1.GetMeshOrder()
+# set new submesh order
+isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_1, SubMesh_2, SubMesh_3 ] ])
+# compute mesh
+isDone = Mesh_1.Compute()
+
+# clear mesh result and compute with other submesh order
+Mesh_1.Clear()
+isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_2, SubMesh_1, SubMesh_3 ] ])
+isDone = Mesh_1.Compute()
--- /dev/null
+# Editing of a mesh
+
+import geompy
+import smesh
+
+def PrintMeshInfo(theMesh):
+ aMesh = theMesh.GetMesh()
+ print "Information about mesh:"
+ print "Number of nodes : ", aMesh.NbNodes()
+ print "Number of edges : ", aMesh.NbEdges()
+ print "Number of faces : ", aMesh.NbFaces()
+ print "Number of volumes : ", aMesh.NbVolumes()
+ pass
+
+# create a box
+box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
+geompy.addToStudy(box, "box")
+
+# select one edge of the box for definition of a local hypothesis
+subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
+edge = subShapeList[0]
+name = geompy.SubShapeName(edge, box)
+geompy.addToStudyInFather(box, edge, name)
+
+# create a mesh
+tria = smesh.Mesh(box, "Mesh 2D")
+algo1D = tria.Segment()
+hyp1 = algo1D.NumberOfSegments(3)
+algo2D = tria.Triangle()
+hyp2 = algo2D.MaxElementArea(10.)
+
+# create a sub-mesh
+algo_local = tria.Segment(edge)
+hyp3 = algo_local.Arithmetic1D(1, 6)
+hyp4 = algo_local.Propagation()
+
+# compute the mesh
+tria.Compute()
+PrintMeshInfo(tria)
+
+# remove a local hypothesis
+mesh = tria.GetMesh()
+mesh.RemoveHypothesis(edge, hyp4)
+
+# compute the mesh
+tria.Compute()
+PrintMeshInfo(tria)
+
+# change the value of the 2D hypothesis
+hyp2.SetMaxElementArea(2.)
+
+# compute the mesh
+tria.Compute()
+PrintMeshInfo(tria)
--- /dev/null
+# Export of a Mesh
+
+import geompy
+import smesh
+
+# create a box
+box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+tetra = smesh.Mesh(box, "MeshBox")
+
+algo1D = tetra.Segment()
+algo1D.NumberOfSegments(7)
+
+algo2D = tetra.Triangle()
+algo2D.MaxElementArea(800.)
+
+algo3D = tetra.Tetrahedron()
+algo3D.MaxElementVolume(900.)
+
+# compute the mesh
+tetra.Compute()
+
+# export the mesh in a MED file
+tetra.ExportMED("/tmp/meshMED.med", 0)
+
+# export a group in a MED file
+face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] # a box side
+group = tetra.GroupOnGeom( face, "face group" ) # group of 2D elements on the <face>
+tetra.ExportMED("/tmp/groupMED.med", meshPart=group)
--- /dev/null
+# Creating a hexahedral mesh on a cylinder.
+# Note: it is a copy of 'ex24_cylinder.py' from SMESH_SWIG
+
+import math
+
+import geompy
+import smesh
+import salome
+geo = geompy
+
+# Parameters
+# ----------
+
+radius = 50
+height = 200
+
+# Build a cylinder
+# ----------------
+
+base = geo.MakeVertex(0, 0, 0)
+direction = geo.MakeVectorDXDYDZ(0, 0, 1)
+
+cylinder = geo.MakeCylinder(base, direction, radius, height)
+
+geo.addToStudy(cylinder, "cylinder")
+
+# Build blocks
+# ------------
+
+size = radius/2.0
+
+box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
+box_axis = geo.MakeLine(base, direction)
+box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
+
+hole = geo.MakeCut(cylinder, box)
+
+plane_trim = 2000
+
+plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
+plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
+
+blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
+blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
+blocks_all = geo.MakeCompound(blocks_list)
+blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
+
+geo.addToStudy(blocks, "cylinder:blocks")
+
+# Build geometric groups
+# ----------------------
+
+def group(name, shape, type, base=None, direction=None):
+ t = geo.ShapeType[type]
+ g = geo.CreateGroup(shape, t)
+
+ geo.addToStudy(g, name)
+ g.SetName(name)
+
+ if base!=None:
+ l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
+ geo.UnionIDs(g, l)
+
+ return g
+
+group_a = group("baseA", blocks, "FACE", base, direction)
+
+base_b = geo.MakeVertex(0, 0, height)
+group_b = group("baseB", blocks, "FACE", base_b, direction)
+
+group_1 = group("limit", blocks, "SOLID")
+group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
+geo.UnionIDs(group_1, group_1_all)
+group_1_box = geo.GetBlockNearPoint(blocks, base)
+geo.DifferenceList(group_1, [group_1_box])
+
+# Mesh the blocks with hexahedral
+# -------------------------------
+
+smesh.SetCurrentStudy(salome.myStudy)
+
+def discretize(x, y, z, n, s=blocks):
+ p = geo.MakeVertex(x, y, z)
+ e = geo.GetEdgeNearPoint(s, p)
+ a = hexa.Segment(e)
+ a.NumberOfSegments(n)
+ a.Propagation()
+
+hexa = smesh.Mesh(blocks)
+
+hexa_1d = hexa.Segment()
+hexa_1d.NumberOfSegments(1)
+
+discretize(+radius , +radius, 0, 5)
+discretize(-radius , +radius, 0, 8)
+discretize((radius+size)/2, 0, 0, 10)
+discretize( +radius, 0, height/2, 20)
+
+hexa.Quadrangle()
+hexa.Hexahedron()
+
+hexa.Compute()
+
+hexa.Group(group_a)
+hexa.Group(group_b)
+hexa.Group(group_1)
--- /dev/null
+# Building a compound of meshes
+# Note: it is a copy of 'SMESH_BuildCompound.py' from SMESH_SWIG
+
+import salome
+import geompy
+import smesh
+
+## create a bottom box
+Box_inf = geompy.MakeBox(0., 0., 0., 200., 200., 50.)
+
+# get a top face
+Psup1=geompy.MakeVertex(100., 100., 50.)
+Fsup1=geompy.GetFaceNearPoint(Box_inf, Psup1)
+# get a bottom face
+Pinf1=geompy.MakeVertex(100., 100., 0.)
+Finf1=geompy.GetFaceNearPoint(Box_inf, Pinf1)
+
+## create a top box
+Box_sup = geompy.MakeBox(100., 100., 50., 200., 200., 100.)
+
+# get a top face
+Psup2=geompy.MakeVertex(150., 150., 100.)
+Fsup2=geompy.GetFaceNearPoint(Box_sup, Psup2)
+# get a bottom face
+Pinf2=geompy.MakeVertex(150., 150., 50.)
+Finf2=geompy.GetFaceNearPoint(Box_sup, Pinf2)
+
+## Publish in the study
+geompy.addToStudy(Box_inf, "Box_inf")
+geompy.addToStudyInFather(Box_inf, Fsup1, "Fsup")
+geompy.addToStudyInFather(Box_inf, Finf1, "Finf")
+
+geompy.addToStudy(Box_sup, "Box_sup")
+geompy.addToStudyInFather(Box_sup, Fsup2, "Fsup")
+geompy.addToStudyInFather(Box_sup, Finf2, "Finf")
+
+smesh.SetCurrentStudy(salome.myStudy)
+
+## create a bottom mesh
+Mesh_inf = smesh.Mesh(Box_inf, "Mesh_inf")
+algo1D_1=Mesh_inf.Segment()
+algo1D_1.NumberOfSegments(10)
+algo2D_1=Mesh_inf.Quadrangle()
+algo3D_1=Mesh_inf.Hexahedron()
+Mesh_inf.Compute()
+
+# create a group on the top face
+Gsup1=Mesh_inf.Group(Fsup1, "Sup")
+# create a group on the bottom face
+Ginf1=Mesh_inf.Group(Finf1, "Inf")
+
+## create a top mesh
+Mesh_sup = smesh.Mesh(Box_sup, "Mesh_sup")
+algo1D_2=Mesh_sup.Segment()
+algo1D_2.NumberOfSegments(5)
+algo2D_2=Mesh_sup.Quadrangle()
+algo3D_2=Mesh_sup.Hexahedron()
+Mesh_sup.Compute()
+
+# create a group on the top face
+Gsup2=Mesh_sup.Group(Fsup2, "Sup")
+# create a group on the bottom face
+Ginf2=Mesh_sup.Group(Finf2, "Inf")
+
+## create compounds
+# create a compound of two meshes with renaming groups with the same names and
+# merging of elements with the given tolerance
+Compound1 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 0, 1, 1e-05)
+smesh.SetName(Compound1, 'Compound_with_RenamedGrps_and_MergeElems')
+# create a compound of two meshes with uniting groups with the same names and
+# creating groups of all elements
+Compound2 = smesh.smesh.Concatenate([Mesh_inf.GetMesh(), Mesh_sup.GetMesh()], 1, 0, 1e-05, True)
+smesh.SetName(Compound2, 'Compound_with_UniteGrps_and_GrpsOfAllElems')
--- /dev/null
+# Mesh Copying
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+# make geometry of a box
+box = geompy.MakeBoxDXDYDZ(100,100,100)
+face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0]
+
+# generate 3D mesh
+mesh = Mesh(box)
+localAlgo = mesh.Triangle(face)
+mesh.AutomaticHexahedralization()
+
+# objects to copy
+fGroup = mesh.GroupOnGeom( face, "2D on face")
+nGroup = mesh.GroupOnGeom( face, "nodes on face", NODE)
+subMesh = localAlgo.GetSubMesh()
+
+# make a new mesh by copying different parts of the mesh
+
+# 1. copy the whole mesh
+newMesh = CopyMesh( mesh, "whole mesh copy")
+
+# 2. copy a group of 2D elements along with groups
+newMesh = CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True)
+
+# 3. copy a group of nodes with preseving their ids
+newMesh = CopyMesh( nGroup, "node group copy", toKeepIDs=True)
+
+# 4. copy some faces
+faceIds = fGroup.GetIDs()[-10:]
+newMesh = CopyMesh( mesh.GetIDSource( faceIds, FACE ), "some faces copy")
+
+# 5. copy some nodes
+nodeIds = nGroup.GetIDs()[-10:]
+newMesh = CopyMesh( mesh.GetIDSource( nodeIds, NODE), "some nodes copy")
+
+# 6. copy a sub-mesh
+newMesh = CopyMesh( subMesh, "submesh copy" )
--- /dev/null
+# Arithmetic 1D
+
+import geompy
+import smesh
+
+# create a box
+box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
+geompy.addToStudy(box, "Box")
+
+# create a hexahedral mesh on the box
+hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+
+# create a Regular 1D algorithm for edges
+algo1D = hexa.Segment()
+
+# optionally reverse node distribution on certain edges
+allEdges = geompy.SubShapeAllSortedIDs( box, geompy.ShapeType["EDGE"])
+reversedEdges = [ allEdges[0], allEdges[4] ]
+
+# define "Arithmetic1D" hypothesis to cut all edges in several segments with increasing arithmetic length
+algo1D.Arithmetic1D(1, 4, reversedEdges)
+
+# create a quadrangle 2D algorithm for faces
+hexa.Quadrangle()
+
+# create a hexahedron 3D algorithm for solids
+hexa.Hexahedron()
+
+# compute the mesh
+hexa.Compute()
--- /dev/null
+# Deflection 1D and Number of Segments
+
+import geompy
+import smesh
+
+# create a face from arc and straight segment
+px = geompy.MakeVertex(100., 0. , 0. )
+py = geompy.MakeVertex(0. , 100., 0. )
+pz = geompy.MakeVertex(0. , 0. , 100.)
+
+exy = geompy.MakeEdge(px, py)
+arc = geompy.MakeArc(py, pz, px)
+
+wire = geompy.MakeWire([exy, arc])
+
+isPlanarFace = 1
+face1 = geompy.MakeFace(wire, isPlanarFace)
+geompy.addToStudy(face1,"Face1")
+
+# get edges from the face
+e_straight,e_arc = geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"])
+geompy.addToStudyInFather(face1, e_arc, "Arc Edge")
+
+# create hexahedral mesh
+hexa = smesh.Mesh(face1, "Face : triangle mesh")
+
+# define "NumberOfSegments" hypothesis to cut a straight edge in a fixed number of segments
+algo1D = hexa.Segment()
+algo1D.NumberOfSegments(6)
+
+# define "MaxElementArea" hypothesis
+algo2D = hexa.Triangle()
+algo2D.MaxElementArea(70.0)
+
+# define a local "Deflection1D" hypothesis on the arc
+algo_local = hexa.Segment(e_arc)
+algo_local.Deflection1D(1.0)
+
+# compute the mesh
+hexa.Compute()
--- /dev/null
+# Start and End Length
+
+from geompy import *
+import smesh
+
+# create a box
+box = MakeBoxDXDYDZ(10., 10., 10.)
+addToStudy(box, "Box")
+
+# get one edge of the box to put local hypothesis on
+p5 = MakeVertex(5., 0., 0.)
+EdgeX = GetEdgeNearPoint(box, p5)
+addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
+
+# create a hexahedral mesh on the box
+hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+
+# set algorithms
+algo1D = hexa.Segment()
+hexa.Quadrangle()
+hexa.Hexahedron()
+
+# define "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
+algo1D.NumberOfSegments(4)
+
+# create a local hypothesis
+algo_local = hexa.Segment(EdgeX)
+
+# define "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
+algo_local.StartEndLength(1, 6)
+
+# define "Propagation" hypothesis that propagates all other hypothesis
+# on all edges on the opposite side in case of quadrangular faces
+algo_local.Propagation()
+
+# compute the mesh
+hexa.Compute()
--- /dev/null
+# Local Length
+
+from geompy import *
+import smesh
+
+# create a box
+box = MakeBoxDXDYDZ(10., 10., 10.)
+addToStudy(box, "Box")
+
+# get one edge of the box to put local hypothesis on
+p5 = MakeVertex(5., 0., 0.)
+EdgeX = GetEdgeNearPoint(box, p5)
+addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
+
+# create a hexahedral mesh on the box
+hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+
+# set algorithms
+algo1D = hexa.Segment()
+hexa.Quadrangle()
+hexa.Hexahedron()
+
+# define "NumberOfSegments" hypothesis to cut all edges in a fixed number of segments
+algo1D.NumberOfSegments(4)
+
+# create a sub-mesh
+algo_local = hexa.Segment(EdgeX)
+
+# define "LocalLength" hypothesis to cut an edge in several segments with the same length
+algo_local.LocalLength(2.)
+
+# define "Propagation" hypothesis that propagates all other hypothesis
+# on all edges on the opposite side in case of quadrangular faces
+algo_local.Propagation()
+
+# compute the mesh
+hexa.Compute()
--- /dev/null
+# Maximum Element Area
+
+import geompy
+import smesh
+import salome
+
+# create a face
+px = geompy.MakeVertex(100., 0. , 0. )
+py = geompy.MakeVertex(0. , 100., 0. )
+pz = geompy.MakeVertex(0. , 0. , 100.)
+
+vxy = geompy.MakeVector(px, py)
+arc = geompy.MakeArc(py, pz, px)
+wire = geompy.MakeWire([vxy, arc])
+
+isPlanarFace = 1
+face = geompy.MakeFace(wire, isPlanarFace)
+
+# add the face in the study
+id_face = geompy.addToStudy(face, "Face to be meshed")
+
+# create a mesh
+tria_mesh = smesh.Mesh(face, "Face : triangulation")
+
+# define 1D meshing:
+algo = tria_mesh.Segment()
+algo.NumberOfSegments(20)
+
+# define 2D meshing:
+
+# assign triangulation algorithm
+algo = tria_mesh.Triangle()
+
+# apply "Max Element Area" hypothesis to each triangle
+algo.MaxElementArea(100)
+
+# compute the mesh
+tria_mesh.Compute()
--- /dev/null
+# Maximum Element Volume
+
+import geompy
+import smesh
+
+# create a cylinder
+cyl = geompy.MakeCylinderRH(30., 50.)
+geompy.addToStudy(cyl, "cyl")
+
+# create a mesh on the cylinder
+tetra = smesh.Mesh(cyl, "Cylinder : tetrahedrical mesh")
+
+# assign algorithms
+algo1D = tetra.Segment()
+algo2D = tetra.Triangle()
+algo3D = tetra.Tetrahedron()
+
+# assign 1D and 2D hypotheses
+algo1D.NumberOfSegments(7)
+algo2D.MaxElementArea(150.)
+
+# assign Max Element Volume hypothesis
+algo3D.MaxElementVolume(200.)
+
+# compute the mesh
+ret = tetra.Compute()
+if ret == 0:
+ print "probleme when computing the mesh"
+else:
+ print "Computation succeded"
--- /dev/null
+# Length from Edges
+
+import geompy
+import smesh
+
+# create sketchers
+sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
+sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
+
+# create a face from two wires
+isPlanarFace = 1
+face1 = geompy.MakeFaces([sketcher1, sketcher2], isPlanarFace)
+geompy.addToStudy(face1, "Face1")
+
+# create a mesh
+tria = smesh.Mesh(face1, "Face : triangle 2D mesh")
+
+# Define 1D meshing
+algo1D = tria.Segment()
+algo1D.NumberOfSegments(2)
+
+# create and assign the algorithm for 2D meshing with triangles
+algo2D = tria.Triangle()
+
+# create and assign "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
+algo2D.LengthFromEdges()
+
+# compute the mesh
+tria.Compute()
--- /dev/null
+# Propagation
+
+from geompy import *
+import smesh
+
+# create a box
+box = MakeBoxDXDYDZ(10., 10., 10.)
+addToStudy(box, "Box")
+
+# get one edge of the box to put local hypothesis on
+p5 = MakeVertex(5., 0., 0.)
+EdgeX = GetEdgeNearPoint(box, p5)
+addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
+
+# create a hexahedral mesh on the box
+hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+
+# set global algorithms and hypotheses
+algo1D = hexa.Segment()
+hexa.Quadrangle()
+hexa.Hexahedron()
+algo1D.NumberOfSegments(4)
+
+# create a sub-mesh with local 1D hypothesis and propagation
+algo_local = hexa.Segment(EdgeX)
+
+# define "Arithmetic1D" hypothesis to cut an edge in several segments with increasing length
+algo_local.Arithmetic1D(1, 4)
+
+# define "Propagation" hypothesis that propagates all other 1D hypotheses
+# from all edges on the opposite side of a face in case of quadrangular faces
+algo_local.Propagation()
+
+# compute the mesh
+hexa.Compute()
--- /dev/null
+# Defining Meshing Algorithms
+
+import geompy
+import smesh
+
+# create a box
+box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
+geompy.addToStudy(box, "Box")
+
+# 1. Create a hexahedral mesh on the box
+hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
+
+# create a Regular 1D algorithm for edges
+algo1D = hexa.Segment()
+
+# create a quadrangle 2D algorithm for faces
+algo2D = hexa.Quadrangle()
+
+# create a hexahedron 3D algorithm for solids
+algo3D = hexa.Hexahedron()
+
+# define hypotheses
+algo1D.Arithmetic1D(1, 4)
+
+# compute the mesh
+hexa.Compute()
+
+# 2. Create a tetrahedral mesh on the box
+tetra = smesh.Mesh(box, "Box : tetrahedrical mesh")
+
+# create a Regular 1D algorithm for edges
+algo1D = tetra.Segment()
+
+# create a Mefisto 2D algorithm for faces
+algo2D = tetra.Triangle()
+
+# create a 3D algorithm for solids
+algo3D = tetra.Tetrahedron()
+
+# define hypotheses
+algo1D.Arithmetic1D(1, 4)
+algo2D.LengthFromEdges()
+
+# compute the mesh
+tetra.Compute()
--- /dev/null
+# Projection Algorithms
+
+# Project prisms from one meshed box to another mesh on the same box
+
+from smesh import *
+
+# Prepare geometry
+
+# Create a parallelepiped
+box = geompy.MakeBoxDXDYDZ(200, 100, 70)
+geompy.addToStudy( box, "box" )
+
+# Get geom faces to mesh with triangles in the 1ts and 2nd meshes
+faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+# 2 adjacent faces of the box
+f1 = faces[2]
+f2 = faces[0]
+# face opposite to f2
+f2opp = faces[1]
+
+# Get vertices used to specify how to associate sides of faces at projection
+[v1F1, v2F1] = geompy.SubShapeAll(f1, geompy.ShapeType["VERTEX"])[:2]
+[v1F2, v2F2] = geompy.SubShapeAll(f2, geompy.ShapeType["VERTEX"])[:2]
+geompy.addToStudyInFather( box, v1F1, "v1F1" )
+geompy.addToStudyInFather( box, v2F1, "v2F1" )
+geompy.addToStudyInFather( box, v1F2, "v1F2" )
+geompy.addToStudyInFather( box, v2F2, "v2F2" )
+
+# Make group of 3 edges of f1 and f2
+edgesF1 = geompy.CreateGroup(f1, geompy.ShapeType["EDGE"])
+geompy.UnionList( edgesF1, geompy.SubShapeAll(f1, geompy.ShapeType["EDGE"])[:3])
+edgesF2 = geompy.CreateGroup(f2, geompy.ShapeType["EDGE"])
+geompy.UnionList( edgesF2, geompy.SubShapeAll(f2, geompy.ShapeType["EDGE"])[:3])
+geompy.addToStudyInFather( box, edgesF1, "edgesF1" )
+geompy.addToStudyInFather( box, edgesF2, "edgesF2" )
+
+
+# Make the source mesh with prisms
+src_mesh = Mesh(box, "Source mesh")
+src_mesh.Segment().NumberOfSegments(9,10)
+src_mesh.Quadrangle()
+src_mesh.Hexahedron()
+src_mesh.Triangle(f1) # triangular sumbesh
+src_mesh.Compute()
+
+
+# Mesh the box using projection algoritms
+
+# Define the same global 1D and 2D hypotheses
+tgt_mesh = Mesh(box, "Target mesh")
+tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True)
+tgt_mesh.Quadrangle()
+
+# Define Projection 1D algorithm to project 1d mesh elements from group edgesF2 to edgesF1
+# It is actually not needed, just a demonstration
+proj1D = tgt_mesh.Projection1D( edgesF1 )
+# each vertex must be at the end of a connected group of edges (or a sole edge)
+proj1D.SourceEdge( edgesF2, src_mesh, v2F1, v2F2 )
+
+# Define 2D hypotheses to project triangles from f1 face of the source mesh to
+# f2 face in the target mesh. Vertices specify how to associate sides of faces
+proj2D = tgt_mesh.Projection2D( f2 )
+proj2D.SourceFace( f1, src_mesh, v1F1, v1F2, v2F1, v2F2 )
+
+# 2D hypotheses to project triangles from f2 of target mesh to the face opposite to f2.
+# Association of face sides is default
+proj2D = tgt_mesh.Projection2D( f2opp )
+proj2D.SourceFace( f2 )
+
+# 3D hypotheses to project prisms from the source to the target mesh
+proj3D = tgt_mesh.Projection3D()
+proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 )
+tgt_mesh.Compute()
+
+# Move the source mesh to visualy compare the two meshes
+src_mesh.TranslateObject( src_mesh, MakeDirStruct( 210, 0, 0 ), Copy=False)
--- /dev/null
+# Projection 1D2D
+
+# Project triangles from one meshed face to another mesh on the same box
+
+from smesh import *
+
+# Prepare geometry
+
+# Create a box
+box = geompy.MakeBoxDXDYDZ(100, 100, 100)
+
+# Get geom faces to mesh with triangles in the 1ts and 2nd meshes
+faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+# 2 adjacent faces of the box
+Face_1 = faces[2]
+Face_2 = faces[0]
+
+geompy.addToStudy( box, 'box' )
+geompy.addToStudyInFather( box, Face_1, 'Face_1' )
+geompy.addToStudyInFather( box, Face_2, 'Face_2' )
+
+# Make the source mesh with Netgem2D
+src_mesh = Mesh(Face_1, "Source mesh")
+src_mesh.Segment().NumberOfSegments(15)
+src_mesh.Triangle()
+src_mesh.Compute()
+
+# Mesh the target mesh using the algoritm Projection1D2D
+tgt_mesh = smesh.Mesh(Face_2, "Target mesh")
+tgt_mesh.Projection1D2D().SourceFace(Face_1,src_mesh)
+tgt_mesh.Compute()
--- /dev/null
+# 1D Mesh with Fixed Points example
+
+import salome
+import geompy
+import smesh
+import StdMeshers
+
+# Create face and explode it on edges
+face = geompy.MakeFaceHW(100, 100, 1)
+edges = geompy.SubShapeAllSorted(face, geompy.ShapeType["EDGE"])
+geompy.addToStudy( face, "Face" )
+
+# get the first edge from exploded result
+edge1 = geompy.GetSubShapeID(face, edges[0])
+
+# Define Mesh on previously created face
+Mesh_1 = smesh.Mesh(face)
+
+# Create Fixed Point 1D hypothesis and define parameters.
+# Note: values greater than 1.0 and less than 0.0 are not taken into account;
+# duplicated values are removed. Also, if not specified explicitly, values 0.0 and 1.0
+# add added automatically.
+# The number of segments should correspond to the number of points (NbSeg = NbPnt-1);
+# extra values of segments splitting parameter are not taken into account,
+# while missing values are considered to be equal to 1.
+Fixed_points_1D_1 = smesh.CreateHypothesis('FixedPoints1D')
+Fixed_points_1D_1.SetPoints( [ 1.1, 0.9, 0.5, 0.0, 0.5, -0.3 ] )
+Fixed_points_1D_1.SetNbSegments( [ 3, 1, 2 ] )
+Fixed_points_1D_1.SetReversedEdges( [edge1] )
+
+# Add hypothesis to mesh and define 2D parameters
+Mesh_1.AddHypothesis(Fixed_points_1D_1)
+Regular_1D = Mesh_1.Segment()
+Quadrangle_2D = Mesh_1.Quadrangle()
+# Compute mesh
+Mesh_1.Compute()
--- /dev/null
+# Radial Quadrangle 1D2D example
+
+from smesh import *
+
+SetCurrentStudy(salome.myStudy)
+
+# Create face from the wire and add to study
+Face = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:R 90:C 20 90:WF", [0, 0, 0, 1, 0, 0, 0, 0, 1])
+geompy.addToStudy(Face,"Face")
+edges = geompy.SubShapeAllSorted(Face, geompy.ShapeType["EDGE"])
+circle, radius1, radius2 = edges
+geompy.addToStudyInFather(Face, radius1,"radius1")
+geompy.addToStudyInFather(Face, radius2,"radius2")
+geompy.addToStudyInFather(Face, circle,"circle")
+
+
+# Define geometry for mesh, and Radial Quadrange algorithm
+mesh = smesh.Mesh(Face)
+radial_Quad_algo = mesh.Quadrangle(algo=RADIAL_QUAD)
+
+# The Radial Quadrange algorithm can work without any hypothesis
+# In this case it uses "Default Nb of Segments" preferences parameter to discretize edges
+mesh.Compute()
+
+# The Radial Quadrange uses global or local 1d hypotheses if it does
+# not have its own hypotheses.
+# Define global hypotheses to discretize radial edges and a local one for circular edge
+global_Nb_Segments = mesh.Segment().NumberOfSegments(5)
+local_Nb_Segments = mesh.Segment(circle).NumberOfSegments(10)
+mesh.Compute()
+
+# Define own parameters of Radial Quadrange algorithm
+radial_Quad_algo.NumberOfLayers( 4 )
+mesh.Compute()
--- /dev/null
+# Quadrangle Parameters example 1 (meshing a face with 3 edges)
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+# Get 1/4 part from the disk face.
+Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100)
+Disk_1 = geompy.MakeDiskR(100, 1)
+Common_1 = geompy.MakeCommon(Disk_1, Box_1)
+geompy.addToStudy( Disk_1, "Disk_1" )
+geompy.addToStudy( Box_1, "Box_1" )
+geompy.addToStudy( Common_1, "Common_1" )
+
+# Set the Geometry for meshing
+Mesh_1 = smesh.Mesh(Common_1)
+
+
+# Define 1D hypothesis and compute the mesh
+Regular_1D = Mesh_1.Segment()
+Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
+Nb_Segments_1.SetDistrType( 0 )
+
+# Create Quadrangle parameters and define the Base Vertex.
+Quadrangle_2D = Mesh_1.Quadrangle().TriangleVertex( 8 )
+
+Mesh_1.Compute()
--- /dev/null
+# Quadrangle Parameters example 2 (using different types)
+
+import geompy
+import smesh
+import StdMeshers
+
+# Make quadrangle face and explode it on edges.
+Vertex_1 = geompy.MakeVertex(0, 0, 0)
+Vertex_2 = geompy.MakeVertex(40, 0, 0)
+Vertex_3 = geompy.MakeVertex(40, 30, 0)
+Vertex_4 = geompy.MakeVertex(0, 30, 0)
+Quadrangle_Face_1 = geompy.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2)
+[Edge_1,Edge_2,Edge_3,Edge_4] = geompy.SubShapeAllSorted(Quadrangle_Face_1, geompy.ShapeType["EDGE"])
+geompy.addToStudy( Vertex_1, "Vertex_1" )
+geompy.addToStudy( Vertex_2, "Vertex_2" )
+geompy.addToStudy( Vertex_3, "Vertex_3" )
+geompy.addToStudy( Vertex_4, "Vertex_4" )
+geompy.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" )
+geompy.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" )
+
+# Set the Geometry for meshing
+Mesh_1 = smesh.Mesh(Quadrangle_Face_1)
+
+# Create Quadrangle parameters and
+# define the Type as Quadrangle Preference
+Quadrangle_Parameters_1 = smesh.CreateHypothesis('QuadrangleParams')
+Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_QUADRANGLE_PREF )
+
+# Define other hypotheses and algorithms
+Regular_1D = Mesh_1.Segment()
+Nb_Segments_1 = Regular_1D.NumberOfSegments(4)
+Nb_Segments_1.SetDistrType( 0 )
+status = Mesh_1.AddHypothesis(Quadrangle_Parameters_1)
+Quadrangle_2D = Mesh_1.Quadrangle()
+
+# Define submesh on one edge to provide different number of segments
+Regular_1D_1 = Mesh_1.Segment(geom=Edge_2)
+Nb_Segments_2 = Regular_1D_1.NumberOfSegments(10)
+Nb_Segments_2.SetDistrType( 0 )
+SubMesh_1 = Regular_1D_1.GetSubMesh()
+
+# Compute mesh (with Quadrangle Preference type)
+isDone = Mesh_1.Compute()
+
+# Change type to Reduced and compute again
+Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_REDUCED )
+isDone = Mesh_1.Compute()
--- /dev/null
+# "Use Existing Elements" example
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+# Make a patritioned box
+
+box = geompy.MakeBoxDXDYDZ(100,100,100)
+
+N = geompy.MakeVectorDXDYDZ( 1,0,0 )
+O = geompy.MakeVertex( 50,0,0 )
+plane = geompy.MakePlane( O, N, 200 ) # plane YOZ
+
+shape2boxes = geompy.MakeHalfPartition( box, plane )
+boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"])
+
+geompy.addToStudy( boxes[0], "boxes[0]")
+geompy.addToStudy( boxes[1], "boxes[1]")
+midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5]
+geompy.addToStudyInFather( boxes[0], midFace0, "middle Face")
+midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0]
+geompy.addToStudyInFather( boxes[1], midFace1, "middle Face")
+
+# Mesh one of boxes with quadrangles. It is a source mesh
+
+srcMesh = Mesh(boxes[0], "source mesh") # box coloser to CS origin
+nSeg1 = srcMesh.Segment().NumberOfSegments(4)
+srcMesh.Quadrangle()
+srcMesh.Compute()
+srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", FACE )
+
+# Import faces from midFace0 to the target mesh
+
+tgtMesh = Mesh(boxes[1], "target mesh")
+importAlgo = tgtMesh.UseExisting2DElements(midFace1)
+import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
+tgtMesh.Segment().NumberOfSegments(3)
+tgtMesh.Quadrangle()
+tgtMesh.Compute()
+
+# Import the whole source mesh with groups
+import2hyp.SetCopySourceMesh(True,True)
+tgtMesh.Compute()
--- /dev/null
+# Viscous layers construction
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+X = geompy.MakeVectorDXDYDZ( 1,0,0 )
+O = geompy.MakeVertex( 100,50,50 )
+plane = geompy.MakePlane( O, X, 200 ) # plane YZ
+
+box = geompy.MakeBoxDXDYDZ(200,100,100)
+
+shape = geompy.MakeHalfPartition( box, plane )
+
+faces = geompy.SubShapeAllSorted(shape, geompy.ShapeType["FACE"])
+face1 = faces[1]
+ignoreFaces = [ faces[0], faces[-1]]
+
+geompy.addToStudy( shape, "shape" )
+geompy.addToStudyInFather( shape, face1, "face1")
+
+
+mesh = Mesh(shape, "CFD")
+
+mesh.Segment().NumberOfSegments( 4 )
+
+mesh.Triangle()
+mesh.Quadrangle(face1)
+mesh.Compute()
+algo3D = mesh.Tetrahedron()
+
+thickness = 20
+numberOfLayers = 10
+stretchFactor = 1.5
+layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,ignoreFaces)
+
+mesh.Compute()
+
+mesh.MakeGroup("Tetras",VOLUME,FT_ElemGeomType,"=",Geom_TETRA)
+mesh.MakeGroup("Pyras",VOLUME,FT_ElemGeomType,"=",Geom_PYRAMID)
+mesh.MakeGroup("Prims",VOLUME,FT_ElemGeomType,"=",Geom_PENTA)
--- /dev/null
+# Aspect ratio
+
+# create mesh
+from SMESH_mechanic import *
+# get faces with aspect ratio > 6.5
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, 6.5)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with aspect ratio > 6.5:", len(ids)
--- /dev/null
+# Aspect ratio 3D
+
+# create mesh with volumes
+from SMESH_mechanic import *
+mesh.Tetrahedron()
+mesh.Compute()
+# get volumes with aspect ratio < 2.0
+filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_LessThan, 2.0)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of volumes with aspect ratio < 2.0:", len(ids)
--- /dev/null
+# Warping angle
+
+# create mesh
+from SMESH_mechanic import *
+# get faces with warping angle = 2.0e-13 with tolerance 5.0e-14
+criterion = smesh.GetCriterion(smesh.FACE, smesh.FT_Warping, smesh.FT_EqualTo, 2.0e-13)
+criterion.Tolerance = 5.0e-14
+filter = smesh.CreateFilterManager().CreateFilter()
+filter.SetCriteria([criterion])
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids)
--- /dev/null
+# Minimum angle
+
+# create mesh
+from SMESH_mechanic import *
+# get faces with minimum angle > 75
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle,">", 75)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with minimum angle > 75:", len(ids)
--- /dev/null
+# Taper
+
+# create mesh
+from SMESH_mechanic import *
+# get faces with taper < 1.e-15
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_LessThan, 1.e-15)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with taper < 1.e-15:", len(ids)
--- /dev/null
+# Skew
+
+# create mesh
+from SMESH_mechanic import *
+# get faces with skew > 50
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, 50)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with skew > 50:", len(ids)
--- /dev/null
+# Area
+
+# create mesh
+from SMESH_mechanic import *
+# get faces with area > 60 and < 90
+criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 60,\
+ smesh.FT_Undefined, smesh.FT_LogicalAND)
+criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 90)
+filter = smesh.CreateFilterManager().CreateFilter()
+filter.SetCriteria([criterion1,criterion2])
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with area in range (60,90):", len(ids)
--- /dev/null
+# Volume
+
+# create mesh with volumes
+from SMESH_mechanic import *
+mesh.Tetrahedron()
+mesh.Compute()
+# get volumes faces with volume > 100
+filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_MoreThan, 100)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of volumes with volume > 100:", len(ids)
--- /dev/null
+# Free borders
+
+# create mesh
+import geompy, smesh, StdMeshers
+face = geompy.MakeFaceHW(100, 100, 1)
+geompy.addToStudy( face, "quadrangle" )
+mesh = smesh.Mesh(face)
+mesh.Segment().NumberOfSegments(10)
+mesh.Triangle().MaxElementArea(25)
+mesh.Compute()
+# get all free borders
+filter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of edges on free borders:", len(ids)
--- /dev/null
+# Free edges
+
+# create mesh
+import geompy, smesh, StdMeshers
+face = geompy.MakeFaceHW(100, 100, 1)
+geompy.addToStudy( face, "quadrangle" )
+mesh = smesh.Mesh(face)
+mesh.Segment().NumberOfSegments(10)
+mesh.Triangle().MaxElementArea(25)
+mesh.Compute()
+# get all faces with free edges
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeEdges)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with free edges:", len(ids)
--- /dev/null
+# Free nodes
+
+# create mesh
+from SMESH_mechanic import *
+# add node
+mesh.AddNode(0,0,0)
+# get all free nodes
+filter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of free nodes:", len(ids)
--- /dev/null
+# Free faces
+
+# create mesh
+from SMESH_mechanic import *
+# get all free faces
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of free faces:", len(ids)
--- /dev/null
+# Bare border faces
+
+# create mesh
+from SMESH_mechanic import *
+# remove some faces to have faces with bare borders
+mesh.RemoveElements( mesh.GetElementsByType(FACE)[0:5] )
+# get all faces bare borders
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_BareBorderFace)
+ids = mesh.GetIdsFromFilter(filter)
+print "Faces with bare borders:", ids
--- /dev/null
+# Coplanar faces
+
+# create mesh
+from SMESH_mechanic import *
+faceID = mesh.GetElementsByType(FACE)[0]
+# get all faces co-planar to the first face with tolerance 5 degrees
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_CoplanarFaces,faceID,Tolerance=5.0)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces coplanar with the first one:", len(ids)
--- /dev/null
+# Over-constrained faces
+# create mesh
+from SMESH_mechanic import *
+# get all over-constrained faces
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_OverConstrainedFace)
+ids = mesh.GetIdsFromFilter(filter)
+print "Over-constrained faces:", ids
--- /dev/null
+# Double edges, Double faces, Double volumes
+
+from smesh import *
+# make a mesh on a box
+box = geompy.MakeBoxDXDYDZ(100,100,100)
+mesh = Mesh( box, "Box" )
+mesh.Segment().NumberOfSegments(10)
+mesh.Quadrangle()
+mesh.Hexahedron()
+mesh.Compute()
+# copy all elements with translation and Merge nodes
+mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True )
+mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) )
+# create filters to find equal elements
+equalEdgesFilter = GetFilter(SMESH.EDGE, FT_EqualEdges)
+equalFacesFilter = GetFilter(SMESH.FACE, FT_EqualFaces)
+equalVolumesFilter = GetFilter(SMESH.VOLUME, FT_EqualVolumes)
+# get equal elements
+print "Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter ))
+print "Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter ))
+print "Number of equal volumes:", len( mesh.GetIdsFromFilter( equalVolumesFilter ))
--- /dev/null
+# Double nodes
+
+from smesh import *
+# make a mesh on a box
+box = geompy.MakeBoxDXDYDZ(100,100,100)
+mesh = Mesh( box, "Box" )
+mesh.Segment().NumberOfSegments(10)
+mesh.Quadrangle()
+mesh.Hexahedron()
+mesh.Compute()
+# copy all elements with translation
+mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True )
+# create filters to find nodes equal within tolerance of 1e-5
+filter = GetFilter(SMESH.NODE, FT_EqualNodes, Tolerance=1e-5)
+# get equal nodes
+print "Number of equal nodes:", len( mesh.GetIdsFromFilter( filter ))
--- /dev/null
+# Borders at multi-connection
+
+# create mesh
+from SMESH_mechanic import *
+# get border edges with number of connected faces = 5
+filter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, 5)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of border edges with 5 faces connected:", len(ids)
--- /dev/null
+# Borders at multi-connection 2D
+
+# create mesh
+from SMESH_mechanic import *
+# get faces which consist of edges belonging to 2 mesh elements
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, 2)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces consisting of edges belonging to 2 faces:", len(ids)
--- /dev/null
+# Length
+
+# create mesh
+from SMESH_mechanic import *
+# get edges with length > 14
+filter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, 14)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of edges with length > 14:", len(ids)
--- /dev/null
+# Length 2D
+
+# create mesh
+from SMESH_mechanic import *
+# get all faces that have edges with length > 14
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, 14)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with maximum edge length > 14:", len(ids)
--- /dev/null
+# Element Diameter 2D
+
+# create mesh
+from SMESH_mechanic import *
+# get all faces that have elements with length > 10
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, 10)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces with maximum element length > 10:", len(ids)
--- /dev/null
+# Element Diameter 3D
+
+# create mesh with volumes
+from SMESH_mechanic import *
+mesh.Tetrahedron()
+mesh.Compute()
+# get all volumes that have elements with length > 10
+filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, 10)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of volumes with maximum element length > 10:", len(ids)
--- /dev/null
+# Bare border volumes
+
+# create mesh
+from SMESH_mechanic import *
+mesh.Tetrahedron()
+mesh.Compute()
+# remove some volumes to have volumes with bare borders
+mesh.RemoveElements( mesh.GetElementsByType(VOLUME)[0:5] )
+# get all volumes with bare borders
+filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BareBorderVolume)
+ids = mesh.GetIdsFromFilter(filter)
+print "Volumes with bare borders:", ids
--- /dev/null
+# Over-constrained volumes
+
+# create mesh
+from SMESH_mechanic import *
+mesh.Tetrahedron()
+mesh.Compute()
+# get all over-constrained volumes
+filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_OverConstrainedVolume)
+ids = mesh.GetIdsFromFilter(filter)
+print "Over-constrained volumes:", ids
--- /dev/null
+# Belong to Geom
+
+# create mesh
+from SMESH_mechanic import *
+# get all faces which nodes lie on the face sub_face3
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToGeom, sub_face3)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces which nodes lie on sub_face3:", len(ids)
--- /dev/null
+# Lying on Geom
+
+# create mesh
+from SMESH_mechanic import *
+# get all faces at least one node of each lies on the face sub_face3
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_LyingOnGeom, sub_face3)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces at least one node of each lies on sub_face3:", len(ids)
--- /dev/null
+# Belong to Plane
+
+# create mesh
+from SMESH_mechanic import *
+# create plane
+import geompy
+plane_1 = geompy.MakePlane(p3,seg1,2000)
+geompy.addToStudy(plane_1, "plane_1")
+# get all nodes which lie on the plane \a plane_1
+filter = smesh.GetFilter(smesh.NODE, smesh.FT_BelongToPlane, plane_1)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of nodes which lie on the plane plane_1:", len(ids)
--- /dev/null
+# Belong to Cylinder
+
+# create mesh
+from SMESH_mechanic import *
+# get all faces which lie on the cylindrical face \a sub_face1
+filter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToCylinder, sub_face1)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of faces which lie on the cylindrical surface sub_face1:", len(ids)
--- /dev/null
+# Belong to Surface
+
+# create mesh
+from SMESH_mechanic import *
+# create b-spline
+spline_1 = geompy.MakeInterpol([p4,p6,p3,p1])
+surface_1 = geompy.MakePrismVecH( spline_1, vz, 70.0 )
+geompy.addToStudy(surface_1, "surface_1")
+# get all nodes which lie on the surface \a surface_1
+filter = smesh.GetFilter(smesh.NODE, smesh.FT_BelongToGenSurface, surface_1)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of nodes which lie on the surface surface_1:", len(ids)
--- /dev/null
+# Range of IDs
+
+# create mesh
+from SMESH_mechanic import *
+# get nodes with identifiers [5-10] and [15-30]
+criterion1 = smesh.GetCriterion(smesh.NODE, smesh.FT_RangeOfIds, Treshold="5-10",\
+ BinaryOp=smesh.FT_LogicalOR)
+criterion2 = smesh.GetCriterion(smesh.NODE, smesh.FT_RangeOfIds, Treshold="15-30")
+filter = smesh.CreateFilterManager().CreateFilter()
+filter.SetCriteria([criterion1,criterion2])
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of nodes in ranges [5-10] and [15-30]:", len(ids)
--- /dev/null
+# Badly oriented volume
+
+# create mesh with volumes
+from SMESH_mechanic import *
+mesh.Tetrahedron()
+mesh.Compute()
+# get all badly oriented volumes
+filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BadOrientedVolume)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of badly oriented volumes:", len(ids)
--- /dev/null
+# Linear / quadratic
+
+# create mesh
+from SMESH_mechanic import *
+# get number of linear and quadratic edges
+filter_linear = smesh.GetFilter(smesh.EDGE, smesh.FT_LinearOrQuadratic)
+filter_quadratic = smesh.GetFilter(smesh.EDGE, smesh.FT_LinearOrQuadratic, smesh.FT_LogicalNOT)
+ids_linear = mesh.GetIdsFromFilter(filter_linear)
+ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
+print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)
+# convert mesh to quadratic
+print "Convert to quadratic..."
+mesh.ConvertToQuadratic(True)
+# get number of linear and quadratic edges
+ids_linear = mesh.GetIdsFromFilter(filter_linear)
+ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
+print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)
--- /dev/null
+# Group color
+
+# create mesh
+from SMESH_mechanic import *
+# create group of edges
+all_edges = mesh.GetElementsByType(smesh.EDGE)
+grp = mesh.MakeGroupByIds("edges group", smesh.EDGE, all_edges[:len(all_edges)/4])
+import SALOMEDS
+c = SALOMEDS.Color(0.1, 0.5, 1.0)
+grp.SetColor(c)
+# get number of the edges not belonging to the group with the given color
+filter = smesh.GetFilter(smesh.EDGE, smesh.FT_GroupColor, c, smesh.FT_LogicalNOT)
+ids = mesh.GetIdsFromFilter(filter)
+print "Number of edges not beloging to the group with color (0.1, 0.5, 1.0):", len(ids)
--- /dev/null
+# Geometry type
+
+# create mesh with volumes
+from SMESH_mechanic import *
+mesh.Tetrahedron()
+mesh.Compute()
+# get all triangles, quadrangles, tetrahedrons, pyramids
+filter_tri = smesh.GetFilter(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_TRIANGLE)
+filter_qua = smesh.GetFilter(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE)
+filter_tet = smesh.GetFilter(smesh.VOLUME, smesh.FT_ElemGeomType, smesh.Geom_TETRA)
+filter_pyr = smesh.GetFilter(smesh.VOLUME, smesh.FT_ElemGeomType, smesh.Geom_PYRAMID)
+ids_tri = mesh.GetIdsFromFilter(filter_tri)
+ids_qua = mesh.GetIdsFromFilter(filter_qua)
+ids_tet = mesh.GetIdsFromFilter(filter_tet)
+ids_pyr = mesh.GetIdsFromFilter(filter_pyr)
+print "Number of triangles:", len(ids_tri)
+print "Number of quadrangles:", len(ids_qua)
+print "Number of tetrahedrons:", len(ids_tet)
+print "Number of pyramids:", len(ids_pyr)
--- /dev/null
+# Combine filters with Criterion structures using of "criteria".
+
+# create mesh
+from SMESH_mechanic import *
+# get all the quadrangle faces ...
+criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE, smesh.FT_LogicalAND)
+# ... AND do NOT get those from sub_face3
+criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_BelongToGeom, sub_face3, smesh.FT_LogicalNOT)
+filter = smesh.CreateFilterManager().CreateFilter()
+filter.SetCriteria([criterion1,criterion2])
+ids = mesh.GetIdsFromFilter(filter)
+
+myGroup = mesh.MakeGroupByIds("Quads_on_cylindrical_faces",smesh.FACE,ids)
--- /dev/null
+# Double nodes on groups boundaries
+
+# This example represents an iron cable (a thin cylinder) in a concrete bloc (a big cylinder).
+# The big cylinder is defined by two geometric volumes.
+
+import geompy
+import smesh
+import SMESH
+
+# geometry
+
+O = geompy.MakeVertex(0, 0, 0)
+OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+Vertex_1 = geompy.MakeVertex(50, 0, 0)
+Cylinder_1 = geompy.MakeCylinder(O, OX, 10, 500)
+Cylinder_2 = geompy.MakeCylinder(Vertex_1, OX, 100, 400)
+Vertex_2 = geompy.MakeVertex(-200, -200, -200)
+Vertex_3 = geompy.MakeVertex(250, 200, 200)
+Box_1 = geompy.MakeBoxTwoPnt(Vertex_2, Vertex_3)
+Fuse_1 = geompy.MakeFuse(Cylinder_1, Cylinder_2)
+Partition_1 = geompy.MakePartition([Fuse_1], [Cylinder_1, Box_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
+[Solid_1,Solid_2] = geompy.GetShapesOnShape(Cylinder_1, Partition_1, geompy.ShapeType["SOLID"], geompy.GEOM.ST_IN)
+[Solid_3,Solid_4] = geompy.GetShapesOnShape(Cylinder_2, Partition_1, geompy.ShapeType["SOLID"], geompy.GEOM.ST_IN)
+Vertex_4 = geompy.MakeVertex(450, 0, 0)
+Vertex_5 = geompy.MakeVertex(500, 0, 0)
+Vertex_6 = geompy.MakeVertex(550, 0, 0)
+vec1 = geompy.MakeVector(Vertex_4, Vertex_5)
+vec2 = geompy.MakeVector(Vertex_5, Vertex_6)
+[Face_1] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec1, geompy.GEOM.ST_ON)
+[Face_2] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec2, geompy.GEOM.ST_ON)
+
+# meshing (we have linear tetrahedrons here, but other elements are OK)
+
+Mesh_1 = smesh.Mesh(Partition_1)
+Regular_1D = Mesh_1.Segment()
+Nb_Segments_1 = Regular_1D.NumberOfSegments(15)
+MEFISTO_2D = Mesh_1.Triangle(algo=smesh.MEFISTO)
+Length_From_Edges_2D = MEFISTO_2D.LengthFromEdges()
+ALGO3D = Mesh_1.Tetrahedron()
+isDone = Mesh_1.Compute()
+
+# relevant groups of volumes and faces
+
+Solid_1_1 = Mesh_1.GroupOnGeom(Solid_1,'Solid_1',SMESH.VOLUME)
+Solid_2_1 = Mesh_1.GroupOnGeom(Solid_2,'Solid_2',SMESH.VOLUME)
+Solid_3_1 = Mesh_1.GroupOnGeom(Solid_3,'Solid_3',SMESH.VOLUME)
+Solid_4_1 = Mesh_1.GroupOnGeom(Solid_4,'Solid_4',SMESH.VOLUME)
+Face_1_1 = Mesh_1.GroupOnGeom(Face_1,'Face_1',SMESH.FACE)
+Face_2_1 = Mesh_1.GroupOnGeom(Face_2,'Face_2',SMESH.FACE)
+
+# Building of flat elements
+
+Mesh_1.DoubleNodesOnGroupBoundaries([Solid_1_1, Solid_2_1, Solid_3_1, Solid_4_1], 1)
+
+Mesh_1.CreateFlatElementsOnFacesGroups([Face_1_1, Face_2_1])
--- /dev/null
+# Create a Standalone Group
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Get ids of all faces with area > 100
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# create a group consisting of faces with area > 100
+aGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
+
+# create a group that contains all nodes from the mesh
+aGroup2 = mesh.CreateEmptyGroup(smesh.NODE, "all nodes")
+aGroup2.AddFrom(mesh.mesh)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Create a Group on Geometry
+
+import salome
+import geompy
+import smesh
+
+# create a box
+box = geompy.MakeBox(0., 0., 0., 100., 100., 100.)
+geompy.addToStudy(box, "box")
+
+# add the first face of the box to the study
+subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+face = subShapeList[0]
+geompy.addToStudyInFather(box, face, "face 1")
+
+# create group of edges on the face
+aGeomGroupE = geompy.CreateGroup(face, geompy.ShapeType["EDGE"])
+geompy.AddObject(aGeomGroupE, 3)
+geompy.AddObject(aGeomGroupE, 6)
+geompy.AddObject(aGeomGroupE, 8)
+geompy.AddObject(aGeomGroupE, 10)
+geompy.addToStudyInFather(face, aGeomGroupE, "Group of Edges")
+
+# create quadrangle 2D mesh on the box
+quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
+algo1D = quadra.Segment()
+quadra.Quadrangle()
+algo1D.NumberOfSegments(7)
+
+# compute the mesh
+quadra.Compute()
+
+# create SMESH group on the face with name "SMESHGroup1"
+aSmeshGroup1 = quadra.GroupOnGeom(face, "SMESHGroup1")
+
+# create SMESH group on <aGeomGroupE> with default name
+aSmeshGroup2 = quadra.GroupOnGeom(aGeomGroupE)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Create a Group on Filter
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+box = geompy.MakeBoxDXDYDZ(10,10,10)
+
+# make a mesh with quadrangles of different area in range [1,16]
+mesh = Mesh(box,"Quad mesh")
+hyp1D = mesh.Segment().StartEndLength( 1, 4 )
+mesh.Quadrangle()
+mesh.Compute()
+
+# create a group on filter selecting faces of medium size
+critaria = [ \
+ GetCriterion(FACE, FT_Area, ">", 1.1, BinaryOp=FT_LogicalAND ),
+ GetCriterion(FACE, FT_Area, "<", 15.0 )
+ ]
+filt = GetFilterFromCriteria( critaria )
+filtGroup = mesh.GroupOnFilter( FACE, "group on filter", filt )
+print "Group on filter contains %s elemens" % filtGroup.Size()
+
+# group on filter is updated if the mesh is modified
+hyp1D.SetStartLength( 2.5 )
+hyp1D.SetEndLength( 2.5 )
+mesh.Compute()
+print "After mesh change, group on filter contains %s elemens" % filtGroup.Size()
+
+# set a new filter defining the group
+filt2 = GetFilter( FACE, FT_RangeOfIds, "1-50" )
+filtGroup.SetFilter( filt2 )
+print "With a new filter, group on filter contains %s elemens" % filtGroup.Size()
+
+# group is updated at modification of the filter
+filt2.SetCriteria( [ GetCriterion( FACE, FT_RangeOfIds, "1-70" )])
+filtIDs3 = filtGroup.GetIDs()
+print "After filter modification, group on filter contains %s elemens" % filtGroup.Size()
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Edit a Group
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Get ids of all faces with area > 35
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 35.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area > 35, Nb = ", len(anIds)
+
+# create a group by adding elements with area > 35
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > 35")
+aGroup.Add(anIds)
+
+# Get ids of all faces with area > 40
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 40.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area > 40, Nb = ", len(anIds)
+
+# create a group of elements with area [35; 40] by removing elements with area > 40 from group aGroup
+aGroup.Remove(anIds)
+
+# print the result
+aGroupElemIDs = aGroup.GetListOfID()
+
+print "Criterion: 35 < Area < 40, Nb = ", len(aGroupElemIDs)
+
+j = 1
+for i in range(len(aGroupElemIDs)):
+ if j > 20: j = 1; print ""
+ print aGroupElemIDs[i],
+ j = j + 1
+ pass
+print ""
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Union of groups
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : AREA > 20
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area > 20, Nb = ", len( anIds )
+
+# create a group by adding elements with area > 20
+aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
+aGroup1.Add(anIds)
+
+# Criterion : AREA = 20
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_EqualTo, 20.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area = 20, Nb = ", len( anIds )
+
+# create a group by adding elements with area = 20
+aGroup2 = mesh.CreateEmptyGroup( smesh.FACE, "Area = 20" )
+
+aGroup2.Add(anIds)
+
+# create union group : area >= 20
+aGroup3 = mesh.UnionListOfGroups([aGroup1, aGroup2], "Area >= 20")
+print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())
+# Please note that also there is UnionGroups() method which works with two groups only
+
+# Criterion : AREA < 20
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 20.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area < 20, Nb = ", len(anIds)
+
+# create a group by adding elements with area < 20
+aGroup4 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 20")
+aGroup4.Add(anIds)
+
+# create union group : area >= 20 and area < 20
+aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
+print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Intersection of groups
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : AREA > 20
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area > 20, Nb = ", len(anIds)
+
+# create a group by adding elements with area > 20
+aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
+aGroup1.Add(anIds)
+
+# Criterion : AREA < 60
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area < 60, Nb = ", len(anIds)
+
+# create a group by adding elements with area < 60
+aGroup2 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 60")
+aGroup2.Add(anIds)
+
+# create an intersection of groups : 20 < area < 60
+aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60")
+print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
+# Please note that also there is IntersectGroups() method which works with two groups only
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Cut of groups
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : AREA > 20
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area > 20, Nb = ", len(anIds)
+
+# create a group by adding elements with area > 20
+aGroupMain = mesh.MakeGroupByIds("Area > 20", smesh.FACE, anIds)
+
+# Criterion : AREA < 60
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area < 60, Nb = ", len(anIds)
+
+# create a group by adding elements with area < 60
+aGroupTool = mesh.MakeGroupByIds("Area < 60", smesh.FACE, anIds)
+
+# create a cut of groups : area >= 60
+aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
+print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
+# Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Creating groups of entities from existing groups of superior dimensions
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : AREA > 100
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area > 100, Nb = ", len(anIds)
+
+# create a group by adding elements with area > 100
+aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
+
+# Criterion : AREA < 30
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 30.)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+print "Criterion: Area < 30, Nb = ", len(anIds)
+
+# create a group by adding elements with area < 30
+aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", smesh.FACE, anIds)
+
+# Create group of edges using source groups of faces
+aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.EDGE, "Edges" )
+
+# Create group of nodes using source groups of faces
+aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.NODE, "Nodes" )
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Minimum Distance
+
+import smesh
+from SMESH_mechanic import mesh as mesh1
+from SMESH_test1 import mesh as mesh2
+
+mesh1.Compute()
+mesh2.Compute()
+
+# compute min distance from mesh1 to the origin (not available yet)
+smesh.MinDistance(mesh1)
+
+# compute min distance from node 10 of mesh1 to the origin
+smesh.MinDistance(mesh1, id1=10)
+# ... or
+mesh1.MinDistance(10)
+
+# compute min distance between nodes 10 and 20 of mesh1
+smesh.MinDistance(mesh1, id1=10, id2=20)
+# ... or
+mesh1.MinDistance(10, 20)
+
+# compute min distance from element 100 of mesh1 to the origin (not available yet)
+smesh.MinDistance(mesh1, id1=100, isElem1=True)
+# ... or
+mesh1.MinDistance(100, isElem1=True)
+
+# compute min distance between elements 100 and 200 of mesh1 (not available yet)
+smesh.MinDistance(mesh1, id1=100, id2=200, isElem1=True, isElem2=True)
+# ... or
+mesh1.MinDistance(100, 200, True, True)
+
+# compute min distance from element 100 to node 20 of mesh1 (not available yet)
+smesh.MinDistance(mesh1, id1=100, id2=20, isElem1=True)
+# ... or
+mesh1.MinDistance(100, 20, True)
+
+# compute min distance from mesh1 to mesh2 (not available yet)
+smesh.MinDistance(mesh1, mesh2)
+
+# compute min distance from node 10 of mesh1 to node 20 of mesh2
+smesh.MinDistance(mesh1, mesh2, 10, 20)
+
+# compute min distance from node 10 of mesh1 to element 200 of mesh2 (not available yet)
+smesh.MinDistance(mesh1, mesh2, 10, 200, isElem2=True)
+
+# etc...
+
--- /dev/null
+# Bounding Box
+
+import smesh
+from SMESH_mechanic import mesh as mesh1
+from SMESH_test1 import mesh as mesh2
+
+mesh1.Compute()
+mesh2.Compute()
+
+# compute bounding box for mesh1
+mesh1.BoundingBox()
+
+# compute bounding box for list of nodes of mesh1
+mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381])
+
+# compute bounding box for list of elements of mesh1
+mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381], isElem=True)
+
+# compute common bounding box of mesh1 and mesh2
+smesh.BoundingBox([mesh1, mesh2])
+
+# etc...
--- /dev/null
+# Add Node
+
+import smesh
+
+mesh = smesh.Mesh()
+
+# add node
+new_id = mesh.AddNode(50, 10, 0)
+print ""
+if new_id == 0: print "KO node addition."
+else: print "New Node has been added with ID ", new_id
--- /dev/null
+# Add 0D Element
+
+import smesh
+
+mesh = smesh.Mesh()
+
+# add node
+node_id = mesh.AddNode(50, 10, 0)
+
+# add 0D Element
+new_id = mesh.Add0DElement(node_id)
+
+print ""
+if new_id == 0: print "KO node addition."
+else: print "New 0D Element has been added with ID ", new_id
--- /dev/null
+# Add 0D Element on Element Nodes
+
+import smesh, SMESH, geompy
+
+# create a geometry
+box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
+face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0]
+
+# make 3D mesh
+mesh = smesh.Mesh( box )
+mesh.AutomaticHexahedralization(0)
+
+# create 0D elements on all nodes of the mesh
+res = mesh.Add0DElementsToAllNodes( mesh )
+
+# find 0D elements on all nodes of the mesh, all found nodes are added to a new group
+groupName = "0Dmesh"
+res = mesh.Add0DElementsToAllNodes( mesh, groupName )
+mesh.RemoveGroupWithContents( res ) # remove all found 0D elements
+
+# create 0D elements on all nodes of a sub-mesh, with group creation
+groupName = "0Dsubmesh"
+submesh = mesh.GetSubMesh( face, "faceSM")
+res = mesh.Add0DElementsToAllNodes( submesh, groupName )
+
+# create 0D elements on all nodes of a group
+group = mesh.Group( face, "faceGroup" )
+res = mesh.Add0DElementsToAllNodes( group )
+
+# remove all 0D elements
+mesh.RemoveElements( mesh.GetIdsFromFilter( smesh.GetFilter( SMESH.ELEM0D,
+ SMESH.FT_ElemGeomType,
+ "=",SMESH.Geom_POINT )))
+
+# create 0D elements on all nodes of some elements
+res = mesh.Add0DElementsToAllNodes( mesh.GetElementsId() )
+
+mesh.RemoveElements( mesh.GetElementsByType( SMESH.ELEM0D ))
+
+# create 0D elements on some nodes
+nodes = range(1,10)
+res = mesh.Add0DElementsToAllNodes( mesh.GetIDSource( nodes, SMESH.NODE ))
--- /dev/null
+# Add Edge
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+print ""
+
+# add node
+n1 = mesh.AddNode(50, 10, 0)
+if n1 == 0: print "KO node addition."
+
+# add edge
+e1 = mesh.AddEdge([n1, 38])
+if e1 == 0: print "KO edge addition."
+else: print "New Edge has been added with ID ", e1
--- /dev/null
+# Add Triangle
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+print ""
+
+# add node
+n1 = mesh.AddNode(50, 10, 0)
+if n1 == 0: print "KO node addition."
+
+# add triangle
+t1 = mesh.AddFace([n1, 38, 39])
+if t1 == 0: print "KO triangle addition."
+else: print "New Triangle has been added with ID ", t1
--- /dev/null
+# Add Quadrangle
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+print ""
+
+# add node
+n1 = mesh.AddNode(50, 10, 0)
+if n1 == 0: print "KO node addition."
+
+n2 = mesh.AddNode(40, 20, 0)
+if n2 == 0: print "KO node addition."
+
+# add quadrangle
+q1 = mesh.AddFace([n2, n1, 38, 39])
+if q1 == 0: print "KO quadrangle addition."
+else: print "New Quadrangle has been added with ID ", q1
--- /dev/null
+# Add Tetrahedron
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+print ""
+
+# add node
+n1 = mesh.AddNode(50, 10, 0)
+if n1 == 0: print "KO node addition."
+
+# add tetrahedron
+t1 = mesh.AddVolume([n1, 38, 39, 246])
+if t1 == 0: print "KO tetrahedron addition."
+else: print "New Tetrahedron has been added with ID ", t1
--- /dev/null
+# Add Hexahedron
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+print ""
+
+# add nodes
+nId1 = mesh.AddNode(50, 10, 0)
+nId2 = mesh.AddNode(47, 12, 0)
+nId3 = mesh.AddNode(50, 10, 10)
+nId4 = mesh.AddNode(47, 12, 10)
+
+if nId1 == 0 or nId2 == 0 or nId3 == 0 or nId4 == 0: print "KO node addition."
+
+# add hexahedron
+vId = mesh.AddVolume([nId2, nId1, 38, 39, nId4, nId3, 245, 246])
+if vId == 0: print "KO Hexahedron addition."
+else: print "New Hexahedron has been added with ID ", vId
--- /dev/null
+# Add Polygon
+
+import math
+import salome
+
+import smesh
+
+# create an empty mesh structure
+mesh = smesh.Mesh()
+
+# a method to build a polygonal mesh element with <nb_vert> angles:
+def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert):
+ al = 2.0 * math.pi / nb_vert
+ node_ids = []
+
+ # Create nodes for a polygon
+ for ii in range(nb_vert):
+ nid = mesh.AddNode(x0 + radius * math.cos(ii*al),
+ y0 + radius * math.sin(ii*al),
+ z0)
+ node_ids.append(nid)
+ pass
+
+ # Create a polygon
+ return mesh.AddPolygonalFace(node_ids)
+
+# Create three polygons
+f1 = MakePolygon(mesh, 0, 0, 0, 30, 13)
+f2 = MakePolygon(mesh, 0, 0, 10, 21, 9)
+f3 = MakePolygon(mesh, 0, 0, 20, 13, 6)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Add Polyhedron
+
+import salome
+import math
+
+# create an empty mesh structure
+mesh = smesh.Mesh()
+
+# Create nodes for 12-hedron with pentagonal faces
+al = 2 * math.pi / 5.0
+cosal = math.cos(al)
+aa = 13
+rr = aa / (2.0 * math.sin(al/2.0))
+dr = 2.0 * rr * cosal
+r1 = rr + dr
+dh = rr * math.sqrt(2.0 * (1.0 - cosal * (1.0 + 2.0 * cosal)))
+hh = 2.0 * dh - dr * (rr*(cosal - 1) + (rr + dr)*(math.cos(al/2) - 1)) / dh
+
+dd = [] # top
+cc = [] # below top
+bb = [] # above bottom
+aa = [] # bottom
+
+for i in range(5):
+ cos_bot = math.cos(i*al)
+ sin_bot = math.sin(i*al)
+
+ cos_top = math.cos(i*al + al/2.0)
+ sin_top = math.sin(i*al + al/2.0)
+
+ nd = mesh.AddNode(rr * cos_top, rr * sin_top, hh ) # top
+ nc = mesh.AddNode(r1 * cos_top, r1 * sin_top, hh - dh) # below top
+ nb = mesh.AddNode(r1 * cos_bot, r1 * sin_bot, dh) # above bottom
+ na = mesh.AddNode(rr * cos_bot, rr * sin_bot, 0) # bottom
+ dd.append(nd) # top
+ cc.append(nc) # below top
+ bb.append(nb) # above bottom
+ aa.append(na) # bottom
+ pass
+
+# Create a polyhedral volume (12-hedron with pentagonal faces)
+MeshEditor.AddPolyhedralVolume([dd[0], dd[1], dd[2], dd[3], dd[4], # top
+ dd[0], cc[0], bb[1], cc[1], dd[1], # -
+ dd[1], cc[1], bb[2], cc[2], dd[2], # -
+ dd[2], cc[2], bb[3], cc[3], dd[3], # - below top
+ dd[3], cc[3], bb[4], cc[4], dd[4], # -
+ dd[4], cc[4], bb[0], cc[0], dd[0], # -
+ aa[4], bb[4], cc[4], bb[0], aa[0], # .
+ aa[3], bb[3], cc[3], bb[4], aa[4], # .
+ aa[2], bb[2], cc[2], bb[3], aa[3], # . above bottom
+ aa[1], bb[1], cc[1], bb[2], aa[2], # .
+ aa[0], bb[0], cc[0], bb[1], aa[1], # .
+ aa[0], aa[1], aa[2], aa[3], aa[4]], # bottom
+ [5,5,5,5,5,5,5,5,5,5,5,5])
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Removing Nodes
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+
+# remove nodes #246 and #255
+res = mesh.RemoveNodes([246, 255])
+if res == 1: print "Nodes removing is OK!"
+else: print "KO nodes removing."
--- /dev/null
+# Removing Elements
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+
+# remove three elements: #850, #859 and #814
+res = mesh.RemoveElements([850, 859, 814])
+if res == 1: print "Elements removing is OK!"
+else: print "KO Elements removing."
--- /dev/null
+# Removing Orphan Nodes
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+
+# add orphan nodes
+mesh.AddNode(0,0,0)
+mesh.AddNode(1,1,1)
+# remove just created orphan nodes
+res = mesh.RemoveOrphanNodes()
+if res == 1: print "Removed %d nodes!" % res
+else: print "KO nodes removing."
--- /dev/null
+# Renumbering Nodes and Elements
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+
+mesh.RenumberNodes()
+
+mesh.RenumberElements()
--- /dev/null
+# Moving Nodes
+
+from geompy import *
+from smesh import *
+
+box = MakeBoxDXDYDZ(200, 200, 200)
+
+mesh = Mesh( box )
+mesh.Segment().AutomaticLength(0.1)
+mesh.Quadrangle()
+mesh.Compute()
+
+# find node at (0,0,0)
+node000 = None
+for vId in SubShapeAllIDs( box, ShapeType["VERTEX"]):
+ if node000: break
+ nodeIds = mesh.GetSubMeshNodesId( vId, True )
+ for node in nodeIds:
+ xyz = mesh.GetNodeXYZ( node )
+ if xyz[0] == 0 and xyz[1] == 0 and xyz[2] == 0 :
+ node000 = node
+ pass
+ pass
+ pass
+
+if not node000:
+ raise "node000 not found"
+
+# find node000 using the tested function
+n = mesh.FindNodeClosestTo( -1,-1,-1 )
+if not n == node000:
+ raise "FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 )
+
+# move node000 to a new location
+x,y,z = -10, -10, -10
+n = mesh.MoveNode( n,x,y,z )
+if not n:
+ raise "MoveNode() returns " + n
+
+# check the coordinates of the node000
+xyz = mesh.GetNodeXYZ( node000 )
+if not ( xyz[0] == x and xyz[1] == y and xyz[2] == z) :
+ raise "Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] )
--- /dev/null
+# Diagonal Inversion
+
+import salome
+import smesh
+
+# create an empty mesh structure
+mesh = smesh.Mesh()
+
+# create the following mesh:
+# .----.----.----.
+# | /| /| /|
+# | / | / | / |
+# | / | / | / |
+# |/ |/ |/ |
+# .----.----.----.
+
+bb = [0, 0, 0, 0]
+tt = [0, 0, 0, 0]
+ff = [0, 0, 0, 0, 0, 0]
+
+bb[0] = mesh.AddNode( 0., 0., 0.)
+bb[1] = mesh.AddNode(10., 0., 0.)
+bb[2] = mesh.AddNode(20., 0., 0.)
+bb[3] = mesh.AddNode(30., 0., 0.)
+
+tt[0] = mesh.AddNode( 0., 15., 0.)
+tt[1] = mesh.AddNode(10., 15., 0.)
+tt[2] = mesh.AddNode(20., 15., 0.)
+tt[3] = mesh.AddNode(30., 15., 0.)
+
+ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
+ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
+ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
+ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
+ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
+ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
+
+# inverse the diagonal bb[1] - tt[2]
+print "\nDiagonal inversion ... ",
+res = mesh.InverseDiag(bb[1], tt[2])
+if not res: print "failed!"
+else: print "done."
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Uniting two Triangles
+
+import salome
+import smesh
+
+# create an empty mesh structure
+mesh = smesh.Mesh()
+
+# create the following mesh:
+# .----.----.----.
+# | /| /| /|
+# | / | / | / |
+# | / | / | / |
+# |/ |/ |/ |
+# .----.----.----.
+
+bb = [0, 0, 0, 0]
+tt = [0, 0, 0, 0]
+ff = [0, 0, 0, 0, 0, 0]
+
+bb[0] = mesh.AddNode( 0., 0., 0.)
+bb[1] = mesh.AddNode(10., 0., 0.)
+bb[2] = mesh.AddNode(20., 0., 0.)
+bb[3] = mesh.AddNode(30., 0., 0.)
+
+tt[0] = mesh.AddNode( 0., 15., 0.)
+tt[1] = mesh.AddNode(10., 15., 0.)
+tt[2] = mesh.AddNode(20., 15., 0.)
+tt[3] = mesh.AddNode(30., 15., 0.)
+
+ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
+ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
+ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
+ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
+ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
+ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
+
+# delete the diagonal bb[1] - tt[2]
+print "\nUnite two triangles ... ",
+res = mesh.DeleteDiag(bb[1], tt[2])
+if not res: print "failed!"
+else: print "done."
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Uniting a Set of Triangles
+
+import salome
+import smesh
+
+# create an empty mesh structure
+mesh = smesh.Mesh()
+
+# create the following mesh:
+# .----.----.----.
+# | /| /| /|
+# | / | / | / |
+# | / | / | / |
+# |/ |/ |/ |
+# .----.----.----.
+
+bb = [0, 0, 0, 0]
+tt = [0, 0, 0, 0]
+ff = [0, 0, 0, 0, 0, 0]
+
+bb[0] = mesh.AddNode( 0., 0., 0.)
+bb[1] = mesh.AddNode(10., 0., 0.)
+bb[2] = mesh.AddNode(20., 0., 0.)
+bb[3] = mesh.AddNode(30., 0., 0.)
+
+tt[0] = mesh.AddNode( 0., 15., 0.)
+tt[1] = mesh.AddNode(10., 15., 0.)
+tt[2] = mesh.AddNode(20., 15., 0.)
+tt[3] = mesh.AddNode(30., 15., 0.)
+
+ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
+ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
+ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
+ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
+ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
+ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
+
+# unite a set of triangles
+print "\nUnite a set of triangles ... ",
+res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], smesh.FT_MinimumAngle, 60.)
+if not res: print "failed!"
+else: print "done."
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Orientation
+
+import salome
+import smesh
+
+# create an empty mesh structure
+mesh = smesh.Mesh()
+
+# build five quadrangles:
+dx = 10
+dy = 20
+
+n1 = mesh.AddNode(0.0 * dx, 0, 0)
+n2 = mesh.AddNode(1.0 * dx, 0, 0)
+n3 = mesh.AddNode(2.0 * dx, 0, 0)
+n4 = mesh.AddNode(3.0 * dx, 0, 0)
+n5 = mesh.AddNode(4.0 * dx, 0, 0)
+n6 = mesh.AddNode(5.0 * dx, 0, 0)
+n7 = mesh.AddNode(0.0 * dx, dy, 0)
+n8 = mesh.AddNode(1.0 * dx, dy, 0)
+n9 = mesh.AddNode(2.0 * dx, dy, 0)
+n10 = mesh.AddNode(3.0 * dx, dy, 0)
+n11 = mesh.AddNode(4.0 * dx, dy, 0)
+n12 = mesh.AddNode(5.0 * dx, dy, 0)
+
+f1 = mesh.AddFace([n1, n2, n8 , n7 ])
+f2 = mesh.AddFace([n2, n3, n9 , n8 ])
+f3 = mesh.AddFace([n3, n4, n10, n9 ])
+f4 = mesh.AddFace([n4, n5, n11, n10])
+f5 = mesh.AddFace([n5, n6, n12, n11])
+
+# Change the orientation of the second and the fourth faces.
+mesh.Reorient([2, 4])
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Cutting Quadrangles
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+
+# cut two quadrangles: 405 and 406
+mesh.QuadToTri([405, 406], smesh.FT_MinimumAngle)
--- /dev/null
+# Smoothing
+
+import salome
+import geompy
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+
+# select the top face
+faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, geompy.ShapeType["FACE"])
+face = faces[3]
+geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face planar with hole")
+
+# create a group of faces to be smoothed
+GroupSmooth = mesh.GroupOnGeom(face, "Group of faces (smooth)", smesh.FACE)
+
+# perform smoothing
+
+# boolean SmoothObject(Object, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method)
+res = mesh.SmoothObject(GroupSmooth, [], 20, 2., smesh.CENTROIDAL_SMOOTH)
+print "\nSmoothing ... ",
+if not res: print "failed!"
+else: print "done."
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Extrusion
+
+import salome
+import geompy
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+
+# 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")
+
+# create a vector for extrusion
+point = smesh.PointStruct(0., 0., 5.)
+vector = smesh.DirStruct(point)
+
+# create a group to be extruded
+GroupTri = mesh.GroupOnGeom(face, "Group of faces (extrusion)", smesh.FACE)
+
+# perform extrusion of the group
+mesh.ExtrusionSweepObject(GroupTri, vector, 5)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Extrusion along a Path
+
+import math
+import salome
+
+# Geometry
+import geompy
+
+# 1. Create points
+points = [[0, 0], [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]]
+
+iv = 1
+vertices = []
+for point in points:
+ vert = geompy.MakeVertex(point[0], point[1], 0)
+ geompy.addToStudy(vert, "Vertex_" + `iv`)
+ vertices.append(vert)
+ iv += 1
+ pass
+
+# 2. Create edges and wires
+Edge_straight = geompy.MakeEdge(vertices[0], vertices[4])
+Edge_bezierrr = geompy.MakeBezier(vertices)
+Wire_polyline = geompy.MakePolyline(vertices)
+Edge_Circle = geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])
+
+geompy.addToStudy(Edge_straight, "Edge_straight")
+geompy.addToStudy(Edge_bezierrr, "Edge_bezierrr")
+geompy.addToStudy(Wire_polyline, "Wire_polyline")
+geompy.addToStudy(Edge_Circle , "Edge_Circle")
+
+# 3. Explode wire on edges, as they will be used for mesh extrusion
+Wire_polyline_edges = geompy.SubShapeAll(Wire_polyline, geompy.ShapeType["EDGE"])
+for ii in range(len(Wire_polyline_edges)):
+ geompy.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + `ii + 1`)
+ pass
+
+# Mesh
+import smesh
+
+# Mesh the given shape with the given 1d hypothesis
+def Mesh1D(shape1d, nbSeg, name):
+ mesh1d_tool = smesh.Mesh(shape1d, name)
+ algo = mesh1d_tool.Segment()
+ hyp = algo.NumberOfSegments(nbSeg)
+ isDone = mesh1d_tool.Compute()
+ if not isDone: print 'Mesh ', name, ': computation failed'
+ return mesh1d_tool
+
+# Create a mesh with six nodes, seven edges and two quadrangle faces
+def MakeQuadMesh2(mesh_name):
+ quad_1 = smesh.Mesh(name = mesh_name)
+
+ # six nodes
+ n1 = quad_1.AddNode(0, 20, 10)
+ n2 = quad_1.AddNode(0, 40, 10)
+ n3 = quad_1.AddNode(0, 40, 30)
+ n4 = quad_1.AddNode(0, 20, 30)
+ n5 = quad_1.AddNode(0, 0, 30)
+ n6 = quad_1.AddNode(0, 0, 10)
+
+ # seven edges
+ quad_1.AddEdge([n1, n2]) # 1
+ quad_1.AddEdge([n2, n3]) # 2
+ quad_1.AddEdge([n3, n4]) # 3
+ quad_1.AddEdge([n4, n1]) # 4
+ quad_1.AddEdge([n4, n5]) # 5
+ quad_1.AddEdge([n5, n6]) # 6
+ quad_1.AddEdge([n6, n1]) # 7
+
+ # two quadrangle faces
+ quad_1.AddFace([n1, n2, n3, n4]) # 8
+ quad_1.AddFace([n1, n4, n5, n6]) # 9
+ return [quad_1, [1,2,3,4,5,6,7], [8,9]]
+
+# Path meshes
+Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight")
+Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr")
+Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline")
+Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle")
+
+# Initial meshes (to be extruded)
+[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1")
+[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2")
+[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3")
+[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4")
+[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5")
+[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6")
+[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7")
+
+# ExtrusionAlongPath
+# IDsOfElements, PathMesh, PathShape, NodeStart,
+# HasAngles, Angles, HasRefPoint, RefPoint
+refPoint = smesh.PointStruct(0, 0, 0)
+a10 = 10.0*math.pi/180.0
+a45 = 45.0*math.pi/180.0
+
+# 1. Extrusion of two mesh edges along a straight path
+error = quad_1.ExtrusionAlongPath([1,2], Edge_straight_mesh, Edge_straight, 1,
+ 0, [], 0, refPoint)
+
+# 2. Extrusion of one mesh edge along a curved path
+error = quad_2.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1,
+ 0, [], 0, refPoint)
+
+# 3. Extrusion of one mesh edge along a curved path with usage of angles
+error = quad_3.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1,
+ 1, [a45, a45, a45, 0, -a45, -a45, -a45], 0, refPoint)
+
+# 4. Extrusion of one mesh edge along the path, which is a part of a meshed wire
+error = quad_4.ExtrusionAlongPath([4], Wire_polyline_mesh, Wire_polyline_edges[0], 1,
+ 1, [a10, a10, a10], 0, refPoint)
+
+# 5. Extrusion of two mesh faces along the path, which is a part of a meshed wire
+error = quad_5.ExtrusionAlongPath(ff_5 , Wire_polyline_mesh, Wire_polyline_edges[2], 4,
+ 0, [], 0, refPoint)
+
+# 6. Extrusion of two mesh faces along a closed path
+error = quad_6.ExtrusionAlongPath(ff_6 , Edge_Circle_mesh, Edge_Circle, 1,
+ 0, [], 0, refPoint)
+
+# 7. Extrusion of two mesh faces along a closed path with usage of angles
+error = quad_7.ExtrusionAlongPath(ff_7, Edge_Circle_mesh, Edge_Circle, 1,
+ 1, [a45, -a45, a45, -a45, a45, -a45, a45, -a45], 0, refPoint)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Revolution
+
+import math
+import SMESH
+
+import SMESH_mechanic
+
+mesh = SMESH_mechanic.mesh
+smesh = SMESH_mechanic.smesh
+
+# create a group of faces to be revolved
+FacesRotate = [492, 493, 502, 503]
+GroupRotate = mesh.CreateEmptyGroup(SMESH.FACE,"Group of faces (rotate)")
+GroupRotate.Add(FacesRotate)
+
+# define revolution angle and axis
+angle45 = 45 * math.pi / 180
+axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -23.321, -13.3402, -13.3265, 6.66632)
+
+# perform revolution of an object
+mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5)
--- /dev/null
+# Pattern Mapping
+
+import geompy
+import smesh
+
+# define the geometry
+Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.)
+geompy.addToStudy(Box_1, "Box_1")
+
+faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"])
+Face_1 = faces[0]
+Face_2 = faces[1]
+
+geompy.addToStudyInFather(Box_1, Face_1, "Face_1")
+geompy.addToStudyInFather(Box_1, Face_2, "Face_2")
+
+# build a quadrangle mesh 3x3 on Face_1
+Mesh_1 = smesh.Mesh(Face_1)
+algo1D = Mesh_1.Segment()
+algo1D.NumberOfSegments(3)
+Mesh_1.Quadrangle()
+
+isDone = Mesh_1.Compute()
+if not isDone: print 'Mesh Mesh_1 : computation failed'
+
+# build a triangle mesh on Face_2
+Mesh_2 = smesh.Mesh(Face_2)
+
+algo1D = Mesh_2.Segment()
+algo1D.NumberOfSegments(1)
+algo2D = Mesh_2.Triangle()
+algo2D.MaxElementArea(240)
+
+isDone = Mesh_2.Compute()
+if not isDone: print 'Mesh Mesh_2 : computation failed'
+
+# create a 2d pattern
+pattern = smesh.GetPattern()
+
+isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
+if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode()
+
+# apply the pattern to a face of the first mesh
+facesToSplit = Mesh_1.GetElementsByType(smesh.SMESH.FACE)
+print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit))
+pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0)
+isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)
+if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode()
+
+# create quadrangle mesh
+Mesh_3 = smesh.Mesh(Box_1)
+Mesh_3.Segment().NumberOfSegments(1)
+Mesh_3.Quadrangle()
+Mesh_3.Hexahedron()
+isDone = Mesh_3.Compute()
+if not isDone: print 'Mesh Mesh_3 : computation failed'
+
+# create a 3d pattern (hexahedrons)
+pattern_hexa = smesh.GetPattern()
+
+smp_hexa = """!!! Nb of points:
+15
+ 0 0 0 !- 0
+ 1 0 0 !- 1
+ 0 1 0 !- 2
+ 1 1 0 !- 3
+ 0 0 1 !- 4
+ 1 0 1 !- 5
+ 0 1 1 !- 6
+ 1 1 1 !- 7
+ 0.5 0 0.5 !- 8
+ 0.5 0 1 !- 9
+ 0.5 0.5 0.5 !- 10
+ 0.5 0.5 1 !- 11
+ 1 0 0.5 !- 12
+ 1 0.5 0.5 !- 13
+ 1 0.5 1 !- 14
+ !!! Indices of points of 4 elements:
+ 8 12 5 9 10 13 14 11
+ 0 8 9 4 2 10 11 6
+ 2 10 11 6 3 13 14 7
+ 0 1 12 8 2 3 13 10"""
+
+pattern_hexa.LoadFromFile(smp_hexa)
+
+# apply the pattern to a mesh
+volsToSplit = Mesh_3.GetElementsByType(smesh.SMESH.VOLUME)
+print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit))
+pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3)
+isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True)
+if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode()
+
+# create one more quadrangle mesh
+Mesh_4 = smesh.Mesh(Box_1)
+Mesh_4.Segment().NumberOfSegments(1)
+Mesh_4.Quadrangle()
+Mesh_4.Hexahedron()
+isDone = Mesh_4.Compute()
+if not isDone: print 'Mesh Mesh_4 : computation failed'
+
+# create another 3d pattern (pyramids)
+pattern_pyra = smesh.GetPattern()
+
+smp_pyra = """!!! Nb of points:
+9
+ 0 0 0 !- 0
+ 1 0 0 !- 1
+ 0 1 0 !- 2
+ 1 1 0 !- 3
+ 0 0 1 !- 4
+ 1 0 1 !- 5
+ 0 1 1 !- 6
+ 1 1 1 !- 7
+ 0.5 0.5 0.5 !- 8
+ !!! Indices of points of 6 elements:
+ 0 1 5 4 8
+ 7 5 1 3 8
+ 3 2 6 7 8
+ 2 0 4 6 8
+ 0 2 3 1 8
+ 4 5 7 6 8"""
+
+pattern_pyra.LoadFromFile(smp_pyra)
+
+# apply the pattern to a face mesh
+volsToSplit = Mesh_4.GetElementsByType(smesh.SMESH.VOLUME)
+print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit))
+pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0)
+isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True)
+if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode()
--- /dev/null
+# Convert mesh to/from quadratic
+
+import geompy
+import smesh
+
+# create sphere of radius 100
+
+Sphere = geompy.MakeSphereR( 100 )
+geompy.addToStudy( Sphere, "Sphere" )
+
+# create simple trihedral mesh
+
+Mesh = smesh.Mesh(Sphere)
+Regular_1D = Mesh.Segment()
+Nb_Segments = Regular_1D.NumberOfSegments(5)
+MEFISTO_2D = Mesh.Triangle()
+Tetrahedron = Mesh.Tetrahedron()
+
+# compute mesh
+
+isDone = Mesh.Compute()
+
+# convert to quadratic
+# theForce3d = 1; this results in the medium node lying at the
+# middle of the line segments connecting start and end node of a mesh
+# element
+
+Mesh.ConvertToQuadratic( theForce3d=1 )
+
+# revert back to the non-quadratic mesh
+
+Mesh.ConvertFromQuadratic()
+
+# convert to quadratic
+# theForce3d = 0; this results in the medium node lying at the
+# geometrical edge from which the mesh element is built
+
+Mesh.ConvertToQuadratic( theForce3d=0 )
+
+# to convert not the whole mesh but a sub-mesh, provide it as
+# an additional argument to the functions:
+# Mesh.ConvertToQuadratic( 0, subMesh )
+# Mesh.ConvertFromQuadratic( subMesh )
+#
+# Note that the mesh becomes non-conformal at conversion of sub-mesh.
--- /dev/null
+# Using SALOME NoteBook
+
+import geompy
+import smesh
+import salome_notebook
+
+# set variables
+notebook = salome_notebook.notebook
+notebook.set("Length", 100)
+notebook.set("Width", 200)
+notebook.set("Offset", 50)
+
+notebook.set("NbSegments", 7)
+notebook.set("MaxElementArea", 800)
+notebook.set("MaxElementVolume", 900)
+
+# create a box
+box = geompy.MakeBoxDXDYDZ("Length", "Width", 300)
+idbox = geompy.addToStudy(box, "Box")
+
+# create a mesh
+tetra = smesh.Mesh(box, "MeshBox")
+
+algo1D = tetra.Segment()
+algo1D.NumberOfSegments("NbSegments")
+
+algo2D = tetra.Triangle()
+algo2D.MaxElementArea("MaxElementArea")
+
+algo3D = tetra.Tetrahedron()
+algo3D.MaxElementVolume("MaxElementVolume")
+
+# compute the mesh
+ret = tetra.Compute()
+
+# translate the mesh
+point = smesh.PointStruct("Offset", 0., 0.)
+vector = smesh.DirStruct(point)
+tetra.TranslateObject(tetra, vector, 0)
--- /dev/null
+# Use 3D extrusion meshing algorithm
+
+import salome, smesh, SMESH, geompy
+
+salome.salome_init()
+smesh.SetCurrentStudy( salome.myStudy )
+
+OX = geompy.MakeVectorDXDYDZ(1,0,0)
+OY = geompy.MakeVectorDXDYDZ(0,1,0)
+OZ = geompy.MakeVectorDXDYDZ(0,0,1)
+
+# Y ^ Make geometry of a "pipe" with the following base (cross section).
+# | Big central quadrangles will be meshed with triangles, walls
+# of the pipe will be meshed with quadrilaterals
+# +--+--+--+--+--+--+
+# | | | | | | |
+# +--+--+--+--+--+--+
+# | | | | |
+# +--+ | +--+
+# | | | | |
+# +--+-----+-----+--+
+# | | | | |
+# +--+ | +--+
+# | | | | |
+# +--+--+--+--+--+--+
+# | | | | | | | -->
+# +--+--+--+--+--+--+ X
+
+quadBig = geompy.MakeFaceHW( 20,20, 1 )
+quadBig = geompy.MakeTranslation( quadBig, 15,15,0 )
+quadSmall = geompy.MakeFaceHW( 10,10, 1 )
+smallQuads1 = geompy.MakeMultiTranslation1D( quadSmall, OX, 10, 3 )
+smallQuads2 = geompy.MakeMultiTranslation1D( quadSmall, OY, 10, 3 )
+smallQuads2 = geompy.SubShapeAllSortedCentres( smallQuads2, geompy.ShapeType["FACE"])[1:]
+
+base = geompy.MakeCompound( smallQuads2 + [smallQuads1, quadBig])
+axis = geompy.MakeLine( geompy.MakeVertex( 25,25,0), OZ )
+base = geompy.MultiRotate1DNbTimes( base, axis, 4)
+base = geompy.MakePartition( [base], theName="base")
+path = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0])
+
+# Make the pipe, each quadrangle of the base turns into a prism with composite wall faces
+pipe = geompy.MakePipe( base, path )
+prisms = geompy.MakePartition( [pipe], theName="prisms")
+
+
+# get base faces of the prism to define sub-mesh on them
+smallQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 0,0,0 ), "smallQuad")
+bigQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 15,15,0 ), "bigQuad")
+
+
+mesh = smesh.Mesh( prisms )
+
+# assign Global hypotheses
+
+# 1D algorithm and hypothesis for vertical division
+mesh.Segment().NumberOfSegments(15)
+
+# Extrusion 3D algo
+mesh.Prism()
+
+# assign Local hypotheses
+
+# 1D and 2D algos and hyps to mesh smallQuad with quadrilaterals
+mesh.Segment(smallQuad).LocalLength( 3 )
+mesh.Quadrangle(smallQuad)
+
+# 1D and 2D algos and hyps to mesh bigQuad with triangles
+mesh.Segment(bigQuad).LocalLength( 3 )
+mesh.Triangle(bigQuad)
+
+# compute the mesh
+mesh.Compute()
--- /dev/null
+# Free Borders
+
+import salome
+import geompy
+
+import smesh
+
+# create open shell: a box without one plane
+box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
+FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+FaceList.remove(FaceList[5])
+box = geompy.MakeShell(FaceList)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+mesh = smesh.Mesh(box, "Mesh_free_borders")
+algo = mesh.Segment()
+algo.NumberOfSegments(5)
+algo = mesh.Triangle()
+algo.MaxElementArea(20.)
+mesh.Compute()
+
+# criterion : free borders
+aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders)
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Free borders Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateGroup(SMESH.EDGE, "Free borders")
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Borders at Multiconnection
+
+import salome
+import geompy
+
+import smesh
+import SMESH
+
+# create open shell: a box without one plane
+box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
+FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+FaceList.remove(FaceList[5])
+box = geompy.MakeShell(FaceList)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+mesh = smesh.Mesh(box, "Mesh_borders_at_multi-connections")
+algo = mesh.Segment()
+algo.NumberOfSegments(5)
+algo = mesh.Triangle()
+algo.MaxElementArea(20.)
+mesh.Compute()
+
+# Criterion : Borders at multi-connection
+nb_conn = 2
+
+aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, nb_conn)
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Borders at multi-connections Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateGroup(SMESH.EDGE, "Borders at multi-connections")
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Length 1D
+
+import salome
+import geompy
+
+import smesh
+
+# create open shell: a box without one plane
+box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
+FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+FaceList.remove(FaceList[5])
+box = geompy.MakeShell(FaceList)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+mesh = smesh.Mesh(box, "Mesh_Length_1D")
+algo = mesh.Segment()
+algo.NumberOfSegments(5)
+algo = mesh.Triangle()
+algo.MaxElementArea(20.)
+mesh.Compute()
+
+# Criterion : Length > 3.
+length_margin = 3.
+
+aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, length_margin)
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Free Edges
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+aFilterMgr = smesh.CreateFilterManager()
+
+# Remove some elements to obtain free edges
+# Criterion : AREA > 95.
+area_margin = 95.
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+mesh.RemoveElements(anIds)
+
+# Criterion : Free Edges
+aBorders = mesh.GetFreeBorders()
+
+# create groups
+aGroupF = mesh.CreateEmptyGroup(smesh.FACE, "Faces with free edges")
+aGroupN = mesh.CreateEmptyGroup(smesh.NODE, "Nodes on free edges")
+
+# fill groups with elements, corresponding to the criterion
+print ""
+print "Criterion: Free edges Nb = ", len(aBorders)
+for i in range(len(aBorders)):
+ aBorder = aBorders[i]
+ print "Face # ", aBorder.myElemId, " : Edge between nodes (",
+ print aBorder.myPnt1, ", ", aBorder.myPnt2, ")"
+
+ aGroupF.Add([aBorder.myElemId])
+ aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2])
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Free Nodes
+
+import salome
+import geompy
+
+import smesh
+
+# create box
+box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+mesh = smesh.Mesh(box, "Mesh_free_nodes")
+algo = mesh.Segment()
+algo.NumberOfSegments(10)
+algo = mesh.Triangle(smesh.MEFISTO)
+algo.MaxElementArea(150.)
+mesh.Compute()
+
+# Remove some elements to obtain free nodes
+# Criterion : AREA < 80.
+area_margin = 80.
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, area_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+mesh.RemoveElements(anIds)
+
+# criterion : free nodes
+aFilter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes)
+anNodeIds = mesh.GetIdsFromFilter(aFilter)
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.NODE, "Free_nodes")
+aGroup.Add(anNodeIds)
+
+# print the result
+print "Criterion: Free nodes Nb = ", len(anNodeIds)
+j = 1
+for i in range(len(anNodeIds)):
+ if j > 20: j = 1; print ""
+ print anNodeIds[i],
+ j = j + 1
+ pass
+print ""
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Free Faces
+
+import salome
+import geompy
+
+####### GEOM part ########
+
+Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
+Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6])
+Box_1 = geompy.GetMainShape(Box_1_vertex_6)
+Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16])
+Box_1 = geompy.GetMainShape(Box_1_vertex_16)
+Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11])
+Box_1 = geompy.GetMainShape(Box_1_vertex_11)
+Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
+Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
+
+Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19])
+Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21])
+Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
+
+geompy.addToStudy( Box_1, "Box_1" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
+geompy.addToStudy( Plane_1, "Plane_1" )
+geompy.addToStudy( Partition_1, "Partition_1" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
+geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
+geompy.addToStudy( Plane_2, "Plane_2" )
+
+###### SMESH part ######
+import smesh
+
+import StdMeshers
+
+Mesh_1 = smesh.Mesh(Partition_1)
+Regular_1D = Mesh_1.Segment()
+Max_Size_1 = Regular_1D.MaxSize(34.641)
+MEFISTO_2D = Mesh_1.Triangle()
+Tetrahedronn = Mesh_1.Tetrahedron()
+isDone = Mesh_1.Compute()
+
+# create a group of free faces
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces )
+aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
+
+aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Free_faces")
+aGroup.Add(aFaceIds)
+
+# print the result
+print "Criterion: Free faces Nb = ", len(aFaceIds)
+j = 1
+for i in range(len(aFaceIds)):
+ if j > 20: j = 1; print ""
+ print aFaceIds[i],
+ j = j + 1
+ pass
+print ""
+
+#filter faces from plane 2
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_2)
+aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
+aGroup.Remove(aFaceIds)
+
+# create a group of shared faces (located on partition boundary inside box)
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_1)
+aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
+
+aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Shared_faces")
+aGroup.Add(aFaceIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Bare border faces
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+box = geompy.MakeBoxDXDYDZ(100, 100, 100)
+geompy.addToStudy( box, "box" )
+
+mesh = smesh.Mesh(box)
+mesh.Segment().NumberOfSegments(3)
+mesh.Quadrangle()
+mesh.Compute()
+
+# remove 2 faces
+allFaces = mesh.GetElementsByType(FACE)
+mesh.RemoveElements( allFaces[0:2])
+
+bareGroup = mesh.MakeGroup("bare faces", FACE, FT_BareBorderFace)
+assert(bareGroup.Size() == 3)
--- /dev/null
+# Bare border volumes
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+box = geompy.MakeBoxDXDYDZ(100, 30, 10)
+# the smallest face of the box
+face = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])[0]
+
+geompy.addToStudy( box, "box" )
+geompy.addToStudyInFather( box, face, "face" )
+
+mesh = Mesh(box)
+mesh.AutomaticHexahedralization();
+
+# remove half of mesh faces from the smallest face
+faceFaces = mesh.GetSubMeshElementsId(face)
+faceToRemove = faceFaces[: len(faceFaces)/2]
+mesh.RemoveElements( faceToRemove )
+
+# make a group of volumes missing the removed faces
+bareGroup = mesh.MakeGroup("bare volumes", VOLUME, FT_BareBorderVolume)
+assert(bareGroup.Size() == len( faceToRemove))
--- /dev/null
+# Over-constrained faces
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+mesh = Mesh()
+faceFilter = GetFilter(FACE,FT_OverConstrainedFace)
+
+#make an edge
+n1 = mesh.AddNode(0,0,0)
+n2 = mesh.AddNode(10,0,0)
+edge = mesh.AddEdge([n1,n2])
+assert( not mesh.GetIdsFromFilter( faceFilter ))
+
+# make faces
+mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 5)
+assert( 2 == len( mesh.GetIdsFromFilter( faceFilter )))
--- /dev/null
+# Over-constrained volumes
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+mesh = Mesh()
+volumeFilter = GetFilter(VOLUME,FT_OverConstrainedVolume)
+
+# make volumes by extrusion of one face
+n1 = mesh.AddNode(0,0,0)
+n2 = mesh.AddNode(10,0,0)
+edge = mesh.AddEdge([n1,n2])
+mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 1)
+mesh.ExtrusionSweep( mesh.GetElementsByType(FACE), MakeDirStruct(0,0,5), 7)
+assert( 2 == len( mesh.GetIdsFromFilter( volumeFilter )))
--- /dev/null
+# Length 2D
+
+import salome
+import geompy
+
+import smesh
+
+# create open shell: a box without one plane
+box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
+FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+FaceList.remove(FaceList[5])
+box = geompy.MakeShell(FaceList)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+mesh = smesh.Mesh(box, "Mesh_Length_2D")
+algo = mesh.Segment()
+algo.NumberOfSegments(5)
+algo = mesh.Triangle()
+algo.MaxElementArea(20.)
+mesh.Compute()
+
+# Criterion : Length 2D > 5.7
+length_margin = 5.7
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, length_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Faces with length 2D > " + `length_margin`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Borders at Multiconnection 2D
+
+import salome
+import geompy
+
+import smesh
+
+# create a compound of two glued boxes
+box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
+box2 = geompy.MakeTranslation(box1, 0., 20., 0)
+comp = geompy.MakeCompound([box1, box2])
+box = geompy.MakeGlueFaces(comp, 0.000001)
+idbox = geompy.addToStudy(box, "box")
+
+# create a mesh
+mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh")
+algo = mesh.Segment()
+algo.NumberOfSegments(5)
+algo = mesh.Triangle()
+algo.MaxElementArea(20.)
+mesh.Compute()
+
+# Criterion : MULTI-CONNECTION 2D = 3
+nb_conn = 3
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, smesh.FT_EqualTo, nb_conn)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Borders at multi-connection 2D = " + `nb_conn`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Area
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : AREA > 100.
+area_margin = 100.
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Area > ", area_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > " + `area_margin`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Taper
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : Taper > 3e-20
+taper_margin = 3e-20
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, taper_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Taper > " + `taper_margin`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Aspect Ratio
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : ASPECT RATIO > 1.8
+ar_margin = 1.8
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, ar_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Aspect Ratio > " + `ar_margin`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Minimum Angle
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : MINIMUM ANGLE < 35.
+min_angle = 35.
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, min_angle)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Minimum Angle < " + `min_angle`)
+
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Warping
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : WARP ANGLE > 1e-15
+wa_margin = 1e-15
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, wa_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Warp > " + `wa_margin`)
+
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Skew
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : Skew > 38.
+skew_margin = 38.
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, skew_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Skew > " + `skew_margin`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Element Diameter 2D
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+salome = SMESH_mechanic.salome
+
+# Criterion : ELEMENT DIAMETER 2D > 10
+mel_2d_margin = 10
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, mel_2d_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Element Diameter 2D Ratio > ", mel_2d_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 2D > " + `mel_2d_margin`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Aspect Ratio 3D
+
+import SMESH_mechanic_tetra
+
+smesh = SMESH_mechanic_tetra.smesh
+mesh = SMESH_mechanic_tetra.mesh
+salome = SMESH_mechanic_tetra.salome
+
+# Criterion : ASPECT RATIO 3D > 4.5
+ar_margin = 4.5
+
+aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_MoreThan, ar_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Aspect Ratio 3D > " + `ar_margin`)
+
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Volume
+
+import SMESH_mechanic_tetra
+
+smesh = SMESH_mechanic_tetra.smesh
+mesh = SMESH_mechanic_tetra.mesh
+salome = SMESH_mechanic_tetra.salome
+
+# Criterion : VOLUME < 7.
+volume_margin = 7.
+
+aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_LessThan, volume_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print ""
+print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Volume < " + `volume_margin`)
+
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Element Diameter 3D
+
+import SMESH_mechanic_tetra
+
+smesh = SMESH_mechanic_tetra.smesh
+mesh = SMESH_mechanic_tetra.mesh
+salome = SMESH_mechanic_tetra.salome
+
+# Criterion : ELEMENT DIAMETER 3D > 10
+mel_3d_margin = 10
+
+aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, mel_3d_margin)
+
+anIds = mesh.GetIdsFromFilter(aFilter)
+
+# print the result
+print "Criterion: Element Diameter 3D Ratio > ", mel_3d_margin, " Nb = ", len(anIds)
+j = 1
+for i in range(len(anIds)):
+ if j > 20: j = 1; print ""
+ print anIds[i],
+ j = j + 1
+ pass
+print ""
+
+# create a group
+aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 3D > " + `mel_3d_margin`)
+aGroup.Add(anIds)
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+#!/usr/bin/env python
+
+import unittest, sys
+
+class SalomeSession(object):
+ def __init__(self, script):
+ import runSalome
+ sys.argv = ["runSalome.py"]
+ sys.argv += ["--terminal"]
+ sys.argv += ["--modules=GEOM,MED,SMESH"]
+ sys.argv += ["--execute=%s" % script]
+ clt, d = runSalome.main()
+ self.port = d['port']
+ return
+
+ def __del__(self):
+ port = self.port
+ import killSalomeWithPort
+ killSalomeWithPort.killMyPort(port)
+ return
+ pass
+
+class MyTest(unittest.TestCase):
+ def testFunction(self):
+ SalomeSession(sys.argv[1])
+ pass
+
+unittest.main(argv=sys.argv[:1])
--- /dev/null
+# Translation
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+
+# define translation vector
+point = smesh.PointStruct(-150., -150., 0.)
+vector =smesh.DirStruct(point)
+
+# translate a mesh
+doCopy = 1
+
+mesh.Translate([], vector, doCopy)
--- /dev/null
+# Rotation
+
+import math
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+
+# define rotation axis and angle
+axisXYZ = smesh.AxisStruct(0., 0., 0., 5., 5., 20.)
+angle270 = 1.5 * math.pi
+
+# rotate a mesh
+mesh.Rotate([], axisXYZ, angle270, 1)
--- /dev/null
+# Scale
+
+import geompy
+Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
+f = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"])
+
+import smesh,SMESH
+import StdMeshers
+Mesh1 = smesh.Mesh(f[0])
+Regular_1D = Mesh1.Segment()
+Nb_Segments_1 = Regular_1D.NumberOfSegments(3)
+Nb_Segments_1.SetDistrType( 0 )
+Quadrangle_2D = Mesh1.Quadrangle()
+isDone = Mesh1.Compute()
+
+#Perform scale opration for the whole mesh and creation of a new mesh
+newMesh = Mesh1.ScaleMakeMesh(Mesh1,SMESH.PointStruct(100,100,200),[0.5,0.3,0.7],True,"ScaledMesh")
+
+#Perform scale operation for the whole mesh and copy elements
+Mesh1.Scale(Mesh1,SMESH.PointStruct(200,100,100),[0.5,0.5,0.5],True,True)
+
+#Perform scale opration for two edges and move elements
+Mesh1.Scale([1,2],SMESH.PointStruct(-100,100,100),[0.8,1.0,0.7],False)
+
+#Perform scale opration for one face and move elements
+Mesh1.Scale([21],SMESH.PointStruct(0,200,200),[0.7,0.7,0.7],False)
--- /dev/null
+# Symmetry
+
+import math
+
+import SMESH_mechanic
+
+smesh = SMESH_mechanic.smesh
+mesh = SMESH_mechanic.mesh
+
+# create a symmetrical copy of the mesh mirrored through a point
+axis = SMESH.AxisStruct(0, 0, 0, 0, 0, 0)
+
+mesh.Mirror([], axis, smesh.POINT, 1)
--- /dev/null
+# Merging Nodes
+
+import SMESH_mechanic
+mesh = SMESH_mechanic.mesh
+
+# merge nodes
+Tolerance = 25.0
+
+GroupsOfNodes = mesh.FindCoincidentNodes(Tolerance)
+mesh.MergeNodes(GroupsOfNodes)
--- /dev/null
+# Merging Elements
+
+import salome
+import geompy
+import smesh
+
+# create a face to be meshed
+px = geompy.MakeVertex(100., 0. , 0. )
+py = geompy.MakeVertex(0. , 100., 0. )
+pz = geompy.MakeVertex(0. , 0. , 100.)
+
+vxy = geompy.MakeVector(px, py)
+arc = geompy.MakeArc(py, pz, px)
+
+wire = geompy.MakeWire([vxy, arc])
+isPlanarFace = 1
+
+face1 = geompy.MakeFace(wire, isPlanarFace)
+id_face1 = geompy.addToStudy(face1, "Face1")
+
+# create a circle to be an extrusion path
+px1 = geompy.MakeVertex( 100., 100., 0.)
+py1 = geompy.MakeVertex(-100., -100., 0.)
+pz1 = geompy.MakeVertex( 0., 0., 50.)
+
+circle = geompy.MakeCircleThreePnt(py1, pz1, px1)
+id_circle = geompy.addToStudy(circle, "Path")
+
+# create a 2D mesh on the face
+trias = smesh.Mesh(face1, "Face : 2D mesh")
+
+algo1D = trias.Segment()
+algo1D.NumberOfSegments(6)
+algo2D = trias.Triangle()
+algo2D.LengthFromEdges()
+
+trias.Compute()
+
+# create a path mesh
+circlemesh = smesh.Mesh(circle, "Path mesh")
+algo = circlemesh.Segment()
+algo.NumberOfSegments(10)
+circlemesh.Compute()
+
+# extrusion of the mesh
+trias.ExtrusionAlongPath([], circlemesh, circle,
+ 1, 0, [], 0, smesh.PointStruct(0, 0, 0))
+
+# merge nodes
+print "Number of nodes before MergeNodes:",
+trias.NbNodes()
+tolerance = 0.001
+array_of_nodes_groups = trias.FindCoincidentNodes(tolerance)
+
+trias.MergeNodes(array_of_nodes_groups)
+
+print "Number of nodes after MergeNodes:", trias.NbNodes()
+print ""
+print "Number of elements before MergeEqualElements:"
+print "Edges : ", trias.NbEdges()
+print "Triangles : ", trias.NbTriangles()
+print "Quadrangles: ", trias.NbQuadrangles()
+print "Volumes : ", trias.NbVolumes()
+
+# merge elements
+trias.MergeEqualElements()
+print "Number of elements after MergeEqualElements:"
+print "Edges : ", trias.NbEdges()
+print "Triangles : ", trias.NbTriangles()
+print "Quadrangles: ", trias.NbQuadrangles()
+print "Volumes : ", trias.NbVolumes()
+
+salome.sg.updateObjBrowser(1)
--- /dev/null
+# Sew Meshes Border to Side
+
+import geompy
+import smesh
+
+# create two faces of a box
+box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.)
+facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
+face1 = facesList1[2]
+
+box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
+facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
+face2 = facesList2[1]
+
+edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
+edge1 = edgesList[2]
+
+aComp = geompy.MakeCompound([face1, face2])
+geompy.addToStudy(aComp, "Two faces")
+
+# create a mesh on two faces
+mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
+
+algo1D = mesh.Segment()
+algo1D.NumberOfSegments(9)
+algo2D = mesh.Quadrangle()
+
+algo_local = mesh.Segment(edge1)
+algo_local.Arithmetic1D(1, 4)
+algo_local.Propagation()
+
+mesh.Compute()
+
+# sew border to side
+# FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
+# FirstNodeIDOnSide, LastNodeIDOnSide,
+# CreatePolygons, CreatePolyedrs
+mesh.SewBorderToSide(5, 45, 6, 113, 109, 0, 0)
--- /dev/null
+# Sew Conform Free Borders
+
+import geompy
+import smesh
+
+# create two faces of the box
+box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.)
+facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
+face1 = facesList1[2]
+
+box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
+facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
+face2 = facesList2[1]
+
+edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
+edge1 = edgesList[2]
+
+aComp = geompy.MakeCompound([face1, face2])
+geompy.addToStudy(aComp, "Two faces")
+
+# create a mesh on two faces
+mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
+
+algo1D = mesh.Segment()
+algo1D.NumberOfSegments(9)
+algo2D = mesh.Quadrangle()
+
+algo_local = mesh.Segment(edge1)
+algo_local.Arithmetic1D(1, 4)
+algo_local.Propagation()
+
+mesh.Compute()
+
+# sew conform free borders
+# FirstNodeID1, SecondNodeID1, LastNodeID1, FirstNodeID2, SecondNodeID2
+mesh.SewConformFreeBorders(5, 45, 6, 3, 24)
--- /dev/null
+# Sew Free Borders
+
+import geompy
+import smesh
+
+# create two faces of the box
+box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
+facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
+face1 = facesList1[2]
+
+box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
+facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
+face2 = facesList2[1]
+
+edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
+edge1 = edgesList[2]
+
+aComp = geompy.MakeCompound([face1, face2])
+geompy.addToStudy(aComp, "Two faces")
+
+# create a mesh on two faces
+mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
+
+algo1D = mesh.Segment()
+algo1D.NumberOfSegments(4)
+algo2D = mesh.Quadrangle()
+
+algo_local = mesh.Segment(edge1)
+algo_local.Arithmetic1D(1, 4)
+algo_local.Propagation()
+
+mesh.Compute()
+
+# sew free borders
+# FirstNodeID1, SecondNodeID1, LastNodeID1,
+# FirstNodeID2, SecondNodeID2, LastNodeID2, CreatePolygons, CreatePolyedrs
+mesh.SewFreeBorders(6, 21, 5, 1, 12, 3, 0, 0)
--- /dev/null
+# Sew Side Elements
+
+import geompy
+import smesh
+
+# create two boxes
+box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.)
+box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.)
+
+EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
+
+aComp = geompy.MakeCompound([box1, box2])
+geompy.addToStudy(aComp, "Two boxes")
+
+# create a mesh on two boxes
+mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
+
+algo1D = mesh.Segment()
+algo1D.NumberOfSegments(2)
+algo2D = mesh.Quadrangle()
+
+algo_local = mesh.Segment(EdgesList[8])
+algo_local.NumberOfSegments(4)
+algo_local.Propagation()
+
+mesh.Compute()
+
+# sew side elements
+# IDsOfSide1Elements, IDsOfSide2Elements,
+# NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge
+mesh.SewSideElements([69, 70, 71, 72], [91, 92, 89, 90], 8, 38, 23, 58)
--- /dev/null
+# Duplicate nodes
+
+import salome
+import smesh
+import SMESH_test1
+
+mesh = SMESH_test1.mesh
+
+# Compute mesh
+mesh.Compute()
+
+# Without the duplication of border elements
+
+# Nodes to duplicate
+nodes1 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes1' )
+nodes1.Add( [ 289, 278, 302, 285 ] )
+
+# Group of faces to replace nodes with new ones
+faces1 = mesh.CreateEmptyGroup( smesh.FACE, 'faces1' )
+faces1.Add( [ 519, 556, 557 ] )
+
+# Duplicate nodes
+print "\nMesh before the first nodes duplication:"
+print "Nodes : ", mesh.NbNodes()
+print "Edges : ", mesh.NbEdges()
+print "Triangles : ", mesh.NbTriangles()
+
+groupOfCreatedNodes = mesh.DoubleNodeGroup(nodes1, faces1, theMakeGroup=True)
+print "New nodes:", groupOfCreatedNodes.GetIDs()
+
+print "\nMesh after the first nodes duplication:"
+print "Nodes : ", mesh.NbNodes()
+print "Edges : ", mesh.NbEdges()
+print "Triangles : ", mesh.NbTriangles()
+
+# With the duplication of border elements
+
+# Edges to duplicate
+edges = mesh.CreateEmptyGroup( smesh.EDGE, 'edges' )
+edges.Add( [ 29, 30, 31 ] )
+
+# Nodes not to duplicate
+nodes2 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes2' )
+nodes2.Add( [ 32, 5 ] )
+
+# Group of faces to replace nodes with new ones
+faces2 = mesh.CreateEmptyGroup( smesh.FACE, 'faces2' )
+faces2.Add( [ 576, 578, 580 ] )
+
+# Duplicate nodes
+print "\nMesh before the second nodes duplication:"
+print "Nodes : ", mesh.NbNodes()
+print "Edges : ", mesh.NbEdges()
+print "Triangles : ", mesh.NbTriangles()
+
+groupOfNewEdges = mesh.DoubleNodeElemGroup( edges, nodes2, faces2, theMakeGroup=True )
+print "New edges:", groupOfNewEdges.GetIDs()
+
+print "\nMesh after the second nodes duplication:"
+print "Nodes : ", mesh.NbNodes()
+print "Edges : ", mesh.NbEdges()
+print "Triangles : ", mesh.NbTriangles()
+
+# Update object browser
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(0)
--- /dev/null
+# Create boundary elements
+
+from smesh import *
+SetCurrentStudy(salome.myStudy)
+
+box = geompy.MakeBoxDXDYDZ(100, 100, 100)
+gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])
+f1,f2 = gFaces[0],gFaces[1]
+geompy.addToStudy(box,"box")
+geompy.addToStudyInFather(box,f1,"face1")
+geompy.addToStudyInFather(box,f2,"face2")
+
+twoFaces = geompy.MakeCompound([f1,f2])
+
+## -----------
+##
+## 2D from 3D
+##
+## -----------
+dim = SMESH.BND_2DFROM3D
+
+init_mesh = Mesh(box, "box")
+init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
+
+# remove some faces
+faces = init_mesh.GetElementsByType( SMESH.FACE )
+nb_faces = len( faces )
+rm_face = faces[ : nb_faces/2]
+init_mesh.RemoveElements( rm_face )
+
+# restore boundary in this mesh
+mesh = CopyMesh( init_mesh, "2D from 3D")
+groupName = "bnd 2D"
+nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
+
+# restore boundary (only) in other mesh
+meshName = "2D boundary of " + init_mesh.GetName()
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
+
+# restore boundary in mesh copy
+meshName = init_mesh.GetName() + " + boundary"
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
+
+
+## -----------
+##
+## 1D from 2D
+##
+## -----------
+dim = SMESH.BND_1DFROM2D
+
+init_mesh = Mesh(f1, "2D mesh")
+init_mesh.AutomaticHexahedralization()
+
+# remove some edges
+edges = init_mesh.GetElementsByType( SMESH.EDGE )
+nb_edges = len( edges )
+rm_edge = edges[ : nb_edges/2]
+init_mesh.RemoveElements( rm_edge )
+
+
+# restore boundary edges in this mesh
+mesh = CopyMesh( init_mesh, "1D from 2D")
+groupName = "bnd 1D"
+nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
+
+# restore boundary edges (only) in other mesh
+meshName = "1D boundary of " + init_mesh.GetName()
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
+
+# restore boundary edges in mesh copy
+meshName = init_mesh.GetName() + " + boundary"
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
+
+
+
+## ------------------
+##
+## 1D from 2D GROUPS
+##
+## ------------------
+dim = SMESH.BND_1DFROM3D
+
+init_mesh = Mesh(box, "box")
+init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
+# remove all edges
+rm_edges = init_mesh.GetElementsByType( SMESH.EDGE )
+init_mesh.RemoveElements( rm_edges )
+
+# make groups of faces
+fGroup1 = init_mesh.Group( f1, "f1" )
+fGroup2 = init_mesh.Group( f2, "f2" )
+
+# make 1D boundary around groups in this mesh
+mesh = CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True)
+groups = mesh.GetGroups()
+nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups)
+
+# make 1D boundary (only) in other mesh
+meshName = "boundary from groups of " + init_mesh.GetName()
+groups = init_mesh.GetGroups()
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,groups=groups)
+
+# make 1D boundary in mesh copy
+meshName = init_mesh.GetName() + " + boundary from groups"
+nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,
+ groups=groups, toCopyAll=True)
+
--- /dev/null
+# Reorient faces by vector
+
+import smesh, geompy, SMESH
+
+# create a geometry consisting of two faces
+box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
+faces = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])
+
+shape = geompy.MakeCompound( faces[:2] )
+faces = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"] )
+geompy.addToStudy( shape, "shape")
+geompy.addToStudyInFather( shape, faces[0], "faces[0]")
+geompy.addToStudyInFather( shape, faces[1], "faces[1]")
+
+# create a 2D mesh
+mesh = smesh.Mesh( shape, "test_Reorient2D")
+mesh.AutomaticHexahedralization(0.5)
+localAlgo = mesh.Segment(faces[0])
+localAlgo.NumberOfSegments( 11 )
+mesh.Compute()
+group = mesh.Group( faces[1] )
+
+vec = geompy.MakeVectorDXDYDZ( 1, 1, 1 )
+
+# Each of arguments of Reorient2D() function can be of different types:
+#
+# 2DObject - the whole mesh
+# Direction - a GEOM object (vector)
+# FaceOrPoint - an ID of face
+mesh.Reorient2D( mesh, vec, mesh.NbElements() )
+#
+# 2DObject - a sub-mesh
+# Direction - components of a vector
+# FaceOrPoint - a GEOM object (vertex)
+mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geompy.GetFirstVertex( vec ))
+#
+# 2DObject - a group of faces
+# Direction - a SMESH.DirStruct structure
+# FaceOrPoint - coordinates of a point
+mesh.Reorient2D( group, smesh.MakeDirStruct( -10, 1, 10 ), [0,0,0])
+#
+# FaceOrPoint - a SMESH.PointStruct structure
+mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0))
--- /dev/null
+# Use existing faces algorithm
+
+import smesh, geompy
+import numpy as np
+
+# define my 2D algorithm
+def my2DMeshing( geomFace ):
+
+ # find gravity center of geomFace
+ gcXYZ = geompy.PointCoordinates( geompy.MakeCDG( geomFace ))
+
+ # define order and orientation of edges
+ sortedEdges = []
+ geomEdges = geompy.SubShapeAll( geomFace, geompy.ShapeType["EDGE"])
+ sortedEdges.append(( geomEdges.pop(0), True ))
+ while geomEdges:
+ prevEdge_rev = sortedEdges[ -1 ]
+ prevVV = geompy.SubShapeAll( prevEdge_rev[0], geompy.ShapeType["VERTEX"])
+ prevV2 = prevVV[ prevEdge_rev[1] ]
+ found = False
+ for iE in range( len( geomEdges )):
+ v1,v2 = geompy.SubShapeAll( geomEdges[ iE ], geompy.ShapeType["VERTEX"])
+ same1,same2 = [( geompy.MinDistance( prevV2, v ) < 1e-7 ) for v in [v1,v2] ]
+ if not same1 and not same2: continue
+ sortedEdges.append(( geomEdges.pop( iE ), same1 ))
+ found = True
+ break
+ assert found
+ sortedEdges.reverse()
+
+ # put nodes on edges in a right order
+ nodes = []
+ for edge, isForward in sortedEdges:
+ v1,v2 = geompy.SubShapeAll( edge, geompy.ShapeType["VERTEX"])
+ edgeNodes = mesh.GetSubMeshNodesId( v2, all=False ) + \
+ mesh.GetSubMeshNodesId( edge, all=False ) + \
+ mesh.GetSubMeshNodesId( v1, all=False )
+ if not isForward: edgeNodes.reverse()
+ nodes.extend( edgeNodes[:-1] )
+
+ # create nodes inside the geomFace
+ r1 = 0.6
+ r2 = 1 - r1
+ nodesInside = []
+ for n in nodes:
+ nXYZ = mesh.GetNodeXYZ( n )
+ newXYZ = np.add( np.multiply( r1, gcXYZ ), np.multiply( r2, nXYZ ))
+ nodesInside.append( mesh.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] ))
+ mesh.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 )
+
+ # find out orientation of faces to create
+ # geomFace normal
+ faceNorm = geompy.GetNormal( geomFace )
+ v1,v2 = [ geompy.PointCoordinates( v ) \
+ for v in geompy.SubShapeAll( faceNorm, geompy.ShapeType["VERTEX"]) ]
+ faceNormXYZ = np.subtract( v2, v1 )
+ outDirXYZ = np.subtract( v1, [ 50, 50, 50 ] )
+ if np.dot( faceNormXYZ, outDirXYZ ) < 0: # reversed face
+ faceNormXYZ = np.multiply( -1., faceNormXYZ )
+ # mesh face normal
+ e1 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodes[1] ))
+ e2 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodesInside[0] ))
+ meshNorm = np.cross( e1, e2 )
+ # faces orientation
+ reverse = ( np.dot( faceNormXYZ, meshNorm ) < 0 )
+
+ # create mesh faces
+ iN = len( nodes )
+ while iN:
+ n1, n2, n3, n4 = nodes[iN-1], nodes[iN-2], nodesInside[iN-2], nodesInside[iN-1]
+ iN -= 1
+ if reverse:
+ f = mesh.AddFace( [n1, n2, n3, n4] )
+ else:
+ f = mesh.AddFace( [n4, n3, n2, n1] )
+ # new faces must be assigned to geometry to allow 3D algorithm finding them
+ mesh.SetMeshElementOnShape( f, geomFace )
+
+ if reverse:
+ nodesInside.reverse()
+ polygon = mesh.AddPolygonalFace( nodesInside )
+ mesh.SetMeshElementOnShape( polygon, geomFace )
+
+ return
+
+# create geometry and get faces to mesh with my2DMeshing()
+box = geompy.MakeBoxDXDYDZ( 100, 100, 100 )
+f1 = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0]
+f2 = geompy.GetOppositeFace( box, f1 )
+geompy.addToStudy( box, "box" )
+geompy.addToStudy( f1, "f1" )
+geompy.addToStudy( f2, "f2" )
+
+# compute 1D mesh
+mesh = smesh.Mesh( box )
+mesh.Segment().NumberOfSegments( 5 )
+mesh.Compute()
+
+# compute 2D mesh
+mesh.Quadrangle()
+mesh.UseExistingFaces(f1) # UseExistingFaces() allows using my2DMeshing()
+mesh.UseExistingFaces(f2)
+my2DMeshing( f1 )
+my2DMeshing( f2 )
+assert mesh.Compute()
+
+# compute 3D mesh
+mesh.Prism()
+assert mesh.Compute()
--- /dev/null
+# Viewing Mesh Infos
+
+import geompy
+import smesh
+import SMESH
+
+# create a box
+box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
+geompy.addToStudy(box, "box")
+[Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
+
+# create a mesh
+tetra = smesh.Mesh(box, "MeshBox")
+
+algo1D = tetra.Segment()
+algo1D.NumberOfSegments(3)
+
+algo2D = tetra.Triangle()
+algo2D.MaxElementArea(10.)
+
+algo3D = tetra.Tetrahedron()
+algo3D.MaxElementVolume(900.)
+
+# Creation of SubMesh
+Regular_1D_1_1 = tetra.Segment(geom=Face_1)
+Nb_Segments_1 = Regular_1D_1_1.NumberOfSegments(5)
+Nb_Segments_1.SetDistrType( 0 )
+Quadrangle_2D = tetra.Quadrangle(geom=Face_1)
+isDone = tetra.Compute()
+submesh = Regular_1D_1_1.GetSubMesh()
+
+# compute the mesh
+tetra.Compute()
+
+# Creation of group
+group = tetra.CreateEmptyGroup( SMESH.FACE, 'Group' )
+nbAdd = group.Add( [ 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76 ] )
+
+# Print information about the mesh
+print "Information about mesh:"
+print "Number of nodes : ", tetra.NbNodes()
+print "Number of edges : ", tetra.NbEdges()
+print "Number of faces : ", tetra.NbFaces()
+print " triangles : ", tetra.NbTriangles()
+print " quadrangles : ", tetra.NbQuadrangles()
+print " polygons : ", tetra.NbPolygons()
+print "Number of volumes : ", tetra.NbVolumes()
+print " tetrahedrons: ", tetra.NbTetras()
+print " hexahedrons : ", tetra.NbHexas()
+print " prisms : ", tetra.NbPrisms()
+print " pyramids : ", tetra.NbPyramids()
+print " polyhedrons : ", tetra.NbPolyhedrons()
+
+# Get Information About Mesh by GetMeshInfo
+print "\nInformation about mesh by GetMeshInfo:"
+info = smesh.GetMeshInfo(tetra)
+keys = info.keys(); keys.sort()
+for i in keys:
+ print " %s : %d" % ( i, info[i] )
+ pass
+
+# Get Information About Group by GetMeshInfo
+print "\nInformation about group by GetMeshInfo:"
+info = smesh.GetMeshInfo(group)
+keys = info.keys(); keys.sort()
+for i in keys:
+ print " %s : %d" % ( i, info[i] )
+ pass
+
+# Get Information About SubMesh by GetMeshInfo
+print "\nInformation about Submesh by GetMeshInfo:"
+info = smesh.GetMeshInfo(submesh)
+keys = info.keys(); keys.sort()
+for i in keys:
+ print " %s : %d" % ( i, info[i] )
+ pass
--- /dev/null
+# Find Element by Point
+
+import geompy
+import smesh
+import SMESH
+
+# Create a geometry to mesh
+box = geompy.MakeBoxDXDYDZ(100,100,100)
+
+# Create a mesh
+mesh = Mesh(box,"Mesh")
+mesh.AutomaticHexahedralization()
+mesh.Compute()
+
+# Create a point
+x,y,z = 0, 0, 1
+
+# Find all elements (except 0D ones) located at the point
+all_elems_except_0D = mesh.FindElementsByPoint(x,y,z)
+assert( len(all_elems_except_0D) == 4)
+
+# Find nodes at the point
+nodes = mesh.FindElementsByPoint(x,y,z, SMESH.NODE )
+assert( len(nodes) == 0)
+assert( len( mesh.FindElementsByPoint(x,y,0, SMESH.NODE)) == 1)
+
+# Find an edge at the point
+edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE )
+assert( len(edges) == 1)
+
+# Find faces at the point
+edges = mesh.FindElementsByPoint(x,y,z, SMESH.FACE )
+assert( len(edges) == 2)
+
+# Find a volume at the point
+vols = mesh.FindElementsByPoint(x,y,z, SMESH.VOLUME )
+assert( len(vols) == 1)
+
+# Find 0D elements at the point
+elems0d = mesh.FindElementsByPoint(x,y,z, SMESH.ELEM0D )
+assert( len(elems0d) == 0)
+
+# Find edges within a group
+group1D = mesh.MakeGroupByIds("1D", SMESH.EDGE, [1,2] )
+edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE, group1D )
FILE_PATTERNS = *.doc
EXCLUDE =
IMAGE_PATH = @srcdir@/images @top_srcdir@/src/Tools/padder/doc/images
-EXAMPLE_PATH = @top_srcdir@/src/SMESH_SWIG
+EXAMPLE_PATH = @top_srcdir@/src/SMESH_SWIG @top_srcdir@/doc/salome/examples
#---------------------------------------------------------------------------
#HTML related options
\anchor example_3d_mesh
<h2>Example of 3d mesh generation:</h2>
-
-\code
-from geompy import *
-import smesh
-
-###
-# Geometry: an assembly of a box, a cylinder and a truncated cone
-# meshed with tetrahedral
-###
-
-# Define values
-name = "ex21_lamp"
-cote = 60
-section = 20
-size = 200
-radius_1 = 80
-radius_2 = 40
-height = 100
-
-# Build a box
-box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote)
-
-# Build a cylinder
-pt1 = MakeVertex(0, 0, cote/3)
-di1 = MakeVectorDXDYDZ(0, 0, 1)
-cyl = MakeCylinder(pt1, di1, section, size)
-
-# Build a truncated cone
-pt2 = MakeVertex(0, 0, size)
-cone = MakeCone(pt2, di1, radius_1, radius_2, height)
-
-# Fuse
-box_cyl = MakeFuse(box, cyl)
-piece = MakeFuse(box_cyl, cone)
-
-# Add to the study
-addToStudy(piece, name)
-
-# Create a group of faces
-group = CreateGroup(piece, ShapeType["FACE"])
-group_name = name + "_grp"
-addToStudy(group, group_name)
-group.SetName(group_name)
-
-# Add faces to the group
-faces = SubShapeAllIDs(piece, ShapeType["FACE"])
-UnionIDs(group, faces)
-
-###
-# Create a mesh
-###
-
-# Define a mesh on a geometry
-tetra = smesh.Mesh(piece, name)
-
-# Define 1D hypothesis
-algo1d = tetra.Segment()
-algo1d.LocalLength(10)
-
-# Define 2D hypothesis
-algo2d = tetra.Triangle()
-algo2d.LengthFromEdges()
-
-# Define 3D hypothesis
-algo3d = tetra.Tetrahedron()
-algo3d.MaxElementVolume(100)
-
-# Compute the mesh
-tetra.Compute()
-
-# Create a groupe of faces
-tetra.Group(group)
-
-\endcode
+\include 3dmesh.py
+<a href="../../examples/SMESH/3dmesh.py">Download this script</a>
Examples of Python scripts for Mesh operations are available by
the following links:
- \subpage tui_measurements_page
- \subpage tui_generate_flat_elements_page
- \subpage tui_work_on_objects_from_gui
+- \subpage tui_prism_3d_algo
*/
/*!
\page tui_cartesian_algo Usage of Body Fitting algorithm
-
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-# create a sphere
-sphere = geompy.MakeSphereR( 50 )
-geompy.addToStudy( sphere, "sphere" )
-
-# create a mesh and assign a "Body Fitting" algo
-mesh = Mesh( sphere )
-cartAlgo = mesh.BodyFitted()
-
-# define a cartesian grid using Coordinates
-coords = range(-100,100,10)
-cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000)
-
-# compute the mesh
-mesh.Compute()
-print "nb hexahedra",mesh.NbHexas()
-print "nb tetrahedra",mesh.NbTetras()
-print "nb polyhedra",mesh.NbPolyhedrons()
-print
-
-# define the grid by setting constant spacing
-cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000)
-
-mesh.Compute()
-print "nb hexahedra",mesh.NbHexas()
-print "nb tetrahedra",mesh.NbTetras()
-print "nb polyhedra",mesh.NbPolyhedrons()
-
-
-# define the grid by setting different spacing in 2 sub-ranges of geometry
-spaceFuns = ["5","10+10*t"]
-cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 )
-
-mesh.Compute()
-print "nb hexahedra",mesh.NbHexas()
-print "nb tetrahedra",mesh.NbTetras()
-print "nb polyhedra",mesh.NbPolyhedrons()
-print
-
-\endcode
+\include cartesian_algo.py
+<a href="../../examples/SMESH/cartesian_algo.py">Download this script</a>
*/
<br>
<h2>Construction of a Mesh</h2>
-
-\code
-import geompy
-import smesh
-
-# create a box
-box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
-idbox = geompy.addToStudy(box, "box")
-
-# create a mesh
-tetra = smesh.Mesh(box, "MeshBox")
-
-algo1D = tetra.Segment()
-algo1D.NumberOfSegments(7)
-
-algo2D = tetra.Triangle()
-algo2D.MaxElementArea(800.)
-
-algo3D = tetra.Tetrahedron()
-algo3D.MaxElementVolume(900.)
-
-# compute the mesh
-ret = tetra.Compute()
-if ret == 0:
- print "problem when computing the mesh"
-else:
- print "mesh computed"
- pass
-\endcode
+\include creating_meshes_ex01.py
+<a href="../../examples/SMESH/creating_meshes_ex01.py">Download this script</a>
<br>
\anchor tui_construction_submesh
<h2>Construction of a Submesh</h2>
-
-\code
-from geompy import *
-import smesh
-
-# create a box
-box = MakeBoxDXDYDZ(10., 10., 10.)
-addToStudy(box, "Box")
-
-# select one edge of the box for definition of a local hypothesis
-p5 = MakeVertex(5., 0., 0.)
-EdgeX = GetEdgeNearPoint(box, p5)
-addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
-
-# create a hexahedral mesh on the box
-quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
-
-# create a regular 1D algorithm for the faces
-algo1D = quadra.Segment()
-
-# define "NumberOfSegments" hypothesis to cut
-# all the edges in a fixed number of segments
-algo1D.NumberOfSegments(4)
-
-# create a quadrangle 2D algorithm for the faces
-quadra.Quadrangle()
-
-# construct a submesh on the edge with a local hypothesis
-algo_local = quadra.Segment(EdgeX)
-
-# define "Arithmetic1D" hypothesis to cut the edge in several segments with increasing arithmetic length
-algo_local.Arithmetic1D(1, 4)
-
-# define "Propagation" hypothesis that propagates all other hypotheses
-# on all edges of the opposite side in case of quadrangular faces
-algo_local.Propagation()
-
-# compute the mesh
-quadra.Compute()
-
-\endcode
+\include creating_meshes_ex02.py
+<a href="../../examples/SMESH/creating_meshes_ex02.py">Download this script</a>
<br>
<h2>Change priority of submeshes in Mesh</h2>
-
-\code
-import salome
-import geompy
-import smesh
-import SMESH
-
-Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
-[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"])
-
-# create Mesh object on Box shape
-Mesh_1 = smesh.Mesh(Box_1)
-
-# assign mesh algorithms
-Regular_1D = Mesh_1.Segment()
-Nb_Segments_1 = Regular_1D.NumberOfSegments(20)
-Nb_Segments_1.SetDistrType( 0 )
-MEFISTO_2D = Mesh_1.Triangle()
-Max_Element_Area_1 = MEFISTO_2D.MaxElementArea(1200)
-Tetrahedron = Mesh_1.Tetrahedron()
-Max_Element_Volume_1 = Tetrahedron.MaxElementVolume(40000)
-
-# create submesh and assign algorithms on Face_1
-Regular_1D_1 = Mesh_1.Segment(geom=Face_1)
-Nb_Segments_2 = Regular_1D_1.NumberOfSegments(4)
-Nb_Segments_2.SetDistrType( 0 )
-MEFISTO_2D_1 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_1)
-Length_From_Edges_2D = MEFISTO_2D_1.LengthFromEdges()
-SubMesh_1 = MEFISTO_2D_1.GetSubMesh()
-
-# create submesh and assign algorithms on Face_2
-Regular_1D_2 = Mesh_1.Segment(geom=Face_2)
-Nb_Segments_3 = Regular_1D_2.NumberOfSegments(8)
-Nb_Segments_3.SetDistrType( 0 )
-MEFISTO_2D_2 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_2)
-Length_From_Edges_2D_1 = MEFISTO_2D_2.LengthFromEdges()
-SubMesh_2 = MEFISTO_2D_2.GetSubMesh()
-
-# create submesh and assign algorithms on Face_3
-Regular_1D_3 = Mesh_1.Segment(geom=Face_3)
-Nb_Segments_4 = Regular_1D_3.NumberOfSegments(12)
-Nb_Segments_4.SetDistrType( 0 )
-MEFISTO_2D_3 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_3)
-Length_From_Edges_2D_2 = MEFISTO_2D_3.LengthFromEdges()
-SubMesh_3 = MEFISTO_2D_3.GetSubMesh()
-
-# check exisiting submesh priority order
-[ [ SubMesh_1, SubMesh_3, SubMesh_2 ] ] = Mesh_1.GetMeshOrder()
-# set new submesh order
-isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_1, SubMesh_2, SubMesh_3 ] ])
-# compute mesh
-isDone = Mesh_1.Compute()
-
-# clear mesh result and compute with other submesh order
-Mesh_1.Clear()
-isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_2, SubMesh_1, SubMesh_3 ] ])
-isDone = Mesh_1.Compute()
-
-\endcode
+\include creating_meshes_ex03.py
+<a href="../../examples/SMESH/creating_meshes_ex03.py">Download this script</a>
<br>
\anchor tui_editing_mesh
<h2>Editing of a mesh</h2>
-
-\code
-import geompy
-import smesh
-
-def PrintMeshInfo(theMesh):
- aMesh = theMesh.GetMesh()
- print "Information about mesh:"
- print "Number of nodes : ", aMesh.NbNodes()
- print "Number of edges : ", aMesh.NbEdges()
- print "Number of faces : ", aMesh.NbFaces()
- print "Number of volumes : ", aMesh.NbVolumes()
- pass
-
-# create a box
-box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
-geompy.addToStudy(box, "box")
-
-# select one edge of the box for definition of a local hypothesis
-subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"])
-edge = subShapeList[0]
-name = geompy.SubShapeName(edge, box)
-geompy.addToStudyInFather(box, edge, name)
-
-# create a mesh
-tria = smesh.Mesh(box, "Mesh 2D")
-algo1D = tria.Segment()
-hyp1 = algo1D.NumberOfSegments(3)
-algo2D = tria.Triangle()
-hyp2 = algo2D.MaxElementArea(10.)
-
-# create a sub-mesh
-algo_local = tria.Segment(edge)
-hyp3 = algo_local.Arithmetic1D(1, 6)
-hyp4 = algo_local.Propagation()
-
-# compute the mesh
-tria.Compute()
-PrintMeshInfo(tria)
-
-# remove a local hypothesis
-mesh = tria.GetMesh()
-mesh.RemoveHypothesis(edge, hyp4)
-
-# compute the mesh
-tria.Compute()
-PrintMeshInfo(tria)
-
-# change the value of the 2D hypothesis
-hyp2.SetMaxElementArea(2.)
-
-# compute the mesh
-tria.Compute()
-PrintMeshInfo(tria)
-\endcode
+\include creating_meshes_ex04.py
+<a href="../../examples/SMESH/creating_meshes_ex04.py">Download this script</a>
<br>
\anchor tui_export_mesh
<h2>Export of a Mesh</h2>
-
-\code
-import geompy
-import smesh
-
-# create a box
-box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
-idbox = geompy.addToStudy(box, "box")
-
-# create a mesh
-tetra = smesh.Mesh(box, "MeshBox")
-
-algo1D = tetra.Segment()
-algo1D.NumberOfSegments(7)
-
-algo2D = tetra.Triangle()
-algo2D.MaxElementArea(800.)
-
-algo3D = tetra.Tetrahedron()
-algo3D.MaxElementVolume(900.)
-
-# compute the mesh
-tetra.Compute()
-
-# export the mesh in a MED file
-tetra.ExportMED("/tmp/meshMED.med", 0)
-
-# export a group in a MED file
-face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] # a box side
-group = tetra.GroupOnGeom( face, "face group" ) # group of 2D elements on the <face>
-tetra.ExportMED("/tmp/groupMED.med", meshPart=group)
-\endcode
+\include creating_meshes_ex05.py
+<a href="../../examples/SMESH/creating_meshes_ex05.py">Download this script</a>
<br>
<h2>How to mesh a cylinder with hexahedrons?</h2>
Here you can see an example of python script, creating a hexahedral
mesh on a cylinder. And a picture below the source code of the script,
demonstrating the resulting mesh.
-\include ex24_cylinder.py
+\include creating_meshes_ex06.py
+<a href="../../examples/SMESH/creating_meshes_ex06.py">Download this script</a>
\image html mesh_cylinder_hexa.png
<br>
\anchor tui_building_compound
<h2>Building a compound of meshes</h2>
-\dontinclude SMESH_BuildCompound.py
-\skipline import geompy
-\until #end
+\include creating_meshes_ex07.py
+<a href="../../examples/SMESH/creating_meshes_ex07.py">Download this script</a>
<br>
\anchor tui_copy_mesh
<h2>Mesh Copying</h2>
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-# make geometry of a box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0]
-
-# generate 3D mesh
-mesh = Mesh(box)
-localAlgo = mesh.Triangle(face)
-mesh.AutomaticHexahedralization()
-
-# objects to copy
-fGroup = mesh.GroupOnGeom( face, "2D on face")
-nGroup = mesh.GroupOnGeom( face, "nodes on face", NODE)
-subMesh = localAlgo.GetSubMesh()
-
-# make a new mesh by copying different parts of the mesh
-
-# 1. copy the whole mesh
-newMesh = CopyMesh( mesh, "whole mesh copy")
-
-# 2. copy a group of 2D elements along with groups
-newMesh = CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True)
-
-# 3. copy a group of nodes with preseving their ids
-newMesh = CopyMesh( nGroup, "node group copy", toKeepIDs=True)
-
-# 4. copy some faces
-faceIds = fGroup.GetIDs()[-10:]
-newMesh = CopyMesh( mesh.GetIDSource( faceIds, FACE ), "some faces copy")
-
-# 5. copy some nodes
-nodeIds = nGroup.GetIDs()[-10:]
-newMesh = CopyMesh( mesh.GetIDSource( nodeIds, NODE), "some nodes copy")
-
-# 6. copy a sub-mesh
-newMesh = CopyMesh( subMesh, "submesh copy" )
-\endcode
+\include creating_meshes_ex08.py
+<a href="../../examples/SMESH/creating_meshes_ex08.py">Download this script</a>
*/
<br>
\anchor tui_1d_arithmetic
<h3>Arithmetic 1D</h3>
-
-\code
-import geompy
-import smesh
-
-# create a box
-box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
-geompy.addToStudy(box, "Box")
-
-# create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
-
-# create a Regular 1D algorithm for edges
-algo1D = hexa.Segment()
-
-# optionally reverse node distribution on certain edges
-allEdges = geompy.SubShapeAllSortedIDs( box, geompy.ShapeType["EDGE"])
-reversedEdges = [ allEdges[0], allEdges[4] ]
-
-# define "Arithmetic1D" hypothesis to cut all edges in several segments with increasing arithmetic length
-algo1D.Arithmetic1D(1, 4, reversedEdges)
-
-# create a quadrangle 2D algorithm for faces
-hexa.Quadrangle()
-
-# create a hexahedron 3D algorithm for solids
-hexa.Hexahedron()
-
-# compute the mesh
-hexa.Compute()
-\endcode
+\include defining_hypotheses_ex01.py
+<a href="../../examples/SMESH/defining_hypotheses_ex01.py">Download this script</a>
<br>
\anchor tui_deflection_1d
<h3>Deflection 1D and Number of Segments</h3>
-
-\code
-import geompy
-import smesh
-
-# create a face from arc and straight segment
-px = geompy.MakeVertex(100., 0. , 0. )
-py = geompy.MakeVertex(0. , 100., 0. )
-pz = geompy.MakeVertex(0. , 0. , 100.)
-
-exy = geompy.MakeEdge(px, py)
-arc = geompy.MakeArc(py, pz, px)
-
-wire = geompy.MakeWire([exy, arc])
-
-isPlanarFace = 1
-face1 = geompy.MakeFace(wire, isPlanarFace)
-geompy.addToStudy(face1,"Face1")
-
-# get edges from the face
-e_straight,e_arc = geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"])
-geompy.addToStudyInFather(face1, e_arc, "Arc Edge")
-
-# create hexahedral mesh
-hexa = smesh.Mesh(face1, "Face : triangle mesh")
-
-# define "NumberOfSegments" hypothesis to cut a straight edge in a fixed number of segments
-algo1D = hexa.Segment()
-algo1D.NumberOfSegments(6)
-
-# define "MaxElementArea" hypothesis
-algo2D = hexa.Triangle()
-algo2D.MaxElementArea(70.0)
-
-# define a local "Deflection1D" hypothesis on the arc
-algo_local = hexa.Segment(e_arc)
-algo_local.Deflection1D(1.0)
-
-# compute the mesh
-hexa.Compute()
-\endcode
+\include defining_hypotheses_ex02.py
+<a href="../../examples/SMESH/defining_hypotheses_ex02.py">Download this script</a>
<br>
\anchor tui_start_and_end_length
<h3>Start and End Length</h3>
-
-\code
-from geompy import *
-import smesh
-
-# create a box
-box = MakeBoxDXDYDZ(10., 10., 10.)
-addToStudy(box, "Box")
-
-# get one edge of the box to put local hypothesis on
-p5 = MakeVertex(5., 0., 0.)
-EdgeX = GetEdgeNearPoint(box, p5)
-addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
-
-# create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
-
-# set algorithms
-algo1D = hexa.Segment()
-hexa.Quadrangle()
-hexa.Hexahedron()
-
-# define "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
-algo1D.NumberOfSegments(4)
-
-# create a local hypothesis
-algo_local = hexa.Segment(EdgeX)
-
-# define "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
-algo_local.StartEndLength(1, 6)
-
-# define "Propagation" hypothesis that propagates all other hypothesis
-# on all edges on the opposite side in case of quadrangular faces
-algo_local.Propagation()
-
-# compute the mesh
-hexa.Compute()
-\endcode
+\include defining_hypotheses_ex03.py
+<a href="../../examples/SMESH/defining_hypotheses_ex03.py">Download this script</a>
<br>
\anchor tui_average_length
<h3>Local Length</h3>
-
-\code
-from geompy import *
-import smesh
-
-# create a box
-box = MakeBoxDXDYDZ(10., 10., 10.)
-addToStudy(box, "Box")
-
-# get one edge of the box to put local hypothesis on
-p5 = MakeVertex(5., 0., 0.)
-EdgeX = GetEdgeNearPoint(box, p5)
-addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
-
-# create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
-
-# set algorithms
-algo1D = hexa.Segment()
-hexa.Quadrangle()
-hexa.Hexahedron()
-
-# define "NumberOfSegments" hypothesis to cut all edges in a fixed number of segments
-algo1D.NumberOfSegments(4)
-
-# create a sub-mesh
-algo_local = hexa.Segment(EdgeX)
-
-# define "LocalLength" hypothesis to cut an edge in several segments with the same length
-algo_local.LocalLength(2.)
-
-# define "Propagation" hypothesis that propagates all other hypothesis
-# on all edges on the opposite side in case of quadrangular faces
-algo_local.Propagation()
-
-# compute the mesh
-hexa.Compute()
-\endcode
+\include defining_hypotheses_ex04.py
+<a href="../../examples/SMESH/defining_hypotheses_ex04.py">Download this script</a>
<br><h2>Defining 2D and 3D hypotheses</h2>
<br>
\anchor tui_max_element_area
<h3>Maximum Element Area</h3>
-
-\code
-import geompy
-import smesh
-import salome
-
-# create a face
-px = geompy.MakeVertex(100., 0. , 0. )
-py = geompy.MakeVertex(0. , 100., 0. )
-pz = geompy.MakeVertex(0. , 0. , 100.)
-
-vxy = geompy.MakeVector(px, py)
-arc = geompy.MakeArc(py, pz, px)
-wire = geompy.MakeWire([vxy, arc])
-
-isPlanarFace = 1
-face = geompy.MakeFace(wire, isPlanarFace)
-
-# add the face in the study
-id_face = geompy.addToStudy(face, "Face to be meshed")
-
-# create a mesh
-tria_mesh = smesh.Mesh(face, "Face : triangulation")
-
-# define 1D meshing:
-algo = tria_mesh.Segment()
-algo.NumberOfSegments(20)
-
-# define 2D meshing:
-
-# assign triangulation algorithm
-algo = tria_mesh.Triangle()
-
-# apply "Max Element Area" hypothesis to each triangle
-algo.MaxElementArea(100)
-
-# compute the mesh
-tria_mesh.Compute()
-\endcode
+\include defining_hypotheses_ex05.py
+<a href="../../examples/SMESH/defining_hypotheses_ex05.py">Download this script</a>
<br>
\anchor tui_max_element_volume
<h3>Maximum Element Volume</h3>
-
-\code
-import geompy
-import smesh
-
-# create a cylinder
-cyl = geompy.MakeCylinderRH(30., 50.)
-geompy.addToStudy(cyl, "cyl")
-
-# create a mesh on the cylinder
-tetra = smesh.Mesh(cyl, "Cylinder : tetrahedrical mesh")
-
-# assign algorithms
-algo1D = tetra.Segment()
-algo2D = tetra.Triangle()
-algo3D = tetra.Tetrahedron()
-
-# assign 1D and 2D hypotheses
-algo1D.NumberOfSegments(7)
-algo2D.MaxElementArea(150.)
-
-# assign Max Element Volume hypothesis
-algo3D.MaxElementVolume(200.)
-
-# compute the mesh
-ret = tetra.Compute()
-if ret == 0:
- print "probleme when computing the mesh"
-else:
- print "Computation succeded"
-\endcode
+\include defining_hypotheses_ex06.py
+<a href="../../examples/SMESH/defining_hypotheses_ex06.py">Download this script</a>
<br>
\anchor tui_length_from_edges
<h3>Length from Edges</h3>
-
-\code
-import geompy
-import smesh
-
-# create sketchers
-sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
-sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
-
-# create a face from two wires
-isPlanarFace = 1
-face1 = geompy.MakeFaces([sketcher1, sketcher2], isPlanarFace)
-geompy.addToStudy(face1, "Face1")
-
-# create a mesh
-tria = smesh.Mesh(face1, "Face : triangle 2D mesh")
-
-# Define 1D meshing
-algo1D = tria.Segment()
-algo1D.NumberOfSegments(2)
-
-# create and assign the algorithm for 2D meshing with triangles
-algo2D = tria.Triangle()
-
-# create and assign "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
-algo2D.LengthFromEdges()
-
-# compute the mesh
-tria.Compute()
-\endcode
+\include defining_hypotheses_ex07.py
+<a href="../../examples/SMESH/defining_hypotheses_ex07.py">Download this script</a>
<br><h2>Defining Additional Hypotheses</h2>
<br>
\anchor tui_propagation
<h3>Propagation</h3>
-
-\code
-from geompy import *
-import smesh
-
-# create a box
-box = MakeBoxDXDYDZ(10., 10., 10.)
-addToStudy(box, "Box")
-
-# get one edge of the box to put local hypothesis on
-p5 = MakeVertex(5., 0., 0.)
-EdgeX = GetEdgeNearPoint(box, p5)
-addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]")
-
-# create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
-
-# set global algorithms and hypotheses
-algo1D = hexa.Segment()
-hexa.Quadrangle()
-hexa.Hexahedron()
-algo1D.NumberOfSegments(4)
-
-# create a sub-mesh with local 1D hypothesis and propagation
-algo_local = hexa.Segment(EdgeX)
-
-# define "Arithmetic1D" hypothesis to cut an edge in several segments with increasing length
-algo_local.Arithmetic1D(1, 4)
-
-# define "Propagation" hypothesis that propagates all other 1D hypotheses
-# from all edges on the opposite side of a face in case of quadrangular faces
-algo_local.Propagation()
-
-# compute the mesh
-hexa.Compute()
-\endcode
+\include defining_hypotheses_ex08.py
+<a href="../../examples/SMESH/defining_hypotheses_ex08.py">Download this script</a>
<br>
\anchor tui_defining_meshing_algos
<h2>Defining Meshing Algorithms</h2>
-
-\code
-import geompy
-import smesh
-
-# create a box
-box = geompy.MakeBoxDXDYDZ(10., 10., 10.)
-geompy.addToStudy(box, "Box")
-
-# 1. Create a hexahedral mesh on the box
-hexa = smesh.Mesh(box, "Box : hexahedrical mesh")
-
-# create a Regular 1D algorithm for edges
-algo1D = hexa.Segment()
-
-# create a quadrangle 2D algorithm for faces
-algo2D = hexa.Quadrangle()
-
-# create a hexahedron 3D algorithm for solids
-algo3D = hexa.Hexahedron()
-
-# define hypotheses
-algo1D.Arithmetic1D(1, 4)
-
-# compute the mesh
-hexa.Compute()
-
-# 2. Create a tetrahedral mesh on the box
-tetra = smesh.Mesh(box, "Box : tetrahedrical mesh")
-
-# create a Regular 1D algorithm for edges
-algo1D = tetra.Segment()
-
-# create a Mefisto 2D algorithm for faces
-algo2D = tetra.Triangle()
-
-# create a 3D algorithm for solids
-algo3D = tetra.Tetrahedron()
-
-# define hypotheses
-algo1D.Arithmetic1D(1, 4)
-algo2D.LengthFromEdges()
-
-# compute the mesh
-tetra.Compute()
-
-\endcode
+\include defining_hypotheses_ex09.py
+<a href="../../examples/SMESH/defining_hypotheses_ex09.py">Download this script</a>
<br>
\anchor tui_projection
<h3>Projection Algorithms</h3>
-
-\code
-# Project prisms from one meshed box to another mesh on the same box
-
-from smesh import *
-
-# Prepare geometry
-
-# Create a parallelepiped
-box = geompy.MakeBoxDXDYDZ(200, 100, 70)
-geompy.addToStudy( box, "box" )
-
-# Get geom faces to mesh with triangles in the 1ts and 2nd meshes
-faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-# 2 adjacent faces of the box
-f1 = faces[2]
-f2 = faces[0]
-# face opposite to f2
-f2opp = faces[1]
-
-# Get vertices used to specify how to associate sides of faces at projection
-[v1F1, v2F1] = geompy.SubShapeAll(f1, geompy.ShapeType["VERTEX"])[:2]
-[v1F2, v2F2] = geompy.SubShapeAll(f2, geompy.ShapeType["VERTEX"])[:2]
-geompy.addToStudyInFather( box, v1F1, "v1F1" )
-geompy.addToStudyInFather( box, v2F1, "v2F1" )
-geompy.addToStudyInFather( box, v1F2, "v1F2" )
-geompy.addToStudyInFather( box, v2F2, "v2F2" )
-
-# Make group of 3 edges of f1 and f2
-edgesF1 = geompy.CreateGroup(f1, geompy.ShapeType["EDGE"])
-geompy.UnionList( edgesF1, geompy.SubShapeAll(f1, geompy.ShapeType["EDGE"])[:3])
-edgesF2 = geompy.CreateGroup(f2, geompy.ShapeType["EDGE"])
-geompy.UnionList( edgesF2, geompy.SubShapeAll(f2, geompy.ShapeType["EDGE"])[:3])
-geompy.addToStudyInFather( box, edgesF1, "edgesF1" )
-geompy.addToStudyInFather( box, edgesF2, "edgesF2" )
-
-
-# Make the source mesh with prisms
-src_mesh = Mesh(box, "Source mesh")
-src_mesh.Segment().NumberOfSegments(9,10)
-src_mesh.Quadrangle()
-src_mesh.Hexahedron()
-src_mesh.Triangle(f1) # triangular sumbesh
-src_mesh.Compute()
-
-
-# Mesh the box using projection algoritms
-
-# Define the same global 1D and 2D hypotheses
-tgt_mesh = Mesh(box, "Target mesh")
-tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True)
-tgt_mesh.Quadrangle()
-
-# Define Projection 1D algorithm to project 1d mesh elements from group edgesF2 to edgesF1
-# It is actually not needed, just a demonstration
-proj1D = tgt_mesh.Projection1D( edgesF1 )
-# each vertex must be at the end of a connected group of edges (or a sole edge)
-proj1D.SourceEdge( edgesF2, src_mesh, v2F1, v2F2 )
-
-# Define 2D hypotheses to project triangles from f1 face of the source mesh to
-# f2 face in the target mesh. Vertices specify how to associate sides of faces
-proj2D = tgt_mesh.Projection2D( f2 )
-proj2D.SourceFace( f1, src_mesh, v1F1, v1F2, v2F1, v2F2 )
-
-# 2D hypotheses to project triangles from f2 of target mesh to the face opposite to f2.
-# Association of face sides is default
-proj2D = tgt_mesh.Projection2D( f2opp )
-proj2D.SourceFace( f2 )
-
-# 3D hypotheses to project prisms from the source to the target mesh
-proj3D = tgt_mesh.Projection3D()
-proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 )
-tgt_mesh.Compute()
-
-# Move the source mesh to visualy compare the two meshes
-src_mesh.TranslateObject( src_mesh, MakeDirStruct( 210, 0, 0 ), Copy=False)
-
-\endcode
+\include defining_hypotheses_ex10.py
+<a href="../../examples/SMESH/defining_hypotheses_ex10.py">Download this script</a>
<h3>Projection 1D2D</h3>
-
-\code
-# Project triangles from one meshed face to another mesh on the same box
-
-from smesh import *
-
-# Prepare geometry
-
-# Create a box
-box = geompy.MakeBoxDXDYDZ(100, 100, 100)
-
-# Get geom faces to mesh with triangles in the 1ts and 2nd meshes
-faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-# 2 adjacent faces of the box
-Face_1 = faces[2]
-Face_2 = faces[0]
-
-geompy.addToStudy( box, 'box' )
-geompy.addToStudyInFather( box, Face_1, 'Face_1' )
-geompy.addToStudyInFather( box, Face_2, 'Face_2' )
-
-# Make the source mesh with Netgem2D
-src_mesh = Mesh(Face_1, "Source mesh")
-src_mesh.Segment().NumberOfSegments(15)
-src_mesh.Triangle()
-src_mesh.Compute()
-
-# Mesh the target mesh using the algoritm Projection1D2D
-tgt_mesh = smesh.Mesh(Face_2, "Target mesh")
-tgt_mesh.Projection1D2D().SourceFace(Face_1,src_mesh)
-tgt_mesh.Compute()
-\endcode
+\include defining_hypotheses_ex11.py
+<a href="../../examples/SMESH/defining_hypotheses_ex11.py">Download this script</a>
<br>
\anchor tui_fixed_points
<h2>1D Mesh with Fixed Points example</h2>
-
-\code
-import salome
-import geompy
-import smesh
-import StdMeshers
-
-# Create face and explode it on edges
-face = geompy.MakeFaceHW(100, 100, 1)
-edges = geompy.SubShapeAllSorted(face, geompy.ShapeType["EDGE"])
-geompy.addToStudy( face, "Face" )
-
-# get the first edge from exploded result
-edge1 = geompy.GetSubShapeID(face, edges[0])
-
-# Define Mesh on previously created face
-Mesh_1 = smesh.Mesh(face)
-
-# Create Fixed Point 1D hypothesis and define parameters.
-# Note: values greater than 1.0 and less than 0.0 are not taken into account;
-# duplicated values are removed. Also, if not specified explicitly, values 0.0 and 1.0
-# add added automatically.
-# The number of segments should correspond to the number of points (NbSeg = NbPnt-1);
-# extra values of segments splitting parameter are not taken into account,
-# while missing values are considered to be equal to 1.
-Fixed_points_1D_1 = smesh.CreateHypothesis('FixedPoints1D')
-Fixed_points_1D_1.SetPoints( [ 1.1, 0.9, 0.5, 0.0, 0.5, -0.3 ] )
-Fixed_points_1D_1.SetNbSegments( [ 3, 1, 2 ] )
-Fixed_points_1D_1.SetReversedEdges( [edge1] )
-
-# Add hypothesis to mesh and define 2D parameters
-Mesh_1.AddHypothesis(Fixed_points_1D_1)
-Regular_1D = Mesh_1.Segment()
-Quadrangle_2D = Mesh_1.Quadrangle()
-# Compute mesh
-Mesh_1.Compute()
-\endcode
+\include defining_hypotheses_ex12.py
+<a href="../../examples/SMESH/defining_hypotheses_ex12.py">Download this script</a>
\anchor tui_radial_quadrangle
<h2> Radial Quadrangle 1D2D example </h2>
-\code
-from smesh import *
-
-SetCurrentStudy(salome.myStudy)
-
-# Create face from the wire and add to study
-Face = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:R 90:C 20 90:WF", [0, 0, 0, 1, 0, 0, 0, 0, 1])
-geompy.addToStudy(Face,"Face")
-edges = geompy.SubShapeAllSorted(Face, geompy.ShapeType["EDGE"])
-circle, radius1, radius2 = edges
-geompy.addToStudyInFather(Face, radius1,"radius1")
-geompy.addToStudyInFather(Face, radius2,"radius2")
-geompy.addToStudyInFather(Face, circle,"circle")
-
-
-# Define geometry for mesh, and Radial Quadrange algorithm
-mesh = smesh.Mesh(Face)
-radial_Quad_algo = mesh.Quadrangle(algo=RADIAL_QUAD)
-
-# The Radial Quadrange algorithm can work without any hypothesis
-# In this case it uses "Default Nb of Segments" preferences parameter to discretize edges
-mesh.Compute()
-
-# The Radial Quadrange uses global or local 1d hypotheses if it does
-# not have its own hypotheses.
-# Define global hypotheses to discretize radial edges and a local one for circular edge
-global_Nb_Segments = mesh.Segment().NumberOfSegments(5)
-local_Nb_Segments = mesh.Segment(circle).NumberOfSegments(10)
-mesh.Compute()
-
-# Define own parameters of Radial Quadrange algorithm
-radial_Quad_algo.NumberOfLayers( 4 )
-mesh.Compute()
-\endcode
+\include defining_hypotheses_ex13.py
+<a href="../../examples/SMESH/defining_hypotheses_ex13.py">Download this script</a>
\anchor tui_quadrangle_parameters
<h2>Quadrangle Parameters example 1 (meshing a face with 3 edges) </h2>
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-# Get 1/4 part from the disk face.
-Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100)
-Disk_1 = geompy.MakeDiskR(100, 1)
-Common_1 = geompy.MakeCommon(Disk_1, Box_1)
-geompy.addToStudy( Disk_1, "Disk_1" )
-geompy.addToStudy( Box_1, "Box_1" )
-geompy.addToStudy( Common_1, "Common_1" )
-
-# Set the Geometry for meshing
-Mesh_1 = smesh.Mesh(Common_1)
-
-
-# Define 1D hypothesis and compute the mesh
-Regular_1D = Mesh_1.Segment()
-Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
-Nb_Segments_1.SetDistrType( 0 )
-
-# Create Quadrangle parameters and define the Base Vertex.
-Quadrangle_2D = Mesh_1.Quadrangle().TriangleVertex( 8 )
-
-Mesh_1.Compute()
-\endcode
+\include defining_hypotheses_ex14.py
+<a href="../../examples/SMESH/defining_hypotheses_ex14.py">Download this script</a>
<h2>Quadrangle Parameters example 2 (using different types) </h2>
-\code
-import geompy
-import smesh
-import StdMeshers
-
-# Make quadrangle face and explode it on edges.
-Vertex_1 = geompy.MakeVertex(0, 0, 0)
-Vertex_2 = geompy.MakeVertex(40, 0, 0)
-Vertex_3 = geompy.MakeVertex(40, 30, 0)
-Vertex_4 = geompy.MakeVertex(0, 30, 0)
-Quadrangle_Face_1 = geompy.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2)
-[Edge_1,Edge_2,Edge_3,Edge_4] = geompy.SubShapeAllSorted(Quadrangle_Face_1, geompy.ShapeType["EDGE"])
-geompy.addToStudy( Vertex_1, "Vertex_1" )
-geompy.addToStudy( Vertex_2, "Vertex_2" )
-geompy.addToStudy( Vertex_3, "Vertex_3" )
-geompy.addToStudy( Vertex_4, "Vertex_4" )
-geompy.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" )
-geompy.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" )
-
-# Set the Geometry for meshing
-Mesh_1 = smesh.Mesh(Quadrangle_Face_1)
-
-# Create Quadrangle parameters and
-# define the Type as Quadrangle Preference
-Quadrangle_Parameters_1 = smesh.CreateHypothesis('QuadrangleParams')
-Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_QUADRANGLE_PREF )
-
-# Define other hypotheses and algorithms
-Regular_1D = Mesh_1.Segment()
-Nb_Segments_1 = Regular_1D.NumberOfSegments(4)
-Nb_Segments_1.SetDistrType( 0 )
-status = Mesh_1.AddHypothesis(Quadrangle_Parameters_1)
-Quadrangle_2D = Mesh_1.Quadrangle()
-
-# Define submesh on one edge to provide different number of segments
-Regular_1D_1 = Mesh_1.Segment(geom=Edge_2)
-Nb_Segments_2 = Regular_1D_1.NumberOfSegments(10)
-Nb_Segments_2.SetDistrType( 0 )
-SubMesh_1 = Regular_1D_1.GetSubMesh()
-
-# Compute mesh (with Quadrangle Preference type)
-isDone = Mesh_1.Compute()
-
-# Change type to Reduced and compute again
-Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_REDUCED )
-isDone = Mesh_1.Compute()
-\endcode
+\include defining_hypotheses_ex15.py
+<a href="../../examples/SMESH/defining_hypotheses_ex15.py">Download this script</a>
\anchor tui_import
<h2>"Use Existing Elements" example </h2>
-\code
-
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-# Make a patritioned box
-
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-
-N = geompy.MakeVectorDXDYDZ( 1,0,0 )
-O = geompy.MakeVertex( 50,0,0 )
-plane = geompy.MakePlane( O, N, 200 ) # plane YOZ
-
-shape2boxes = geompy.MakeHalfPartition( box, plane )
-boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"])
-
-geompy.addToStudy( boxes[0], "boxes[0]")
-geompy.addToStudy( boxes[1], "boxes[1]")
-midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5]
-geompy.addToStudyInFather( boxes[0], midFace0, "middle Face")
-midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0]
-geompy.addToStudyInFather( boxes[1], midFace1, "middle Face")
-
-# Mesh one of boxes with quadrangles. It is a source mesh
-
-srcMesh = Mesh(boxes[0], "source mesh") # box coloser to CS origin
-nSeg1 = srcMesh.Segment().NumberOfSegments(4)
-srcMesh.Quadrangle()
-srcMesh.Compute()
-srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", FACE )
-
-# Import faces from midFace0 to the target mesh
-
-tgtMesh = Mesh(boxes[1], "target mesh")
-importAlgo = tgtMesh.UseExisting2DElements(midFace1)
-import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
-tgtMesh.Segment().NumberOfSegments(3)
-tgtMesh.Quadrangle()
-tgtMesh.Compute()
-
-# Import the whole source mesh with groups
-import2hyp.SetCopySourceMesh(True,True)
-tgtMesh.Compute()
-\endcode
+\include defining_hypotheses_ex16.py
+<a href="../../examples/SMESH/defining_hypotheses_ex16.py">Download this script</a>
\anchor tui_viscous_layers
<h2>Viscous layers construction</h2>
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-X = geompy.MakeVectorDXDYDZ( 1,0,0 )
-O = geompy.MakeVertex( 100,50,50 )
-plane = geompy.MakePlane( O, X, 200 ) # plane YZ
-
-box = geompy.MakeBoxDXDYDZ(200,100,100)
-
-shape = geompy.MakeHalfPartition( box, plane )
-
-faces = geompy.SubShapeAllSorted(shape, geompy.ShapeType["FACE"])
-face1 = faces[1]
-ignoreFaces = [ faces[0], faces[-1]]
-
-geompy.addToStudy( shape, "shape" )
-geompy.addToStudyInFather( shape, face1, "face1")
-
-
-mesh = Mesh(shape, "CFD")
-
-mesh.Segment().NumberOfSegments( 4 )
-
-mesh.Triangle()
-mesh.Quadrangle(face1)
-mesh.Compute()
-algo3D = mesh.Tetrahedron()
-
-thickness = 20
-numberOfLayers = 10
-stretchFactor = 1.5
-layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,ignoreFaces)
-
-mesh.Compute()
-
-mesh.MakeGroup("Tetras",VOLUME,FT_ElemGeomType,"=",Geom_TETRA)
-mesh.MakeGroup("Pyras",VOLUME,FT_ElemGeomType,"=",Geom_PYRAMID)
-mesh.MakeGroup("Prims",VOLUME,FT_ElemGeomType,"=",Geom_PENTA)
-
-\endcode
+\include defining_hypotheses_ex17.py
+<a href="../../examples/SMESH/defining_hypotheses_ex17.py">Download this script</a>
*/
- functor type should be \a smesh.FT_AspectRatio
- threshold is floating point value (aspect ratio)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get faces with aspect ratio > 6.5
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, 6.5)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with aspect ratio > 6.5:", len(ids)
-\endcode
+\include filters_ex01.py
+<a href="../../examples/SMESH/filters_ex01.py">Download this script</a>
\sa \ref tui_aspect_ratio
- functor type is \a smesh.FT_AspectRatio3D
- threshold is floating point value (aspect ratio)
-\code
-# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
-# get volumes with aspect ratio < 2.0
-filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_LessThan, 2.0)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of volumes with aspect ratio < 2.0:", len(ids)
-\endcode
+\include filters_ex02.py
+<a href="../../examples/SMESH/filters_ex02.py">Download this script</a>
\sa \ref tui_aspect_ratio_3d
- functor type is \a smesh.FT_Warping
- threshold is floating point value (warping angle)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get faces with warping angle = 2.0e-13 with tolerance 5.0e-14
-criterion = smesh.GetCriterion(smesh.FACE, smesh.FT_Warping, smesh.FT_EqualTo, 2.0e-13)
-criterion.Tolerance = 5.0e-14
-filter = smesh.CreateFilterManager().CreateFilter()
-filter.SetCriteria([criterion])
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids)
-\endcode
+\include filters_ex03.py
+<a href="../../examples/SMESH/filters_ex03.py">Download this script</a>
\sa \ref tui_warping
- functor type is \a smesh.FT_MinimumAngle
- threshold is floating point value (minimum angle)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get faces with minimum angle > 75
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle,">", 75)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with minimum angle > 75:", len(ids)
-\endcode
+\include filters_ex04.py
+<a href="../../examples/SMESH/filters_ex04.py">Download this script</a>
\sa \ref tui_minimum_angle
- functor type is \a smesh.FT_Taper
- threshold is floating point value (taper)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get faces with taper < 1.e-15
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_LessThan, 1.e-15)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with taper < 1.e-15:", len(ids)
-\endcode
+\include filters_ex05.py
+<a href="../../examples/SMESH/filters_ex05.py">Download this script</a>
\sa \ref tui_taper
- functor type is \a smesh.FT_Skew
- threshold is floating point value (skew)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get faces with skew > 50
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, 50)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with skew > 50:", len(ids)
-\endcode
+\include filters_ex06.py
+<a href="../../examples/SMESH/filters_ex06.py">Download this script</a>
\sa \ref tui_skew
- functor type is \a smesh.FT_Area
- threshold is floating point value (area)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get faces with area > 60 and < 90
-criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 60,\
- smesh.FT_Undefined, smesh.FT_LogicalAND)
-criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 90)
-filter = smesh.CreateFilterManager().CreateFilter()
-filter.SetCriteria([criterion1,criterion2])
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with area in range (60,90):", len(ids)
-\endcode
+\include filters_ex07.py
+<a href="../../examples/SMESH/filters_ex07.py">Download this script</a>
\sa \ref tui_area
- functor type is \a smesh.FT_Volume3D
- threshold is floating point value (volume)
-\code
-# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
-# get volumes faces with volume > 100
-filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_MoreThan, 100)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of volumes with volume > 100:", len(ids)
-\endcode
+\include filters_ex08.py
+<a href="../../examples/SMESH/filters_ex08.py">Download this script</a>
\sa \ref tui_volume
- functor type is \a smesh.FT_FreeBorders
- threshold value is not required
-\code
-# create mesh
-import geompy, smesh, StdMeshers
-face = geompy.MakeFaceHW(100, 100, 1)
-geompy.addToStudy( face, "quadrangle" )
-mesh = smesh.Mesh(face)
-mesh.Segment().NumberOfSegments(10)
-mesh.Triangle().MaxElementArea(25)
-mesh.Compute()
-# get all free borders
-filter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of edges on free borders:", len(ids)
-\endcode
+\include filters_ex09.py
+<a href="../../examples/SMESH/filters_ex09.py">Download this script</a>
\sa \ref tui_free_borders
- functor type is \a smesh.FT_FreeEdges
- threshold value is not required
-\code
-# create mesh
-import geompy, smesh, StdMeshers
-face = geompy.MakeFaceHW(100, 100, 1)
-geompy.addToStudy( face, "quadrangle" )
-mesh = smesh.Mesh(face)
-mesh.Segment().NumberOfSegments(10)
-mesh.Triangle().MaxElementArea(25)
-mesh.Compute()
-# get all faces with free edges
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeEdges)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with free edges:", len(ids)
-\endcode
+\include filters_ex10.py
+<a href="../../examples/SMESH/filters_ex10.py">Download this script</a>
\sa \ref tui_free_edges
- functor type is \a smesh.FT_FreeNodes
- threshold value is not required
-\code
-# create mesh
-from SMESH_mechanic import *
-# add node
-mesh.AddNode(0,0,0)
-# get all free nodes
-filter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of free nodes:", len(ids)
-\endcode
+\include filters_ex11.py
+<a href="../../examples/SMESH/filters_ex11.py">Download this script</a>
\sa \ref tui_free_nodes
- functor type is \a smesh.FT_FreeFaces
- threshold value is not required
-\code
-# create mesh
-from SMESH_mechanic import *
-# get all free faces
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of free faces:", len(ids)
-\endcode
+\include filters_ex12.py
+<a href="../../examples/SMESH/filters_ex12.py">Download this script</a>
\sa \ref tui_free_faces
- functor type is \a smesh.FT_BareBorderFace
- threshold value is not required
-\code
-# create mesh
-from SMESH_mechanic import *
-# remove some faces to have faces with bare borders
-mesh.RemoveElements( mesh.GetElementsByType(FACE)[0:5] )
-# get all faces bare borders
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_BareBorderFace)
-ids = mesh.GetIdsFromFilter(filter)
-print "Faces with bare borders:", ids
-\endcode
+\include filters_ex13.py
+<a href="../../examples/SMESH/filters_ex13.py">Download this script</a>
\sa \ref tui_bare_border_faces
- threshold value is the face ID
- tolerance is in degrees
-\code
-# create mesh
-from SMESH_mechanic import *
-faceID = mesh.GetElementsByType(FACE)[0]
-# get all faces co-planar to the first face with tolerance 5 degrees
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_CoplanarFaces,faceID,Tolerance=5.0)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces coplanar with the first one:", len(ids)
-\endcode
+\include filters_ex14.py
+<a href="../../examples/SMESH/filters_ex14.py">Download this script</a>
\section filter_over_constrained_faces Over-constrained faces
- functor type is \a smesh.FT_OverConstrainedFace
- threshold value is not required
-\code
-# create mesh
-from SMESH_mechanic import *
-# get all over-constrained faces
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_OverConstrainedFace)
-ids = mesh.GetIdsFromFilter(filter)
-print "Over-constrained faces:", ids
-\endcode
+\include filters_ex15.py
+<a href="../../examples/SMESH/filters_ex15.py">Download this script</a>
\sa \ref tui_over_constrained_faces
smesh.FT_EqualFaces or \a smesh.FT_EqualVolumes,
- threshold value is not required
-\code
-from smesh import *
-# make a mesh on a box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-mesh = Mesh( box, "Box" )
-mesh.Segment().NumberOfSegments(10)
-mesh.Quadrangle()
-mesh.Hexahedron()
-mesh.Compute()
-# copy all elements with translation and Merge nodes
-mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True )
-mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) )
-# create filters to find equal elements
-equalEdgesFilter = GetFilter(SMESH.EDGE, FT_EqualEdges)
-equalFacesFilter = GetFilter(SMESH.FACE, FT_EqualFaces)
-equalVolumesFilter = GetFilter(SMESH.VOLUME, FT_EqualVolumes)
-# get equal elements
-print "Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter ))
-print "Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter ))
-print "Number of equal volumes:", len( mesh.GetIdsFromFilter( equalVolumesFilter ))
-\endcode
+\include filters_ex16.py
+<a href="../../examples/SMESH/filters_ex16.py">Download this script</a>
\section tui_double_nodes_control Double nodes
- threshold value is not required
- default tolerance is 1.0e-7
-\code
-from smesh import *
-# make a mesh on a box
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-mesh = Mesh( box, "Box" )
-mesh.Segment().NumberOfSegments(10)
-mesh.Quadrangle()
-mesh.Hexahedron()
-mesh.Compute()
-# copy all elements with translation
-mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True )
-# create filters to find nodes equal within tolerance of 1e-5
-filter = GetFilter(SMESH.NODE, FT_EqualNodes, Tolerance=1e-5)
-# get equal nodes
-print "Number of equal nodes:", len( mesh.GetIdsFromFilter( filter ))
-\endcode
+\include filters_ex17.py
+<a href="../../examples/SMESH/filters_ex17.py">Download this script</a>
\section filter_borders_multiconnection Borders at multi-connection
- functor type is \a smesh.FT_MultiConnection
- threshold is integer value (number of connections)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get border edges with number of connected faces = 5
-filter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, 5)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of border edges with 5 faces connected:", len(ids)
-\endcode
+\include filters_ex18.py
+<a href="../../examples/SMESH/filters_ex18.py">Download this script</a>
\sa \ref tui_borders_at_multiconnection
- functor type is \a smesh.FT_MultiConnection2D
- threshold is integer value (number of connections)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get faces which consist of edges belonging to 2 mesh elements
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, 2)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces consisting of edges belonging to 2 faces:", len(ids)
-\endcode
+\include filters_ex19.py
+<a href="../../examples/SMESH/filters_ex19.py">Download this script</a>
\sa \ref tui_borders_at_multiconnection_2d
- functor type should be \a smesh.FT_Length
- threshold is floating point value (length)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get edges with length > 14
-filter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, 14)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of edges with length > 14:", len(ids)
-\endcode
+\include filters_ex20.py
+<a href="../../examples/SMESH/filters_ex20.py">Download this script</a>
\sa \ref tui_length_1d
- functor type should be \a smesh.FT_Length2D
- threshold is floating point value (edge length)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get all faces that have edges with length > 14
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, 14)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with maximum edge length > 14:", len(ids)
-\endcode
+\include filters_ex21.py
+<a href="../../examples/SMESH/filters_ex21.py">Download this script</a>
\sa \ref tui_length_2d
- functor type should be \a smesh.FT_MaxElementLength2D
- threshold is floating point value (edge/diagonal length)
-\code
-# create mesh
-from SMESH_mechanic import *
-# get all faces that have elements with length > 10
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, 10)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces with maximum element length > 10:", len(ids)
-\endcode
+\include filters_ex22.py
+<a href="../../examples/SMESH/filters_ex22.py">Download this script</a>
\sa \ref tui_max_element_length_2d
- functor type should be \a smesh.FT_MaxElementLength3D
- threshold is floating point value (edge/diagonal length)
-\code
-# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
-# get all volumes that have elements with length > 10
-filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, 10)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of volumes with maximum element length > 10:", len(ids)
-\endcode
+\include filters_ex23.py
+<a href="../../examples/SMESH/filters_ex23.py">Download this script</a>
\sa \ref tui_max_element_length_3d
- functor type is \a smesh.FT_BareBorderVolume
- threshold value is not required
-\code
-# create mesh
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
-# remove some volumes to have volumes with bare borders
-mesh.RemoveElements( mesh.GetElementsByType(VOLUME)[0:5] )
-# get all volumes with bare borders
-filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BareBorderVolume)
-ids = mesh.GetIdsFromFilter(filter)
-print "Volumes with bare borders:", ids
-\endcode
+\include filters_ex24.py
+<a href="../../examples/SMESH/filters_ex24.py">Download this script</a>
\sa \ref tui_bare_border_volumes
- functor type is \a smesh.FT_OverConstrainedVolume
- threshold value is not required
-\code
-# create mesh
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
-# get all over-constrained volumes
-filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_OverConstrainedVolume)
-ids = mesh.GetIdsFromFilter(filter)
-print "Over-constrained volumes:", ids
-\endcode
+\include filters_ex25.py
+<a href="../../examples/SMESH/filters_ex25.py">Download this script</a>
\sa \ref tui_over_constrained_faces
- functor type should be \a smesh.FT_BelongToGeom
- threshold is geometrical object
-\code
-# create mesh
-from SMESH_mechanic import *
-# get all faces which nodes lie on the face sub_face3
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToGeom, sub_face3)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces which nodes lie on sub_face3:", len(ids)
-\endcode
+\include filters_ex26.py
+<a href="../../examples/SMESH/filters_ex26.py">Download this script</a>
\section filter_lying_on_geom Lying on Geom
- functor type should be \a smesh.FT_LyingOnGeom
- threshold is geometrical object
-\code
-# create mesh
-from SMESH_mechanic import *
-# get all faces at least one node of each lies on the face sub_face3
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_LyingOnGeom, sub_face3)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces at least one node of each lies on sub_face3:", len(ids)
-\endcode
+\include filters_ex27.py
+<a href="../../examples/SMESH/filters_ex27.py">Download this script</a>
\section filter_belong_to_plane Belong to Plane
- threshold is geometrical object (plane)
- default tolerance is 1.0e-7
-\code
-# create mesh
-from SMESH_mechanic import *
-# create plane
-import geompy
-plane_1 = geompy.MakePlane(p3,seg1,2000)
-geompy.addToStudy(plane_1, "plane_1")
-# get all nodes which lie on the plane \a plane_1
-filter = smesh.GetFilter(smesh.NODE, smesh.FT_BelongToPlane, plane_1)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of nodes which lie on the plane plane_1:", len(ids)
-\endcode
+\include filters_ex28.py
+<a href="../../examples/SMESH/filters_ex28.py">Download this script</a>
\section filter_belong_to_cylinder Belong to Cylinder
- threshold is geometrical object (cylindrical face)
- default tolerance is 1.0e-7
-\code
-# create mesh
-from SMESH_mechanic import *
-# get all faces which lie on the cylindrical face \a sub_face1
-filter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToCylinder, sub_face1)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of faces which lie on the cylindrical surface sub_face1:", len(ids)
-\endcode
+\include filters_ex29.py
+<a href="../../examples/SMESH/filters_ex29.py">Download this script</a>
\section filter_belong_to_surface Belong to Surface
- threshold is geometrical object (arbitrary surface)
- default tolerance is 1.0e-7
-\code
-# create mesh
-from SMESH_mechanic import *
-# create b-spline
-spline_1 = geompy.MakeInterpol([p4,p6,p3,p1])
-surface_1 = geompy.MakePrismVecH( spline_1, vz, 70.0 )
-geompy.addToStudy(surface_1, "surface_1")
-# get all nodes which lie on the surface \a surface_1
-filter = smesh.GetFilter(smesh.NODE, smesh.FT_BelongToGenSurface, surface_1)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of nodes which lie on the surface surface_1:", len(ids)
-\endcode
+\include filters_ex30.py
+<a href="../../examples/SMESH/filters_ex30.py">Download this script</a>
\section filter_range_of_ids Range of IDs
- functor type is \a smesh.FT_RangeOfIds
- threshold is string listing required IDs and/or ranges of IDs, e.g."1,2,3,50-60,63,67,70-78"
-\code
-# create mesh
-from SMESH_mechanic import *
-# get nodes with identifiers [5-10] and [15-30]
-criterion1 = smesh.GetCriterion(smesh.NODE, smesh.FT_RangeOfIds, Treshold="5-10",\
- BinaryOp=smesh.FT_LogicalOR)
-criterion2 = smesh.GetCriterion(smesh.NODE, smesh.FT_RangeOfIds, Treshold="15-30")
-filter = smesh.CreateFilterManager().CreateFilter()
-filter.SetCriteria([criterion1,criterion2])
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of nodes in ranges [5-10] and [15-30]:", len(ids)
-\endcode
+\include filters_ex31.py
+<a href="../../examples/SMESH/filters_ex31.py">Download this script</a>
\section filter_bad_oriented_volume Badly oriented volume
- functor type is \a smesh.FT_BadOrientedVolume
- threshold is not required
-\code
-# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
-# get all badly oriented volumes
-filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BadOrientedVolume)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of badly oriented volumes:", len(ids)
-\endcode
+\include filters_ex32.py
+<a href="../../examples/SMESH/filters_ex32.py">Download this script</a>
\section filter_linear_or_quadratic Linear / quadratic
- if unary operator is set to smesh.FT_LogicalNOT, the quadratic
elements are selected, otherwise (by default) linear elements are selected
-\code
-# create mesh
-from SMESH_mechanic import *
-# get number of linear and quadratic edges
-filter_linear = smesh.GetFilter(smesh.EDGE, smesh.FT_LinearOrQuadratic)
-filter_quadratic = smesh.GetFilter(smesh.EDGE, smesh.FT_LinearOrQuadratic, smesh.FT_LogicalNOT)
-ids_linear = mesh.GetIdsFromFilter(filter_linear)
-ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
-print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)
-# convert mesh to quadratic
-print "Convert to quadratic..."
-mesh.ConvertToQuadratic(True)
-# get number of linear and quadratic edges
-ids_linear = mesh.GetIdsFromFilter(filter_linear)
-ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic)
-print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic)
-\endcode
+\include filters_ex33.py
+<a href="../../examples/SMESH/filters_ex33.py">Download this script</a>
\section filter_group_color Group color
- functor type is \a smesh.FT_GroupColor
- threshold should be of SALOMEDS.Color type
-\code
-# create mesh
-from SMESH_mechanic import *
-# create group of edges
-all_edges = mesh.GetElementsByType(smesh.EDGE)
-grp = mesh.MakeGroupByIds("edges group", smesh.EDGE, all_edges[:len(all_edges)/4])
-import SALOMEDS
-c = SALOMEDS.Color(0.1, 0.5, 1.0)
-grp.SetColor(c)
-# get number of the edges not belonging to the group with the given color
-filter = smesh.GetFilter(smesh.EDGE, smesh.FT_GroupColor, c, smesh.FT_LogicalNOT)
-ids = mesh.GetIdsFromFilter(filter)
-print "Number of edges not beloging to the group with color (0.1, 0.5, 1.0):", len(ids)
-\endcode
+\include filters_ex34.py
+<a href="../../examples/SMESH/filters_ex34.py">Download this script</a>
\section filter_geom_type Geometry type
- functor type should be \a smesh.FT_ElemGeomType
- threshold is of smesh.GeometryType value
-\code
-# create mesh with volumes
-from SMESH_mechanic import *
-mesh.Tetrahedron()
-mesh.Compute()
-# get all triangles, quadrangles, tetrahedrons, pyramids
-filter_tri = smesh.GetFilter(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_TRIANGLE)
-filter_qua = smesh.GetFilter(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE)
-filter_tet = smesh.GetFilter(smesh.VOLUME, smesh.FT_ElemGeomType, smesh.Geom_TETRA)
-filter_pyr = smesh.GetFilter(smesh.VOLUME, smesh.FT_ElemGeomType, smesh.Geom_PYRAMID)
-ids_tri = mesh.GetIdsFromFilter(filter_tri)
-ids_qua = mesh.GetIdsFromFilter(filter_qua)
-ids_tet = mesh.GetIdsFromFilter(filter_tet)
-ids_pyr = mesh.GetIdsFromFilter(filter_pyr)
-print "Number of triangles:", len(ids_tri)
-print "Number of quadrangles:", len(ids_qua)
-print "Number of tetrahedrons:", len(ids_tet)
-print "Number of pyramids:", len(ids_pyr)
-\endcode
+\include filters_ex35.py
+<a href="../../examples/SMESH/filters_ex35.py">Download this script</a>
\section combining_filters How to combine filters with Criterion structures?
Example :
-\code
-# create mesh
-from SMESH_mechanic import *
-# get all the quadrangle faces ...
-criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE, smesh.FT_LogicalAND)
-# ... AND do NOT get those from sub_face3
-criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_BelongToGeom, sub_face3, smesh.FT_LogicalNOT)
-filter = smesh.CreateFilterManager().CreateFilter()
-filter.SetCriteria([criterion1,criterion2])
-ids = mesh.GetIdsFromFilter(filter)
-
-myGroup = mesh.MakeGroupByIds("Quads_on_cylindrical_faces",smesh.FACE,ids)
-\endcode
+\include filters_ex36.py
+<a href="../../examples/SMESH/filters_ex36.py">Download this script</a>
*/
\n This example represents an iron cable (a thin cylinder) in a concrete bloc (a big cylinder).
The big cylinder is defined by two geometric volumes.
-\code
-import geompy
-import smesh
-import SMESH
-# geometry
-
-O = geompy.MakeVertex(0, 0, 0)
-OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
-OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
-OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
-Vertex_1 = geompy.MakeVertex(50, 0, 0)
-Cylinder_1 = geompy.MakeCylinder(O, OX, 10, 500)
-Cylinder_2 = geompy.MakeCylinder(Vertex_1, OX, 100, 400)
-Vertex_2 = geompy.MakeVertex(-200, -200, -200)
-Vertex_3 = geompy.MakeVertex(250, 200, 200)
-Box_1 = geompy.MakeBoxTwoPnt(Vertex_2, Vertex_3)
-Fuse_1 = geompy.MakeFuse(Cylinder_1, Cylinder_2)
-Partition_1 = geompy.MakePartition([Fuse_1], [Cylinder_1, Box_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
-[Solid_1,Solid_2] = geompy.GetShapesOnShape(Cylinder_1, Partition_1, geompy.ShapeType["SOLID"], geompy.GEOM.ST_IN)
-[Solid_3,Solid_4] = geompy.GetShapesOnShape(Cylinder_2, Partition_1, geompy.ShapeType["SOLID"], geompy.GEOM.ST_IN)
-Vertex_4 = geompy.MakeVertex(450, 0, 0)
-Vertex_5 = geompy.MakeVertex(500, 0, 0)
-Vertex_6 = geompy.MakeVertex(550, 0, 0)
-vec1 = geompy.MakeVector(Vertex_4, Vertex_5)
-vec2 = geompy.MakeVector(Vertex_5, Vertex_6)
-[Face_1] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec1, geompy.GEOM.ST_ON)
-[Face_2] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec2, geompy.GEOM.ST_ON)
-
-# meshing (we have linear tetrahedrons here, but other elements are OK)
-
-Mesh_1 = smesh.Mesh(Partition_1)
-Regular_1D = Mesh_1.Segment()
-Nb_Segments_1 = Regular_1D.NumberOfSegments(15)
-MEFISTO_2D = Mesh_1.Triangle(algo=smesh.MEFISTO)
-Length_From_Edges_2D = MEFISTO_2D.LengthFromEdges()
-ALGO3D = Mesh_1.Tetrahedron()
-isDone = Mesh_1.Compute()
-
-# relevant groups of volumes and faces
-
-Solid_1_1 = Mesh_1.GroupOnGeom(Solid_1,'Solid_1',SMESH.VOLUME)
-Solid_2_1 = Mesh_1.GroupOnGeom(Solid_2,'Solid_2',SMESH.VOLUME)
-Solid_3_1 = Mesh_1.GroupOnGeom(Solid_3,'Solid_3',SMESH.VOLUME)
-Solid_4_1 = Mesh_1.GroupOnGeom(Solid_4,'Solid_4',SMESH.VOLUME)
-Face_1_1 = Mesh_1.GroupOnGeom(Face_1,'Face_1',SMESH.FACE)
-Face_2_1 = Mesh_1.GroupOnGeom(Face_2,'Face_2',SMESH.FACE)
-
-\endcode
+\include generate_flat_elements.py
+<a href="../../examples/SMESH/generate_flat_elements.py">Download this script</a>
\n Here, the 4 groups of volumes [Solid_1_1, Solid_2_1, Solid_3_1, Solid_4_1] constitute a partition of the mesh.
-The flat elements on group boundaries and on faces are built with the following code.
+The flat elements on group boundaries and on faces are built with the
+2 last lines of the code above.
\n If the last argument (Boolean) in DoubleNodesOnGroupBoundaries is set to 1,
the flat elements are built, otherwise, there is only a duplication of the nodes.
-\code
-Mesh_1.DoubleNodesOnGroupBoundaries([Solid_1_1, Solid_2_1, Solid_3_1, Solid_4_1], 1)
-
-Mesh_1.CreateFlatElementsOnFacesGroups([Face_1_1, Face_2_1])
-\endcode
-
\n To observe flat element groups, save the resulting mesh on a MED file and reload it.
*/
<br>
\anchor tui_create_standalone_group
<h2>Create a Standalone Group</h2>
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Get ids of all faces with area > 100
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# create a group consisting of faces with area > 100
-aGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
-
-# create a group that contains all nodes from the mesh
-aGroup2 = mesh.CreateEmptyGroup(smesh.NODE, "all nodes")
-aGroup2.AddFrom(mesh.mesh)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include grouping_elements_ex01.py
+<a href="../../examples/SMESH/grouping_elements_ex01.py">Download this script</a>
\image html create_group.png
<br>
\anchor tui_create_group_on_geometry
<h2>Create a Group on Geometry</h2>
-
-\code
-import salome
-import geompy
-import smesh
-
-# create a box
-box = geompy.MakeBox(0., 0., 0., 100., 100., 100.)
-geompy.addToStudy(box, "box")
-
-# add the first face of the box to the study
-subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-face = subShapeList[0]
-geompy.addToStudyInFather(box, face, "face 1")
-
-# create group of edges on the face
-aGeomGroupE = geompy.CreateGroup(face, geompy.ShapeType["EDGE"])
-geompy.AddObject(aGeomGroupE, 3)
-geompy.AddObject(aGeomGroupE, 6)
-geompy.AddObject(aGeomGroupE, 8)
-geompy.AddObject(aGeomGroupE, 10)
-geompy.addToStudyInFather(face, aGeomGroupE, "Group of Edges")
-
-# create quadrangle 2D mesh on the box
-quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh")
-algo1D = quadra.Segment()
-quadra.Quadrangle()
-algo1D.NumberOfSegments(7)
-
-# compute the mesh
-quadra.Compute()
-
-# create SMESH group on the face with name "SMESHGroup1"
-aSmeshGroup1 = quadra.GroupOnGeom(face, "SMESHGroup1")
-
-# create SMESH group on <aGeomGroupE> with default name
-aSmeshGroup2 = quadra.GroupOnGeom(aGeomGroupE)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include grouping_elements_ex02.py
+<a href="../../examples/SMESH/grouping_elements_ex02.py">Download this script</a>
<br>
\anchor tui_create_group_on_filter
<h2>Create a Group on Filter</h2>
-
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-box = geompy.MakeBoxDXDYDZ(10,10,10)
-
-# make a mesh with quadrangles of different area in range [1,16]
-mesh = Mesh(box,"Quad mesh")
-hyp1D = mesh.Segment().StartEndLength( 1, 4 )
-mesh.Quadrangle()
-mesh.Compute()
-
-# create a group on filter selecting faces of medium size
-critaria = [ \
- GetCriterion(FACE, FT_Area, ">", 1.1, BinaryOp=FT_LogicalAND ),
- GetCriterion(FACE, FT_Area, "<", 15.0 )
- ]
-filt = GetFilterFromCriteria( critaria )
-filtGroup = mesh.GroupOnFilter( FACE, "group on filter", filt )
-print "Group on filter contains %s elemens" % filtGroup.Size()
-
-# group on filter is updated if the mesh is modified
-hyp1D.SetStartLength( 2.5 )
-hyp1D.SetEndLength( 2.5 )
-mesh.Compute()
-print "After mesh change, group on filter contains %s elemens" % filtGroup.Size()
-
-# set a new filter defining the group
-filt2 = GetFilter( FACE, FT_RangeOfIds, "1-50" )
-filtGroup.SetFilter( filt2 )
-print "With a new filter, group on filter contains %s elemens" % filtGroup.Size()
-
-# group is updated at modification of the filter
-filt2.SetCriteria( [ GetCriterion( FACE, FT_RangeOfIds, "1-70" )])
-filtIDs3 = filtGroup.GetIDs()
-print "After filter modification, group on filter contains %s elemens" % filtGroup.Size()
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include grouping_elements_ex03.py
+<a href="../../examples/SMESH/grouping_elements_ex03.py">Download this script</a>
<br>
\anchor tui_edit_group
<h2>Edit a Group</h2>
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Get ids of all faces with area > 35
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 35.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area > 35, Nb = ", len(anIds)
-
-# create a group by adding elements with area > 35
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > 35")
-aGroup.Add(anIds)
-
-# Get ids of all faces with area > 40
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 40.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area > 40, Nb = ", len(anIds)
-
-# create a group of elements with area [35; 40] by removing elements with area > 40 from group aGroup
-aGroup.Remove(anIds)
-
-# print the result
-aGroupElemIDs = aGroup.GetListOfID()
-
-print "Criterion: 35 < Area < 40, Nb = ", len(aGroupElemIDs)
-
-j = 1
-for i in range(len(aGroupElemIDs)):
- if j > 20: j = 1; print ""
- print aGroupElemIDs[i],
- j = j + 1
- pass
-print ""
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include grouping_elements_ex04.py
+<a href="../../examples/SMESH/grouping_elements_ex04.py">Download this script</a>
\image html editing_groups1.png
<br>
\anchor tui_union_of_groups
<h2>Union of groups</h2>
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : AREA > 20
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area > 20, Nb = ", len( anIds )
-
-# create a group by adding elements with area > 20
-aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
-aGroup1.Add(anIds)
-
-# Criterion : AREA = 20
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_EqualTo, 20.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area = 20, Nb = ", len( anIds )
-
-# create a group by adding elements with area = 20
-aGroup2 = mesh.CreateEmptyGroup( smesh.FACE, "Area = 20" )
-
-aGroup2.Add(anIds)
-
-# create union group : area >= 20
-aGroup3 = mesh.UnionListOfGroups([aGroup1, aGroup2], "Area >= 20")
-print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID())
-# Please note that also there is UnionGroups() method which works with two groups only
-
-# Criterion : AREA < 20
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 20.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area < 20, Nb = ", len(anIds)
-
-# create a group by adding elements with area < 20
-aGroup4 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 20")
-aGroup4.Add(anIds)
-
-# create union group : area >= 20 and area < 20
-aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area")
-print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID())
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include grouping_elements_ex05.py
+<a href="../../examples/SMESH/grouping_elements_ex05.py">Download this script</a>
\image html union_groups1.png
<br>
\anchor tui_intersection_of_groups
<h2>Intersection of groups</h2>
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : AREA > 20
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area > 20, Nb = ", len(anIds)
-
-# create a group by adding elements with area > 20
-aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20")
-aGroup1.Add(anIds)
-
-# Criterion : AREA < 60
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area < 60, Nb = ", len(anIds)
-
-# create a group by adding elements with area < 60
-aGroup2 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 60")
-aGroup2.Add(anIds)
-
-# create an intersection of groups : 20 < area < 60
-aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60")
-print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID())
-# Please note that also there is IntersectGroups() method which works with two groups only
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include grouping_elements_ex06.py
+<a href="../../examples/SMESH/grouping_elements_ex06.py">Download this script</a>
\image html intersect_groups1.png
<br>
\anchor tui_cut_of_groups
<h2>Cut of groups</h2>
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : AREA > 20
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area > 20, Nb = ", len(anIds)
-
-# create a group by adding elements with area > 20
-aGroupMain = mesh.MakeGroupByIds("Area > 20", smesh.FACE, anIds)
-
-# Criterion : AREA < 60
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area < 60, Nb = ", len(anIds)
-
-# create a group by adding elements with area < 60
-aGroupTool = mesh.MakeGroupByIds("Area < 60", smesh.FACE, anIds)
-
-# create a cut of groups : area >= 60
-aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60")
-print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID())
-# Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include grouping_elements_ex07.py
+<a href="../../examples/SMESH/grouping_elements_ex07.py">Download this script</a>
\image html cut_groups1.png
<br>
\anchor tui_create_dim_group
<h2>Creating groups of entities from existing groups of superior dimensions</h2>
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : AREA > 100
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area > 100, Nb = ", len(anIds)
-
-# create a group by adding elements with area > 100
-aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
-
-# Criterion : AREA < 30
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 30.)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-print "Criterion: Area < 30, Nb = ", len(anIds)
-
-# create a group by adding elements with area < 30
-aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", smesh.FACE, anIds)
-
-# Create group of edges using source groups of faces
-aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.EDGE, "Edges" )
-
-# Create group of nodes using source groups of faces
-aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.NODE, "Nodes" )
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include grouping_elements_ex08.py
+<a href="../../examples/SMESH/grouping_elements_ex08.py">Download this script</a>
\image html dimgroup_tui1.png
<center>Source groups of faces</center>
\page tui_measurements_page Measurements
\section tui_min_distance Minimum Distance
-
-\code
-
-import smesh
-from SMESH_mechanic import mesh as mesh1
-from SMESH_test1 import mesh as mesh2
-
-mesh1.Compute()
-mesh2.Compute()
-
-# compute min distance from mesh1 to the origin (not available yet)
-smesh.MinDistance(mesh1)
-
-# compute min distance from node 10 of mesh1 to the origin
-smesh.MinDistance(mesh1, id1=10)
-# ... or
-mesh1.MinDistance(10)
-
-# compute min distance between nodes 10 and 20 of mesh1
-smesh.MinDistance(mesh1, id1=10, id2=20)
-# ... or
-mesh1.MinDistance(10, 20)
-
-# compute min distance from element 100 of mesh1 to the origin (not available yet)
-smesh.MinDistance(mesh1, id1=100, isElem1=True)
-# ... or
-mesh1.MinDistance(100, isElem1=True)
-
-# compute min distance between elements 100 and 200 of mesh1 (not available yet)
-smesh.MinDistance(mesh1, id1=100, id2=200, isElem1=True, isElem2=True)
-# ... or
-mesh1.MinDistance(100, 200, True, True)
-
-# compute min distance from element 100 to node 20 of mesh1 (not available yet)
-smesh.MinDistance(mesh1, id1=100, id2=20, isElem1=True)
-# ... or
-mesh1.MinDistance(100, 20, True)
-
-# compute min distance from mesh1 to mesh2 (not available yet)
-smesh.MinDistance(mesh1, mesh2)
-
-# compute min distance from node 10 of mesh1 to node 20 of mesh2
-smesh.MinDistance(mesh1, mesh2, 10, 20)
-
-# compute min distance from node 10 of mesh1 to element 200 of mesh2 (not available yet)
-smesh.MinDistance(mesh1, mesh2, 10, 200, isElem2=True)
-
-# etc...
-
-\endcode
+\include measurements_ex01.py
+<a href="../../examples/SMESH/measurements_ex01.py">Download this script</a>
\section tui_bounding_box Bounding Box
-
-\code
-
-import smesh
-from SMESH_mechanic import mesh as mesh1
-from SMESH_test1 import mesh as mesh2
-
-mesh1.Compute()
-mesh2.Compute()
-
-# compute bounding box for mesh1
-mesh1.BoundingBox()
-
-# compute bounding box for list of nodes of mesh1
-mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381])
-
-# compute bounding box for list of elements of mesh1
-mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381], isElem=True)
-
-# compute common bounding box of mesh1 and mesh2
-smesh.BoundingBox([mesh1, mesh2])
-
-# etc...
-
-\endcode
+\include measurements_ex02.py
+<a href="../../examples/SMESH/measurements_ex02.py">Download this script</a>
*/
<br>
\anchor tui_add_node
<h3>Add Node</h3>
-
-\code
-import smesh
-
-mesh = smesh.Mesh()
-
-# add node
-new_id = mesh.AddNode(50, 10, 0)
-print ""
-if new_id == 0: print "KO node addition."
-else: print "New Node has been added with ID ", new_id
-\endcode
+\include modifying_meshes_ex01.py
+<a href="../../examples/SMESH/modifying_meshes_ex01.py">Download this script</a>
<br>
\anchor tui_add_0DElement
<h3>Add 0D Element</h3>
-
-\code
-import smesh
-
-mesh = smesh.Mesh()
-
-# add node
-node_id = mesh.AddNode(50, 10, 0)
-
-# add 0D Element
-new_id = mesh.Add0DElement(node_id)
-
-print ""
-if new_id == 0: print "KO node addition."
-else: print "New 0D Element has been added with ID ", new_id
-\endcode
+\include modifying_meshes_ex02.py
+<a href="../../examples/SMESH/modifying_meshes_ex02.py">Download this script</a>
<br>
\anchor tui_add_0DElement_on_all_nodes
<h3>Add 0D Element on Element Nodes</h3>
-
-\code
-import smesh, SMESH, geompy
-
-# create a geometry
-box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
-face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0]
-
-# make 3D mesh
-mesh = smesh.Mesh( box )
-mesh.AutomaticHexahedralization(0)
-
-# create 0D elements on all nodes of the mesh
-res = mesh.Add0DElementsToAllNodes( mesh )
-
-# find 0D elements on all nodes of the mesh, all found nodes are added to a new group
-groupName = "0Dmesh"
-res = mesh.Add0DElementsToAllNodes( mesh, groupName )
-mesh.RemoveGroupWithContents( res ) # remove all found 0D elements
-
-# create 0D elements on all nodes of a sub-mesh, with group creation
-groupName = "0Dsubmesh"
-submesh = mesh.GetSubMesh( face, "faceSM")
-res = mesh.Add0DElementsToAllNodes( submesh, groupName )
-
-# create 0D elements on all nodes of a group
-group = mesh.Group( face, "faceGroup" )
-res = mesh.Add0DElementsToAllNodes( group )
-
-# remove all 0D elements
-mesh.RemoveElements( mesh.GetIdsFromFilter( smesh.GetFilter( SMESH.ELEM0D,
- SMESH.FT_ElemGeomType,
- "=",SMESH.Geom_POINT )))
-
-# create 0D elements on all nodes of some elements
-res = mesh.Add0DElementsToAllNodes( mesh.GetElementsId() )
-
-mesh.RemoveElements( mesh.GetElementsByType( SMESH.ELEM0D ))
-
-# create 0D elements on some nodes
-nodes = range(1,10)
-res = mesh.Add0DElementsToAllNodes( mesh.GetIDSource( nodes, SMESH.NODE ))
-
-\endcode
+\include modifying_meshes_ex03.py
+<a href="../../examples/SMESH/modifying_meshes_ex03.py">Download this script</a>
<br>
\anchor tui_add_edge
<h3>Add Edge</h3>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print ""
-
-# add node
-n1 = mesh.AddNode(50, 10, 0)
-if n1 == 0: print "KO node addition."
-
-# add edge
-e1 = mesh.AddEdge([n1, 38])
-if e1 == 0: print "KO edge addition."
-else: print "New Edge has been added with ID ", e1
-\endcode
+\include modifying_meshes_ex04.py
+<a href="../../examples/SMESH/modifying_meshes_ex04.py">Download this script</a>
<br>
\anchor tui_add_triangle
<h3>Add Triangle</h3>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print ""
-
-# add node
-n1 = mesh.AddNode(50, 10, 0)
-if n1 == 0: print "KO node addition."
-
-# add triangle
-t1 = mesh.AddFace([n1, 38, 39])
-if t1 == 0: print "KO triangle addition."
-else: print "New Triangle has been added with ID ", t1
-\endcode
+\include modifying_meshes_ex05.py
+<a href="../../examples/SMESH/modifying_meshes_ex05.py">Download this script</a>
<br>
\anchor tui_add_quadrangle
<h3>Add Quadrangle</h3>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print ""
-
-# add node
-n1 = mesh.AddNode(50, 10, 0)
-if n1 == 0: print "KO node addition."
-
-n2 = mesh.AddNode(40, 20, 0)
-if n2 == 0: print "KO node addition."
-
-# add quadrangle
-q1 = mesh.AddFace([n2, n1, 38, 39])
-if q1 == 0: print "KO quadrangle addition."
-else: print "New Quadrangle has been added with ID ", q1
-\endcode
+\include modifying_meshes_ex06.py
+<a href="../../examples/SMESH/modifying_meshes_ex06.py">Download this script</a>
<br>
\anchor tui_add_tetrahedron
<h3>Add Tetrahedron</h3>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print ""
-
-# add node
-n1 = mesh.AddNode(50, 10, 0)
-if n1 == 0: print "KO node addition."
-
-# add tetrahedron
-t1 = mesh.AddVolume([n1, 38, 39, 246])
-if t1 == 0: print "KO tetrahedron addition."
-else: print "New Tetrahedron has been added with ID ", t1
-\endcode
+\include modifying_meshes_ex07.py
+<a href="../../examples/SMESH/modifying_meshes_ex07.py">Download this script</a>
<br>
\anchor tui_add_hexahedron
<h3>Add Hexahedron</h3>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-print ""
-
-# add nodes
-nId1 = mesh.AddNode(50, 10, 0)
-nId2 = mesh.AddNode(47, 12, 0)
-nId3 = mesh.AddNode(50, 10, 10)
-nId4 = mesh.AddNode(47, 12, 10)
-
-if nId1 == 0 or nId2 == 0 or nId3 == 0 or nId4 == 0: print "KO node addition."
-
-# add hexahedron
-vId = mesh.AddVolume([nId2, nId1, 38, 39, nId4, nId3, 245, 246])
-if vId == 0: print "KO Hexahedron addition."
-else: print "New Hexahedron has been added with ID ", vId
-\endcode
+\include modifying_meshes_ex08.py
+<a href="../../examples/SMESH/modifying_meshes_ex08.py">Download this script</a>
<br>
\anchor tui_add_polygon
<h3>Add Polygon</h3>
-
-\code
-import math
-import salome
-
-import smesh
-
-# create an empty mesh structure
-mesh = smesh.Mesh()
-
-# a method to build a polygonal mesh element with <nb_vert> angles:
-def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert):
- al = 2.0 * math.pi / nb_vert
- node_ids = []
-
- # Create nodes for a polygon
- for ii in range(nb_vert):
- nid = mesh.AddNode(x0 + radius * math.cos(ii*al),
- y0 + radius * math.sin(ii*al),
- z0)
- node_ids.append(nid)
- pass
-
- # Create a polygon
- return mesh.AddPolygonalFace(node_ids)
-
-# Create three polygons
-f1 = MakePolygon(mesh, 0, 0, 0, 30, 13)
-f2 = MakePolygon(mesh, 0, 0, 10, 21, 9)
-f3 = MakePolygon(mesh, 0, 0, 20, 13, 6)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex09.py
+<a href="../../examples/SMESH/modifying_meshes_ex09.py">Download this script</a>
<br>
\anchor tui_add_polyhedron
<h3>Add Polyhedron</h3>
-
-\code
-import salome
-import math
-
-# create an empty mesh structure
-mesh = smesh.Mesh()
-
-# Create nodes for 12-hedron with pentagonal faces
-al = 2 * math.pi / 5.0
-cosal = math.cos(al)
-aa = 13
-rr = aa / (2.0 * math.sin(al/2.0))
-dr = 2.0 * rr * cosal
-r1 = rr + dr
-dh = rr * math.sqrt(2.0 * (1.0 - cosal * (1.0 + 2.0 * cosal)))
-hh = 2.0 * dh - dr * (rr*(cosal - 1) + (rr + dr)*(math.cos(al/2) - 1)) / dh
-
-dd = [] # top
-cc = [] # below top
-bb = [] # above bottom
-aa = [] # bottom
-
-for i in range(5):
- cos_bot = math.cos(i*al)
- sin_bot = math.sin(i*al)
-
- cos_top = math.cos(i*al + al/2.0)
- sin_top = math.sin(i*al + al/2.0)
-
- nd = mesh.AddNode(rr * cos_top, rr * sin_top, hh ) # top
- nc = mesh.AddNode(r1 * cos_top, r1 * sin_top, hh - dh) # below top
- nb = mesh.AddNode(r1 * cos_bot, r1 * sin_bot, dh) # above bottom
- na = mesh.AddNode(rr * cos_bot, rr * sin_bot, 0) # bottom
- dd.append(nd) # top
- cc.append(nc) # below top
- bb.append(nb) # above bottom
- aa.append(na) # bottom
- pass
-
-# Create a polyhedral volume (12-hedron with pentagonal faces)
-MeshEditor.AddPolyhedralVolume([dd[0], dd[1], dd[2], dd[3], dd[4], # top
- dd[0], cc[0], bb[1], cc[1], dd[1], # -
- dd[1], cc[1], bb[2], cc[2], dd[2], # -
- dd[2], cc[2], bb[3], cc[3], dd[3], # - below top
- dd[3], cc[3], bb[4], cc[4], dd[4], # -
- dd[4], cc[4], bb[0], cc[0], dd[0], # -
- aa[4], bb[4], cc[4], bb[0], aa[0], # .
- aa[3], bb[3], cc[3], bb[4], aa[4], # .
- aa[2], bb[2], cc[2], bb[3], aa[3], # . above bottom
- aa[1], bb[1], cc[1], bb[2], aa[2], # .
- aa[0], bb[0], cc[0], bb[1], aa[1], # .
- aa[0], aa[1], aa[2], aa[3], aa[4]], # bottom
- [5,5,5,5,5,5,5,5,5,5,5,5])
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex10.py
+<a href="../../examples/SMESH/modifying_meshes_ex10.py">Download this script</a>
<br>
\anchor tui_removing_nodes_and_elements
<br>
\anchor tui_removing_nodes
<h3>Removing Nodes</h3>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-
-# remove nodes #246 and #255
-res = mesh.RemoveNodes([246, 255])
-if res == 1: print "Nodes removing is OK!"
-else: print "KO nodes removing."
-\endcode
+\include modifying_meshes_ex11.py
+<a href="../../examples/SMESH/modifying_meshes_ex11.py">Download this script</a>
<br>
\anchor tui_removing_elements
<h3>Removing Elements</h3>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-
-# remove three elements: #850, #859 and #814
-res = mesh.RemoveElements([850, 859, 814])
-if res == 1: print "Elements removing is OK!"
-else: print "KO Elements removing."
-\endcode
+\include modifying_meshes_ex12.py
+<a href="../../examples/SMESH/modifying_meshes_ex12.py">Download this script</a>
<br>
\anchor tui_removing_orphan_nodes
<h3>Removing Orphan Nodes</h3>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-
-# add orphan nodes
-mesh.AddNode(0,0,0)
-mesh.AddNode(1,1,1)
-# remove just created orphan nodes
-res = mesh.RemoveOrphanNodes()
-if res == 1: print "Removed %d nodes!" % res
-else: print "KO nodes removing."
-\endcode
+\include modifying_meshes_ex13.py
+<a href="../../examples/SMESH/modifying_meshes_ex13.py">Download this script</a>
<br>
\anchor tui_renumbering_nodes_and_elements
<h2>Renumbering Nodes and Elements</h2>
-
-\code
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-
-mesh.RenumberNodes()
-
-mesh.RenumberElements()
-\endcode
+\include modifying_meshes_ex14.py
+<a href="../../examples/SMESH/modifying_meshes_ex14.py">Download this script</a>
<br>
\anchor tui_moving_nodes
<h2>Moving Nodes</h2>
-
-\code
-from geompy import *
-from smesh import *
-
-box = MakeBoxDXDYDZ(200, 200, 200)
-
-mesh = Mesh( box )
-mesh.Segment().AutomaticLength(0.1)
-mesh.Quadrangle()
-mesh.Compute()
-
-# find node at (0,0,0)
-node000 = None
-for vId in SubShapeAllIDs( box, ShapeType["VERTEX"]):
- if node000: break
- nodeIds = mesh.GetSubMeshNodesId( vId, True )
- for node in nodeIds:
- xyz = mesh.GetNodeXYZ( node )
- if xyz[0] == 0 and xyz[1] == 0 and xyz[2] == 0 :
- node000 = node
- pass
- pass
- pass
-
-if not node000:
- raise "node000 not found"
-
-# find node000 using the tested function
-n = mesh.FindNodeClosestTo( -1,-1,-1 )
-if not n == node000:
- raise "FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 )
-
-# move node000 to a new location
-x,y,z = -10, -10, -10
-n = mesh.MoveNode( n,x,y,z )
-if not n:
- raise "MoveNode() returns " + n
-
-# check the coordinates of the node000
-xyz = mesh.GetNodeXYZ( node000 )
-if not ( xyz[0] == x and xyz[1] == y and xyz[2] == z) :
- raise "Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] )
-\endcode
+\include modifying_meshes_ex15.py
+<a href="../../examples/SMESH/modifying_meshes_ex15.py">Download this script</a>
<br>
\anchor tui_diagonal_inversion
<h2>Diagonal Inversion</h2>
-
-\code
-import salome
-import smesh
-
-# create an empty mesh structure
-mesh = smesh.Mesh()
-
-# create the following mesh:
-# .----.----.----.
-# | /| /| /|
-# | / | / | / |
-# | / | / | / |
-# |/ |/ |/ |
-# .----.----.----.
-
-bb = [0, 0, 0, 0]
-tt = [0, 0, 0, 0]
-ff = [0, 0, 0, 0, 0, 0]
-
-bb[0] = mesh.AddNode( 0., 0., 0.)
-bb[1] = mesh.AddNode(10., 0., 0.)
-bb[2] = mesh.AddNode(20., 0., 0.)
-bb[3] = mesh.AddNode(30., 0., 0.)
-
-tt[0] = mesh.AddNode( 0., 15., 0.)
-tt[1] = mesh.AddNode(10., 15., 0.)
-tt[2] = mesh.AddNode(20., 15., 0.)
-tt[3] = mesh.AddNode(30., 15., 0.)
-
-ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
-ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
-ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
-ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
-ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
-ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
-
-# inverse the diagonal bb[1] - tt[2]
-print "\nDiagonal inversion ... ",
-res = mesh.InverseDiag(bb[1], tt[2])
-if not res: print "failed!"
-else: print "done."
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex16.py
+<a href="../../examples/SMESH/modifying_meshes_ex16.py">Download this script</a>
<br>
\anchor tui_uniting_two_triangles
<h2>Uniting two Triangles</h2>
-
-\code
-import salome
-import smesh
-
-# create an empty mesh structure
-mesh = smesh.Mesh()
-
-# create the following mesh:
-# .----.----.----.
-# | /| /| /|
-# | / | / | / |
-# | / | / | / |
-# |/ |/ |/ |
-# .----.----.----.
-
-bb = [0, 0, 0, 0]
-tt = [0, 0, 0, 0]
-ff = [0, 0, 0, 0, 0, 0]
-
-bb[0] = mesh.AddNode( 0., 0., 0.)
-bb[1] = mesh.AddNode(10., 0., 0.)
-bb[2] = mesh.AddNode(20., 0., 0.)
-bb[3] = mesh.AddNode(30., 0., 0.)
-
-tt[0] = mesh.AddNode( 0., 15., 0.)
-tt[1] = mesh.AddNode(10., 15., 0.)
-tt[2] = mesh.AddNode(20., 15., 0.)
-tt[3] = mesh.AddNode(30., 15., 0.)
-
-ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
-ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
-ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
-ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
-ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
-ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
-
-# delete the diagonal bb[1] - tt[2]
-print "\nUnite two triangles ... ",
-res = mesh.DeleteDiag(bb[1], tt[2])
-if not res: print "failed!"
-else: print "done."
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex17.py
+<a href="../../examples/SMESH/modifying_meshes_ex17.py">Download this script</a>
<br>
\anchor tui_uniting_set_of_triangles
<h2>Uniting a Set of Triangles</h2>
-
-\code
-import salome
-import smesh
-
-# create an empty mesh structure
-mesh = smesh.Mesh()
-
-# create the following mesh:
-# .----.----.----.
-# | /| /| /|
-# | / | / | / |
-# | / | / | / |
-# |/ |/ |/ |
-# .----.----.----.
-
-bb = [0, 0, 0, 0]
-tt = [0, 0, 0, 0]
-ff = [0, 0, 0, 0, 0, 0]
-
-bb[0] = mesh.AddNode( 0., 0., 0.)
-bb[1] = mesh.AddNode(10., 0., 0.)
-bb[2] = mesh.AddNode(20., 0., 0.)
-bb[3] = mesh.AddNode(30., 0., 0.)
-
-tt[0] = mesh.AddNode( 0., 15., 0.)
-tt[1] = mesh.AddNode(10., 15., 0.)
-tt[2] = mesh.AddNode(20., 15., 0.)
-tt[3] = mesh.AddNode(30., 15., 0.)
-
-ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
-ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
-ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
-ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
-ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
-ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
-
-# unite a set of triangles
-print "\nUnite a set of triangles ... ",
-res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], smesh.FT_MinimumAngle, 60.)
-if not res: print "failed!"
-else: print "done."
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex18.py
+<a href="../../examples/SMESH/modifying_meshes_ex18.py">Download this script</a>
<br>
\anchor tui_orientation
<h2>Orientation</h2>
-
-\code
-import salome
-import smesh
-
-# create an empty mesh structure
-mesh = smesh.Mesh()
-
-# build five quadrangles:
-dx = 10
-dy = 20
-
-n1 = mesh.AddNode(0.0 * dx, 0, 0)
-n2 = mesh.AddNode(1.0 * dx, 0, 0)
-n3 = mesh.AddNode(2.0 * dx, 0, 0)
-n4 = mesh.AddNode(3.0 * dx, 0, 0)
-n5 = mesh.AddNode(4.0 * dx, 0, 0)
-n6 = mesh.AddNode(5.0 * dx, 0, 0)
-n7 = mesh.AddNode(0.0 * dx, dy, 0)
-n8 = mesh.AddNode(1.0 * dx, dy, 0)
-n9 = mesh.AddNode(2.0 * dx, dy, 0)
-n10 = mesh.AddNode(3.0 * dx, dy, 0)
-n11 = mesh.AddNode(4.0 * dx, dy, 0)
-n12 = mesh.AddNode(5.0 * dx, dy, 0)
-
-f1 = mesh.AddFace([n1, n2, n8 , n7 ])
-f2 = mesh.AddFace([n2, n3, n9 , n8 ])
-f3 = mesh.AddFace([n3, n4, n10, n9 ])
-f4 = mesh.AddFace([n4, n5, n11, n10])
-f5 = mesh.AddFace([n5, n6, n12, n11])
-
-# Change the orientation of the second and the fourth faces.
-mesh.Reorient([2, 4])
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex19.py
+<a href="../../examples/SMESH/modifying_meshes_ex19.py">Download this script</a>
<br>
\anchor tui_cutting_quadrangles
<h2>Cutting Quadrangles</h2>
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-
-# cut two quadrangles: 405 and 406
-mesh.QuadToTri([405, 406], smesh.FT_MinimumAngle)
-\endcode
+\include modifying_meshes_ex20.py
+<a href="../../examples/SMESH/modifying_meshes_ex20.py">Download this script</a>
<br>
\anchor tui_smoothing
<h2>Smoothing</h2>
-
-\code
-import salome
-import geompy
-
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-
-# select the top face
-faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, geompy.ShapeType["FACE"])
-face = faces[3]
-geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face planar with hole")
-
-# create a group of faces to be smoothed
-GroupSmooth = mesh.GroupOnGeom(face, "Group of faces (smooth)", smesh.FACE)
-
-# perform smoothing
-
-# boolean SmoothObject(Object, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method)
-res = mesh.SmoothObject(GroupSmooth, [], 20, 2., smesh.CENTROIDAL_SMOOTH)
-print "\nSmoothing ... ",
-if not res: print "failed!"
-else: print "done."
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex21.py
+<a href="../../examples/SMESH/modifying_meshes_ex21.py">Download this script</a>
<br>
\anchor tui_extrusion
<h2>Extrusion</h2>
-
-\code
-import salome
-import geompy
-
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-
-# 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")
-
-# create a vector for extrusion
-point = smesh.PointStruct(0., 0., 5.)
-vector = smesh.DirStruct(point)
-
-# create a group to be extruded
-GroupTri = mesh.GroupOnGeom(face, "Group of faces (extrusion)", smesh.FACE)
-
-# perform extrusion of the group
-mesh.ExtrusionSweepObject(GroupTri, vector, 5)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex22.py
+<a href="../../examples/SMESH/modifying_meshes_ex22.py">Download this script</a>
<br>
\anchor tui_extrusion_along_path
<h2>Extrusion along a Path</h2>
-
-\code
-import math
-import salome
-
-# Geometry
-import geompy
-
-# 1. Create points
-points = [[0, 0], [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]]
-
-iv = 1
-vertices = []
-for point in points:
- vert = geompy.MakeVertex(point[0], point[1], 0)
- geompy.addToStudy(vert, "Vertex_" + `iv`)
- vertices.append(vert)
- iv += 1
- pass
-
-# 2. Create edges and wires
-Edge_straight = geompy.MakeEdge(vertices[0], vertices[4])
-Edge_bezierrr = geompy.MakeBezier(vertices)
-Wire_polyline = geompy.MakePolyline(vertices)
-Edge_Circle = geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])
-
-geompy.addToStudy(Edge_straight, "Edge_straight")
-geompy.addToStudy(Edge_bezierrr, "Edge_bezierrr")
-geompy.addToStudy(Wire_polyline, "Wire_polyline")
-geompy.addToStudy(Edge_Circle , "Edge_Circle")
-
-# 3. Explode wire on edges, as they will be used for mesh extrusion
-Wire_polyline_edges = geompy.SubShapeAll(Wire_polyline, geompy.ShapeType["EDGE"])
-for ii in range(len(Wire_polyline_edges)):
- geompy.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + `ii + 1`)
- pass
-
-# Mesh
-import smesh
-
-# Mesh the given shape with the given 1d hypothesis
-def Mesh1D(shape1d, nbSeg, name):
- mesh1d_tool = smesh.Mesh(shape1d, name)
- algo = mesh1d_tool.Segment()
- hyp = algo.NumberOfSegments(nbSeg)
- isDone = mesh1d_tool.Compute()
- if not isDone: print 'Mesh ', name, ': computation failed'
- return mesh1d_tool
-
-# Create a mesh with six nodes, seven edges and two quadrangle faces
-def MakeQuadMesh2(mesh_name):
- quad_1 = smesh.Mesh(name = mesh_name)
-
- # six nodes
- n1 = quad_1.AddNode(0, 20, 10)
- n2 = quad_1.AddNode(0, 40, 10)
- n3 = quad_1.AddNode(0, 40, 30)
- n4 = quad_1.AddNode(0, 20, 30)
- n5 = quad_1.AddNode(0, 0, 30)
- n6 = quad_1.AddNode(0, 0, 10)
-
- # seven edges
- quad_1.AddEdge([n1, n2]) # 1
- quad_1.AddEdge([n2, n3]) # 2
- quad_1.AddEdge([n3, n4]) # 3
- quad_1.AddEdge([n4, n1]) # 4
- quad_1.AddEdge([n4, n5]) # 5
- quad_1.AddEdge([n5, n6]) # 6
- quad_1.AddEdge([n6, n1]) # 7
-
- # two quadrangle faces
- quad_1.AddFace([n1, n2, n3, n4]) # 8
- quad_1.AddFace([n1, n4, n5, n6]) # 9
- return [quad_1, [1,2,3,4,5,6,7], [8,9]]
-
-# Path meshes
-Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight")
-Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr")
-Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline")
-Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle")
-
-# Initial meshes (to be extruded)
-[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1")
-[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2")
-[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3")
-[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4")
-[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5")
-[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6")
-[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7")
-
-# ExtrusionAlongPath
-# IDsOfElements, PathMesh, PathShape, NodeStart,
-# HasAngles, Angles, HasRefPoint, RefPoint
-refPoint = smesh.PointStruct(0, 0, 0)
-a10 = 10.0*math.pi/180.0
-a45 = 45.0*math.pi/180.0
-
-# 1. Extrusion of two mesh edges along a straight path
-error = quad_1.ExtrusionAlongPath([1,2], Edge_straight_mesh, Edge_straight, 1,
- 0, [], 0, refPoint)
-
-# 2. Extrusion of one mesh edge along a curved path
-error = quad_2.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1,
- 0, [], 0, refPoint)
-
-# 3. Extrusion of one mesh edge along a curved path with usage of angles
-error = quad_3.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1,
- 1, [a45, a45, a45, 0, -a45, -a45, -a45], 0, refPoint)
-
-# 4. Extrusion of one mesh edge along the path, which is a part of a meshed wire
-error = quad_4.ExtrusionAlongPath([4], Wire_polyline_mesh, Wire_polyline_edges[0], 1,
- 1, [a10, a10, a10], 0, refPoint)
-
-# 5. Extrusion of two mesh faces along the path, which is a part of a meshed wire
-error = quad_5.ExtrusionAlongPath(ff_5 , Wire_polyline_mesh, Wire_polyline_edges[2], 4,
- 0, [], 0, refPoint)
-
-# 6. Extrusion of two mesh faces along a closed path
-error = quad_6.ExtrusionAlongPath(ff_6 , Edge_Circle_mesh, Edge_Circle, 1,
- 0, [], 0, refPoint)
-
-# 7. Extrusion of two mesh faces along a closed path with usage of angles
-error = quad_7.ExtrusionAlongPath(ff_7, Edge_Circle_mesh, Edge_Circle, 1,
- 1, [a45, -a45, a45, -a45, a45, -a45, a45, -a45], 0, refPoint)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include modifying_meshes_ex23.py
+<a href="../../examples/SMESH/modifying_meshes_ex23.py">Download this script</a>
<br>
\anchor tui_revolution
<h2>Revolution</h2>
-
-\code
-import math
-import SMESH
-
-import SMESH_mechanic
-
-mesh = SMESH_mechanic.mesh
-smesh = SMESH_mechanic.smesh
-
-# create a group of faces to be revolved
-FacesRotate = [492, 493, 502, 503]
-GroupRotate = mesh.CreateEmptyGroup(SMESH.FACE,"Group of faces (rotate)")
-GroupRotate.Add(FacesRotate)
-
-# define revolution angle and axis
-angle45 = 45 * math.pi / 180
-axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -23.321, -13.3402, -13.3265, 6.66632)
-
-# perform revolution of an object
-mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5)
-\endcode
+\include modifying_meshes_ex24.py
+<a href="../../examples/SMESH/modifying_meshes_ex24.py">Download this script</a>
<br>
\anchor tui_pattern_mapping
<h2>Pattern Mapping</h2>
-
-\code
-import geompy
-import smesh
-
-# define the geometry
-Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.)
-geompy.addToStudy(Box_1, "Box_1")
-
-faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"])
-Face_1 = faces[0]
-Face_2 = faces[1]
-
-geompy.addToStudyInFather(Box_1, Face_1, "Face_1")
-geompy.addToStudyInFather(Box_1, Face_2, "Face_2")
-
-# build a quadrangle mesh 3x3 on Face_1
-Mesh_1 = smesh.Mesh(Face_1)
-algo1D = Mesh_1.Segment()
-algo1D.NumberOfSegments(3)
-Mesh_1.Quadrangle()
-
-isDone = Mesh_1.Compute()
-if not isDone: print 'Mesh Mesh_1 : computation failed'
-
-# build a triangle mesh on Face_2
-Mesh_2 = smesh.Mesh(Face_2)
-
-algo1D = Mesh_2.Segment()
-algo1D.NumberOfSegments(1)
-algo2D = Mesh_2.Triangle()
-algo2D.MaxElementArea(240)
-
-isDone = Mesh_2.Compute()
-if not isDone: print 'Mesh Mesh_2 : computation failed'
-
-# create a 2d pattern
-pattern = smesh.GetPattern()
-
-isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
-if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode()
-
-# apply the pattern to a face of the first mesh
-facesToSplit = Mesh_1.GetElementsByType(smesh.SMESH.FACE)
-print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit))
-pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0)
-isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)
-if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode()
-
-# create quadrangle mesh
-Mesh_3 = smesh.Mesh(Box_1)
-Mesh_3.Segment().NumberOfSegments(1)
-Mesh_3.Quadrangle()
-Mesh_3.Hexahedron()
-isDone = Mesh_3.Compute()
-if not isDone: print 'Mesh Mesh_3 : computation failed'
-
-# create a 3d pattern (hexahedrons)
-pattern_hexa = smesh.GetPattern()
-
-smp_hexa = """!!! Nb of points:
-15
- 0 0 0 !- 0
- 1 0 0 !- 1
- 0 1 0 !- 2
- 1 1 0 !- 3
- 0 0 1 !- 4
- 1 0 1 !- 5
- 0 1 1 !- 6
- 1 1 1 !- 7
- 0.5 0 0.5 !- 8
- 0.5 0 1 !- 9
- 0.5 0.5 0.5 !- 10
- 0.5 0.5 1 !- 11
- 1 0 0.5 !- 12
- 1 0.5 0.5 !- 13
- 1 0.5 1 !- 14
- !!! Indices of points of 4 elements:
- 8 12 5 9 10 13 14 11
- 0 8 9 4 2 10 11 6
- 2 10 11 6 3 13 14 7
- 0 1 12 8 2 3 13 10"""
-
-pattern_hexa.LoadFromFile(smp_hexa)
-
-# apply the pattern to a mesh
-volsToSplit = Mesh_3.GetElementsByType(smesh.SMESH.VOLUME)
-print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit))
-pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3)
-isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True)
-if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode()
-
-# create one more quadrangle mesh
-Mesh_4 = smesh.Mesh(Box_1)
-Mesh_4.Segment().NumberOfSegments(1)
-Mesh_4.Quadrangle()
-Mesh_4.Hexahedron()
-isDone = Mesh_4.Compute()
-if not isDone: print 'Mesh Mesh_4 : computation failed'
-
-# create another 3d pattern (pyramids)
-pattern_pyra = smesh.GetPattern()
-
-smp_pyra = """!!! Nb of points:
-9
- 0 0 0 !- 0
- 1 0 0 !- 1
- 0 1 0 !- 2
- 1 1 0 !- 3
- 0 0 1 !- 4
- 1 0 1 !- 5
- 0 1 1 !- 6
- 1 1 1 !- 7
- 0.5 0.5 0.5 !- 8
- !!! Indices of points of 6 elements:
- 0 1 5 4 8
- 7 5 1 3 8
- 3 2 6 7 8
- 2 0 4 6 8
- 0 2 3 1 8
- 4 5 7 6 8"""
-
-pattern_pyra.LoadFromFile(smp_pyra)
-
-# apply the pattern to a face mesh
-volsToSplit = Mesh_4.GetElementsByType(smesh.SMESH.VOLUME)
-print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit))
-pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0)
-isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True)
-if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode()
-\endcode
+\include modifying_meshes_ex25.py
+<a href="../../examples/SMESH/modifying_meshes_ex25.py">Download this script</a>
<br>
\anchor tui_quadratic
<h2>Convert mesh to/from quadratic</h2>
-
-\code
-import geompy
-import smesh
-
-# create sphere of radius 100
-
-Sphere = geompy.MakeSphereR( 100 )
-geompy.addToStudy( Sphere, "Sphere" )
-
-# create simple trihedral mesh
-
-Mesh = smesh.Mesh(Sphere)
-Regular_1D = Mesh.Segment()
-Nb_Segments = Regular_1D.NumberOfSegments(5)
-MEFISTO_2D = Mesh.Triangle()
-Tetrahedron = Mesh.Tetrahedron()
-
-# compute mesh
-
-isDone = Mesh.Compute()
-
-# convert to quadratic
-# theForce3d = 1; this results in the medium node lying at the
-# middle of the line segments connecting start and end node of a mesh
-# element
-
-Mesh.ConvertToQuadratic( theForce3d=1 )
-
-# revert back to the non-quadratic mesh
-
-Mesh.ConvertFromQuadratic()
-
-# convert to quadratic
-# theForce3d = 0; this results in the medium node lying at the
-# geometrical edge from which the mesh element is built
-
-Mesh.ConvertToQuadratic( theForce3d=0 )
-
-# to convert not the whole mesh but a sub-mesh, provide it as
-# an additional argument to the functions:
-# Mesh.ConvertToQuadratic( 0, subMesh )
-# Mesh.ConvertFromQuadratic( subMesh )
-#
-# Note that the mesh becomes non-conformal at conversion of sub-mesh.
-
-\endcode
+\include modifying_meshes_ex26.py
+<a href="../../examples/SMESH/modifying_meshes_ex26.py">Download this script</a>
*/
\page tui_notebook_smesh_page Using SALOME NoteBook
\anchor tui_notebook_smesh
-
-\code
-import geompy
-import smesh
-import salome_notebook
-
-# set variables
-notebook = salome_notebook.notebook
-notebook.set("Length", 100)
-notebook.set("Width", 200)
-notebook.set("Offset", 50)
-
-notebook.set("NbSegments", 7)
-notebook.set("MaxElementArea", 800)
-notebook.set("MaxElementVolume", 900)
-
-# create a box
-box = geompy.MakeBoxDXDYDZ("Length", "Width", 300)
-idbox = geompy.addToStudy(box, "Box")
-
-# create a mesh
-tetra = smesh.Mesh(box, "MeshBox")
-
-algo1D = tetra.Segment()
-algo1D.NumberOfSegments("NbSegments")
-
-algo2D = tetra.Triangle()
-algo2D.MaxElementArea("MaxElementArea")
-
-algo3D = tetra.Tetrahedron()
-algo3D.MaxElementVolume("MaxElementVolume")
-
-# compute the mesh
-ret = tetra.Compute()
-
-# translate the mesh
-point = smesh.PointStruct("Offset", 0., 0.)
-vector = smesh.DirStruct(point)
-tetra.TranslateObject(tetra, vector, 0)
-\endcode
+\include notebook_smesh.py
+<a href="../../examples/SMESH/notebook_smesh.py">Download this script</a>
*/
/*!
\page tui_prism_3d_algo Use 3D extrusion meshing algorithm
-
-\code
-import salome, smesh, SMESH, geompy
-
-salome.salome_init()
-smesh.SetCurrentStudy( salome.myStudy )
-
-OX = geompy.MakeVectorDXDYDZ(1,0,0)
-OY = geompy.MakeVectorDXDYDZ(0,1,0)
-OZ = geompy.MakeVectorDXDYDZ(0,0,1)
-
-# Y ^ Make geometry of a "pipe" with the following base (cross section).
-# | Big central quadrangles will be meshed with triangles, walls
-# of the pipe will be meshed with quadrilaterals
-# +--+--+--+--+--+--+
-# | | | | | | |
-# +--+--+--+--+--+--+
-# | | | | |
-# +--+ | +--+
-# | | | | |
-# +--+-----+-----+--+
-# | | | | |
-# +--+ | +--+
-# | | | | |
-# +--+--+--+--+--+--+
-# | | | | | | | -->
-# +--+--+--+--+--+--+ X
-
-quadBig = geompy.MakeFaceHW( 20,20, 1 )
-quadBig = geompy.MakeTranslation( quadBig, 15,15,0 )
-quadSmall = geompy.MakeFaceHW( 10,10, 1 )
-smallQuads1 = geompy.MakeMultiTranslation1D( quadSmall, OX, 10, 3 )
-smallQuads2 = geompy.MakeMultiTranslation1D( quadSmall, OY, 10, 3 )
-smallQuads2 = geompy.SubShapeAllSortedCentres( smallQuads2, geompy.ShapeType["FACE"])[1:]
-
-base = geompy.MakeCompound( smallQuads2 + [smallQuads1, quadBig])
-axis = geompy.MakeLine( geompy.MakeVertex( 25,25,0), OZ )
-base = geompy.MultiRotate1DNbTimes( base, axis, 4)
-base = geompy.MakePartition( [base], theName="base")
-path = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0])
-
-# Make the pipe, each quadrangle of the base turns into a prism with composite wall faces
-pipe = geompy.MakePipe( base, path )
-prisms = geompy.MakePartition( [pipe], theName="prisms")
-
-
-# get base faces of the prism to define sub-mesh on them
-smallQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 0,0,0 ), "smallQuad")
-bigQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 15,15,0 ), "bigQuad")
-
-
-mesh = smesh.Mesh( prisms )
-
-# assign Global hypotheses
-
-# 1D algorithm and hypothesis for vertical division
-mesh.Segment().NumberOfSegments(15)
-
-# Extrusion 3D algo
-mesh.Prism()
-
-# assign Local hypotheses
-
-# 1D and 2D algos and hyps to mesh smallQuad with quadrilaterals
-mesh.Segment(smallQuad).LocalLength( 3 )
-mesh.Quadrangle(smallQuad)
-
-# 1D and 2D algos and hyps to mesh bigQuad with triangles
-mesh.Segment(bigQuad).LocalLength( 3 )
-mesh.Triangle(bigQuad)
-
-# compute the mesh
-mesh.Compute()
-
-\endcode
+\include prism_3d_algo.py
+<a href="../../examples/SMESH/prism_3d_algo.py">Download this script</a>
The result geometry and mesh is shown below
\image html prism_tui_sample.png
\page tui_quality_controls_page Quality Controls
\section tui_free_borders Free Borders
-
-\code
-import salome
-import geompy
-
-import smesh
-
-# create open shell: a box without one plane
-box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-FaceList.remove(FaceList[5])
-box = geompy.MakeShell(FaceList)
-idbox = geompy.addToStudy(box, "box")
-
-# create a mesh
-mesh = smesh.Mesh(box, "Mesh_free_borders")
-algo = mesh.Segment()
-algo.NumberOfSegments(5)
-algo = mesh.Triangle()
-algo.MaxElementArea(20.)
-mesh.Compute()
-
-# criterion : free borders
-aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders)
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Free borders Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateGroup(SMESH.EDGE, "Free borders")
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex01.py
+<a href="../../examples/SMESH/quality_controls_ex01.py">Download this script</a>
\section tui_borders_at_multiconnection Borders at Multiconnection
-
-\code
-import salome
-import geompy
-
-import smesh
-import SMESH
-
-# create open shell: a box without one plane
-box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-FaceList.remove(FaceList[5])
-box = geompy.MakeShell(FaceList)
-idbox = geompy.addToStudy(box, "box")
-
-# create a mesh
-mesh = smesh.Mesh(box, "Mesh_borders_at_multi-connections")
-algo = mesh.Segment()
-algo.NumberOfSegments(5)
-algo = mesh.Triangle()
-algo.MaxElementArea(20.)
-mesh.Compute()
-
-# Criterion : Borders at multi-connection
-nb_conn = 2
-
-aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, nb_conn)
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Borders at multi-connections Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateGroup(SMESH.EDGE, "Borders at multi-connections")
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex02.py
+<a href="../../examples/SMESH/quality_controls_ex02.py">Download this script</a>
\section tui_length_1d Length 1D
-
-\code
-import salome
-import geompy
-
-import smesh
-
-# create open shell: a box without one plane
-box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-FaceList.remove(FaceList[5])
-box = geompy.MakeShell(FaceList)
-idbox = geompy.addToStudy(box, "box")
-
-# create a mesh
-mesh = smesh.Mesh(box, "Mesh_Length_1D")
-algo = mesh.Segment()
-algo.NumberOfSegments(5)
-algo = mesh.Triangle()
-algo.MaxElementArea(20.)
-mesh.Compute()
-
-# Criterion : Length > 3.
-length_margin = 3.
-
-aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, length_margin)
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex03.py
+<a href="../../examples/SMESH/quality_controls_ex03.py">Download this script</a>
\section tui_free_edges Free Edges
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-aFilterMgr = smesh.CreateFilterManager()
-
-# Remove some elements to obtain free edges
-# Criterion : AREA > 95.
-area_margin = 95.
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-mesh.RemoveElements(anIds)
-
-# Criterion : Free Edges
-aBorders = mesh.GetFreeBorders()
-
-# create groups
-aGroupF = mesh.CreateEmptyGroup(smesh.FACE, "Faces with free edges")
-aGroupN = mesh.CreateEmptyGroup(smesh.NODE, "Nodes on free edges")
-
-# fill groups with elements, corresponding to the criterion
-print ""
-print "Criterion: Free edges Nb = ", len(aBorders)
-for i in range(len(aBorders)):
- aBorder = aBorders[i]
- print "Face # ", aBorder.myElemId, " : Edge between nodes (",
- print aBorder.myPnt1, ", ", aBorder.myPnt2, ")"
-
- aGroupF.Add([aBorder.myElemId])
- aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2])
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex04.py
+<a href="../../examples/SMESH/quality_controls_ex04.py">Download this script</a>
\section tui_free_nodes Free Nodes
-
-\code
-import salome
-import geompy
-
-import smesh
-
-# create box
-box = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
-idbox = geompy.addToStudy(box, "box")
-
-# create a mesh
-mesh = smesh.Mesh(box, "Mesh_free_nodes")
-algo = mesh.Segment()
-algo.NumberOfSegments(10)
-algo = mesh.Triangle(smesh.MEFISTO)
-algo.MaxElementArea(150.)
-mesh.Compute()
-
-# Remove some elements to obtain free nodes
-# Criterion : AREA < 80.
-area_margin = 80.
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, area_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-mesh.RemoveElements(anIds)
-
-# criterion : free nodes
-aFilter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes)
-anNodeIds = mesh.GetIdsFromFilter(aFilter)
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.NODE, "Free_nodes")
-aGroup.Add(anNodeIds)
-
-# print the result
-print "Criterion: Free nodes Nb = ", len(anNodeIds)
-j = 1
-for i in range(len(anNodeIds)):
- if j > 20: j = 1; print ""
- print anNodeIds[i],
- j = j + 1
- pass
-print ""
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex05.py
+<a href="../../examples/SMESH/quality_controls_ex05.py">Download this script</a>
\section tui_free_faces Free Faces
-
-\code
-import salome
-import geompy
-
-####### GEOM part ########
-
-Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
-Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6])
-Box_1 = geompy.GetMainShape(Box_1_vertex_6)
-Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16])
-Box_1 = geompy.GetMainShape(Box_1_vertex_16)
-Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11])
-Box_1 = geompy.GetMainShape(Box_1_vertex_11)
-Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000)
-Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
-
-Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19])
-Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21])
-Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000)
-
-geompy.addToStudy( Box_1, "Box_1" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" )
-geompy.addToStudy( Plane_1, "Plane_1" )
-geompy.addToStudy( Partition_1, "Partition_1" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" )
-geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" )
-geompy.addToStudy( Plane_2, "Plane_2" )
-
-###### SMESH part ######
-import smesh
-
-import StdMeshers
-
-Mesh_1 = smesh.Mesh(Partition_1)
-Regular_1D = Mesh_1.Segment()
-Max_Size_1 = Regular_1D.MaxSize(34.641)
-MEFISTO_2D = Mesh_1.Triangle()
-Tetrahedronn = Mesh_1.Tetrahedron()
-isDone = Mesh_1.Compute()
-
-# create a group of free faces
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces )
-aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
-
-aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Free_faces")
-aGroup.Add(aFaceIds)
-
-# print the result
-print "Criterion: Free faces Nb = ", len(aFaceIds)
-j = 1
-for i in range(len(aFaceIds)):
- if j > 20: j = 1; print ""
- print aFaceIds[i],
- j = j + 1
- pass
-print ""
-
-#filter faces from plane 2
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_2)
-aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
-aGroup.Remove(aFaceIds)
-
-# create a group of shared faces (located on partition boundary inside box)
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_1)
-aFaceIds = Mesh_1.GetIdsFromFilter(aFilter)
-
-aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Shared_faces")
-aGroup.Add(aFaceIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex06.py
+<a href="../../examples/SMESH/quality_controls_ex06.py">Download this script</a>
\section tui_bare_border_faces Bare border faces
-
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-box = geompy.MakeBoxDXDYDZ(100, 100, 100)
-geompy.addToStudy( box, "box" )
-
-mesh = smesh.Mesh(box)
-mesh.Segment().NumberOfSegments(3)
-mesh.Quadrangle()
-mesh.Compute()
-
-# remove 2 faces
-allFaces = mesh.GetElementsByType(FACE)
-mesh.RemoveElements( allFaces[0:2])
-
-bareGroup = mesh.MakeGroup("bare faces", FACE, FT_BareBorderFace)
-assert(bareGroup.Size() == 3)
-\endcode
+\include quality_controls_ex07.py
+<a href="../../examples/SMESH/quality_controls_ex07.py">Download this script</a>
\section tui_bare_border_volumes Bare border volumes
-
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-box = geompy.MakeBoxDXDYDZ(100, 30, 10)
-# the smallest face of the box
-face = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])[0]
-
-geompy.addToStudy( box, "box" )
-geompy.addToStudyInFather( box, face, "face" )
-
-mesh = Mesh(box)
-mesh.AutomaticHexahedralization();
-
-# remove half of mesh faces from the smallest face
-faceFaces = mesh.GetSubMeshElementsId(face)
-faceToRemove = faceFaces[: len(faceFaces)/2]
-mesh.RemoveElements( faceToRemove )
-
-# make a group of volumes missing the removed faces
-bareGroup = mesh.MakeGroup("bare volumes", VOLUME, FT_BareBorderVolume)
-assert(bareGroup.Size() == len( faceToRemove))
-\endcode
+\include quality_controls_ex08.py
+<a href="../../examples/SMESH/quality_controls_ex08.py">Download this script</a>
\section tui_over_constrained_faces Over-constrained faces
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-mesh = Mesh()
-faceFilter = GetFilter(FACE,FT_OverConstrainedFace)
-
-#make an edge
-n1 = mesh.AddNode(0,0,0)
-n2 = mesh.AddNode(10,0,0)
-edge = mesh.AddEdge([n1,n2])
-assert( not mesh.GetIdsFromFilter( faceFilter ))
-
-# make faces
-mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 5)
-assert( 2 == len( mesh.GetIdsFromFilter( faceFilter )))
-\endcode
+\include quality_controls_ex09.py
+<a href="../../examples/SMESH/quality_controls_ex09.py">Download this script</a>
\section tui_over_constrained_volumes Over-constrained volumes
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-mesh = Mesh()
-volumeFilter = GetFilter(VOLUME,FT_OverConstrainedVolume)
-
-# make volumes by extrusion of one face
-n1 = mesh.AddNode(0,0,0)
-n2 = mesh.AddNode(10,0,0)
-edge = mesh.AddEdge([n1,n2])
-mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 1)
-mesh.ExtrusionSweep( mesh.GetElementsByType(FACE), MakeDirStruct(0,0,5), 7)
-assert( 2 == len( mesh.GetIdsFromFilter( volumeFilter )))
-\endcode
+\include quality_controls_ex10.py
+<a href="../../examples/SMESH/quality_controls_ex10.py">Download this script</a>
\section tui_length_2d Length 2D
-
-\code
-import salome
-import geompy
-
-import smesh
-
-# create open shell: a box without one plane
-box = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-FaceList.remove(FaceList[5])
-box = geompy.MakeShell(FaceList)
-idbox = geompy.addToStudy(box, "box")
-
-# create a mesh
-mesh = smesh.Mesh(box, "Mesh_Length_2D")
-algo = mesh.Segment()
-algo.NumberOfSegments(5)
-algo = mesh.Triangle()
-algo.MaxElementArea(20.)
-mesh.Compute()
-
-# Criterion : Length 2D > 5.7
-length_margin = 5.7
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, length_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Faces with length 2D > " + `length_margin`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex11.py
+<a href="../../examples/SMESH/quality_controls_ex11.py">Download this script</a>
\section tui_borders_at_multiconnection_2d Borders at Multiconnection 2D
-
-\code
-import salome
-import geompy
-
-import smesh
-
-# create a compound of two glued boxes
-box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-box2 = geompy.MakeTranslation(box1, 0., 20., 0)
-comp = geompy.MakeCompound([box1, box2])
-box = geompy.MakeGlueFaces(comp, 0.000001)
-idbox = geompy.addToStudy(box, "box")
-
-# create a mesh
-mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh")
-algo = mesh.Segment()
-algo.NumberOfSegments(5)
-algo = mesh.Triangle()
-algo.MaxElementArea(20.)
-mesh.Compute()
-
-# Criterion : MULTI-CONNECTION 2D = 3
-nb_conn = 3
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, smesh.FT_EqualTo, nb_conn)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Borders at multi-connection 2D = " + `nb_conn`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex12.py
+<a href="../../examples/SMESH/quality_controls_ex12.py">Download this script</a>
\section tui_area Area
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : AREA > 100.
-area_margin = 100.
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Area > ", area_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > " + `area_margin`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex13.py
+<a href="../../examples/SMESH/quality_controls_ex13.py">Download this script</a>
\section tui_taper Taper
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : Taper > 3e-20
-taper_margin = 3e-20
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, taper_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Taper > " + `taper_margin`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex14.py
+<a href="../../examples/SMESH/quality_controls_ex14.py">Download this script</a>
\section tui_aspect_ratio Aspect Ratio
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : ASPECT RATIO > 1.8
-ar_margin = 1.8
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, ar_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Aspect Ratio > " + `ar_margin`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex15.py
+<a href="../../examples/SMESH/quality_controls_ex15.py">Download this script</a>
\section tui_minimum_angle Minimum Angle
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : MINIMUM ANGLE < 35.
-min_angle = 35.
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, min_angle)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Minimum Angle < " + `min_angle`)
-
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex16.py
+<a href="../../examples/SMESH/quality_controls_ex16.py">Download this script</a>
\section tui_warping Warping
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : WARP ANGLE > 1e-15
-wa_margin = 1e-15
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, wa_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Warp > " + `wa_margin`)
-
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex17.py
+<a href="../../examples/SMESH/quality_controls_ex17.py">Download this script</a>
\section tui_skew Skew
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : Skew > 38.
-skew_margin = 38.
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, skew_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Skew > " + `skew_margin`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex18.py
+<a href="../../examples/SMESH/quality_controls_ex18.py">Download this script</a>
\section tui_max_element_length_2d Element Diameter 2D
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-salome = SMESH_mechanic.salome
-
-# Criterion : ELEMENT DIAMETER 2D > 10
-mel_2d_margin = 10
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, mel_2d_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Element Diameter 2D Ratio > ", mel_2d_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 2D > " + `mel_2d_margin`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex19.py
+<a href="../../examples/SMESH/quality_controls_ex19.py">Download this script</a>
\section tui_aspect_ratio_3d Aspect Ratio 3D
-
-\code
-import SMESH_mechanic_tetra
-
-smesh = SMESH_mechanic_tetra.smesh
-mesh = SMESH_mechanic_tetra.mesh
-salome = SMESH_mechanic_tetra.salome
-
-# Criterion : ASPECT RATIO 3D > 4.5
-ar_margin = 4.5
-
-aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_MoreThan, ar_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Aspect Ratio 3D > " + `ar_margin`)
-
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex20.py
+<a href="../../examples/SMESH/quality_controls_ex20.py">Download this script</a>
\section tui_volume Volume
-
-\code
-import SMESH_mechanic_tetra
-
-smesh = SMESH_mechanic_tetra.smesh
-mesh = SMESH_mechanic_tetra.mesh
-salome = SMESH_mechanic_tetra.salome
-
-# Criterion : VOLUME < 7.
-volume_margin = 7.
-
-aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_LessThan, volume_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print ""
-print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Volume < " + `volume_margin`)
-
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex21.py
+<a href="../../examples/SMESH/quality_controls_ex21.py">Download this script</a>
\section tui_max_element_length_3d Element Diameter 3D
-
-\code
-import SMESH_mechanic_tetra
-
-smesh = SMESH_mechanic_tetra.smesh
-mesh = SMESH_mechanic_tetra.mesh
-salome = SMESH_mechanic_tetra.salome
-
-# Criterion : ELEMENT DIAMETER 3D > 10
-mel_3d_margin = 10
-
-aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, mel_3d_margin)
-
-anIds = mesh.GetIdsFromFilter(aFilter)
-
-# print the result
-print "Criterion: Element Diameter 3D Ratio > ", mel_3d_margin, " Nb = ", len(anIds)
-j = 1
-for i in range(len(anIds)):
- if j > 20: j = 1; print ""
- print anIds[i],
- j = j + 1
- pass
-print ""
-
-# create a group
-aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 3D > " + `mel_3d_margin`)
-aGroup.Add(anIds)
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include quality_controls_ex22.py
+<a href="../../examples/SMESH/quality_controls_ex22.py">Download this script</a>
*/
<br>
\anchor tui_translation
<h3>Translation</h3>
-
-\code
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-
-# define translation vector
-point = smesh.PointStruct(-150., -150., 0.)
-vector =smesh.DirStruct(point)
-
-# translate a mesh
-doCopy = 1
-
-mesh.Translate([], vector, doCopy)
-\endcode
+\include transforming_meshes_ex01.py
+<a href="../../examples/SMESH/transforming_meshes_ex01.py">Download this script</a>
<br>
\anchor tui_rotation
<h3>Rotation</h3>
-
-\code
-import math
-
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-
-# define rotation axis and angle
-axisXYZ = smesh.AxisStruct(0., 0., 0., 5., 5., 20.)
-angle270 = 1.5 * math.pi
-
-# rotate a mesh
-mesh.Rotate([], axisXYZ, angle270, 1)
-\endcode
+\include transforming_meshes_ex02.py
+<a href="../../examples/SMESH/transforming_meshes_ex02.py">Download this script</a>
<br>
\anchor tui_scale
<h3>Scale</h3>
-
-\code
-import geompy
-Box = geompy.MakeBoxDXDYDZ(200, 200, 200)
-f = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"])
-
-import smesh,SMESH
-import StdMeshers
-Mesh1 = smesh.Mesh(f[0])
-Regular_1D = Mesh1.Segment()
-Nb_Segments_1 = Regular_1D.NumberOfSegments(3)
-Nb_Segments_1.SetDistrType( 0 )
-Quadrangle_2D = Mesh1.Quadrangle()
-isDone = Mesh1.Compute()
-
-#Perform scale opration for the whole mesh and creation of a new mesh
-newMesh = Mesh1.ScaleMakeMesh(Mesh1,SMESH.PointStruct(100,100,200),[0.5,0.3,0.7],True,"ScaledMesh")
-
-#Perform scale operation for the whole mesh and copy elements
-Mesh1.Scale(Mesh1,SMESH.PointStruct(200,100,100),[0.5,0.5,0.5],True,True)
-
-#Perform scale opration for two edges and move elements
-Mesh1.Scale([1,2],SMESH.PointStruct(-100,100,100),[0.8,1.0,0.7],False)
-
-#Perform scale opration for one face and move elements
-Mesh1.Scale([21],SMESH.PointStruct(0,200,200),[0.7,0.7,0.7],False)
-\endcode
+\include transforming_meshes_ex03.py
+<a href="../../examples/SMESH/transforming_meshes_ex03.py">Download this script</a>
<br>
\anchor tui_symmetry
<h3>Symmetry</h3>
-
-\code
-import math
-
-import SMESH_mechanic
-
-smesh = SMESH_mechanic.smesh
-mesh = SMESH_mechanic.mesh
-
-# create a symmetrical copy of the mesh mirrored through a point
-axis = SMESH.AxisStruct(0, 0, 0, 0, 0, 0)
-
-mesh.Mirror([], axis, smesh.POINT, 1)
-\endcode
+\include transforming_meshes_ex04.py
+<a href="../../examples/SMESH/transforming_meshes_ex04.py">Download this script</a>
<br>
\anchor tui_merging_nodes
<h3>Merging Nodes</h3>
-
-\code
-import SMESH_mechanic
-mesh = SMESH_mechanic.mesh
-
-# merge nodes
-Tolerance = 25.0
-
-GroupsOfNodes = mesh.FindCoincidentNodes(Tolerance)
-mesh.MergeNodes(GroupsOfNodes)
-\endcode
+\include transforming_meshes_ex05.py
+<a href="../../examples/SMESH/transforming_meshes_ex05.py">Download this script</a>
<br>
\anchor tui_merging_elements
<h3>Merging Elements</h3>
-
-\code
-import salome
-import geompy
-import smesh
-
-# create a face to be meshed
-px = geompy.MakeVertex(100., 0. , 0. )
-py = geompy.MakeVertex(0. , 100., 0. )
-pz = geompy.MakeVertex(0. , 0. , 100.)
-
-vxy = geompy.MakeVector(px, py)
-arc = geompy.MakeArc(py, pz, px)
-
-wire = geompy.MakeWire([vxy, arc])
-isPlanarFace = 1
-
-face1 = geompy.MakeFace(wire, isPlanarFace)
-id_face1 = geompy.addToStudy(face1, "Face1")
-
-# create a circle to be an extrusion path
-px1 = geompy.MakeVertex( 100., 100., 0.)
-py1 = geompy.MakeVertex(-100., -100., 0.)
-pz1 = geompy.MakeVertex( 0., 0., 50.)
-
-circle = geompy.MakeCircleThreePnt(py1, pz1, px1)
-id_circle = geompy.addToStudy(circle, "Path")
-
-# create a 2D mesh on the face
-trias = smesh.Mesh(face1, "Face : 2D mesh")
-
-algo1D = trias.Segment()
-algo1D.NumberOfSegments(6)
-algo2D = trias.Triangle()
-algo2D.LengthFromEdges()
-
-trias.Compute()
-
-# create a path mesh
-circlemesh = smesh.Mesh(circle, "Path mesh")
-algo = circlemesh.Segment()
-algo.NumberOfSegments(10)
-circlemesh.Compute()
-
-# extrusion of the mesh
-trias.ExtrusionAlongPath([], circlemesh, circle,
- 1, 0, [], 0, smesh.PointStruct(0, 0, 0))
-
-# merge nodes
-print "Number of nodes before MergeNodes:",
-trias.NbNodes()
-tolerance = 0.001
-array_of_nodes_groups = trias.FindCoincidentNodes(tolerance)
-
-trias.MergeNodes(array_of_nodes_groups)
-
-print "Number of nodes after MergeNodes:", trias.NbNodes()
-print ""
-print "Number of elements before MergeEqualElements:"
-print "Edges : ", trias.NbEdges()
-print "Triangles : ", trias.NbTriangles()
-print "Quadrangles: ", trias.NbQuadrangles()
-print "Volumes : ", trias.NbVolumes()
-
-# merge elements
-trias.MergeEqualElements()
-print "Number of elements after MergeEqualElements:"
-print "Edges : ", trias.NbEdges()
-print "Triangles : ", trias.NbTriangles()
-print "Quadrangles: ", trias.NbQuadrangles()
-print "Volumes : ", trias.NbVolumes()
-
-salome.sg.updateObjBrowser(1)
-\endcode
+\include transforming_meshes_ex06.py
+<a href="../../examples/SMESH/transforming_meshes_ex06.py">Download this script</a>
<br><h2>Sewing Meshes</h2>
<br>
\anchor tui_sew_meshes_border_to_side
<h3>Sew Meshes Border to Side</h3>
-
-\code
-import geompy
-import smesh
-
-# create two faces of a box
-box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.)
-facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
-face1 = facesList1[2]
-
-box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
-facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
-face2 = facesList2[1]
-
-edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
-edge1 = edgesList[2]
-
-aComp = geompy.MakeCompound([face1, face2])
-geompy.addToStudy(aComp, "Two faces")
-
-# create a mesh on two faces
-mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
-
-algo1D = mesh.Segment()
-algo1D.NumberOfSegments(9)
-algo2D = mesh.Quadrangle()
-
-algo_local = mesh.Segment(edge1)
-algo_local.Arithmetic1D(1, 4)
-algo_local.Propagation()
-
-mesh.Compute()
-
-# sew border to side
-# FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
-# FirstNodeIDOnSide, LastNodeIDOnSide,
-# CreatePolygons, CreatePolyedrs
-mesh.SewBorderToSide(5, 45, 6, 113, 109, 0, 0)
-\endcode
+\include transforming_meshes_ex07.py
+<a href="../../examples/SMESH/transforming_meshes_ex07.py">Download this script</a>
<br>
\anchor tui_sew_conform_free_borders
<h3>Sew Conform Free Borders</h3>
-
-\code
-import geompy
-import smesh
-
-# create two faces of the box
-box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.)
-facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
-face1 = facesList1[2]
-
-box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
-facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
-face2 = facesList2[1]
-
-edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
-edge1 = edgesList[2]
-
-aComp = geompy.MakeCompound([face1, face2])
-geompy.addToStudy(aComp, "Two faces")
-
-# create a mesh on two faces
-mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
-
-algo1D = mesh.Segment()
-algo1D.NumberOfSegments(9)
-algo2D = mesh.Quadrangle()
-
-algo_local = mesh.Segment(edge1)
-algo_local.Arithmetic1D(1, 4)
-algo_local.Propagation()
-
-mesh.Compute()
-
-# sew conform free borders
-# FirstNodeID1, SecondNodeID1, LastNodeID1, FirstNodeID2, SecondNodeID2
-mesh.SewConformFreeBorders(5, 45, 6, 3, 24)
-\endcode
+\include transforming_meshes_ex08.py
+<a href="../../examples/SMESH/transforming_meshes_ex08.py">Download this script</a>
<br>
\anchor tui_sew_free_borders
<h3>Sew Free Borders</h3>
-
-\code
-import geompy
-import smesh
-
-# create two faces of the box
-box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.)
-facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"])
-face1 = facesList1[2]
-
-box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.)
-facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"])
-face2 = facesList2[1]
-
-edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"])
-edge1 = edgesList[2]
-
-aComp = geompy.MakeCompound([face1, face2])
-geompy.addToStudy(aComp, "Two faces")
-
-# create a mesh on two faces
-mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
-
-algo1D = mesh.Segment()
-algo1D.NumberOfSegments(4)
-algo2D = mesh.Quadrangle()
-
-algo_local = mesh.Segment(edge1)
-algo_local.Arithmetic1D(1, 4)
-algo_local.Propagation()
-
-mesh.Compute()
-
-# sew free borders
-# FirstNodeID1, SecondNodeID1, LastNodeID1,
-# FirstNodeID2, SecondNodeID2, LastNodeID2, CreatePolygons, CreatePolyedrs
-mesh.SewFreeBorders(6, 21, 5, 1, 12, 3, 0, 0)
-\endcode
+\include transforming_meshes_ex09.py
+<a href="../../examples/SMESH/transforming_meshes_ex09.py">Download this script</a>
<br>
\anchor tui_sew_side_elements
<h3>Sew Side Elements</h3>
-
-\code
-import geompy
-import smesh
-
-# create two boxes
-box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.)
-box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.)
-
-EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"])
-
-aComp = geompy.MakeCompound([box1, box2])
-geompy.addToStudy(aComp, "Two boxes")
-
-# create a mesh on two boxes
-mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh")
-
-algo1D = mesh.Segment()
-algo1D.NumberOfSegments(2)
-algo2D = mesh.Quadrangle()
-
-algo_local = mesh.Segment(EdgesList[8])
-algo_local.NumberOfSegments(4)
-algo_local.Propagation()
-
-mesh.Compute()
-
-# sew side elements
-# IDsOfSide1Elements, IDsOfSide2Elements,
-# NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge
-mesh.SewSideElements([69, 70, 71, 72], [91, 92, 89, 90], 8, 38, 23, 58)
-\endcode
+\include transforming_meshes_ex10.py
+<a href="../../examples/SMESH/transforming_meshes_ex10.py">Download this script</a>
<br>
\anchor tui_duplicate_nodes
<h3>Duplicate nodes</h3>
-
-\code
-import salome
-import smesh
-import SMESH_test1
-
-mesh = SMESH_test1.mesh
-
-# Compute mesh
-mesh.Compute()
-
-# Without the duplication of border elements
-
-# Nodes to duplicate
-nodes1 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes1' )
-nodes1.Add( [ 289, 278, 302, 285 ] )
-
-# Group of faces to replace nodes with new ones
-faces1 = mesh.CreateEmptyGroup( smesh.FACE, 'faces1' )
-faces1.Add( [ 519, 556, 557 ] )
-
-# Duplicate nodes
-print "\nMesh before the first nodes duplication:"
-print "Nodes : ", mesh.NbNodes()
-print "Edges : ", mesh.NbEdges()
-print "Triangles : ", mesh.NbTriangles()
-
-groupOfCreatedNodes = mesh.DoubleNodeGroup(nodes1, faces1, theMakeGroup=True)
-print "New nodes:", groupOfCreatedNodes.GetIDs()
-
-print "\nMesh after the first nodes duplication:"
-print "Nodes : ", mesh.NbNodes()
-print "Edges : ", mesh.NbEdges()
-print "Triangles : ", mesh.NbTriangles()
-
-# With the duplication of border elements
-
-# Edges to duplicate
-edges = mesh.CreateEmptyGroup( smesh.EDGE, 'edges' )
-edges.Add( [ 29, 30, 31 ] )
-
-# Nodes not to duplicate
-nodes2 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes2' )
-nodes2.Add( [ 32, 5 ] )
-
-# Group of faces to replace nodes with new ones
-faces2 = mesh.CreateEmptyGroup( smesh.FACE, 'faces2' )
-faces2.Add( [ 576, 578, 580 ] )
-
-# Duplicate nodes
-print "\nMesh before the second nodes duplication:"
-print "Nodes : ", mesh.NbNodes()
-print "Edges : ", mesh.NbEdges()
-print "Triangles : ", mesh.NbTriangles()
-
-groupOfNewEdges = mesh.DoubleNodeElemGroup( edges, nodes2, faces2, theMakeGroup=True )
-print "New edges:", groupOfNewEdges.GetIDs()
-
-print "\nMesh after the second nodes duplication:"
-print "Nodes : ", mesh.NbNodes()
-print "Edges : ", mesh.NbEdges()
-print "Triangles : ", mesh.NbTriangles()
-
-# Update object browser
-if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(0)
-\endcode
+\include transforming_meshes_ex11.py
+<a href="../../examples/SMESH/transforming_meshes_ex11.py">Download this script</a>
<br>
\anchor tui_make_2dmesh_from_3d
<h3>Create boundary elements</h3>
-
-\code
-from smesh import *
-SetCurrentStudy(salome.myStudy)
-
-box = geompy.MakeBoxDXDYDZ(100, 100, 100)
-gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])
-f1,f2 = gFaces[0],gFaces[1]
-geompy.addToStudy(box,"box")
-geompy.addToStudyInFather(box,f1,"face1")
-geompy.addToStudyInFather(box,f2,"face2")
-
-twoFaces = geompy.MakeCompound([f1,f2])
-
-## -----------
-##
-## 2D from 3D
-##
-## -----------
-dim = SMESH.BND_2DFROM3D
-
-init_mesh = Mesh(box, "box")
-init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
-
-# remove some faces
-faces = init_mesh.GetElementsByType( SMESH.FACE )
-nb_faces = len( faces )
-rm_face = faces[ : nb_faces/2]
-init_mesh.RemoveElements( rm_face )
-
-# restore boundary in this mesh
-mesh = CopyMesh( init_mesh, "2D from 3D")
-groupName = "bnd 2D"
-nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
-
-# restore boundary (only) in other mesh
-meshName = "2D boundary of " + init_mesh.GetName()
-nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
-
-# restore boundary in mesh copy
-meshName = init_mesh.GetName() + " + boundary"
-nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
-
-
-## -----------
-##
-## 1D from 2D
-##
-## -----------
-dim = SMESH.BND_1DFROM2D
-
-init_mesh = Mesh(f1, "2D mesh")
-init_mesh.AutomaticHexahedralization()
-
-# remove some edges
-edges = init_mesh.GetElementsByType( SMESH.EDGE )
-nb_edges = len( edges )
-rm_edge = edges[ : nb_edges/2]
-init_mesh.RemoveElements( rm_edge )
-
-
-# restore boundary edges in this mesh
-mesh = CopyMesh( init_mesh, "1D from 2D")
-groupName = "bnd 1D"
-nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName)
-
-# restore boundary edges (only) in other mesh
-meshName = "1D boundary of " + init_mesh.GetName()
-nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName)
-
-# restore boundary edges in mesh copy
-meshName = init_mesh.GetName() + " + boundary"
-nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True)
-
-
-
-## ------------------
-##
-## 1D from 2D GROUPS
-##
-## ------------------
-dim = SMESH.BND_1DFROM3D
-
-init_mesh = Mesh(box, "box")
-init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons
-# remove all edges
-rm_edges = init_mesh.GetElementsByType( SMESH.EDGE )
-init_mesh.RemoveElements( rm_edges )
-
-# make groups of faces
-fGroup1 = init_mesh.Group( f1, "f1" )
-fGroup2 = init_mesh.Group( f2, "f2" )
-
-# make 1D boundary around groups in this mesh
-mesh = CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True)
-groups = mesh.GetGroups()
-nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups)
-
-# make 1D boundary (only) in other mesh
-meshName = "boundary from groups of " + init_mesh.GetName()
-groups = init_mesh.GetGroups()
-nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,groups=groups)
-
-# make 1D boundary in mesh copy
-meshName = init_mesh.GetName() + " + boundary from groups"
-nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,
- groups=groups, toCopyAll=True)
-
-\endcode
+\include transforming_meshes_ex12.py
+<a href="../../examples/SMESH/transforming_meshes_ex12.py">Download this script</a>
<br>
\anchor tui_reorient_faces
<h3>Reorient faces by vector</h3>
-
-\code
-import smesh, geompy, SMESH
-
-# create a geometry consisting of two faces
-box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
-faces = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])
-
-shape = geompy.MakeCompound( faces[:2] )
-faces = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"] )
-geompy.addToStudy( shape, "shape")
-geompy.addToStudyInFather( shape, faces[0], "faces[0]")
-geompy.addToStudyInFather( shape, faces[1], "faces[1]")
-
-# create a 2D mesh
-mesh = smesh.Mesh( shape, "test_Reorient2D")
-mesh.AutomaticHexahedralization(0.5)
-localAlgo = mesh.Segment(faces[0])
-localAlgo.NumberOfSegments( 11 )
-mesh.Compute()
-group = mesh.Group( faces[1] )
-
-vec = geompy.MakeVectorDXDYDZ( 1, 1, 1 )
-
-# Each of arguments of Reorient2D() function can be of different types:
-#
-# 2DObject - the whole mesh
-# Direction - a GEOM object (vector)
-# FaceOrPoint - an ID of face
-mesh.Reorient2D( mesh, vec, mesh.NbElements() )
-#
-# 2DObject - a sub-mesh
-# Direction - components of a vector
-# FaceOrPoint - a GEOM object (vertex)
-mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geompy.GetFirstVertex( vec ))
-#
-# 2DObject - a group of faces
-# Direction - a SMESH.DirStruct structure
-# FaceOrPoint - coordinates of a point
-mesh.Reorient2D( group, smesh.MakeDirStruct( -10, 1, 10 ), [0,0,0])
-#
-# FaceOrPoint - a SMESH.PointStruct structure
-mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0))
-
-\endcode
+\include transforming_meshes_ex13.py
+<a href="../../examples/SMESH/transforming_meshes_ex13.py">Download this script</a>
*/
which is actulally just a stub allowing to use your own 2D algoritm
implemented in Python.
-
-\code
-import smesh, geompy
-import numpy as np
-
-# define my 2D algorithm
-def my2DMeshing( geomFace ):
-
- # find gravity center of geomFace
- gcXYZ = geompy.PointCoordinates( geompy.MakeCDG( geomFace ))
-
- # define order and orientation of edges
- sortedEdges = []
- geomEdges = geompy.SubShapeAll( geomFace, geompy.ShapeType["EDGE"])
- sortedEdges.append(( geomEdges.pop(0), True ))
- while geomEdges:
- prevEdge_rev = sortedEdges[ -1 ]
- prevVV = geompy.SubShapeAll( prevEdge_rev[0], geompy.ShapeType["VERTEX"])
- prevV2 = prevVV[ prevEdge_rev[1] ]
- found = False
- for iE in range( len( geomEdges )):
- v1,v2 = geompy.SubShapeAll( geomEdges[ iE ], geompy.ShapeType["VERTEX"])
- same1,same2 = [( geompy.MinDistance( prevV2, v ) < 1e-7 ) for v in [v1,v2] ]
- if not same1 and not same2: continue
- sortedEdges.append(( geomEdges.pop( iE ), same1 ))
- found = True
- break
- assert found
- sortedEdges.reverse()
-
- # put nodes on edges in a right order
- nodes = []
- for edge, isForward in sortedEdges:
- v1,v2 = geompy.SubShapeAll( edge, geompy.ShapeType["VERTEX"])
- edgeNodes = mesh.GetSubMeshNodesId( v2, all=False ) + \
- mesh.GetSubMeshNodesId( edge, all=False ) + \
- mesh.GetSubMeshNodesId( v1, all=False )
- if not isForward: edgeNodes.reverse()
- nodes.extend( edgeNodes[:-1] )
-
- # create nodes inside the geomFace
- r1 = 0.6
- r2 = 1 - r1
- nodesInside = []
- for n in nodes:
- nXYZ = mesh.GetNodeXYZ( n )
- newXYZ = np.add( np.multiply( r1, gcXYZ ), np.multiply( r2, nXYZ ))
- nodesInside.append( mesh.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] ))
- mesh.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 )
-
- # find out orientation of faces to create
- # geomFace normal
- faceNorm = geompy.GetNormal( geomFace )
- v1,v2 = [ geompy.PointCoordinates( v ) \
- for v in geompy.SubShapeAll( faceNorm, geompy.ShapeType["VERTEX"]) ]
- faceNormXYZ = np.subtract( v2, v1 )
- outDirXYZ = np.subtract( v1, [ 50, 50, 50 ] )
- if np.dot( faceNormXYZ, outDirXYZ ) < 0: # reversed face
- faceNormXYZ = np.multiply( -1., faceNormXYZ )
- # mesh face normal
- e1 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodes[1] ))
- e2 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodesInside[0] ))
- meshNorm = np.cross( e1, e2 )
- # faces orientation
- reverse = ( np.dot( faceNormXYZ, meshNorm ) < 0 )
-
- # create mesh faces
- iN = len( nodes )
- while iN:
- n1, n2, n3, n4 = nodes[iN-1], nodes[iN-2], nodesInside[iN-2], nodesInside[iN-1]
- iN -= 1
- if reverse:
- f = mesh.AddFace( [n1, n2, n3, n4] )
- else:
- f = mesh.AddFace( [n4, n3, n2, n1] )
- # new faces must be assigned to geometry to allow 3D algorithm finding them
- mesh.SetMeshElementOnShape( f, geomFace )
-
- if reverse:
- nodesInside.reverse()
- polygon = mesh.AddPolygonalFace( nodesInside )
- mesh.SetMeshElementOnShape( polygon, geomFace )
-
- return
-
-# create geometry and get faces to mesh with my2DMeshing()
-box = geompy.MakeBoxDXDYDZ( 100, 100, 100 )
-f1 = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0]
-f2 = geompy.GetOppositeFace( box, f1 )
-geompy.addToStudy( box, "box" )
-geompy.addToStudy( f1, "f1" )
-geompy.addToStudy( f2, "f2" )
-
-# compute 1D mesh
-mesh = smesh.Mesh( box )
-mesh.Segment().NumberOfSegments( 5 )
-mesh.Compute()
-
-# compute 2D mesh
-mesh.Quadrangle()
-mesh.UseExistingFaces(f1) # UseExistingFaces() allows using my2DMeshing()
-mesh.UseExistingFaces(f2)
-my2DMeshing( f1 )
-my2DMeshing( f2 )
-assert mesh.Compute()
-
-# compute 3D mesh
-mesh.Prism()
-assert mesh.Compute()
-
-\endcode
+\include use_existing_faces.py
+<a href="../../examples/SMESH/use_existing_faces.py">Download this script</a>
Resulting mesh:
\image html use_existing_face_sample_mesh.png
<br>
\anchor tui_viewing_mesh_infos
<h2>Viewing Mesh Infos</h2>
-
-\code
-import geompy
-import smesh
-import SMESH
-
-# create a box
-box = geompy.MakeBox(0., 0., 0., 20., 20., 20.)
-geompy.addToStudy(box, "box")
-[Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
-
-# create a mesh
-tetra = smesh.Mesh(box, "MeshBox")
-
-algo1D = tetra.Segment()
-algo1D.NumberOfSegments(3)
-
-algo2D = tetra.Triangle()
-algo2D.MaxElementArea(10.)
-
-algo3D = tetra.Tetrahedron()
-algo3D.MaxElementVolume(900.)
-
-# Creation of SubMesh
-Regular_1D_1_1 = tetra.Segment(geom=Face_1)
-Nb_Segments_1 = Regular_1D_1_1.NumberOfSegments(5)
-Nb_Segments_1.SetDistrType( 0 )
-Quadrangle_2D = tetra.Quadrangle(geom=Face_1)
-isDone = tetra.Compute()
-submesh = Regular_1D_1_1.GetSubMesh()
-
-# compute the mesh
-tetra.Compute()
-
-# Creation of group
-group = tetra.CreateEmptyGroup( SMESH.FACE, 'Group' )
-nbAdd = group.Add( [ 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76 ] )
-
-# Print information about the mesh
-print "Information about mesh:"
-print "Number of nodes : ", tetra.NbNodes()
-print "Number of edges : ", tetra.NbEdges()
-print "Number of faces : ", tetra.NbFaces()
-print " triangles : ", tetra.NbTriangles()
-print " quadrangles : ", tetra.NbQuadrangles()
-print " polygons : ", tetra.NbPolygons()
-print "Number of volumes : ", tetra.NbVolumes()
-print " tetrahedrons: ", tetra.NbTetras()
-print " hexahedrons : ", tetra.NbHexas()
-print " prisms : ", tetra.NbPrisms()
-print " pyramids : ", tetra.NbPyramids()
-print " polyhedrons : ", tetra.NbPolyhedrons()
-
-# Get Information About Mesh by GetMeshInfo
-print "\nInformation about mesh by GetMeshInfo:"
-info = smesh.GetMeshInfo(tetra)
-keys = info.keys(); keys.sort()
-for i in keys:
- print " %s : %d" % ( i, info[i] )
- pass
-
-# Get Information About Group by GetMeshInfo
-print "\nInformation about group by GetMeshInfo:"
-info = smesh.GetMeshInfo(group)
-keys = info.keys(); keys.sort()
-for i in keys:
- print " %s : %d" % ( i, info[i] )
- pass
-
-# Get Information About SubMesh by GetMeshInfo
-print "\nInformation about Submesh by GetMeshInfo:"
-info = smesh.GetMeshInfo(submesh)
-keys = info.keys(); keys.sort()
-for i in keys:
- print " %s : %d" % ( i, info[i] )
- pass
-\endcode
-
-
+\include viewing_meshes_ex01.py
+<a href="../../examples/SMESH/viewing_meshes_ex01.py">Download this script</a>
<br>
\anchor tui_find_element_by_point
<h2>Find Element by Point</h2>
-
-\code
-import geompy
-import smesh
-import SMESH
-
-# Create a geometry to mesh
-box = geompy.MakeBoxDXDYDZ(100,100,100)
-
-# Create a mesh
-mesh = Mesh(box,"Mesh")
-mesh.AutomaticHexahedralization()
-mesh.Compute()
-
-# Create a point
-x,y,z = 0, 0, 1
-
-# Find all elements (except 0D ones) located at the point
-all_elems_except_0D = mesh.FindElementsByPoint(x,y,z)
-assert( len(all_elems_except_0D) == 4)
-
-# Find nodes at the point
-nodes = mesh.FindElementsByPoint(x,y,z, SMESH.NODE )
-assert( len(nodes) == 0)
-assert( len( mesh.FindElementsByPoint(x,y,0, SMESH.NODE)) == 1)
-
-# Find an edge at the point
-edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE )
-assert( len(edges) == 1)
-
-# Find faces at the point
-edges = mesh.FindElementsByPoint(x,y,z, SMESH.FACE )
-assert( len(edges) == 2)
-
-# Find a volume at the point
-vols = mesh.FindElementsByPoint(x,y,z, SMESH.VOLUME )
-assert( len(vols) == 1)
-
-# Find 0D elements at the point
-elems0d = mesh.FindElementsByPoint(x,y,z, SMESH.ELEM0D )
-assert( len(elems0d) == 0)
-
-# Find edges within a group
-group1D = mesh.MakeGroupByIds("1D", SMESH.EDGE, [1,2] )
-edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE, group1D )
-
-\endcode
+\include viewing_meshes_ex02.py
+<a href="../../examples/SMESH/viewing_meshes_ex02.py">Download this script</a>
*/