From c2a1a7c926ffd8f0fbf2b48241d94a989d9d8e3d Mon Sep 17 00:00:00 2001 From: prascle Date: Wed, 20 Mar 2013 15:47:19 +0000 Subject: [PATCH] PR: update documentation for smeshBuilder --- configure.ac | 1 + doc/salome/Makefile.am | 2 +- doc/salome/examples/Makefile.am | 31 ++++ doc/salome/examples/blsurfdemo.py | 146 +++++++++++++++++ doc/salome/gui/BLSURFPLUGIN/doxyfile.in | 8 +- doc/salome/gui/BLSURFPLUGIN/doxyfile_py.in | 3 +- .../input/blsurfplugin_python_interface.doc | 150 +----------------- 7 files changed, 193 insertions(+), 148 deletions(-) create mode 100644 doc/salome/examples/Makefile.am create mode 100644 doc/salome/examples/blsurfdemo.py diff --git a/configure.ac b/configure.ac index a1f53a2..101cc20 100644 --- a/configure.ac +++ b/configure.ac @@ -441,6 +441,7 @@ AC_OUTPUT([ \ adm_local/cmake_files/Makefile \ doc/Makefile \ doc/salome/Makefile \ + doc/salome/examples/Makefile \ doc/salome/gui/Makefile \ doc/salome/gui/BLSURFPLUGIN/Makefile \ doc/salome/gui/BLSURFPLUGIN/doxyfile \ diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am index f5de046..7733346 100644 --- a/doc/salome/Makefile.am +++ b/doc/salome/Makefile.am @@ -21,7 +21,7 @@ # Author : Patrick GOLDBRONN (CEA) # Date : 30/11/2001 # -SUBDIRS = tui gui +SUBDIRS = examples tui gui SUBDIRSTUI = tui SUBDIRSGUI = gui diff --git a/doc/salome/examples/Makefile.am b/doc/salome/examples/Makefile.am new file mode 100644 index 0000000..7198ca9 --- /dev/null +++ b/doc/salome/examples/Makefile.am @@ -0,0 +1,31 @@ +# 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/BLSURFPLUGIN + +pyexamples_SCRIPTS = blsurfdemo.py + +EXTRA_DIST += $(pyexamples_SCRIPTS) diff --git a/doc/salome/examples/blsurfdemo.py b/doc/salome/examples/blsurfdemo.py new file mode 100644 index 0000000..33a6e9d --- /dev/null +++ b/doc/salome/examples/blsurfdemo.py @@ -0,0 +1,146 @@ +# ------------------------------------------------- +# blsurf_construct_mesh_basic_hypo Basic hypothesis +# ------------------------------------------------- + +import salome +salome.salome_init() +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + +# create a box +box = geompy.MakeBoxDXDYDZ(200., 200., 200.) +geompy.addToStudy(box, "box") + +# get sub-shapes +Face_1 = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0] +Edge_1 = geompy.SubShapeAllSorted(box, geompy.ShapeType["EDGE"])[0] +Vertex_1 = geompy.SubShapeAllSorted(box, geompy.ShapeType["VERTEX"])[0] + +Face_2 = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[5] +Wire_1 = geompy.SubShapeAllSorted(Face_2, geompy.ShapeType["WIRE"])[0] + +# Geom object with sizemaps can be unpublished in study. +# They will then be automatically published. +geompy.addToStudyInFather(box,Face_1, "Face_1") +geompy.addToStudyInFather(box,Edge_1, "Edge_1") +geompy.addToStudyInFather(box,Vertex_1, "Vertex_1") + +geompy.addToStudyInFather(box ,Face_2, "Face_2") +geompy.addToStudyInFather(Face_2,Wire_1, "Wire_1") + +# create a mesh on the box +blsurfMesh = smesh.Mesh(box,"box: BLSurf mesh") + +# create a BLSurf algorithm for faces +algo2d = blsurfMesh.Triangle(algo=smesh.BLSURF) + +# ---------------------------------------------- +# blsurf_construct_mesh_sizemaps Adding sizemaps +# ---------------------------------------------- + +# optional - set physical mesh to 2 = Size Map +algo2d.SetPhysicalMesh( 2 ) + +# optional - set global mesh size +algo2d.SetPhySize( 34.641 ) + +# set size on Face_1 +algo2d.SetSizeMap(Face_1, 'def f(u,v): return 10' ) +# set size on Edge_1 +algo2d.SetSizeMap(Edge_1, 'def f(t): return 5' ) +# set size on Vertex_1 +algo2d.SetSizeMap(Vertex_1, 'def f(): return 2' ) + +# compute the mesh +blsurfMesh.Compute() + +# ---------------------------------------------------------------- +# blsurf_construct_mesh_enforced_vertices Adding enforced vertices +# ---------------------------------------------------------------- + +# Add enforced vertex for Face_1 on (50, 50, 50) +# The projection coordinates will be (50, 50, 0) +algo2d.SetEnforcedVertex(Face_1, 50, 50, 50) + +# Add another enforced vertex on (150, 150, 150) +algo2d.SetEnforcedVertex(Face_1, 150, 150, 150) + +# Retrieve and print the list of enforced vertices defines on Face_1 +enfList = algo2d.GetEnforcedVertices(Face_1) +print "List of enforced vertices for Face_1: " +print enfList + +# compute the mesh +blsurfMesh.Compute() + +# Remove an enforced vertex and print the list +algo2d.UnsetEnforcedVertex(Face_1, 50, 50, 50) +enfList = algo2d.GetEnforcedVertices(Face_1) +print "List of enforced vertices for Face_1: " +print enfList + +# compute the mesh +blsurfMesh.Compute() + +# Remove all enforced vertices defined on Face_1 +algo2d.UnsetEnforcedVertices(Face_1) + +# compute the mesh +blsurfMesh.Compute() + +# --------------------------------------------------- +# blsurf_construct_mesh_attractor Adding an attractor +# --------------------------------------------------- + +# Add an attractor on Face_2, which shape is Wire_1 + +# The size on Wire_1 is 1 and will grow until a maximum of 36.641 (physical size set above) +# The influence distance of the attractor is 20 +# The size is kept constant until a distance of 10 +algo2d.SetAttractorGeom(Face_2, Wire_1, 1, 36.641, 20, 10) + +# In order to let the attractor control the growing of the mesh let set +# the gradation to its maximum +algo2d.SetGradation( 2.5 ) + +# compute the mesh +blsurfMesh.Compute() + +# --------------------------------------------------------------- +# blsurf_construct_mesh_internal_vertices Using internal vertices +# --------------------------------------------------------------- + +# Creating a geometry containing internal vertices +Face_3 = geompy.MakeFaceHW(1, 1, 1) +Vertex_2 = geompy.MakeVertex(0.2, 0.2, 0) +Partition_1 = geompy.MakePartition([Face_3, Vertex_2], [], [], [], geompy.ShapeType["FACE"], 0, [], 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +Multi_Translation_1 = geompy.MakeMultiTranslation2D(Partition_1, OX, 1, 10, OY, 1, 10) +geompy.addToStudy( Face_3, 'Face_3' ) +geompy.addToStudy( Vertex_2, 'Vertex_2' ) +geompy.addToStudy( Partition_1, 'Partition_1' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( Multi_Translation_1, 'Multi-Translation_1' ) + +# The mesh on the geometry with internal vertices +blsurfMesh_internal = smesh.Mesh(Multi_Translation_1, "blsurfMesh_internal") +algo2d = blsurfMesh_internal.Triangle(algo=smesh.BLSURF) +algo2d.SetPhySize( 0.1 ) + +# Allows BLSURF to take into account internal vertices +algo2d.SetInternalEnforcedVertexAllFaces( True ) + +# Add the created nodes into a group +algo2d.SetInternalEnforcedVertexAllFacesGroup( "my group" ) + +# compute the mesh +blsurfMesh_internal.Compute() + +# End of script diff --git a/doc/salome/gui/BLSURFPLUGIN/doxyfile.in b/doc/salome/gui/BLSURFPLUGIN/doxyfile.in index 1a8f9a5..5e07999 100755 --- a/doc/salome/gui/BLSURFPLUGIN/doxyfile.in +++ b/doc/salome/gui/BLSURFPLUGIN/doxyfile.in @@ -38,6 +38,7 @@ WARNINGS = YES INPUT = @srcdir@/input FILE_PATTERNS = *.doc IMAGE_PATH = @srcdir@/images +EXAMPLE_PATH = @top_srcdir@/doc/salome/examples #--------------------------------------------------------------------------- #HTML related options @@ -69,4 +70,9 @@ GENERATE_RTF = NO #rnv: 07.04.2011 Workaround for the doxygen 1.7.3: #because it wrongly defines location of the html files for search. TAGFILES = blsurfpluginpy_doc.tag=../BLSURFPLUGIN/blsurfpluginpy_doc -SEARCHENGINE = YES \ No newline at end of file +SEARCHENGINE = YES + +#--------------------------------------------------------------------------- +#Custom commands +#--------------------------------------------------------------------------- +ALIASES += tui_script{1}="\include \1 Download this script" diff --git a/doc/salome/gui/BLSURFPLUGIN/doxyfile_py.in b/doc/salome/gui/BLSURFPLUGIN/doxyfile_py.in index 8b69b6a..ba2ad04 100755 --- a/doc/salome/gui/BLSURFPLUGIN/doxyfile_py.in +++ b/doc/salome/gui/BLSURFPLUGIN/doxyfile_py.in @@ -97,7 +97,8 @@ EXAMPLE_RECURSIVE = NO #Input related options #--------------------------------------------------------------------------- INPUT = @top_srcdir@/src/BLSURFPlugin/BLSURFPluginBuilder.py \ - @SMESH_ROOT_DIR@/bin/salome/smesh_algorithm.py + @SMESH_ROOT_DIR@/lib/python@PYTHON_VERSION@/site-packages/salome/salome/smesh/smeshBuilder.py \ + @SMESH_ROOT_DIR@/lib/python@PYTHON_VERSION@/site-packages/salome/salome/smesh/smesh_algorithm.py FILE_PATTERNS = IMAGE_PATH = @srcdir@/images RECURSIVE = NO diff --git a/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc b/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc index 0f81912..3ee0b8f 100644 --- a/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc +++ b/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc @@ -2,9 +2,9 @@ \page blsurfplugin_python_interface_page Python Interface -Python package BLSURFPluginBuilder defines several classes, destined for creation of the 2D meshes. +Python package BLSURFPlugin defines several classes, destined for creation of the 2D meshes. -BLSURF meshing plugin dynamically adds several methods to the smesh.Mesh class to create meshing algorithms. +BLSURF meshing plugin dynamically adds several methods to the \ref SMESH_SWIG.smeshBuilder.Mesh "class Mesh" to create meshing algorithms. Below you can see an example of usage of the BLSURFPlugin Python API for mesh generation: @@ -12,148 +12,8 @@ Below you can see an example of usage of the BLSURFPlugin Python API for mesh ge \section blsurf_construct_mesh Construction of Mesh using BLSurf algorithm -\subsection blsurf_construct_mesh_basic_hypo Basic hypothesis -\code -import geompy -import smesh -import BLSURFPlugin - -# create a box -box = geompy.MakeBoxDXDYDZ(200., 200., 200.) -geompy.addToStudy(box, "box") - -# get sub-shapes -Face_1 = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[0] -Edge_1 = geompy.SubShapeAllSorted(box, geompy.ShapeType["EDGE"])[0] -Vertex_1 = geompy.SubShapeAllSorted(box, geompy.ShapeType["VERTEX"])[0] - -Face_2 = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])[5] -Wire_1 = geompy.SubShapeAllSorted(Face_2, geompy.ShapeType["WIRE"])[0] - -# Geom object with sizemaps can be unpublished in study. -# They will then be automatically published. -geompy.addToStudyInFather(box,Face_1, "Face_1") -geompy.addToStudyInFather(box,Edge_1, "Edge_1") -geompy.addToStudyInFather(box,Vertex_1, "Vertex_1") - -geompy.addToStudyInFather(box ,Face_2, "Face_2") -geompy.addToStudyInFather(Face_2,Wire_1, "Wire_1") - -# create a mesh on the box -blsurfMesh = smesh.Mesh(box,"box: BLSurf mesh") - -# create a BLSurf algorithm for faces -algo2d = blsurfMesh.Triangle(algo=smesh.BLSURF) - -# End of script -\endcode - -\subsection blsurf_construct_mesh_sizemaps Adding sizemaps -\code -# optional - set physical mesh to 2 = Size Map -algo2d.SetPhysicalMesh( 2 ) - -# optional - set global mesh size -algo2d.SetPhySize( 34.641 ) - -# set size on Face_1 -algo2d.SetSizeMap(Face_1, 'def f(u,v): return 10' ) -# set size on Edge_1 -algo2d.SetSizeMap(Edge_1, 'def f(t): return 5' ) -# set size on Vertex_1 -algo2d.SetSizeMap(Vertex_1, 'def f(): return 2' ) - -# compute the mesh -blsurfMesh.Compute() - -# End of script -\endcode - -\subsection blsurf_construct_mesh_enforced_vertices Adding enforced vertices -\code -# Add enforced vertex for Face_1 on (50, 50, 50) -# The projection coordinates will be (50, 50, 0) -algo2d.SetEnforcedVertex(Face_1, 50, 50, 50) - -# Add another enforced vertex on (150, 150, 150) -algo2d.SetEnforcedVertex(Face_1, 150, 150, 150) - -# Retrieve and print the list of enforced vertices defines on Face_1 -enfList = algo2d.GetEnforcedVertices(Face_1) -print "List of enforced vertices for Face_1: " -print enfList - -# compute the mesh -blsurfMesh.Compute() - -# Remove an enforced vertex and print the list -algo2d.UnsetEnforcedVertex(Face_1, 50, 50, 50) -enfList = algo2d.GetEnforcedVertices(Face_1) -print "List of enforced vertices for Face_1: " -print enfList - -# compute the mesh -blsurfMesh.Compute() - -# Remove all enforced vertices defined on Face_1 -algo2d.UnsetEnforcedVertices(Face_1) - -# compute the mesh -blsurfMesh.Compute() - -# End of script -\endcode - -\subsection blsurf_construct_mesh_attractor Adding an attractor -\code -# Add an attractor on Face_2, which shape is Wire_1 - -# The size on Wire_1 is 1 and will grow until a maximum of 36.641 (physical size set above) -# The influence distance of the attractor is 20 -# The size is kept constant until a distance of 10 -algo2d.SetAttractorGeom(Face_2, Wire_1, 1, 36.641, 20, 10) - -# In order to let the attractor control the growing of the mesh let set -# the gradation to its maximum -algo2d.SetGradation( 2.5 ) - -# compute the mesh -blsurfMesh.Compute() - -# End of script -\endcode - -\subsection blsurf_construct_mesh_internal_vertices Using internal vertices -\code -# Creating a geometry containing internal vertices -Face_3 = geompy.MakeFaceHW(1, 1, 1) -Vertex_2 = geompy.MakeVertex(0.2, 0.2, 0) -Partition_1 = geompy.MakePartition([Face_3, Vertex_2], [], [], [], geompy.ShapeType["FACE"], 0, [], 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -Multi_Translation_1 = geompy.MakeMultiTranslation2D(Partition_1, OX, 1, 10, OY, 1, 10) -geompy.addToStudy( Face_3, 'Face_3' ) -geompy.addToStudy( Vertex_2, 'Vertex_2' ) -geompy.addToStudy( Partition_1, 'Partition_1' ) -geompy.addToStudy( OX, 'OX' ) -geompy.addToStudy( OY, 'OY' ) -geompy.addToStudy( Multi_Translation_1, 'Multi-Translation_1' ) - -# The mesh on the geometry with internal vertices -blsurfMesh_internal = smesh.Mesh(Multi_Translation_1, "blsurfMesh_internal") -algo2d = blsurfMesh_internal.Triangle(algo=smesh.BLSURF) -algo2d.SetPhySize( 0.1 ) - -# Allows BLSURF to take into account internal vertices -algo2d.SetInternalEnforcedVertexAllFaces( True ) - -# Add the created nodes into a group -algo2d.SetInternalEnforcedVertexAllFacesGroup( "my group" ) - -# compute the mesh -blsurfMesh_internal.Compute() - -# End of script -\endcode +\anchor example_BLSURFPlugin +

Example of mesh generation with BLSurf algorithm:

+\tui_script{blsurfdemo.py} */ -- 2.39.2