mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-29 19:00:35 +05:00
0021895: EDF 2372 GEOM SMESH : Generate the doc examples from real python scripts
This commit is contained in:
parent
aea880cf9e
commit
46ecd4169e
@ -537,6 +537,7 @@ AC_OUTPUT([ \
|
|||||||
doc/docutils/Makefile \
|
doc/docutils/Makefile \
|
||||||
doc/docutils/conf.py \
|
doc/docutils/conf.py \
|
||||||
doc/salome/Makefile \
|
doc/salome/Makefile \
|
||||||
|
doc/salome/examples/Makefile \
|
||||||
doc/salome/gui/Makefile \
|
doc/salome/gui/Makefile \
|
||||||
doc/salome/gui/SMESH/Makefile \
|
doc/salome/gui/SMESH/Makefile \
|
||||||
doc/salome/gui/SMESH/doxyfile \
|
doc/salome/gui/SMESH/doxyfile \
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
# Modified by : Alexander BORODIN (OCN) - autotools usage
|
# Modified by : Alexander BORODIN (OCN) - autotools usage
|
||||||
# $Header:
|
# $Header:
|
||||||
#
|
#
|
||||||
SUBDIRS = tui gui
|
SUBDIRS = tui gui examples
|
||||||
SUBDIRSTUI = tui
|
SUBDIRSTUI = tui
|
||||||
SUBDIRSGUI = gui
|
SUBDIRSGUI = gui
|
||||||
|
|
||||||
|
72
doc/salome/examples/3dmesh.py
Normal file
72
doc/salome/examples/3dmesh.py
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# 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)
|
180
doc/salome/examples/Makefile.am
Normal file
180
doc/salome/examples/Makefile.am
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
# 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
|
42
doc/salome/examples/cartesian_algo.py
Normal file
42
doc/salome/examples/cartesian_algo.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# 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
|
28
doc/salome/examples/creating_meshes_ex01.py
Normal file
28
doc/salome/examples/creating_meshes_ex01.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# 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
|
39
doc/salome/examples/creating_meshes_ex02.py
Normal file
39
doc/salome/examples/creating_meshes_ex02.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# 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()
|
57
doc/salome/examples/creating_meshes_ex03.py
Normal file
57
doc/salome/examples/creating_meshes_ex03.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# 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()
|
54
doc/salome/examples/creating_meshes_ex04.py
Normal file
54
doc/salome/examples/creating_meshes_ex04.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# 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)
|
31
doc/salome/examples/creating_meshes_ex05.py
Normal file
31
doc/salome/examples/creating_meshes_ex05.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# 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)
|
106
doc/salome/examples/creating_meshes_ex06.py
Normal file
106
doc/salome/examples/creating_meshes_ex06.py
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# 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)
|
73
doc/salome/examples/creating_meshes_ex07.py
Normal file
73
doc/salome/examples/creating_meshes_ex07.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
# 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')
|
40
doc/salome/examples/creating_meshes_ex08.py
Normal file
40
doc/salome/examples/creating_meshes_ex08.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# 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" )
|
30
doc/salome/examples/defining_hypotheses_ex01.py
Normal file
30
doc/salome/examples/defining_hypotheses_ex01.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# 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()
|
40
doc/salome/examples/defining_hypotheses_ex02.py
Normal file
40
doc/salome/examples/defining_hypotheses_ex02.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# 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()
|
37
doc/salome/examples/defining_hypotheses_ex03.py
Normal file
37
doc/salome/examples/defining_hypotheses_ex03.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# 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()
|
37
doc/salome/examples/defining_hypotheses_ex04.py
Normal file
37
doc/salome/examples/defining_hypotheses_ex04.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# 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()
|
38
doc/salome/examples/defining_hypotheses_ex05.py
Normal file
38
doc/salome/examples/defining_hypotheses_ex05.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# 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()
|
30
doc/salome/examples/defining_hypotheses_ex06.py
Normal file
30
doc/salome/examples/defining_hypotheses_ex06.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# 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"
|
29
doc/salome/examples/defining_hypotheses_ex07.py
Normal file
29
doc/salome/examples/defining_hypotheses_ex07.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# 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()
|
35
doc/salome/examples/defining_hypotheses_ex08.py
Normal file
35
doc/salome/examples/defining_hypotheses_ex08.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# 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()
|
45
doc/salome/examples/defining_hypotheses_ex09.py
Normal file
45
doc/salome/examples/defining_hypotheses_ex09.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# 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()
|
76
doc/salome/examples/defining_hypotheses_ex10.py
Normal file
76
doc/salome/examples/defining_hypotheses_ex10.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# 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)
|
31
doc/salome/examples/defining_hypotheses_ex11.py
Normal file
31
doc/salome/examples/defining_hypotheses_ex11.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# 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()
|
36
doc/salome/examples/defining_hypotheses_ex12.py
Normal file
36
doc/salome/examples/defining_hypotheses_ex12.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# 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()
|
34
doc/salome/examples/defining_hypotheses_ex13.py
Normal file
34
doc/salome/examples/defining_hypotheses_ex13.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# 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()
|
26
doc/salome/examples/defining_hypotheses_ex14.py
Normal file
26
doc/salome/examples/defining_hypotheses_ex14.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# 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()
|
47
doc/salome/examples/defining_hypotheses_ex15.py
Normal file
47
doc/salome/examples/defining_hypotheses_ex15.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# 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()
|
43
doc/salome/examples/defining_hypotheses_ex16.py
Normal file
43
doc/salome/examples/defining_hypotheses_ex16.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# "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()
|
40
doc/salome/examples/defining_hypotheses_ex17.py
Normal file
40
doc/salome/examples/defining_hypotheses_ex17.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex01.py
Normal file
8
doc/salome/examples/filters_ex01.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
10
doc/salome/examples/filters_ex02.py
Normal file
10
doc/salome/examples/filters_ex02.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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)
|
11
doc/salome/examples/filters_ex03.py
Normal file
11
doc/salome/examples/filters_ex03.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex04.py
Normal file
8
doc/salome/examples/filters_ex04.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex05.py
Normal file
8
doc/salome/examples/filters_ex05.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex06.py
Normal file
8
doc/salome/examples/filters_ex06.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
12
doc/salome/examples/filters_ex07.py
Normal file
12
doc/salome/examples/filters_ex07.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 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)
|
10
doc/salome/examples/filters_ex08.py
Normal file
10
doc/salome/examples/filters_ex08.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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)
|
14
doc/salome/examples/filters_ex09.py
Normal file
14
doc/salome/examples/filters_ex09.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# 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)
|
14
doc/salome/examples/filters_ex10.py
Normal file
14
doc/salome/examples/filters_ex10.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# 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)
|
10
doc/salome/examples/filters_ex11.py
Normal file
10
doc/salome/examples/filters_ex11.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex12.py
Normal file
8
doc/salome/examples/filters_ex12.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
10
doc/salome/examples/filters_ex13.py
Normal file
10
doc/salome/examples/filters_ex13.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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
|
9
doc/salome/examples/filters_ex14.py
Normal file
9
doc/salome/examples/filters_ex14.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# 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)
|
7
doc/salome/examples/filters_ex15.py
Normal file
7
doc/salome/examples/filters_ex15.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# 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
|
21
doc/salome/examples/filters_ex16.py
Normal file
21
doc/salome/examples/filters_ex16.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# 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 ))
|
16
doc/salome/examples/filters_ex17.py
Normal file
16
doc/salome/examples/filters_ex17.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# 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 ))
|
8
doc/salome/examples/filters_ex18.py
Normal file
8
doc/salome/examples/filters_ex18.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex19.py
Normal file
8
doc/salome/examples/filters_ex19.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex20.py
Normal file
8
doc/salome/examples/filters_ex20.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex21.py
Normal file
8
doc/salome/examples/filters_ex21.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex22.py
Normal file
8
doc/salome/examples/filters_ex22.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
10
doc/salome/examples/filters_ex23.py
Normal file
10
doc/salome/examples/filters_ex23.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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)
|
12
doc/salome/examples/filters_ex24.py
Normal file
12
doc/salome/examples/filters_ex24.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 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
|
10
doc/salome/examples/filters_ex25.py
Normal file
10
doc/salome/examples/filters_ex25.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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
|
8
doc/salome/examples/filters_ex26.py
Normal file
8
doc/salome/examples/filters_ex26.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex27.py
Normal file
8
doc/salome/examples/filters_ex27.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
12
doc/salome/examples/filters_ex28.py
Normal file
12
doc/salome/examples/filters_ex28.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 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)
|
8
doc/salome/examples/filters_ex29.py
Normal file
8
doc/salome/examples/filters_ex29.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 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)
|
12
doc/salome/examples/filters_ex30.py
Normal file
12
doc/salome/examples/filters_ex30.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 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)
|
12
doc/salome/examples/filters_ex31.py
Normal file
12
doc/salome/examples/filters_ex31.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# 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)
|
10
doc/salome/examples/filters_ex32.py
Normal file
10
doc/salome/examples/filters_ex32.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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)
|
17
doc/salome/examples/filters_ex33.py
Normal file
17
doc/salome/examples/filters_ex33.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# 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)
|
14
doc/salome/examples/filters_ex34.py
Normal file
14
doc/salome/examples/filters_ex34.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# 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)
|
19
doc/salome/examples/filters_ex35.py
Normal file
19
doc/salome/examples/filters_ex35.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# 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)
|
13
doc/salome/examples/filters_ex36.py
Normal file
13
doc/salome/examples/filters_ex36.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# 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)
|
57
doc/salome/examples/generate_flat_elements.py
Normal file
57
doc/salome/examples/generate_flat_elements.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# 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])
|
21
doc/salome/examples/grouping_elements_ex01.py
Normal file
21
doc/salome/examples/grouping_elements_ex01.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# 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)
|
39
doc/salome/examples/grouping_elements_ex02.py
Normal file
39
doc/salome/examples/grouping_elements_ex02.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# 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)
|
39
doc/salome/examples/grouping_elements_ex03.py
Normal file
39
doc/salome/examples/grouping_elements_ex03.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# 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)
|
43
doc/salome/examples/grouping_elements_ex04.py
Normal file
43
doc/salome/examples/grouping_elements_ex04.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# 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)
|
52
doc/salome/examples/grouping_elements_ex05.py
Normal file
52
doc/salome/examples/grouping_elements_ex05.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# 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)
|
36
doc/salome/examples/grouping_elements_ex06.py
Normal file
36
doc/salome/examples/grouping_elements_ex06.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# 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)
|
34
doc/salome/examples/grouping_elements_ex07.py
Normal file
34
doc/salome/examples/grouping_elements_ex07.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# 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)
|
35
doc/salome/examples/grouping_elements_ex08.py
Normal file
35
doc/salome/examples/grouping_elements_ex08.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# 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)
|
48
doc/salome/examples/measurements_ex01.py
Normal file
48
doc/salome/examples/measurements_ex01.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# 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...
|
||||||
|
|
22
doc/salome/examples/measurements_ex02.py
Normal file
22
doc/salome/examples/measurements_ex02.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# 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...
|
11
doc/salome/examples/modifying_meshes_ex01.py
Normal file
11
doc/salome/examples/modifying_meshes_ex01.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# 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
|
15
doc/salome/examples/modifying_meshes_ex02.py
Normal file
15
doc/salome/examples/modifying_meshes_ex02.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 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
|
42
doc/salome/examples/modifying_meshes_ex03.py
Normal file
42
doc/salome/examples/modifying_meshes_ex03.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# 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 ))
|
15
doc/salome/examples/modifying_meshes_ex04.py
Normal file
15
doc/salome/examples/modifying_meshes_ex04.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 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
|
15
doc/salome/examples/modifying_meshes_ex05.py
Normal file
15
doc/salome/examples/modifying_meshes_ex05.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 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
|
18
doc/salome/examples/modifying_meshes_ex06.py
Normal file
18
doc/salome/examples/modifying_meshes_ex06.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# 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
|
15
doc/salome/examples/modifying_meshes_ex07.py
Normal file
15
doc/salome/examples/modifying_meshes_ex07.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# 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
|
19
doc/salome/examples/modifying_meshes_ex08.py
Normal file
19
doc/salome/examples/modifying_meshes_ex08.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# 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
|
32
doc/salome/examples/modifying_meshes_ex09.py
Normal file
32
doc/salome/examples/modifying_meshes_ex09.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# 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)
|
56
doc/salome/examples/modifying_meshes_ex10.py
Normal file
56
doc/salome/examples/modifying_meshes_ex10.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# 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)
|
10
doc/salome/examples/modifying_meshes_ex11.py
Normal file
10
doc/salome/examples/modifying_meshes_ex11.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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."
|
10
doc/salome/examples/modifying_meshes_ex12.py
Normal file
10
doc/salome/examples/modifying_meshes_ex12.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# 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."
|
13
doc/salome/examples/modifying_meshes_ex13.py
Normal file
13
doc/salome/examples/modifying_meshes_ex13.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# 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."
|
9
doc/salome/examples/modifying_meshes_ex14.py
Normal file
9
doc/salome/examples/modifying_meshes_ex14.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Renumbering Nodes and Elements
|
||||||
|
|
||||||
|
import SMESH_mechanic
|
||||||
|
|
||||||
|
mesh = SMESH_mechanic.mesh
|
||||||
|
|
||||||
|
mesh.RenumberNodes()
|
||||||
|
|
||||||
|
mesh.RenumberElements()
|
43
doc/salome/examples/modifying_meshes_ex15.py
Normal file
43
doc/salome/examples/modifying_meshes_ex15.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# 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] )
|
44
doc/salome/examples/modifying_meshes_ex16.py
Normal file
44
doc/salome/examples/modifying_meshes_ex16.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# 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)
|
44
doc/salome/examples/modifying_meshes_ex17.py
Normal file
44
doc/salome/examples/modifying_meshes_ex17.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# 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)
|
44
doc/salome/examples/modifying_meshes_ex18.py
Normal file
44
doc/salome/examples/modifying_meshes_ex18.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# 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)
|
35
doc/salome/examples/modifying_meshes_ex19.py
Normal file
35
doc/salome/examples/modifying_meshes_ex19.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# 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)
|
9
doc/salome/examples/modifying_meshes_ex20.py
Normal file
9
doc/salome/examples/modifying_meshes_ex20.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# 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)
|
27
doc/salome/examples/modifying_meshes_ex21.py
Normal file
27
doc/salome/examples/modifying_meshes_ex21.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# 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)
|
26
doc/salome/examples/modifying_meshes_ex22.py
Normal file
26
doc/salome/examples/modifying_meshes_ex22.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# 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)
|
126
doc/salome/examples/modifying_meshes_ex23.py
Normal file
126
doc/salome/examples/modifying_meshes_ex23.py
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
# 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)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user