From: nge Date: Wed, 18 Feb 2009 13:32:33 +0000 (+0000) Subject: First version of SizeMap for BLSurf : X-Git-Tag: V0~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e8e567901e8f7dab7ca17ebc11372a604f204ef6;p=plugins%2Fblsurfplugin.git First version of SizeMap for BLSurf : Size maps can be defined on vertices, edges or faces. Implemented : - SizeMaps arguments passed to BLSurf - Persistence (hdf+dump) - can use python fonction (f(u,v) for a face, f(t) for an edge, f() for a vertex) - verification of this expression in gui (python syntax) and engine (python evaluation). - make dev_docs Limitation : - Objects have to be published to have size map defined on them. - does not compile with gcc 3.3 (Debian Sarge) - u,v / t used (Cascade ones) not very clear for user ...Still in development (SID)... --- diff --git a/Makefile.am b/Makefile.am index d5c2257..d3ca9b6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,9 +38,9 @@ else !BLSURFPLUGIN_ENABLE_GUI -I ${SMESH_ROOT_DIR}/adm_local/unix/config_files endif -SUBDIRS = idl adm_local resources src bin +SUBDIRS = idl adm_local resources src bin doc -DIST_SUBDIRS = idl adm_local resources src bin +DIST_SUBDIRS = idl adm_local resources src bin doc DISTCLEANFILES = a.out aclocal.m4 configure @@ -52,3 +52,12 @@ EXTRA_DIST += \ dist-hook: rm -rf `find $(distdir) -name CVS` + +usr_docs: + (cd doc && $(MAKE) $(AM_MAKEFLAGS) usr_docs) + +docs: usr_docs + +dev_docs: + (cd doc && $(MAKE) $(AM_MAKEFLAGS) dev_docs) + diff --git a/clean_configure b/clean_configure index 8f00366..0d23d94 100755 --- a/clean_configure +++ b/clean_configure @@ -32,6 +32,7 @@ find bin -name Makefile.in | xargs rm -f find doc -name Makefile.in | xargs rm -f find idl -name Makefile.in | xargs rm -f find resources -name Makefile.in | xargs rm -f -find salome_adm -name Makefile.in | xargs rm -f +find adm_local -name Makefile.in | xargs rm -f find src -name Makefile.in | xargs rm -f rm -f Makefile.in +rm -Rf salome_adm diff --git a/configure.ac b/configure.ac index 57c3fd7..612968f 100644 --- a/configure.ac +++ b/configure.ac @@ -400,11 +400,18 @@ AC_OUTPUT([ \ ./adm_local/Makefile \ ./adm_local/unix/Makefile \ ./adm_local/unix/config_files/Makefile \ + ./doc/Makefile \ + ./doc/salome/Makefile \ + ./doc/salome/gui/Makefile \ + ./doc/salome/gui/doxyfile \ + ./doc/salome/tui/Makefile \ + ./doc/salome/tui/doxyfile \ ./bin/VERSION \ ./bin/Makefile \ ./idl/Makefile \ ./resources/Makefile \ ./src/Makefile \ + ./src/PluginUtils/Makefile \ ./src/BLSURFPlugin/Makefile \ ./src/GUI/Makefile \ ./BLSURFPLUGIN_version.h \ diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..bf2a8e0 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,34 @@ +# Copyright (C) 2007-2008 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 +# +# -* Makefile *- +# Author : Patrick GOLDBRONN (CEA) +# Date : 30/11/2001 +# +SUBDIRS = salome + +usr_docs: + (cd salome && $(MAKE) $(AM_MAKEFLAGS) usr_docs) + +docs: usr_docs + +dev_docs: + (cd salome && $(MAKE) $(AM_MAKEFLAGS) dev_docs) diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am new file mode 100644 index 0000000..b17b95b --- /dev/null +++ b/doc/salome/Makefile.am @@ -0,0 +1,40 @@ +# Copyright (C) 2007-2008 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 +# +# -* Makefile *- +# Author : Patrick GOLDBRONN (CEA) +# Date : 30/11/2001 +# +SUBDIRS = tui gui +SUBDIRSTUI = tui +SUBDIRSGUI = gui + +usr_docs: + @@SETX@; for d in $(SUBDIRSGUI); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done; + +docs: usr_docs + +dev_docs: + @@SETX@; for d in $(SUBDIRSTUI); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done; diff --git a/doc/salome/gui/Makefile.am b/doc/salome/gui/Makefile.am new file mode 100644 index 0000000..61de9ca --- /dev/null +++ b/doc/salome/gui/Makefile.am @@ -0,0 +1,44 @@ +# Copyright (C) 2007-2008 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 +# +# File : Makefile.in +# Author : Vasily Rusyaev (Open Cascade NN) +# Module : doc +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +EXTRA_DIST += images input static + +usr_docs: doxyfile + echo "Running doxygen in directory: "`pwd`; \ + $(DOXYGEN) $< + +docs: usr_docs + +clean-local: + -rm -fr GUI doxygen.bak + +install-data-local: usr_docs + $(INSTALL) -d $(DESTDIR)$(docdir)/gui + cp -rp GUI $(DESTDIR)$(docdir)/gui + +uninstall-local: + rm -rf $(DESTDIR)$(docdir)/gui/GUI diff --git a/doc/salome/gui/doxyfile.in b/doc/salome/gui/doxyfile.in new file mode 100755 index 0000000..dd9ea65 --- /dev/null +++ b/doc/salome/gui/doxyfile.in @@ -0,0 +1,65 @@ +# Copyright (C) 2007-2008 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 = "GUI Module Reference Manual v.@VERSION@" +OUTPUT_DIRECTORY = GUI +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 +IMAGE_PATH = @srcdir@/images + +#--------------------------------------------------------------------------- +#HTML related options +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = . +HTML_HEADER = @srcdir@/static/header.html +HTML_FOOTER = @srcdir@/static/footer.html +#HTML_STYLESHEET = @srcdir@/static/doxygen.css +TOC_EXPAND = YES +DISABLE_INDEX = NO +GENERATE_TREEVIEW = YES +TREEVIEW_WIDTH = 300 + +#--------------------------------------------------------------------------- +#LaTeX related option +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO + +#--------------------------------------------------------------------------- +#RTF related options +#--------------------------------------------------------------------------- +GENERATE_RTF = NO \ No newline at end of file diff --git a/doc/salome/gui/static/footer.html b/doc/salome/gui/static/footer.html new file mode 100755 index 0000000..56d52a6 --- /dev/null +++ b/doc/salome/gui/static/footer.html @@ -0,0 +1,10 @@ + + + + + +
+
Copyright © 2003-2007 CEA, EDF
+
+ + diff --git a/doc/salome/gui/static/header.html b/doc/salome/gui/static/header.html new file mode 100755 index 0000000..a70a95e --- /dev/null +++ b/doc/salome/gui/static/header.html @@ -0,0 +1,12 @@ + + + + + $title + + +
+
+SALOME documentation central +
+
diff --git a/doc/salome/tui/Makefile.am b/doc/salome/tui/Makefile.am new file mode 100644 index 0000000..4b05cbf --- /dev/null +++ b/doc/salome/tui/Makefile.am @@ -0,0 +1,44 @@ +# Copyright (C) 2007-2008 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 +# +# File : Makefile.in +# Author : Vasily Rusyaev (Open Cascade NN) +# Module : doc +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +EXTRA_DIST += images static + +dev_docs: doxyfile + echo "Running doxygen in directory: "`pwd`; \ + $(DOXYGEN) $<; + +clean-local: + -rm -fr BLSURFPLUGIN doxygen.bak + +install-data-local: + if test -d BLSURFPLUGIN; then \ + $(INSTALL) -d $(DESTDIR)$(docdir)/tui ; \ + cp -rp BLSURFPLUGIN $(DESTDIR)$(docdir)/tui ; \ + fi; + +uninstall-local: + rm -rf $(DESTDIR)$(docdir)/tui/BLSURFPLUGIN diff --git a/doc/salome/tui/doxyfile.in b/doc/salome/tui/doxyfile.in new file mode 100755 index 0000000..3baf75b --- /dev/null +++ b/doc/salome/tui/doxyfile.in @@ -0,0 +1,263 @@ +# Copyright (C) 2007-2008 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 +# +# Doxyfile 1.4.6 + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "BLSURFPLUGIN Module Programming Guide v.@VERSION@" +PROJECT_NUMBER = +OUTPUT_DIRECTORY = BLSURFPLUGIN +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = NO +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = YES +INLINE_INHERITED_MEMB = YES +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = @top_srcdir@ @top_builddir@ +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = NO +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 5 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = YES +BUILTIN_STL_SUPPORT = @DOXYGEN_SUPPORT_STL@ +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = YES +HIDE_UNDOC_CLASSES = YES +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = YES +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = NO +SORT_BRIEF_DOCS = NO +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 25 +SHOW_USED_FILES = NO +SHOW_DIRECTORIES = NO +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = @top_srcdir@/src \ + @top_srcdir@/bin \ + @top_srcdir@/idl \ + @top_builddir@/bin +FILE_PATTERNS = *.idl *.hxx *.cxx *.h *.c *.hh *.cc @DOXYGEN_PYTHON_EXTENSION@ +RECURSIVE = YES +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = YES +IMAGE_PATH = @srcdir@/images +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = YES + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 3 +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = . +HTML_FILE_EXTENSION = .html +HTML_HEADER = @srcdir@/static/myheader.html +HTML_FOOTER = @srcdir@/static/footer.html +HTML_STYLESHEET = @srcdir@/static/doxygen.css +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = YES +TOC_EXPAND = YES +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = NO + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = NO +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = NO +GROUP_GRAPHS = NO +UML_LOOK = NO +TEMPLATE_RELATIONS = YES +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = NO +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = jpg +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1200 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = NO +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/doc/salome/tui/images/Application-About.png b/doc/salome/tui/images/Application-About.png new file mode 100755 index 0000000..7b58330 Binary files /dev/null and b/doc/salome/tui/images/Application-About.png differ diff --git a/doc/salome/tui/images/application.gif b/doc/salome/tui/images/application.gif new file mode 100755 index 0000000..0b05d5c Binary files /dev/null and b/doc/salome/tui/images/application.gif differ diff --git a/doc/salome/tui/images/html_comments.gif b/doc/salome/tui/images/html_comments.gif new file mode 100755 index 0000000..f0c0f0b Binary files /dev/null and b/doc/salome/tui/images/html_comments.gif differ diff --git a/doc/salome/tui/images/logocorp.gif b/doc/salome/tui/images/logocorp.gif new file mode 100755 index 0000000..7697e08 Binary files /dev/null and b/doc/salome/tui/images/logocorp.gif differ diff --git a/doc/salome/tui/static/doxygen.css b/doc/salome/tui/static/doxygen.css new file mode 100755 index 0000000..4893b5e --- /dev/null +++ b/doc/salome/tui/static/doxygen.css @@ -0,0 +1,152 @@ +H1 { + text-align: center; +} + +CAPTION { + font-weight: bold +} + +/* Link in the top navbar */ +A.qindex {} + +A.qindexRef {} + +/* Link to any cross-referenced Doxygen element */ +A.el { + text-decoration: none; + font-weight: bold +} + +A.elRef { + font-weight: bold +} + +/* Link to any cross-referenced Doxygen element inside a code section + (ex: header) +*/ +A.code { + text-decoration: none; + font-weight: normal; + color: #4444ee +} + +A.codeRef { + font-weight: normal; + color: #4444ee +} + +A:hover { + text-decoration: none; + background-color: lightblue +} + +DL.el { + margin-left: -1cm +} + +/* A code fragment (ex: header) */ +DIV.fragment { + width: 100%; + border: none; + background-color: #CCCCCC +} + +/* In the alpha list (coumpound index), style of an alphabetical index letter */ +DIV.ah { + background-color: #CCCCCC; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px +} + +/* Method name (+ type) */ +TD.md { + background-color: lightblue; + font-weight: bold; +} + +/* Method parameter (some of them) */ +TD.mdname1 { + background-color: lightblue; + font-weight: bold; color: #602020; +} + +/* Method parameter (some of them) */ +TD.mdname { + background-color: lightblue; + font-weight: bold; + color: #602020; + width: 600px; +} + +/* Separator between methods group (usually empty, seems not supported by IE) */ +DIV.groupHeader { + margin-left: 16px; + margin-top: 12px; + margin-bottom: 6px; + font-weight: bold +} + +DIV.groupText { + margin-left: 16px; + font-style: italic; + font-size: smaller +} + +BODY { background: #FFFFFF +} + +/* BODY { + background: url(sources/bg_salome.gif) +} */ + +div.tabs { + text-align: justify; + font-weight: bold; + color: #FFFFFF; +} + +DIV.div-footer { + margin-left: 1em; + margin-right: 1em; + margin-bottom: 0.2em; + text-align: right; + font-size: 9pt; +} + +/* In File List, Coumpound List, etc, 1st column of the index */ +TD.indexkey { + background-color: #CCCCCC; + font-weight: bold; + padding-right : 10px; + padding-top : 2px; + padding-left : 10px; + padding-bottom : 2px; + margin-left : 0px; + margin-right : 0px; + margin-top : 2px; + margin-bottom : 2px +} + +/* In File List, Coumpound List, etc, 2nd column of the index */ +TD.indexvalue { + background-color: #CCCCCC; + font-style: italic; + padding-right : 10px; + padding-top : 2px; + padding-left : 10px; + padding-bottom : 2px; + margin-left : 0px; + margin-right : 0px; + margin-top : 2px; + margin-bottom : 2px +} + +span.keyword { color: #008000 } +span.keywordtype { color: #604020 } +span.keywordflow { color: #e08000 } +span.comment { color: #800000 } +span.preprocessor { color: #806020 } +span.stringliteral { color: #002080 } +span.charliteral { color: #008080 } diff --git a/doc/salome/tui/static/footer.html b/doc/salome/tui/static/footer.html new file mode 100755 index 0000000..cb55f39 --- /dev/null +++ b/doc/salome/tui/static/footer.html @@ -0,0 +1,5 @@ + + + + diff --git a/doc/salome/tui/static/myheader.html b/doc/salome/tui/static/myheader.html new file mode 100755 index 0000000..d2efb75 --- /dev/null +++ b/doc/salome/tui/static/myheader.html @@ -0,0 +1,13 @@ + + + + + + Main Page + + + + +  + + diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 026602a..da90c24 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -25,6 +25,7 @@ #define _SMESH_BLSURFALGORITHM_IDL_ #include "SMESH_Hypothesis.idl" +#include "GEOM_Gen.idl" #include "SALOME_Exception.idl" /*! @@ -160,8 +161,19 @@ module BLSURFPlugin * Note: the method is mostly for interaction with GUI. */ void SetOptionValues(in string_array options); - }; + /*! + * SizeMap + */ + void SetSizeMapEntry(in string entry,in string sizeMap ); + string GetSizeMapEntry(in string entry); + void UnsetEntry(in string entry); + string_array GetSizeMapEntries(); + void SetSizeMapEntries(in string_array sizeMaps); + void ClearSizeMaps(); + void SetSizeMap(in GEOM::GEOM_Object GeomObj, in string sizeMap ); + void UnsetSizeMap(in GEOM::GEOM_Object GeomObj); + }; }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 39e7d49..7678717 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -25,9 +25,13 @@ #include "BLSURFPlugin_BLSURF.hxx" #include "BLSURFPlugin_Hypothesis.hxx" +#include + + #include #include #include +#include #include #include @@ -35,8 +39,11 @@ #include +#include #include #include +#include +#include #include #include @@ -68,6 +75,166 @@ extern "C"{ #include #endif +#include + + +/* =========== PYTHON ============== + * + * + * On est trop des brutes ! + * + * + * + * ==================================*/ + +typedef struct { + PyObject_HEAD + int softspace; + std::string *out; + } PyStdOut; + +static void +PyStdOut_dealloc(PyStdOut *self) +{ + PyObject_Del(self); +} + +static PyObject * +PyStdOut_write(PyStdOut *self, PyObject *args) +{ + char *c; + int l; + if (!PyArg_ParseTuple(args, "t#:write",&c, &l)) + return NULL; + + //std::cerr << c ; + *(self->out)=*(self->out)+c; + + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef PyStdOut_methods[] = { + {"write", (PyCFunction)PyStdOut_write, METH_VARARGS, + PyDoc_STR("write(string) -> None")}, + {NULL, NULL} /* sentinel */ +}; + +static PyMemberDef PyStdOut_memberlist[] = { + {"softspace", T_INT, offsetof(PyStdOut, softspace), 0, + "flag indicating that a space needs to be printed; used by print"}, + {NULL} /* Sentinel */ +}; + +static PyTypeObject PyStdOut_Type = { + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "PyOut", /*tp_name*/ + sizeof(PyStdOut), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PyStdOut_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + /* softspace is writable: we must supply tp_setattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + PyStdOut_methods, /*tp_methods*/ + PyStdOut_memberlist, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ +}; + +PyObject * newPyStdOut( std::string& out ) +{ + PyStdOut *self; + self = PyObject_New(PyStdOut, &PyStdOut_Type); + if (self == NULL) + return NULL; + self->softspace = 0; + self->out=&out; + return (PyObject*)self; +} + + +////////////////////////END PYTHON/////////////////////////// + + +//////////////////TO WELL DEFINE UNORDERED TOPODS_MAP//////// + +namespace std { +namespace tr1 { +template<> + struct hash + : public std::unary_function + { + std::size_t operator() (const TopoDS_Face & Face) const + { return Face.HashCode(471662);} + // { return Face.HashCode(std::numeric_limits::max());} +}; + +template<> + struct hash + : public std::unary_function + { + std::size_t operator() (const TopoDS_Edge & Edge) const + { return Edge.HashCode(471662);} + // { return Face.HashCode(std::numeric_limits::max());} +}; + +template<> + struct hash + : public std::unary_function + { + std::size_t operator() (const TopoDS_Vertex & Vertex) const + { return Vertex.HashCode(471662);} + // { return Face.HashCode(std::numeric_limits::max());} +}; +} +} + +//////////////////MY MAPS//////////////////////////////////////// +std::tr1::unordered_map Face2SizeMap; +std::tr1::unordered_map Edge2SizeMap; +std::tr1::unordered_map Vertex2SizeMap; +std::map FaceId2PythonSmp; +std::map EdgeId2PythonSmp; +std::map VertexId2PythonSmp; + + +bool HasSizeMapOnFace=false; +bool HasSizeMapOnEdge=false; +bool HasSizeMapOnVertex=false; + //============================================================================= /*! * @@ -86,6 +253,22 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, _requireDescretBoundary = false; _onlyUnaryInput = false; _hypothesis = NULL; + + + /* Initialize the Python interpreter */ + assert(Py_IsInitialized()); + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + + main_mod = NULL; + main_mod = PyImport_AddModule("__main__"); + + main_dict = NULL; + main_dict = PyModule_GetDict(main_mod); + + PyRun_SimpleString("from math import *"); + PyGILState_Release(gstate); + } //============================================================================= @@ -99,6 +282,7 @@ BLSURFPlugin_BLSURF::~BLSURFPlugin_BLSURF() MESSAGE("BLSURFPlugin_BLSURF::~BLSURFPlugin_BLSURF"); } + //============================================================================= /*! * @@ -165,6 +349,13 @@ inline std::string to_string(int i) return o.str(); } +double _smp_phy_size; +status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data); +status_t size_on_edge(integer edge_id, real t, real *size, void *user_data); +status_t size_on_vertex(integer vertex_id, real *size, void *user_data); + +double my_u_min=1e6,my_v_min=1e6,my_u_max=-1e6,my_v_max=-1e6; + void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls) { int _topology = BLSURFPlugin_Hypothesis::GetDefaultTopology(); @@ -177,7 +368,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu bool _quadAllowed = BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed(); bool _decimesh = BLSURFPlugin_Hypothesis::GetDefaultDecimesh(); int _verb = BLSURFPlugin_Hypothesis::GetDefaultVerbosity(); - + if (hyp) { MESSAGE("BLSURFPlugin_BLSURF::SetParameters"); _topology = (int) hyp->GetTopology(); @@ -213,13 +404,64 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu } else { MESSAGE("BLSURFPlugin_BLSURF::SetParameters using defaults"); } - + _smp_phy_size = _phySize; blsurf_set_param(bls, "topo_points", _topology > 0 ? "1" : "0"); blsurf_set_param(bls, "topo_curves", _topology > 0 ? "1" : "0"); blsurf_set_param(bls, "topo_project", _topology > 0 ? "1" : "0"); blsurf_set_param(bls, "clean_boundary", _topology > 1 ? "1" : "0"); blsurf_set_param(bls, "close_boundary", _topology > 1 ? "1" : "0"); blsurf_set_param(bls, "hphy_flag", to_string(_physicalMesh).c_str()); +// blsurf_set_param(bls, "hphy_flag", "2"); + if ((to_string(_physicalMesh))=="2"){ + MESSAGE("Setting a Size Map"); + const BLSURFPlugin_Hypothesis::TSizeMap & sizeMaps = hyp->GetSizeMapEntries(); + BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt; + GeomSelectionTools* GeomST; + GeomST=new GeomSelectionTools::GeomSelectionTools( SMESH::GetActiveStudyDocument()); + + Face2SizeMap.clear(); + Edge2SizeMap.clear(); + Vertex2SizeMap.clear(); + + for ( smIt = sizeMaps.begin(); smIt != sizeMaps.end(); ++smIt ) { + if ( !smIt->second.empty() ) { +#ifdef _DEBUG_ + cout << "blsurf_set_sizeMap(): " << smIt->first << " = " << smIt->second << endl; +#endif + TopoDS_Shape GeomShape=GeomST->entryToShape(smIt->first); + TopAbs_ShapeEnum GeomType= GeomShape.ShapeType(); + if (GeomType==TopAbs_FACE){ + HasSizeMapOnFace=true; + Face2SizeMap[TopoDS::Face(GeomShape)]= smIt->second; + } + if (GeomType==TopAbs_EDGE){ + HasSizeMapOnEdge=true; + HasSizeMapOnFace=true; + Edge2SizeMap[TopoDS::Edge(GeomShape)]= smIt->second; + } + if (GeomType==TopAbs_VERTEX){ + HasSizeMapOnVertex=true; + HasSizeMapOnEdge=true; + HasSizeMapOnFace=true; + Vertex2SizeMap[TopoDS::Vertex(GeomShape)]= smIt->second; + } + } + } +// if (HasSizeMapOnFace){ + // In all size map cases (hphy_flag = 2), at least map on face must be defined + std::cout << "Setting Size Map on FACES " << std::endl; + blsurf_data_set_sizemap_iso_cad_face(bls, size_on_surface, &_smp_phy_size); +// } + + if (HasSizeMapOnEdge){ + std::cout << "Setting Size Map on EDGES " << std::endl; + blsurf_data_set_sizemap_iso_cad_edge(bls, size_on_edge, &_smp_phy_size); + } + if (HasSizeMapOnVertex){ + std::cout << "Setting Size Map on VERTICES " << std::endl; + blsurf_data_set_sizemap_iso_cad_point(bls, size_on_vertex, &_smp_phy_size); + } + } blsurf_set_param(bls, "hphydef", to_string(_phySize).c_str()); blsurf_set_param(bls, "hgeo_flag", to_string(_geometricMesh).c_str()); blsurf_set_param(bls, "angle_meshs", to_string(_angleMeshS).c_str()); @@ -257,18 +499,37 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) cad_t *c = cad_new(ctx); + blsurf_session_t *bls = blsurf_session_new(ctx); + + + SetParameters(_hypothesis, bls); + TopTools_IndexedMapOfShape fmap; TopTools_IndexedMapOfShape emap; TopTools_IndexedMapOfShape pmap; vector curves; vector surfaces; + + fmap.Clear(); + FaceId2PythonSmp.clear(); emap.Clear(); + EdgeId2PythonSmp.clear(); pmap.Clear(); + VertexId2PythonSmp.clear(); surfaces.resize(0); curves.resize(0); + assert(Py_IsInitialized()); + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); +/* + Standard_Real u_min; + Standard_Real v_min; + Standard_Real u_max; + Standard_Real v_max; +*/ int iface = 0; for (TopExp_Explorer face_iter(aShape,TopAbs_FACE);face_iter.More();face_iter.Next()) { TopoDS_Face f=TopoDS::Face(face_iter.Current()); @@ -278,6 +539,19 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) fmap.Add(f); iface++; surfaces.push_back(BRep_Tool::Surface(f)); + // Get bound values of uv surface + //BRep_Tool::Surface(f)->Bounds(u_min,u_max,v_min,v_max); + //std::cout << "BRep_Tool::Surface(f)->Bounds(u_min,u_max,v_min,v_max): " << u_min << ", " << u_max << ", " << v_min << ", " << v_max << std::endl; + if ((HasSizeMapOnFace) && Face2SizeMap.find(f)!=Face2SizeMap.end()){ + // Expr To Python function, verification is performed at validation in GUI + PyObject * obj = NULL; + obj= PyRun_String(Face2SizeMap[f].c_str(), Py_file_input, main_dict, NULL); + Py_DECREF(obj); + PyObject * func = NULL; + func = PyObject_GetAttrString(main_mod, "f"); + FaceId2PythonSmp[iface]=func; + Face2SizeMap.erase(f); + } cad_face_t *fce = cad_face_new(c, iface, surf_fun, surfaces.back()); cad_face_set_tag(fce, iface); if(f.Orientation() != TopAbs_FORWARD){ @@ -294,6 +568,16 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) double tmin,tmax; curves.push_back(BRep_Tool::CurveOnSurface(e, f, tmin, tmax)); + if ((HasSizeMapOnEdge) && Edge2SizeMap.find(e)!=Edge2SizeMap.end()){ + // Expr To Python function, verification is performed at validation in GUI + PyObject * obj = NULL; + obj= PyRun_String(Edge2SizeMap[e].c_str(), Py_file_input, main_dict, NULL); + Py_DECREF(obj); + PyObject * func = NULL; + func = PyObject_GetAttrString(main_mod, "f"); + EdgeId2PythonSmp[ic]=func; + Edge2SizeMap.erase(e); + } cad_edge_t *edg = cad_edge_new(fce, ic, tmin, tmax, curv_fun, curves.back()); cad_edge_set_tag(edg, ic); cad_edge_set_property(edg, EDGE_PROPERTY_SOFT_REQUIRED); @@ -307,7 +591,6 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) Standard_Real d1=0,d2=0; for (TopExp_Explorer ex_edge(e ,TopAbs_VERTEX); ex_edge.More(); ex_edge.Next()) { TopoDS_Vertex v = TopoDS::Vertex(ex_edge.Current()); - ++npts; if (npts == 1){ ip = &ip1; @@ -319,6 +602,16 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) *ip = pmap.FindIndex(v); if(*ip <= 0) *ip = pmap.Add(v); + if ((HasSizeMapOnVertex) && Vertex2SizeMap.find(v)!=Vertex2SizeMap.end()){ + // Expr To Python function, verification is performed at validation in GUI + PyObject * obj = NULL; + obj= PyRun_String(Vertex2SizeMap[v].c_str(), Py_file_input, main_dict, NULL); + Py_DECREF(obj); + PyObject * func = NULL; + func = PyObject_GetAttrString(main_mod, "f"); + VertexId2PythonSmp[*ip]=func; + Vertex2SizeMap.erase(v); + } } if (npts != 2) { // should not happen @@ -333,13 +626,10 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) } //for face + PyGILState_Release(gstate); - - blsurf_session_t *bls = blsurf_session_new(ctx); blsurf_data_set_cad(bls, c); - SetParameters(_hypothesis, bls); - cout << endl; cout << "Beginning of Surface Mesh generation" << endl; cout << endl; @@ -384,6 +674,11 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) cout << "End of Surface Mesh generation" << endl; cout << endl; + cout << "****************** U MIN: " << my_u_min << endl; + cout << "****************** V MIN: " << my_v_min << endl; + cout << "****************** U MAX: " << my_u_max << endl; + cout << "****************** V MAX: " << my_v_max << endl; + mesh_t *msh; blsurf_data_get_mesh(bls, &msh); if(!msh){ @@ -604,6 +899,129 @@ status_t surf_fun(real *uv, real *xyz, real*du, real *dv, return 0; } + +status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data) +{ + if (face_id == 1) { + if (my_u_min > uv[0]) { + my_u_min = uv[0]; +// cout << "****************** FACE ID / U MIN: " << face_id << " / " << my_u_min << endl; + } + if (my_v_min > uv[1]) { + my_v_min = uv[1]; +// cout << "****************** FACE ID / V MIN: " << face_id << " / " << my_v_min << endl; + } + if (my_u_max < uv[0]) { + my_u_max = uv[0]; +// cout << "****************** FACE ID / U MAX: " << face_id << " / " << my_u_max << endl; + } + if (my_v_max < uv[1]) { + my_v_max = uv[1]; +// cout << "****************** FACE ID / V MAX: " << face_id << " / " << my_v_max << endl; + } + } + + if (FaceId2PythonSmp.count(face_id) != 0){ + PyObject * pyresult = NULL; + PyObject* new_stderr = NULL; + assert(Py_IsInitialized()); + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],"(f,f)",uv[0],uv[1]); + double result; + if ( pyresult == NULL){ + fflush(stderr); + string err_description=""; + new_stderr = newPyStdOut(err_description); + PySys_SetObject("stderr", new_stderr); + PyErr_Print(); + PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + Py_DECREF(new_stderr); + std::cout << "Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description << std::endl; + result = *((double*)user_data); + } + else { + result = PyFloat_AsDouble(pyresult); + Py_DECREF(pyresult); + } + *size = result; + //std::cout << "f(" << uv[0] << "," << uv[1] << ")" << " = " << result << std::endl; + PyGILState_Release(gstate); + } + else { + *size = *((double*)user_data); + } + return STATUS_OK; +} + +status_t size_on_edge(integer edge_id, real t, real *size, void *user_data) +{ + if (EdgeId2PythonSmp.count(edge_id) != 0){ + PyObject * pyresult = NULL; + PyObject* new_stderr = NULL; + assert(Py_IsInitialized()); + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + pyresult = PyObject_CallFunction(EdgeId2PythonSmp[edge_id],"(f)",t); + double result; + if ( pyresult == NULL){ + fflush(stderr); + string err_description=""; + new_stderr = newPyStdOut(err_description); + PySys_SetObject("stderr", new_stderr); + PyErr_Print(); + PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + Py_DECREF(new_stderr); + std::cout << "Can't evaluate f(" << t << ")" << " error is " << err_description << std::endl; + result = *((double*)user_data); + } + else { + result = PyFloat_AsDouble(pyresult); + Py_DECREF(pyresult); + } + *size = result; + PyGILState_Release(gstate); + } + else { + *size = *((double*)user_data); + } + return STATUS_OK; +} + +status_t size_on_vertex(integer point_id, real *size, void *user_data) +{ + if (VertexId2PythonSmp.count(point_id) != 0){ + PyObject * pyresult = NULL; + PyObject* new_stderr = NULL; + assert(Py_IsInitialized()); + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],""); + double result; + if ( pyresult == NULL){ + fflush(stderr); + string err_description=""; + new_stderr = newPyStdOut(err_description); + PySys_SetObject("stderr", new_stderr); + PyErr_Print(); + PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + Py_DECREF(new_stderr); + std::cout << "Can't evaluate f()" << " error is " << err_description << std::endl; + result = *((double*)user_data); + } + else { + result = PyFloat_AsDouble(pyresult); + Py_DECREF(pyresult); + } + *size = result; + PyGILState_Release(gstate); + } + else { + *size = *((double*)user_data); + } + return STATUS_OK; +} + status_t message_callback(message_t *msg, void *user_data) { integer errnumber = 0; diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 8dd022f..67eb80f 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -25,6 +25,7 @@ #ifndef _BLSURFPlugin_BLSURF_HXX_ #define _BLSURFPlugin_BLSURF_HXX_ +#include #include "SMESH_2D_Algo.hxx" #include "SMESH_Mesh.hxx" #include "Utils_SALOME_Exception.hxx" @@ -52,9 +53,14 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { istream & LoadFrom(istream & load); friend ostream & operator << (ostream & save, BLSURFPlugin_BLSURF & hyp); friend istream & operator >> (istream & load, BLSURFPlugin_BLSURF & hyp); - + protected: const BLSURFPlugin_Hypothesis* _hypothesis; + + private: + PyObject * main_mod; + PyObject * main_dict; + }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index ad35365..d22a941 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -24,6 +24,7 @@ // #include #include +#include //============================================================================= BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, @@ -120,6 +121,8 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, _charOptions.insert( charOptionNames[i] ); _option2value[ charOptionNames[i++] ].clear(); } + + _sizeMap.clear(); } //============================================================================= @@ -333,6 +336,41 @@ void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) op_val->second.clear(); } + +void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry,const std::string& sizeMap) +{ + if (_sizeMap[entry].compare(sizeMap) != 0) { + _sizeMap[entry]=sizeMap; + NotifySubMeshesHypothesisModification(); + } +} + +std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) +{ + TSizeMap::iterator it = _sizeMap.find( entry ); + if ( it != _sizeMap.end() ) + return it->second; + else + return "No_Such_Entry"; +} + +void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry) +{ + TSizeMap::iterator it = _sizeMap.find( entry ); + if ( it != _sizeMap.end() ) + _sizeMap.erase(it); + else + std::cout<<"No_Such_Entry"<second.empty() ) - save << " " << op_val->first - << " " << op_val->second << "%#"; // "%#" is a mark of value end + if (op_val != _option2value.end()) { + save << " " << "__OPTIONS_BEGIN__"; + for ( ; op_val != _option2value.end(); ++op_val ) { + if ( !op_val->second.empty() ) + save << " " << op_val->first + << " " << op_val->second << "%#"; // "%#" is a mark of value end + } + save << " " << "__OPTIONS_END__"; } + TSizeMap::iterator it_sm = _sizeMap.begin(); + if (it_sm != _sizeMap.end()) { + save << " " << "__SIZEMAP_BEGIN__"; + for ( ; it_sm != _sizeMap.end(); ++it_sm ) { + save << " " << it_sm->first + << " " << it_sm->second << "%#"; // "%#" is a mark of value end + } + save << " " << "__SIZEMAP_END__"; + } + + return save; } @@ -452,11 +505,25 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) else load.clear(std::ios::badbit | load.rdstate()); + std::string option_or_sm; + bool hasOptions = false; + bool hasSizeMap = false; + + isOK = (load >> option_or_sm); + if (isOK) + if (option_or_sm == "__OPTIONS_BEGIN__") + hasOptions = true; + else if (option_or_sm == "__SIZEMAP_BEGIN__") + hasSizeMap = true; + std::string optName, optValue; - while (isOK) { + while (isOK && hasOptions) { isOK = (load >> optName); - if (isOK) + if (isOK) { + if (optName == "__OPTIONS_END__") + break; isOK = (load >> optValue); + } if (isOK) { std::string & value = _option2value[ optName ]; value = optValue; @@ -478,6 +545,41 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) } } + if (hasOptions) { + isOK = (load >> option_or_sm); + if (isOK && option_or_sm == "__SIZEMAP_BEGIN__") + hasSizeMap = true; + } + + std::string smEntry, smValue; + while (isOK && hasSizeMap) { + isOK = (load >> smEntry); + if (isOK) { + if (smEntry == "__SIZEMAP_END__") + break; + isOK = (load >> smValue); + } + if (isOK) { + std::string & value2 = _sizeMap[ smEntry ]; + value2 = smValue; + int len2= value2.size(); + // continue reading until "%#" encountered + while ( value2[len2-1] != '#' || value2[len2-2] != '%' ) + { + isOK = (load >> smValue); + if (isOK) { + value2 += " "; + value2 += smValue; + len2 = value2.size(); + } + else { + break; + } + } + value2[ len2-2 ] = '\0'; //cut off "%#" + } + } + return load; } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index a8fb7d2..fe30639 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -95,6 +95,15 @@ public: void SetVerbosity(int theVal); int GetVerbosity() const { return _verb; } + + + typedef std::map TSizeMap; + void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap ); + std::string GetSizeMapEntry(const std::string& entry); + void ClearEntry(const std::string& entry); + void ClearSizeMaps(); + + const TSizeMap& GetSizeMapEntries() const { return _sizeMap; } static Topology GetDefaultTopology(); static PhysicalMesh GetDefaultPhysicalMesh(); @@ -152,6 +161,7 @@ private: int _verb; TOptionValues _option2value; TOptionNames _doubleOptions, _charOptions; + TSizeMap _sizeMap; }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 55ca0d8..846ad2f 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -24,6 +24,7 @@ #include "BLSURFPlugin_Hypothesis_i.hxx" #include "SMESH_Gen.hxx" #include "SMESH_PythonDump.hxx" +#include "GEOM_Object.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" @@ -507,6 +508,146 @@ void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array } } +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* sizeMap) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + std::cout << "ENGINE : SETSIZEMAP START ENTRY : " << entry << std::endl; + bool valueChanged = false; + try { + valueChanged = ( this->GetImpl()->GetSizeMapEntry(entry) != sizeMap ); + if ( valueChanged ) + this->GetImpl()->SetSizeMapEntry(entry, sizeMap); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)"; + ExDescription.lineNumber = 0; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + std::cout << "ENGINE : SETSIZEMAP END ENTRY : " << entry << std::endl; + if ( valueChanged ) + SMESH::TPythonDump() << _this() << ".SetSizeMap(" + << entry << ", '" << sizeMap << "' )"; +} + +//============================================================================= + +char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + try { + return CORBA::string_dup( this->GetImpl()->GetSizeMapEntry(entry).c_str()); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)"; + ExDescription.lineNumber = 0; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + return 0; +} + +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) +{ + ASSERT(myBaseImpl); + this->GetImpl()->ClearEntry(entry); + SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )"; +} + +//============================================================================= + +BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries() +{ + ASSERT(myBaseImpl); + BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array(); + + const ::BLSURFPlugin_Hypothesis::TSizeMap & sizeMaps= this->GetImpl()->GetSizeMapEntries(); + result->length( sizeMaps.size() ); + + ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin(); + for ( int i = 0 ; smIt != sizeMaps.end(); ++smIt, ++i ) { + string entry_sizemap = smIt->first; + if ( !smIt->second.empty() ) { + entry_sizemap += "|"; + entry_sizemap += smIt->second; + } + result[i] = CORBA::string_dup(entry_sizemap.c_str()); + } + return result._retn(); +} + +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + for (int i = 0; i < sizeMaps.length(); ++i) + { + string entry_sizemap = sizeMaps[i].in(); + int colonPos = entry_sizemap.find( '|' ); + string entry, sizemap; + if ( colonPos == string::npos ) // '|' separator not found + entry = entry_sizemap; + else { + entry = entry_sizemap.substr( 0, colonPos); + if ( colonPos < entry_sizemap.size()-1 && entry_sizemap[colonPos] != ' ') + sizemap = entry_sizemap.substr( colonPos+1 ); + } + this->GetImpl()->SetSizeMapEntry( entry.c_str(), sizemap.c_str() ); + } +} + +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::ClearSizeMaps() +{ + ASSERT(myBaseImpl); + this->GetImpl()->ClearSizeMaps(); +} + + +//============================================================================= + +void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj,const char* sizeMap) +{ + ASSERT(myBaseImpl); + string entry; + entry=GeomObj->GetStudyEntry(); + std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl; + std::cout << "IDL : SETSIZEMAP ( "<< entry << " , " << sizeMap << ")" << std::endl; + SetSizeMapEntry( entry.c_str(),sizeMap); +} + +//============================================================================= +void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj) +{ + ASSERT(myBaseImpl); + string entry; + entry=GeomObj->GetStudyEntry(); + std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl; + std::cout << "IDL : UNSETSIZEMAP ( "<< entry << ")" << std::endl; + UnsetEntry( entry.c_str()); +} + + + //============================================================================= /*! * BLSURFPlugin_Hypothesis_i::GetImpl diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index 76b826f..5c7329d 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -31,6 +31,7 @@ #include "BLSURFPlugin_Hypothesis.hxx" class SMESH_Gen; +class GEOM_Object; // BLSURFPlugin parameters hypothesis @@ -98,6 +99,22 @@ class BLSURFPlugin_Hypothesis_i: void SetOptionValues(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception); + void SetSizeMapEntry(const char* entry,const char* sizeMap ) throw (SALOME::SALOME_Exception); + + char* GetSizeMapEntry(const char* entry) throw (SALOME::SALOME_Exception); + + void UnsetEntry(const char* entry); + + BLSURFPlugin::string_array* GetSizeMapEntries(); + + void SetSizeMapEntries(const BLSURFPlugin::string_array& options) throw (SALOME::SALOME_Exception); + + void SetSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap); + + void UnsetSizeMap(GEOM::GEOM_Object_ptr GeomObj); + + void ClearSizeMaps(); + // Get implementation ::BLSURFPlugin_Hypothesis* GetImpl(); diff --git a/src/BLSURFPlugin/Makefile.am b/src/BLSURFPlugin/Makefile.am index e78b060..88c937c 100644 --- a/src/BLSURFPlugin/Makefile.am +++ b/src/BLSURFPlugin/Makefile.am @@ -41,6 +41,8 @@ dist_libBLSURFEngine_la_SOURCES = \ BLSURFPlugin_i.cxx libBLSURFEngine_la_CPPFLAGS = \ + $(QT_INCLUDES) \ + $(PYTHON_INCLUDES) \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ $(MED_CXXFLAGS) \ @@ -51,11 +53,15 @@ libBLSURFEngine_la_CPPFLAGS = \ $(CORBA_CXXFLAGS) \ $(CORBA_INCLUDES) \ $(BOOST_CPPFLAGS) \ + -I$(srcdir)/../PluginUtils \ -I$(top_builddir)/idl \ - -I$(top_builddir)/salome_adm/unix + -I$(top_builddir)/salome_adm/unix + +#Qt uniquement necessaire pour le getActiveStudyDocument de SMeshGuiUtils.h libBLSURFEngine_la_LDFLAGS = \ ../../idl/libSalomeIDLBLSURFPLUGIN.la \ + ../PluginUtils/libGeomSelectionTools.la \ $(BLSURF_LIBS) \ $(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine -lStdMeshersEngine \ $(KERNEL_LDFLAGS) -lSalomeGenericObj diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index ba14fc8..9f41e7d 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D + // Copyright (C) 2007-2008 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 @@ -20,12 +20,14 @@ // File : BLSURFPluginGUI_HypothesisCreator.cxx // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA) // & Aurelien ALLEAUME (DISTENE) +// Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE) // --- // #include "BLSURFPluginGUI_HypothesisCreator.h" #include #include +#include #include #include @@ -48,19 +50,35 @@ #include #include #include - +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +// #include #define WITH_SIZE_BOUNDARIES enum Topology { FromCAD, Process, Process2 - }; + } ; enum PhysicalMesh { DefaultSize = 0, - PhysicalUserDefined + PhysicalUserDefined, + SizeMap }; enum GeometricMesh @@ -72,15 +90,140 @@ enum GeometricMesh enum { STD_TAB = 0, ADV_TAB, + SMP_TAB, OPTION_ID_COLUMN = 0, OPTION_NAME_COLUMN, OPTION_VALUE_COLUMN, - NB_COLUMNS + NB_COLUMNS, + SMP_ENTRY_COLUMN = 0, + SMP_NAME_COLUMN, + SMP_SIZEMAP_COLUMN, + SMP_NB_COLUMNS +}; + + + +typedef struct { + PyObject_HEAD + int softspace; + std::string *out; + } PyStdOut; + +static void +PyStdOut_dealloc(PyStdOut *self) +{ + PyObject_Del(self); +} + +static PyObject * +PyStdOut_write(PyStdOut *self, PyObject *args) +{ + char *c; + int l; + if (!PyArg_ParseTuple(args, "t#:write",&c, &l)) + return NULL; + + //std::cerr << c ; + *(self->out)=*(self->out)+c; + + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef PyStdOut_methods[] = { + {"write", (PyCFunction)PyStdOut_write, METH_VARARGS, + PyDoc_STR("write(string) -> None")}, + {NULL, NULL} /* sentinel */ +}; + +static PyMemberDef PyStdOut_memberlist[] = { + {"softspace", T_INT, offsetof(PyStdOut, softspace), 0, + "flag indicating that a space needs to be printed; used by print"}, + {NULL} /* Sentinel */ +}; + +static PyTypeObject PyStdOut_Type = { + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "PyOut", /*tp_name*/ + sizeof(PyStdOut), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + /* methods */ + (destructor)PyStdOut_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + /* softspace is writable: we must supply tp_setattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + PyStdOut_methods, /*tp_methods*/ + PyStdOut_memberlist, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ }; +PyObject * newPyStdOut( std::string& out ) +{ + PyStdOut *self; + self = PyObject_New(PyStdOut, &PyStdOut_Type); + if (self == NULL) + return NULL; + self->softspace = 0; + self->out=&out; + return (PyObject*)self; +} + + BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QString& theHypType ) : SMESHGUI_GenericHypothesisCreator( theHypType ) { + cout << "BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator" << endl; + this->mySMPMap.clear(); + + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + GeomToolSelected = new GeomSelectionTools(aStudy); + + /* Initialize the Python interpreter */ + assert(Py_IsInitialized()); + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + + main_mod = NULL; + main_mod = PyImport_AddModule("__main__"); + + main_dict = NULL; + main_dict = PyModule_GetDict(main_mod); + + PyRun_SimpleString("from math import *"); + PyGILState_Release(gstate); } BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator() @@ -101,6 +244,7 @@ namespace { bool BLSURFPluginGUI_HypothesisCreator::checkParams() const { + cout << "BLSURFPluginGUI_HypothesisCreator::checkParams" << endl; bool ok = true; if ( !isDouble( myPhySize->text(), false )) { if ( myPhySize->text().isEmpty() ) @@ -153,11 +297,49 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const h->SetOptionValues( myOptions ); // restore values } + // SizeMap + if ( ok ) + { + mySizeMapTable->setFocus(); + QApplication::instance()->processEvents(); + + BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() ); + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + + int row = 0, nbRows = mySizeMapTable->rowCount(); + for ( ; row < nbRows; ++row ) + { + QString entry = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); + QString sizeMap = mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->text().trimmed(); + if ( !sizeMap.isEmpty() ) { + if (that->sizeMapValidationFromRow(row)) + { + try { + const char* e = entry.toLatin1().constData(); + const char* s = that->mySMPMap[entry].toLatin1().constData(); + h->SetSizeMapEntry( e, s ); + } + catch ( const SALOME::SALOME_Exception& ex ) + { + SUIT_MessageBox::critical( dlg(), + tr("SMESH_ERROR"), + ex.details.text.in() ); + ok = false; + } + } + else { + ok = false; + } + } + } + } + return ok; } QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() { + cout << "BLSURFPluginGUI_HypothesisCreator::buildFrame" << endl; QFrame* fr = new QFrame( 0 ); QVBoxLayout* lay = new QVBoxLayout( fr ); lay->setMargin( 5 ); @@ -187,7 +369,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myPhysicalMesh = new QComboBox( myStdGroup ); aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 ); QStringList physicalTypes; - physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ); + physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ) << tr( "BLSURF_SIZE_MAP"); myPhysicalMesh->addItems( physicalTypes ); aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 ); @@ -289,9 +471,45 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() anAdvLayout->setRowStretch( 4, 5 ); anAdvLayout->setColumnStretch( 1, 5 ); + // Size Maps parameters + + mySmpGroup = new QWidget(); + QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup); + + mySizeMapTable = new QTableWidget( 0, SMP_NB_COLUMNS, mySmpGroup ); + anSmpLayout->addWidget(mySizeMapTable, 1, 0, 6, 1); + QStringList sizeMapHeaders; + sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" ); + mySizeMapTable->setHorizontalHeaderLabels(sizeMapHeaders); + mySizeMapTable->horizontalHeader()->hideSection( SMP_ENTRY_COLUMN ); + mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN); + mySizeMapTable->resizeColumnToContents(SMP_ENTRY_COLUMN); + mySizeMapTable->setAlternatingRowColors(true); + mySizeMapTable->verticalHeader()->hide(); + + addSurfaceButton = new QPushButton(tr("BLSURF_SM_SURFACE"),mySmpGroup); + anSmpLayout->addWidget(addSurfaceButton, 1, 1, 1, 1); + + addEdgeButton = new QPushButton(tr("BLSURF_SM_EDGE"),mySmpGroup); + anSmpLayout->addWidget(addEdgeButton, 2, 1, 1, 1); + + addPointButton = new QPushButton(tr("BLSURF_SM_POINT"),mySmpGroup); + anSmpLayout->addWidget(addPointButton, 3, 1, 1, 1); + + QFrame *line = new QFrame(mySmpGroup); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + anSmpLayout->addWidget(line, 4, 1, 1, 1); + + removeButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup); + anSmpLayout->addWidget(removeButton, 5, 1, 1, 1); + + // --- tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) ); tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) ); + tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) ); + tab->setCurrentIndex( STD_TAB ); // --- @@ -300,12 +518,20 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) ); connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) ); connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) ); + + connect(addSurfaceButton, SIGNAL(clicked()), this, SLOT(onAddMapOnSurface())); + connect(addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddMapOnEdge())); + connect(addPointButton, SIGNAL(clicked()), this, SLOT(onAddMapOnPoint())); + connect(removeButton, SIGNAL(clicked()), this, SLOT(onRemoveMap())); + connect(mySizeMapTable, SIGNAL(cellChanged ( int, int )),this,SLOT (onSetSizeMap(int,int ))); return fr; } + void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const { + cout << "BLSURFPluginGUI_HypothesisCreator::retrieveParams" << endl; BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; BlsurfHypothesisData data; @@ -332,7 +558,7 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const myAllowQuadrangles->setChecked( data.myAllowQuadrangles ); myDecimesh->setChecked( data.myDecimesh ); myVerbosity->setValue( data.myVerbosity ); - + if ( myOptions.operator->() ) { printf("retrieveParams():myOptions->length()=%d\n",myOptions->length()); for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) { @@ -355,6 +581,28 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const } myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN ); + printf("retrieveParams():that->mySMPMap.size()=%d\n",that->mySMPMap.size()); + QMapIterator i(that->mySMPMap); + while (i.hasNext()) { + i.next(); + const QString entry = i.key(); + string shapeName = GeomToolSelected->getNameFromEntry(entry.toStdString()); + const QString sizeMap = i.value(); + int row = mySizeMapTable->rowCount(); + mySizeMapTable->setRowCount( row+1 ); + mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( entry ) ); + mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 ); + mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) ); + mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 ); + mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) ); + mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable | + Qt::ItemIsEditable | + Qt::ItemIsEnabled ); + } + + mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); + mySizeMapTable->resizeColumnToContents(SMP_ENTRY_COLUMN); + // update widgets that->onPhysicalMeshChanged(); that->onGeometricMeshChanged(); @@ -368,11 +616,13 @@ QString BLSURFPluginGUI_HypothesisCreator::storeParams() const QString guiHyp = that->readParamsFromWidgets( data ); that->storeParamsToHypo( data ); + //cout<<"BLSURFPluginGUI_HypothesisCreator::storeParams(), guiHyp: "<myOptions = h->GetOptionValues(); + + BLSURFPlugin::string_array_var mySMPString = h->GetSizeMapEntries(); + + cout << "mySMPString->length() = " << mySMPString->length() << endl; + that->mySMPMap.clear(); + + TopoDS_Shape S; + + for ( int i = 0;ilength(); ++i ) { + QString sizemaps_line = mySMPString[i].in(); + QStringList entry_sm = sizemaps_line.split( "|", QString::KeepEmptyParts ); + if ( entry_sm.count() > 1 ) { + string fullSizeMap = entry_sm[1].toStdString(); + int pos = fullSizeMap.find("return")+7; + QString sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos)); + that->mySMPMap[entry_sm[0]] = sizeMap; + that->mySMPShapeTypeMap[entry_sm[0]] = GeomToolSelected->entryToShape(entry_sm[0].toStdString()).ShapeType(); + MESSAGE("mySMPMap[" << entry_sm[0].toStdString() << "] = " << sizeMap.toStdString()); + MESSAGE("mySMPShapeTypeMap[" << entry_sm[0].toStdString() << "] = " << that->mySMPShapeTypeMap[entry_sm[0]]); + } + } + return true; } bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const { + cout << "BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo" << endl; BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( hypothesis() ); @@ -434,7 +707,7 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi if ( h->GetVerbosity() != h_data.myVerbosity ) h->SetVerbosity( h_data.myVerbosity ); - if( (int) h_data.myPhysicalMesh == PhysicalUserDefined ) { + if( ((int) h_data.myPhysicalMesh == PhysicalUserDefined)||((int) h_data.myPhysicalMesh == SizeMap) ) { if ( h->GetPhySize() != h_data.myPhySize.toDouble() ) h->SetPhySize( h_data.myPhySize.toDouble() ); } @@ -463,8 +736,39 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi h->SetGeoMax( h_data.myGeoMax.toDouble() ); #endif - printf("storeParamsToHypo():myOptions->length()=%d\n",myOptions->length()); + //printf("storeParamsToHypo():myOptions->length()=%d\n",myOptions->length()); h->SetOptionValues( myOptions ); // is set in checkParams() + + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + //printf("storeParamsToHypo():that->mySMPMap.size()=%d\n",that->mySMPMap.size()); + QMapIterator i(that->mySMPMap); + // Reset the size maps in engine + // h->ClearSizeMaps(); + // Iterate over each size map + while (i.hasNext()) { + i.next(); + const QString entry = i.key(); + const QString sizeMap = i.value(); + + if (sizeMap == "__TO_DELETE__") { + cout << "Delete entry " << entry.toStdString() << " from engine" << endl; + h->UnsetEntry(entry.toLatin1().constData()); + ok = false; + break; + } + + QString fullSizeMap; + fullSizeMap = QString(""); + if (that->mySMPShapeTypeMap[entry] == TopAbs_FACE) + fullSizeMap = QString("def f(u,v): return ") + sizeMap; + else if (that->mySMPShapeTypeMap[entry] == TopAbs_EDGE) + fullSizeMap = QString("def f(t): return ") + sizeMap; + else if (that->mySMPShapeTypeMap[entry] == TopAbs_VERTEX) + fullSizeMap = QString("def f(): return ") + sizeMap; + + cout << "SetSizeMapEntry("<SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() ); + } } catch(const SALOME::SALOME_Exception& ex) { @@ -476,6 +780,7 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const { + cout << "BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets" << endl; h_data.myName = myName ? myName->text() : ""; h_data.myTopology = myTopology->currentIndex(); h_data.myPhysicalMesh = myPhysicalMesh->currentIndex(); @@ -526,14 +831,24 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes guiHyp += name + " = " + value + "; "; } } - + + // SizeMap + row = 0, nbRows = mySizeMapTable->rowCount(); + for ( ; row < nbRows; ++row ) + { + QString entry = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); + if ( that->mySMPMap.contains(entry) ) + guiHyp += entry + " = " + that->mySMPMap[entry] + "; "; + } + cout << "guiHyp : " << guiHyp.toLatin1().data() << endl; return guiHyp; } void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { - bool isCustom = (myPhysicalMesh->currentIndex() == PhysicalUserDefined); + cout << "BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged" << endl; + bool isCustom = ((myPhysicalMesh->currentIndex() == PhysicalUserDefined) || (myPhysicalMesh->currentIndex() == SizeMap)) ; myPhySize->setEnabled(isCustom); myPhyMax->setEnabled(isCustom); myPhyMin->setEnabled(isCustom); @@ -559,6 +874,7 @@ void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { } void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { + cout << "BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged" << endl; bool isCustom = (myGeometricMesh->currentIndex() == UserDefined); myAngleMeshS->setEnabled(isCustom); myAngleMeshC->setEnabled(isCustom); @@ -661,6 +977,260 @@ void BLSURFPluginGUI_HypothesisCreator::onDeleteOption() myOptionTable->removeRow( it.previous() ); } +// ********************** +// *** BEGIN SIZE MAP *** +// ********************** + + +void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() +{ + cout<<"BLSURFPluginGUI_HypothesisCreator::onRemoveMap()"< selectedRows; + QList selected = mySizeMapTable->selectedItems(); + QTableWidgetItem* item; + int row; + foreach( item, selected ) { + row = item->row(); + if ( !selectedRows.contains( row ) ) + selectedRows.append( row ); + } + + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + + qSort( selectedRows ); + QListIterator it( selectedRows ); + it.toBack(); + while ( it.hasPrevious() ) { + row = it.previous(); + cout << "delete row #"<< row <item(row,SMP_ENTRY_COLUMN)->text(); + if (that->mySMPMap.contains(entry)) + that->mySMPMap[entry] = "__TO_DELETE__"; + if (that->mySMPShapeTypeMap.contains(entry)) + that->mySMPShapeTypeMap.remove(entry); + mySizeMapTable->removeRow(row ); + } + mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN); + mySizeMapTable->resizeColumnToContents(SMP_ENTRY_COLUMN); +} + +void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) +{ + cout<<"BLSURFPluginGUI_HypothesisCreator::onSetSizeMap()"<mySizeMapTable->item(row, SMP_ENTRY_COLUMN)->text(); + QString sizeMap = that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->text().trimmed(); + if (not that->mySMPShapeTypeMap.contains(entry)) + return; + QString prevSizeMap = that->mySMPMap[entry]; + that->mySMPMap[entry] = sizeMap; + if (not sizeMapValidationFromEntry(entry)) { + that->mySMPMap[entry] = prevSizeMap; + that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setText(prevSizeMap); + } + } +} + +void BLSURFPluginGUI_HypothesisCreator::onAddMapOnSurface() +{ + insertElementType(TopAbs_FACE); +} + +void BLSURFPluginGUI_HypothesisCreator::onAddMapOnEdge() +{ + insertElementType(TopAbs_EDGE); +} + +void BLSURFPluginGUI_HypothesisCreator::onAddMapOnPoint() +{ + insertElementType(TopAbs_VERTEX); +} + +void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeShapeAsked) +{ + cout<<"BLSURFPluginGUI_HypothesisCreator::insertElementType()"<selectionMgr(); + SALOME_ListIO ListSelectedObjects; + aSel->selectedObjects(ListSelectedObjects, NULL, false ); + if (!ListSelectedObjects.IsEmpty()) + { + SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects); + for (; Object_It.More(); Object_It.Next()) + { + Handle(SALOME_InteractiveObject) anObject = Object_It.Value(); + entry = GeomToolSelected->getEntryOfObject(anObject); + shapeName = anObject->getName(); + S = GeomToolSelected->entryToShape(entry); + if ((! S.IsNull()) && (S.ShapeType() == typeShapeAsked)) + { + mySizeMapTable->setFocus(); + QString shapeEntry; + shapeEntry = QString::fromStdString(entry); + double phySize = h->GetPhySize(); + std::ostringstream oss; + oss << phySize; + QString sizeMap; + sizeMap = QString::fromStdString(oss.str()); + if (that->mySMPMap.contains(shapeEntry)) { + if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") { + MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")"); + break; + } + } + that->mySMPMap[shapeEntry] = sizeMap; + that->mySMPShapeTypeMap[shapeEntry] = typeShapeAsked; + int row = mySizeMapTable->rowCount() ; + mySizeMapTable->setRowCount( row+1 ); + mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( shapeEntry ) ); + mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 ); + mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) ); + mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 ); + mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) ); + mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled ); + mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); + mySizeMapTable->resizeColumnToContents(SMP_ENTRY_COLUMN); + mySizeMapTable->clearSelection(); + mySizeMapTable->scrollToItem( mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN ) ); + + if ( myPhysicalMesh->currentIndex() != SizeMap ) { + myPhysicalMesh->setCurrentIndex( SizeMap ); + onPhysicalMeshChanged(); + } + } + } + } +} + +bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation() +{ + cout<<"BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()"<rowCount(); + for ( ; row < nbRows; ++row ) + if (not sizeMapValidationFromRow(row)) + return false; + return true; +} + +bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow) +{ + cout<<"BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow()"<item( myRow, SMP_ENTRY_COLUMN )->text(); + return sizeMapValidationFromEntry(myEntry); +} + +bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEntry) +{ + cout<<"BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry()"<mySMPMap.contains(myEntry)) { + cout<<"Geometry with entry "<mySMPShapeTypeMap.contains(myEntry)) { + cout<<"Shape type with entry "<mySMPShapeTypeMap[myEntry] == TopAbs_FACE) + expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString(); + else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE) + expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString(); + else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX) + expr = "def f() : return " + that->mySMPMap[myEntry].toStdString(); + + assert(Py_IsInitialized()); + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + + PyObject * obj = NULL; + PyObject* new_stderr = NULL; + string err_description=""; + obj= PyRun_String(expr.c_str(), Py_file_input, main_dict, NULL); + if (obj == NULL){ + fflush(stderr); + err_description=""; + new_stderr=newPyStdOut(err_description); + PySys_SetObject("stderr", new_stderr); + PyErr_Print(); + PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + Py_DECREF(new_stderr); + SUIT_MessageBox::warning( dlg(),"Definition of Python Function : Error" ,err_description.c_str() ); + PyGILState_Release(gstate); + return false; + } + Py_DECREF(obj); + + PyObject * func = NULL; + func = PyObject_GetAttrString(main_mod, "f"); + if ( func == NULL){ + fflush(stderr); + err_description=""; + new_stderr=newPyStdOut(err_description); + PySys_SetObject("stderr", new_stderr); + PyErr_Print(); + PySys_SetObject("stderr", PySys_GetObject("__stderr__")); + Py_DECREF(new_stderr); + SUIT_MessageBox::warning( dlg(),"Python Error" ,err_description.c_str() ); + PyGILState_Release(gstate); + return false; + } + + PyGILState_Release(gstate); + + cout<<"SizeMap expression "<row(); + int myColumn = index->column(); + + if (myColumn == 2){ + if (!myEditor) { + myEditor = new BLSURFPluginGUI_MapFunctionEditor(sizeMapModel->item(myRow,0)->text()); + connect(myEditor, SIGNAL(FunctionEntered(QString)), this, SLOT(FunctionLightValidation(QString))); + } + myEditor->exec(); +// myEditor->show(); +// myEditor->raise(); +// myEditor->activateWindow(); + + +// BLSURFPluginGUI_MapFunctionEditor* myEditor = new BLSURFPluginGUI_MapFunctionEditor(sizeMapModel->item(myRow,0)->text()); +// myEditor->exec(); + QString myFunction = myEditor->GetFunctionText(); + // FIN RECUPERATION FONCTION + + if (! myFunction.isEmpty()) { + + // MAJ DE LA MAP + + BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = + BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis()); + +// h->SetSizeMapEntry(sizeMapModel->item(myRow,1)->text().toLatin1().constData(), +// item->text().toLatin1().constData()); + h->SetSizeMapEntry(sizeMapModel->item(myRow,1)->text().toLatin1().constData(), + myFunction.toLatin1().constData()); + // FIN MAJ DE LA MAP + } + } +}*/ QString BLSURFPluginGUI_HypothesisCreator::caption() const { @@ -681,3 +1251,13 @@ QString BLSURFPluginGUI_HypothesisCreator::helpPage() const { return "blsurf_hypo_page.html"; } + +LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr() +{ + + SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if( anApp ) + return dynamic_cast( anApp->selectionMgr() ); + else + return 0; +} diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 15e701e..94f54ee 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -35,8 +35,13 @@ #define BLSURFPLUGIN_GUI_EXPORT #endif +#include #include #include +#include +#include +#include +#include #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm) class QGroupBox; @@ -45,21 +50,26 @@ class QComboBox; class QCheckBox; class QLineEdit; class QTableWidget; +class QTableView; +class QStandardItemModel; +class QStandardItem; +class QModelIndex; class QSpinBox; class QMenu; class QAction; +class LightApp_SelectionMgr; typedef struct { int myTopology, myVerbosity; int myPhysicalMesh, myGeometricMesh; double myAngleMeshS, myAngleMeshC, myGradation; - QString myPhySize, myGeoMin, myGeoMax, myPhyMin, myPhyMax; - bool myAllowQuadrangles, myDecimesh; + QString myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax; + bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint; QString myName; - } BlsurfHypothesisData; + /*! * \brief Class for creation of BLSURF hypotheses */ @@ -73,6 +83,8 @@ public: virtual bool checkParams() const; virtual QString helpPage() const; + void insertElementType( TopAbs_ShapeEnum ); + static LightApp_SelectionMgr* selectionMgr(); protected: virtual QFrame* buildFrame (); @@ -89,11 +101,19 @@ protected slots: void onAddOption(); void onDeleteOption(); void onOptionChosenInPopup( QAction* ); + void onAddMapOnSurface(); + void onAddMapOnEdge(); + void onAddMapOnPoint(); + void onRemoveMap(); + void onSetSizeMap(int,int); private: bool readParamsFromHypo( BlsurfHypothesisData& ) const; QString readParamsFromWidgets( BlsurfHypothesisData& ) const; bool storeParamsToHypo( const BlsurfHypothesisData& ) const; + bool sizeMapsValidation(); + bool sizeMapValidationFromRow(int); + bool sizeMapValidationFromEntry(QString); private: QWidget* myStdGroup; @@ -116,7 +136,22 @@ private: QSpinBox* myVerbosity; QTableWidget* myOptionTable; + QWidget *mySmpGroup; + QTableWidget *mySizeMapTable; + QPushButton *addEdgeButton; + QPushButton *addSurfaceButton; + QPushButton *addPointButton; + QPushButton *removeButton; + + // map = entry , size map + QMap mySMPMap; + QMap mySMPShapeTypeMap; + GeomSelectionTools* GeomToolSelected; + BLSURFPlugin::string_array_var myOptions; + + PyObject * main_mod; + PyObject * main_dict; }; #endif // BLSURFPLUGINGUI_HypothesisCreator_H diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 0e4e862..5712ed2 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -94,6 +94,51 @@ BLSURF_PHY_MESH Physical Mesh + + BLSURF_SIZE_MAP + Size Map + + + SMP_ENTRY_COLUMN + Entry + + + + SMP_NAME_COLUMN + Name + + + SMP_SIZEMAP_COLUMN + Size Map + + + BLSURF_SM_SURFACE + Add Map on Surface + + + BLSURF_SM_EDGE + Add Map on Edge + + + BLSURF_SM_POINT + Add Map on Point + + + BLSURF_SM_REMOVE + Remove Map + + + BLSURF_SM_SURF_VALUE + Size on Surface(s) + + + BLSURF_SM_EDGE_VALUE + Size on Edge(s) + + + BLSURF_SM_POINT_VALUE + Size on Point(s) + BLSURF_TITLE Hypothesis Construction diff --git a/src/GUI/Makefile.am b/src/GUI/Makefile.am index 20136b4..28ff246 100644 --- a/src/GUI/Makefile.am +++ b/src/GUI/Makefile.am @@ -32,7 +32,10 @@ lib_LTLIBRARIES = libBLSURFPluginGUI.la dist_libBLSURFPluginGUI_la_SOURCES = \ BLSURFPluginGUI.cxx \ BLSURFPluginGUI_HypothesisCreator.h \ - BLSURFPluginGUI_HypothesisCreator.cxx + BLSURFPluginGUI_HypothesisCreator.cxx +# ui_BLSURFPluginGUI_MapFunctionEditor.h \ +# BLSURFPluginGUI_MapFunctionEditor.h \ +# BLSURFPluginGUI_MapFunctionEditor.cxx MOC_FILES = \ BLSURFPluginGUI_HypothesisCreator_moc.cxx @@ -56,11 +59,13 @@ libBLSURFPluginGUI_la_CPPFLAGS = \ $(CORBA_INCLUDES) \ $(BLSURF_INCLUDES) \ -I$(srcdir)/../BLSURFPlugin \ + -I$(srcdir)/../PluginUtils \ -I$(top_builddir)/idl \ -I$(top_builddir)/salome_adm/unix libBLSURFPluginGUI_la_LDFLAGS = \ ../BLSURFPlugin/libBLSURFEngine.la \ + ../PluginUtils/libGeomSelectionTools.la \ ${SMESH_LDFLAGS} -lSMESH \ $(CAS_KERNEL) $(BLSURF_LIBS) diff --git a/src/Makefile.am b/src/Makefile.am index 5768f50..2d86256 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,10 +23,10 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am -SUBDIRS = BLSURFPlugin +SUBDIRS = PluginUtils BLSURFPlugin if BLSURFPLUGIN_ENABLE_GUI SUBDIRS += GUI endif -DIST_SUBDIRS = BLSURFPlugin GUI \ No newline at end of file +DIST_SUBDIRS = PluginUtils BLSURFPlugin GUI diff --git a/src/PluginUtils/GeomSelectionTools.cxx b/src/PluginUtils/GeomSelectionTools.cxx new file mode 100644 index 0000000..df8ab5a --- /dev/null +++ b/src/PluginUtils/GeomSelectionTools.cxx @@ -0,0 +1,218 @@ +// Copyright (C) 2007-2008 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 +// +// --- +// File : GeomSelectionTools.cxx +// Authors : Nicolas GEIMER (OCC) +// --- +// + + +#include "GeomSelectionTools.h" +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +GeomSelectionTools::GeomSelectionTools(_PTR(Study) aStudy) +{ + myStudy = aStudy; +} + + + +LightApp_SelectionMgr* GeomSelectionTools::selectionMgr() +{ + SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if (anApp) + return dynamic_cast( anApp->selectionMgr() ); + else + return 0; +} + +SALOME_ListIO* GeomSelectionTools::getSelectedSalomeObjects() +{ + SALOME_ListIO* selected; + LightApp_SelectionMgr* aSel = selectionMgr(); + aSel->selectedObjects( *selected, NULL, false ); + return selected; +} + + +Handle(SALOME_InteractiveObject) GeomSelectionTools::getFirstSelectedSalomeObject() +{ + SALOME_ListIO selected; + LightApp_SelectionMgr* aSel = selectionMgr(); + aSel->selectedObjects( selected, NULL, false ); + if (!selected.IsEmpty()){ + SALOME_ListIteratorOfListIO anIt(selected); + Handle(SALOME_InteractiveObject) anIO; + anIO = anIt.Value(); + return anIO; + } + return NULL; +} + +std::string GeomSelectionTools::getFirstSelectedEntry() +{ + Handle(SALOME_InteractiveObject) anIO; + std::string entry=""; + anIO=GeomSelectionTools::getFirstSelectedSalomeObject(); + return GeomSelectionTools::getEntryOfObject(anIO); +} + +std::string GeomSelectionTools::getEntryOfObject(Handle(SALOME_InteractiveObject) anIO){ + std::string entry=""; + _PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry()); + if (aSO){ + _PTR(SObject) aRefSObj; + // If selected object is a reference + if ( aSO->ReferencedObject( aRefSObj )) + entry = aRefSObj->GetID(); + // If selected object is a reference is not a reference + else + entry= anIO->getEntry(); + } + return entry; +} + + +std::string GeomSelectionTools::getNameFromEntry(std::string entry){ + std::string name = ""; + _PTR(SObject) aSO = myStudy->FindObjectID(entry); + if (aSO){ + _PTR(SObject) aRefSObj; + // If selected object is a reference + if ( aSO->ReferencedObject( aRefSObj )) + name = aRefSObj->GetName(); + // If selected object is a reference is not a reference + else + name = aSO->GetName(); + } + return name; +} + +std::string GeomSelectionTools::getFirstSelectedComponentDataType() +{ + Handle(SALOME_InteractiveObject) anIO; + std::string DataType=""; + anIO=GeomSelectionTools::getFirstSelectedSalomeObject(); + _PTR(SObject) aSO = myStudy->FindObjectID(anIO->getEntry()); + if (aSO){ + _PTR(SObject) aRefSObj; + // If selected object is a reference + if ( aSO->ReferencedObject( aRefSObj )) + DataType= aRefSObj->GetFatherComponent()->ComponentDataType(); + // If selected object is a reference is not a reference + else + DataType=anIO->getComponentDataType(); + } + return DataType; +} + +TopoDS_Shape GeomSelectionTools::getFirstSelectedTopoDSShape() +{ + Handle(SALOME_InteractiveObject) anIO; + anIO=GeomSelectionTools::getFirstSelectedSalomeObject(); + return entryToShape(anIO->getEntry()); +} + +TopoDS_Shape GeomSelectionTools::entryToShape(std::string entry){ + TopoDS_Shape S = TopoDS_Shape(); + _PTR(SObject) aSO = myStudy->FindObjectID(entry); + if (aSO){ + _PTR(SObject) aRefSObj; + GEOM::GEOM_Object_var aShape; + // If selected object is a reference + if ( aSO->ReferencedObject( aRefSObj )){ + if (aRefSObj->GetFatherComponent()->ComponentDataType() == "GEOM") + aShape=SMESH::SObjectToInterface(aRefSObj); + } + // If selected object is a reference is not a reference + else { + if ( aSO->GetFatherComponent()->ComponentDataType() == "GEOM") + aShape = SMESH::SObjectToInterface(aSO); + } + if ( !aShape->_is_nil() ){ + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) + S=gen->GeomObjectToShape( aShape.in() ); + } + } + return S; +} + +TopAbs_ShapeEnum GeomSelectionTools:: getFirstSelectedShapeType() +{ + TopoDS_Shape S=getFirstSelectedTopoDSShape(); + if (!S.IsNull()) + return S.ShapeType(); + else + // FIXME : Gérer l'exception de manière correct si la shape est nulle + return TopAbs_SHAPE; + +} + +void GeomSelectionTools::getFaceInformation() +{ + TopoDS_Shape S=getFirstSelectedTopoDSShape(); + if (!S.IsNull() && S.ShapeType()==TopAbs_FACE){ + TopoDS_Face f=TopoDS::Face(S); + Handle(Geom_Surface) surf = BRep_Tool::Surface(f); + BRepAdaptor_Surface surf_adap=BRepAdaptor_Surface::BRepAdaptor_Surface(f); + + /* Global Information */ + cout << "GLOBAL INFORMATION" << endl; + cout << "******************" << endl; + stringstream buffer; + buffer << "Degre U : " << surf_adap.UDegree(); + //conversion nécessaire pour affichage + cout << buffer.str() << endl; +/* cout << " Degre V : " << surf_adap.VDegree() << endl; + cout << " Nb Poles U : " << surf_adap.NbUPoles() << endl; + cout << " Nb Poles V : " << surf_adap.NbVPoles() << endl; + cout << " Nb Noeuds U : " << surf_adap.NbUKnots() << endl; + cout << " Nb Noeuds V : " << surf_adap.NbVKnots() << endl; + cout << " U Rationnel ? " << surf_adap.IsURational() << endl; + cout << " V Rationnel ? " << surf_adap.IsVRational() << endl; */ + + GeomAbs_SurfaceType surf_type=surf_adap.GetType(); + /* + Returns the type of the surface : Plane, Cylinder, + Cone, Sphere, Torus, BezierSurface, + BSplineSurface, SurfaceOfRevolution, + SurfaceOfExtrusion, OtherSurface + */ + + + + } + return; +} diff --git a/src/PluginUtils/GeomSelectionTools.h b/src/PluginUtils/GeomSelectionTools.h new file mode 100644 index 0000000..1196571 --- /dev/null +++ b/src/PluginUtils/GeomSelectionTools.h @@ -0,0 +1,56 @@ +// Copyright (C) 2007-2008 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 +// +// --- +// File : GeomSelectionTools.h +// Authors : Nicolas GEIMER (OCC) +// --- + + + +#include "SALOMEDSClient.hxx" +#include "SALOME_InteractiveObject.hxx" +#include + +#include + +class LightApp_SelectionMgr; + +class GeomSelectionTools +{ + +private: + + _PTR(Study) myStudy; + +public: + + GeomSelectionTools(_PTR(Study)); + static LightApp_SelectionMgr* selectionMgr(); + SALOME_ListIO* getSelectedSalomeObjects(); + Handle(SALOME_InteractiveObject) getFirstSelectedSalomeObject(); + std::string getFirstSelectedEntry(); + std::string getEntryOfObject(Handle(SALOME_InteractiveObject)); + std::string getNameFromEntry(std::string); + std::string getFirstSelectedComponentDataType(); + TopoDS_Shape getFirstSelectedTopoDSShape(); + TopAbs_ShapeEnum getFirstSelectedShapeType(); + TopoDS_Shape entryToShape(std::string ); + void getFaceInformation(); +}; + + diff --git a/src/PluginUtils/Makefile.am b/src/PluginUtils/Makefile.am new file mode 100644 index 0000000..6ba3947 --- /dev/null +++ b/src/PluginUtils/Makefile.am @@ -0,0 +1,66 @@ +# Copyright (C) 2007-2008 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 +# +# --- +# File : Makefile.am +# Author : Nicolas GEIMER (OCC) +# --- +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# header files +salomeinclude_HEADERS = + +# Libraries targets +lib_LTLIBRARIES = libGeomSelectionTools.la + +dist_libGeomSelectionTools_la_SOURCES = \ + GeomSelectionTools.h \ + GeomSelectionTools.cxx + +MOC_FILES = \ + BLSURFPluginGUI_HypothesisCreator_moc.cxx + +nodist_GeomSelectionTools_la_SOURCES = \ + $(MOC_FILES) + +# additionnal information to compil and link file + +libGeomSelectionTools_la_CPPFLAGS = \ + $(QT_INCLUDES) \ + $(CAS_CPPFLAGS) \ + $(PYTHON_INCLUDES) \ + $(KERNEL_CXXFLAGS) \ + $(GUI_CXXFLAGS) \ + $(GEOM_CXXFLAGS) \ + $(SMESH_CXXFLAGS) \ + $(MED_CXXFLAGS) \ + $(BOOST_CPPFLAGS) \ + $(CORBA_CXXFLAGS) \ + $(CORBA_INCLUDES) \ + -I$(top_builddir)/idl \ + -I$(top_builddir)/salome_adm/unix + +libGeomSelectionTools_la_LDFLAGS = \ + ${SMESH_LDFLAGS} -lSMESH \ + $(CAS_KERNEL) + +# resources files +#nodist_salomeres_DATA = \ +# BLSURFPlugin_images.qm \ +# BLSURFPlugin_msg_en.qm diff --git a/src/PluginUtils/PluginUtils.h b/src/PluginUtils/PluginUtils.h new file mode 100644 index 0000000..69c2e86 --- /dev/null +++ b/src/PluginUtils/PluginUtils.h @@ -0,0 +1,28 @@ +// Copyright (C) 2007-2008 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 +// +// File : PluginUtils.h +// Author : Nicolas GEIMER (OCC) +// Module : BLSURFPlugin +// + + + diff --git a/src/PluginUtils/SizeMapPython.cxx b/src/PluginUtils/SizeMapPython.cxx new file mode 100644 index 0000000..e69de29 diff --git a/src/PluginUtils/SizeMapPython.h b/src/PluginUtils/SizeMapPython.h new file mode 100644 index 0000000..576fc6d --- /dev/null +++ b/src/PluginUtils/SizeMapPython.h @@ -0,0 +1 @@ +#include