From 009772f8b3d74d414c19285447c6125f99369fc9 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 4 Apr 2013 07:09:59 +0000 Subject: [PATCH] Merge from BR_plugins_pbyacs 03/04/2013 --- configure.ac | 1 + doc/salome/Makefile.am | 2 +- doc/salome/examples/Makefile.am | 33 +++ doc/salome/examples/ghs3d_enfmesh.py | 107 +++++++++ doc/salome/examples/ghs3d_enfvert.py | 68 ++++++ doc/salome/examples/ghs3ddemo.py | 27 +++ doc/salome/gui/GHS3DPLUGIN/Makefile.am | 5 +- doc/salome/gui/GHS3DPLUGIN/doxyfile.in | 9 +- doc/salome/gui/GHS3DPLUGIN/doxyfile_py.in | 6 +- .../input/ghs3dplugin_python_interface.doc | 204 +----------------- resources/GHS3DPlugin.xml | 2 +- ...GHS3DPluginDC.py => GHS3DPluginBuilder.py} | 6 +- src/GHS3DPlugin/Makefile.am | 6 +- src/GHS3DPlugin/__init__.py | 23 ++ 14 files changed, 290 insertions(+), 209 deletions(-) create mode 100644 doc/salome/examples/Makefile.am create mode 100644 doc/salome/examples/ghs3d_enfmesh.py create mode 100644 doc/salome/examples/ghs3d_enfvert.py create mode 100644 doc/salome/examples/ghs3ddemo.py rename src/GHS3DPlugin/{GHS3DPluginDC.py => GHS3DPluginBuilder.py} (98%) create mode 100644 src/GHS3DPlugin/__init__.py diff --git a/configure.ac b/configure.ac index 6708ddb..985d94b 100644 --- a/configure.ac +++ b/configure.ac @@ -425,6 +425,7 @@ AC_OUTPUT([ \ GHS3DPLUGIN_version.h \ doc/Makefile \ doc/salome/Makefile \ + doc/salome/examples/Makefile \ doc/salome/gui/Makefile \ doc/salome/gui/GHS3DPLUGIN/Makefile \ doc/salome/gui/GHS3DPLUGIN/doxyfile \ diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am index 9fd2b2d..f55ed01 100644 --- a/doc/salome/Makefile.am +++ b/doc/salome/Makefile.am @@ -17,7 +17,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SUBDIRS = gui +SUBDIRS = examples gui SUBDIRSGUI = gui usr_docs: diff --git a/doc/salome/examples/Makefile.am b/doc/salome/examples/Makefile.am new file mode 100644 index 0000000..2eab4ae --- /dev/null +++ b/doc/salome/examples/Makefile.am @@ -0,0 +1,33 @@ +# Copyright (C) 2007-2013 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/GHS3DPLUGIN + +pyexamples_SCRIPTS = ghs3ddemo.py \ + ghs3d_enfvert.py \ + ghs3d_enfmesh.py + +EXTRA_DIST += $(pyexamples_SCRIPTS) diff --git a/doc/salome/examples/ghs3d_enfmesh.py b/doc/salome/examples/ghs3d_enfmesh.py new file mode 100644 index 0000000..4da517e --- /dev/null +++ b/doc/salome/examples/ghs3d_enfmesh.py @@ -0,0 +1,107 @@ + +# It is possible to constrain GHS3D with another mesh or group. +# The constraint can refer to the nodes, edges or faces. +# This feature is available only on 2D meshes without geometry. +# The constraining elements are called enforced elements for the mesh. +# They can be recovered using groups if necessary. + +# In the following examples, a box and a cylinder are meshed in 2D. +# The mesh of the cylinder will be used as a constraint for the +# 3D mesh of the box. + +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) + +box = geompy.MakeBoxDXDYDZ(200, 200, 200) +geompy.addToStudy( box, "box" ) +cylindre = geompy.MakeCylinderRH(50, 50) +geompy.TranslateDXDYDZ(cylindre, 100, 100, 30) +face_cyl = geompy.ExtractShapes(cylindre, geompy.ShapeType["FACE"], True)[1] +geompy.addToStudy( cylindre, 'cylindre' ) +geompy.addToStudyInFather( cylindre, face_cyl, 'face_cyl' ) +p1 = geompy.MakeVertex(20, 20, 20) +p2 = geompy.MakeVertex(180, 180, 20) +c = geompy.MakeCompound([p1,p2]) +geompy.addToStudy( p1, "p1" ) +geompy.addToStudy( p2, "p2" ) +geompy.addToStudy( c, "c" ) + +# Create the 2D algorithm and hypothesis +BLSURF = smesh.CreateHypothesis('BLSURF', 'BLSURFEngine') +# For the box +BLSURF_Parameters = smesh.CreateHypothesis('BLSURF_Parameters', 'BLSURFEngine') +BLSURF_Parameters.SetPhysicalMesh( 1 ) +BLSURF_Parameters.SetPhySize( 200 ) +# For the cylinder +BLSURF_Parameters2 = smesh.CreateHypothesis('BLSURF_Parameters', 'BLSURFEngine') +BLSURF_Parameters2.SetGeometricMesh( 1 ) + +# Create the 3D algorithm and hypothesis +GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine') +GHS3D_Parameters_node = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +#GHS3D_Parameters_node.SetToMeshHoles( 1 ) +GHS3D_Parameters_edge = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +#GHS3D_Parameters_edge.SetToMeshHoles( 1 ) +GHS3D_Parameters_face = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +GHS3D_Parameters_face.SetToMeshHoles( 1 ) # to mesh inside the cylinder +GHS3D_Parameters_mesh = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +GHS3D_Parameters_mesh.SetToMeshHoles( 1 ) # to mesh inside the cylinder + +# Create the mesh on the cylinder +Mesh_cylindre = smesh.Mesh(cylindre) +smesh.SetName(Mesh_cylindre,"Mesh_cylindre") +Mesh_cylindre.AddHypothesis( BLSURF ) +Mesh_cylindre.AddHypothesis( BLSURF_Parameters2 ) +# Create some groups +face_cyl_faces = Mesh_cylindre.GroupOnGeom(face_cyl,'group_face_cyl', SMESH.FACE) +face_cyl_edges = Mesh_cylindre.GroupOnGeom(face_cyl,'group_edge_cyl', SMESH.EDGE) +face_cyl_nodes = Mesh_cylindre.GroupOnGeom(face_cyl,'group_node_cyl', SMESH.NODE) +Mesh_cylindre.Compute() + +# Create the mesh on the cylinder +Mesh_box_tri = smesh.Mesh(box) +smesh.SetName(Mesh_box_tri,"Mesh_box_tri") +Mesh_box_tri.AddHypothesis( BLSURF ) +Mesh_box_tri.AddHypothesis( BLSURF_Parameters ) +Mesh_box_tri.Compute() + +# Create 4 copies of the 2D mesh to test the 3 types of contraints (NODE, EDGE, FACE) +# from the whole mesh and from groups of elements. +# Then the 3D algo and hypothesis are assigned to them. + +mesh_mesh = smesh.CopyMesh( Mesh_box_tri, 'Enforced by faces of mesh', 0, 0) +mesh_mesh.AddHypothesis( GHS3D ) +mesh_mesh.AddHypothesis( GHS3D_Parameters_mesh) + +mesh_node = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of nodes', 0, 0) +mesh_node.AddHypothesis( GHS3D ) +mesh_node.AddHypothesis( GHS3D_Parameters_node) + +mesh_edge = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of edges', 0, 0) +mesh_edge.AddHypothesis( GHS3D ) +mesh_edge.AddHypothesis( GHS3D_Parameters_edge) + +mesh_face = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of faces', 0, 0) +mesh_face.AddHypothesis( GHS3D ) +mesh_face.AddHypothesis( GHS3D_Parameters_face) + +# Add the enforced elements +GHS3D_Parameters_mesh.SetEnforcedMeshWithGroup(Mesh_cylindre.GetMesh(),SMESH.FACE,"faces from cylinder") +GHS3D_Parameters_node.SetEnforcedMeshWithGroup(face_cyl_nodes,SMESH.NODE,"nodes from face_cyl_nodes") +GHS3D_Parameters_edge.SetEnforcedMeshWithGroup(face_cyl_edges,SMESH.EDGE,"edges from face_cyl_edges") +GHS3D_Parameters_face.SetEnforcedMeshWithGroup(face_cyl_faces,SMESH.FACE,"faces from face_cyl_faces") + +#Compute the meshes +mesh_node.Compute() +mesh_edge.Compute() +mesh_face.Compute() +mesh_mesh.Compute() + +# End of script diff --git a/doc/salome/examples/ghs3d_enfvert.py b/doc/salome/examples/ghs3d_enfvert.py new file mode 100644 index 0000000..319ca32 --- /dev/null +++ b/doc/salome/examples/ghs3d_enfvert.py @@ -0,0 +1,68 @@ + +# An enforced vertex can be added via: +# - the coordinates x,y,z +# - a GEOM vertex or compound (No geometry, TUI only) +# +# The created enforced nodes can also be stored in +# a group. +# +# This feature is available only on meshes without geometry. + +# Ex1: Add one enforced vertex with coordinates (50,50,100) +# and physical size 2. + +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") +# create a mesh on the box +ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh") +# create a BLSurf algorithm for faces +ghs3dMesh.Triangle(algo=smeshBuilder.BLSURF) +# compute the mesh +ghs3dMesh.Compute() + +# Make a copy of the 2D mesh +ghs3dMesh_wo_geometry = smesh.CopyMesh( ghs3dMesh, 'Ghs3D wo geometry', 0, 0) + +# create a Ghs3D algorithm and hypothesis and assign them to the mesh +GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine') +GHS3D_Parameters = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +ghs3dMesh.AddHypothesis( GHS3D ) +ghs3dMesh.AddHypothesis( GHS3D_Parameters ) +# Create the enforced vertex +GHS3D_Parameters.SetEnforcedVertex( 50, 50, 100, 2) # no group +# Compute the mesh +ghs3dMesh.Compute() + + +# Ex2: Add one vertex enforced by a GEOM vertex at (50,50,100) +# with physical size 5 and add it to a group called "My special nodes" + +# Create another GHS3D hypothesis and assign it to the mesh without geometry +GHS3D_Parameters_wo_geometry = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +ghs3dMesh_wo_geometry.AddHypothesis( GHS3D ) +ghs3dMesh_wo_geometry.AddHypothesis( GHS3D_Parameters_wo_geometry ) + +# Create the enforced vertex +p1 = geompy.MakeVertex(150, 150, 100) +geompy.addToStudy(p1, "p1") +GHS3D_Parameters_wo_geometry.SetEnforcedVertexGeomWithGroup( p1, 5 , "My special nodes") +#GHS3D_Parameters.SetEnforcedVertexGeom( p1, 5 ) # no group + +# compute the mesh +ghs3dMesh_wo_geometry.Compute() + +# Erase all enforced vertices +GHS3D_Parameters.ClearEnforcedVertices() + +# End of script diff --git a/doc/salome/examples/ghs3ddemo.py b/doc/salome/examples/ghs3ddemo.py new file mode 100644 index 0000000..2e43838 --- /dev/null +++ b/doc/salome/examples/ghs3ddemo.py @@ -0,0 +1,27 @@ + +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") + +# create a mesh on the box +ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh") + +# create a BLSurf algorithm for faces +BLSURF = ghs3dMesh.Triangle(algo=smeshBuilder.BLSURF) +GHS3D = ghs3dMesh.Tetrahedron(algo=smeshBuilder.GHS3D) + +# compute the mesh +ghs3dMesh.Compute() + +# End of script + diff --git a/doc/salome/gui/GHS3DPLUGIN/Makefile.am b/doc/salome/gui/GHS3DPLUGIN/Makefile.am index 84a38aa..c1fd421 100755 --- a/doc/salome/gui/GHS3DPLUGIN/Makefile.am +++ b/doc/salome/gui/GHS3DPLUGIN/Makefile.am @@ -27,10 +27,7 @@ DOC_PYTHONPATH=$(prefix)/bin/salome:$(SMESH_ROOT_DIR)/bin/salome:$(SMESH_ROOT_DI DOC_LD_LIBRARY_PATH=$(prefix)/lib/salome:${SMESH_ROOT_DIR}/lib/salome:${MED_ROOT_DIR}/lib/salome:${GEOM_ROOT_DIR}/lib/salome:${KERNEL_ROOT_DIR}/lib/salome DOC_SMESH_MeshersList=GHS3DPlugin -smesh.py: $(top_srcdir)/src/GHS3DPlugin/GHS3DPluginDC.py - @PYTHONPATH=$(DOC_PYTHONPATH):${PYTHONPATH} LD_LIBRARY_PATH=$(DOC_LD_LIBRARY_PATH):${LD_LIBRARY_PATH} SMESH_MeshersList=$(DOC_SMESH_MeshersList) $(PYTHON) $(SMESH_ROOT_DIR)/bin/salome/collect_mesh_methods.py -d -o $@ GHS3DPlugin - -usr_docs: doxyfile_py doxyfile smesh.py +usr_docs: doxyfile_py doxyfile @$(DOXYGEN) doxyfile_py ; \ $(DOXYGEN) doxyfile diff --git a/doc/salome/gui/GHS3DPLUGIN/doxyfile.in b/doc/salome/gui/GHS3DPLUGIN/doxyfile.in index cbb8f6a..46366d3 100755 --- a/doc/salome/gui/GHS3DPLUGIN/doxyfile.in +++ b/doc/salome/gui/GHS3DPLUGIN/doxyfile.in @@ -39,7 +39,7 @@ INPUT = @srcdir@/input FILE_PATTERNS = *.doc EXCLUDE = IMAGE_PATH = @srcdir@/images -EXAMPLE_PATH = +EXAMPLE_PATH = @top_srcdir@/doc/salome/examples #--------------------------------------------------------------------------- #HTML related options @@ -78,4 +78,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 = ghs3dpluginpy_doc.tag=../GHS3DPLUGIN/ghs3dpluginpy_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/GHS3DPLUGIN/doxyfile_py.in b/doc/salome/gui/GHS3DPLUGIN/doxyfile_py.in index 9a63aa6..e4e2f9d 100755 --- a/doc/salome/gui/GHS3DPLUGIN/doxyfile_py.in +++ b/doc/salome/gui/GHS3DPLUGIN/doxyfile_py.in @@ -96,9 +96,9 @@ EXAMPLE_RECURSIVE = NO #--------------------------------------------------------------------------- #Input related options #--------------------------------------------------------------------------- -INPUT = @top_srcdir@/src/GHS3DPlugin/GHS3DPluginDC.py \ - smesh.py \ - @SMESH_ROOT_DIR@/bin/salome/smesh_algorithm.py +INPUT = @top_srcdir@/src/GHS3DPlugin/GHS3DPluginBuilder.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/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc b/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc index 220bd07..73c4639 100644 --- a/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc +++ b/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc @@ -2,9 +2,9 @@ \page ghs3dplugin_python_interface_page Python Interface -Python package GHS3DPluginDC defines several classes, destined for creation of the 3D meshes. +Python package GHS3DPlugin defines several classes, destined for creation of the 3D meshes. -GHS3D meshing plugin dynamically adds several methods to the smesh.Mesh class to create meshing algorithms. +GHS3D meshing plugin dynamically adds several methods to the \ref SMESH_SWIG.smeshBuilder.Mesh "class Mesh" class to create meshing algorithms. Below you can see an example of usage of the GHS3DPlugin Python API for mesh generation: @@ -16,28 +16,10 @@ Below you can see an example of usage of the GHS3DPlugin Python API for mesh gen \section tui_ghs3d_basic Construction of Mesh using Ghs3D algorithm -\code -import geompy -import smesh -import BLSURFPlugin -import GHS3DPlugin +\anchor example_BLSURFPlugin +

Example of mesh generation with GHS3D algorithm:

+\tui_script{ghs3ddemo.py} -# create a box -box = geompy.MakeBoxDXDYDZ(200., 200., 200.) -geompy.addToStudy(box, "box") - -# create a mesh on the box -ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh") - -# create a BLSurf algorithm for faces -BLSURF = ghs3dMesh.Triangle(algo=smesh.BLSURF) -GHS3D = ghs3dMesh.Tetrahedron(algo=smesh.GHS3D) - -# compute the mesh -ghs3dMesh.Compute() - -# End of script -\endcode \image html ghs3d_screenshot.png Ghs3d mesh without hypothesis @@ -45,72 +27,9 @@ ghs3dMesh.Compute() \section tui_ghs3d_enforced_vertices Adding enforced vertices -\code - -# An enforced vertex can be added via: -# - the coordinates x,y,z -# - a GEOM vertex or compound (No geometry, TUI only) -# -# The created enforced nodes can also be stored in -# a group. -# -# This feature is available only on meshes without geometry. - -# Ex1: Add one enforced vertex with coordinates (50,50,100) -# and physical size 2. - -import geompy -import smesh -import BLSURFPlugin -import GHS3DPlugin - -# create a box -box = geompy.MakeBoxDXDYDZ(200., 200., 200.) -geompy.addToStudy(box, "box") -# create a mesh on the box -ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh") -# create a BLSurf algorithm for faces -ghs3dMesh.Triangle(algo=smesh.BLSURF) -# compute the mesh -ghs3dMesh.Compute() - -# Make a copy of the 2D mesh -ghs3dMesh_wo_geometry = smesh.CopyMesh( ghs3dMesh, 'Ghs3D wo geometry', 0, 0) - -# create a Ghs3D algorithm and hypothesis and assign them to the mesh -GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine') -GHS3D_Parameters = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') -ghs3dMesh.AddHypothesis( GHS3D ) -ghs3dMesh.AddHypothesis( GHS3D_Parameters ) -# Create the enforced vertex -GHS3D_Parameters.SetEnforcedVertex( 50, 50, 100, 2) # no group -# Compute the mesh -ghs3dMesh.Compute() - - -# Ex2: Add one vertex enforced by a GEOM vertex at (50,50,100) -# with physical size 5 and add it to a group called "My special nodes" - -# Create another GHS3D hypothesis and assign it to the mesh without geometry -GHS3D_Parameters_wo_geometry = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') -ghs3dMesh_wo_geometry.AddHypothesis( GHS3D ) -ghs3dMesh_wo_geometry.AddHypothesis( GHS3D_Parameters_wo_geometry ) - -# Create the enforced vertex -p1 = geompy.MakeVertex(150, 150, 100) -geompy.addToStudy(p1, "p1") -GHS3D_Parameters_wo_geometry.SetEnforcedVertexGeomWithGroup( p1, 5 , "My special nodes") -#GHS3D_Parameters.SetEnforcedVertexGeom( p1, 5 ) # no group - -# compute the mesh -ghs3dMesh_wo_geometry.Compute() - -# Erase all enforced vertices -GHS3D_Parameters.ClearEnforcedVertices() - -# End of script - -\endcode +

Example of enforced vertices with GHS3D algorithm:

+\tui_script{ghs3d_enfvert.py} + \image html ghs3d_screenshot_enf1.png Ghs3d mesh with enforced vertex \image html ghs3d_screenshot_enf2.png Ghs3d mesh with enforced vertex from GEOM vertex @@ -119,111 +38,8 @@ GHS3D_Parameters.ClearEnforcedVertices() \section tui_ghs3d_enforced_meshes Adding enforced mesh -\code - -# It is possible to constrain GHS3D with another mesh or group. -# The constraint can refer to the nodes, edges or faces. -# This feature is available only on 2D meshes without geometry. -# The constraining elements are called enforced elements for the mesh. -# They can be recovered using groups if necessary. - -# In the following examples, a box and a cylinder are meshed in 2D. -# The mesh of the cylinder will be used as a constraint for the -# 3D mesh of the box. - -import geompy -import smesh -import BLSURFPlugin -import GHS3DPlugin - -box = geompy.MakeBoxDXDYDZ(200, 200, 200) -geompy.addToStudy( box, "box" ) -cylindre = geompy.MakeCylinderRH(50, 50) -geompy.TranslateDXDYDZ(cylindre, 100, 100, 30) -face_cyl = geompy.ExtractShapes(cylindre, geompy.ShapeType["FACE"], True)[1] -geompy.addToStudy( cylindre, 'cylindre' ) -geompy.addToStudyInFather( cylindre, face_cyl, 'face_cyl' ) -p1 = geompy.MakeVertex(20, 20, 20) -p2 = geompy.MakeVertex(180, 180, 20) -c = geompy.MakeCompound([p1,p2]) -geompy.addToStudy( p1, "p1" ) -geompy.addToStudy( p2, "p2" ) -geompy.addToStudy( c, "c" ) - -# Create the 2D algorithm and hypothesis -BLSURF = smesh.CreateHypothesis('BLSURF', 'BLSURFEngine') -# For the box -BLSURF_Parameters = smesh.CreateHypothesis('BLSURF_Parameters', 'BLSURFEngine') -BLSURF_Parameters.SetPhysicalMesh( 1 ) -BLSURF_Parameters.SetPhySize( 200 ) -# For the cylinder -BLSURF_Parameters2 = smesh.CreateHypothesis('BLSURF_Parameters', 'BLSURFEngine') -BLSURF_Parameters2.SetGeometricMesh( 1 ) - -# Create the 3D algorithm and hypothesis -GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine') -GHS3D_Parameters_node = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') -#GHS3D_Parameters_node.SetToMeshHoles( 1 ) -GHS3D_Parameters_edge = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') -#GHS3D_Parameters_edge.SetToMeshHoles( 1 ) -GHS3D_Parameters_face = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') -GHS3D_Parameters_face.SetToMeshHoles( 1 ) # to mesh inside the cylinder -GHS3D_Parameters_mesh = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') -GHS3D_Parameters_mesh.SetToMeshHoles( 1 ) # to mesh inside the cylinder - -# Create the mesh on the cylinder -Mesh_cylindre = smesh.Mesh(cylindre) -smesh.SetName(Mesh_cylindre,"Mesh_cylindre") -Mesh_cylindre.AddHypothesis( BLSURF ) -Mesh_cylindre.AddHypothesis( BLSURF_Parameters2 ) -# Create some groups -face_cyl_faces = Mesh_cylindre.GroupOnGeom(face_cyl,'group_face_cyl', smesh.FACE) -face_cyl_edges = Mesh_cylindre.GroupOnGeom(face_cyl,'group_edge_cyl', smesh.EDGE) -face_cyl_nodes = Mesh_cylindre.GroupOnGeom(face_cyl,'group_node_cyl', smesh.NODE) -Mesh_cylindre.Compute() - -# Create the mesh on the cylinder -Mesh_box_tri = smesh.Mesh(box) -smesh.SetName(Mesh_box_tri,"Mesh_box_tri") -Mesh_box_tri.AddHypothesis( BLSURF ) -Mesh_box_tri.AddHypothesis( BLSURF_Parameters ) -Mesh_box_tri.Compute() - -# Create 4 copies of the 2D mesh to test the 3 types of contraints (NODE, EDGE, FACE) -# from the whole mesh and from groups of elements. -# Then the 3D algo and hypothesis are assigned to them. - -mesh_mesh = smesh.CopyMesh( Mesh_box_tri, 'Enforced by faces of mesh', 0, 0) -mesh_mesh.AddHypothesis( GHS3D ) -mesh_mesh.AddHypothesis( GHS3D_Parameters_mesh) - -mesh_node = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of nodes', 0, 0) -mesh_node.AddHypothesis( GHS3D ) -mesh_node.AddHypothesis( GHS3D_Parameters_node) - -mesh_edge = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of edges', 0, 0) -mesh_edge.AddHypothesis( GHS3D ) -mesh_edge.AddHypothesis( GHS3D_Parameters_edge) - -mesh_face = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of faces', 0, 0) -mesh_face.AddHypothesis( GHS3D ) -mesh_face.AddHypothesis( GHS3D_Parameters_face) - -# Add the enforced elements -GHS3D_Parameters_mesh.SetEnforcedMeshWithGroup(Mesh_cylindre.GetMesh(),smesh.FACE,"faces from cylinder") -GHS3D_Parameters_node.SetEnforcedMeshWithGroup(face_cyl_nodes,smesh.NODE,"nodes from face_cyl_nodes") -GHS3D_Parameters_edge.SetEnforcedMeshWithGroup(face_cyl_edges,smesh.EDGE,"edges from face_cyl_edges") -GHS3D_Parameters_face.SetEnforcedMeshWithGroup(face_cyl_faces,smesh.FACE,"faces from face_cyl_faces") - -#Compute the meshes -mesh_node.Compute() -mesh_edge.Compute() -mesh_face.Compute() -mesh_mesh.Compute() - -# End of script - -\endcode +

Example of enforced meshes with GHS3D algorithm:

+\tui_script{ghs3d_enfmesh.py} \image html ghs3d_screenshot_enf3.png \image html ghs3d_screenshot_enf4.png diff --git a/resources/GHS3DPlugin.xml b/resources/GHS3DPlugin.xml index fcea00f..144cb6d 100644 --- a/resources/GHS3DPlugin.xml +++ b/resources/GHS3DPlugin.xml @@ -61,7 +61,7 @@ opt-hypos="GHS3D_Parameters, ViscousLayers" dim="3"> - GHS3D_3D=Tetrahedron(algo=smesh.GHS3D) + GHS3D_3D=Tetrahedron(algo=smeshBuilder.GHS3D) GHS3D_Parameters=Parameters() ViscousLayers=ViscousLayers(SetTotalThickness(),SetNumberLayers(),SetStretchFactor(),SetIgnoreFaces()) diff --git a/src/GHS3DPlugin/GHS3DPluginDC.py b/src/GHS3DPlugin/GHS3DPluginBuilder.py similarity index 98% rename from src/GHS3DPlugin/GHS3DPluginDC.py rename to src/GHS3DPlugin/GHS3DPluginBuilder.py index 3c1028b..daefa79 100644 --- a/src/GHS3DPlugin/GHS3DPluginDC.py +++ b/src/GHS3DPlugin/GHS3DPluginBuilder.py @@ -18,11 +18,11 @@ # ## -# @package GHS3DPluginDC +# @package GHS3DPluginBuilder # Python API for the GHS3D meshing plug-in module. -from smesh_algorithm import Mesh_Algorithm -from smesh import AssureGeomPublished +from salome.smesh.smesh_algorithm import Mesh_Algorithm +from salome.smesh.smeshBuilder import AssureGeomPublished # import GHS3DPlugin module if possible noGHS3DPlugin = 0 diff --git a/src/GHS3DPlugin/Makefile.am b/src/GHS3DPlugin/Makefile.am index f6a9005..4af27ab 100644 --- a/src/GHS3DPlugin/Makefile.am +++ b/src/GHS3DPlugin/Makefile.am @@ -63,4 +63,8 @@ libGHS3DEngine_la_LDFLAGS = \ $(KERNEL_LDFLAGS) -lSalomeGenericObj -lSALOMELocalTrace -lSALOMEBasics -lSalomeNS -lOpUtil # Scripts to be installed. -dist_salomescript_DATA= GHS3DPluginDC.py +#dist_salomescript_DATA= GHS3DPluginDC.py +mypkgpythondir = $(salomepythondir)/salome/GHS3DPlugin +mypkgpython_PYTHON = \ + __init__.py \ + GHS3DPluginBuilder.py diff --git a/src/GHS3DPlugin/__init__.py b/src/GHS3DPlugin/__init__.py new file mode 100644 index 0000000..72bdea5 --- /dev/null +++ b/src/GHS3DPlugin/__init__.py @@ -0,0 +1,23 @@ +# Copyright (C) 2007-2013 CEA/DEN, EDF R&D +# +# 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 +# + +## +# @package GHS3DPluginBuilder +# Python API for the GHS3D meshing plug-in module. + -- 2.39.2