From: boulant Date: Tue, 8 Nov 2011 10:13:50 +0000 (+0000) Subject: Finalize SMESH/padder integration (with tests and documentation) X-Git-Tag: RELIQUAT_6x_15112011~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0f838b96446dfd41a90e833cb3af4dbaf865fb7f;p=modules%2Fsmesh.git Finalize SMESH/padder integration (with tests and documentation) --- diff --git a/configure.ac b/configure.ac index e3d0d097c..e1922bfe9 100644 --- a/configure.ac +++ b/configure.ac @@ -549,6 +549,8 @@ AC_OUTPUT([ \ src/Tools/padder/resources/padderexe/envPadder.sh \ src/Tools/padder/unittests/Makefile \ src/Tools/padder/unittests/autotest.sh \ + src/Tools/padder/doc/Makefile \ + src/Tools/padder/doc/doxyfile \ resources/Makefile \ resources/SMESHCatalog.xml \ resources/SalomeApp.xml \ diff --git a/src/Tools/Makefile.am b/src/Tools/Makefile.am index 08a35c7c4..8191cf8a9 100644 --- a/src/Tools/Makefile.am +++ b/src/Tools/Makefile.am @@ -25,7 +25,7 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am -#SUBDIRS = MeshCut padder -SUBDIRS = MeshCut +SUBDIRS = MeshCut padder +#SUBDIRS = MeshCut DIST_SUBDIRS = MeshCut diff --git a/src/Tools/padder/Makefile.am b/src/Tools/padder/Makefile.am index 95b82b7cf..9cf8a0a4e 100644 --- a/src/Tools/padder/Makefile.am +++ b/src/Tools/padder/Makefile.am @@ -1 +1 @@ -SUBDIRS = meshjob spadderpy unittests resources +SUBDIRS = meshjob spadderpy unittests resources doc diff --git a/src/Tools/padder/doc/Makefile.am b/src/Tools/padder/doc/Makefile.am new file mode 100755 index 000000000..d5c4468f0 --- /dev/null +++ b/src/Tools/padder/doc/Makefile.am @@ -0,0 +1,92 @@ +# Copyright (C) 2007-2011 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 +# + +# Author : Guillaume Boulant (EDF/R&D) + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +EXTRA_DIST += images input + +# +# The simplest way to extends the documentation of SMESH with the +# documentation for PADDER is to copy the local source files (*.doc +# and *.png) in the source directory of SMESH documentation. Theses +# pages will be automagically included in the SMESH documentation +# generating process (make usr_docs executed at installation step) and +# will be inserted in the page pages.html that lists the "Related +# pages". +# + +DOC_FILES = \ + padder_userguide.doc + +DOCDIR=$(top_srcdir)/doc/salome/gui/SMESH/input + +IMG_FILES = \ + SMESH_spadder_end.png \ + SMESH_spadder_inputdialog_concrete.png \ + SMESH_spadder_inputdialog_start.png \ + SMESH_spadder_inputdialog_steelbar.png \ + SMESH_spadder_menu.png \ + SMESH_spadder_plugindialog_compute_finished.png \ + SMESH_spadder_plugindialog_compute_ready.png \ + SMESH_spadder_plugindialog_compute_running.png \ + SMESH_spadder_plugindialog_published.png \ + SMESH_spadder_plugindialog_start.png \ + SMESH_spadder_start.png + + +IMGDIR=$(top_srcdir)/doc/salome/gui/SMESH/images + + +all: + @mkdir -p $(DOCDIR); \ + for docfile in $(DOC_FILES); do \ + if [ ! -h $(DOCDIR)/$${docfile} ]; then \ + echo "Linking file $${docfile} to $(DOCDIR)/$${docfile}"; \ + ln -s ../$(srcdir)/input/$${docfile} $(DOCDIR)/$${docfile}; \ + fi; \ + done; \ + for imgfile in $(IMG_FILES); do \ + if [ ! -h $(IMGDIR)/$${imgfile} ]; then \ + echo "Linking file $${imgfile} to $(IMGDIR)/$${imgfile}"; \ + ln -s ../$(srcdir)/images/$${imgfile} $(IMGDIR)/$${imgfile}; \ + fi; \ + done; + +clean-local: + @ls | grep -v -e Makefile -e doxyfile | xargs rm -rf; \ + for docfile in $(DOC_FILES); do \ + echo "Removing file $${docfile} from $(DOCDIR)"; \ + rm $(DOCDIR)/$${docfile}; \ + done; \ + for imgfile in $(IMG_FILES); do \ + echo "Removing file $${imgfile} from $(IMGDIR)"; \ + rm $(IMGDIR)/$${imgfile}; \ + done; + +# +# For test purpose, we let the user generate a local dosygen +# documentation including only the local pages +# +test_docs: doxyfile + echo "===========================================" ; \ + echo "Generating PADDER documentation" ; \ + echo "===========================================" ; \ + $(DOXYGEN) doxyfile ; diff --git a/src/Tools/padder/doc/doxyfile.in b/src/Tools/padder/doc/doxyfile.in new file mode 100755 index 000000000..8f2aa2ac2 --- /dev/null +++ b/src/Tools/padder/doc/doxyfile.in @@ -0,0 +1,77 @@ +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# 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 +# + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "SALOME Mesh User's Guide" +OUTPUT_DIRECTORY = . +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +TAB_SIZE = 5 + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES + +#--------------------------------------------------------------------------- +#Input related options +#--------------------------------------------------------------------------- +INPUT = @srcdir@/input +FILE_PATTERNS = *.doc +EXCLUDE = +IMAGE_PATH = @srcdir@/images +EXAMPLE_PATH = @top_srcdir@/src/SMESH_SWIG + +#--------------------------------------------------------------------------- +#HTML related options +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = . +HTML_HEADER = @top_builddir@/doc/salome/gui/SMESH/static/header.html +HTML_FOOTER = @top_srcdir@/doc/salome/gui/SMESH/static/footer.html +HTML_STYLESHEET = @top_srcdir@/doc/salome/gui/SMESH/static/doxygen.css +TOC_EXPAND = YES +DISABLE_INDEX = NO +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 300 + +#--------------------------------------------------------------------------- +#SORT related options +#--------------------------------------------------------------------------- +SORT_GROUP_NAMES = NO + + +#--------------------------------------------------------------------------- +#LaTeX related option +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +EXTRA_PACKAGES = amsmath + +#--------------------------------------------------------------------------- +#RTF related options +#--------------------------------------------------------------------------- +GENERATE_RTF = NO + +SEARCHENGINE = YES diff --git a/src/Tools/padder/doc/images/SMESH_spadder_end.png b/src/Tools/padder/doc/images/SMESH_spadder_end.png new file mode 100644 index 000000000..12e2b7cf2 Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_end.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_concrete.png b/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_concrete.png new file mode 100644 index 000000000..ed0a8a72c Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_concrete.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_start.png b/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_start.png new file mode 100644 index 000000000..8725d7165 Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_start.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_steelbar.png b/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_steelbar.png new file mode 100644 index 000000000..8e692dcff Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_inputdialog_steelbar.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_menu.png b/src/Tools/padder/doc/images/SMESH_spadder_menu.png new file mode 100644 index 000000000..e89140690 Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_menu.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_finished.png b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_finished.png new file mode 100644 index 000000000..e29cf5634 Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_finished.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_ready.png b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_ready.png new file mode 100644 index 000000000..f86790b0c Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_ready.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_running.png b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_running.png new file mode 100644 index 000000000..b3c9ef169 Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_compute_running.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_published.png b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_published.png new file mode 100644 index 000000000..19e1ae71f Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_published.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_start.png b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_start.png new file mode 100644 index 000000000..45ba1a097 Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_plugindialog_start.png differ diff --git a/src/Tools/padder/doc/images/SMESH_spadder_start.png b/src/Tools/padder/doc/images/SMESH_spadder_start.png new file mode 100644 index 000000000..160da9d26 Binary files /dev/null and b/src/Tools/padder/doc/images/SMESH_spadder_start.png differ diff --git a/src/Tools/padder/doc/input/padder_userguide.doc b/src/Tools/padder/doc/input/padder_userguide.doc new file mode 100644 index 000000000..d92f85ef6 --- /dev/null +++ b/src/Tools/padder/doc/input/padder_userguide.doc @@ -0,0 +1,139 @@ +/*! + +\page padder_userguide_page Use the padder SMESH Plugin + +-# \ref S1_PADDER +-# \ref S2_PADDER +-# \ref S3_PADDER + +\section S1_PADDER The PADDER Algorithm + +PADDER is an algorithm that creates a set of particules called a "discrete mesh". +The particules are characterized by a location in space and a weight that can be considered +as the radius of a sphere whose center is the location of the particule. + +Discrete meshes are typically used to modelize civil components in rapid dynamic +computation problems (seisms, chocs). These components consists in concrete parts +embedding steal bares for reinforcement. These parts are input to the algorithm +as standard finite elements meshes. The cells of theses meshes drive the location +and sizing of particules. + +In the med representation, a discrete mesh is described as MED_BALL elements. +A MED_BALL element is defined by a location and a radius. + +\section S2_PADDER The PADDER SALOME plugin + +The PADDER algoritm is integrated in the module SMESH as a SALOME +plugin. This section illustrates how to use this plugin to create a +discrete mesh. + +In this example, we suppose that two standard meshes (Finite Elements +Meshes) have been created and publish in the study to modelize the +concrete part (here with the name "concrete") and the steal bars part +(here with the name "ferrail"): + +\image html SMESH_spadder_start.png + +The PADDER plugin can be invoked from the SMESH plugins menu, as +illustrated on the figure below: + +\image html SMESH_spadder_menu.png + +When you clic on the "PADDER mesher" item, the graphical interface of +the PADDER plugin appears: + +\image html SMESH_spadder_plugindialog_start.png + +This interface invites you to specify input data by pressing the button +"Input". This command opens the Input dialog box to specify the list +of meshes and the type of the selected meshes (to be choosen between +"concrete" or "steelbar" using the combobox on the right side of the +input line): + +\image html SMESH_spadder_inputdialog_start.png + +In the figure below, the mesh with name "concrete" has been selected +in the study and added in the list of input file as a "concrete +mesh". You have to input the mesh in the dialog using the rounded +arrow icon, then specify a group name (the name of the group of +MED_BALL created for this mesh in the resulting mesh), and finnaly +clic on the "Add" icon: + +\image html SMESH_spadder_inputdialog_concrete.png + +Then, the mesh with name "ferrail" is selected and added to the list +as a "steelbar mesh": + +\image html SMESH_spadder_inputdialog_steelbar.png + +The input dialog box can be validated toreturn to the main plugin +interface. The "Compute" button is now enable, indicating that the +problem is ready to be computed: + +\image html SMESH_spadder_plugindialog_compute_ready.png + +The command "Compute" start the job. The progression can be requested +using the command "Refresh". In the figure below, the job is still +running: + +\image html SMESH_spadder_plugindialog_compute_running.png + +Finally, the job is finished and the result is ready to be published +in the SALOME study: + +\image html SMESH_spadder_plugindialog_compute_finished.png + +Clic on the command "Publish" to explicitly import the resulting med +file in SMESH and published the resulting mesh in the SALOME study: + +\image html SMESH_spadder_plugindialog_published.png + +Note that this mesh contains one group for each of the input mesh. A +group with the name specified in the input dialog has been defined for +the set of MED_BALL created from the corresponding input mesh: + +\image html SMESH_spadder_end.png + +\section S3_PADDER Configuring the plugin + +The configuration of the plugin consists in specifying the location of +the padder executable program for each of the SALOME resource (at +least for the localhost resource). This specification is done in the +file padder.cfg, located in the plugin installation folder +(i.e. /plugins): + +\code +# This section specify the configurations to be used respectively for +# the local execution and the remote execution. The value for 'local' +# and 'remote' keys must be the name of a configuration section in +# this file. The default key must specify a value between "local" or +# "remote" to indicate the user preference. +[resources] +local = localhost +remote = nepal + +[preferences] +defaultres = local + +# The following sections defines the available configurations. +# The name of the section can be choosen arbitrary. But the value of +# the resname key MUST be the name of a SALOME resource defined in the +# catalog of resources (CatalogResources.xml). + +# For each section: +# - resname : the name of the SALOME resource to be used in this configuration +# - binpath : the path to the padder executable program on this resource +# - envpath : the path to the environment file on this resource +[localhost] +resname = localhost +binpath = /home/.programs/salome/workspace/V6_4_BR/SMESH/install/share/salome/resources/smesh/padderexe/padder.exe +envpath = /home/.programs/salome/workspace/V6_4_BR/SMESH/install/share/salome/resources/smesh/padderexe/envPadder.sh + +[nepal] +resname = nepal@nepal +binpath = /usr/local/bin/padder.exe +envpath = /usr/local/share/envPadder.sh +\endcode + +*/ + diff --git a/src/Tools/padder/meshjob/idl/Makefile.am b/src/Tools/padder/meshjob/idl/Makefile.am index 3c2ebc7d5..1f6ae9af2 100644 --- a/src/Tools/padder/meshjob/idl/Makefile.am +++ b/src/Tools/padder/meshjob/idl/Makefile.am @@ -24,11 +24,12 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am -BUILT_SOURCES = \ - MESHJOBSK.cc +BUILT_SOURCES = MESHJOBSK.cc +IDL_FILES = MESHJOB.idl -IDL_FILES = \ - MESHJOB.idl +# For test purpose, we add a little component: +BUILT_SOURCES += SPADDERPluginTestSK.cc +IDL_FILES += SPADDERPluginTest.idl salomeidl_DATA = $(IDL_FILES) diff --git a/src/Tools/padder/meshjob/idl/SPADDERPluginTest.idl b/src/Tools/padder/meshjob/idl/SPADDERPluginTest.idl new file mode 100644 index 000000000..6f04f0104 --- /dev/null +++ b/src/Tools/padder/meshjob/idl/SPADDERPluginTest.idl @@ -0,0 +1,46 @@ +// Copyright (C) 2011 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 +// +// Authors : Guillaume Boulant (EDF) - 31/01/2011 + +#ifndef _SPADDERPLUGINTEST_IDL_ +#define _SPADDERPLUGINTEST_IDL_ + +#include "SALOME_Exception.idl" +#include "SALOME_Component.idl" + +module SPADDERPluginTest { + + // + // ======================================================================== + // Thi module defines an interface provided for testing the usage + // of SPADDERPlugin components and underlying classes from within a + // C++ unit test running in a SALOME container (easy to run from a + // python client).. + // ======================================================================== + // + + interface SPADDERPluginTester: Engines::EngineComponent + { + void demo(in double a,in double b,out double c) raises (SALOME::SALOME_Exception); + boolean testkernel() raises (SALOME::SALOME_Exception); + boolean testsmesh(in long studyId) raises (SALOME::SALOME_Exception); + }; +}; + +#endif // _SPADDERPLUGINTEST_IDL_ diff --git a/src/Tools/padder/meshjob/impl/Makefile.am b/src/Tools/padder/meshjob/impl/Makefile.am index 7ef6c2e40..065882b3e 100644 --- a/src/Tools/padder/meshjob/impl/Makefile.am +++ b/src/Tools/padder/meshjob/impl/Makefile.am @@ -15,26 +15,56 @@ salomeinclude_HEADERS= \ libMeshJobManagerEngine_la_SOURCES = \ MeshJobManager_i.cxx - -LIBXML_INCLUDES=@LIBXML_INCLUDES@ LIBXML_LIBS=@LIBXML_LIBS@ KERNEL_CXXFLAGS=@KERNEL_CXXFLAGS@ -#KERNEL_LIBS=@KERNEL_LDFLAGS@ -lSalomeContainer -lOpUtil -lSalomeDSCContainer -lSalomeDSCSuperv -lSalomeDatastream -lSalomeDSCSupervBasic -lCalciumC -lSalomeKernelHelpers -KERNEL_LIBS = \ - @KERNEL_LDFLAGS@ \ - -lSalomeContainer - -# -lSalomeLauncher -lSalomeKernelHelpers \ -# -lSalomeGenericObj -lSalomeIDLKernel - -OMNIORB_CXXFLAGS= libMeshJobManagerEngine_la_CXXFLAGS = \ -I$(builddir)/../idl $(KERNEL_CXXFLAGS) \ - @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \ - $(LIBXML_INCLUDES) + @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @LIBXML_INCLUDES@ +libMeshJobManagerEngine_la_FFLAGS = -fexceptions libMeshJobManagerEngine_la_LDFLAGS = \ $(builddir)/../idl/libSalomeIDLSPADDER.la \ - $(KERNEL_LIBS) \ - $(LIBXML_LIBS) + @KERNEL_LDFLAGS@ -lSalomeContainer -lSalomeKernelHelpers \ + @LIBXML_LIBS@ + +# ============================================================= +# Definition of the SPADDERPluginTester engine construction +# ============================================================= +lib_LTLIBRARIES += libSPADDERPluginTesterEngine.la + +libSPADDERPluginTesterEngine_la_SOURCES = \ + SPADDERPluginTester_i.cxx + +nodist_libSPADDERPluginTesterEngine_la_SOURCES = + +libSPADDERPluginTesterEngine_la_CXXFLAGS = \ + -I$(builddir)/../idl $(KERNEL_CXXFLAGS) \ + @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @LIBXML_INCLUDES@ + +libSPADDERPluginTesterEngine_la_FFLAGS = -fexceptions +libSPADDERPluginTesterEngine_la_LIBADD = \ + $(builddir)/../idl/libSalomeIDLSPADDER.la \ + @KERNEL_LDFLAGS@ -lSalomeContainer -lSalomeKernelHelpers \ + @LIBXML_LIBS@ + + +# For testing SMESH +# +libSPADDERPluginTesterEngine_la_CXXFLAGS += \ + @GEOM_CXXFLAGS@ @MED_CXXFLAGS@ \ + -I$(top_builddir)/idl \ + -I$(top_srcdir)/src/SMESH \ + -I$(top_srcdir)/src/SMESH_I \ + -I$(top_srcdir)/src/SMESHDS \ + -I$(top_srcdir)/src/SMDS \ + -I$(top_srcdir)/src/SMESHUtils \ + $(VTK_INCLUDES) $(CAS_CPPFLAGS) + +libSPADDERPluginTesterEngine_la_LIBADD += \ + $(top_builddir)/src/SMESH/libSMESHimpl.la \ + $(top_builddir)/src/SMESH_I/libSMESHEngine.la \ + $(top_builddir)/src/SMESHDS/libSMESHDS.la \ + $(top_builddir)/src/SMDS/libSMDS.la \ + $(top_builddir)/src/SMESHUtils/libSMESHUtils.la + diff --git a/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx b/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx index b2917df82..4825d8f3d 100644 --- a/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx +++ b/src/Tools/padder/meshjob/impl/MeshJobManager_i.cxx @@ -28,8 +28,6 @@ #undef LOG #define LOG STDLOG -#include "testhelper.hxx" - // // ==================================================================== // General purpose helper functions (to put elsewhere at least) diff --git a/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.cxx b/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.cxx new file mode 100644 index 000000000..ae4f8cd32 --- /dev/null +++ b/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.cxx @@ -0,0 +1,151 @@ +// Copyright (C) 2007-2010 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 + +#include "SPADDERPluginTester_i.hxx" + +#include +#include + +// For standard logging +#include "Basics_Utils.hxx" + +// +// ========================================================================== +// Implementation of the SPADDER component interface +// ========================================================================== +// +using namespace std; + +/*! + * Constructor for component "SPADDER" instance + */ +SPADDERPluginTester_i::SPADDERPluginTester_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + : Engines_Component_i(orb, poa, contId, instanceName, interfaceName) +{ + LOG("Activating SPADDERPluginTester_i::SPADDERPluginTester object"); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +} + +//! Destructor for component "SPADDER" instance +SPADDERPluginTester_i::~SPADDERPluginTester_i() +{ + std::cerr << "SPADDERPluginTester destruction" << std::endl; +} + +/*! + * This test is just to check the component SPADDER. + */ +void SPADDERPluginTester_i::demo(CORBA::Double a,CORBA::Double b,CORBA::Double& c) +{ + beginService("SPADDERPluginTester_i::demo"); + try { + //BODY + + std::cerr << "a: " << a << std::endl; + std::cerr << "b: " << b << std::endl; + c=a+b; + std::cerr << "c: " << c << std::endl; + + } + catch ( const SALOME_Exception & ex) { + SALOME::ExceptionStruct es; + es.text=CORBA::string_dup(ex.what()); + es.type=SALOME::INTERNAL_ERROR; + throw SALOME::SALOME_Exception(es); + } + catch ( const SALOME::SALOME_Exception & ex) { + throw; + } + catch (...) { + std::cerr << "unknown exception" << std::endl; + SALOME::ExceptionStruct es; + es.text=CORBA::string_dup(" unknown exception"); + es.type=SALOME::INTERNAL_ERROR; + throw SALOME::SALOME_Exception(es); + } + endService("SPADDERPluginTester_i::demo"); +} + +#include +#include "SALOME_Launcher.hxx" +bool SPADDERPluginTester_i::testkernel() +{ + beginService("SPADDERPluginTester_i::testplugin"); + + Engines::SalomeLauncher_ptr salomeLauncher = KERNEL::getSalomeLauncher(); + + endService("SPADDERPluginTester_i::testplugin"); + return true; +} + + +#include +#include +#include +#include CORBA_CLIENT_HEADER(SALOMEDS) + +#include + +/*! + * This test checks the constructor of the basic classes of the SMESH + * plugin for PADDER. + */ +bool SPADDERPluginTester_i::testsmesh(CORBA::Long studyId) +{ + beginService("SPADDERPluginTester_i::testsmesh"); + + // Resolve the SMESH engine and the SALOME study + // _WARN_ The SMESH engine should have been loaded first + SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject); + SALOMEDS::Study_var myStudy = aStudyMgr->GetStudyByID(studyId); + + // + // _MEM_ CAUTION: SMESH_Gen define a data structure for local usage + // while SMESH_Gen_i is the implementation of the SMESH_Gen IDL + // interface. + // + + endService("SPADDERPluginTester_i::testsmesh"); + return true; +} + +// +// ========================================================================== +// Factory services +// ========================================================================== +// +extern "C" +{ + PortableServer::ObjectId * SPADDERPluginTesterEngine_factory( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("PortableServer::ObjectId * SPADDERPluginTesterEngine_factory()"); + SPADDERPluginTester_i * myEngine = new SPADDERPluginTester_i(orb, poa, contId, instanceName, interfaceName); + return myEngine->getId() ; + } +} diff --git a/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.hxx b/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.hxx new file mode 100644 index 000000000..85a02a94f --- /dev/null +++ b/src/Tools/padder/meshjob/impl/SPADDERPluginTester_i.hxx @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2010 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 +// +// Authors : Guillaume Boulant (EDF) - 01/02/2011 + +#ifndef _SPADDER_PLUGINTESTER_HXX_ +#define _SPADDER_PLUGINTESTER_HXX_ + +// include the stubs generating from SPADDERPluginTest.idl +#include +#include CORBA_SERVER_HEADER(SPADDERPluginTest) +#include +#include "SALOME_Component_i.hxx" + +class SPADDERPluginTester_i: + public virtual POA_SPADDERPluginTest::SPADDERPluginTester, + public Engines_Component_i +{ +public: + SPADDERPluginTester_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, const char *interfaceName); + virtual ~SPADDERPluginTester_i(); + + void demo(CORBA::Double a,CORBA::Double b,CORBA::Double& c); + bool testkernel(); + bool testsmesh(CORBA::Long studyId); + +}; + +#endif + diff --git a/src/Tools/padder/meshjob/impl/testhelper.hxx b/src/Tools/padder/meshjob/impl/testhelper.hxx index 7ce0646a5..76e233258 100644 --- a/src/Tools/padder/meshjob/impl/testhelper.hxx +++ b/src/Tools/padder/meshjob/impl/testhelper.hxx @@ -1,27 +1,38 @@ #ifndef __TESTHELPER_HXX__ #define __TESTHELPER_HXX__ +// >>> +// WARN: this file is DEPRECATED and/or should be used for test +// purpose only. The PADDER configuration is now read in a +// configuration file (padder.cfg). +// <<< + #include // Standard C include (for getenv) #include #include /*! - * This function returns the module SPADDER installation root - * directory as a string. + * This function returns the module SMESH installation root directory + * as a string. */ -static std::string SPADDER_ROOT_DIR() { - static std::string * spadder_root_dir; - if ( spadder_root_dir == NULL ) { - char * SPADDER_ROOT_DIR = getenv("SPADDER_ROOT_DIR"); - spadder_root_dir = new std::string(SPADDER_ROOT_DIR); +static std::string SMESH_ROOT_DIR() { + static std::string * smesh_root_dir; + if ( smesh_root_dir == NULL ) { + char * SMESH_ROOT_DIR = getenv("SMESH_ROOT_DIR"); + if ( SMESH_ROOT_DIR == NULL ) { + smesh_root_dir = new std::string(""); + } + else { + smesh_root_dir = new std::string(SMESH_ROOT_DIR); + } } - return *spadder_root_dir; + return *smesh_root_dir; } /*! Relative path of the directory containing data and exe for tests */ -static std::string PADDEREXE_RPATH("/share/salome/resources/spadder/padderexe"); +static std::string PADDEREXE_RPATH("/share/salome/resources/smesh/padderexe"); /*! Absolute path of the directory containing data and exe for tests */ -static std::string PADDEREXE_APATH(SPADDER_ROOT_DIR()+PADDEREXE_RPATH); +static std::string PADDEREXE_APATH(SMESH_ROOT_DIR()+PADDEREXE_RPATH); /*! Absolute path of the exe shell script for tests */ static std::string PADDEREXE_SCRIPT_FILENAME(PADDEREXE_APATH+"/padder.sh"); diff --git a/src/Tools/padder/resources/SPADDERCatalog.xml b/src/Tools/padder/resources/SPADDERCatalog.xml index 756375666..4e4cafe42 100644 --- a/src/Tools/padder/resources/SPADDERCatalog.xml +++ b/src/Tools/padder/resources/SPADDERCatalog.xml @@ -9,5 +9,8 @@ MeshJobManager + + SPADDERPluginTester + diff --git a/src/Tools/padder/spadderpy/__init__.py b/src/Tools/padder/spadderpy/__init__.py index 1a2c26a6a..a134daf95 100644 --- a/src/Tools/padder/spadderpy/__init__.py +++ b/src/Tools/padder/spadderpy/__init__.py @@ -87,3 +87,7 @@ def loadSpadderCatalog(): filename = getSpadderCatalogFilename() catalog.ImportXmlCatalogFile(filename) + + from salome.kernel import services + print "The list of SALOME components is now:" + print services.getComponentList() diff --git a/src/Tools/padder/spadderpy/gui/plugindialog.py b/src/Tools/padder/spadderpy/gui/plugindialog.py index 51902be66..26a2d7ca8 100644 --- a/src/Tools/padder/spadderpy/gui/plugindialog.py +++ b/src/Tools/padder/spadderpy/gui/plugindialog.py @@ -22,7 +22,7 @@ # Author : Guillaume Boulant (EDF) # -from PyQt4.QtGui import QDialog, QMessageBox, QIcon +from PyQt4.QtGui import QDialog, QIcon from PyQt4.QtCore import QObject, SIGNAL, SLOT, Qt from plugindialog_ui import Ui_PluginDialog @@ -35,6 +35,7 @@ from inputdata import InputData import os import salome from salome.kernel import studyedit +from salome.kernel.uiexception import AdminException from omniORB import CORBA import SMESH @@ -106,6 +107,8 @@ class PluginDialog(QDialog): the initialize step, by specifing the name of the resource to be used. ''' + # We first + configReader = ConfigReader() config = configReader.getLocalConfig() configId = config.resname @@ -173,12 +176,28 @@ class PluginDialog(QDialog): def __getJobManager(self): """ - This function requests a pointer to the MeshJobManager servant. + This function requests a pointer to the MeshJobManager + servant. Note that the component is loaded on first demand, + and then the reference is recycled. """ + if self.__dict__.has_key("__jobManager") and self.__jobManager is not None: + return self.__jobManager + + # WARN: we first have to update the SALOME components catalog + # with the SPADDER components (because they are not defined in + # the SMESH catalog, and then they are not in the default + # catalog) + from salome.smesh import spadder + spadder.loadSpadderCatalog() + # Then we can load the MeshJobManager component component=salome.lcc.FindOrLoadComponent("FactoryServer","MeshJobManager") if component is None: - self.__log("ERR: the SALOME component MeshJobManager can't be reached") - return component + msg="ERR: the SALOME component MeshJobManager can't be reached" + self.__log(msg) + raise AdminException(msg) + + self.__jobManager = component + return self.__jobManager def __log(self, message): """ @@ -237,9 +256,9 @@ class PluginDialog(QDialog): # from the dialog window. self.__listInputData = self.__inputDialog.getData() self.__ui.lblStatusBar.setText("Input data OK") + self.__log("INF: Press \"Compute\" to start the job") self.__setGuiState(["CAN_SELECT", "CAN_COMPUTE"]) - def onCompute(self): ''' This function is the slot connected to the Compute button. It diff --git a/src/Tools/padder/spadderpy/gui/plugindialog.ui b/src/Tools/padder/spadderpy/gui/plugindialog.ui index 69b65f65d..c6af08f68 100644 --- a/src/Tools/padder/spadderpy/gui/plugindialog.ui +++ b/src/Tools/padder/spadderpy/gui/plugindialog.ui @@ -1,118 +1,126 @@ - + + PluginDialog - - + + + true + + 0 0 - 417 + 649 367 - + Create a mesh with PADDER - - - 9 - - + + 6 + + 9 + - - - 0 - - + + 6 + + 0 + - - + + QFrame::Raised - + 1 - + 0 - - - 9 - - + + 6 + + 9 + - - - 0 - - + + 6 + + 0 + - + - - - 0 - - + + 6 + + 0 + - - + + Input - - parameters.png + + + parameters.pngparameters.png - - + + Compute - - compute.png + + + compute.pngcompute.png - - + + Refresh - - refresh.png + + + refresh.pngrefresh.png - - + + Publish - - publish.png + + + publish.pngpublish.png - + Qt::Vertical - + 75 101 @@ -121,12 +129,13 @@ - - + + Clear - - clear.png + + + clear.pngclear.png @@ -135,17 +144,17 @@ - - + + true - + QFrame::StyledPanel - + QFrame::Sunken - + diff --git a/src/Tools/padder/spadderpy/padder.cfg.in b/src/Tools/padder/spadderpy/padder.cfg.in index d1ef795b4..9a8f5e1dd 100644 --- a/src/Tools/padder/spadderpy/padder.cfg.in +++ b/src/Tools/padder/spadderpy/padder.cfg.in @@ -21,8 +21,8 @@ defaultres = local # - envpath : the path to the environment file on this resource [localhost] resname = localhost -binpath = @prefix@/share/salome/resources/spadder/padderexe/padder.exe -envpath = @prefix@/share/salome/resources/spadder/padderexe/envPadder.sh +binpath = @prefix@/share/salome/resources/smesh/padderexe/padder.exe +envpath = @prefix@/share/salome/resources/smesh/padderexe/envPadder.sh [venus] resname = gboulant@venus diff --git a/src/Tools/padder/spadderpy/plugin/Makefile.am b/src/Tools/padder/spadderpy/plugin/Makefile.am index 3fbef14d3..871ef1323 100644 --- a/src/Tools/padder/spadderpy/plugin/Makefile.am +++ b/src/Tools/padder/spadderpy/plugin/Makefile.am @@ -6,7 +6,7 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am # plugins and created in the root installation directory. # salomeplugins_PYTHON = \ - salome_plugins.py + smesh_plugins.py salomeplugins_DATA = \ envPlugins.sh diff --git a/src/Tools/padder/spadderpy/plugin/salome_plugins.py b/src/Tools/padder/spadderpy/plugin/salome_plugins.py index 62ad634d7..cff860725 100755 --- a/src/Tools/padder/spadderpy/plugin/salome_plugins.py +++ b/src/Tools/padder/spadderpy/plugin/salome_plugins.py @@ -26,8 +26,17 @@ import salome_pluginsmanager def runSpadderPlugin(context): from salome.smesh.spadder.gui import plugindialog - dialog=plugindialog.getDialog() - dialog.update() + from salome.kernel.uiexception import UiException + try: + dialog=plugindialog.getDialog() + except UiException, err: + from PyQt4.QtGui import QMessageBox + QMessageBox.critical(None, + "An error occurs during PADDER configuration", + err.getUIMessage()) + return + + dialog.update() dialog.show() salome_pluginsmanager.AddFunction('PADDER mesher', diff --git a/src/Tools/padder/spadderpy/plugin/smesh_plugins.py b/src/Tools/padder/spadderpy/plugin/smesh_plugins.py new file mode 100755 index 000000000..cff860725 --- /dev/null +++ b/src/Tools/padder/spadderpy/plugin/smesh_plugins.py @@ -0,0 +1,45 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2011 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 +# +# -* Makefile *- +# +# Author : Guillaume Boulant (EDF) +# +import salome_pluginsmanager + + +def runSpadderPlugin(context): + from salome.smesh.spadder.gui import plugindialog + from salome.kernel.uiexception import UiException + try: + dialog=plugindialog.getDialog() + except UiException, err: + from PyQt4.QtGui import QMessageBox + QMessageBox.critical(None, + "An error occurs during PADDER configuration", + err.getUIMessage()) + return + + dialog.update() + dialog.show() + +salome_pluginsmanager.AddFunction('PADDER mesher', + 'Create a mesh with PADDER', + runSpadderPlugin) + diff --git a/src/Tools/padder/unittests/Makefile.am b/src/Tools/padder/unittests/Makefile.am index 33d0b5900..af904826d 100644 --- a/src/Tools/padder/unittests/Makefile.am +++ b/src/Tools/padder/unittests/Makefile.am @@ -2,9 +2,10 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am spadderpydir=$(smeshpypkgdir)/spadder/unittests -spadderpy_PYTHON = \ - __init__.py \ - usecase_meshJobManager.py +spadderpy_PYTHON = \ + __init__.py \ + usecase_meshJobManager.py \ + usecase_spadderPluginTester.py spadderbindir=$(bindir)/spadder spadderbin_SCRIPTS = \ diff --git a/src/Tools/padder/unittests/usecase_meshJobManager.py b/src/Tools/padder/unittests/usecase_meshJobManager.py index e9e4a33ea..9b6011bab 100644 --- a/src/Tools/padder/unittests/usecase_meshJobManager.py +++ b/src/Tools/padder/unittests/usecase_meshJobManager.py @@ -44,6 +44,8 @@ import MESHJOB # from salome.smesh import spadder spadder.loadSpadderCatalog() + +salome.salome_init() component = salome.lcc.FindOrLoadComponent("FactoryServer","MeshJobManager") config = MESHJOB.ConfigParameter(resname="localhost", binpath=pathpadderexe, diff --git a/src/Tools/padder/unittests/usecase_spadderPluginTester.py b/src/Tools/padder/unittests/usecase_spadderPluginTester.py new file mode 100644 index 000000000..f21348d9e --- /dev/null +++ b/src/Tools/padder/unittests/usecase_spadderPluginTester.py @@ -0,0 +1,51 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2011 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 +# +# Author(s): Guillaume Boulant (23/03/2011) +# + +# This script illustrates the standard use case of the component +# SPADDERPluginTester from within a SALOME script. This component is +# dedicated to test purpose only + +import salome +import SPADDERPluginTest + +# We first have to update the SALOME components list by loading the +# SPADDER catalog (load on demand only) +from salome.smesh import spadder +spadder.loadSpadderCatalog() + +# Basic test +print "Basic tests" +c=salome.lcc.FindOrLoadComponent("FactoryServer","SPADDERPluginTester") +z=c.demo(2.,3.) + +# Test of usage of KERNEL services from the test component +print "Test of usage of KERNEL services from the test component" +c.testkernel() + +# Test of usage of SMESH engine from the test component +# WARN: the SMESH engine must be loaded first +print "Test of usage of SMESH engine from the test component" +import SMESH +salome.lcc.FindOrLoadComponent("FactoryServer","SMESH") +c.testsmesh(salome.myStudyId) + +print "Test completed : OK"