From 46ecd4169ed9380c2796d7014cd32646049ffc25 Mon Sep 17 00:00:00 2001 From: akl Date: Fri, 8 Feb 2013 14:11:14 +0000 Subject: [PATCH] 0021895: EDF 2372 GEOM SMESH : Generate the doc examples from real python scripts --- configure.ac | 1 + doc/salome/Makefile.am | 2 +- doc/salome/examples/3dmesh.py | 72 ++ doc/salome/examples/Makefile.am | 180 ++++ doc/salome/examples/cartesian_algo.py | 42 + doc/salome/examples/creating_meshes_ex01.py | 28 + doc/salome/examples/creating_meshes_ex02.py | 39 + doc/salome/examples/creating_meshes_ex03.py | 57 ++ doc/salome/examples/creating_meshes_ex04.py | 54 + doc/salome/examples/creating_meshes_ex05.py | 31 + doc/salome/examples/creating_meshes_ex06.py | 106 ++ doc/salome/examples/creating_meshes_ex07.py | 73 ++ doc/salome/examples/creating_meshes_ex08.py | 40 + .../examples/defining_hypotheses_ex01.py | 30 + .../examples/defining_hypotheses_ex02.py | 40 + .../examples/defining_hypotheses_ex03.py | 37 + .../examples/defining_hypotheses_ex04.py | 37 + .../examples/defining_hypotheses_ex05.py | 38 + .../examples/defining_hypotheses_ex06.py | 30 + .../examples/defining_hypotheses_ex07.py | 29 + .../examples/defining_hypotheses_ex08.py | 35 + .../examples/defining_hypotheses_ex09.py | 45 + .../examples/defining_hypotheses_ex10.py | 76 ++ .../examples/defining_hypotheses_ex11.py | 31 + .../examples/defining_hypotheses_ex12.py | 36 + .../examples/defining_hypotheses_ex13.py | 34 + .../examples/defining_hypotheses_ex14.py | 26 + .../examples/defining_hypotheses_ex15.py | 47 + .../examples/defining_hypotheses_ex16.py | 43 + .../examples/defining_hypotheses_ex17.py | 40 + doc/salome/examples/filters_ex01.py | 8 + doc/salome/examples/filters_ex02.py | 10 + doc/salome/examples/filters_ex03.py | 11 + doc/salome/examples/filters_ex04.py | 8 + doc/salome/examples/filters_ex05.py | 8 + doc/salome/examples/filters_ex06.py | 8 + doc/salome/examples/filters_ex07.py | 12 + doc/salome/examples/filters_ex08.py | 10 + doc/salome/examples/filters_ex09.py | 14 + doc/salome/examples/filters_ex10.py | 14 + doc/salome/examples/filters_ex11.py | 10 + doc/salome/examples/filters_ex12.py | 8 + doc/salome/examples/filters_ex13.py | 10 + doc/salome/examples/filters_ex14.py | 9 + doc/salome/examples/filters_ex15.py | 7 + doc/salome/examples/filters_ex16.py | 21 + doc/salome/examples/filters_ex17.py | 16 + doc/salome/examples/filters_ex18.py | 8 + doc/salome/examples/filters_ex19.py | 8 + doc/salome/examples/filters_ex20.py | 8 + doc/salome/examples/filters_ex21.py | 8 + doc/salome/examples/filters_ex22.py | 8 + doc/salome/examples/filters_ex23.py | 10 + doc/salome/examples/filters_ex24.py | 12 + doc/salome/examples/filters_ex25.py | 10 + doc/salome/examples/filters_ex26.py | 8 + doc/salome/examples/filters_ex27.py | 8 + doc/salome/examples/filters_ex28.py | 12 + doc/salome/examples/filters_ex29.py | 8 + doc/salome/examples/filters_ex30.py | 12 + doc/salome/examples/filters_ex31.py | 12 + doc/salome/examples/filters_ex32.py | 10 + doc/salome/examples/filters_ex33.py | 17 + doc/salome/examples/filters_ex34.py | 14 + doc/salome/examples/filters_ex35.py | 19 + doc/salome/examples/filters_ex36.py | 13 + doc/salome/examples/generate_flat_elements.py | 57 ++ doc/salome/examples/grouping_elements_ex01.py | 21 + doc/salome/examples/grouping_elements_ex02.py | 39 + doc/salome/examples/grouping_elements_ex03.py | 39 + doc/salome/examples/grouping_elements_ex04.py | 43 + doc/salome/examples/grouping_elements_ex05.py | 52 + doc/salome/examples/grouping_elements_ex06.py | 36 + doc/salome/examples/grouping_elements_ex07.py | 34 + doc/salome/examples/grouping_elements_ex08.py | 35 + doc/salome/examples/measurements_ex01.py | 48 + doc/salome/examples/measurements_ex02.py | 22 + doc/salome/examples/modifying_meshes_ex01.py | 11 + doc/salome/examples/modifying_meshes_ex02.py | 15 + doc/salome/examples/modifying_meshes_ex03.py | 42 + doc/salome/examples/modifying_meshes_ex04.py | 15 + doc/salome/examples/modifying_meshes_ex05.py | 15 + doc/salome/examples/modifying_meshes_ex06.py | 18 + doc/salome/examples/modifying_meshes_ex07.py | 15 + doc/salome/examples/modifying_meshes_ex08.py | 19 + doc/salome/examples/modifying_meshes_ex09.py | 32 + doc/salome/examples/modifying_meshes_ex10.py | 56 + doc/salome/examples/modifying_meshes_ex11.py | 10 + doc/salome/examples/modifying_meshes_ex12.py | 10 + doc/salome/examples/modifying_meshes_ex13.py | 13 + doc/salome/examples/modifying_meshes_ex14.py | 9 + doc/salome/examples/modifying_meshes_ex15.py | 43 + doc/salome/examples/modifying_meshes_ex16.py | 44 + doc/salome/examples/modifying_meshes_ex17.py | 44 + doc/salome/examples/modifying_meshes_ex18.py | 44 + doc/salome/examples/modifying_meshes_ex19.py | 35 + doc/salome/examples/modifying_meshes_ex20.py | 9 + doc/salome/examples/modifying_meshes_ex21.py | 27 + doc/salome/examples/modifying_meshes_ex22.py | 26 + doc/salome/examples/modifying_meshes_ex23.py | 126 +++ doc/salome/examples/modifying_meshes_ex24.py | 21 + doc/salome/examples/modifying_meshes_ex25.py | 130 +++ doc/salome/examples/modifying_meshes_ex26.py | 45 + doc/salome/examples/notebook_smesh.py | 39 + doc/salome/examples/prism_3d_algo.py | 73 ++ doc/salome/examples/quality_controls_ex01.py | 41 + doc/salome/examples/quality_controls_ex02.py | 44 + doc/salome/examples/quality_controls_ex03.py | 43 + doc/salome/examples/quality_controls_ex04.py | 39 + doc/salome/examples/quality_controls_ex05.py | 48 + doc/salome/examples/quality_controls_ex06.py | 73 ++ doc/salome/examples/quality_controls_ex07.py | 19 + doc/salome/examples/quality_controls_ex08.py | 23 + doc/salome/examples/quality_controls_ex09.py | 17 + doc/salome/examples/quality_controls_ex10.py | 15 + doc/salome/examples/quality_controls_ex11.py | 44 + doc/salome/examples/quality_controls_ex12.py | 44 + doc/salome/examples/quality_controls_ex13.py | 30 + doc/salome/examples/quality_controls_ex14.py | 30 + doc/salome/examples/quality_controls_ex15.py | 30 + doc/salome/examples/quality_controls_ex16.py | 31 + doc/salome/examples/quality_controls_ex17.py | 31 + doc/salome/examples/quality_controls_ex18.py | 30 + doc/salome/examples/quality_controls_ex19.py | 30 + doc/salome/examples/quality_controls_ex20.py | 31 + doc/salome/examples/quality_controls_ex21.py | 32 + doc/salome/examples/quality_controls_ex22.py | 30 + doc/salome/examples/testme.py | 28 + .../examples/transforming_meshes_ex01.py | 15 + .../examples/transforming_meshes_ex02.py | 15 + .../examples/transforming_meshes_ex03.py | 26 + .../examples/transforming_meshes_ex04.py | 13 + .../examples/transforming_meshes_ex05.py | 10 + .../examples/transforming_meshes_ex06.py | 73 ++ .../examples/transforming_meshes_ex07.py | 38 + .../examples/transforming_meshes_ex08.py | 36 + .../examples/transforming_meshes_ex09.py | 37 + .../examples/transforming_meshes_ex10.py | 31 + .../examples/transforming_meshes_ex11.py | 66 ++ .../examples/transforming_meshes_ex12.py | 108 ++ .../examples/transforming_meshes_ex13.py | 43 + doc/salome/examples/use_existing_faces.py | 109 ++ doc/salome/examples/viewing_meshes_ex01.py | 76 ++ doc/salome/examples/viewing_meshes_ex02.py | 45 + doc/salome/gui/SMESH/doxyfile.in | 2 +- .../gui/SMESH/input/smeshpy_interface.doc | 77 +- .../gui/SMESH/input/tui_cartesian_algo.doc | 46 +- .../gui/SMESH/input/tui_creating_meshes.doc | 276 +---- .../SMESH/input/tui_defining_hypotheses.doc | 704 +------------ doc/salome/gui/SMESH/input/tui_filters.doc | 462 ++------- .../input/tui_generate_flat_elements.doc | 59 +- .../gui/SMESH/input/tui_grouping_elements.doc | 323 +----- .../gui/SMESH/input/tui_measurements.doc | 79 +- .../gui/SMESH/input/tui_modifying_meshes.doc | 954 +----------------- .../gui/SMESH/input/tui_notebook_smesh.doc | 42 +- .../gui/SMESH/input/tui_prism_3d_algo.doc | 77 +- .../gui/SMESH/input/tui_quality_controls.doc | 819 +-------------- .../SMESH/input/tui_transforming_meshes.doc | 551 +--------- .../SMESH/input/tui_use_existing_faces.doc | 113 +-- .../gui/SMESH/input/tui_viewing_meshes.doc | 130 +-- 160 files changed, 4987 insertions(+), 4431 deletions(-) create mode 100644 doc/salome/examples/3dmesh.py create mode 100644 doc/salome/examples/Makefile.am create mode 100644 doc/salome/examples/cartesian_algo.py create mode 100644 doc/salome/examples/creating_meshes_ex01.py create mode 100644 doc/salome/examples/creating_meshes_ex02.py create mode 100644 doc/salome/examples/creating_meshes_ex03.py create mode 100644 doc/salome/examples/creating_meshes_ex04.py create mode 100644 doc/salome/examples/creating_meshes_ex05.py create mode 100644 doc/salome/examples/creating_meshes_ex06.py create mode 100644 doc/salome/examples/creating_meshes_ex07.py create mode 100644 doc/salome/examples/creating_meshes_ex08.py create mode 100644 doc/salome/examples/defining_hypotheses_ex01.py create mode 100644 doc/salome/examples/defining_hypotheses_ex02.py create mode 100644 doc/salome/examples/defining_hypotheses_ex03.py create mode 100644 doc/salome/examples/defining_hypotheses_ex04.py create mode 100644 doc/salome/examples/defining_hypotheses_ex05.py create mode 100644 doc/salome/examples/defining_hypotheses_ex06.py create mode 100644 doc/salome/examples/defining_hypotheses_ex07.py create mode 100644 doc/salome/examples/defining_hypotheses_ex08.py create mode 100644 doc/salome/examples/defining_hypotheses_ex09.py create mode 100644 doc/salome/examples/defining_hypotheses_ex10.py create mode 100644 doc/salome/examples/defining_hypotheses_ex11.py create mode 100644 doc/salome/examples/defining_hypotheses_ex12.py create mode 100644 doc/salome/examples/defining_hypotheses_ex13.py create mode 100644 doc/salome/examples/defining_hypotheses_ex14.py create mode 100644 doc/salome/examples/defining_hypotheses_ex15.py create mode 100644 doc/salome/examples/defining_hypotheses_ex16.py create mode 100644 doc/salome/examples/defining_hypotheses_ex17.py create mode 100644 doc/salome/examples/filters_ex01.py create mode 100644 doc/salome/examples/filters_ex02.py create mode 100644 doc/salome/examples/filters_ex03.py create mode 100644 doc/salome/examples/filters_ex04.py create mode 100644 doc/salome/examples/filters_ex05.py create mode 100644 doc/salome/examples/filters_ex06.py create mode 100644 doc/salome/examples/filters_ex07.py create mode 100644 doc/salome/examples/filters_ex08.py create mode 100644 doc/salome/examples/filters_ex09.py create mode 100644 doc/salome/examples/filters_ex10.py create mode 100644 doc/salome/examples/filters_ex11.py create mode 100644 doc/salome/examples/filters_ex12.py create mode 100644 doc/salome/examples/filters_ex13.py create mode 100644 doc/salome/examples/filters_ex14.py create mode 100644 doc/salome/examples/filters_ex15.py create mode 100644 doc/salome/examples/filters_ex16.py create mode 100644 doc/salome/examples/filters_ex17.py create mode 100644 doc/salome/examples/filters_ex18.py create mode 100644 doc/salome/examples/filters_ex19.py create mode 100644 doc/salome/examples/filters_ex20.py create mode 100644 doc/salome/examples/filters_ex21.py create mode 100644 doc/salome/examples/filters_ex22.py create mode 100644 doc/salome/examples/filters_ex23.py create mode 100644 doc/salome/examples/filters_ex24.py create mode 100644 doc/salome/examples/filters_ex25.py create mode 100644 doc/salome/examples/filters_ex26.py create mode 100644 doc/salome/examples/filters_ex27.py create mode 100644 doc/salome/examples/filters_ex28.py create mode 100644 doc/salome/examples/filters_ex29.py create mode 100644 doc/salome/examples/filters_ex30.py create mode 100644 doc/salome/examples/filters_ex31.py create mode 100644 doc/salome/examples/filters_ex32.py create mode 100644 doc/salome/examples/filters_ex33.py create mode 100644 doc/salome/examples/filters_ex34.py create mode 100644 doc/salome/examples/filters_ex35.py create mode 100644 doc/salome/examples/filters_ex36.py create mode 100644 doc/salome/examples/generate_flat_elements.py create mode 100644 doc/salome/examples/grouping_elements_ex01.py create mode 100644 doc/salome/examples/grouping_elements_ex02.py create mode 100644 doc/salome/examples/grouping_elements_ex03.py create mode 100644 doc/salome/examples/grouping_elements_ex04.py create mode 100644 doc/salome/examples/grouping_elements_ex05.py create mode 100644 doc/salome/examples/grouping_elements_ex06.py create mode 100644 doc/salome/examples/grouping_elements_ex07.py create mode 100644 doc/salome/examples/grouping_elements_ex08.py create mode 100644 doc/salome/examples/measurements_ex01.py create mode 100644 doc/salome/examples/measurements_ex02.py create mode 100644 doc/salome/examples/modifying_meshes_ex01.py create mode 100644 doc/salome/examples/modifying_meshes_ex02.py create mode 100644 doc/salome/examples/modifying_meshes_ex03.py create mode 100644 doc/salome/examples/modifying_meshes_ex04.py create mode 100644 doc/salome/examples/modifying_meshes_ex05.py create mode 100644 doc/salome/examples/modifying_meshes_ex06.py create mode 100644 doc/salome/examples/modifying_meshes_ex07.py create mode 100644 doc/salome/examples/modifying_meshes_ex08.py create mode 100644 doc/salome/examples/modifying_meshes_ex09.py create mode 100644 doc/salome/examples/modifying_meshes_ex10.py create mode 100644 doc/salome/examples/modifying_meshes_ex11.py create mode 100644 doc/salome/examples/modifying_meshes_ex12.py create mode 100644 doc/salome/examples/modifying_meshes_ex13.py create mode 100644 doc/salome/examples/modifying_meshes_ex14.py create mode 100644 doc/salome/examples/modifying_meshes_ex15.py create mode 100644 doc/salome/examples/modifying_meshes_ex16.py create mode 100644 doc/salome/examples/modifying_meshes_ex17.py create mode 100644 doc/salome/examples/modifying_meshes_ex18.py create mode 100644 doc/salome/examples/modifying_meshes_ex19.py create mode 100644 doc/salome/examples/modifying_meshes_ex20.py create mode 100644 doc/salome/examples/modifying_meshes_ex21.py create mode 100644 doc/salome/examples/modifying_meshes_ex22.py create mode 100644 doc/salome/examples/modifying_meshes_ex23.py create mode 100644 doc/salome/examples/modifying_meshes_ex24.py create mode 100644 doc/salome/examples/modifying_meshes_ex25.py create mode 100644 doc/salome/examples/modifying_meshes_ex26.py create mode 100644 doc/salome/examples/notebook_smesh.py create mode 100644 doc/salome/examples/prism_3d_algo.py create mode 100644 doc/salome/examples/quality_controls_ex01.py create mode 100644 doc/salome/examples/quality_controls_ex02.py create mode 100644 doc/salome/examples/quality_controls_ex03.py create mode 100644 doc/salome/examples/quality_controls_ex04.py create mode 100644 doc/salome/examples/quality_controls_ex05.py create mode 100644 doc/salome/examples/quality_controls_ex06.py create mode 100644 doc/salome/examples/quality_controls_ex07.py create mode 100644 doc/salome/examples/quality_controls_ex08.py create mode 100644 doc/salome/examples/quality_controls_ex09.py create mode 100644 doc/salome/examples/quality_controls_ex10.py create mode 100644 doc/salome/examples/quality_controls_ex11.py create mode 100644 doc/salome/examples/quality_controls_ex12.py create mode 100644 doc/salome/examples/quality_controls_ex13.py create mode 100644 doc/salome/examples/quality_controls_ex14.py create mode 100644 doc/salome/examples/quality_controls_ex15.py create mode 100644 doc/salome/examples/quality_controls_ex16.py create mode 100644 doc/salome/examples/quality_controls_ex17.py create mode 100644 doc/salome/examples/quality_controls_ex18.py create mode 100644 doc/salome/examples/quality_controls_ex19.py create mode 100644 doc/salome/examples/quality_controls_ex20.py create mode 100644 doc/salome/examples/quality_controls_ex21.py create mode 100644 doc/salome/examples/quality_controls_ex22.py create mode 100755 doc/salome/examples/testme.py create mode 100644 doc/salome/examples/transforming_meshes_ex01.py create mode 100644 doc/salome/examples/transforming_meshes_ex02.py create mode 100644 doc/salome/examples/transforming_meshes_ex03.py create mode 100644 doc/salome/examples/transforming_meshes_ex04.py create mode 100644 doc/salome/examples/transforming_meshes_ex05.py create mode 100644 doc/salome/examples/transforming_meshes_ex06.py create mode 100644 doc/salome/examples/transforming_meshes_ex07.py create mode 100644 doc/salome/examples/transforming_meshes_ex08.py create mode 100644 doc/salome/examples/transforming_meshes_ex09.py create mode 100644 doc/salome/examples/transforming_meshes_ex10.py create mode 100644 doc/salome/examples/transforming_meshes_ex11.py create mode 100644 doc/salome/examples/transforming_meshes_ex12.py create mode 100644 doc/salome/examples/transforming_meshes_ex13.py create mode 100644 doc/salome/examples/use_existing_faces.py create mode 100644 doc/salome/examples/viewing_meshes_ex01.py create mode 100644 doc/salome/examples/viewing_meshes_ex02.py diff --git a/configure.ac b/configure.ac index e16a306a3..a949b25d1 100644 --- a/configure.ac +++ b/configure.ac @@ -537,6 +537,7 @@ AC_OUTPUT([ \ doc/docutils/Makefile \ doc/docutils/conf.py \ doc/salome/Makefile \ + doc/salome/examples/Makefile \ doc/salome/gui/Makefile \ doc/salome/gui/SMESH/Makefile \ doc/salome/gui/SMESH/doxyfile \ diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am index 8bf9f392d..10bcc3f25 100644 --- a/doc/salome/Makefile.am +++ b/doc/salome/Makefile.am @@ -23,7 +23,7 @@ # Modified by : Alexander BORODIN (OCN) - autotools usage # $Header: # -SUBDIRS = tui gui +SUBDIRS = tui gui examples SUBDIRSTUI = tui SUBDIRSGUI = gui diff --git a/doc/salome/examples/3dmesh.py b/doc/salome/examples/3dmesh.py new file mode 100644 index 000000000..bd6d3b4cc --- /dev/null +++ b/doc/salome/examples/3dmesh.py @@ -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) diff --git a/doc/salome/examples/Makefile.am b/doc/salome/examples/Makefile.am new file mode 100644 index 000000000..930edd9fc --- /dev/null +++ b/doc/salome/examples/Makefile.am @@ -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 diff --git a/doc/salome/examples/cartesian_algo.py b/doc/salome/examples/cartesian_algo.py new file mode 100644 index 000000000..b15455f28 --- /dev/null +++ b/doc/salome/examples/cartesian_algo.py @@ -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 diff --git a/doc/salome/examples/creating_meshes_ex01.py b/doc/salome/examples/creating_meshes_ex01.py new file mode 100644 index 000000000..0b93356c4 --- /dev/null +++ b/doc/salome/examples/creating_meshes_ex01.py @@ -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 diff --git a/doc/salome/examples/creating_meshes_ex02.py b/doc/salome/examples/creating_meshes_ex02.py new file mode 100644 index 000000000..c541b4add --- /dev/null +++ b/doc/salome/examples/creating_meshes_ex02.py @@ -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() diff --git a/doc/salome/examples/creating_meshes_ex03.py b/doc/salome/examples/creating_meshes_ex03.py new file mode 100644 index 000000000..7b219f3a6 --- /dev/null +++ b/doc/salome/examples/creating_meshes_ex03.py @@ -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() diff --git a/doc/salome/examples/creating_meshes_ex04.py b/doc/salome/examples/creating_meshes_ex04.py new file mode 100644 index 000000000..33106c775 --- /dev/null +++ b/doc/salome/examples/creating_meshes_ex04.py @@ -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) diff --git a/doc/salome/examples/creating_meshes_ex05.py b/doc/salome/examples/creating_meshes_ex05.py new file mode 100644 index 000000000..6ba410307 --- /dev/null +++ b/doc/salome/examples/creating_meshes_ex05.py @@ -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 +tetra.ExportMED("/tmp/groupMED.med", meshPart=group) diff --git a/doc/salome/examples/creating_meshes_ex06.py b/doc/salome/examples/creating_meshes_ex06.py new file mode 100644 index 000000000..96b2a29c7 --- /dev/null +++ b/doc/salome/examples/creating_meshes_ex06.py @@ -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) diff --git a/doc/salome/examples/creating_meshes_ex07.py b/doc/salome/examples/creating_meshes_ex07.py new file mode 100644 index 000000000..3140acee8 --- /dev/null +++ b/doc/salome/examples/creating_meshes_ex07.py @@ -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') diff --git a/doc/salome/examples/creating_meshes_ex08.py b/doc/salome/examples/creating_meshes_ex08.py new file mode 100644 index 000000000..a76e8d175 --- /dev/null +++ b/doc/salome/examples/creating_meshes_ex08.py @@ -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" ) diff --git a/doc/salome/examples/defining_hypotheses_ex01.py b/doc/salome/examples/defining_hypotheses_ex01.py new file mode 100644 index 000000000..6efb1cfb9 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex01.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex02.py b/doc/salome/examples/defining_hypotheses_ex02.py new file mode 100644 index 000000000..b0726a1ca --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex02.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex03.py b/doc/salome/examples/defining_hypotheses_ex03.py new file mode 100644 index 000000000..cfb1ca86c --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex03.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex04.py b/doc/salome/examples/defining_hypotheses_ex04.py new file mode 100644 index 000000000..0a17f5ca1 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex04.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex05.py b/doc/salome/examples/defining_hypotheses_ex05.py new file mode 100644 index 000000000..fcf03d0d6 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex05.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex06.py b/doc/salome/examples/defining_hypotheses_ex06.py new file mode 100644 index 000000000..24bc4da39 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex06.py @@ -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" diff --git a/doc/salome/examples/defining_hypotheses_ex07.py b/doc/salome/examples/defining_hypotheses_ex07.py new file mode 100644 index 000000000..59d7521a2 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex07.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex08.py b/doc/salome/examples/defining_hypotheses_ex08.py new file mode 100644 index 000000000..438773427 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex08.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex09.py b/doc/salome/examples/defining_hypotheses_ex09.py new file mode 100644 index 000000000..9956e4ba5 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex09.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex10.py b/doc/salome/examples/defining_hypotheses_ex10.py new file mode 100644 index 000000000..644908be2 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex10.py @@ -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) diff --git a/doc/salome/examples/defining_hypotheses_ex11.py b/doc/salome/examples/defining_hypotheses_ex11.py new file mode 100644 index 000000000..be5504778 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex11.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex12.py b/doc/salome/examples/defining_hypotheses_ex12.py new file mode 100644 index 000000000..dd891a73e --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex12.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex13.py b/doc/salome/examples/defining_hypotheses_ex13.py new file mode 100644 index 000000000..283984916 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex13.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex14.py b/doc/salome/examples/defining_hypotheses_ex14.py new file mode 100644 index 000000000..6c93e3d27 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex14.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex15.py b/doc/salome/examples/defining_hypotheses_ex15.py new file mode 100644 index 000000000..a08dfbfae --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex15.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex16.py b/doc/salome/examples/defining_hypotheses_ex16.py new file mode 100644 index 000000000..493034020 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex16.py @@ -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() diff --git a/doc/salome/examples/defining_hypotheses_ex17.py b/doc/salome/examples/defining_hypotheses_ex17.py new file mode 100644 index 000000000..dc3ee9bc8 --- /dev/null +++ b/doc/salome/examples/defining_hypotheses_ex17.py @@ -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) diff --git a/doc/salome/examples/filters_ex01.py b/doc/salome/examples/filters_ex01.py new file mode 100644 index 000000000..986904774 --- /dev/null +++ b/doc/salome/examples/filters_ex01.py @@ -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) diff --git a/doc/salome/examples/filters_ex02.py b/doc/salome/examples/filters_ex02.py new file mode 100644 index 000000000..f69217398 --- /dev/null +++ b/doc/salome/examples/filters_ex02.py @@ -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) diff --git a/doc/salome/examples/filters_ex03.py b/doc/salome/examples/filters_ex03.py new file mode 100644 index 000000000..5afe3a44e --- /dev/null +++ b/doc/salome/examples/filters_ex03.py @@ -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) diff --git a/doc/salome/examples/filters_ex04.py b/doc/salome/examples/filters_ex04.py new file mode 100644 index 000000000..d4d31a76c --- /dev/null +++ b/doc/salome/examples/filters_ex04.py @@ -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) diff --git a/doc/salome/examples/filters_ex05.py b/doc/salome/examples/filters_ex05.py new file mode 100644 index 000000000..b15225194 --- /dev/null +++ b/doc/salome/examples/filters_ex05.py @@ -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) diff --git a/doc/salome/examples/filters_ex06.py b/doc/salome/examples/filters_ex06.py new file mode 100644 index 000000000..0f609a569 --- /dev/null +++ b/doc/salome/examples/filters_ex06.py @@ -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) diff --git a/doc/salome/examples/filters_ex07.py b/doc/salome/examples/filters_ex07.py new file mode 100644 index 000000000..723d8d282 --- /dev/null +++ b/doc/salome/examples/filters_ex07.py @@ -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) diff --git a/doc/salome/examples/filters_ex08.py b/doc/salome/examples/filters_ex08.py new file mode 100644 index 000000000..2bc96b672 --- /dev/null +++ b/doc/salome/examples/filters_ex08.py @@ -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) diff --git a/doc/salome/examples/filters_ex09.py b/doc/salome/examples/filters_ex09.py new file mode 100644 index 000000000..0d045b7b7 --- /dev/null +++ b/doc/salome/examples/filters_ex09.py @@ -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) diff --git a/doc/salome/examples/filters_ex10.py b/doc/salome/examples/filters_ex10.py new file mode 100644 index 000000000..bbbdd9889 --- /dev/null +++ b/doc/salome/examples/filters_ex10.py @@ -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) diff --git a/doc/salome/examples/filters_ex11.py b/doc/salome/examples/filters_ex11.py new file mode 100644 index 000000000..4d754bc00 --- /dev/null +++ b/doc/salome/examples/filters_ex11.py @@ -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) diff --git a/doc/salome/examples/filters_ex12.py b/doc/salome/examples/filters_ex12.py new file mode 100644 index 000000000..dfb0f40ba --- /dev/null +++ b/doc/salome/examples/filters_ex12.py @@ -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) diff --git a/doc/salome/examples/filters_ex13.py b/doc/salome/examples/filters_ex13.py new file mode 100644 index 000000000..d5415e20a --- /dev/null +++ b/doc/salome/examples/filters_ex13.py @@ -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 diff --git a/doc/salome/examples/filters_ex14.py b/doc/salome/examples/filters_ex14.py new file mode 100644 index 000000000..45c356cdf --- /dev/null +++ b/doc/salome/examples/filters_ex14.py @@ -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) diff --git a/doc/salome/examples/filters_ex15.py b/doc/salome/examples/filters_ex15.py new file mode 100644 index 000000000..2044c6048 --- /dev/null +++ b/doc/salome/examples/filters_ex15.py @@ -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 diff --git a/doc/salome/examples/filters_ex16.py b/doc/salome/examples/filters_ex16.py new file mode 100644 index 000000000..3c7159d9f --- /dev/null +++ b/doc/salome/examples/filters_ex16.py @@ -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 )) diff --git a/doc/salome/examples/filters_ex17.py b/doc/salome/examples/filters_ex17.py new file mode 100644 index 000000000..b79f4a74d --- /dev/null +++ b/doc/salome/examples/filters_ex17.py @@ -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 )) diff --git a/doc/salome/examples/filters_ex18.py b/doc/salome/examples/filters_ex18.py new file mode 100644 index 000000000..30158e28b --- /dev/null +++ b/doc/salome/examples/filters_ex18.py @@ -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) diff --git a/doc/salome/examples/filters_ex19.py b/doc/salome/examples/filters_ex19.py new file mode 100644 index 000000000..41b7cc762 --- /dev/null +++ b/doc/salome/examples/filters_ex19.py @@ -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) diff --git a/doc/salome/examples/filters_ex20.py b/doc/salome/examples/filters_ex20.py new file mode 100644 index 000000000..37227c49d --- /dev/null +++ b/doc/salome/examples/filters_ex20.py @@ -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) diff --git a/doc/salome/examples/filters_ex21.py b/doc/salome/examples/filters_ex21.py new file mode 100644 index 000000000..0882fe294 --- /dev/null +++ b/doc/salome/examples/filters_ex21.py @@ -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) diff --git a/doc/salome/examples/filters_ex22.py b/doc/salome/examples/filters_ex22.py new file mode 100644 index 000000000..f65421786 --- /dev/null +++ b/doc/salome/examples/filters_ex22.py @@ -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) diff --git a/doc/salome/examples/filters_ex23.py b/doc/salome/examples/filters_ex23.py new file mode 100644 index 000000000..848f8d92c --- /dev/null +++ b/doc/salome/examples/filters_ex23.py @@ -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) diff --git a/doc/salome/examples/filters_ex24.py b/doc/salome/examples/filters_ex24.py new file mode 100644 index 000000000..036ba037e --- /dev/null +++ b/doc/salome/examples/filters_ex24.py @@ -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 diff --git a/doc/salome/examples/filters_ex25.py b/doc/salome/examples/filters_ex25.py new file mode 100644 index 000000000..7e4489848 --- /dev/null +++ b/doc/salome/examples/filters_ex25.py @@ -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 diff --git a/doc/salome/examples/filters_ex26.py b/doc/salome/examples/filters_ex26.py new file mode 100644 index 000000000..3c5ce2965 --- /dev/null +++ b/doc/salome/examples/filters_ex26.py @@ -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) diff --git a/doc/salome/examples/filters_ex27.py b/doc/salome/examples/filters_ex27.py new file mode 100644 index 000000000..10067ea07 --- /dev/null +++ b/doc/salome/examples/filters_ex27.py @@ -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) diff --git a/doc/salome/examples/filters_ex28.py b/doc/salome/examples/filters_ex28.py new file mode 100644 index 000000000..032b966a5 --- /dev/null +++ b/doc/salome/examples/filters_ex28.py @@ -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) diff --git a/doc/salome/examples/filters_ex29.py b/doc/salome/examples/filters_ex29.py new file mode 100644 index 000000000..c256724b3 --- /dev/null +++ b/doc/salome/examples/filters_ex29.py @@ -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) diff --git a/doc/salome/examples/filters_ex30.py b/doc/salome/examples/filters_ex30.py new file mode 100644 index 000000000..19c213810 --- /dev/null +++ b/doc/salome/examples/filters_ex30.py @@ -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) diff --git a/doc/salome/examples/filters_ex31.py b/doc/salome/examples/filters_ex31.py new file mode 100644 index 000000000..a20f7d708 --- /dev/null +++ b/doc/salome/examples/filters_ex31.py @@ -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) diff --git a/doc/salome/examples/filters_ex32.py b/doc/salome/examples/filters_ex32.py new file mode 100644 index 000000000..726ca153f --- /dev/null +++ b/doc/salome/examples/filters_ex32.py @@ -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) diff --git a/doc/salome/examples/filters_ex33.py b/doc/salome/examples/filters_ex33.py new file mode 100644 index 000000000..2fbaab03e --- /dev/null +++ b/doc/salome/examples/filters_ex33.py @@ -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) diff --git a/doc/salome/examples/filters_ex34.py b/doc/salome/examples/filters_ex34.py new file mode 100644 index 000000000..8e63056b4 --- /dev/null +++ b/doc/salome/examples/filters_ex34.py @@ -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) diff --git a/doc/salome/examples/filters_ex35.py b/doc/salome/examples/filters_ex35.py new file mode 100644 index 000000000..369d7323a --- /dev/null +++ b/doc/salome/examples/filters_ex35.py @@ -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) diff --git a/doc/salome/examples/filters_ex36.py b/doc/salome/examples/filters_ex36.py new file mode 100644 index 000000000..7675bc9f6 --- /dev/null +++ b/doc/salome/examples/filters_ex36.py @@ -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) diff --git a/doc/salome/examples/generate_flat_elements.py b/doc/salome/examples/generate_flat_elements.py new file mode 100644 index 000000000..a23c200a4 --- /dev/null +++ b/doc/salome/examples/generate_flat_elements.py @@ -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]) diff --git a/doc/salome/examples/grouping_elements_ex01.py b/doc/salome/examples/grouping_elements_ex01.py new file mode 100644 index 000000000..d0971d621 --- /dev/null +++ b/doc/salome/examples/grouping_elements_ex01.py @@ -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) diff --git a/doc/salome/examples/grouping_elements_ex02.py b/doc/salome/examples/grouping_elements_ex02.py new file mode 100644 index 000000000..228248d7f --- /dev/null +++ b/doc/salome/examples/grouping_elements_ex02.py @@ -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 with default name +aSmeshGroup2 = quadra.GroupOnGeom(aGeomGroupE) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/grouping_elements_ex03.py b/doc/salome/examples/grouping_elements_ex03.py new file mode 100644 index 000000000..05fb69d57 --- /dev/null +++ b/doc/salome/examples/grouping_elements_ex03.py @@ -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) diff --git a/doc/salome/examples/grouping_elements_ex04.py b/doc/salome/examples/grouping_elements_ex04.py new file mode 100644 index 000000000..730a2ca6b --- /dev/null +++ b/doc/salome/examples/grouping_elements_ex04.py @@ -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) diff --git a/doc/salome/examples/grouping_elements_ex05.py b/doc/salome/examples/grouping_elements_ex05.py new file mode 100644 index 000000000..90453fed1 --- /dev/null +++ b/doc/salome/examples/grouping_elements_ex05.py @@ -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) diff --git a/doc/salome/examples/grouping_elements_ex06.py b/doc/salome/examples/grouping_elements_ex06.py new file mode 100644 index 000000000..cc8146fb9 --- /dev/null +++ b/doc/salome/examples/grouping_elements_ex06.py @@ -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) diff --git a/doc/salome/examples/grouping_elements_ex07.py b/doc/salome/examples/grouping_elements_ex07.py new file mode 100644 index 000000000..5bcccd0c7 --- /dev/null +++ b/doc/salome/examples/grouping_elements_ex07.py @@ -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) diff --git a/doc/salome/examples/grouping_elements_ex08.py b/doc/salome/examples/grouping_elements_ex08.py new file mode 100644 index 000000000..a86ec6317 --- /dev/null +++ b/doc/salome/examples/grouping_elements_ex08.py @@ -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) diff --git a/doc/salome/examples/measurements_ex01.py b/doc/salome/examples/measurements_ex01.py new file mode 100644 index 000000000..967754709 --- /dev/null +++ b/doc/salome/examples/measurements_ex01.py @@ -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... + diff --git a/doc/salome/examples/measurements_ex02.py b/doc/salome/examples/measurements_ex02.py new file mode 100644 index 000000000..3333bc0e5 --- /dev/null +++ b/doc/salome/examples/measurements_ex02.py @@ -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... diff --git a/doc/salome/examples/modifying_meshes_ex01.py b/doc/salome/examples/modifying_meshes_ex01.py new file mode 100644 index 000000000..ee183d708 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex01.py @@ -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 diff --git a/doc/salome/examples/modifying_meshes_ex02.py b/doc/salome/examples/modifying_meshes_ex02.py new file mode 100644 index 000000000..c99bf2aff --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex02.py @@ -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 diff --git a/doc/salome/examples/modifying_meshes_ex03.py b/doc/salome/examples/modifying_meshes_ex03.py new file mode 100644 index 000000000..19b423e03 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex03.py @@ -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 )) diff --git a/doc/salome/examples/modifying_meshes_ex04.py b/doc/salome/examples/modifying_meshes_ex04.py new file mode 100644 index 000000000..5aad0f551 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex04.py @@ -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 diff --git a/doc/salome/examples/modifying_meshes_ex05.py b/doc/salome/examples/modifying_meshes_ex05.py new file mode 100644 index 000000000..bd1e1438b --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex05.py @@ -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 diff --git a/doc/salome/examples/modifying_meshes_ex06.py b/doc/salome/examples/modifying_meshes_ex06.py new file mode 100644 index 000000000..b05c88089 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex06.py @@ -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 diff --git a/doc/salome/examples/modifying_meshes_ex07.py b/doc/salome/examples/modifying_meshes_ex07.py new file mode 100644 index 000000000..5dfa8da03 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex07.py @@ -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 diff --git a/doc/salome/examples/modifying_meshes_ex08.py b/doc/salome/examples/modifying_meshes_ex08.py new file mode 100644 index 000000000..4cfa89ee4 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex08.py @@ -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 diff --git a/doc/salome/examples/modifying_meshes_ex09.py b/doc/salome/examples/modifying_meshes_ex09.py new file mode 100644 index 000000000..2fd91114d --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex09.py @@ -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 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) diff --git a/doc/salome/examples/modifying_meshes_ex10.py b/doc/salome/examples/modifying_meshes_ex10.py new file mode 100644 index 000000000..7f36728c1 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex10.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex11.py b/doc/salome/examples/modifying_meshes_ex11.py new file mode 100644 index 000000000..6ba78c331 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex11.py @@ -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." diff --git a/doc/salome/examples/modifying_meshes_ex12.py b/doc/salome/examples/modifying_meshes_ex12.py new file mode 100644 index 000000000..5437b3815 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex12.py @@ -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." diff --git a/doc/salome/examples/modifying_meshes_ex13.py b/doc/salome/examples/modifying_meshes_ex13.py new file mode 100644 index 000000000..4189b852b --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex13.py @@ -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." diff --git a/doc/salome/examples/modifying_meshes_ex14.py b/doc/salome/examples/modifying_meshes_ex14.py new file mode 100644 index 000000000..7bb10fd9f --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex14.py @@ -0,0 +1,9 @@ +# Renumbering Nodes and Elements + +import SMESH_mechanic + +mesh = SMESH_mechanic.mesh + +mesh.RenumberNodes() + +mesh.RenumberElements() diff --git a/doc/salome/examples/modifying_meshes_ex15.py b/doc/salome/examples/modifying_meshes_ex15.py new file mode 100644 index 000000000..49676d0ee --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex15.py @@ -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] ) diff --git a/doc/salome/examples/modifying_meshes_ex16.py b/doc/salome/examples/modifying_meshes_ex16.py new file mode 100644 index 000000000..6567dff19 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex16.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex17.py b/doc/salome/examples/modifying_meshes_ex17.py new file mode 100644 index 000000000..732953ab2 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex17.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex18.py b/doc/salome/examples/modifying_meshes_ex18.py new file mode 100644 index 000000000..9f7393022 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex18.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex19.py b/doc/salome/examples/modifying_meshes_ex19.py new file mode 100644 index 000000000..c3eaf4977 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex19.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex20.py b/doc/salome/examples/modifying_meshes_ex20.py new file mode 100644 index 000000000..aa52da784 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex20.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex21.py b/doc/salome/examples/modifying_meshes_ex21.py new file mode 100644 index 000000000..ece705c7d --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex21.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex22.py b/doc/salome/examples/modifying_meshes_ex22.py new file mode 100644 index 000000000..e9dcb3c96 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex22.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex23.py b/doc/salome/examples/modifying_meshes_ex23.py new file mode 100644 index 000000000..a789b76f0 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex23.py @@ -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) diff --git a/doc/salome/examples/modifying_meshes_ex24.py b/doc/salome/examples/modifying_meshes_ex24.py new file mode 100644 index 000000000..d07a7ca5b --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex24.py @@ -0,0 +1,21 @@ +# Revolution + +import math +import SMESH + +import SMESH_mechanic + +mesh = SMESH_mechanic.mesh +smesh = SMESH_mechanic.smesh + +# create a group of faces to be revolved +FacesRotate = [492, 493, 502, 503] +GroupRotate = mesh.CreateEmptyGroup(SMESH.FACE,"Group of faces (rotate)") +GroupRotate.Add(FacesRotate) + +# define revolution angle and axis +angle45 = 45 * math.pi / 180 +axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -23.321, -13.3402, -13.3265, 6.66632) + +# perform revolution of an object +mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5) diff --git a/doc/salome/examples/modifying_meshes_ex25.py b/doc/salome/examples/modifying_meshes_ex25.py new file mode 100644 index 000000000..e8801e003 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex25.py @@ -0,0 +1,130 @@ +# Pattern Mapping + +import geompy +import smesh + +# define the geometry +Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.) +geompy.addToStudy(Box_1, "Box_1") + +faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"]) +Face_1 = faces[0] +Face_2 = faces[1] + +geompy.addToStudyInFather(Box_1, Face_1, "Face_1") +geompy.addToStudyInFather(Box_1, Face_2, "Face_2") + +# build a quadrangle mesh 3x3 on Face_1 +Mesh_1 = smesh.Mesh(Face_1) +algo1D = Mesh_1.Segment() +algo1D.NumberOfSegments(3) +Mesh_1.Quadrangle() + +isDone = Mesh_1.Compute() +if not isDone: print 'Mesh Mesh_1 : computation failed' + +# build a triangle mesh on Face_2 +Mesh_2 = smesh.Mesh(Face_2) + +algo1D = Mesh_2.Segment() +algo1D.NumberOfSegments(1) +algo2D = Mesh_2.Triangle() +algo2D.MaxElementArea(240) + +isDone = Mesh_2.Compute() +if not isDone: print 'Mesh Mesh_2 : computation failed' + +# create a 2d pattern +pattern = smesh.GetPattern() + +isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0) +if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode() + +# apply the pattern to a face of the first mesh +facesToSplit = Mesh_1.GetElementsByType(smesh.SMESH.FACE) +print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit)) +pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0) +isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0) +if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode() + +# create quadrangle mesh +Mesh_3 = smesh.Mesh(Box_1) +Mesh_3.Segment().NumberOfSegments(1) +Mesh_3.Quadrangle() +Mesh_3.Hexahedron() +isDone = Mesh_3.Compute() +if not isDone: print 'Mesh Mesh_3 : computation failed' + +# create a 3d pattern (hexahedrons) +pattern_hexa = smesh.GetPattern() + +smp_hexa = """!!! Nb of points: +15 + 0 0 0 !- 0 + 1 0 0 !- 1 + 0 1 0 !- 2 + 1 1 0 !- 3 + 0 0 1 !- 4 + 1 0 1 !- 5 + 0 1 1 !- 6 + 1 1 1 !- 7 + 0.5 0 0.5 !- 8 + 0.5 0 1 !- 9 + 0.5 0.5 0.5 !- 10 + 0.5 0.5 1 !- 11 + 1 0 0.5 !- 12 + 1 0.5 0.5 !- 13 + 1 0.5 1 !- 14 + !!! Indices of points of 4 elements: + 8 12 5 9 10 13 14 11 + 0 8 9 4 2 10 11 6 + 2 10 11 6 3 13 14 7 + 0 1 12 8 2 3 13 10""" + +pattern_hexa.LoadFromFile(smp_hexa) + +# apply the pattern to a mesh +volsToSplit = Mesh_3.GetElementsByType(smesh.SMESH.VOLUME) +print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit)) +pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3) +isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True) +if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode() + +# create one more quadrangle mesh +Mesh_4 = smesh.Mesh(Box_1) +Mesh_4.Segment().NumberOfSegments(1) +Mesh_4.Quadrangle() +Mesh_4.Hexahedron() +isDone = Mesh_4.Compute() +if not isDone: print 'Mesh Mesh_4 : computation failed' + +# create another 3d pattern (pyramids) +pattern_pyra = smesh.GetPattern() + +smp_pyra = """!!! Nb of points: +9 + 0 0 0 !- 0 + 1 0 0 !- 1 + 0 1 0 !- 2 + 1 1 0 !- 3 + 0 0 1 !- 4 + 1 0 1 !- 5 + 0 1 1 !- 6 + 1 1 1 !- 7 + 0.5 0.5 0.5 !- 8 + !!! Indices of points of 6 elements: + 0 1 5 4 8 + 7 5 1 3 8 + 3 2 6 7 8 + 2 0 4 6 8 + 0 2 3 1 8 + 4 5 7 6 8""" + +pattern_pyra.LoadFromFile(smp_pyra) + +# apply the pattern to a face mesh +volsToSplit = Mesh_4.GetElementsByType(smesh.SMESH.VOLUME) +print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit)) +pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0) +isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True) +if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode() diff --git a/doc/salome/examples/modifying_meshes_ex26.py b/doc/salome/examples/modifying_meshes_ex26.py new file mode 100644 index 000000000..aa8cb4379 --- /dev/null +++ b/doc/salome/examples/modifying_meshes_ex26.py @@ -0,0 +1,45 @@ +# Convert mesh to/from quadratic + +import geompy +import smesh + +# create sphere of radius 100 + +Sphere = geompy.MakeSphereR( 100 ) +geompy.addToStudy( Sphere, "Sphere" ) + +# create simple trihedral mesh + +Mesh = smesh.Mesh(Sphere) +Regular_1D = Mesh.Segment() +Nb_Segments = Regular_1D.NumberOfSegments(5) +MEFISTO_2D = Mesh.Triangle() +Tetrahedron = Mesh.Tetrahedron() + +# compute mesh + +isDone = Mesh.Compute() + +# convert to quadratic +# theForce3d = 1; this results in the medium node lying at the +# middle of the line segments connecting start and end node of a mesh +# element + +Mesh.ConvertToQuadratic( theForce3d=1 ) + +# revert back to the non-quadratic mesh + +Mesh.ConvertFromQuadratic() + +# convert to quadratic +# theForce3d = 0; this results in the medium node lying at the +# geometrical edge from which the mesh element is built + +Mesh.ConvertToQuadratic( theForce3d=0 ) + +# to convert not the whole mesh but a sub-mesh, provide it as +# an additional argument to the functions: +# Mesh.ConvertToQuadratic( 0, subMesh ) +# Mesh.ConvertFromQuadratic( subMesh ) +# +# Note that the mesh becomes non-conformal at conversion of sub-mesh. diff --git a/doc/salome/examples/notebook_smesh.py b/doc/salome/examples/notebook_smesh.py new file mode 100644 index 000000000..9cccc7b5b --- /dev/null +++ b/doc/salome/examples/notebook_smesh.py @@ -0,0 +1,39 @@ +# Using SALOME NoteBook + +import geompy +import smesh +import salome_notebook + +# set variables +notebook = salome_notebook.notebook +notebook.set("Length", 100) +notebook.set("Width", 200) +notebook.set("Offset", 50) + +notebook.set("NbSegments", 7) +notebook.set("MaxElementArea", 800) +notebook.set("MaxElementVolume", 900) + +# create a box +box = geompy.MakeBoxDXDYDZ("Length", "Width", 300) +idbox = geompy.addToStudy(box, "Box") + +# create a mesh +tetra = smesh.Mesh(box, "MeshBox") + +algo1D = tetra.Segment() +algo1D.NumberOfSegments("NbSegments") + +algo2D = tetra.Triangle() +algo2D.MaxElementArea("MaxElementArea") + +algo3D = tetra.Tetrahedron() +algo3D.MaxElementVolume("MaxElementVolume") + +# compute the mesh +ret = tetra.Compute() + +# translate the mesh +point = smesh.PointStruct("Offset", 0., 0.) +vector = smesh.DirStruct(point) +tetra.TranslateObject(tetra, vector, 0) diff --git a/doc/salome/examples/prism_3d_algo.py b/doc/salome/examples/prism_3d_algo.py new file mode 100644 index 000000000..df18d0fcb --- /dev/null +++ b/doc/salome/examples/prism_3d_algo.py @@ -0,0 +1,73 @@ +# Use 3D extrusion meshing algorithm + +import salome, smesh, SMESH, geompy + +salome.salome_init() +smesh.SetCurrentStudy( salome.myStudy ) + +OX = geompy.MakeVectorDXDYDZ(1,0,0) +OY = geompy.MakeVectorDXDYDZ(0,1,0) +OZ = geompy.MakeVectorDXDYDZ(0,0,1) + +# Y ^ Make geometry of a "pipe" with the following base (cross section). +# | Big central quadrangles will be meshed with triangles, walls +# of the pipe will be meshed with quadrilaterals +# +--+--+--+--+--+--+ +# | | | | | | | +# +--+--+--+--+--+--+ +# | | | | | +# +--+ | +--+ +# | | | | | +# +--+-----+-----+--+ +# | | | | | +# +--+ | +--+ +# | | | | | +# +--+--+--+--+--+--+ +# | | | | | | | --> +# +--+--+--+--+--+--+ X + +quadBig = geompy.MakeFaceHW( 20,20, 1 ) +quadBig = geompy.MakeTranslation( quadBig, 15,15,0 ) +quadSmall = geompy.MakeFaceHW( 10,10, 1 ) +smallQuads1 = geompy.MakeMultiTranslation1D( quadSmall, OX, 10, 3 ) +smallQuads2 = geompy.MakeMultiTranslation1D( quadSmall, OY, 10, 3 ) +smallQuads2 = geompy.SubShapeAllSortedCentres( smallQuads2, geompy.ShapeType["FACE"])[1:] + +base = geompy.MakeCompound( smallQuads2 + [smallQuads1, quadBig]) +axis = geompy.MakeLine( geompy.MakeVertex( 25,25,0), OZ ) +base = geompy.MultiRotate1DNbTimes( base, axis, 4) +base = geompy.MakePartition( [base], theName="base") +path = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0]) + +# Make the pipe, each quadrangle of the base turns into a prism with composite wall faces +pipe = geompy.MakePipe( base, path ) +prisms = geompy.MakePartition( [pipe], theName="prisms") + + +# get base faces of the prism to define sub-mesh on them +smallQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 0,0,0 ), "smallQuad") +bigQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 15,15,0 ), "bigQuad") + + +mesh = smesh.Mesh( prisms ) + +# assign Global hypotheses + +# 1D algorithm and hypothesis for vertical division +mesh.Segment().NumberOfSegments(15) + +# Extrusion 3D algo +mesh.Prism() + +# assign Local hypotheses + +# 1D and 2D algos and hyps to mesh smallQuad with quadrilaterals +mesh.Segment(smallQuad).LocalLength( 3 ) +mesh.Quadrangle(smallQuad) + +# 1D and 2D algos and hyps to mesh bigQuad with triangles +mesh.Segment(bigQuad).LocalLength( 3 ) +mesh.Triangle(bigQuad) + +# compute the mesh +mesh.Compute() diff --git a/doc/salome/examples/quality_controls_ex01.py b/doc/salome/examples/quality_controls_ex01.py new file mode 100644 index 000000000..ed4dc244e --- /dev/null +++ b/doc/salome/examples/quality_controls_ex01.py @@ -0,0 +1,41 @@ +# Free Borders + +import salome +import geompy + +import smesh + +# create open shell: a box without one plane +box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) +FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +FaceList.remove(FaceList[5]) +box = geompy.MakeShell(FaceList) +idbox = geompy.addToStudy(box, "box") + +# create a mesh +mesh = smesh.Mesh(box, "Mesh_free_borders") +algo = mesh.Segment() +algo.NumberOfSegments(5) +algo = mesh.Triangle() +algo.MaxElementArea(20.) +mesh.Compute() + +# criterion : free borders +aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders) +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Free borders Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateGroup(SMESH.EDGE, "Free borders") +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex02.py b/doc/salome/examples/quality_controls_ex02.py new file mode 100644 index 000000000..7b1f55e6f --- /dev/null +++ b/doc/salome/examples/quality_controls_ex02.py @@ -0,0 +1,44 @@ +# Borders at Multiconnection + +import salome +import geompy + +import smesh +import SMESH + +# create open shell: a box without one plane +box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) +FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +FaceList.remove(FaceList[5]) +box = geompy.MakeShell(FaceList) +idbox = geompy.addToStudy(box, "box") + +# create a mesh +mesh = smesh.Mesh(box, "Mesh_borders_at_multi-connections") +algo = mesh.Segment() +algo.NumberOfSegments(5) +algo = mesh.Triangle() +algo.MaxElementArea(20.) +mesh.Compute() + +# Criterion : Borders at multi-connection +nb_conn = 2 + +aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, nb_conn) +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Borders at multi-connections Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateGroup(SMESH.EDGE, "Borders at multi-connections") +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex03.py b/doc/salome/examples/quality_controls_ex03.py new file mode 100644 index 000000000..8cb409866 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex03.py @@ -0,0 +1,43 @@ +# Length 1D + +import salome +import geompy + +import smesh + +# create open shell: a box without one plane +box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) +FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +FaceList.remove(FaceList[5]) +box = geompy.MakeShell(FaceList) +idbox = geompy.addToStudy(box, "box") + +# create a mesh +mesh = smesh.Mesh(box, "Mesh_Length_1D") +algo = mesh.Segment() +algo.NumberOfSegments(5) +algo = mesh.Triangle() +algo.MaxElementArea(20.) +mesh.Compute() + +# Criterion : Length > 3. +length_margin = 3. + +aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, length_margin) +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex04.py b/doc/salome/examples/quality_controls_ex04.py new file mode 100644 index 000000000..d26eb4d82 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex04.py @@ -0,0 +1,39 @@ +# Free Edges + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + +aFilterMgr = smesh.CreateFilterManager() + +# Remove some elements to obtain free edges +# Criterion : AREA > 95. +area_margin = 95. + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +mesh.RemoveElements(anIds) + +# Criterion : Free Edges +aBorders = mesh.GetFreeBorders() + +# create groups +aGroupF = mesh.CreateEmptyGroup(smesh.FACE, "Faces with free edges") +aGroupN = mesh.CreateEmptyGroup(smesh.NODE, "Nodes on free edges") + +# fill groups with elements, corresponding to the criterion +print "" +print "Criterion: Free edges Nb = ", len(aBorders) +for i in range(len(aBorders)): + aBorder = aBorders[i] + print "Face # ", aBorder.myElemId, " : Edge between nodes (", + print aBorder.myPnt1, ", ", aBorder.myPnt2, ")" + + aGroupF.Add([aBorder.myElemId]) + aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2]) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex05.py b/doc/salome/examples/quality_controls_ex05.py new file mode 100644 index 000000000..90c7c0451 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex05.py @@ -0,0 +1,48 @@ +# Free Nodes + +import salome +import geompy + +import smesh + +# create box +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box, "box") + +# create a mesh +mesh = smesh.Mesh(box, "Mesh_free_nodes") +algo = mesh.Segment() +algo.NumberOfSegments(10) +algo = mesh.Triangle(smesh.MEFISTO) +algo.MaxElementArea(150.) +mesh.Compute() + +# Remove some elements to obtain free nodes +# Criterion : AREA < 80. +area_margin = 80. + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, area_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +mesh.RemoveElements(anIds) + +# criterion : free nodes +aFilter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes) +anNodeIds = mesh.GetIdsFromFilter(aFilter) + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.NODE, "Free_nodes") +aGroup.Add(anNodeIds) + +# print the result +print "Criterion: Free nodes Nb = ", len(anNodeIds) +j = 1 +for i in range(len(anNodeIds)): + if j > 20: j = 1; print "" + print anNodeIds[i], + j = j + 1 + pass +print "" + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex06.py b/doc/salome/examples/quality_controls_ex06.py new file mode 100644 index 000000000..2fe67abf6 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex06.py @@ -0,0 +1,73 @@ +# Free Faces + +import salome +import geompy + +####### GEOM part ######## + +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6]) +Box_1 = geompy.GetMainShape(Box_1_vertex_6) +Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16]) +Box_1 = geompy.GetMainShape(Box_1_vertex_16) +Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11]) +Box_1 = geompy.GetMainShape(Box_1_vertex_11) +Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000) +Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) + +Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19]) +Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21]) +Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000) + +geompy.addToStudy( Box_1, "Box_1" ) +geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" ) +geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" ) +geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" ) +geompy.addToStudy( Plane_1, "Plane_1" ) +geompy.addToStudy( Partition_1, "Partition_1" ) +geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" ) +geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" ) +geompy.addToStudy( Plane_2, "Plane_2" ) + +###### SMESH part ###### +import smesh + +import StdMeshers + +Mesh_1 = smesh.Mesh(Partition_1) +Regular_1D = Mesh_1.Segment() +Max_Size_1 = Regular_1D.MaxSize(34.641) +MEFISTO_2D = Mesh_1.Triangle() +Tetrahedronn = Mesh_1.Tetrahedron() +isDone = Mesh_1.Compute() + +# create a group of free faces +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces ) +aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) + +aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Free_faces") +aGroup.Add(aFaceIds) + +# print the result +print "Criterion: Free faces Nb = ", len(aFaceIds) +j = 1 +for i in range(len(aFaceIds)): + if j > 20: j = 1; print "" + print aFaceIds[i], + j = j + 1 + pass +print "" + +#filter faces from plane 2 +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_2) +aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) +aGroup.Remove(aFaceIds) + +# create a group of shared faces (located on partition boundary inside box) +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_1) +aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) + +aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Shared_faces") +aGroup.Add(aFaceIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex07.py b/doc/salome/examples/quality_controls_ex07.py new file mode 100644 index 000000000..a2be02932 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex07.py @@ -0,0 +1,19 @@ +# Bare border faces + +from smesh import * +SetCurrentStudy(salome.myStudy) + +box = geompy.MakeBoxDXDYDZ(100, 100, 100) +geompy.addToStudy( box, "box" ) + +mesh = smesh.Mesh(box) +mesh.Segment().NumberOfSegments(3) +mesh.Quadrangle() +mesh.Compute() + +# remove 2 faces +allFaces = mesh.GetElementsByType(FACE) +mesh.RemoveElements( allFaces[0:2]) + +bareGroup = mesh.MakeGroup("bare faces", FACE, FT_BareBorderFace) +assert(bareGroup.Size() == 3) diff --git a/doc/salome/examples/quality_controls_ex08.py b/doc/salome/examples/quality_controls_ex08.py new file mode 100644 index 000000000..77e7e4c94 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex08.py @@ -0,0 +1,23 @@ +# Bare border volumes + +from smesh import * +SetCurrentStudy(salome.myStudy) + +box = geompy.MakeBoxDXDYDZ(100, 30, 10) +# the smallest face of the box +face = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])[0] + +geompy.addToStudy( box, "box" ) +geompy.addToStudyInFather( box, face, "face" ) + +mesh = Mesh(box) +mesh.AutomaticHexahedralization(); + +# remove half of mesh faces from the smallest face +faceFaces = mesh.GetSubMeshElementsId(face) +faceToRemove = faceFaces[: len(faceFaces)/2] +mesh.RemoveElements( faceToRemove ) + +# make a group of volumes missing the removed faces +bareGroup = mesh.MakeGroup("bare volumes", VOLUME, FT_BareBorderVolume) +assert(bareGroup.Size() == len( faceToRemove)) diff --git a/doc/salome/examples/quality_controls_ex09.py b/doc/salome/examples/quality_controls_ex09.py new file mode 100644 index 000000000..c4ca44e80 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex09.py @@ -0,0 +1,17 @@ +# Over-constrained faces + +from smesh import * +SetCurrentStudy(salome.myStudy) + +mesh = Mesh() +faceFilter = GetFilter(FACE,FT_OverConstrainedFace) + +#make an edge +n1 = mesh.AddNode(0,0,0) +n2 = mesh.AddNode(10,0,0) +edge = mesh.AddEdge([n1,n2]) +assert( not mesh.GetIdsFromFilter( faceFilter )) + +# make faces +mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 5) +assert( 2 == len( mesh.GetIdsFromFilter( faceFilter ))) diff --git a/doc/salome/examples/quality_controls_ex10.py b/doc/salome/examples/quality_controls_ex10.py new file mode 100644 index 000000000..49ef2e72a --- /dev/null +++ b/doc/salome/examples/quality_controls_ex10.py @@ -0,0 +1,15 @@ +# Over-constrained volumes + +from smesh import * +SetCurrentStudy(salome.myStudy) + +mesh = Mesh() +volumeFilter = GetFilter(VOLUME,FT_OverConstrainedVolume) + +# make volumes by extrusion of one face +n1 = mesh.AddNode(0,0,0) +n2 = mesh.AddNode(10,0,0) +edge = mesh.AddEdge([n1,n2]) +mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 1) +mesh.ExtrusionSweep( mesh.GetElementsByType(FACE), MakeDirStruct(0,0,5), 7) +assert( 2 == len( mesh.GetIdsFromFilter( volumeFilter ))) diff --git a/doc/salome/examples/quality_controls_ex11.py b/doc/salome/examples/quality_controls_ex11.py new file mode 100644 index 000000000..ca955b6ab --- /dev/null +++ b/doc/salome/examples/quality_controls_ex11.py @@ -0,0 +1,44 @@ +# Length 2D + +import salome +import geompy + +import smesh + +# create open shell: a box without one plane +box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) +FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +FaceList.remove(FaceList[5]) +box = geompy.MakeShell(FaceList) +idbox = geompy.addToStudy(box, "box") + +# create a mesh +mesh = smesh.Mesh(box, "Mesh_Length_2D") +algo = mesh.Segment() +algo.NumberOfSegments(5) +algo = mesh.Triangle() +algo.MaxElementArea(20.) +mesh.Compute() + +# Criterion : Length 2D > 5.7 +length_margin = 5.7 + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, length_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Faces with length 2D > " + `length_margin`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex12.py b/doc/salome/examples/quality_controls_ex12.py new file mode 100644 index 000000000..28a0192c5 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex12.py @@ -0,0 +1,44 @@ +# Borders at Multiconnection 2D + +import salome +import geompy + +import smesh + +# create a compound of two glued boxes +box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.) +box2 = geompy.MakeTranslation(box1, 0., 20., 0) +comp = geompy.MakeCompound([box1, box2]) +box = geompy.MakeGlueFaces(comp, 0.000001) +idbox = geompy.addToStudy(box, "box") + +# create a mesh +mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh") +algo = mesh.Segment() +algo.NumberOfSegments(5) +algo = mesh.Triangle() +algo.MaxElementArea(20.) +mesh.Compute() + +# Criterion : MULTI-CONNECTION 2D = 3 +nb_conn = 3 + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, smesh.FT_EqualTo, nb_conn) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Borders at multi-connection 2D = " + `nb_conn`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex13.py b/doc/salome/examples/quality_controls_ex13.py new file mode 100644 index 000000000..1673fc737 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex13.py @@ -0,0 +1,30 @@ +# Area + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + +# Criterion : AREA > 100. +area_margin = 100. + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Area > ", area_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > " + `area_margin`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex14.py b/doc/salome/examples/quality_controls_ex14.py new file mode 100644 index 000000000..379affdbd --- /dev/null +++ b/doc/salome/examples/quality_controls_ex14.py @@ -0,0 +1,30 @@ +# Taper + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + +# Criterion : Taper > 3e-20 +taper_margin = 3e-20 + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, taper_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Taper > " + `taper_margin`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex15.py b/doc/salome/examples/quality_controls_ex15.py new file mode 100644 index 000000000..5ca56db0b --- /dev/null +++ b/doc/salome/examples/quality_controls_ex15.py @@ -0,0 +1,30 @@ +# Aspect Ratio + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + +# Criterion : ASPECT RATIO > 1.8 +ar_margin = 1.8 + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, ar_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Aspect Ratio > " + `ar_margin`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex16.py b/doc/salome/examples/quality_controls_ex16.py new file mode 100644 index 000000000..a20f38f7b --- /dev/null +++ b/doc/salome/examples/quality_controls_ex16.py @@ -0,0 +1,31 @@ +# Minimum Angle + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + +# Criterion : MINIMUM ANGLE < 35. +min_angle = 35. + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, min_angle) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Minimum Angle < " + `min_angle`) + +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex17.py b/doc/salome/examples/quality_controls_ex17.py new file mode 100644 index 000000000..fcc596c75 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex17.py @@ -0,0 +1,31 @@ +# Warping + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + +# Criterion : WARP ANGLE > 1e-15 +wa_margin = 1e-15 + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, wa_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Warp > " + `wa_margin`) + +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex18.py b/doc/salome/examples/quality_controls_ex18.py new file mode 100644 index 000000000..42e4b30e8 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex18.py @@ -0,0 +1,30 @@ +# Skew + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + +# Criterion : Skew > 38. +skew_margin = 38. + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, skew_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Skew > " + `skew_margin`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex19.py b/doc/salome/examples/quality_controls_ex19.py new file mode 100644 index 000000000..abe195200 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex19.py @@ -0,0 +1,30 @@ +# Element Diameter 2D + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + +# Criterion : ELEMENT DIAMETER 2D > 10 +mel_2d_margin = 10 + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, mel_2d_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Element Diameter 2D Ratio > ", mel_2d_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 2D > " + `mel_2d_margin`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex20.py b/doc/salome/examples/quality_controls_ex20.py new file mode 100644 index 000000000..9e332e0dc --- /dev/null +++ b/doc/salome/examples/quality_controls_ex20.py @@ -0,0 +1,31 @@ +# Aspect Ratio 3D + +import SMESH_mechanic_tetra + +smesh = SMESH_mechanic_tetra.smesh +mesh = SMESH_mechanic_tetra.mesh +salome = SMESH_mechanic_tetra.salome + +# Criterion : ASPECT RATIO 3D > 4.5 +ar_margin = 4.5 + +aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_MoreThan, ar_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Aspect Ratio 3D > " + `ar_margin`) + +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex21.py b/doc/salome/examples/quality_controls_ex21.py new file mode 100644 index 000000000..833ffff81 --- /dev/null +++ b/doc/salome/examples/quality_controls_ex21.py @@ -0,0 +1,32 @@ +# Volume + +import SMESH_mechanic_tetra + +smesh = SMESH_mechanic_tetra.smesh +mesh = SMESH_mechanic_tetra.mesh +salome = SMESH_mechanic_tetra.salome + +# Criterion : VOLUME < 7. +volume_margin = 7. + +aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_LessThan, volume_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "" +print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Volume < " + `volume_margin`) + +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/quality_controls_ex22.py b/doc/salome/examples/quality_controls_ex22.py new file mode 100644 index 000000000..5264b1ade --- /dev/null +++ b/doc/salome/examples/quality_controls_ex22.py @@ -0,0 +1,30 @@ +# Element Diameter 3D + +import SMESH_mechanic_tetra + +smesh = SMESH_mechanic_tetra.smesh +mesh = SMESH_mechanic_tetra.mesh +salome = SMESH_mechanic_tetra.salome + +# Criterion : ELEMENT DIAMETER 3D > 10 +mel_3d_margin = 10 + +aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, mel_3d_margin) + +anIds = mesh.GetIdsFromFilter(aFilter) + +# print the result +print "Criterion: Element Diameter 3D Ratio > ", mel_3d_margin, " Nb = ", len(anIds) +j = 1 +for i in range(len(anIds)): + if j > 20: j = 1; print "" + print anIds[i], + j = j + 1 + pass +print "" + +# create a group +aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 3D > " + `mel_3d_margin`) +aGroup.Add(anIds) + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/testme.py b/doc/salome/examples/testme.py new file mode 100755 index 000000000..b1328b596 --- /dev/null +++ b/doc/salome/examples/testme.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import unittest, sys + +class SalomeSession(object): + def __init__(self, script): + import runSalome + sys.argv = ["runSalome.py"] + sys.argv += ["--terminal"] + sys.argv += ["--modules=GEOM,MED,SMESH"] + sys.argv += ["--execute=%s" % script] + clt, d = runSalome.main() + self.port = d['port'] + return + + def __del__(self): + port = self.port + import killSalomeWithPort + killSalomeWithPort.killMyPort(port) + return + pass + +class MyTest(unittest.TestCase): + def testFunction(self): + SalomeSession(sys.argv[1]) + pass + +unittest.main(argv=sys.argv[:1]) diff --git a/doc/salome/examples/transforming_meshes_ex01.py b/doc/salome/examples/transforming_meshes_ex01.py new file mode 100644 index 000000000..0ea75cc85 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex01.py @@ -0,0 +1,15 @@ +# Translation + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh + +# define translation vector +point = smesh.PointStruct(-150., -150., 0.) +vector =smesh.DirStruct(point) + +# translate a mesh +doCopy = 1 + +mesh.Translate([], vector, doCopy) diff --git a/doc/salome/examples/transforming_meshes_ex02.py b/doc/salome/examples/transforming_meshes_ex02.py new file mode 100644 index 000000000..f96a6bb41 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex02.py @@ -0,0 +1,15 @@ +# Rotation + +import math + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh + +# define rotation axis and angle +axisXYZ = smesh.AxisStruct(0., 0., 0., 5., 5., 20.) +angle270 = 1.5 * math.pi + +# rotate a mesh +mesh.Rotate([], axisXYZ, angle270, 1) diff --git a/doc/salome/examples/transforming_meshes_ex03.py b/doc/salome/examples/transforming_meshes_ex03.py new file mode 100644 index 000000000..da8105a67 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex03.py @@ -0,0 +1,26 @@ +# Scale + +import geompy +Box = geompy.MakeBoxDXDYDZ(200, 200, 200) +f = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) + +import smesh,SMESH +import StdMeshers +Mesh1 = smesh.Mesh(f[0]) +Regular_1D = Mesh1.Segment() +Nb_Segments_1 = Regular_1D.NumberOfSegments(3) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = Mesh1.Quadrangle() +isDone = Mesh1.Compute() + +#Perform scale opration for the whole mesh and creation of a new mesh +newMesh = Mesh1.ScaleMakeMesh(Mesh1,SMESH.PointStruct(100,100,200),[0.5,0.3,0.7],True,"ScaledMesh") + +#Perform scale operation for the whole mesh and copy elements +Mesh1.Scale(Mesh1,SMESH.PointStruct(200,100,100),[0.5,0.5,0.5],True,True) + +#Perform scale opration for two edges and move elements +Mesh1.Scale([1,2],SMESH.PointStruct(-100,100,100),[0.8,1.0,0.7],False) + +#Perform scale opration for one face and move elements +Mesh1.Scale([21],SMESH.PointStruct(0,200,200),[0.7,0.7,0.7],False) diff --git a/doc/salome/examples/transforming_meshes_ex04.py b/doc/salome/examples/transforming_meshes_ex04.py new file mode 100644 index 000000000..ea7c72f54 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex04.py @@ -0,0 +1,13 @@ +# Symmetry + +import math + +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh + +# create a symmetrical copy of the mesh mirrored through a point +axis = SMESH.AxisStruct(0, 0, 0, 0, 0, 0) + +mesh.Mirror([], axis, smesh.POINT, 1) diff --git a/doc/salome/examples/transforming_meshes_ex05.py b/doc/salome/examples/transforming_meshes_ex05.py new file mode 100644 index 000000000..f99d50b6a --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex05.py @@ -0,0 +1,10 @@ +# Merging Nodes + +import SMESH_mechanic +mesh = SMESH_mechanic.mesh + +# merge nodes +Tolerance = 25.0 + +GroupsOfNodes = mesh.FindCoincidentNodes(Tolerance) +mesh.MergeNodes(GroupsOfNodes) diff --git a/doc/salome/examples/transforming_meshes_ex06.py b/doc/salome/examples/transforming_meshes_ex06.py new file mode 100644 index 000000000..fe8c91db3 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex06.py @@ -0,0 +1,73 @@ +# Merging Elements + +import salome +import geompy +import smesh + +# create a face to be meshed +px = geompy.MakeVertex(100., 0. , 0. ) +py = geompy.MakeVertex(0. , 100., 0. ) +pz = geompy.MakeVertex(0. , 0. , 100.) + +vxy = geompy.MakeVector(px, py) +arc = geompy.MakeArc(py, pz, px) + +wire = geompy.MakeWire([vxy, arc]) +isPlanarFace = 1 + +face1 = geompy.MakeFace(wire, isPlanarFace) +id_face1 = geompy.addToStudy(face1, "Face1") + +# create a circle to be an extrusion path +px1 = geompy.MakeVertex( 100., 100., 0.) +py1 = geompy.MakeVertex(-100., -100., 0.) +pz1 = geompy.MakeVertex( 0., 0., 50.) + +circle = geompy.MakeCircleThreePnt(py1, pz1, px1) +id_circle = geompy.addToStudy(circle, "Path") + +# create a 2D mesh on the face +trias = smesh.Mesh(face1, "Face : 2D mesh") + +algo1D = trias.Segment() +algo1D.NumberOfSegments(6) +algo2D = trias.Triangle() +algo2D.LengthFromEdges() + +trias.Compute() + +# create a path mesh +circlemesh = smesh.Mesh(circle, "Path mesh") +algo = circlemesh.Segment() +algo.NumberOfSegments(10) +circlemesh.Compute() + +# extrusion of the mesh +trias.ExtrusionAlongPath([], circlemesh, circle, + 1, 0, [], 0, smesh.PointStruct(0, 0, 0)) + +# merge nodes +print "Number of nodes before MergeNodes:", +trias.NbNodes() +tolerance = 0.001 +array_of_nodes_groups = trias.FindCoincidentNodes(tolerance) + +trias.MergeNodes(array_of_nodes_groups) + +print "Number of nodes after MergeNodes:", trias.NbNodes() +print "" +print "Number of elements before MergeEqualElements:" +print "Edges : ", trias.NbEdges() +print "Triangles : ", trias.NbTriangles() +print "Quadrangles: ", trias.NbQuadrangles() +print "Volumes : ", trias.NbVolumes() + +# merge elements +trias.MergeEqualElements() +print "Number of elements after MergeEqualElements:" +print "Edges : ", trias.NbEdges() +print "Triangles : ", trias.NbTriangles() +print "Quadrangles: ", trias.NbQuadrangles() +print "Volumes : ", trias.NbVolumes() + +salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/transforming_meshes_ex07.py b/doc/salome/examples/transforming_meshes_ex07.py new file mode 100644 index 000000000..bb42d33eb --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex07.py @@ -0,0 +1,38 @@ +# Sew Meshes Border to Side + +import geompy +import smesh + +# create two faces of a box +box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.) +facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +face1 = facesList1[2] + +box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.) +facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +face2 = facesList2[1] + +edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"]) +edge1 = edgesList[2] + +aComp = geompy.MakeCompound([face1, face2]) +geompy.addToStudy(aComp, "Two faces") + +# create a mesh on two faces +mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") + +algo1D = mesh.Segment() +algo1D.NumberOfSegments(9) +algo2D = mesh.Quadrangle() + +algo_local = mesh.Segment(edge1) +algo_local.Arithmetic1D(1, 4) +algo_local.Propagation() + +mesh.Compute() + +# sew border to side +# FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, +# FirstNodeIDOnSide, LastNodeIDOnSide, +# CreatePolygons, CreatePolyedrs +mesh.SewBorderToSide(5, 45, 6, 113, 109, 0, 0) diff --git a/doc/salome/examples/transforming_meshes_ex08.py b/doc/salome/examples/transforming_meshes_ex08.py new file mode 100644 index 000000000..e028735a0 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex08.py @@ -0,0 +1,36 @@ +# Sew Conform Free Borders + +import geompy +import smesh + +# create two faces of the box +box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.) +facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +face1 = facesList1[2] + +box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.) +facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +face2 = facesList2[1] + +edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"]) +edge1 = edgesList[2] + +aComp = geompy.MakeCompound([face1, face2]) +geompy.addToStudy(aComp, "Two faces") + +# create a mesh on two faces +mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") + +algo1D = mesh.Segment() +algo1D.NumberOfSegments(9) +algo2D = mesh.Quadrangle() + +algo_local = mesh.Segment(edge1) +algo_local.Arithmetic1D(1, 4) +algo_local.Propagation() + +mesh.Compute() + +# sew conform free borders +# FirstNodeID1, SecondNodeID1, LastNodeID1, FirstNodeID2, SecondNodeID2 +mesh.SewConformFreeBorders(5, 45, 6, 3, 24) diff --git a/doc/salome/examples/transforming_meshes_ex09.py b/doc/salome/examples/transforming_meshes_ex09.py new file mode 100644 index 000000000..5f92fd1ad --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex09.py @@ -0,0 +1,37 @@ +# Sew Free Borders + +import geompy +import smesh + +# create two faces of the box +box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.) +facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +face1 = facesList1[2] + +box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.) +facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +face2 = facesList2[1] + +edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"]) +edge1 = edgesList[2] + +aComp = geompy.MakeCompound([face1, face2]) +geompy.addToStudy(aComp, "Two faces") + +# create a mesh on two faces +mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") + +algo1D = mesh.Segment() +algo1D.NumberOfSegments(4) +algo2D = mesh.Quadrangle() + +algo_local = mesh.Segment(edge1) +algo_local.Arithmetic1D(1, 4) +algo_local.Propagation() + +mesh.Compute() + +# sew free borders +# FirstNodeID1, SecondNodeID1, LastNodeID1, +# FirstNodeID2, SecondNodeID2, LastNodeID2, CreatePolygons, CreatePolyedrs +mesh.SewFreeBorders(6, 21, 5, 1, 12, 3, 0, 0) diff --git a/doc/salome/examples/transforming_meshes_ex10.py b/doc/salome/examples/transforming_meshes_ex10.py new file mode 100644 index 000000000..c54aca660 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex10.py @@ -0,0 +1,31 @@ +# Sew Side Elements + +import geompy +import smesh + +# create two boxes +box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.) +box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.) + +EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) + +aComp = geompy.MakeCompound([box1, box2]) +geompy.addToStudy(aComp, "Two boxes") + +# create a mesh on two boxes +mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") + +algo1D = mesh.Segment() +algo1D.NumberOfSegments(2) +algo2D = mesh.Quadrangle() + +algo_local = mesh.Segment(EdgesList[8]) +algo_local.NumberOfSegments(4) +algo_local.Propagation() + +mesh.Compute() + +# sew side elements +# IDsOfSide1Elements, IDsOfSide2Elements, +# NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge +mesh.SewSideElements([69, 70, 71, 72], [91, 92, 89, 90], 8, 38, 23, 58) diff --git a/doc/salome/examples/transforming_meshes_ex11.py b/doc/salome/examples/transforming_meshes_ex11.py new file mode 100644 index 000000000..55fbe8f28 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex11.py @@ -0,0 +1,66 @@ +# Duplicate nodes + +import salome +import smesh +import SMESH_test1 + +mesh = SMESH_test1.mesh + +# Compute mesh +mesh.Compute() + +# Without the duplication of border elements + +# Nodes to duplicate +nodes1 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes1' ) +nodes1.Add( [ 289, 278, 302, 285 ] ) + +# Group of faces to replace nodes with new ones +faces1 = mesh.CreateEmptyGroup( smesh.FACE, 'faces1' ) +faces1.Add( [ 519, 556, 557 ] ) + +# Duplicate nodes +print "\nMesh before the first nodes duplication:" +print "Nodes : ", mesh.NbNodes() +print "Edges : ", mesh.NbEdges() +print "Triangles : ", mesh.NbTriangles() + +groupOfCreatedNodes = mesh.DoubleNodeGroup(nodes1, faces1, theMakeGroup=True) +print "New nodes:", groupOfCreatedNodes.GetIDs() + +print "\nMesh after the first nodes duplication:" +print "Nodes : ", mesh.NbNodes() +print "Edges : ", mesh.NbEdges() +print "Triangles : ", mesh.NbTriangles() + +# With the duplication of border elements + +# Edges to duplicate +edges = mesh.CreateEmptyGroup( smesh.EDGE, 'edges' ) +edges.Add( [ 29, 30, 31 ] ) + +# Nodes not to duplicate +nodes2 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes2' ) +nodes2.Add( [ 32, 5 ] ) + +# Group of faces to replace nodes with new ones +faces2 = mesh.CreateEmptyGroup( smesh.FACE, 'faces2' ) +faces2.Add( [ 576, 578, 580 ] ) + +# Duplicate nodes +print "\nMesh before the second nodes duplication:" +print "Nodes : ", mesh.NbNodes() +print "Edges : ", mesh.NbEdges() +print "Triangles : ", mesh.NbTriangles() + +groupOfNewEdges = mesh.DoubleNodeElemGroup( edges, nodes2, faces2, theMakeGroup=True ) +print "New edges:", groupOfNewEdges.GetIDs() + +print "\nMesh after the second nodes duplication:" +print "Nodes : ", mesh.NbNodes() +print "Edges : ", mesh.NbEdges() +print "Triangles : ", mesh.NbTriangles() + +# Update object browser +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(0) diff --git a/doc/salome/examples/transforming_meshes_ex12.py b/doc/salome/examples/transforming_meshes_ex12.py new file mode 100644 index 000000000..0380cc363 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex12.py @@ -0,0 +1,108 @@ +# Create boundary elements + +from smesh import * +SetCurrentStudy(salome.myStudy) + +box = geompy.MakeBoxDXDYDZ(100, 100, 100) +gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"]) +f1,f2 = gFaces[0],gFaces[1] +geompy.addToStudy(box,"box") +geompy.addToStudyInFather(box,f1,"face1") +geompy.addToStudyInFather(box,f2,"face2") + +twoFaces = geompy.MakeCompound([f1,f2]) + +## ----------- +## +## 2D from 3D +## +## ----------- +dim = SMESH.BND_2DFROM3D + +init_mesh = Mesh(box, "box") +init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons + +# remove some faces +faces = init_mesh.GetElementsByType( SMESH.FACE ) +nb_faces = len( faces ) +rm_face = faces[ : nb_faces/2] +init_mesh.RemoveElements( rm_face ) + +# restore boundary in this mesh +mesh = CopyMesh( init_mesh, "2D from 3D") +groupName = "bnd 2D" +nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName) + +# restore boundary (only) in other mesh +meshName = "2D boundary of " + init_mesh.GetName() +nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName) + +# restore boundary in mesh copy +meshName = init_mesh.GetName() + " + boundary" +nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True) + + +## ----------- +## +## 1D from 2D +## +## ----------- +dim = SMESH.BND_1DFROM2D + +init_mesh = Mesh(f1, "2D mesh") +init_mesh.AutomaticHexahedralization() + +# remove some edges +edges = init_mesh.GetElementsByType( SMESH.EDGE ) +nb_edges = len( edges ) +rm_edge = edges[ : nb_edges/2] +init_mesh.RemoveElements( rm_edge ) + + +# restore boundary edges in this mesh +mesh = CopyMesh( init_mesh, "1D from 2D") +groupName = "bnd 1D" +nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName) + +# restore boundary edges (only) in other mesh +meshName = "1D boundary of " + init_mesh.GetName() +nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName) + +# restore boundary edges in mesh copy +meshName = init_mesh.GetName() + " + boundary" +nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True) + + + +## ------------------ +## +## 1D from 2D GROUPS +## +## ------------------ +dim = SMESH.BND_1DFROM3D + +init_mesh = Mesh(box, "box") +init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons +# remove all edges +rm_edges = init_mesh.GetElementsByType( SMESH.EDGE ) +init_mesh.RemoveElements( rm_edges ) + +# make groups of faces +fGroup1 = init_mesh.Group( f1, "f1" ) +fGroup2 = init_mesh.Group( f2, "f2" ) + +# make 1D boundary around groups in this mesh +mesh = CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True) +groups = mesh.GetGroups() +nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups) + +# make 1D boundary (only) in other mesh +meshName = "boundary from groups of " + init_mesh.GetName() +groups = init_mesh.GetGroups() +nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,groups=groups) + +# make 1D boundary in mesh copy +meshName = init_mesh.GetName() + " + boundary from groups" +nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, + groups=groups, toCopyAll=True) + diff --git a/doc/salome/examples/transforming_meshes_ex13.py b/doc/salome/examples/transforming_meshes_ex13.py new file mode 100644 index 000000000..0126b7108 --- /dev/null +++ b/doc/salome/examples/transforming_meshes_ex13.py @@ -0,0 +1,43 @@ +# Reorient faces by vector + +import smesh, geompy, SMESH + +# create a geometry consisting of two faces +box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) +faces = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"]) + +shape = geompy.MakeCompound( faces[:2] ) +faces = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"] ) +geompy.addToStudy( shape, "shape") +geompy.addToStudyInFather( shape, faces[0], "faces[0]") +geompy.addToStudyInFather( shape, faces[1], "faces[1]") + +# create a 2D mesh +mesh = smesh.Mesh( shape, "test_Reorient2D") +mesh.AutomaticHexahedralization(0.5) +localAlgo = mesh.Segment(faces[0]) +localAlgo.NumberOfSegments( 11 ) +mesh.Compute() +group = mesh.Group( faces[1] ) + +vec = geompy.MakeVectorDXDYDZ( 1, 1, 1 ) + +# Each of arguments of Reorient2D() function can be of different types: +# +# 2DObject - the whole mesh +# Direction - a GEOM object (vector) +# FaceOrPoint - an ID of face +mesh.Reorient2D( mesh, vec, mesh.NbElements() ) +# +# 2DObject - a sub-mesh +# Direction - components of a vector +# FaceOrPoint - a GEOM object (vertex) +mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geompy.GetFirstVertex( vec )) +# +# 2DObject - a group of faces +# Direction - a SMESH.DirStruct structure +# FaceOrPoint - coordinates of a point +mesh.Reorient2D( group, smesh.MakeDirStruct( -10, 1, 10 ), [0,0,0]) +# +# FaceOrPoint - a SMESH.PointStruct structure +mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0)) diff --git a/doc/salome/examples/use_existing_faces.py b/doc/salome/examples/use_existing_faces.py new file mode 100644 index 000000000..12b5a9a56 --- /dev/null +++ b/doc/salome/examples/use_existing_faces.py @@ -0,0 +1,109 @@ +# Use existing faces algorithm + +import smesh, geompy +import numpy as np + +# define my 2D algorithm +def my2DMeshing( geomFace ): + + # find gravity center of geomFace + gcXYZ = geompy.PointCoordinates( geompy.MakeCDG( geomFace )) + + # define order and orientation of edges + sortedEdges = [] + geomEdges = geompy.SubShapeAll( geomFace, geompy.ShapeType["EDGE"]) + sortedEdges.append(( geomEdges.pop(0), True )) + while geomEdges: + prevEdge_rev = sortedEdges[ -1 ] + prevVV = geompy.SubShapeAll( prevEdge_rev[0], geompy.ShapeType["VERTEX"]) + prevV2 = prevVV[ prevEdge_rev[1] ] + found = False + for iE in range( len( geomEdges )): + v1,v2 = geompy.SubShapeAll( geomEdges[ iE ], geompy.ShapeType["VERTEX"]) + same1,same2 = [( geompy.MinDistance( prevV2, v ) < 1e-7 ) for v in [v1,v2] ] + if not same1 and not same2: continue + sortedEdges.append(( geomEdges.pop( iE ), same1 )) + found = True + break + assert found + sortedEdges.reverse() + + # put nodes on edges in a right order + nodes = [] + for edge, isForward in sortedEdges: + v1,v2 = geompy.SubShapeAll( edge, geompy.ShapeType["VERTEX"]) + edgeNodes = mesh.GetSubMeshNodesId( v2, all=False ) + \ + mesh.GetSubMeshNodesId( edge, all=False ) + \ + mesh.GetSubMeshNodesId( v1, all=False ) + if not isForward: edgeNodes.reverse() + nodes.extend( edgeNodes[:-1] ) + + # create nodes inside the geomFace + r1 = 0.6 + r2 = 1 - r1 + nodesInside = [] + for n in nodes: + nXYZ = mesh.GetNodeXYZ( n ) + newXYZ = np.add( np.multiply( r1, gcXYZ ), np.multiply( r2, nXYZ )) + nodesInside.append( mesh.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] )) + mesh.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 ) + + # find out orientation of faces to create + # geomFace normal + faceNorm = geompy.GetNormal( geomFace ) + v1,v2 = [ geompy.PointCoordinates( v ) \ + for v in geompy.SubShapeAll( faceNorm, geompy.ShapeType["VERTEX"]) ] + faceNormXYZ = np.subtract( v2, v1 ) + outDirXYZ = np.subtract( v1, [ 50, 50, 50 ] ) + if np.dot( faceNormXYZ, outDirXYZ ) < 0: # reversed face + faceNormXYZ = np.multiply( -1., faceNormXYZ ) + # mesh face normal + e1 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodes[1] )) + e2 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodesInside[0] )) + meshNorm = np.cross( e1, e2 ) + # faces orientation + reverse = ( np.dot( faceNormXYZ, meshNorm ) < 0 ) + + # create mesh faces + iN = len( nodes ) + while iN: + n1, n2, n3, n4 = nodes[iN-1], nodes[iN-2], nodesInside[iN-2], nodesInside[iN-1] + iN -= 1 + if reverse: + f = mesh.AddFace( [n1, n2, n3, n4] ) + else: + f = mesh.AddFace( [n4, n3, n2, n1] ) + # new faces must be assigned to geometry to allow 3D algorithm finding them + mesh.SetMeshElementOnShape( f, geomFace ) + + if reverse: + nodesInside.reverse() + polygon = mesh.AddPolygonalFace( nodesInside ) + mesh.SetMeshElementOnShape( polygon, geomFace ) + + return + +# create geometry and get faces to mesh with my2DMeshing() +box = geompy.MakeBoxDXDYDZ( 100, 100, 100 ) +f1 = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] +f2 = geompy.GetOppositeFace( box, f1 ) +geompy.addToStudy( box, "box" ) +geompy.addToStudy( f1, "f1" ) +geompy.addToStudy( f2, "f2" ) + +# compute 1D mesh +mesh = smesh.Mesh( box ) +mesh.Segment().NumberOfSegments( 5 ) +mesh.Compute() + +# compute 2D mesh +mesh.Quadrangle() +mesh.UseExistingFaces(f1) # UseExistingFaces() allows using my2DMeshing() +mesh.UseExistingFaces(f2) +my2DMeshing( f1 ) +my2DMeshing( f2 ) +assert mesh.Compute() + +# compute 3D mesh +mesh.Prism() +assert mesh.Compute() diff --git a/doc/salome/examples/viewing_meshes_ex01.py b/doc/salome/examples/viewing_meshes_ex01.py new file mode 100644 index 000000000..b2fa7df40 --- /dev/null +++ b/doc/salome/examples/viewing_meshes_ex01.py @@ -0,0 +1,76 @@ +# Viewing Mesh Infos + +import geompy +import smesh +import SMESH + +# create a box +box = geompy.MakeBox(0., 0., 0., 20., 20., 20.) +geompy.addToStudy(box, "box") +[Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) + +# create a mesh +tetra = smesh.Mesh(box, "MeshBox") + +algo1D = tetra.Segment() +algo1D.NumberOfSegments(3) + +algo2D = tetra.Triangle() +algo2D.MaxElementArea(10.) + +algo3D = tetra.Tetrahedron() +algo3D.MaxElementVolume(900.) + +# Creation of SubMesh +Regular_1D_1_1 = tetra.Segment(geom=Face_1) +Nb_Segments_1 = Regular_1D_1_1.NumberOfSegments(5) +Nb_Segments_1.SetDistrType( 0 ) +Quadrangle_2D = tetra.Quadrangle(geom=Face_1) +isDone = tetra.Compute() +submesh = Regular_1D_1_1.GetSubMesh() + +# compute the mesh +tetra.Compute() + +# Creation of group +group = tetra.CreateEmptyGroup( SMESH.FACE, 'Group' ) +nbAdd = group.Add( [ 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76 ] ) + +# Print information about the mesh +print "Information about mesh:" +print "Number of nodes : ", tetra.NbNodes() +print "Number of edges : ", tetra.NbEdges() +print "Number of faces : ", tetra.NbFaces() +print " triangles : ", tetra.NbTriangles() +print " quadrangles : ", tetra.NbQuadrangles() +print " polygons : ", tetra.NbPolygons() +print "Number of volumes : ", tetra.NbVolumes() +print " tetrahedrons: ", tetra.NbTetras() +print " hexahedrons : ", tetra.NbHexas() +print " prisms : ", tetra.NbPrisms() +print " pyramids : ", tetra.NbPyramids() +print " polyhedrons : ", tetra.NbPolyhedrons() + +# Get Information About Mesh by GetMeshInfo +print "\nInformation about mesh by GetMeshInfo:" +info = smesh.GetMeshInfo(tetra) +keys = info.keys(); keys.sort() +for i in keys: + print " %s : %d" % ( i, info[i] ) + pass + +# Get Information About Group by GetMeshInfo +print "\nInformation about group by GetMeshInfo:" +info = smesh.GetMeshInfo(group) +keys = info.keys(); keys.sort() +for i in keys: + print " %s : %d" % ( i, info[i] ) + pass + +# Get Information About SubMesh by GetMeshInfo +print "\nInformation about Submesh by GetMeshInfo:" +info = smesh.GetMeshInfo(submesh) +keys = info.keys(); keys.sort() +for i in keys: + print " %s : %d" % ( i, info[i] ) + pass diff --git a/doc/salome/examples/viewing_meshes_ex02.py b/doc/salome/examples/viewing_meshes_ex02.py new file mode 100644 index 000000000..de345e8a3 --- /dev/null +++ b/doc/salome/examples/viewing_meshes_ex02.py @@ -0,0 +1,45 @@ +# Find Element by Point + +import geompy +import smesh +import SMESH + +# Create a geometry to mesh +box = geompy.MakeBoxDXDYDZ(100,100,100) + +# Create a mesh +mesh = Mesh(box,"Mesh") +mesh.AutomaticHexahedralization() +mesh.Compute() + +# Create a point +x,y,z = 0, 0, 1 + +# Find all elements (except 0D ones) located at the point +all_elems_except_0D = mesh.FindElementsByPoint(x,y,z) +assert( len(all_elems_except_0D) == 4) + +# Find nodes at the point +nodes = mesh.FindElementsByPoint(x,y,z, SMESH.NODE ) +assert( len(nodes) == 0) +assert( len( mesh.FindElementsByPoint(x,y,0, SMESH.NODE)) == 1) + +# Find an edge at the point +edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE ) +assert( len(edges) == 1) + +# Find faces at the point +edges = mesh.FindElementsByPoint(x,y,z, SMESH.FACE ) +assert( len(edges) == 2) + +# Find a volume at the point +vols = mesh.FindElementsByPoint(x,y,z, SMESH.VOLUME ) +assert( len(vols) == 1) + +# Find 0D elements at the point +elems0d = mesh.FindElementsByPoint(x,y,z, SMESH.ELEM0D ) +assert( len(elems0d) == 0) + +# Find edges within a group +group1D = mesh.MakeGroupByIds("1D", SMESH.EDGE, [1,2] ) +edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE, group1D ) diff --git a/doc/salome/gui/SMESH/doxyfile.in b/doc/salome/gui/SMESH/doxyfile.in index bceb23d55..a6a5fc1f1 100755 --- a/doc/salome/gui/SMESH/doxyfile.in +++ b/doc/salome/gui/SMESH/doxyfile.in @@ -42,7 +42,7 @@ INPUT = @srcdir@/input @top_srcdir@/src/Tools/padder/doc/input FILE_PATTERNS = *.doc EXCLUDE = IMAGE_PATH = @srcdir@/images @top_srcdir@/src/Tools/padder/doc/images -EXAMPLE_PATH = @top_srcdir@/src/SMESH_SWIG +EXAMPLE_PATH = @top_srcdir@/src/SMESH_SWIG @top_srcdir@/doc/salome/examples #--------------------------------------------------------------------------- #HTML related options diff --git a/doc/salome/gui/SMESH/input/smeshpy_interface.doc b/doc/salome/gui/SMESH/input/smeshpy_interface.doc index b2b487954..699e5c981 100644 --- a/doc/salome/gui/SMESH/input/smeshpy_interface.doc +++ b/doc/salome/gui/SMESH/input/smeshpy_interface.doc @@ -36,80 +36,8 @@ An example below demonstrates usage of the Python API for 3d mesh generation. \anchor example_3d_mesh

Example of 3d mesh generation:

- -\code -from geompy import * -import smesh - -### -# Geometry: an assembly of a box, a cylinder and a truncated cone -# meshed with tetrahedral -### - -# Define values -name = "ex21_lamp" -cote = 60 -section = 20 -size = 200 -radius_1 = 80 -radius_2 = 40 -height = 100 - -# Build a box -box = MakeBox(-cote, -cote, -cote, +cote, +cote, +cote) - -# Build a cylinder -pt1 = MakeVertex(0, 0, cote/3) -di1 = MakeVectorDXDYDZ(0, 0, 1) -cyl = MakeCylinder(pt1, di1, section, size) - -# Build a truncated cone -pt2 = MakeVertex(0, 0, size) -cone = MakeCone(pt2, di1, radius_1, radius_2, height) - -# Fuse -box_cyl = MakeFuse(box, cyl) -piece = MakeFuse(box_cyl, cone) - -# Add to the study -addToStudy(piece, name) - -# Create a group of faces -group = CreateGroup(piece, ShapeType["FACE"]) -group_name = name + "_grp" -addToStudy(group, group_name) -group.SetName(group_name) - -# Add faces to the group -faces = SubShapeAllIDs(piece, ShapeType["FACE"]) -UnionIDs(group, faces) - -### -# Create a mesh -### - -# Define a mesh on a geometry -tetra = smesh.Mesh(piece, name) - -# Define 1D hypothesis -algo1d = tetra.Segment() -algo1d.LocalLength(10) - -# Define 2D hypothesis -algo2d = tetra.Triangle() -algo2d.LengthFromEdges() - -# Define 3D hypothesis -algo3d = tetra.Tetrahedron() -algo3d.MaxElementVolume(100) - -# Compute the mesh -tetra.Compute() - -# Create a groupe of faces -tetra.Group(group) - -\endcode +\include 3dmesh.py +Download this script Examples of Python scripts for Mesh operations are available by the following links: @@ -128,5 +56,6 @@ the following links: - \subpage tui_measurements_page - \subpage tui_generate_flat_elements_page - \subpage tui_work_on_objects_from_gui +- \subpage tui_prism_3d_algo */ diff --git a/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc b/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc index 3eb7f0fe2..4cc1ec654 100644 --- a/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc +++ b/doc/salome/gui/SMESH/input/tui_cartesian_algo.doc @@ -1,49 +1,7 @@ /*! \page tui_cartesian_algo Usage of Body Fitting algorithm - -\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -# create a sphere -sphere = geompy.MakeSphereR( 50 ) -geompy.addToStudy( sphere, "sphere" ) - -# create a mesh and assign a "Body Fitting" algo -mesh = Mesh( sphere ) -cartAlgo = mesh.BodyFitted() - -# define a cartesian grid using Coordinates -coords = range(-100,100,10) -cartHyp = cartAlgo.SetGrid( coords,coords,coords, 1000000) - -# compute the mesh -mesh.Compute() -print "nb hexahedra",mesh.NbHexas() -print "nb tetrahedra",mesh.NbTetras() -print "nb polyhedra",mesh.NbPolyhedrons() -print - -# define the grid by setting constant spacing -cartHyp = cartAlgo.SetGrid( "10","10","10", 1000000) - -mesh.Compute() -print "nb hexahedra",mesh.NbHexas() -print "nb tetrahedra",mesh.NbTetras() -print "nb polyhedra",mesh.NbPolyhedrons() - - -# define the grid by setting different spacing in 2 sub-ranges of geometry -spaceFuns = ["5","10+10*t"] -cartAlgo.SetGrid( [spaceFuns, [0.5]], [spaceFuns, [0.5]], [spaceFuns, [0.25]], 10 ) - -mesh.Compute() -print "nb hexahedra",mesh.NbHexas() -print "nb tetrahedra",mesh.NbTetras() -print "nb polyhedra",mesh.NbPolyhedrons() -print - -\endcode +\include cartesian_algo.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_creating_meshes.doc b/doc/salome/gui/SMESH/input/tui_creating_meshes.doc index 24161d483..bdeeb8a7a 100644 --- a/doc/salome/gui/SMESH/input/tui_creating_meshes.doc +++ b/doc/salome/gui/SMESH/input/tui_creating_meshes.doc @@ -7,296 +7,52 @@

Construction of a Mesh

- -\code -import geompy -import smesh - -# create a box -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") - -# create a mesh -tetra = smesh.Mesh(box, "MeshBox") - -algo1D = tetra.Segment() -algo1D.NumberOfSegments(7) - -algo2D = tetra.Triangle() -algo2D.MaxElementArea(800.) - -algo3D = tetra.Tetrahedron() -algo3D.MaxElementVolume(900.) - -# compute the mesh -ret = tetra.Compute() -if ret == 0: - print "problem when computing the mesh" -else: - print "mesh computed" - pass -\endcode +\include creating_meshes_ex01.py +Download this script
\anchor tui_construction_submesh

Construction of a Submesh

- -\code -from geompy import * -import smesh - -# create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") - -# select one edge of the box for definition of a local hypothesis -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") - -# create a hexahedral mesh on the box -quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh") - -# create a regular 1D algorithm for the faces -algo1D = quadra.Segment() - -# define "NumberOfSegments" hypothesis to cut -# all the edges in a fixed number of segments -algo1D.NumberOfSegments(4) - -# create a quadrangle 2D algorithm for the faces -quadra.Quadrangle() - -# construct a submesh on the edge with a local hypothesis -algo_local = quadra.Segment(EdgeX) - -# define "Arithmetic1D" hypothesis to cut the edge in several segments with increasing arithmetic length -algo_local.Arithmetic1D(1, 4) - -# define "Propagation" hypothesis that propagates all other hypotheses -# on all edges of the opposite side in case of quadrangular faces -algo_local.Propagation() - -# compute the mesh -quadra.Compute() - -\endcode +\include creating_meshes_ex02.py +Download this script

Change priority of submeshes in Mesh

- -\code -import salome -import geompy -import smesh -import SMESH - -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -[Face_1,Face_2,Face_3,Face_4,Face_5,Face_6] = geompy.SubShapeAllSorted(Box_1, geompy.ShapeType["FACE"]) - -# create Mesh object on Box shape -Mesh_1 = smesh.Mesh(Box_1) - -# assign mesh algorithms -Regular_1D = Mesh_1.Segment() -Nb_Segments_1 = Regular_1D.NumberOfSegments(20) -Nb_Segments_1.SetDistrType( 0 ) -MEFISTO_2D = Mesh_1.Triangle() -Max_Element_Area_1 = MEFISTO_2D.MaxElementArea(1200) -Tetrahedron = Mesh_1.Tetrahedron() -Max_Element_Volume_1 = Tetrahedron.MaxElementVolume(40000) - -# create submesh and assign algorithms on Face_1 -Regular_1D_1 = Mesh_1.Segment(geom=Face_1) -Nb_Segments_2 = Regular_1D_1.NumberOfSegments(4) -Nb_Segments_2.SetDistrType( 0 ) -MEFISTO_2D_1 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_1) -Length_From_Edges_2D = MEFISTO_2D_1.LengthFromEdges() -SubMesh_1 = MEFISTO_2D_1.GetSubMesh() - -# create submesh and assign algorithms on Face_2 -Regular_1D_2 = Mesh_1.Segment(geom=Face_2) -Nb_Segments_3 = Regular_1D_2.NumberOfSegments(8) -Nb_Segments_3.SetDistrType( 0 ) -MEFISTO_2D_2 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_2) -Length_From_Edges_2D_1 = MEFISTO_2D_2.LengthFromEdges() -SubMesh_2 = MEFISTO_2D_2.GetSubMesh() - -# create submesh and assign algorithms on Face_3 -Regular_1D_3 = Mesh_1.Segment(geom=Face_3) -Nb_Segments_4 = Regular_1D_3.NumberOfSegments(12) -Nb_Segments_4.SetDistrType( 0 ) -MEFISTO_2D_3 = Mesh_1.Triangle(algo=smesh.MEFISTO,geom=Face_3) -Length_From_Edges_2D_2 = MEFISTO_2D_3.LengthFromEdges() -SubMesh_3 = MEFISTO_2D_3.GetSubMesh() - -# check exisiting submesh priority order -[ [ SubMesh_1, SubMesh_3, SubMesh_2 ] ] = Mesh_1.GetMeshOrder() -# set new submesh order -isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_1, SubMesh_2, SubMesh_3 ] ]) -# compute mesh -isDone = Mesh_1.Compute() - -# clear mesh result and compute with other submesh order -Mesh_1.Clear() -isDone = Mesh_1.SetMeshOrder( [ [ SubMesh_2, SubMesh_1, SubMesh_3 ] ]) -isDone = Mesh_1.Compute() - -\endcode +\include creating_meshes_ex03.py +Download this script
\anchor tui_editing_mesh

Editing of a mesh

- -\code -import geompy -import smesh - -def PrintMeshInfo(theMesh): - aMesh = theMesh.GetMesh() - print "Information about mesh:" - print "Number of nodes : ", aMesh.NbNodes() - print "Number of edges : ", aMesh.NbEdges() - print "Number of faces : ", aMesh.NbFaces() - print "Number of volumes : ", aMesh.NbVolumes() - pass - -# create a box -box = geompy.MakeBox(0., 0., 0., 20., 20., 20.) -geompy.addToStudy(box, "box") - -# select one edge of the box for definition of a local hypothesis -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"]) -edge = subShapeList[0] -name = geompy.SubShapeName(edge, box) -geompy.addToStudyInFather(box, edge, name) - -# create a mesh -tria = smesh.Mesh(box, "Mesh 2D") -algo1D = tria.Segment() -hyp1 = algo1D.NumberOfSegments(3) -algo2D = tria.Triangle() -hyp2 = algo2D.MaxElementArea(10.) - -# create a sub-mesh -algo_local = tria.Segment(edge) -hyp3 = algo_local.Arithmetic1D(1, 6) -hyp4 = algo_local.Propagation() - -# compute the mesh -tria.Compute() -PrintMeshInfo(tria) - -# remove a local hypothesis -mesh = tria.GetMesh() -mesh.RemoveHypothesis(edge, hyp4) - -# compute the mesh -tria.Compute() -PrintMeshInfo(tria) - -# change the value of the 2D hypothesis -hyp2.SetMaxElementArea(2.) - -# compute the mesh -tria.Compute() -PrintMeshInfo(tria) -\endcode +\include creating_meshes_ex04.py +Download this script
\anchor tui_export_mesh

Export of a Mesh

- -\code -import geompy -import smesh - -# create a box -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") - -# create a mesh -tetra = smesh.Mesh(box, "MeshBox") - -algo1D = tetra.Segment() -algo1D.NumberOfSegments(7) - -algo2D = tetra.Triangle() -algo2D.MaxElementArea(800.) - -algo3D = tetra.Tetrahedron() -algo3D.MaxElementVolume(900.) - -# compute the mesh -tetra.Compute() - -# export the mesh in a MED file -tetra.ExportMED("/tmp/meshMED.med", 0) - -# export a group in a MED file -face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] # a box side -group = tetra.GroupOnGeom( face, "face group" ) # group of 2D elements on the -tetra.ExportMED("/tmp/groupMED.med", meshPart=group) -\endcode +\include creating_meshes_ex05.py +Download this script

How to mesh a cylinder with hexahedrons?

Here you can see an example of python script, creating a hexahedral mesh on a cylinder. And a picture below the source code of the script, demonstrating the resulting mesh. -\include ex24_cylinder.py +\include creating_meshes_ex06.py +Download this script \image html mesh_cylinder_hexa.png
\anchor tui_building_compound

Building a compound of meshes

-\dontinclude SMESH_BuildCompound.py -\skipline import geompy -\until #end +\include creating_meshes_ex07.py +Download this script
\anchor tui_copy_mesh

Mesh Copying

-\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -# make geometry of a box -box = geompy.MakeBoxDXDYDZ(100,100,100) -face = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0] - -# generate 3D mesh -mesh = Mesh(box) -localAlgo = mesh.Triangle(face) -mesh.AutomaticHexahedralization() - -# objects to copy -fGroup = mesh.GroupOnGeom( face, "2D on face") -nGroup = mesh.GroupOnGeom( face, "nodes on face", NODE) -subMesh = localAlgo.GetSubMesh() - -# make a new mesh by copying different parts of the mesh - -# 1. copy the whole mesh -newMesh = CopyMesh( mesh, "whole mesh copy") - -# 2. copy a group of 2D elements along with groups -newMesh = CopyMesh( fGroup, "face group copy with groups",toCopyGroups=True) - -# 3. copy a group of nodes with preseving their ids -newMesh = CopyMesh( nGroup, "node group copy", toKeepIDs=True) - -# 4. copy some faces -faceIds = fGroup.GetIDs()[-10:] -newMesh = CopyMesh( mesh.GetIDSource( faceIds, FACE ), "some faces copy") - -# 5. copy some nodes -nodeIds = nGroup.GetIDs()[-10:] -newMesh = CopyMesh( mesh.GetIDSource( nodeIds, NODE), "some nodes copy") - -# 6. copy a sub-mesh -newMesh = CopyMesh( subMesh, "submesh copy" ) -\endcode +\include creating_meshes_ex08.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_defining_hypotheses.doc b/doc/salome/gui/SMESH/input/tui_defining_hypotheses.doc index d9e2b31f9..3f3124db3 100644 --- a/doc/salome/gui/SMESH/input/tui_defining_hypotheses.doc +++ b/doc/salome/gui/SMESH/input/tui_defining_hypotheses.doc @@ -44,738 +44,102 @@ This page provides example codes of \ref tui_defining_meshing_algos
\anchor tui_1d_arithmetic

Arithmetic 1D

- -\code -import geompy -import smesh - -# create a box -box = geompy.MakeBoxDXDYDZ(10., 10., 10.) -geompy.addToStudy(box, "Box") - -# create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") - -# create a Regular 1D algorithm for edges -algo1D = hexa.Segment() - -# optionally reverse node distribution on certain edges -allEdges = geompy.SubShapeAllSortedIDs( box, geompy.ShapeType["EDGE"]) -reversedEdges = [ allEdges[0], allEdges[4] ] - -# define "Arithmetic1D" hypothesis to cut all edges in several segments with increasing arithmetic length -algo1D.Arithmetic1D(1, 4, reversedEdges) - -# create a quadrangle 2D algorithm for faces -hexa.Quadrangle() - -# create a hexahedron 3D algorithm for solids -hexa.Hexahedron() - -# compute the mesh -hexa.Compute() -\endcode +\include defining_hypotheses_ex01.py +Download this script
\anchor tui_deflection_1d

Deflection 1D and Number of Segments

- -\code -import geompy -import smesh - -# create a face from arc and straight segment -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) - -exy = geompy.MakeEdge(px, py) -arc = geompy.MakeArc(py, pz, px) - -wire = geompy.MakeWire([exy, arc]) - -isPlanarFace = 1 -face1 = geompy.MakeFace(wire, isPlanarFace) -geompy.addToStudy(face1,"Face1") - -# get edges from the face -e_straight,e_arc = geompy.SubShapeAll(face1, geompy.ShapeType["EDGE"]) -geompy.addToStudyInFather(face1, e_arc, "Arc Edge") - -# create hexahedral mesh -hexa = smesh.Mesh(face1, "Face : triangle mesh") - -# define "NumberOfSegments" hypothesis to cut a straight edge in a fixed number of segments -algo1D = hexa.Segment() -algo1D.NumberOfSegments(6) - -# define "MaxElementArea" hypothesis -algo2D = hexa.Triangle() -algo2D.MaxElementArea(70.0) - -# define a local "Deflection1D" hypothesis on the arc -algo_local = hexa.Segment(e_arc) -algo_local.Deflection1D(1.0) - -# compute the mesh -hexa.Compute() -\endcode +\include defining_hypotheses_ex02.py +Download this script
\anchor tui_start_and_end_length

Start and End Length

- -\code -from geompy import * -import smesh - -# create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") - -# get one edge of the box to put local hypothesis on -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") - -# create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") - -# set algorithms -algo1D = hexa.Segment() -hexa.Quadrangle() -hexa.Hexahedron() - -# define "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments -algo1D.NumberOfSegments(4) - -# create a local hypothesis -algo_local = hexa.Segment(EdgeX) - -# define "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length -algo_local.StartEndLength(1, 6) - -# define "Propagation" hypothesis that propagates all other hypothesis -# on all edges on the opposite side in case of quadrangular faces -algo_local.Propagation() - -# compute the mesh -hexa.Compute() -\endcode +\include defining_hypotheses_ex03.py +Download this script
\anchor tui_average_length

Local Length

- -\code -from geompy import * -import smesh - -# create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") - -# get one edge of the box to put local hypothesis on -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") - -# create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") - -# set algorithms -algo1D = hexa.Segment() -hexa.Quadrangle() -hexa.Hexahedron() - -# define "NumberOfSegments" hypothesis to cut all edges in a fixed number of segments -algo1D.NumberOfSegments(4) - -# create a sub-mesh -algo_local = hexa.Segment(EdgeX) - -# define "LocalLength" hypothesis to cut an edge in several segments with the same length -algo_local.LocalLength(2.) - -# define "Propagation" hypothesis that propagates all other hypothesis -# on all edges on the opposite side in case of quadrangular faces -algo_local.Propagation() - -# compute the mesh -hexa.Compute() -\endcode +\include defining_hypotheses_ex04.py +Download this script

Defining 2D and 3D hypotheses


\anchor tui_max_element_area

Maximum Element Area

- -\code -import geompy -import smesh -import salome - -# create a face -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) - -vxy = geompy.MakeVector(px, py) -arc = geompy.MakeArc(py, pz, px) -wire = geompy.MakeWire([vxy, arc]) - -isPlanarFace = 1 -face = geompy.MakeFace(wire, isPlanarFace) - -# add the face in the study -id_face = geompy.addToStudy(face, "Face to be meshed") - -# create a mesh -tria_mesh = smesh.Mesh(face, "Face : triangulation") - -# define 1D meshing: -algo = tria_mesh.Segment() -algo.NumberOfSegments(20) - -# define 2D meshing: - -# assign triangulation algorithm -algo = tria_mesh.Triangle() - -# apply "Max Element Area" hypothesis to each triangle -algo.MaxElementArea(100) - -# compute the mesh -tria_mesh.Compute() -\endcode +\include defining_hypotheses_ex05.py +Download this script
\anchor tui_max_element_volume

Maximum Element Volume

- -\code -import geompy -import smesh - -# create a cylinder -cyl = geompy.MakeCylinderRH(30., 50.) -geompy.addToStudy(cyl, "cyl") - -# create a mesh on the cylinder -tetra = smesh.Mesh(cyl, "Cylinder : tetrahedrical mesh") - -# assign algorithms -algo1D = tetra.Segment() -algo2D = tetra.Triangle() -algo3D = tetra.Tetrahedron() - -# assign 1D and 2D hypotheses -algo1D.NumberOfSegments(7) -algo2D.MaxElementArea(150.) - -# assign Max Element Volume hypothesis -algo3D.MaxElementVolume(200.) - -# compute the mesh -ret = tetra.Compute() -if ret == 0: - print "probleme when computing the mesh" -else: - print "Computation succeded" -\endcode +\include defining_hypotheses_ex06.py +Download this script
\anchor tui_length_from_edges

Length from Edges

- -\code -import geompy -import smesh - -# create sketchers -sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW") -sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW") - -# create a face from two wires -isPlanarFace = 1 -face1 = geompy.MakeFaces([sketcher1, sketcher2], isPlanarFace) -geompy.addToStudy(face1, "Face1") - -# create a mesh -tria = smesh.Mesh(face1, "Face : triangle 2D mesh") - -# Define 1D meshing -algo1D = tria.Segment() -algo1D.NumberOfSegments(2) - -# create and assign the algorithm for 2D meshing with triangles -algo2D = tria.Triangle() - -# create and assign "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire -algo2D.LengthFromEdges() - -# compute the mesh -tria.Compute() -\endcode +\include defining_hypotheses_ex07.py +Download this script

Defining Additional Hypotheses


\anchor tui_propagation

Propagation

- -\code -from geompy import * -import smesh - -# create a box -box = MakeBoxDXDYDZ(10., 10., 10.) -addToStudy(box, "Box") - -# get one edge of the box to put local hypothesis on -p5 = MakeVertex(5., 0., 0.) -EdgeX = GetEdgeNearPoint(box, p5) -addToStudyInFather(box, EdgeX, "Edge [0,0,0 - 10,0,0]") - -# create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") - -# set global algorithms and hypotheses -algo1D = hexa.Segment() -hexa.Quadrangle() -hexa.Hexahedron() -algo1D.NumberOfSegments(4) - -# create a sub-mesh with local 1D hypothesis and propagation -algo_local = hexa.Segment(EdgeX) - -# define "Arithmetic1D" hypothesis to cut an edge in several segments with increasing length -algo_local.Arithmetic1D(1, 4) - -# define "Propagation" hypothesis that propagates all other 1D hypotheses -# from all edges on the opposite side of a face in case of quadrangular faces -algo_local.Propagation() - -# compute the mesh -hexa.Compute() -\endcode +\include defining_hypotheses_ex08.py +Download this script
\anchor tui_defining_meshing_algos

Defining Meshing Algorithms

- -\code -import geompy -import smesh - -# create a box -box = geompy.MakeBoxDXDYDZ(10., 10., 10.) -geompy.addToStudy(box, "Box") - -# 1. Create a hexahedral mesh on the box -hexa = smesh.Mesh(box, "Box : hexahedrical mesh") - -# create a Regular 1D algorithm for edges -algo1D = hexa.Segment() - -# create a quadrangle 2D algorithm for faces -algo2D = hexa.Quadrangle() - -# create a hexahedron 3D algorithm for solids -algo3D = hexa.Hexahedron() - -# define hypotheses -algo1D.Arithmetic1D(1, 4) - -# compute the mesh -hexa.Compute() - -# 2. Create a tetrahedral mesh on the box -tetra = smesh.Mesh(box, "Box : tetrahedrical mesh") - -# create a Regular 1D algorithm for edges -algo1D = tetra.Segment() - -# create a Mefisto 2D algorithm for faces -algo2D = tetra.Triangle() - -# create a 3D algorithm for solids -algo3D = tetra.Tetrahedron() - -# define hypotheses -algo1D.Arithmetic1D(1, 4) -algo2D.LengthFromEdges() - -# compute the mesh -tetra.Compute() - -\endcode +\include defining_hypotheses_ex09.py +Download this script
\anchor tui_projection

Projection Algorithms

- -\code -# Project prisms from one meshed box to another mesh on the same box - -from smesh import * - -# Prepare geometry - -# Create a parallelepiped -box = geompy.MakeBoxDXDYDZ(200, 100, 70) -geompy.addToStudy( box, "box" ) - -# Get geom faces to mesh with triangles in the 1ts and 2nd meshes -faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -# 2 adjacent faces of the box -f1 = faces[2] -f2 = faces[0] -# face opposite to f2 -f2opp = faces[1] - -# Get vertices used to specify how to associate sides of faces at projection -[v1F1, v2F1] = geompy.SubShapeAll(f1, geompy.ShapeType["VERTEX"])[:2] -[v1F2, v2F2] = geompy.SubShapeAll(f2, geompy.ShapeType["VERTEX"])[:2] -geompy.addToStudyInFather( box, v1F1, "v1F1" ) -geompy.addToStudyInFather( box, v2F1, "v2F1" ) -geompy.addToStudyInFather( box, v1F2, "v1F2" ) -geompy.addToStudyInFather( box, v2F2, "v2F2" ) - -# Make group of 3 edges of f1 and f2 -edgesF1 = geompy.CreateGroup(f1, geompy.ShapeType["EDGE"]) -geompy.UnionList( edgesF1, geompy.SubShapeAll(f1, geompy.ShapeType["EDGE"])[:3]) -edgesF2 = geompy.CreateGroup(f2, geompy.ShapeType["EDGE"]) -geompy.UnionList( edgesF2, geompy.SubShapeAll(f2, geompy.ShapeType["EDGE"])[:3]) -geompy.addToStudyInFather( box, edgesF1, "edgesF1" ) -geompy.addToStudyInFather( box, edgesF2, "edgesF2" ) - - -# Make the source mesh with prisms -src_mesh = Mesh(box, "Source mesh") -src_mesh.Segment().NumberOfSegments(9,10) -src_mesh.Quadrangle() -src_mesh.Hexahedron() -src_mesh.Triangle(f1) # triangular sumbesh -src_mesh.Compute() - - -# Mesh the box using projection algoritms - -# Define the same global 1D and 2D hypotheses -tgt_mesh = Mesh(box, "Target mesh") -tgt_mesh.Segment().NumberOfSegments(9,10,UseExisting=True) -tgt_mesh.Quadrangle() - -# Define Projection 1D algorithm to project 1d mesh elements from group edgesF2 to edgesF1 -# It is actually not needed, just a demonstration -proj1D = tgt_mesh.Projection1D( edgesF1 ) -# each vertex must be at the end of a connected group of edges (or a sole edge) -proj1D.SourceEdge( edgesF2, src_mesh, v2F1, v2F2 ) - -# Define 2D hypotheses to project triangles from f1 face of the source mesh to -# f2 face in the target mesh. Vertices specify how to associate sides of faces -proj2D = tgt_mesh.Projection2D( f2 ) -proj2D.SourceFace( f1, src_mesh, v1F1, v1F2, v2F1, v2F2 ) - -# 2D hypotheses to project triangles from f2 of target mesh to the face opposite to f2. -# Association of face sides is default -proj2D = tgt_mesh.Projection2D( f2opp ) -proj2D.SourceFace( f2 ) - -# 3D hypotheses to project prisms from the source to the target mesh -proj3D = tgt_mesh.Projection3D() -proj3D.SourceShape3D( box, src_mesh, v1F1, v1F2, v2F1, v2F2 ) -tgt_mesh.Compute() - -# Move the source mesh to visualy compare the two meshes -src_mesh.TranslateObject( src_mesh, MakeDirStruct( 210, 0, 0 ), Copy=False) - -\endcode +\include defining_hypotheses_ex10.py +Download this script

Projection 1D2D

- -\code -# Project triangles from one meshed face to another mesh on the same box - -from smesh import * - -# Prepare geometry - -# Create a box -box = geompy.MakeBoxDXDYDZ(100, 100, 100) - -# Get geom faces to mesh with triangles in the 1ts and 2nd meshes -faces = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -# 2 adjacent faces of the box -Face_1 = faces[2] -Face_2 = faces[0] - -geompy.addToStudy( box, 'box' ) -geompy.addToStudyInFather( box, Face_1, 'Face_1' ) -geompy.addToStudyInFather( box, Face_2, 'Face_2' ) - -# Make the source mesh with Netgem2D -src_mesh = Mesh(Face_1, "Source mesh") -src_mesh.Segment().NumberOfSegments(15) -src_mesh.Triangle() -src_mesh.Compute() - -# Mesh the target mesh using the algoritm Projection1D2D -tgt_mesh = smesh.Mesh(Face_2, "Target mesh") -tgt_mesh.Projection1D2D().SourceFace(Face_1,src_mesh) -tgt_mesh.Compute() -\endcode +\include defining_hypotheses_ex11.py +Download this script
\anchor tui_fixed_points

1D Mesh with Fixed Points example

- -\code -import salome -import geompy -import smesh -import StdMeshers - -# Create face and explode it on edges -face = geompy.MakeFaceHW(100, 100, 1) -edges = geompy.SubShapeAllSorted(face, geompy.ShapeType["EDGE"]) -geompy.addToStudy( face, "Face" ) - -# get the first edge from exploded result -edge1 = geompy.GetSubShapeID(face, edges[0]) - -# Define Mesh on previously created face -Mesh_1 = smesh.Mesh(face) - -# Create Fixed Point 1D hypothesis and define parameters. -# Note: values greater than 1.0 and less than 0.0 are not taken into account; -# duplicated values are removed. Also, if not specified explicitly, values 0.0 and 1.0 -# add added automatically. -# The number of segments should correspond to the number of points (NbSeg = NbPnt-1); -# extra values of segments splitting parameter are not taken into account, -# while missing values are considered to be equal to 1. -Fixed_points_1D_1 = smesh.CreateHypothesis('FixedPoints1D') -Fixed_points_1D_1.SetPoints( [ 1.1, 0.9, 0.5, 0.0, 0.5, -0.3 ] ) -Fixed_points_1D_1.SetNbSegments( [ 3, 1, 2 ] ) -Fixed_points_1D_1.SetReversedEdges( [edge1] ) - -# Add hypothesis to mesh and define 2D parameters -Mesh_1.AddHypothesis(Fixed_points_1D_1) -Regular_1D = Mesh_1.Segment() -Quadrangle_2D = Mesh_1.Quadrangle() -# Compute mesh -Mesh_1.Compute() -\endcode +\include defining_hypotheses_ex12.py +Download this script \anchor tui_radial_quadrangle

Radial Quadrangle 1D2D example

-\code -from smesh import * - -SetCurrentStudy(salome.myStudy) - -# Create face from the wire and add to study -Face = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:R 90:C 20 90:WF", [0, 0, 0, 1, 0, 0, 0, 0, 1]) -geompy.addToStudy(Face,"Face") -edges = geompy.SubShapeAllSorted(Face, geompy.ShapeType["EDGE"]) -circle, radius1, radius2 = edges -geompy.addToStudyInFather(Face, radius1,"radius1") -geompy.addToStudyInFather(Face, radius2,"radius2") -geompy.addToStudyInFather(Face, circle,"circle") - - -# Define geometry for mesh, and Radial Quadrange algorithm -mesh = smesh.Mesh(Face) -radial_Quad_algo = mesh.Quadrangle(algo=RADIAL_QUAD) - -# The Radial Quadrange algorithm can work without any hypothesis -# In this case it uses "Default Nb of Segments" preferences parameter to discretize edges -mesh.Compute() - -# The Radial Quadrange uses global or local 1d hypotheses if it does -# not have its own hypotheses. -# Define global hypotheses to discretize radial edges and a local one for circular edge -global_Nb_Segments = mesh.Segment().NumberOfSegments(5) -local_Nb_Segments = mesh.Segment(circle).NumberOfSegments(10) -mesh.Compute() - -# Define own parameters of Radial Quadrange algorithm -radial_Quad_algo.NumberOfLayers( 4 ) -mesh.Compute() -\endcode +\include defining_hypotheses_ex13.py +Download this script \anchor tui_quadrangle_parameters

Quadrangle Parameters example 1 (meshing a face with 3 edges)

-\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -# Get 1/4 part from the disk face. -Box_1 = geompy.MakeBoxDXDYDZ(100, 100, 100) -Disk_1 = geompy.MakeDiskR(100, 1) -Common_1 = geompy.MakeCommon(Disk_1, Box_1) -geompy.addToStudy( Disk_1, "Disk_1" ) -geompy.addToStudy( Box_1, "Box_1" ) -geompy.addToStudy( Common_1, "Common_1" ) - -# Set the Geometry for meshing -Mesh_1 = smesh.Mesh(Common_1) - - -# Define 1D hypothesis and compute the mesh -Regular_1D = Mesh_1.Segment() -Nb_Segments_1 = Regular_1D.NumberOfSegments(10) -Nb_Segments_1.SetDistrType( 0 ) - -# Create Quadrangle parameters and define the Base Vertex. -Quadrangle_2D = Mesh_1.Quadrangle().TriangleVertex( 8 ) - -Mesh_1.Compute() -\endcode +\include defining_hypotheses_ex14.py +Download this script

Quadrangle Parameters example 2 (using different types)

-\code -import geompy -import smesh -import StdMeshers - -# Make quadrangle face and explode it on edges. -Vertex_1 = geompy.MakeVertex(0, 0, 0) -Vertex_2 = geompy.MakeVertex(40, 0, 0) -Vertex_3 = geompy.MakeVertex(40, 30, 0) -Vertex_4 = geompy.MakeVertex(0, 30, 0) -Quadrangle_Face_1 = geompy.MakeQuad4Vertices(Vertex_1, Vertex_4, Vertex_3, Vertex_2) -[Edge_1,Edge_2,Edge_3,Edge_4] = geompy.SubShapeAllSorted(Quadrangle_Face_1, geompy.ShapeType["EDGE"]) -geompy.addToStudy( Vertex_1, "Vertex_1" ) -geompy.addToStudy( Vertex_2, "Vertex_2" ) -geompy.addToStudy( Vertex_3, "Vertex_3" ) -geompy.addToStudy( Vertex_4, "Vertex_4" ) -geompy.addToStudy( Quadrangle_Face_1, "Quadrangle Face_1" ) -geompy.addToStudyInFather( Quadrangle_Face_1, Edge_2, "Edge_2" ) - -# Set the Geometry for meshing -Mesh_1 = smesh.Mesh(Quadrangle_Face_1) - -# Create Quadrangle parameters and -# define the Type as Quadrangle Preference -Quadrangle_Parameters_1 = smesh.CreateHypothesis('QuadrangleParams') -Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_QUADRANGLE_PREF ) - -# Define other hypotheses and algorithms -Regular_1D = Mesh_1.Segment() -Nb_Segments_1 = Regular_1D.NumberOfSegments(4) -Nb_Segments_1.SetDistrType( 0 ) -status = Mesh_1.AddHypothesis(Quadrangle_Parameters_1) -Quadrangle_2D = Mesh_1.Quadrangle() - -# Define submesh on one edge to provide different number of segments -Regular_1D_1 = Mesh_1.Segment(geom=Edge_2) -Nb_Segments_2 = Regular_1D_1.NumberOfSegments(10) -Nb_Segments_2.SetDistrType( 0 ) -SubMesh_1 = Regular_1D_1.GetSubMesh() - -# Compute mesh (with Quadrangle Preference type) -isDone = Mesh_1.Compute() - -# Change type to Reduced and compute again -Quadrangle_Parameters_1.SetQuadType( StdMeshers.QUAD_REDUCED ) -isDone = Mesh_1.Compute() -\endcode +\include defining_hypotheses_ex15.py +Download this script \anchor tui_import

"Use Existing Elements" example

-\code - -from smesh import * -SetCurrentStudy(salome.myStudy) - -# Make a patritioned box - -box = geompy.MakeBoxDXDYDZ(100,100,100) - -N = geompy.MakeVectorDXDYDZ( 1,0,0 ) -O = geompy.MakeVertex( 50,0,0 ) -plane = geompy.MakePlane( O, N, 200 ) # plane YOZ - -shape2boxes = geompy.MakeHalfPartition( box, plane ) -boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"]) - -geompy.addToStudy( boxes[0], "boxes[0]") -geompy.addToStudy( boxes[1], "boxes[1]") -midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5] -geompy.addToStudyInFather( boxes[0], midFace0, "middle Face") -midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0] -geompy.addToStudyInFather( boxes[1], midFace1, "middle Face") - -# Mesh one of boxes with quadrangles. It is a source mesh - -srcMesh = Mesh(boxes[0], "source mesh") # box coloser to CS origin -nSeg1 = srcMesh.Segment().NumberOfSegments(4) -srcMesh.Quadrangle() -srcMesh.Compute() -srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", FACE ) - -# Import faces from midFace0 to the target mesh - -tgtMesh = Mesh(boxes[1], "target mesh") -importAlgo = tgtMesh.UseExisting2DElements(midFace1) -import2hyp = importAlgo.SourceFaces( [srcFaceGroup] ) -tgtMesh.Segment().NumberOfSegments(3) -tgtMesh.Quadrangle() -tgtMesh.Compute() - -# Import the whole source mesh with groups -import2hyp.SetCopySourceMesh(True,True) -tgtMesh.Compute() -\endcode +\include defining_hypotheses_ex16.py +Download this script \anchor tui_viscous_layers

Viscous layers construction

-\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -X = geompy.MakeVectorDXDYDZ( 1,0,0 ) -O = geompy.MakeVertex( 100,50,50 ) -plane = geompy.MakePlane( O, X, 200 ) # plane YZ - -box = geompy.MakeBoxDXDYDZ(200,100,100) - -shape = geompy.MakeHalfPartition( box, plane ) - -faces = geompy.SubShapeAllSorted(shape, geompy.ShapeType["FACE"]) -face1 = faces[1] -ignoreFaces = [ faces[0], faces[-1]] - -geompy.addToStudy( shape, "shape" ) -geompy.addToStudyInFather( shape, face1, "face1") - - -mesh = Mesh(shape, "CFD") - -mesh.Segment().NumberOfSegments( 4 ) - -mesh.Triangle() -mesh.Quadrangle(face1) -mesh.Compute() -algo3D = mesh.Tetrahedron() - -thickness = 20 -numberOfLayers = 10 -stretchFactor = 1.5 -layersHyp = algo3D.ViscousLayers(thickness,numberOfLayers,stretchFactor,ignoreFaces) - -mesh.Compute() - -mesh.MakeGroup("Tetras",VOLUME,FT_ElemGeomType,"=",Geom_TETRA) -mesh.MakeGroup("Pyras",VOLUME,FT_ElemGeomType,"=",Geom_PYRAMID) -mesh.MakeGroup("Prims",VOLUME,FT_ElemGeomType,"=",Geom_PENTA) - -\endcode +\include defining_hypotheses_ex17.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_filters.doc b/doc/salome/gui/SMESH/input/tui_filters.doc index 0eb41dd28..2540f52b8 100755 --- a/doc/salome/gui/SMESH/input/tui_filters.doc +++ b/doc/salome/gui/SMESH/input/tui_filters.doc @@ -27,14 +27,8 @@ Filter 2D mesh elements (faces) according to the aspect ratio value: - functor type should be \a smesh.FT_AspectRatio - threshold is floating point value (aspect ratio) -\code -# create mesh -from SMESH_mechanic import * -# get faces with aspect ratio > 6.5 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, 6.5) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with aspect ratio > 6.5:", len(ids) -\endcode +\include filters_ex01.py +Download this script \sa \ref tui_aspect_ratio @@ -45,16 +39,8 @@ Filter 3D mesh elements (volumes) according to the aspect ratio value: - functor type is \a smesh.FT_AspectRatio3D - threshold is floating point value (aspect ratio) -\code -# create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() -# get volumes with aspect ratio < 2.0 -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_LessThan, 2.0) -ids = mesh.GetIdsFromFilter(filter) -print "Number of volumes with aspect ratio < 2.0:", len(ids) -\endcode +\include filters_ex02.py +Download this script \sa \ref tui_aspect_ratio_3d @@ -65,17 +51,8 @@ Filter 2D mesh elements (faces) according to the warping angle value: - functor type is \a smesh.FT_Warping - threshold is floating point value (warping angle) -\code -# create mesh -from SMESH_mechanic import * -# get faces with warping angle = 2.0e-13 with tolerance 5.0e-14 -criterion = smesh.GetCriterion(smesh.FACE, smesh.FT_Warping, smesh.FT_EqualTo, 2.0e-13) -criterion.Tolerance = 5.0e-14 -filter = smesh.CreateFilterManager().CreateFilter() -filter.SetCriteria([criterion]) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with warping angle = 2.0e-13 (tolerance 5.0e-14):", len(ids) -\endcode +\include filters_ex03.py +Download this script \sa \ref tui_warping @@ -86,14 +63,8 @@ Filter 2D mesh elements (faces) according to the minimum angle value: - functor type is \a smesh.FT_MinimumAngle - threshold is floating point value (minimum angle) -\code -# create mesh -from SMESH_mechanic import * -# get faces with minimum angle > 75 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle,">", 75) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with minimum angle > 75:", len(ids) -\endcode +\include filters_ex04.py +Download this script \sa \ref tui_minimum_angle @@ -104,14 +75,8 @@ Filter 2D mesh elements (faces) according to the taper value: - functor type is \a smesh.FT_Taper - threshold is floating point value (taper) -\code -# create mesh -from SMESH_mechanic import * -# get faces with taper < 1.e-15 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_LessThan, 1.e-15) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with taper < 1.e-15:", len(ids) -\endcode +\include filters_ex05.py +Download this script \sa \ref tui_taper @@ -122,14 +87,8 @@ Filter 2D mesh elements (faces) according to the skew value: - functor type is \a smesh.FT_Skew - threshold is floating point value (skew) -\code -# create mesh -from SMESH_mechanic import * -# get faces with skew > 50 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, 50) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with skew > 50:", len(ids) -\endcode +\include filters_ex06.py +Download this script \sa \ref tui_skew @@ -140,18 +99,8 @@ Filter 2D mesh elements (faces) according to the area value: - functor type is \a smesh.FT_Area - threshold is floating point value (area) -\code -# create mesh -from SMESH_mechanic import * -# get faces with area > 60 and < 90 -criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 60,\ - smesh.FT_Undefined, smesh.FT_LogicalAND) -criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 90) -filter = smesh.CreateFilterManager().CreateFilter() -filter.SetCriteria([criterion1,criterion2]) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with area in range (60,90):", len(ids) -\endcode +\include filters_ex07.py +Download this script \sa \ref tui_area @@ -162,16 +111,8 @@ Filter 3D mesh elements (volumes) according to the volume value: - functor type is \a smesh.FT_Volume3D - threshold is floating point value (volume) -\code -# create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() -# get volumes faces with volume > 100 -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_MoreThan, 100) -ids = mesh.GetIdsFromFilter(filter) -print "Number of volumes with volume > 100:", len(ids) -\endcode +\include filters_ex08.py +Download this script \sa \ref tui_volume @@ -182,20 +123,8 @@ Filter 1D mesh elements (edges) which represent free borders of a mesh: - functor type is \a smesh.FT_FreeBorders - threshold value is not required -\code -# create mesh -import geompy, smesh, StdMeshers -face = geompy.MakeFaceHW(100, 100, 1) -geompy.addToStudy( face, "quadrangle" ) -mesh = smesh.Mesh(face) -mesh.Segment().NumberOfSegments(10) -mesh.Triangle().MaxElementArea(25) -mesh.Compute() -# get all free borders -filter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders) -ids = mesh.GetIdsFromFilter(filter) -print "Number of edges on free borders:", len(ids) -\endcode +\include filters_ex09.py +Download this script \sa \ref tui_free_borders @@ -207,20 +136,8 @@ element of mesh only: - functor type is \a smesh.FT_FreeEdges - threshold value is not required -\code -# create mesh -import geompy, smesh, StdMeshers -face = geompy.MakeFaceHW(100, 100, 1) -geompy.addToStudy( face, "quadrangle" ) -mesh = smesh.Mesh(face) -mesh.Segment().NumberOfSegments(10) -mesh.Triangle().MaxElementArea(25) -mesh.Compute() -# get all faces with free edges -filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeEdges) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with free edges:", len(ids) -\endcode +\include filters_ex10.py +Download this script \sa \ref tui_free_edges @@ -231,16 +148,8 @@ Filter free nodes: - functor type is \a smesh.FT_FreeNodes - threshold value is not required -\code -# create mesh -from SMESH_mechanic import * -# add node -mesh.AddNode(0,0,0) -# get all free nodes -filter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes) -ids = mesh.GetIdsFromFilter(filter) -print "Number of free nodes:", len(ids) -\endcode +\include filters_ex11.py +Download this script \sa \ref tui_free_nodes @@ -251,14 +160,8 @@ Filter free faces: - functor type is \a smesh.FT_FreeFaces - threshold value is not required -\code -# create mesh -from SMESH_mechanic import * -# get all free faces -filter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces) -ids = mesh.GetIdsFromFilter(filter) -print "Number of free faces:", len(ids) -\endcode +\include filters_ex12.py +Download this script \sa \ref tui_free_faces @@ -269,16 +172,8 @@ Filter faces with bare borders: - functor type is \a smesh.FT_BareBorderFace - threshold value is not required -\code -# create mesh -from SMESH_mechanic import * -# remove some faces to have faces with bare borders -mesh.RemoveElements( mesh.GetElementsByType(FACE)[0:5] ) -# get all faces bare borders -filter = smesh.GetFilter(smesh.FACE, smesh.FT_BareBorderFace) -ids = mesh.GetIdsFromFilter(filter) -print "Faces with bare borders:", ids -\endcode +\include filters_ex13.py +Download this script \sa \ref tui_bare_border_faces @@ -290,15 +185,8 @@ Filter faces with bare borders: - threshold value is the face ID - tolerance is in degrees -\code -# create mesh -from SMESH_mechanic import * -faceID = mesh.GetElementsByType(FACE)[0] -# get all faces co-planar to the first face with tolerance 5 degrees -filter = smesh.GetFilter(smesh.FACE, smesh.FT_CoplanarFaces,faceID,Tolerance=5.0) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces coplanar with the first one:", len(ids) -\endcode +\include filters_ex14.py +Download this script \section filter_over_constrained_faces Over-constrained faces @@ -307,14 +195,8 @@ Filter over-constrained faces: - functor type is \a smesh.FT_OverConstrainedFace - threshold value is not required -\code -# create mesh -from SMESH_mechanic import * -# get all over-constrained faces -filter = smesh.GetFilter(smesh.FACE, smesh.FT_OverConstrainedFace) -ids = mesh.GetIdsFromFilter(filter) -print "Over-constrained faces:", ids -\endcode +\include filters_ex15.py +Download this script \sa \ref tui_over_constrained_faces @@ -326,27 +208,8 @@ filter mesh elements basing on the same set of nodes: smesh.FT_EqualFaces or \a smesh.FT_EqualVolumes, - threshold value is not required -\code -from smesh import * -# make a mesh on a box -box = geompy.MakeBoxDXDYDZ(100,100,100) -mesh = Mesh( box, "Box" ) -mesh.Segment().NumberOfSegments(10) -mesh.Quadrangle() -mesh.Hexahedron() -mesh.Compute() -# copy all elements with translation and Merge nodes -mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True ) -mesh.MergeNodes( mesh.FindCoincidentNodes(1e-7) ) -# create filters to find equal elements -equalEdgesFilter = GetFilter(SMESH.EDGE, FT_EqualEdges) -equalFacesFilter = GetFilter(SMESH.FACE, FT_EqualFaces) -equalVolumesFilter = GetFilter(SMESH.VOLUME, FT_EqualVolumes) -# get equal elements -print "Number of equal edges:", len( mesh.GetIdsFromFilter( equalEdgesFilter )) -print "Number of equal faces:", len( mesh.GetIdsFromFilter( equalFacesFilter )) -print "Number of equal volumes:", len( mesh.GetIdsFromFilter( equalVolumesFilter )) -\endcode +\include filters_ex16.py +Download this script \section tui_double_nodes_control Double nodes @@ -357,22 +220,8 @@ filters mesh nodes which are coincident with other nodes (within a given toleran - threshold value is not required - default tolerance is 1.0e-7 -\code -from smesh import * -# make a mesh on a box -box = geompy.MakeBoxDXDYDZ(100,100,100) -mesh = Mesh( box, "Box" ) -mesh.Segment().NumberOfSegments(10) -mesh.Quadrangle() -mesh.Hexahedron() -mesh.Compute() -# copy all elements with translation -mesh.TranslateObject( mesh, MakeDirStruct( 10,0,0), Copy=True ) -# create filters to find nodes equal within tolerance of 1e-5 -filter = GetFilter(SMESH.NODE, FT_EqualNodes, Tolerance=1e-5) -# get equal nodes -print "Number of equal nodes:", len( mesh.GetIdsFromFilter( filter )) -\endcode +\include filters_ex17.py +Download this script \section filter_borders_multiconnection Borders at multi-connection @@ -383,14 +232,8 @@ connections (faces belonging the border edges) - functor type is \a smesh.FT_MultiConnection - threshold is integer value (number of connections) -\code -# create mesh -from SMESH_mechanic import * -# get border edges with number of connected faces = 5 -filter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, 5) -ids = mesh.GetIdsFromFilter(filter) -print "Number of border edges with 5 faces connected:", len(ids) -\endcode +\include filters_ex18.py +Download this script \sa \ref tui_borders_at_multiconnection @@ -402,14 +245,8 @@ to the specified number of mesh elements - functor type is \a smesh.FT_MultiConnection2D - threshold is integer value (number of connections) -\code -# create mesh -from SMESH_mechanic import * -# get faces which consist of edges belonging to 2 mesh elements -filter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, 2) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces consisting of edges belonging to 2 faces:", len(ids) -\endcode +\include filters_ex19.py +Download this script \sa \ref tui_borders_at_multiconnection_2d @@ -420,14 +257,8 @@ Filter 1D mesh elements (edges) according to the edge length value: - functor type should be \a smesh.FT_Length - threshold is floating point value (length) -\code -# create mesh -from SMESH_mechanic import * -# get edges with length > 14 -filter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, 14) -ids = mesh.GetIdsFromFilter(filter) -print "Number of edges with length > 14:", len(ids) -\endcode +\include filters_ex20.py +Download this script \sa \ref tui_length_1d @@ -439,14 +270,8 @@ value of its edges: - functor type should be \a smesh.FT_Length2D - threshold is floating point value (edge length) -\code -# create mesh -from SMESH_mechanic import * -# get all faces that have edges with length > 14 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, 14) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with maximum edge length > 14:", len(ids) -\endcode +\include filters_ex21.py +Download this script \sa \ref tui_length_2d @@ -458,14 +283,8 @@ value of its edges and diagonals: - functor type should be \a smesh.FT_MaxElementLength2D - threshold is floating point value (edge/diagonal length) -\code -# create mesh -from SMESH_mechanic import * -# get all faces that have elements with length > 10 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, 10) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces with maximum element length > 10:", len(ids) -\endcode +\include filters_ex22.py +Download this script \sa \ref tui_max_element_length_2d @@ -477,16 +296,8 @@ value of its edges and diagonals: - functor type should be \a smesh.FT_MaxElementLength3D - threshold is floating point value (edge/diagonal length) -\code -# create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() -# get all volumes that have elements with length > 10 -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, 10) -ids = mesh.GetIdsFromFilter(filter) -print "Number of volumes with maximum element length > 10:", len(ids) -\endcode +\include filters_ex23.py +Download this script \sa \ref tui_max_element_length_3d @@ -497,18 +308,8 @@ Filter 3D mesh elements with bare borders: - functor type is \a smesh.FT_BareBorderVolume - threshold value is not required -\code -# create mesh -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() -# remove some volumes to have volumes with bare borders -mesh.RemoveElements( mesh.GetElementsByType(VOLUME)[0:5] ) -# get all volumes with bare borders -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BareBorderVolume) -ids = mesh.GetIdsFromFilter(filter) -print "Volumes with bare borders:", ids -\endcode +\include filters_ex24.py +Download this script \sa \ref tui_bare_border_volumes @@ -519,16 +320,8 @@ Filter over-constrained volumes: - functor type is \a smesh.FT_OverConstrainedVolume - threshold value is not required -\code -# create mesh -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() -# get all over-constrained volumes -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_OverConstrainedVolume) -ids = mesh.GetIdsFromFilter(filter) -print "Over-constrained volumes:", ids -\endcode +\include filters_ex25.py +Download this script \sa \ref tui_over_constrained_faces @@ -540,14 +333,8 @@ shape defined by threshold value: - functor type should be \a smesh.FT_BelongToGeom - threshold is geometrical object -\code -# create mesh -from SMESH_mechanic import * -# get all faces which nodes lie on the face sub_face3 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToGeom, sub_face3) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces which nodes lie on sub_face3:", len(ids) -\endcode +\include filters_ex26.py +Download this script \section filter_lying_on_geom Lying on Geom @@ -557,14 +344,8 @@ shape defined by threshold value: - functor type should be \a smesh.FT_LyingOnGeom - threshold is geometrical object -\code -# create mesh -from SMESH_mechanic import * -# get all faces at least one node of each lies on the face sub_face3 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_LyingOnGeom, sub_face3) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces at least one node of each lies on sub_face3:", len(ids) -\endcode +\include filters_ex27.py +Download this script \section filter_belong_to_plane Belong to Plane @@ -575,18 +356,8 @@ plane defined by threshold value with the given tolerance: - threshold is geometrical object (plane) - default tolerance is 1.0e-7 -\code -# create mesh -from SMESH_mechanic import * -# create plane -import geompy -plane_1 = geompy.MakePlane(p3,seg1,2000) -geompy.addToStudy(plane_1, "plane_1") -# get all nodes which lie on the plane \a plane_1 -filter = smesh.GetFilter(smesh.NODE, smesh.FT_BelongToPlane, plane_1) -ids = mesh.GetIdsFromFilter(filter) -print "Number of nodes which lie on the plane plane_1:", len(ids) -\endcode +\include filters_ex28.py +Download this script \section filter_belong_to_cylinder Belong to Cylinder @@ -597,14 +368,8 @@ cylindrical face defined by threshold value with the given tolerance: - threshold is geometrical object (cylindrical face) - default tolerance is 1.0e-7 -\code -# create mesh -from SMESH_mechanic import * -# get all faces which lie on the cylindrical face \a sub_face1 -filter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToCylinder, sub_face1) -ids = mesh.GetIdsFromFilter(filter) -print "Number of faces which lie on the cylindrical surface sub_face1:", len(ids) -\endcode +\include filters_ex29.py +Download this script \section filter_belong_to_surface Belong to Surface @@ -615,18 +380,8 @@ arbitrary surface defined by threshold value with the given tolerance: - threshold is geometrical object (arbitrary surface) - default tolerance is 1.0e-7 -\code -# create mesh -from SMESH_mechanic import * -# create b-spline -spline_1 = geompy.MakeInterpol([p4,p6,p3,p1]) -surface_1 = geompy.MakePrismVecH( spline_1, vz, 70.0 ) -geompy.addToStudy(surface_1, "surface_1") -# get all nodes which lie on the surface \a surface_1 -filter = smesh.GetFilter(smesh.NODE, smesh.FT_BelongToGenSurface, surface_1) -ids = mesh.GetIdsFromFilter(filter) -print "Number of nodes which lie on the surface surface_1:", len(ids) -\endcode +\include filters_ex30.py +Download this script \section filter_range_of_ids Range of IDs @@ -636,18 +391,8 @@ specified identifiers range: - functor type is \a smesh.FT_RangeOfIds - threshold is string listing required IDs and/or ranges of IDs, e.g."1,2,3,50-60,63,67,70-78" -\code -# create mesh -from SMESH_mechanic import * -# get nodes with identifiers [5-10] and [15-30] -criterion1 = smesh.GetCriterion(smesh.NODE, smesh.FT_RangeOfIds, Treshold="5-10",\ - BinaryOp=smesh.FT_LogicalOR) -criterion2 = smesh.GetCriterion(smesh.NODE, smesh.FT_RangeOfIds, Treshold="15-30") -filter = smesh.CreateFilterManager().CreateFilter() -filter.SetCriteria([criterion1,criterion2]) -ids = mesh.GetIdsFromFilter(filter) -print "Number of nodes in ranges [5-10] and [15-30]:", len(ids) -\endcode +\include filters_ex31.py +Download this script \section filter_bad_oriented_volume Badly oriented volume @@ -657,16 +402,8 @@ the point of view of MED convention. - functor type is \a smesh.FT_BadOrientedVolume - threshold is not required -\code -# create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() -# get all badly oriented volumes -filter = smesh.GetFilter(smesh.VOLUME, smesh.FT_BadOrientedVolume) -ids = mesh.GetIdsFromFilter(filter) -print "Number of badly oriented volumes:", len(ids) -\endcode +\include filters_ex32.py +Download this script \section filter_linear_or_quadratic Linear / quadratic @@ -677,23 +414,8 @@ Filter linear / quadratic mesh elements: - if unary operator is set to smesh.FT_LogicalNOT, the quadratic elements are selected, otherwise (by default) linear elements are selected -\code -# create mesh -from SMESH_mechanic import * -# get number of linear and quadratic edges -filter_linear = smesh.GetFilter(smesh.EDGE, smesh.FT_LinearOrQuadratic) -filter_quadratic = smesh.GetFilter(smesh.EDGE, smesh.FT_LinearOrQuadratic, smesh.FT_LogicalNOT) -ids_linear = mesh.GetIdsFromFilter(filter_linear) -ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic) -print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic) -# convert mesh to quadratic -print "Convert to quadratic..." -mesh.ConvertToQuadratic(True) -# get number of linear and quadratic edges -ids_linear = mesh.GetIdsFromFilter(filter_linear) -ids_quadratic = mesh.GetIdsFromFilter(filter_quadratic) -print "Number of linear edges:", len(ids_linear), "; number of quadratic edges:", len(ids_quadratic) -\endcode +\include filters_ex33.py +Download this script \section filter_group_color Group color @@ -702,20 +424,8 @@ Filter mesh entities, belonging to the group with the color defined by the thres - functor type is \a smesh.FT_GroupColor - threshold should be of SALOMEDS.Color type -\code -# create mesh -from SMESH_mechanic import * -# create group of edges -all_edges = mesh.GetElementsByType(smesh.EDGE) -grp = mesh.MakeGroupByIds("edges group", smesh.EDGE, all_edges[:len(all_edges)/4]) -import SALOMEDS -c = SALOMEDS.Color(0.1, 0.5, 1.0) -grp.SetColor(c) -# get number of the edges not belonging to the group with the given color -filter = smesh.GetFilter(smesh.EDGE, smesh.FT_GroupColor, c, smesh.FT_LogicalNOT) -ids = mesh.GetIdsFromFilter(filter) -print "Number of edges not beloging to the group with color (0.1, 0.5, 1.0):", len(ids) -\endcode +\include filters_ex34.py +Download this script \section filter_geom_type Geometry type @@ -726,25 +436,8 @@ entity type. - functor type should be \a smesh.FT_ElemGeomType - threshold is of smesh.GeometryType value -\code -# create mesh with volumes -from SMESH_mechanic import * -mesh.Tetrahedron() -mesh.Compute() -# get all triangles, quadrangles, tetrahedrons, pyramids -filter_tri = smesh.GetFilter(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_TRIANGLE) -filter_qua = smesh.GetFilter(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE) -filter_tet = smesh.GetFilter(smesh.VOLUME, smesh.FT_ElemGeomType, smesh.Geom_TETRA) -filter_pyr = smesh.GetFilter(smesh.VOLUME, smesh.FT_ElemGeomType, smesh.Geom_PYRAMID) -ids_tri = mesh.GetIdsFromFilter(filter_tri) -ids_qua = mesh.GetIdsFromFilter(filter_qua) -ids_tet = mesh.GetIdsFromFilter(filter_tet) -ids_pyr = mesh.GetIdsFromFilter(filter_pyr) -print "Number of triangles:", len(ids_tri) -print "Number of quadrangles:", len(ids_qua) -print "Number of tetrahedrons:", len(ids_tet) -print "Number of pyramids:", len(ids_pyr) -\endcode +\include filters_ex35.py +Download this script \section combining_filters How to combine filters with Criterion structures? @@ -752,19 +445,8 @@ Filters can be combined by making use of "criteria". Example : -\code -# create mesh -from SMESH_mechanic import * -# get all the quadrangle faces ... -criterion1 = smesh.GetCriterion(smesh.FACE, smesh.FT_ElemGeomType, smesh.Geom_QUADRANGLE, smesh.FT_LogicalAND) -# ... AND do NOT get those from sub_face3 -criterion2 = smesh.GetCriterion(smesh.FACE, smesh.FT_BelongToGeom, sub_face3, smesh.FT_LogicalNOT) -filter = smesh.CreateFilterManager().CreateFilter() -filter.SetCriteria([criterion1,criterion2]) -ids = mesh.GetIdsFromFilter(filter) - -myGroup = mesh.MakeGroupByIds("Quads_on_cylindrical_faces",smesh.FACE,ids) -\endcode +\include filters_ex36.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_generate_flat_elements.doc b/doc/salome/gui/SMESH/input/tui_generate_flat_elements.doc index eaf544556..36e13d304 100644 --- a/doc/salome/gui/SMESH/input/tui_generate_flat_elements.doc +++ b/doc/salome/gui/SMESH/input/tui_generate_flat_elements.doc @@ -17,66 +17,15 @@ by flat elements. \n This example represents an iron cable (a thin cylinder) in a concrete bloc (a big cylinder). The big cylinder is defined by two geometric volumes. -\code -import geompy -import smesh -import SMESH -# geometry - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Vertex_1 = geompy.MakeVertex(50, 0, 0) -Cylinder_1 = geompy.MakeCylinder(O, OX, 10, 500) -Cylinder_2 = geompy.MakeCylinder(Vertex_1, OX, 100, 400) -Vertex_2 = geompy.MakeVertex(-200, -200, -200) -Vertex_3 = geompy.MakeVertex(250, 200, 200) -Box_1 = geompy.MakeBoxTwoPnt(Vertex_2, Vertex_3) -Fuse_1 = geompy.MakeFuse(Cylinder_1, Cylinder_2) -Partition_1 = geompy.MakePartition([Fuse_1], [Cylinder_1, Box_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) -[Solid_1,Solid_2] = geompy.GetShapesOnShape(Cylinder_1, Partition_1, geompy.ShapeType["SOLID"], geompy.GEOM.ST_IN) -[Solid_3,Solid_4] = geompy.GetShapesOnShape(Cylinder_2, Partition_1, geompy.ShapeType["SOLID"], geompy.GEOM.ST_IN) -Vertex_4 = geompy.MakeVertex(450, 0, 0) -Vertex_5 = geompy.MakeVertex(500, 0, 0) -Vertex_6 = geompy.MakeVertex(550, 0, 0) -vec1 = geompy.MakeVector(Vertex_4, Vertex_5) -vec2 = geompy.MakeVector(Vertex_5, Vertex_6) -[Face_1] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec1, geompy.GEOM.ST_ON) -[Face_2] = geompy.GetShapesOnPlane(Partition_1, geompy.ShapeType["FACE"], vec2, geompy.GEOM.ST_ON) - -# meshing (we have linear tetrahedrons here, but other elements are OK) - -Mesh_1 = smesh.Mesh(Partition_1) -Regular_1D = Mesh_1.Segment() -Nb_Segments_1 = Regular_1D.NumberOfSegments(15) -MEFISTO_2D = Mesh_1.Triangle(algo=smesh.MEFISTO) -Length_From_Edges_2D = MEFISTO_2D.LengthFromEdges() -ALGO3D = Mesh_1.Tetrahedron() -isDone = Mesh_1.Compute() - -# relevant groups of volumes and faces - -Solid_1_1 = Mesh_1.GroupOnGeom(Solid_1,'Solid_1',SMESH.VOLUME) -Solid_2_1 = Mesh_1.GroupOnGeom(Solid_2,'Solid_2',SMESH.VOLUME) -Solid_3_1 = Mesh_1.GroupOnGeom(Solid_3,'Solid_3',SMESH.VOLUME) -Solid_4_1 = Mesh_1.GroupOnGeom(Solid_4,'Solid_4',SMESH.VOLUME) -Face_1_1 = Mesh_1.GroupOnGeom(Face_1,'Face_1',SMESH.FACE) -Face_2_1 = Mesh_1.GroupOnGeom(Face_2,'Face_2',SMESH.FACE) - -\endcode +\include generate_flat_elements.py +Download this script \n Here, the 4 groups of volumes [Solid_1_1, Solid_2_1, Solid_3_1, Solid_4_1] constitute a partition of the mesh. -The flat elements on group boundaries and on faces are built with the following code. +The flat elements on group boundaries and on faces are built with the +2 last lines of the code above. \n If the last argument (Boolean) in DoubleNodesOnGroupBoundaries is set to 1, the flat elements are built, otherwise, there is only a duplication of the nodes. -\code -Mesh_1.DoubleNodesOnGroupBoundaries([Solid_1_1, Solid_2_1, Solid_3_1, Solid_4_1], 1) - -Mesh_1.CreateFlatElementsOnFacesGroups([Face_1_1, Face_2_1]) -\endcode - \n To observe flat element groups, save the resulting mesh on a MED file and reload it. */ diff --git a/doc/salome/gui/SMESH/input/tui_grouping_elements.doc b/doc/salome/gui/SMESH/input/tui_grouping_elements.doc index 3b769060a..d3113ab2c 100644 --- a/doc/salome/gui/SMESH/input/tui_grouping_elements.doc +++ b/doc/salome/gui/SMESH/input/tui_grouping_elements.doc @@ -5,167 +5,29 @@
\anchor tui_create_standalone_group

Create a Standalone Group

- -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Get ids of all faces with area > 100 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# create a group consisting of faces with area > 100 -aGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds) - -# create a group that contains all nodes from the mesh -aGroup2 = mesh.CreateEmptyGroup(smesh.NODE, "all nodes") -aGroup2.AddFrom(mesh.mesh) - -salome.sg.updateObjBrowser(1) -\endcode +\include grouping_elements_ex01.py +Download this script \image html create_group.png
\anchor tui_create_group_on_geometry

Create a Group on Geometry

- -\code -import salome -import geompy -import smesh - -# create a box -box = geompy.MakeBox(0., 0., 0., 100., 100., 100.) -geompy.addToStudy(box, "box") - -# add the first face of the box to the study -subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -face = subShapeList[0] -geompy.addToStudyInFather(box, face, "face 1") - -# create group of edges on the face -aGeomGroupE = geompy.CreateGroup(face, geompy.ShapeType["EDGE"]) -geompy.AddObject(aGeomGroupE, 3) -geompy.AddObject(aGeomGroupE, 6) -geompy.AddObject(aGeomGroupE, 8) -geompy.AddObject(aGeomGroupE, 10) -geompy.addToStudyInFather(face, aGeomGroupE, "Group of Edges") - -# create quadrangle 2D mesh on the box -quadra = smesh.Mesh(box, "Box : quadrangle 2D mesh") -algo1D = quadra.Segment() -quadra.Quadrangle() -algo1D.NumberOfSegments(7) - -# compute the mesh -quadra.Compute() - -# create SMESH group on the face with name "SMESHGroup1" -aSmeshGroup1 = quadra.GroupOnGeom(face, "SMESHGroup1") - -# create SMESH group on with default name -aSmeshGroup2 = quadra.GroupOnGeom(aGeomGroupE) - -salome.sg.updateObjBrowser(1) -\endcode +\include grouping_elements_ex02.py +Download this script
\anchor tui_create_group_on_filter

Create a Group on Filter

- -\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -box = geompy.MakeBoxDXDYDZ(10,10,10) - -# make a mesh with quadrangles of different area in range [1,16] -mesh = Mesh(box,"Quad mesh") -hyp1D = mesh.Segment().StartEndLength( 1, 4 ) -mesh.Quadrangle() -mesh.Compute() - -# create a group on filter selecting faces of medium size -critaria = [ \ - GetCriterion(FACE, FT_Area, ">", 1.1, BinaryOp=FT_LogicalAND ), - GetCriterion(FACE, FT_Area, "<", 15.0 ) - ] -filt = GetFilterFromCriteria( critaria ) -filtGroup = mesh.GroupOnFilter( FACE, "group on filter", filt ) -print "Group on filter contains %s elemens" % filtGroup.Size() - -# group on filter is updated if the mesh is modified -hyp1D.SetStartLength( 2.5 ) -hyp1D.SetEndLength( 2.5 ) -mesh.Compute() -print "After mesh change, group on filter contains %s elemens" % filtGroup.Size() - -# set a new filter defining the group -filt2 = GetFilter( FACE, FT_RangeOfIds, "1-50" ) -filtGroup.SetFilter( filt2 ) -print "With a new filter, group on filter contains %s elemens" % filtGroup.Size() - -# group is updated at modification of the filter -filt2.SetCriteria( [ GetCriterion( FACE, FT_RangeOfIds, "1-70" )]) -filtIDs3 = filtGroup.GetIDs() -print "After filter modification, group on filter contains %s elemens" % filtGroup.Size() - -salome.sg.updateObjBrowser(1) -\endcode +\include grouping_elements_ex03.py +Download this script
\anchor tui_edit_group

Edit a Group

- -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Get ids of all faces with area > 35 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 35.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area > 35, Nb = ", len(anIds) - -# create a group by adding elements with area > 35 -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > 35") -aGroup.Add(anIds) - -# Get ids of all faces with area > 40 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 40.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area > 40, Nb = ", len(anIds) - -# create a group of elements with area [35; 40] by removing elements with area > 40 from group aGroup -aGroup.Remove(anIds) - -# print the result -aGroupElemIDs = aGroup.GetListOfID() - -print "Criterion: 35 < Area < 40, Nb = ", len(aGroupElemIDs) - -j = 1 -for i in range(len(aGroupElemIDs)): - if j > 20: j = 1; print "" - print aGroupElemIDs[i], - j = j + 1 - pass -print "" - -salome.sg.updateObjBrowser(1) -\endcode +\include grouping_elements_ex04.py +Download this script \image html editing_groups1.png @@ -174,59 +36,8 @@ salome.sg.updateObjBrowser(1)
\anchor tui_union_of_groups

Union of groups

- -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : AREA > 20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area > 20, Nb = ", len( anIds ) - -# create a group by adding elements with area > 20 -aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20") -aGroup1.Add(anIds) - -# Criterion : AREA = 20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_EqualTo, 20.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area = 20, Nb = ", len( anIds ) - -# create a group by adding elements with area = 20 -aGroup2 = mesh.CreateEmptyGroup( smesh.FACE, "Area = 20" ) - -aGroup2.Add(anIds) - -# create union group : area >= 20 -aGroup3 = mesh.UnionListOfGroups([aGroup1, aGroup2], "Area >= 20") -print "Criterion: Area >= 20, Nb = ", len(aGroup3.GetListOfID()) -# Please note that also there is UnionGroups() method which works with two groups only - -# Criterion : AREA < 20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 20.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area < 20, Nb = ", len(anIds) - -# create a group by adding elements with area < 20 -aGroup4 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 20") -aGroup4.Add(anIds) - -# create union group : area >= 20 and area < 20 -aGroup5 = mesh.UnionListOfGroups([aGroup3, aGroup4], "Any Area") -print "Criterion: Any Area, Nb = ", len(aGroup5.GetListOfID()) - -salome.sg.updateObjBrowser(1) -\endcode +\include grouping_elements_ex05.py +Download this script \image html union_groups1.png @@ -237,43 +48,8 @@ salome.sg.updateObjBrowser(1)
\anchor tui_intersection_of_groups

Intersection of groups

- -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : AREA > 20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area > 20, Nb = ", len(anIds) - -# create a group by adding elements with area > 20 -aGroup1 = mesh.CreateEmptyGroup(smesh.FACE, "Area > 20") -aGroup1.Add(anIds) - -# Criterion : AREA < 60 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area < 60, Nb = ", len(anIds) - -# create a group by adding elements with area < 60 -aGroup2 = mesh.CreateEmptyGroup(smesh.FACE, "Area < 60") -aGroup2.Add(anIds) - -# create an intersection of groups : 20 < area < 60 -aGroup3 = mesh.IntersectListOfGroups([aGroup1, aGroup2], "20 < Area < 60") -print "Criterion: 20 < Area < 60, Nb = ", len(aGroup3.GetListOfID()) -# Please note that also there is IntersectGroups() method which works with two groups only - -salome.sg.updateObjBrowser(1) -\endcode +\include grouping_elements_ex06.py +Download this script \image html intersect_groups1.png @@ -284,41 +60,8 @@ salome.sg.updateObjBrowser(1)
\anchor tui_cut_of_groups

Cut of groups

- -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : AREA > 20 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 20.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area > 20, Nb = ", len(anIds) - -# create a group by adding elements with area > 20 -aGroupMain = mesh.MakeGroupByIds("Area > 20", smesh.FACE, anIds) - -# Criterion : AREA < 60 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 60.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area < 60, Nb = ", len(anIds) - -# create a group by adding elements with area < 60 -aGroupTool = mesh.MakeGroupByIds("Area < 60", smesh.FACE, anIds) - -# create a cut of groups : area >= 60 -aGroupRes = mesh.CutGroups(aGroupMain, aGroupTool, "Area >= 60") -print "Criterion: Area >= 60, Nb = ", len(aGroupRes.GetListOfID()) -# Please note that also there is CutListOfGroups() method which works with lists of groups of any lengths - -salome.sg.updateObjBrowser(1) -\endcode +\include grouping_elements_ex07.py +Download this script \image html cut_groups1.png @@ -329,42 +72,8 @@ salome.sg.updateObjBrowser(1)
\anchor tui_create_dim_group

Creating groups of entities from existing groups of superior dimensions

- -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : AREA > 100 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area > 100, Nb = ", len(anIds) - -# create a group by adding elements with area > 100 -aSrcGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds) - -# Criterion : AREA < 30 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, 30.) - -anIds = mesh.GetIdsFromFilter(aFilter) - -print "Criterion: Area < 30, Nb = ", len(anIds) - -# create a group by adding elements with area < 30 -aSrcGroup2 = mesh.MakeGroupByIds("Area < 30", smesh.FACE, anIds) - -# Create group of edges using source groups of faces -aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.EDGE, "Edges" ) - -# Create group of nodes using source groups of faces -aGrp = mesh.CreateDimGroup( [aSrcGroup1, aSrcGroup2], smesh.NODE, "Nodes" ) - -salome.sg.updateObjBrowser(1) -\endcode +\include grouping_elements_ex08.py +Download this script \image html dimgroup_tui1.png
Source groups of faces
diff --git a/doc/salome/gui/SMESH/input/tui_measurements.doc b/doc/salome/gui/SMESH/input/tui_measurements.doc index aabf0b317..8ca283fc3 100644 --- a/doc/salome/gui/SMESH/input/tui_measurements.doc +++ b/doc/salome/gui/SMESH/input/tui_measurements.doc @@ -3,82 +3,11 @@ \page tui_measurements_page Measurements \section tui_min_distance Minimum Distance - -\code - -import smesh -from SMESH_mechanic import mesh as mesh1 -from SMESH_test1 import mesh as mesh2 - -mesh1.Compute() -mesh2.Compute() - -# compute min distance from mesh1 to the origin (not available yet) -smesh.MinDistance(mesh1) - -# compute min distance from node 10 of mesh1 to the origin -smesh.MinDistance(mesh1, id1=10) -# ... or -mesh1.MinDistance(10) - -# compute min distance between nodes 10 and 20 of mesh1 -smesh.MinDistance(mesh1, id1=10, id2=20) -# ... or -mesh1.MinDistance(10, 20) - -# compute min distance from element 100 of mesh1 to the origin (not available yet) -smesh.MinDistance(mesh1, id1=100, isElem1=True) -# ... or -mesh1.MinDistance(100, isElem1=True) - -# compute min distance between elements 100 and 200 of mesh1 (not available yet) -smesh.MinDistance(mesh1, id1=100, id2=200, isElem1=True, isElem2=True) -# ... or -mesh1.MinDistance(100, 200, True, True) - -# compute min distance from element 100 to node 20 of mesh1 (not available yet) -smesh.MinDistance(mesh1, id1=100, id2=20, isElem1=True) -# ... or -mesh1.MinDistance(100, 20, True) - -# compute min distance from mesh1 to mesh2 (not available yet) -smesh.MinDistance(mesh1, mesh2) - -# compute min distance from node 10 of mesh1 to node 20 of mesh2 -smesh.MinDistance(mesh1, mesh2, 10, 20) - -# compute min distance from node 10 of mesh1 to element 200 of mesh2 (not available yet) -smesh.MinDistance(mesh1, mesh2, 10, 200, isElem2=True) - -# etc... - -\endcode +\include measurements_ex01.py +Download this script \section tui_bounding_box Bounding Box - -\code - -import smesh -from SMESH_mechanic import mesh as mesh1 -from SMESH_test1 import mesh as mesh2 - -mesh1.Compute() -mesh2.Compute() - -# compute bounding box for mesh1 -mesh1.BoundingBox() - -# compute bounding box for list of nodes of mesh1 -mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381]) - -# compute bounding box for list of elements of mesh1 -mesh1.BoundingBox([363, 364, 370, 371, 372, 373, 379, 380, 381], isElem=True) - -# compute common bounding box of mesh1 and mesh2 -smesh.BoundingBox([mesh1, mesh2]) - -# etc... - -\endcode +\include measurements_ex02.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc b/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc index 977ff6e86..e7844327c 100644 --- a/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc +++ b/doc/salome/gui/SMESH/input/tui_modifying_meshes.doc @@ -9,291 +9,62 @@
\anchor tui_add_node

Add Node

- -\code -import smesh - -mesh = smesh.Mesh() - -# add node -new_id = mesh.AddNode(50, 10, 0) -print "" -if new_id == 0: print "KO node addition." -else: print "New Node has been added with ID ", new_id -\endcode +\include modifying_meshes_ex01.py +Download this script
\anchor tui_add_0DElement

Add 0D Element

- -\code -import smesh - -mesh = smesh.Mesh() - -# add node -node_id = mesh.AddNode(50, 10, 0) - -# add 0D Element -new_id = mesh.Add0DElement(node_id) - -print "" -if new_id == 0: print "KO node addition." -else: print "New 0D Element has been added with ID ", new_id -\endcode +\include modifying_meshes_ex02.py +Download this script
\anchor tui_add_0DElement_on_all_nodes

Add 0D Element on Element Nodes

- -\code -import smesh, SMESH, geompy - -# create a geometry -box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) -face = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] - -# make 3D mesh -mesh = smesh.Mesh( box ) -mesh.AutomaticHexahedralization(0) - -# create 0D elements on all nodes of the mesh -res = mesh.Add0DElementsToAllNodes( mesh ) - -# find 0D elements on all nodes of the mesh, all found nodes are added to a new group -groupName = "0Dmesh" -res = mesh.Add0DElementsToAllNodes( mesh, groupName ) -mesh.RemoveGroupWithContents( res ) # remove all found 0D elements - -# create 0D elements on all nodes of a sub-mesh, with group creation -groupName = "0Dsubmesh" -submesh = mesh.GetSubMesh( face, "faceSM") -res = mesh.Add0DElementsToAllNodes( submesh, groupName ) - -# create 0D elements on all nodes of a group -group = mesh.Group( face, "faceGroup" ) -res = mesh.Add0DElementsToAllNodes( group ) - -# remove all 0D elements -mesh.RemoveElements( mesh.GetIdsFromFilter( smesh.GetFilter( SMESH.ELEM0D, - SMESH.FT_ElemGeomType, - "=",SMESH.Geom_POINT ))) - -# create 0D elements on all nodes of some elements -res = mesh.Add0DElementsToAllNodes( mesh.GetElementsId() ) - -mesh.RemoveElements( mesh.GetElementsByType( SMESH.ELEM0D )) - -# create 0D elements on some nodes -nodes = range(1,10) -res = mesh.Add0DElementsToAllNodes( mesh.GetIDSource( nodes, SMESH.NODE )) - -\endcode +\include modifying_meshes_ex03.py +Download this script
\anchor tui_add_edge

Add Edge

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print "" - -# add node -n1 = mesh.AddNode(50, 10, 0) -if n1 == 0: print "KO node addition." - -# add edge -e1 = mesh.AddEdge([n1, 38]) -if e1 == 0: print "KO edge addition." -else: print "New Edge has been added with ID ", e1 -\endcode +\include modifying_meshes_ex04.py +Download this script
\anchor tui_add_triangle

Add Triangle

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print "" - -# add node -n1 = mesh.AddNode(50, 10, 0) -if n1 == 0: print "KO node addition." - -# add triangle -t1 = mesh.AddFace([n1, 38, 39]) -if t1 == 0: print "KO triangle addition." -else: print "New Triangle has been added with ID ", t1 -\endcode +\include modifying_meshes_ex05.py +Download this script
\anchor tui_add_quadrangle

Add Quadrangle

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print "" - -# add node -n1 = mesh.AddNode(50, 10, 0) -if n1 == 0: print "KO node addition." - -n2 = mesh.AddNode(40, 20, 0) -if n2 == 0: print "KO node addition." - -# add quadrangle -q1 = mesh.AddFace([n2, n1, 38, 39]) -if q1 == 0: print "KO quadrangle addition." -else: print "New Quadrangle has been added with ID ", q1 -\endcode +\include modifying_meshes_ex06.py +Download this script
\anchor tui_add_tetrahedron

Add Tetrahedron

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print "" - -# add node -n1 = mesh.AddNode(50, 10, 0) -if n1 == 0: print "KO node addition." - -# add tetrahedron -t1 = mesh.AddVolume([n1, 38, 39, 246]) -if t1 == 0: print "KO tetrahedron addition." -else: print "New Tetrahedron has been added with ID ", t1 -\endcode +\include modifying_meshes_ex07.py +Download this script
\anchor tui_add_hexahedron

Add Hexahedron

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -print "" - -# add nodes -nId1 = mesh.AddNode(50, 10, 0) -nId2 = mesh.AddNode(47, 12, 0) -nId3 = mesh.AddNode(50, 10, 10) -nId4 = mesh.AddNode(47, 12, 10) - -if nId1 == 0 or nId2 == 0 or nId3 == 0 or nId4 == 0: print "KO node addition." - -# add hexahedron -vId = mesh.AddVolume([nId2, nId1, 38, 39, nId4, nId3, 245, 246]) -if vId == 0: print "KO Hexahedron addition." -else: print "New Hexahedron has been added with ID ", vId -\endcode +\include modifying_meshes_ex08.py +Download this script
\anchor tui_add_polygon

Add Polygon

- -\code -import math -import salome - -import smesh - -# create an empty mesh structure -mesh = smesh.Mesh() - -# a method to build a polygonal mesh element with angles: -def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert): - al = 2.0 * math.pi / nb_vert - node_ids = [] - - # Create nodes for a polygon - for ii in range(nb_vert): - nid = mesh.AddNode(x0 + radius * math.cos(ii*al), - y0 + radius * math.sin(ii*al), - z0) - node_ids.append(nid) - pass - - # Create a polygon - return mesh.AddPolygonalFace(node_ids) - -# Create three polygons -f1 = MakePolygon(mesh, 0, 0, 0, 30, 13) -f2 = MakePolygon(mesh, 0, 0, 10, 21, 9) -f3 = MakePolygon(mesh, 0, 0, 20, 13, 6) - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex09.py +Download this script
\anchor tui_add_polyhedron

Add Polyhedron

- -\code -import salome -import math - -# create an empty mesh structure -mesh = smesh.Mesh() - -# Create nodes for 12-hedron with pentagonal faces -al = 2 * math.pi / 5.0 -cosal = math.cos(al) -aa = 13 -rr = aa / (2.0 * math.sin(al/2.0)) -dr = 2.0 * rr * cosal -r1 = rr + dr -dh = rr * math.sqrt(2.0 * (1.0 - cosal * (1.0 + 2.0 * cosal))) -hh = 2.0 * dh - dr * (rr*(cosal - 1) + (rr + dr)*(math.cos(al/2) - 1)) / dh - -dd = [] # top -cc = [] # below top -bb = [] # above bottom -aa = [] # bottom - -for i in range(5): - cos_bot = math.cos(i*al) - sin_bot = math.sin(i*al) - - cos_top = math.cos(i*al + al/2.0) - sin_top = math.sin(i*al + al/2.0) - - nd = mesh.AddNode(rr * cos_top, rr * sin_top, hh ) # top - nc = mesh.AddNode(r1 * cos_top, r1 * sin_top, hh - dh) # below top - nb = mesh.AddNode(r1 * cos_bot, r1 * sin_bot, dh) # above bottom - na = mesh.AddNode(rr * cos_bot, rr * sin_bot, 0) # bottom - dd.append(nd) # top - cc.append(nc) # below top - bb.append(nb) # above bottom - aa.append(na) # bottom - pass - -# Create a polyhedral volume (12-hedron with pentagonal faces) -MeshEditor.AddPolyhedralVolume([dd[0], dd[1], dd[2], dd[3], dd[4], # top - dd[0], cc[0], bb[1], cc[1], dd[1], # - - dd[1], cc[1], bb[2], cc[2], dd[2], # - - dd[2], cc[2], bb[3], cc[3], dd[3], # - below top - dd[3], cc[3], bb[4], cc[4], dd[4], # - - dd[4], cc[4], bb[0], cc[0], dd[0], # - - aa[4], bb[4], cc[4], bb[0], aa[0], # . - aa[3], bb[3], cc[3], bb[4], aa[4], # . - aa[2], bb[2], cc[2], bb[3], aa[3], # . above bottom - aa[1], bb[1], cc[1], bb[2], aa[2], # . - aa[0], bb[0], cc[0], bb[1], aa[1], # . - aa[0], aa[1], aa[2], aa[3], aa[4]], # bottom - [5,5,5,5,5,5,5,5,5,5,5,5]) - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex10.py +Download this script
\anchor tui_removing_nodes_and_elements @@ -302,718 +73,97 @@ salome.sg.updateObjBrowser(1)
\anchor tui_removing_nodes

Removing Nodes

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh - -# remove nodes #246 and #255 -res = mesh.RemoveNodes([246, 255]) -if res == 1: print "Nodes removing is OK!" -else: print "KO nodes removing." -\endcode +\include modifying_meshes_ex11.py +Download this script
\anchor tui_removing_elements

Removing Elements

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh - -# remove three elements: #850, #859 and #814 -res = mesh.RemoveElements([850, 859, 814]) -if res == 1: print "Elements removing is OK!" -else: print "KO Elements removing." -\endcode +\include modifying_meshes_ex12.py +Download this script
\anchor tui_removing_orphan_nodes

Removing Orphan Nodes

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh - -# add orphan nodes -mesh.AddNode(0,0,0) -mesh.AddNode(1,1,1) -# remove just created orphan nodes -res = mesh.RemoveOrphanNodes() -if res == 1: print "Removed %d nodes!" % res -else: print "KO nodes removing." -\endcode +\include modifying_meshes_ex13.py +Download this script
\anchor tui_renumbering_nodes_and_elements

Renumbering Nodes and Elements

- -\code -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh - -mesh.RenumberNodes() - -mesh.RenumberElements() -\endcode +\include modifying_meshes_ex14.py +Download this script
\anchor tui_moving_nodes

Moving Nodes

- -\code -from geompy import * -from smesh import * - -box = MakeBoxDXDYDZ(200, 200, 200) - -mesh = Mesh( box ) -mesh.Segment().AutomaticLength(0.1) -mesh.Quadrangle() -mesh.Compute() - -# find node at (0,0,0) -node000 = None -for vId in SubShapeAllIDs( box, ShapeType["VERTEX"]): - if node000: break - nodeIds = mesh.GetSubMeshNodesId( vId, True ) - for node in nodeIds: - xyz = mesh.GetNodeXYZ( node ) - if xyz[0] == 0 and xyz[1] == 0 and xyz[2] == 0 : - node000 = node - pass - pass - pass - -if not node000: - raise "node000 not found" - -# find node000 using the tested function -n = mesh.FindNodeClosestTo( -1,-1,-1 ) -if not n == node000: - raise "FindNodeClosestTo() returns " + str( n ) + " != " + str( node000 ) - -# move node000 to a new location -x,y,z = -10, -10, -10 -n = mesh.MoveNode( n,x,y,z ) -if not n: - raise "MoveNode() returns " + n - -# check the coordinates of the node000 -xyz = mesh.GetNodeXYZ( node000 ) -if not ( xyz[0] == x and xyz[1] == y and xyz[2] == z) : - raise "Wrong coordinates: " + str( xyz ) + " != " + str( [x,y,z] ) -\endcode +\include modifying_meshes_ex15.py +Download this script
\anchor tui_diagonal_inversion

Diagonal Inversion

- -\code -import salome -import smesh - -# create an empty mesh structure -mesh = smesh.Mesh() - -# create the following mesh: -# .----.----.----. -# | /| /| /| -# | / | / | / | -# | / | / | / | -# |/ |/ |/ | -# .----.----.----. - -bb = [0, 0, 0, 0] -tt = [0, 0, 0, 0] -ff = [0, 0, 0, 0, 0, 0] - -bb[0] = mesh.AddNode( 0., 0., 0.) -bb[1] = mesh.AddNode(10., 0., 0.) -bb[2] = mesh.AddNode(20., 0., 0.) -bb[3] = mesh.AddNode(30., 0., 0.) - -tt[0] = mesh.AddNode( 0., 15., 0.) -tt[1] = mesh.AddNode(10., 15., 0.) -tt[2] = mesh.AddNode(20., 15., 0.) -tt[3] = mesh.AddNode(30., 15., 0.) - -ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]]) -ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]]) -ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]]) -ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]]) -ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]]) -ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]]) - -# inverse the diagonal bb[1] - tt[2] -print "\nDiagonal inversion ... ", -res = mesh.InverseDiag(bb[1], tt[2]) -if not res: print "failed!" -else: print "done." - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex16.py +Download this script
\anchor tui_uniting_two_triangles

Uniting two Triangles

- -\code -import salome -import smesh - -# create an empty mesh structure -mesh = smesh.Mesh() - -# create the following mesh: -# .----.----.----. -# | /| /| /| -# | / | / | / | -# | / | / | / | -# |/ |/ |/ | -# .----.----.----. - -bb = [0, 0, 0, 0] -tt = [0, 0, 0, 0] -ff = [0, 0, 0, 0, 0, 0] - -bb[0] = mesh.AddNode( 0., 0., 0.) -bb[1] = mesh.AddNode(10., 0., 0.) -bb[2] = mesh.AddNode(20., 0., 0.) -bb[3] = mesh.AddNode(30., 0., 0.) - -tt[0] = mesh.AddNode( 0., 15., 0.) -tt[1] = mesh.AddNode(10., 15., 0.) -tt[2] = mesh.AddNode(20., 15., 0.) -tt[3] = mesh.AddNode(30., 15., 0.) - -ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]]) -ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]]) -ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]]) -ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]]) -ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]]) -ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]]) - -# delete the diagonal bb[1] - tt[2] -print "\nUnite two triangles ... ", -res = mesh.DeleteDiag(bb[1], tt[2]) -if not res: print "failed!" -else: print "done." - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex17.py +Download this script
\anchor tui_uniting_set_of_triangles

Uniting a Set of Triangles

- -\code -import salome -import smesh - -# create an empty mesh structure -mesh = smesh.Mesh() - -# create the following mesh: -# .----.----.----. -# | /| /| /| -# | / | / | / | -# | / | / | / | -# |/ |/ |/ | -# .----.----.----. - -bb = [0, 0, 0, 0] -tt = [0, 0, 0, 0] -ff = [0, 0, 0, 0, 0, 0] - -bb[0] = mesh.AddNode( 0., 0., 0.) -bb[1] = mesh.AddNode(10., 0., 0.) -bb[2] = mesh.AddNode(20., 0., 0.) -bb[3] = mesh.AddNode(30., 0., 0.) - -tt[0] = mesh.AddNode( 0., 15., 0.) -tt[1] = mesh.AddNode(10., 15., 0.) -tt[2] = mesh.AddNode(20., 15., 0.) -tt[3] = mesh.AddNode(30., 15., 0.) - -ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]]) -ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]]) -ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]]) -ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]]) -ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]]) -ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]]) - -# unite a set of triangles -print "\nUnite a set of triangles ... ", -res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], smesh.FT_MinimumAngle, 60.) -if not res: print "failed!" -else: print "done." - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex18.py +Download this script
\anchor tui_orientation

Orientation

- -\code -import salome -import smesh - -# create an empty mesh structure -mesh = smesh.Mesh() - -# build five quadrangles: -dx = 10 -dy = 20 - -n1 = mesh.AddNode(0.0 * dx, 0, 0) -n2 = mesh.AddNode(1.0 * dx, 0, 0) -n3 = mesh.AddNode(2.0 * dx, 0, 0) -n4 = mesh.AddNode(3.0 * dx, 0, 0) -n5 = mesh.AddNode(4.0 * dx, 0, 0) -n6 = mesh.AddNode(5.0 * dx, 0, 0) -n7 = mesh.AddNode(0.0 * dx, dy, 0) -n8 = mesh.AddNode(1.0 * dx, dy, 0) -n9 = mesh.AddNode(2.0 * dx, dy, 0) -n10 = mesh.AddNode(3.0 * dx, dy, 0) -n11 = mesh.AddNode(4.0 * dx, dy, 0) -n12 = mesh.AddNode(5.0 * dx, dy, 0) - -f1 = mesh.AddFace([n1, n2, n8 , n7 ]) -f2 = mesh.AddFace([n2, n3, n9 , n8 ]) -f3 = mesh.AddFace([n3, n4, n10, n9 ]) -f4 = mesh.AddFace([n4, n5, n11, n10]) -f5 = mesh.AddFace([n5, n6, n12, n11]) - -# Change the orientation of the second and the fourth faces. -mesh.Reorient([2, 4]) - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex19.py +Download this script
\anchor tui_cutting_quadrangles

Cutting Quadrangles

- -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh - -# cut two quadrangles: 405 and 406 -mesh.QuadToTri([405, 406], smesh.FT_MinimumAngle) -\endcode +\include modifying_meshes_ex20.py +Download this script
\anchor tui_smoothing

Smoothing

- -\code -import salome -import geompy - -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh - -# select the top face -faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, geompy.ShapeType["FACE"]) -face = faces[3] -geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face planar with hole") - -# create a group of faces to be smoothed -GroupSmooth = mesh.GroupOnGeom(face, "Group of faces (smooth)", smesh.FACE) - -# perform smoothing - -# boolean SmoothObject(Object, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method) -res = mesh.SmoothObject(GroupSmooth, [], 20, 2., smesh.CENTROIDAL_SMOOTH) -print "\nSmoothing ... ", -if not res: print "failed!" -else: print "done." - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex21.py +Download this script
\anchor tui_extrusion

Extrusion

- -\code -import salome -import geompy - -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh - -# select the top face -faces = geompy.SubShapeAllSorted(SMESH_mechanic.shape_mesh, geompy.ShapeType["FACE"]) -face = faces[7] -geompy.addToStudyInFather(SMESH_mechanic.shape_mesh, face, "face circular top") - -# create a vector for extrusion -point = smesh.PointStruct(0., 0., 5.) -vector = smesh.DirStruct(point) - -# create a group to be extruded -GroupTri = mesh.GroupOnGeom(face, "Group of faces (extrusion)", smesh.FACE) - -# perform extrusion of the group -mesh.ExtrusionSweepObject(GroupTri, vector, 5) - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex22.py +Download this script
\anchor tui_extrusion_along_path

Extrusion along a Path

- -\code -import math -import salome - -# Geometry -import geompy - -# 1. Create points -points = [[0, 0], [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]] - -iv = 1 -vertices = [] -for point in points: - vert = geompy.MakeVertex(point[0], point[1], 0) - geompy.addToStudy(vert, "Vertex_" + `iv`) - vertices.append(vert) - iv += 1 - pass - -# 2. Create edges and wires -Edge_straight = geompy.MakeEdge(vertices[0], vertices[4]) -Edge_bezierrr = geompy.MakeBezier(vertices) -Wire_polyline = geompy.MakePolyline(vertices) -Edge_Circle = geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2]) - -geompy.addToStudy(Edge_straight, "Edge_straight") -geompy.addToStudy(Edge_bezierrr, "Edge_bezierrr") -geompy.addToStudy(Wire_polyline, "Wire_polyline") -geompy.addToStudy(Edge_Circle , "Edge_Circle") - -# 3. Explode wire on edges, as they will be used for mesh extrusion -Wire_polyline_edges = geompy.SubShapeAll(Wire_polyline, geompy.ShapeType["EDGE"]) -for ii in range(len(Wire_polyline_edges)): - geompy.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii], "Edge_" + `ii + 1`) - pass - -# Mesh -import smesh - -# Mesh the given shape with the given 1d hypothesis -def Mesh1D(shape1d, nbSeg, name): - mesh1d_tool = smesh.Mesh(shape1d, name) - algo = mesh1d_tool.Segment() - hyp = algo.NumberOfSegments(nbSeg) - isDone = mesh1d_tool.Compute() - if not isDone: print 'Mesh ', name, ': computation failed' - return mesh1d_tool - -# Create a mesh with six nodes, seven edges and two quadrangle faces -def MakeQuadMesh2(mesh_name): - quad_1 = smesh.Mesh(name = mesh_name) - - # six nodes - n1 = quad_1.AddNode(0, 20, 10) - n2 = quad_1.AddNode(0, 40, 10) - n3 = quad_1.AddNode(0, 40, 30) - n4 = quad_1.AddNode(0, 20, 30) - n5 = quad_1.AddNode(0, 0, 30) - n6 = quad_1.AddNode(0, 0, 10) - - # seven edges - quad_1.AddEdge([n1, n2]) # 1 - quad_1.AddEdge([n2, n3]) # 2 - quad_1.AddEdge([n3, n4]) # 3 - quad_1.AddEdge([n4, n1]) # 4 - quad_1.AddEdge([n4, n5]) # 5 - quad_1.AddEdge([n5, n6]) # 6 - quad_1.AddEdge([n6, n1]) # 7 - - # two quadrangle faces - quad_1.AddFace([n1, n2, n3, n4]) # 8 - quad_1.AddFace([n1, n4, n5, n6]) # 9 - return [quad_1, [1,2,3,4,5,6,7], [8,9]] - -# Path meshes -Edge_straight_mesh = Mesh1D(Edge_straight, 7, "Edge_straight") -Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7, "Edge_bezierrr") -Wire_polyline_mesh = Mesh1D(Wire_polyline, 3, "Wire_polyline") -Edge_Circle_mesh = Mesh1D(Edge_Circle , 8, "Edge_Circle") - -# Initial meshes (to be extruded) -[quad_1, ee_1, ff_1] = MakeQuadMesh2("quad_1") -[quad_2, ee_2, ff_2] = MakeQuadMesh2("quad_2") -[quad_3, ee_3, ff_3] = MakeQuadMesh2("quad_3") -[quad_4, ee_4, ff_4] = MakeQuadMesh2("quad_4") -[quad_5, ee_5, ff_5] = MakeQuadMesh2("quad_5") -[quad_6, ee_6, ff_6] = MakeQuadMesh2("quad_6") -[quad_7, ee_7, ff_7] = MakeQuadMesh2("quad_7") - -# ExtrusionAlongPath -# IDsOfElements, PathMesh, PathShape, NodeStart, -# HasAngles, Angles, HasRefPoint, RefPoint -refPoint = smesh.PointStruct(0, 0, 0) -a10 = 10.0*math.pi/180.0 -a45 = 45.0*math.pi/180.0 - -# 1. Extrusion of two mesh edges along a straight path -error = quad_1.ExtrusionAlongPath([1,2], Edge_straight_mesh, Edge_straight, 1, - 0, [], 0, refPoint) - -# 2. Extrusion of one mesh edge along a curved path -error = quad_2.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1, - 0, [], 0, refPoint) - -# 3. Extrusion of one mesh edge along a curved path with usage of angles -error = quad_3.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1, - 1, [a45, a45, a45, 0, -a45, -a45, -a45], 0, refPoint) - -# 4. Extrusion of one mesh edge along the path, which is a part of a meshed wire -error = quad_4.ExtrusionAlongPath([4], Wire_polyline_mesh, Wire_polyline_edges[0], 1, - 1, [a10, a10, a10], 0, refPoint) - -# 5. Extrusion of two mesh faces along the path, which is a part of a meshed wire -error = quad_5.ExtrusionAlongPath(ff_5 , Wire_polyline_mesh, Wire_polyline_edges[2], 4, - 0, [], 0, refPoint) - -# 6. Extrusion of two mesh faces along a closed path -error = quad_6.ExtrusionAlongPath(ff_6 , Edge_Circle_mesh, Edge_Circle, 1, - 0, [], 0, refPoint) - -# 7. Extrusion of two mesh faces along a closed path with usage of angles -error = quad_7.ExtrusionAlongPath(ff_7, Edge_Circle_mesh, Edge_Circle, 1, - 1, [a45, -a45, a45, -a45, a45, -a45, a45, -a45], 0, refPoint) - -salome.sg.updateObjBrowser(1) -\endcode +\include modifying_meshes_ex23.py +Download this script
\anchor tui_revolution

Revolution

- -\code -import math -import SMESH - -import SMESH_mechanic - -mesh = SMESH_mechanic.mesh -smesh = SMESH_mechanic.smesh - -# create a group of faces to be revolved -FacesRotate = [492, 493, 502, 503] -GroupRotate = mesh.CreateEmptyGroup(SMESH.FACE,"Group of faces (rotate)") -GroupRotate.Add(FacesRotate) - -# define revolution angle and axis -angle45 = 45 * math.pi / 180 -axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -23.321, -13.3402, -13.3265, 6.66632) - -# perform revolution of an object -mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5) -\endcode +\include modifying_meshes_ex24.py +Download this script
\anchor tui_pattern_mapping

Pattern Mapping

- -\code -import geompy -import smesh - -# define the geometry -Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.) -geompy.addToStudy(Box_1, "Box_1") - -faces = geompy.SubShapeAll(Box_1, geompy.ShapeType["FACE"]) -Face_1 = faces[0] -Face_2 = faces[1] - -geompy.addToStudyInFather(Box_1, Face_1, "Face_1") -geompy.addToStudyInFather(Box_1, Face_2, "Face_2") - -# build a quadrangle mesh 3x3 on Face_1 -Mesh_1 = smesh.Mesh(Face_1) -algo1D = Mesh_1.Segment() -algo1D.NumberOfSegments(3) -Mesh_1.Quadrangle() - -isDone = Mesh_1.Compute() -if not isDone: print 'Mesh Mesh_1 : computation failed' - -# build a triangle mesh on Face_2 -Mesh_2 = smesh.Mesh(Face_2) - -algo1D = Mesh_2.Segment() -algo1D.NumberOfSegments(1) -algo2D = Mesh_2.Triangle() -algo2D.MaxElementArea(240) - -isDone = Mesh_2.Compute() -if not isDone: print 'Mesh Mesh_2 : computation failed' - -# create a 2d pattern -pattern = smesh.GetPattern() - -isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0) -if (isDone != 1): print 'LoadFromFace :', pattern.GetErrorCode() - -# apply the pattern to a face of the first mesh -facesToSplit = Mesh_1.GetElementsByType(smesh.SMESH.FACE) -print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit)) -pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0) -isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0) -if (isDone != 1): print 'MakeMesh :', pattern.GetErrorCode() - -# create quadrangle mesh -Mesh_3 = smesh.Mesh(Box_1) -Mesh_3.Segment().NumberOfSegments(1) -Mesh_3.Quadrangle() -Mesh_3.Hexahedron() -isDone = Mesh_3.Compute() -if not isDone: print 'Mesh Mesh_3 : computation failed' - -# create a 3d pattern (hexahedrons) -pattern_hexa = smesh.GetPattern() - -smp_hexa = """!!! Nb of points: -15 - 0 0 0 !- 0 - 1 0 0 !- 1 - 0 1 0 !- 2 - 1 1 0 !- 3 - 0 0 1 !- 4 - 1 0 1 !- 5 - 0 1 1 !- 6 - 1 1 1 !- 7 - 0.5 0 0.5 !- 8 - 0.5 0 1 !- 9 - 0.5 0.5 0.5 !- 10 - 0.5 0.5 1 !- 11 - 1 0 0.5 !- 12 - 1 0.5 0.5 !- 13 - 1 0.5 1 !- 14 - !!! Indices of points of 4 elements: - 8 12 5 9 10 13 14 11 - 0 8 9 4 2 10 11 6 - 2 10 11 6 3 13 14 7 - 0 1 12 8 2 3 13 10""" - -pattern_hexa.LoadFromFile(smp_hexa) - -# apply the pattern to a mesh -volsToSplit = Mesh_3.GetElementsByType(smesh.SMESH.VOLUME) -print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit)) -pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3) -isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(), True, True) -if (isDone != 1): print 'MakeMesh :', pattern_hexa.GetErrorCode() - -# create one more quadrangle mesh -Mesh_4 = smesh.Mesh(Box_1) -Mesh_4.Segment().NumberOfSegments(1) -Mesh_4.Quadrangle() -Mesh_4.Hexahedron() -isDone = Mesh_4.Compute() -if not isDone: print 'Mesh Mesh_4 : computation failed' - -# create another 3d pattern (pyramids) -pattern_pyra = smesh.GetPattern() - -smp_pyra = """!!! Nb of points: -9 - 0 0 0 !- 0 - 1 0 0 !- 1 - 0 1 0 !- 2 - 1 1 0 !- 3 - 0 0 1 !- 4 - 1 0 1 !- 5 - 0 1 1 !- 6 - 1 1 1 !- 7 - 0.5 0.5 0.5 !- 8 - !!! Indices of points of 6 elements: - 0 1 5 4 8 - 7 5 1 3 8 - 3 2 6 7 8 - 2 0 4 6 8 - 0 2 3 1 8 - 4 5 7 6 8""" - -pattern_pyra.LoadFromFile(smp_pyra) - -# apply the pattern to a face mesh -volsToSplit = Mesh_4.GetElementsByType(smesh.SMESH.VOLUME) -print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit)) -pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0) -isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(), True, True) -if (isDone != 1): print 'MakeMesh :', pattern_pyra.GetErrorCode() -\endcode +\include modifying_meshes_ex25.py +Download this script
\anchor tui_quadratic

Convert mesh to/from quadratic

- -\code -import geompy -import smesh - -# create sphere of radius 100 - -Sphere = geompy.MakeSphereR( 100 ) -geompy.addToStudy( Sphere, "Sphere" ) - -# create simple trihedral mesh - -Mesh = smesh.Mesh(Sphere) -Regular_1D = Mesh.Segment() -Nb_Segments = Regular_1D.NumberOfSegments(5) -MEFISTO_2D = Mesh.Triangle() -Tetrahedron = Mesh.Tetrahedron() - -# compute mesh - -isDone = Mesh.Compute() - -# convert to quadratic -# theForce3d = 1; this results in the medium node lying at the -# middle of the line segments connecting start and end node of a mesh -# element - -Mesh.ConvertToQuadratic( theForce3d=1 ) - -# revert back to the non-quadratic mesh - -Mesh.ConvertFromQuadratic() - -# convert to quadratic -# theForce3d = 0; this results in the medium node lying at the -# geometrical edge from which the mesh element is built - -Mesh.ConvertToQuadratic( theForce3d=0 ) - -# to convert not the whole mesh but a sub-mesh, provide it as -# an additional argument to the functions: -# Mesh.ConvertToQuadratic( 0, subMesh ) -# Mesh.ConvertFromQuadratic( subMesh ) -# -# Note that the mesh becomes non-conformal at conversion of sub-mesh. - -\endcode +\include modifying_meshes_ex26.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_notebook_smesh.doc b/doc/salome/gui/SMESH/input/tui_notebook_smesh.doc index a300ee633..340359069 100644 --- a/doc/salome/gui/SMESH/input/tui_notebook_smesh.doc +++ b/doc/salome/gui/SMESH/input/tui_notebook_smesh.doc @@ -3,45 +3,7 @@ \page tui_notebook_smesh_page Using SALOME NoteBook \anchor tui_notebook_smesh - -\code -import geompy -import smesh -import salome_notebook - -# set variables -notebook = salome_notebook.notebook -notebook.set("Length", 100) -notebook.set("Width", 200) -notebook.set("Offset", 50) - -notebook.set("NbSegments", 7) -notebook.set("MaxElementArea", 800) -notebook.set("MaxElementVolume", 900) - -# create a box -box = geompy.MakeBoxDXDYDZ("Length", "Width", 300) -idbox = geompy.addToStudy(box, "Box") - -# create a mesh -tetra = smesh.Mesh(box, "MeshBox") - -algo1D = tetra.Segment() -algo1D.NumberOfSegments("NbSegments") - -algo2D = tetra.Triangle() -algo2D.MaxElementArea("MaxElementArea") - -algo3D = tetra.Tetrahedron() -algo3D.MaxElementVolume("MaxElementVolume") - -# compute the mesh -ret = tetra.Compute() - -# translate the mesh -point = smesh.PointStruct("Offset", 0., 0.) -vector = smesh.DirStruct(point) -tetra.TranslateObject(tetra, vector, 0) -\endcode +\include notebook_smesh.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_prism_3d_algo.doc b/doc/salome/gui/SMESH/input/tui_prism_3d_algo.doc index 4c38d2c7f..d0234a7ab 100644 --- a/doc/salome/gui/SMESH/input/tui_prism_3d_algo.doc +++ b/doc/salome/gui/SMESH/input/tui_prism_3d_algo.doc @@ -1,81 +1,8 @@ /*! \page tui_prism_3d_algo Use 3D extrusion meshing algorithm - -\code -import salome, smesh, SMESH, geompy - -salome.salome_init() -smesh.SetCurrentStudy( salome.myStudy ) - -OX = geompy.MakeVectorDXDYDZ(1,0,0) -OY = geompy.MakeVectorDXDYDZ(0,1,0) -OZ = geompy.MakeVectorDXDYDZ(0,0,1) - -# Y ^ Make geometry of a "pipe" with the following base (cross section). -# | Big central quadrangles will be meshed with triangles, walls -# of the pipe will be meshed with quadrilaterals -# +--+--+--+--+--+--+ -# | | | | | | | -# +--+--+--+--+--+--+ -# | | | | | -# +--+ | +--+ -# | | | | | -# +--+-----+-----+--+ -# | | | | | -# +--+ | +--+ -# | | | | | -# +--+--+--+--+--+--+ -# | | | | | | | --> -# +--+--+--+--+--+--+ X - -quadBig = geompy.MakeFaceHW( 20,20, 1 ) -quadBig = geompy.MakeTranslation( quadBig, 15,15,0 ) -quadSmall = geompy.MakeFaceHW( 10,10, 1 ) -smallQuads1 = geompy.MakeMultiTranslation1D( quadSmall, OX, 10, 3 ) -smallQuads2 = geompy.MakeMultiTranslation1D( quadSmall, OY, 10, 3 ) -smallQuads2 = geompy.SubShapeAllSortedCentres( smallQuads2, geompy.ShapeType["FACE"])[1:] - -base = geompy.MakeCompound( smallQuads2 + [smallQuads1, quadBig]) -axis = geompy.MakeLine( geompy.MakeVertex( 25,25,0), OZ ) -base = geompy.MultiRotate1DNbTimes( base, axis, 4) -base = geompy.MakePartition( [base], theName="base") -path = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 100:R 0:C -90 180:T 0 -150",[0,0,0, 0,-1,0, 1,0,0]) - -# Make the pipe, each quadrangle of the base turns into a prism with composite wall faces -pipe = geompy.MakePipe( base, path ) -prisms = geompy.MakePartition( [pipe], theName="prisms") - - -# get base faces of the prism to define sub-mesh on them -smallQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 0,0,0 ), "smallQuad") -bigQuad = geompy.GetFaceNearPoint( prisms, geompy.MakeVertex( 15,15,0 ), "bigQuad") - - -mesh = smesh.Mesh( prisms ) - -# assign Global hypotheses - -# 1D algorithm and hypothesis for vertical division -mesh.Segment().NumberOfSegments(15) - -# Extrusion 3D algo -mesh.Prism() - -# assign Local hypotheses - -# 1D and 2D algos and hyps to mesh smallQuad with quadrilaterals -mesh.Segment(smallQuad).LocalLength( 3 ) -mesh.Quadrangle(smallQuad) - -# 1D and 2D algos and hyps to mesh bigQuad with triangles -mesh.Segment(bigQuad).LocalLength( 3 ) -mesh.Triangle(bigQuad) - -# compute the mesh -mesh.Compute() - -\endcode +\include prism_3d_algo.py +Download this script The result geometry and mesh is shown below \image html prism_tui_sample.png diff --git a/doc/salome/gui/SMESH/input/tui_quality_controls.doc b/doc/salome/gui/SMESH/input/tui_quality_controls.doc index 2991eb521..e09389d3f 100644 --- a/doc/salome/gui/SMESH/input/tui_quality_controls.doc +++ b/doc/salome/gui/SMESH/input/tui_quality_controls.doc @@ -3,822 +3,91 @@ \page tui_quality_controls_page Quality Controls \section tui_free_borders Free Borders - -\code -import salome -import geompy - -import smesh - -# create open shell: a box without one plane -box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -FaceList.remove(FaceList[5]) -box = geompy.MakeShell(FaceList) -idbox = geompy.addToStudy(box, "box") - -# create a mesh -mesh = smesh.Mesh(box, "Mesh_free_borders") -algo = mesh.Segment() -algo.NumberOfSegments(5) -algo = mesh.Triangle() -algo.MaxElementArea(20.) -mesh.Compute() - -# criterion : free borders -aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_FreeBorders) -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Free borders Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateGroup(SMESH.EDGE, "Free borders") -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex01.py +Download this script \section tui_borders_at_multiconnection Borders at Multiconnection - -\code -import salome -import geompy - -import smesh -import SMESH - -# create open shell: a box without one plane -box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -FaceList.remove(FaceList[5]) -box = geompy.MakeShell(FaceList) -idbox = geompy.addToStudy(box, "box") - -# create a mesh -mesh = smesh.Mesh(box, "Mesh_borders_at_multi-connections") -algo = mesh.Segment() -algo.NumberOfSegments(5) -algo = mesh.Triangle() -algo.MaxElementArea(20.) -mesh.Compute() - -# Criterion : Borders at multi-connection -nb_conn = 2 - -aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, nb_conn) -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Borders at multi-connections Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateGroup(SMESH.EDGE, "Borders at multi-connections") -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex02.py +Download this script \section tui_length_1d Length 1D - -\code -import salome -import geompy - -import smesh - -# create open shell: a box without one plane -box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -FaceList.remove(FaceList[5]) -box = geompy.MakeShell(FaceList) -idbox = geompy.addToStudy(box, "box") - -# create a mesh -mesh = smesh.Mesh(box, "Mesh_Length_1D") -algo = mesh.Segment() -algo.NumberOfSegments(5) -algo = mesh.Triangle() -algo.MaxElementArea(20.) -mesh.Compute() - -# Criterion : Length > 3. -length_margin = 3. - -aFilter = smesh.GetFilter(smesh.EDGE, smesh.FT_Length, smesh.FT_MoreThan, length_margin) -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Edges length > ", length_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateGroup(SMESH.EDGE, "Edges with length > " + `length_margin`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex03.py +Download this script \section tui_free_edges Free Edges - -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -aFilterMgr = smesh.CreateFilterManager() - -# Remove some elements to obtain free edges -# Criterion : AREA > 95. -area_margin = 95. - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -mesh.RemoveElements(anIds) - -# Criterion : Free Edges -aBorders = mesh.GetFreeBorders() - -# create groups -aGroupF = mesh.CreateEmptyGroup(smesh.FACE, "Faces with free edges") -aGroupN = mesh.CreateEmptyGroup(smesh.NODE, "Nodes on free edges") - -# fill groups with elements, corresponding to the criterion -print "" -print "Criterion: Free edges Nb = ", len(aBorders) -for i in range(len(aBorders)): - aBorder = aBorders[i] - print "Face # ", aBorder.myElemId, " : Edge between nodes (", - print aBorder.myPnt1, ", ", aBorder.myPnt2, ")" - - aGroupF.Add([aBorder.myElemId]) - aGroupN.Add([aBorder.myPnt1, aBorder.myPnt2]) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex04.py +Download this script \section tui_free_nodes Free Nodes - -\code -import salome -import geompy - -import smesh - -# create box -box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box, "box") - -# create a mesh -mesh = smesh.Mesh(box, "Mesh_free_nodes") -algo = mesh.Segment() -algo.NumberOfSegments(10) -algo = mesh.Triangle(smesh.MEFISTO) -algo.MaxElementArea(150.) -mesh.Compute() - -# Remove some elements to obtain free nodes -# Criterion : AREA < 80. -area_margin = 80. - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_LessThan, area_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -mesh.RemoveElements(anIds) - -# criterion : free nodes -aFilter = smesh.GetFilter(smesh.NODE, smesh.FT_FreeNodes) -anNodeIds = mesh.GetIdsFromFilter(aFilter) - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.NODE, "Free_nodes") -aGroup.Add(anNodeIds) - -# print the result -print "Criterion: Free nodes Nb = ", len(anNodeIds) -j = 1 -for i in range(len(anNodeIds)): - if j > 20: j = 1; print "" - print anNodeIds[i], - j = j + 1 - pass -print "" - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex05.py +Download this script \section tui_free_faces Free Faces - -\code -import salome -import geompy - -####### GEOM part ######## - -Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) -Box_1_vertex_6 = geompy.GetSubShape(Box_1, [6]) -Box_1 = geompy.GetMainShape(Box_1_vertex_6) -Box_1_vertex_16 = geompy.GetSubShape(Box_1, [16]) -Box_1 = geompy.GetMainShape(Box_1_vertex_16) -Box_1_vertex_11 = geompy.GetSubShape(Box_1, [11]) -Box_1 = geompy.GetMainShape(Box_1_vertex_11) -Plane_1 = geompy.MakePlaneThreePnt(Box_1_vertex_6, Box_1_vertex_16, Box_1_vertex_11, 2000) -Partition_1 = geompy.MakePartition([Box_1], [Plane_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0) - -Box_1_vertex_19 = geompy.GetSubShape(Box_1, [19]) -Box_1_vertex_21 = geompy.GetSubShape(Box_1, [21]) -Plane_2 = geompy.MakePlaneThreePnt(Box_1_vertex_16, Box_1_vertex_19, Box_1_vertex_21, 2000) - -geompy.addToStudy( Box_1, "Box_1" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_6, "Box_1:vertex_6" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_16, "Box_1:vertex_16" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_11, "Box_1:vertex_11" ) -geompy.addToStudy( Plane_1, "Plane_1" ) -geompy.addToStudy( Partition_1, "Partition_1" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_19, "Box_1:vertex_19" ) -geompy.addToStudyInFather( Box_1, Box_1_vertex_21, "Box_1:vertex_21" ) -geompy.addToStudy( Plane_2, "Plane_2" ) - -###### SMESH part ###### -import smesh - -import StdMeshers - -Mesh_1 = smesh.Mesh(Partition_1) -Regular_1D = Mesh_1.Segment() -Max_Size_1 = Regular_1D.MaxSize(34.641) -MEFISTO_2D = Mesh_1.Triangle() -Tetrahedronn = Mesh_1.Tetrahedron() -isDone = Mesh_1.Compute() - -# create a group of free faces -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_FreeFaces ) -aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) - -aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Free_faces") -aGroup.Add(aFaceIds) - -# print the result -print "Criterion: Free faces Nb = ", len(aFaceIds) -j = 1 -for i in range(len(aFaceIds)): - if j > 20: j = 1; print "" - print aFaceIds[i], - j = j + 1 - pass -print "" - -#filter faces from plane 2 -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_2) -aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) -aGroup.Remove(aFaceIds) - -# create a group of shared faces (located on partition boundary inside box) -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_BelongToPlane, Plane_1) -aFaceIds = Mesh_1.GetIdsFromFilter(aFilter) - -aGroup = Mesh_1.CreateEmptyGroup(smesh.FACE, "Shared_faces") -aGroup.Add(aFaceIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex06.py +Download this script \section tui_bare_border_faces Bare border faces - -\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -box = geompy.MakeBoxDXDYDZ(100, 100, 100) -geompy.addToStudy( box, "box" ) - -mesh = smesh.Mesh(box) -mesh.Segment().NumberOfSegments(3) -mesh.Quadrangle() -mesh.Compute() - -# remove 2 faces -allFaces = mesh.GetElementsByType(FACE) -mesh.RemoveElements( allFaces[0:2]) - -bareGroup = mesh.MakeGroup("bare faces", FACE, FT_BareBorderFace) -assert(bareGroup.Size() == 3) -\endcode +\include quality_controls_ex07.py +Download this script \section tui_bare_border_volumes Bare border volumes - -\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -box = geompy.MakeBoxDXDYDZ(100, 30, 10) -# the smallest face of the box -face = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"])[0] - -geompy.addToStudy( box, "box" ) -geompy.addToStudyInFather( box, face, "face" ) - -mesh = Mesh(box) -mesh.AutomaticHexahedralization(); - -# remove half of mesh faces from the smallest face -faceFaces = mesh.GetSubMeshElementsId(face) -faceToRemove = faceFaces[: len(faceFaces)/2] -mesh.RemoveElements( faceToRemove ) - -# make a group of volumes missing the removed faces -bareGroup = mesh.MakeGroup("bare volumes", VOLUME, FT_BareBorderVolume) -assert(bareGroup.Size() == len( faceToRemove)) -\endcode +\include quality_controls_ex08.py +Download this script \section tui_over_constrained_faces Over-constrained faces -\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -mesh = Mesh() -faceFilter = GetFilter(FACE,FT_OverConstrainedFace) - -#make an edge -n1 = mesh.AddNode(0,0,0) -n2 = mesh.AddNode(10,0,0) -edge = mesh.AddEdge([n1,n2]) -assert( not mesh.GetIdsFromFilter( faceFilter )) - -# make faces -mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 5) -assert( 2 == len( mesh.GetIdsFromFilter( faceFilter ))) -\endcode +\include quality_controls_ex09.py +Download this script \section tui_over_constrained_volumes Over-constrained volumes -\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -mesh = Mesh() -volumeFilter = GetFilter(VOLUME,FT_OverConstrainedVolume) - -# make volumes by extrusion of one face -n1 = mesh.AddNode(0,0,0) -n2 = mesh.AddNode(10,0,0) -edge = mesh.AddEdge([n1,n2]) -mesh.ExtrusionSweep([edge], MakeDirStruct(0,7,0), 1) -mesh.ExtrusionSweep( mesh.GetElementsByType(FACE), MakeDirStruct(0,0,5), 7) -assert( 2 == len( mesh.GetIdsFromFilter( volumeFilter ))) -\endcode +\include quality_controls_ex10.py +Download this script \section tui_length_2d Length 2D - -\code -import salome -import geompy - -import smesh - -# create open shell: a box without one plane -box = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -FaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) -FaceList.remove(FaceList[5]) -box = geompy.MakeShell(FaceList) -idbox = geompy.addToStudy(box, "box") - -# create a mesh -mesh = smesh.Mesh(box, "Mesh_Length_2D") -algo = mesh.Segment() -algo.NumberOfSegments(5) -algo = mesh.Triangle() -algo.MaxElementArea(20.) -mesh.Compute() - -# Criterion : Length 2D > 5.7 -length_margin = 5.7 - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Length2D, smesh.FT_MoreThan, length_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Edges length 2D > ", length_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Faces with length 2D > " + `length_margin`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex11.py +Download this script \section tui_borders_at_multiconnection_2d Borders at Multiconnection 2D - -\code -import salome -import geompy - -import smesh - -# create a compound of two glued boxes -box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -box2 = geompy.MakeTranslation(box1, 0., 20., 0) -comp = geompy.MakeCompound([box1, box2]) -box = geompy.MakeGlueFaces(comp, 0.000001) -idbox = geompy.addToStudy(box, "box") - -# create a mesh -mesh = smesh.Mesh(box, "Box compound : 2D triangle mesh") -algo = mesh.Segment() -algo.NumberOfSegments(5) -algo = mesh.Triangle() -algo.MaxElementArea(20.) -mesh.Compute() - -# Criterion : MULTI-CONNECTION 2D = 3 -nb_conn = 3 - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MultiConnection2D, smesh.FT_EqualTo, nb_conn) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Borders at multi-connection 2D = ", nb_conn, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Borders at multi-connection 2D = " + `nb_conn`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex12.py +Download this script \section tui_area Area - -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : AREA > 100. -area_margin = 100. - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, area_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Area > ", area_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Area > " + `area_margin`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex13.py +Download this script \section tui_taper Taper - -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : Taper > 3e-20 -taper_margin = 3e-20 - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, taper_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Taper > ", taper_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Taper > " + `taper_margin`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex14.py +Download this script \section tui_aspect_ratio Aspect Ratio - -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : ASPECT RATIO > 1.8 -ar_margin = 1.8 - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, ar_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Aspect Ratio > ", ar_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Aspect Ratio > " + `ar_margin`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex15.py +Download this script \section tui_minimum_angle Minimum Angle - -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : MINIMUM ANGLE < 35. -min_angle = 35. - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, min_angle) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Minimum Angle < ", min_angle, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Minimum Angle < " + `min_angle`) - -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex16.py +Download this script \section tui_warping Warping - -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : WARP ANGLE > 1e-15 -wa_margin = 1e-15 - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, wa_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Warp > ", wa_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Warp > " + `wa_margin`) - -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex17.py +Download this script \section tui_skew Skew - -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : Skew > 38. -skew_margin = 38. - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, skew_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Skew > ", skew_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Skew > " + `skew_margin`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex18.py +Download this script \section tui_max_element_length_2d Element Diameter 2D - -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh -salome = SMESH_mechanic.salome - -# Criterion : ELEMENT DIAMETER 2D > 10 -mel_2d_margin = 10 - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength2D, smesh.FT_MoreThan, mel_2d_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Element Diameter 2D Ratio > ", mel_2d_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 2D > " + `mel_2d_margin`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex19.py +Download this script \section tui_aspect_ratio_3d Aspect Ratio 3D - -\code -import SMESH_mechanic_tetra - -smesh = SMESH_mechanic_tetra.smesh -mesh = SMESH_mechanic_tetra.mesh -salome = SMESH_mechanic_tetra.salome - -# Criterion : ASPECT RATIO 3D > 4.5 -ar_margin = 4.5 - -aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_AspectRatio3D, smesh.FT_MoreThan, ar_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Aspect Ratio 3D > ", ar_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Aspect Ratio 3D > " + `ar_margin`) - -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex20.py +Download this script \section tui_volume Volume - -\code -import SMESH_mechanic_tetra - -smesh = SMESH_mechanic_tetra.smesh -mesh = SMESH_mechanic_tetra.mesh -salome = SMESH_mechanic_tetra.salome - -# Criterion : VOLUME < 7. -volume_margin = 7. - -aFilter = smesh.GetFilter(smesh.VOLUME, smesh.FT_Volume3D, smesh.FT_LessThan, volume_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "" -print "Criterion: Volume < ", volume_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.VOLUME, "Volume < " + `volume_margin`) - -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex21.py +Download this script \section tui_max_element_length_3d Element Diameter 3D - -\code -import SMESH_mechanic_tetra - -smesh = SMESH_mechanic_tetra.smesh -mesh = SMESH_mechanic_tetra.mesh -salome = SMESH_mechanic_tetra.salome - -# Criterion : ELEMENT DIAMETER 3D > 10 -mel_3d_margin = 10 - -aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_MaxElementLength3D, smesh.FT_MoreThan, mel_3d_margin) - -anIds = mesh.GetIdsFromFilter(aFilter) - -# print the result -print "Criterion: Element Diameter 3D Ratio > ", mel_3d_margin, " Nb = ", len(anIds) -j = 1 -for i in range(len(anIds)): - if j > 20: j = 1; print "" - print anIds[i], - j = j + 1 - pass -print "" - -# create a group -aGroup = mesh.CreateEmptyGroup(smesh.FACE, "Element Diameter 3D > " + `mel_3d_margin`) -aGroup.Add(anIds) - -salome.sg.updateObjBrowser(1) -\endcode +\include quality_controls_ex22.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc b/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc index a4c6df87d..3b77fab34 100644 --- a/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc +++ b/doc/salome/gui/SMESH/input/tui_transforming_meshes.doc @@ -7,580 +7,81 @@
\anchor tui_translation

Translation

- -\code -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh - -# define translation vector -point = smesh.PointStruct(-150., -150., 0.) -vector =smesh.DirStruct(point) - -# translate a mesh -doCopy = 1 - -mesh.Translate([], vector, doCopy) -\endcode +\include transforming_meshes_ex01.py +Download this script
\anchor tui_rotation

Rotation

- -\code -import math - -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh - -# define rotation axis and angle -axisXYZ = smesh.AxisStruct(0., 0., 0., 5., 5., 20.) -angle270 = 1.5 * math.pi - -# rotate a mesh -mesh.Rotate([], axisXYZ, angle270, 1) -\endcode +\include transforming_meshes_ex02.py +Download this script
\anchor tui_scale

Scale

- -\code -import geompy -Box = geompy.MakeBoxDXDYDZ(200, 200, 200) -f = geompy.SubShapeAllSorted(Box, geompy.ShapeType["FACE"]) - -import smesh,SMESH -import StdMeshers -Mesh1 = smesh.Mesh(f[0]) -Regular_1D = Mesh1.Segment() -Nb_Segments_1 = Regular_1D.NumberOfSegments(3) -Nb_Segments_1.SetDistrType( 0 ) -Quadrangle_2D = Mesh1.Quadrangle() -isDone = Mesh1.Compute() - -#Perform scale opration for the whole mesh and creation of a new mesh -newMesh = Mesh1.ScaleMakeMesh(Mesh1,SMESH.PointStruct(100,100,200),[0.5,0.3,0.7],True,"ScaledMesh") - -#Perform scale operation for the whole mesh and copy elements -Mesh1.Scale(Mesh1,SMESH.PointStruct(200,100,100),[0.5,0.5,0.5],True,True) - -#Perform scale opration for two edges and move elements -Mesh1.Scale([1,2],SMESH.PointStruct(-100,100,100),[0.8,1.0,0.7],False) - -#Perform scale opration for one face and move elements -Mesh1.Scale([21],SMESH.PointStruct(0,200,200),[0.7,0.7,0.7],False) -\endcode +\include transforming_meshes_ex03.py +Download this script
\anchor tui_symmetry

Symmetry

- -\code -import math - -import SMESH_mechanic - -smesh = SMESH_mechanic.smesh -mesh = SMESH_mechanic.mesh - -# create a symmetrical copy of the mesh mirrored through a point -axis = SMESH.AxisStruct(0, 0, 0, 0, 0, 0) - -mesh.Mirror([], axis, smesh.POINT, 1) -\endcode +\include transforming_meshes_ex04.py +Download this script
\anchor tui_merging_nodes

Merging Nodes

- -\code -import SMESH_mechanic -mesh = SMESH_mechanic.mesh - -# merge nodes -Tolerance = 25.0 - -GroupsOfNodes = mesh.FindCoincidentNodes(Tolerance) -mesh.MergeNodes(GroupsOfNodes) -\endcode +\include transforming_meshes_ex05.py +Download this script
\anchor tui_merging_elements

Merging Elements

- -\code -import salome -import geompy -import smesh - -# create a face to be meshed -px = geompy.MakeVertex(100., 0. , 0. ) -py = geompy.MakeVertex(0. , 100., 0. ) -pz = geompy.MakeVertex(0. , 0. , 100.) - -vxy = geompy.MakeVector(px, py) -arc = geompy.MakeArc(py, pz, px) - -wire = geompy.MakeWire([vxy, arc]) -isPlanarFace = 1 - -face1 = geompy.MakeFace(wire, isPlanarFace) -id_face1 = geompy.addToStudy(face1, "Face1") - -# create a circle to be an extrusion path -px1 = geompy.MakeVertex( 100., 100., 0.) -py1 = geompy.MakeVertex(-100., -100., 0.) -pz1 = geompy.MakeVertex( 0., 0., 50.) - -circle = geompy.MakeCircleThreePnt(py1, pz1, px1) -id_circle = geompy.addToStudy(circle, "Path") - -# create a 2D mesh on the face -trias = smesh.Mesh(face1, "Face : 2D mesh") - -algo1D = trias.Segment() -algo1D.NumberOfSegments(6) -algo2D = trias.Triangle() -algo2D.LengthFromEdges() - -trias.Compute() - -# create a path mesh -circlemesh = smesh.Mesh(circle, "Path mesh") -algo = circlemesh.Segment() -algo.NumberOfSegments(10) -circlemesh.Compute() - -# extrusion of the mesh -trias.ExtrusionAlongPath([], circlemesh, circle, - 1, 0, [], 0, smesh.PointStruct(0, 0, 0)) - -# merge nodes -print "Number of nodes before MergeNodes:", -trias.NbNodes() -tolerance = 0.001 -array_of_nodes_groups = trias.FindCoincidentNodes(tolerance) - -trias.MergeNodes(array_of_nodes_groups) - -print "Number of nodes after MergeNodes:", trias.NbNodes() -print "" -print "Number of elements before MergeEqualElements:" -print "Edges : ", trias.NbEdges() -print "Triangles : ", trias.NbTriangles() -print "Quadrangles: ", trias.NbQuadrangles() -print "Volumes : ", trias.NbVolumes() - -# merge elements -trias.MergeEqualElements() -print "Number of elements after MergeEqualElements:" -print "Edges : ", trias.NbEdges() -print "Triangles : ", trias.NbTriangles() -print "Quadrangles: ", trias.NbQuadrangles() -print "Volumes : ", trias.NbVolumes() - -salome.sg.updateObjBrowser(1) -\endcode +\include transforming_meshes_ex06.py +Download this script

Sewing Meshes


\anchor tui_sew_meshes_border_to_side

Sew Meshes Border to Side

- -\code -import geompy -import smesh - -# create two faces of a box -box1 = geompy.MakeBox(0., 0., -10., 30., 20., 25.) -facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) -face1 = facesList1[2] - -box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.) -facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) -face2 = facesList2[1] - -edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"]) -edge1 = edgesList[2] - -aComp = geompy.MakeCompound([face1, face2]) -geompy.addToStudy(aComp, "Two faces") - -# create a mesh on two faces -mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") - -algo1D = mesh.Segment() -algo1D.NumberOfSegments(9) -algo2D = mesh.Quadrangle() - -algo_local = mesh.Segment(edge1) -algo_local.Arithmetic1D(1, 4) -algo_local.Propagation() - -mesh.Compute() - -# sew border to side -# FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, -# FirstNodeIDOnSide, LastNodeIDOnSide, -# CreatePolygons, CreatePolyedrs -mesh.SewBorderToSide(5, 45, 6, 113, 109, 0, 0) -\endcode +\include transforming_meshes_ex07.py +Download this script
\anchor tui_sew_conform_free_borders

Sew Conform Free Borders

- -\code -import geompy -import smesh - -# create two faces of the box -box1 = geompy.MakeBox(0., 0., -10., 20., 20., 15.) -facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) -face1 = facesList1[2] - -box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.) -facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) -face2 = facesList2[1] - -edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"]) -edge1 = edgesList[2] - -aComp = geompy.MakeCompound([face1, face2]) -geompy.addToStudy(aComp, "Two faces") - -# create a mesh on two faces -mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") - -algo1D = mesh.Segment() -algo1D.NumberOfSegments(9) -algo2D = mesh.Quadrangle() - -algo_local = mesh.Segment(edge1) -algo_local.Arithmetic1D(1, 4) -algo_local.Propagation() - -mesh.Compute() - -# sew conform free borders -# FirstNodeID1, SecondNodeID1, LastNodeID1, FirstNodeID2, SecondNodeID2 -mesh.SewConformFreeBorders(5, 45, 6, 3, 24) -\endcode +\include transforming_meshes_ex08.py +Download this script
\anchor tui_sew_free_borders

Sew Free Borders

- -\code -import geompy -import smesh - -# create two faces of the box -box1 = geompy.MakeBox(0., 0., 0., 20., 20., 15.) -facesList1 = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) -face1 = facesList1[2] - -box2 = geompy.MakeBox(0., 5., 0., 20., 20., 15.) -facesList2 = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) -face2 = facesList2[1] - -edgesList = geompy.SubShapeAll(face2, geompy.ShapeType["EDGE"]) -edge1 = edgesList[2] - -aComp = geompy.MakeCompound([face1, face2]) -geompy.addToStudy(aComp, "Two faces") - -# create a mesh on two faces -mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") - -algo1D = mesh.Segment() -algo1D.NumberOfSegments(4) -algo2D = mesh.Quadrangle() - -algo_local = mesh.Segment(edge1) -algo_local.Arithmetic1D(1, 4) -algo_local.Propagation() - -mesh.Compute() - -# sew free borders -# FirstNodeID1, SecondNodeID1, LastNodeID1, -# FirstNodeID2, SecondNodeID2, LastNodeID2, CreatePolygons, CreatePolyedrs -mesh.SewFreeBorders(6, 21, 5, 1, 12, 3, 0, 0) -\endcode +\include transforming_meshes_ex09.py +Download this script
\anchor tui_sew_side_elements

Sew Side Elements

- -\code -import geompy -import smesh - -# create two boxes -box1 = geompy.MakeBox(0., 0., 0., 10., 10., 10.) -box2 = geompy.MakeBox(0., 15., 0., 20., 25., 10.) - -EdgesList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) - -aComp = geompy.MakeCompound([box1, box2]) -geompy.addToStudy(aComp, "Two boxes") - -# create a mesh on two boxes -mesh = smesh.Mesh(aComp, "Two faces : quadrangle mesh") - -algo1D = mesh.Segment() -algo1D.NumberOfSegments(2) -algo2D = mesh.Quadrangle() - -algo_local = mesh.Segment(EdgesList[8]) -algo_local.NumberOfSegments(4) -algo_local.Propagation() - -mesh.Compute() - -# sew side elements -# IDsOfSide1Elements, IDsOfSide2Elements, -# NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge -mesh.SewSideElements([69, 70, 71, 72], [91, 92, 89, 90], 8, 38, 23, 58) -\endcode +\include transforming_meshes_ex10.py +Download this script
\anchor tui_duplicate_nodes

Duplicate nodes

- -\code -import salome -import smesh -import SMESH_test1 - -mesh = SMESH_test1.mesh - -# Compute mesh -mesh.Compute() - -# Without the duplication of border elements - -# Nodes to duplicate -nodes1 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes1' ) -nodes1.Add( [ 289, 278, 302, 285 ] ) - -# Group of faces to replace nodes with new ones -faces1 = mesh.CreateEmptyGroup( smesh.FACE, 'faces1' ) -faces1.Add( [ 519, 556, 557 ] ) - -# Duplicate nodes -print "\nMesh before the first nodes duplication:" -print "Nodes : ", mesh.NbNodes() -print "Edges : ", mesh.NbEdges() -print "Triangles : ", mesh.NbTriangles() - -groupOfCreatedNodes = mesh.DoubleNodeGroup(nodes1, faces1, theMakeGroup=True) -print "New nodes:", groupOfCreatedNodes.GetIDs() - -print "\nMesh after the first nodes duplication:" -print "Nodes : ", mesh.NbNodes() -print "Edges : ", mesh.NbEdges() -print "Triangles : ", mesh.NbTriangles() - -# With the duplication of border elements - -# Edges to duplicate -edges = mesh.CreateEmptyGroup( smesh.EDGE, 'edges' ) -edges.Add( [ 29, 30, 31 ] ) - -# Nodes not to duplicate -nodes2 = mesh.CreateEmptyGroup( smesh.NODE, 'nodes2' ) -nodes2.Add( [ 32, 5 ] ) - -# Group of faces to replace nodes with new ones -faces2 = mesh.CreateEmptyGroup( smesh.FACE, 'faces2' ) -faces2.Add( [ 576, 578, 580 ] ) - -# Duplicate nodes -print "\nMesh before the second nodes duplication:" -print "Nodes : ", mesh.NbNodes() -print "Edges : ", mesh.NbEdges() -print "Triangles : ", mesh.NbTriangles() - -groupOfNewEdges = mesh.DoubleNodeElemGroup( edges, nodes2, faces2, theMakeGroup=True ) -print "New edges:", groupOfNewEdges.GetIDs() - -print "\nMesh after the second nodes duplication:" -print "Nodes : ", mesh.NbNodes() -print "Edges : ", mesh.NbEdges() -print "Triangles : ", mesh.NbTriangles() - -# Update object browser -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(0) -\endcode +\include transforming_meshes_ex11.py +Download this script
\anchor tui_make_2dmesh_from_3d

Create boundary elements

- -\code -from smesh import * -SetCurrentStudy(salome.myStudy) - -box = geompy.MakeBoxDXDYDZ(100, 100, 100) -gFaces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"]) -f1,f2 = gFaces[0],gFaces[1] -geompy.addToStudy(box,"box") -geompy.addToStudyInFather(box,f1,"face1") -geompy.addToStudyInFather(box,f2,"face2") - -twoFaces = geompy.MakeCompound([f1,f2]) - -## ----------- -## -## 2D from 3D -## -## ----------- -dim = SMESH.BND_2DFROM3D - -init_mesh = Mesh(box, "box") -init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons - -# remove some faces -faces = init_mesh.GetElementsByType( SMESH.FACE ) -nb_faces = len( faces ) -rm_face = faces[ : nb_faces/2] -init_mesh.RemoveElements( rm_face ) - -# restore boundary in this mesh -mesh = CopyMesh( init_mesh, "2D from 3D") -groupName = "bnd 2D" -nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName) - -# restore boundary (only) in other mesh -meshName = "2D boundary of " + init_mesh.GetName() -nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName) - -# restore boundary in mesh copy -meshName = init_mesh.GetName() + " + boundary" -nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True) - - -## ----------- -## -## 1D from 2D -## -## ----------- -dim = SMESH.BND_1DFROM2D - -init_mesh = Mesh(f1, "2D mesh") -init_mesh.AutomaticHexahedralization() - -# remove some edges -edges = init_mesh.GetElementsByType( SMESH.EDGE ) -nb_edges = len( edges ) -rm_edge = edges[ : nb_edges/2] -init_mesh.RemoveElements( rm_edge ) - - -# restore boundary edges in this mesh -mesh = CopyMesh( init_mesh, "1D from 2D") -groupName = "bnd 1D" -nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName) - -# restore boundary edges (only) in other mesh -meshName = "1D boundary of " + init_mesh.GetName() -nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName) - -# restore boundary edges in mesh copy -meshName = init_mesh.GetName() + " + boundary" -nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, toCopyAll=True) - - - -## ------------------ -## -## 1D from 2D GROUPS -## -## ------------------ -dim = SMESH.BND_1DFROM3D - -init_mesh = Mesh(box, "box") -init_mesh.AutomaticHexahedralization() # it makes 3 x 3 x 3 hexahedrons -# remove all edges -rm_edges = init_mesh.GetElementsByType( SMESH.EDGE ) -init_mesh.RemoveElements( rm_edges ) - -# make groups of faces -fGroup1 = init_mesh.Group( f1, "f1" ) -fGroup2 = init_mesh.Group( f2, "f2" ) - -# make 1D boundary around groups in this mesh -mesh = CopyMesh( init_mesh, "1D from 2D groups", toCopyGroups=True) -groups = mesh.GetGroups() -nb, new_mesh, new_group = mesh.MakeBoundaryElements(dim, groupName,groups=groups) - -# make 1D boundary (only) in other mesh -meshName = "boundary from groups of " + init_mesh.GetName() -groups = init_mesh.GetGroups() -nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName,groups=groups) - -# make 1D boundary in mesh copy -meshName = init_mesh.GetName() + " + boundary from groups" -nb, new_mesh, new_group = init_mesh.MakeBoundaryElements(dim, groupName, meshName, - groups=groups, toCopyAll=True) - -\endcode +\include transforming_meshes_ex12.py +Download this script
\anchor tui_reorient_faces

Reorient faces by vector

- -\code -import smesh, geompy, SMESH - -# create a geometry consisting of two faces -box = geompy.MakeBoxDXDYDZ( 10, 10, 10 ) -faces = geompy.SubShapeAllSorted( box, geompy.ShapeType["FACE"]) - -shape = geompy.MakeCompound( faces[:2] ) -faces = geompy.SubShapeAll( shape, geompy.ShapeType["FACE"] ) -geompy.addToStudy( shape, "shape") -geompy.addToStudyInFather( shape, faces[0], "faces[0]") -geompy.addToStudyInFather( shape, faces[1], "faces[1]") - -# create a 2D mesh -mesh = smesh.Mesh( shape, "test_Reorient2D") -mesh.AutomaticHexahedralization(0.5) -localAlgo = mesh.Segment(faces[0]) -localAlgo.NumberOfSegments( 11 ) -mesh.Compute() -group = mesh.Group( faces[1] ) - -vec = geompy.MakeVectorDXDYDZ( 1, 1, 1 ) - -# Each of arguments of Reorient2D() function can be of different types: -# -# 2DObject - the whole mesh -# Direction - a GEOM object (vector) -# FaceOrPoint - an ID of face -mesh.Reorient2D( mesh, vec, mesh.NbElements() ) -# -# 2DObject - a sub-mesh -# Direction - components of a vector -# FaceOrPoint - a GEOM object (vertex) -mesh.Reorient2D( localAlgo.GetSubMesh(), [ 1, -1, 1 ], geompy.GetFirstVertex( vec )) -# -# 2DObject - a group of faces -# Direction - a SMESH.DirStruct structure -# FaceOrPoint - coordinates of a point -mesh.Reorient2D( group, smesh.MakeDirStruct( -10, 1, 10 ), [0,0,0]) -# -# FaceOrPoint - a SMESH.PointStruct structure -mesh.Reorient2D( localAlgo.GetSubMesh().GetIDs(), [10,1,0], SMESH.PointStruct(0,0,0)) - -\endcode +\include transforming_meshes_ex13.py +Download this script */ diff --git a/doc/salome/gui/SMESH/input/tui_use_existing_faces.doc b/doc/salome/gui/SMESH/input/tui_use_existing_faces.doc index 0f95ac4d4..46dfe1e05 100644 --- a/doc/salome/gui/SMESH/input/tui_use_existing_faces.doc +++ b/doc/salome/gui/SMESH/input/tui_use_existing_faces.doc @@ -6,117 +6,8 @@ This sample demonstrates how to use Use existing faces algorithm, which is actulally just a stub allowing to use your own 2D algoritm implemented in Python. - -\code -import smesh, geompy -import numpy as np - -# define my 2D algorithm -def my2DMeshing( geomFace ): - - # find gravity center of geomFace - gcXYZ = geompy.PointCoordinates( geompy.MakeCDG( geomFace )) - - # define order and orientation of edges - sortedEdges = [] - geomEdges = geompy.SubShapeAll( geomFace, geompy.ShapeType["EDGE"]) - sortedEdges.append(( geomEdges.pop(0), True )) - while geomEdges: - prevEdge_rev = sortedEdges[ -1 ] - prevVV = geompy.SubShapeAll( prevEdge_rev[0], geompy.ShapeType["VERTEX"]) - prevV2 = prevVV[ prevEdge_rev[1] ] - found = False - for iE in range( len( geomEdges )): - v1,v2 = geompy.SubShapeAll( geomEdges[ iE ], geompy.ShapeType["VERTEX"]) - same1,same2 = [( geompy.MinDistance( prevV2, v ) < 1e-7 ) for v in [v1,v2] ] - if not same1 and not same2: continue - sortedEdges.append(( geomEdges.pop( iE ), same1 )) - found = True - break - assert found - sortedEdges.reverse() - - # put nodes on edges in a right order - nodes = [] - for edge, isForward in sortedEdges: - v1,v2 = geompy.SubShapeAll( edge, geompy.ShapeType["VERTEX"]) - edgeNodes = mesh.GetSubMeshNodesId( v2, all=False ) + \ - mesh.GetSubMeshNodesId( edge, all=False ) + \ - mesh.GetSubMeshNodesId( v1, all=False ) - if not isForward: edgeNodes.reverse() - nodes.extend( edgeNodes[:-1] ) - - # create nodes inside the geomFace - r1 = 0.6 - r2 = 1 - r1 - nodesInside = [] - for n in nodes: - nXYZ = mesh.GetNodeXYZ( n ) - newXYZ = np.add( np.multiply( r1, gcXYZ ), np.multiply( r2, nXYZ )) - nodesInside.append( mesh.AddNode( newXYZ[0], newXYZ[1], newXYZ[2] )) - mesh.SetNodeOnFace( nodesInside[-1], geomFace, 0, 0 ) - - # find out orientation of faces to create - # geomFace normal - faceNorm = geompy.GetNormal( geomFace ) - v1,v2 = [ geompy.PointCoordinates( v ) \ - for v in geompy.SubShapeAll( faceNorm, geompy.ShapeType["VERTEX"]) ] - faceNormXYZ = np.subtract( v2, v1 ) - outDirXYZ = np.subtract( v1, [ 50, 50, 50 ] ) - if np.dot( faceNormXYZ, outDirXYZ ) < 0: # reversed face - faceNormXYZ = np.multiply( -1., faceNormXYZ ) - # mesh face normal - e1 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodes[1] )) - e2 = np.subtract( mesh.GetNodeXYZ( nodes[0] ), mesh.GetNodeXYZ( nodesInside[0] )) - meshNorm = np.cross( e1, e2 ) - # faces orientation - reverse = ( np.dot( faceNormXYZ, meshNorm ) < 0 ) - - # create mesh faces - iN = len( nodes ) - while iN: - n1, n2, n3, n4 = nodes[iN-1], nodes[iN-2], nodesInside[iN-2], nodesInside[iN-1] - iN -= 1 - if reverse: - f = mesh.AddFace( [n1, n2, n3, n4] ) - else: - f = mesh.AddFace( [n4, n3, n2, n1] ) - # new faces must be assigned to geometry to allow 3D algorithm finding them - mesh.SetMeshElementOnShape( f, geomFace ) - - if reverse: - nodesInside.reverse() - polygon = mesh.AddPolygonalFace( nodesInside ) - mesh.SetMeshElementOnShape( polygon, geomFace ) - - return - -# create geometry and get faces to mesh with my2DMeshing() -box = geompy.MakeBoxDXDYDZ( 100, 100, 100 ) -f1 = geompy.SubShapeAll( box, geompy.ShapeType["FACE"])[0] -f2 = geompy.GetOppositeFace( box, f1 ) -geompy.addToStudy( box, "box" ) -geompy.addToStudy( f1, "f1" ) -geompy.addToStudy( f2, "f2" ) - -# compute 1D mesh -mesh = smesh.Mesh( box ) -mesh.Segment().NumberOfSegments( 5 ) -mesh.Compute() - -# compute 2D mesh -mesh.Quadrangle() -mesh.UseExistingFaces(f1) # UseExistingFaces() allows using my2DMeshing() -mesh.UseExistingFaces(f2) -my2DMeshing( f1 ) -my2DMeshing( f2 ) -assert mesh.Compute() - -# compute 3D mesh -mesh.Prism() -assert mesh.Compute() - -\endcode +\include use_existing_faces.py +Download this script Resulting mesh: \image html use_existing_face_sample_mesh.png diff --git a/doc/salome/gui/SMESH/input/tui_viewing_meshes.doc b/doc/salome/gui/SMESH/input/tui_viewing_meshes.doc index fc0094e4b..06586ffea 100644 --- a/doc/salome/gui/SMESH/input/tui_viewing_meshes.doc +++ b/doc/salome/gui/SMESH/input/tui_viewing_meshes.doc @@ -5,135 +5,13 @@
\anchor tui_viewing_mesh_infos

Viewing Mesh Infos

- -\code -import geompy -import smesh -import SMESH - -# create a box -box = geompy.MakeBox(0., 0., 0., 20., 20., 20.) -geompy.addToStudy(box, "box") -[Face_1,Face_2,Face_3,Face_4,Face_5,Face_5] = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) - -# create a mesh -tetra = smesh.Mesh(box, "MeshBox") - -algo1D = tetra.Segment() -algo1D.NumberOfSegments(3) - -algo2D = tetra.Triangle() -algo2D.MaxElementArea(10.) - -algo3D = tetra.Tetrahedron() -algo3D.MaxElementVolume(900.) - -# Creation of SubMesh -Regular_1D_1_1 = tetra.Segment(geom=Face_1) -Nb_Segments_1 = Regular_1D_1_1.NumberOfSegments(5) -Nb_Segments_1.SetDistrType( 0 ) -Quadrangle_2D = tetra.Quadrangle(geom=Face_1) -isDone = tetra.Compute() -submesh = Regular_1D_1_1.GetSubMesh() - -# compute the mesh -tetra.Compute() - -# Creation of group -group = tetra.CreateEmptyGroup( SMESH.FACE, 'Group' ) -nbAdd = group.Add( [ 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76 ] ) - -# Print information about the mesh -print "Information about mesh:" -print "Number of nodes : ", tetra.NbNodes() -print "Number of edges : ", tetra.NbEdges() -print "Number of faces : ", tetra.NbFaces() -print " triangles : ", tetra.NbTriangles() -print " quadrangles : ", tetra.NbQuadrangles() -print " polygons : ", tetra.NbPolygons() -print "Number of volumes : ", tetra.NbVolumes() -print " tetrahedrons: ", tetra.NbTetras() -print " hexahedrons : ", tetra.NbHexas() -print " prisms : ", tetra.NbPrisms() -print " pyramids : ", tetra.NbPyramids() -print " polyhedrons : ", tetra.NbPolyhedrons() - -# Get Information About Mesh by GetMeshInfo -print "\nInformation about mesh by GetMeshInfo:" -info = smesh.GetMeshInfo(tetra) -keys = info.keys(); keys.sort() -for i in keys: - print " %s : %d" % ( i, info[i] ) - pass - -# Get Information About Group by GetMeshInfo -print "\nInformation about group by GetMeshInfo:" -info = smesh.GetMeshInfo(group) -keys = info.keys(); keys.sort() -for i in keys: - print " %s : %d" % ( i, info[i] ) - pass - -# Get Information About SubMesh by GetMeshInfo -print "\nInformation about Submesh by GetMeshInfo:" -info = smesh.GetMeshInfo(submesh) -keys = info.keys(); keys.sort() -for i in keys: - print " %s : %d" % ( i, info[i] ) - pass -\endcode - - +\include viewing_meshes_ex01.py +Download this script
\anchor tui_find_element_by_point

Find Element by Point

- -\code -import geompy -import smesh -import SMESH - -# Create a geometry to mesh -box = geompy.MakeBoxDXDYDZ(100,100,100) - -# Create a mesh -mesh = Mesh(box,"Mesh") -mesh.AutomaticHexahedralization() -mesh.Compute() - -# Create a point -x,y,z = 0, 0, 1 - -# Find all elements (except 0D ones) located at the point -all_elems_except_0D = mesh.FindElementsByPoint(x,y,z) -assert( len(all_elems_except_0D) == 4) - -# Find nodes at the point -nodes = mesh.FindElementsByPoint(x,y,z, SMESH.NODE ) -assert( len(nodes) == 0) -assert( len( mesh.FindElementsByPoint(x,y,0, SMESH.NODE)) == 1) - -# Find an edge at the point -edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE ) -assert( len(edges) == 1) - -# Find faces at the point -edges = mesh.FindElementsByPoint(x,y,z, SMESH.FACE ) -assert( len(edges) == 2) - -# Find a volume at the point -vols = mesh.FindElementsByPoint(x,y,z, SMESH.VOLUME ) -assert( len(vols) == 1) - -# Find 0D elements at the point -elems0d = mesh.FindElementsByPoint(x,y,z, SMESH.ELEM0D ) -assert( len(elems0d) == 0) - -# Find edges within a group -group1D = mesh.MakeGroupByIds("1D", SMESH.EDGE, [1,2] ) -edges = mesh.FindElementsByPoint(x,y,z, SMESH.EDGE, group1D ) - -\endcode +\include viewing_meshes_ex02.py +Download this script */