From: vsr Date: Thu, 9 Aug 2012 11:46:18 +0000 (+0000) Subject: Merge from V6_main_20120808 08Aug12 X-Git-Tag: V7_0_0~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a51df48e9905b1ff60c6693fca90cd7eb303a39d;p=plugins%2Fhybridplugin.git Merge from V6_main_20120808 08Aug12 --- diff --git a/GHS3DPLUGIN_version.h.in b/GHS3DPLUGIN_version.h.in index a04a008..7d4806c 100644 --- a/GHS3DPLUGIN_version.h.in +++ b/GHS3DPLUGIN_version.h.in @@ -1,21 +1,22 @@ -// Copyright (C) 2004-2008 CEA/DEN, EDF R&D +// Copyright (C) 2004-2012 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 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : GHS3DPLUGIN_version.h // Author : Vadim SANDLER // Module : SALOME @@ -29,5 +30,6 @@ #define GHS3DPLUGIN_VERSION_STR "@VERSION@" #define GHS3DPLUGIN_VERSION @XVERSION@ +#define GHS3DPLUGIN_DEVELOPMENT @VERSION_DEV@ #endif // __GHS3DPLUGIN_VERSION_H__ diff --git a/Makefile.am b/Makefile.am index 38e3966..afc6dd9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # -* Makefile *- # Author : Patrick GOLDBRONN (CEA) # Date : 28/06/2001 @@ -39,11 +40,11 @@ else !GHS3DPLUGIN_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 +DISTCLEANFILES = a.out aclocal.m4 configure local-install.sh hack_libtool salomeinclude_DATA = GHS3DPLUGIN_version.h diff --git a/adm_local/Makefile.am b/adm_local/Makefile.am index 0c722d0..249f903 100644 --- a/adm_local/Makefile.am +++ b/adm_local/Makefile.am @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + include $(top_srcdir)/adm_local/unix/make_common_starter.am SUBDIRS = unix diff --git a/adm_local/unix/Makefile.am b/adm_local/unix/Makefile.am index d109e0d..cd2cfe6 100644 --- a/adm_local/unix/Makefile.am +++ b/adm_local/unix/Makefile.am @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + include $(top_srcdir)/adm_local/unix/make_common_starter.am SUBDIRS = config_files diff --git a/adm_local/unix/config_files/Makefile.am b/adm_local/unix/config_files/Makefile.am index ee5c4d8..6d25f43 100644 --- a/adm_local/unix/config_files/Makefile.am +++ b/adm_local/unix/config_files/Makefile.am @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + include $(top_srcdir)/adm_local/unix/make_common_starter.am dist_admlocalm4_DATA = \ diff --git a/adm_local/unix/config_files/check_GHS3D.m4 b/adm_local/unix/config_files/check_GHS3D.m4 index 954a828..cec27b7 100644 --- a/adm_local/unix/config_files/check_GHS3D.m4 +++ b/adm_local/unix/config_files/check_GHS3D.m4 @@ -1,21 +1,22 @@ -dnl Copyright (C) 2004-2008 CEA/DEN, EDF R&D +dnl Copyright (C) 2004-2012 CEA/DEN, EDF R&D dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License. +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA dnl -dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com dnl + AC_DEFUN([CHECK_GHS3D],[ GHS3D_ok=no diff --git a/adm_local/unix/config_files/check_GHS3DPLUGIN.m4 b/adm_local/unix/config_files/check_GHS3DPLUGIN.m4 index 5ed3b2d..25f56bd 100755 --- a/adm_local/unix/config_files/check_GHS3DPLUGIN.m4 +++ b/adm_local/unix/config_files/check_GHS3DPLUGIN.m4 @@ -1,21 +1,22 @@ -dnl Copyright (C) 2004-2008 CEA/DEN, EDF R&D +dnl Copyright (C) 2004-2012 CEA/DEN, EDF R&D dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License. +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA dnl -dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com dnl + # Check availability of GHS3DPLUGIN binary distribution # # Author : Marc Tajchman (CEA, 2002) diff --git a/adm_local/unix/make_common_starter.am b/adm_local/unix/make_common_starter.am index 27fcce1..694041f 100644 --- a/adm_local/unix/make_common_starter.am +++ b/adm_local/unix/make_common_starter.am @@ -1,21 +1,30 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + +# ============================================================ +# The following is to avoid PACKAGE_... env variable +# redefinition compilation warnings +# ============================================================ +# +AM_CXXFLAGS = @KERNEL_CXXFLAGS@ -include SALOMEconfig.h +AM_CPPFLAGS = @KERNEL_CXXFLAGS@ -include SALOMEconfig.h + # ============================================================ # This file defines the common definitions used in several # Makefile. This file must be included, if needed, by the file diff --git a/bin/Makefile.am b/bin/Makefile.am index df80d88..75e88d0 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # -* Makefile *- # Author : Guillaume Boulant (CSSI) # Module : GHS3DPLUGIN diff --git a/bin/VERSION.in b/bin/VERSION.in index 777656f..735f67e 100755 --- a/bin/VERSION.in +++ b/bin/VERSION.in @@ -1 +1,3 @@ -THIS IS SALOME - GHS3DPLUGIN VERSION: @VERSION@ +[SALOME GHS3DPLUGIN] : @VERSION@ +[DEVELOPMENT] : @VERSION_DEV@ +[DESCRIPTION] : DISTENE TetGen-GHS3d meshing plug-in for SALOME Mesh module diff --git a/build_cmake b/build_cmake new file mode 100755 index 0000000..47bd15c --- /dev/null +++ b/build_cmake @@ -0,0 +1,27 @@ +#!/bin/sh +# Copyright (C) 2004-2012 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 +# + +CURRENT_DIR=`pwd` +CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` +cd ${CONF_DIR} +python $KERNEL_ROOT_DIR/salome_adm/cmake_files/am2cmake.py --ghs3dplugin +status=$? +cd ${CURRENT_DIR} +exit $status diff --git a/build_cmake.bat b/build_cmake.bat new file mode 100644 index 0000000..5008649 --- /dev/null +++ b/build_cmake.bat @@ -0,0 +1,20 @@ +@REM Copyright (C) 2004-2012 CEA/DEN, EDF R&D +@REM +@REM This library is free software; you can redistribute it and/or +@REM modify it under the terms of the GNU Lesser General Public +@REM License as published by the Free Software Foundation; either +@REM version 2.1 of the License. +@REM +@REM This library is distributed in the hope that it will be useful, +@REM but WITHOUT ANY WARRANTY; without even the implied warranty of +@REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +@REM Lesser General Public License for more details. +@REM +@REM You should have received a copy of the GNU Lesser General Public +@REM License along with this library; if not, write to the Free Software +@REM Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +@REM +@REM See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +@REM + +%PYTHONBIN% %KERNEL_ROOT_DIR%\salome_adm\cmake_files\am2cmake.py --ghs3dplugin diff --git a/build_configure b/build_configure index 4d2dd1d..33e1049 100755 --- a/build_configure +++ b/build_configure @@ -1,22 +1,23 @@ #!/bin/bash -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # Tool for updating list of .in file for the SALOME project # and regenerating configure script # Author : Marc Tajchman - CEA @@ -25,19 +26,6 @@ # ORIG_DIR=`pwd` CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` -GHS3DPLUGIN_WITH_GUI="yes" - -for option -do - case $option in - -with-gui | --with-gui) - GHS3DPLUGIN_WITH_GUI="yes" - break;; - -without-gui | --without-gui | -with-gui=no | --with-gui=no) - GHS3DPLUGIN_WITH_GUI="no" - break;; - esac -done ######################################################################## # Test if the KERNEL_ROOT_DIR is set correctly @@ -54,16 +42,6 @@ fi # exit #fi -######################################################################## -# Test if the GUI_ROOT_DIR is set correctly - -if test ${GHS3DPLUGIN_WITH_GUI} = yes; then - if test ! -d "${GUI_ROOT_DIR}"; then - echo "failed : GUI_ROOT_DIR variable is not correct !" - exit - fi -fi - ######################################################################## # Test if the GEOM_ROOT_DIR is set correctly @@ -92,40 +70,17 @@ cd ${CONF_DIR} ABS_CONF_DIR=`pwd` ####################################################################### -# Update configure.ac script: to set GHS3DPLUGIN_WITH_GUI variable -sed -e s/GHS3DPLUGIN_WITH_GUI=[a-z]*/GHS3DPLUGIN_WITH_GUI=${GHS3DPLUGIN_WITH_GUI}/g configure.ac > configure.tmp -mv -f configure.tmp configure.ac - -mkdir -p salome_adm/unix/config_files -#cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/* salome_adm/unix/config_files -#cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/pythonbe.py salome_adm/unix - -cp -f ${KERNEL_ROOT_DIR}/salome_adm/unix/SALOMEconfig.h.in salome_adm/unix - -#cp -f ${GUI_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files -#cp -f ${MED_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files -#cp -f ${GEOM_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files -#cp -f ${SMESH_ROOT_DIR}/adm_local/unix/config_files/* salome_adm/unix/config_files - -# remove KERNEL deprecated configure files -#for deprecated in ac_cc_warnings.m4 ac_cxx_partial_specialization.m4 \ -# check_mico.m4 config.guess ltmain.sh ac_cxx_bool.m4 ltconfig ac_cxx_typename.m4 \ -# check_pthreads.m4 config.sub libtool.m4 ac_cxx_mutable.m4 missing -# do -# rm -f salome_adm/unix/config_files/${deprecated} -# done - # ____________________________________________________________________ # aclocal creates the aclocal.m4 file from the standard macro and the -# custom macro embedded in the directory salome_adm/unix/config_files +# custom macro embedded in the directory adm_local/unix/config_files # and KERNEL config_files directory. # output: # aclocal.m4 # autom4te.cache (directory) -echo "====================================================== aclocal" +echo "======================================================= aclocal" -if test ${GHS3DPLUGIN_WITH_GUI} = yes; then +if test -d "${GUI_ROOT_DIR}"; then aclocal -I adm_local/unix/config_files \ -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \ -I ${GUI_ROOT_DIR}/adm_local/unix/config_files \ @@ -146,10 +101,10 @@ fi # version. The files are created in the directory specified with the # AC_CONFIG_AUX_DIR() tag (see configure.ac). # output: -# salome_adm/unix/config_files/config.guess -# salome_adm/unix/config_files/config.sub -# salome_adm/unix/config_files/ltmain.sh -#echo "====================================================== libtoolize" +# adm_local/unix/config_files/config.guess +# adm_local/unix/config_files/config.sub +# adm_local/unix/config_files/ltmain.sh +echo "==================================================== libtoolize" libtoolize --force --copy --automake || exit 1 @@ -169,11 +124,11 @@ autoconf # AC_CONFIG_AUX_DIR() tag (see configure.ac). This step also # creates the Makefile.in files from the Makefile.am files. # output: -# salome_adm/unix/config_files/compile -# salome_adm/unix/config_files/depcomp -# salome_adm/unix/config_files/install-sh -# salome_adm/unix/config_files/missing -# salome_adm/unix/config_files/py-compile +# adm_local/unix/config_files/compile +# adm_local/unix/config_files/depcomp +# adm_local/unix/config_files/install-sh +# adm_local/unix/config_files/missing +# adm_local/unix/config_files/py-compile # Makefile.in (from Makefile.am) echo "====================================================== automake" diff --git a/clean_configure b/clean_configure index 6728b2e..891edb9 100755 --- a/clean_configure +++ b/clean_configure @@ -1,32 +1,25 @@ #!/bin/sh -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + rm -rf autom4te.cache aclocal.m4 configure make_config find . -name "*~" -print -exec rm {} \; find . -name "*.pyc" -print -exec rm {} \; -#exit -# ==================== ON SORT AVANT - -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 src -name Makefile.in | xargs rm -f -rm -f Makefile.in +find . -name Makefile.in | xargs rm -f +( cd adm_local/unix/config_files && rm -f config.* depcomp install-sh l*.m4 ltmain.sh missing py-compile ) diff --git a/configure.ac b/configure.ac index f5c94f7..d39b98b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # PLEASE DO NOT MODIFY configure.in FILE # ALL CHANGES WILL BE DISCARDED BY THE NEXT # build_configure COMMAND @@ -26,14 +27,16 @@ # Modified by : Marc Tajchman (CEA) # Created from configure.in.base # -AC_INIT([Salome2 Project GHS3DPLUGIN module],[5.1.0], [webmaster.salome@opencascade.com], [SalomeGHS3DPLUGIN]) -AC_CONFIG_AUX_DIR(salome_adm/unix/config_files) +AC_INIT([Salome2 Project GHS3DPLUGIN module],[6.5.0], [webmaster.salome@opencascade.com], [SalomeGHS3DPLUGIN]) +AC_CONFIG_AUX_DIR(adm_local/unix/config_files) AC_CANONICAL_HOST AC_CANONICAL_TARGET -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([-Wno-portability]) XVERSION=`echo $VERSION | awk -F. '{printf("0x%02x%02x%02x",$1,$2,$3)}'` AC_SUBST(XVERSION) +VERSION_DEV=1 +AC_SUBST(VERSION_DEV) # set up MODULE_NAME variable for dynamic construction of directories (resources, etc.) MODULE_NAME=ghs3dplugin @@ -78,6 +81,7 @@ echo AC_PROG_MAKE_SET AC_PROG_INSTALL +AC_LOCAL_INSTALL dnl dnl libtool macro check for CC, LD, NM, LN_S, RANLIB, STRIP + pour les librairies dynamiques ! @@ -99,7 +103,7 @@ dnl Fix up the INSTALL macro if it s a relative path. We want the dnl full-path to the binary instead. case "$INSTALL" in *install-sh*) - INSTALL="${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/install-sh -c" + INSTALL="${KERNEL_ROOT_DIR}/adm_local/unix/config_files/install-sh -c" ;; esac @@ -141,7 +145,15 @@ dnl testing MPICH dnl --------------------------------------------- dnl -CHECK_MPICH +dnl CHECK_MPICH + +echo +echo --------------------------------------------- +echo testing MPI +echo --------------------------------------------- +echo + +CHECK_MPI echo echo --------------------------------------------- @@ -217,11 +229,34 @@ AC_SUBST_FILE(CORBA) corba=make_$ORB CORBA=adm_local/unix/$corba -GHS3DPLUGIN_WITH_GUI=yes +echo +echo --------------------------------------------- +echo Testing GUI +echo --------------------------------------------- +echo + +CHECK_GUI_MODULE + +gui_ok=no +if test "${SalomeGUI_need}" != "no" -a "${FullGUI_ok}" = "yes" ; then + gui_ok=yes +fi -AM_CONDITIONAL(GHS3DPLUGIN_ENABLE_GUI, [test "${GHS3DPLUGIN_WITH_GUI}" = "yes"]) +AM_CONDITIONAL(GHS3DPLUGIN_ENABLE_GUI, [test "${gui_ok}" = "yes"]) + +if test "${SalomeGUI_need}" == "yes"; then + if test "${FullGUI_ok}" != "yes"; then + AC_MSG_WARN(For configure GHS3DPLUGIN module necessary full GUI!) + fi +elif test "${SalomeGUI_need}" == "auto"; then + if test "${FullGUI_ok}" != "yes"; then + AC_MSG_WARN(Full GUI not found. Build will be done without GUI!) + fi +elif test "${SalomeGUI_need}" == "no"; then + echo Build without GUI option has been chosen +fi -if test "${GHS3DPLUGIN_WITH_GUI}" = "yes"; then +if test "${gui_ok}" = "yes"; then echo echo --------------------------------------------- @@ -238,35 +273,15 @@ if test "${GHS3DPLUGIN_WITH_GUI}" = "yes"; then echo CHECK_QT +fi - echo - echo --------------------------------------------- - echo testing VTK - echo --------------------------------------------- - echo - - CHECK_VTK - - echo - echo --------------------------------------------- - echo Testing GUI - echo --------------------------------------------- - echo - - CHECK_SALOME_GUI - - echo - echo --------------------------------------------- - echo Testing full GUI - echo --------------------------------------------- - echo +echo +echo --------------------------------------------- +echo testing VTK +echo --------------------------------------------- +echo - CHECK_CORBA_IN_GUI - if test "x${CORBA_IN_GUI}" != "xyes"; then - echo "failed : For configure GHS3DPLUGIN module necessary full GUI !" - exit - fi -fi +CHECK_VTK echo echo --------------------------------------------- @@ -339,6 +354,13 @@ echo --------------------------------------------- echo CHECK_GHS3D +if test "${GHS3D_ok}" = "yes"; then + if test "x$GHS3D_VERSION" = "x" + then + GHS3D_VERSION=`ghs3d -u |grep "TETMESH-GHS3D SOFTWARE"|awk '{print $3}'|awk -F- '{print $1}'|awk -F. '{print $1$2}'` + fi + AC_DEFINE_UNQUOTED(GHS3D_VERSION,${GHS3D_VERSION}) +fi echo echo --------------------------------------------- @@ -347,12 +369,14 @@ echo --------------------------------------------- echo echo Configure -if test "${GHS3DPLUGIN_WITH_GUI}" = "yes"; then -variables="cc_ok boost_ok threads_ok omniORB_ok occ_ok doxygen_ok Kernel_ok Geom_ok Med_ok SMesh_ok GHS3D_ok OpenGL_ok qt_ok vtk_ok" -fi -if test "${GHS3DPLUGIN_WITH_GUI}" = "no"; then -variables="cc_ok boost_ok threads_ok omniORB_ok occ_ok doxygen_ok Kernel_ok Geom_ok Med_ok SMesh_ok GHS3D_ok" +if test "${gui_ok}" = "yes"; then + variables="cc_ok boost_ok threads_ok omniORB_ok occ_ok doxygen_ok Kernel_ok gui_ok Geom_ok Med_ok SMesh_ok GHS3D_ok OpenGL_ok qt_ok vtk_ok" +elif test "${SalomeGUI_need}" != "no"; then + variables="cc_ok boost_ok threads_ok omniORB_ok occ_ok doxygen_ok Kernel_ok gui_ok Geom_ok Med_ok SMesh_ok GHS3D_ok vtk_ok" +else + variables="cc_ok boost_ok threads_ok omniORB_ok occ_ok doxygen_ok Kernel_ok Geom_ok Med_ok SMesh_ok GHS3D_ok vtk_ok" fi + for var in $variables do printf " %10s : " `echo \$var | sed -e "s,_ok,,"` @@ -370,6 +394,10 @@ if test "X$GMAKE" = "Xyes"; then else AC_SUBST(SETX) SETX="set -x" fi + +dnl Build with SMESH cancel compute feature +AC_DEFINE(WITH_SMESH_CANCEL_COMPUTE) + echo echo --------------------------------------------- echo generating Makefiles and configure files @@ -380,21 +408,40 @@ AC_OUTPUT_COMMANDS([ \ chmod +x ./bin/*; \ ]) +AC_HACK_LIBTOOL +AC_CONFIG_COMMANDS([hack_libtool],[ +sed -i "s%^CC=\"\(.*\)\"%hack_libtool (){ \n\ + $(pwd)/hack_libtool \1 \"\$[@]\" \n\ +}\n\ +CC=\"hack_libtool\"%g" libtool +sed -i "s%\(\s*\)for searchdir in \$newlib_search_path \$lib_search_path \$sys_lib_search_path \$shlib_search_path; do%\1searchdirs=\"\$newlib_search_path \$lib_search_path \$sys_lib_search_path \$shlib_search_path\"\n\1for searchdir in \$searchdirs; do%g" libtool +sed -i "s%\(\s*\)searchdirs=\"\$newlib_search_path \$lib_search_path \(.*\)\"%\1searchdirs=\"\$newlib_search_path \$lib_search_path\"\n\1sss_beg=\"\"\n\1sss_end=\"\2\"%g" libtool +sed -i "s%\(\s*\)\(for searchdir in \$searchdirs; do\)%\1for sss in \$searchdirs; do\n\1 if ! test -d \$sss; then continue; fi\n\1 ssss=\$(cd \$sss; pwd)\n\1 if test \"\$ssss\" != \"\" \&\& test -d \$ssss; then\n\1 case \$ssss in\n\1 /usr/lib | /usr/lib64 ) ;;\n\1 * ) sss_beg=\"\$sss_beg \$ssss\" ;;\n\1 esac\n\1 fi\n\1done\n\1searchdirs=\"\$sss_beg \$sss_end\"\n\1\2%g" libtool +],[]) + # This list is initiated using autoscan and must be updated manually # when adding a new file .in to manage. When you execute # autoscan, the Makefile list is generated in the output file configure.scan. # This could be helpfull to update de configuration. AC_OUTPUT([ \ - ./salome_adm/unix/SALOMEconfig.h \ - ./adm_local/Makefile \ - ./adm_local/unix/Makefile \ - ./adm_local/unix/config_files/Makefile \ - ./bin/VERSION \ - ./bin/Makefile \ - ./GHS3DPLUGIN_version.h \ - ./src/Makefile \ - ./src/GUI/Makefile \ - ./resources/Makefile \ - ./idl/Makefile \ + adm_local/Makefile \ + adm_local/unix/Makefile \ + adm_local/unix/config_files/Makefile \ + bin/VERSION \ + bin/Makefile \ + GHS3DPLUGIN_version.h \ + doc/Makefile \ + doc/salome/Makefile \ + doc/salome/gui/Makefile \ + doc/salome/gui/GHS3DPLUGIN/Makefile \ + doc/salome/gui/GHS3DPLUGIN/doxyfile \ + doc/salome/gui/GHS3DPLUGIN/doxyfile_py \ + doc/salome/gui/GHS3DPLUGIN/static/header.html \ + doc/salome/gui/GHS3DPLUGIN/static/header_py.html \ + src/Makefile \ + src/GUI/Makefile \ + src/GHS3DPlugin/Makefile \ + resources/Makefile \ + idl/Makefile \ Makefile \ ]) diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..2599845 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,24 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +SUBDIRS = salome + +usr_docs: + (cd salome && $(MAKE) $(AM_MAKEFLAGS) usr_docs) + +docs: usr_docs diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am new file mode 100644 index 0000000..15038d3 --- /dev/null +++ b/doc/salome/Makefile.am @@ -0,0 +1,28 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SUBDIRS = gui +SUBDIRSGUI = gui + +usr_docs: + @@SETX@; for d in $(SUBDIRSGUI); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done; + +docs: usr_docs \ No newline at end of file diff --git a/doc/salome/gui/GHS3DPLUGIN/Makefile.am b/doc/salome/gui/GHS3DPLUGIN/Makefile.am new file mode 100755 index 0000000..dfe458e --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/Makefile.am @@ -0,0 +1,62 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +EXTRA_DIST += images input static/footer.html static/doxygen.css + +guidocdir = $(docdir)/gui/GHS3DPLUGIN +guidoc_DATA = images/head.png + + +usr_docs: doxyfile + echo "===========================================" ; \ + echo "Generating Python interface documentation"; \ + echo "===========================================" ; \ + $(DOXYGEN) doxyfile_py \ + echo "===========================================" ; \ + echo "Generating GUI documentation" ; \ + echo "===========================================" ; \ + $(DOXYGEN) doxyfile ; + +docs: usr_docs + +clean-local: + @for filen in `find . -maxdepth 1` ; do \ + case $${filen} in \ + ./Makefile | ./doxyfile | ./doxyfile_py ) ;; \ + . | .. | ./static ) ;; \ + *) echo "Removing $${filen}" ; rm -rf $${filen} ;; \ + esac ; \ + done ; + +install-data-local: usr_docs + $(INSTALL) -d $(DESTDIR)$(docdir)/gui/GHS3DPLUGIN + @for filen in `find . -maxdepth 1` ; do \ + case $${filen} in \ + ./Makefile | ./doxyfile | ./doxyfile_py ) ;; \ + ./doxyfile.bak | ./doxyfile_py.bak ) ;; \ + . | .. | ./static ) ;; \ + *) echo "Installing $${filen}" ; cp -rp $${filen} $(DESTDIR)$(docdir)/gui/GHS3DPLUGIN ;; \ + esac ; \ + done ; + cp -rp $(srcdir)/images/head.png $(DESTDIR)$(docdir)/gui/GHS3DPLUGIN/ghs3dpluginpy_doc/ ; + +uninstall-local: + rm -rf $(DESTDIR)$(docdir)/gui/GHS3DPLUGIN + diff --git a/doc/salome/gui/GHS3DPLUGIN/doxyfile.in b/doc/salome/gui/GHS3DPLUGIN/doxyfile.in new file mode 100755 index 0000000..7af64c9 --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/doxyfile.in @@ -0,0 +1,81 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "SALOME GHS3DPLUGIN User's Guide" +OUTPUT_DIRECTORY = . +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +TAB_SIZE = 5 + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES + +#--------------------------------------------------------------------------- +#Input related options +#--------------------------------------------------------------------------- +INPUT = @srcdir@/input +FILE_PATTERNS = *.doc +EXCLUDE = +IMAGE_PATH = @srcdir@/images +EXAMPLE_PATH = + +#--------------------------------------------------------------------------- +#HTML related options +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = . +HTML_HEADER = @builddir@/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 + +#--------------------------------------------------------------------------- +#SORT related options +#--------------------------------------------------------------------------- +SORT_GROUP_NAMES = NO + + +#--------------------------------------------------------------------------- +#LaTeX related option +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +EXTRA_PACKAGES = amsmath + +#--------------------------------------------------------------------------- +#RTF related options +#--------------------------------------------------------------------------- +GENERATE_RTF = NO + +#--------------------------------------------------------------------------- +#External reference options +#--------------------------------------------------------------------------- + +#rnv: 07.04.2011 Workaround for the doxygen 1.7.3: +#because it wrongly defines location of the html files for search. +TAGFILES = ghs3dpluginpy_doc.tag=../GHS3DPLUGIN/ghs3dpluginpy_doc +SEARCHENGINE = YES \ No newline at end of file diff --git a/doc/salome/gui/GHS3DPLUGIN/doxyfile_py.in b/doc/salome/gui/GHS3DPLUGIN/doxyfile_py.in new file mode 100755 index 0000000..47082b5 --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/doxyfile_py.in @@ -0,0 +1,159 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "SALOME GHS3DPLUGIN User's Guide" +OUTPUT_DIRECTORY = . +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ALWAYS_DETAILED_SEC = YES +INLINE_INHERITED_MEMB = YES +FULL_PATH_NAMES = NO +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = YES +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 5 +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = YES +BUILTIN_STL_SUPPORT = NO +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = NO +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = YES +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = YES +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 +MAX_INITIALIZER_LINES = 25 +SHOW_USED_FILES = NO +SHOW_DIRECTORIES = NO + +#--------------------------------------------------------------------------- +# 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 warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +EXCLUDE_SYMLINKS = NO +EXAMPLE_RECURSIVE = NO + +#--------------------------------------------------------------------------- +#Input related options +#--------------------------------------------------------------------------- +INPUT = @top_srcdir@/src/GHS3DPlugin/GHS3DPluginDC.py +FILE_PATTERNS = +IMAGE_PATH = @srcdir@/images +RECURSIVE = NO +EXAMPLE_PATH = + +#--------------------------------------------------------------------------- +#HTML related options +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = ghs3dpluginpy_doc +HTML_HEADER = @builddir@/static/header_py.html +HTML_FOOTER = @srcdir@/static/footer.html +HTML_STYLESHEET = @srcdir@/static/doxygen.css +TOC_EXPAND = YES +DISABLE_INDEX = NO +GENERATE_TREEVIEW = NO + +#--------------------------------------------------------------------------- +#LaTeX related option +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO + +#--------------------------------------------------------------------------- +#RTF related options +#--------------------------------------------------------------------------- +GENERATE_RTF = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = NO +HIDE_UNDOC_RELATIONS = NO +HAVE_DOT = NO +CLASS_GRAPH = NO +COLLABORATION_GRAPH = NO +GROUP_GRAPHS = NO +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = NO +INCLUDED_BY_GRAPH = NO +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = NO +DIRECTORY_GRAPH = NO +DOT_IMAGE_FORMAT = jpg +DOT_FONTNAME = Arial +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 + +#--------------------------------------------------------------------------- +#External reference options +#--------------------------------------------------------------------------- +GENERATE_TAGFILE = ghs3dpluginpy_doc.tag +SEARCHENGINE = YES \ No newline at end of file diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_meshes.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_meshes.png new file mode 100644 index 0000000..9ddc012 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_meshes.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_vertices.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_vertices.png new file mode 100644 index 0000000..d3a4bbc Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_enforced_vertices.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png new file mode 100644 index 0000000..c254112 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_basic.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_basic.png new file mode 100644 index 0000000..9519c14 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_basic.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot.png new file mode 100644 index 0000000..a9e7b97 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf1.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf1.png new file mode 100644 index 0000000..8923f00 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf1.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf2.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf2.png new file mode 100644 index 0000000..5daf8a2 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf2.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf3.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf3.png new file mode 100644 index 0000000..f6911ce Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf3.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf4.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf4.png new file mode 100644 index 0000000..46f12d8 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf4.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf5.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf5.png new file mode 100644 index 0000000..531b812 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf5.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf6.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf6.png new file mode 100644 index 0000000..003f89f Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_screenshot_enf6.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/head.png b/doc/salome/gui/GHS3DPLUGIN/images/head.png new file mode 100755 index 0000000..307d9ef Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/head.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/images/image2.gif b/doc/salome/gui/GHS3DPLUGIN/images/image2.gif new file mode 100755 index 0000000..1983513 Binary files /dev/null and b/doc/salome/gui/GHS3DPLUGIN/images/image2.gif differ diff --git a/doc/salome/gui/GHS3DPLUGIN/input/additional_hypo.doc b/doc/salome/gui/GHS3DPLUGIN/input/additional_hypo.doc new file mode 100644 index 0000000..90873f2 --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/input/additional_hypo.doc @@ -0,0 +1,18 @@ +/*! + +\page additional_hypo_page Additional Hypotheses + +\n Additional Hypotheses can be applied as a supplement to the +main hypotheses, introducing additional concepts to mesh creation. + +One additional hypotheses can be used together with GHS3D algoritm: +
    +
  • Viscous Layers additional hypothesis can be used together with GHS3D. +This hypothesis allows creation of layers of highly stretched prisms near +mesh boundary, which is beneficial for high quality viscous +computations. The prisms constructed on the quadrangular mesh faces are +actually the hexahedrons.
  • +
+ +For more detailed description of the this additional hypothesis please refer SALOME Mesh User's Guide. +*/ diff --git a/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc b/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc new file mode 100644 index 0000000..4c4ce5f --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc @@ -0,0 +1,180 @@ +/*! + +\page ghs3d_hypo_page GHS3D Parameters hypothesis + +\anchor ghs3d_top +\n GHS3D Parameters hypothesis works only with Tetrahedron (GHS3D) +algorithm. This algorithm is a commercial software. +\n To get a licence, visit http://www.distene.com/corp/eval-distene.html + +-# \ref ghs3d_general_parameters +-# \ref ghs3d_advanced_parameters +-# \ref ghs3d_enforced_vertices +-# \ref ghs3d_enforced_meshes + +\section ghs3d_general_parameters General parameters + +\image html ghs3d_parameters_basic.png + +
    +
  • Name - allows to define the name of the hypothesis (GHS3D +Parameters by default).
  • + +
  • To mesh holes - if checked, the algorithm will +create mesh in the holes inside a solid shape, else only the outermost +shape will be meshed. Volumic elements created within holes are bound +to the solid.
  • + +
  • Optimization level - allows choosing the required +optimization level: +
      +
    • none,
    • +
    • light,
    • +
    • medium (standard),
    • +
    • standard+,
    • +
    • strong.
    • +
    +Higher level of +optimisation provides better mesh, but can be time-consuming. +
  • +
+ +\ref ghs3d_top "Back to top" + +\section ghs3d_advanced_parameters Advanced parameters + +\image html ghs3d_parameters_advanced.png + +
  • Maximum memory size - launches ghs3d software with +work space limited to the specified amount of RAM, in Mbytes. If this option is +checked off, the software will be launched with 7O% of the total RAM space.
  • + +
  • Initial memory size - starts ghs3d software with +the specified amount of work space, in Mbytes. If this option is checked off, the +software will be started with 100 Megabytes of working space.
  • + +
  • Working directory - allows defining the folder for input and output +files of ghs3d software, which are the files starting with "GHS3D_" prefix.
  • + +
  • Keep working files - allows checking input and output files +of ghs3d software, while usually these files are removed after the +launch of the mesher.
  • + +
  • Verbose level - to choose verbosity level in the range from +0 to 10. +
    • 0, no standard output, +
    • 2, prints the data, quality statistics of the skin and final +meshes and indicates when the final mesh is being saved. In addition +the software gives indication regarding the CPU time. +
    • 10, same as 2 plus the main steps in the computation, quality +statistics histogram of the skin mesh, quality statistics histogram +together with the characteristics of the final mesh. +
  • + +
  • To create new nodes - if this option is checked off, ghs3d +tries to create tetrahedrons using only the nodes of the 2D mesh.
  • + +
  • To remove the initial central point TetMesh-GHS3D adds an internal point +at the gravity centre of the bounding box to speed up and to simplify +the meshing process. However, it is possible to refrain from creating +this point by using the command line option -no initial central point. This can be +particularly useful to generate a volume mesh without internal points at all and in some rare cases +at the boundary regeneration phase when it is impossible to proceed +with the standard options +(for example, when one dimension of the domain is more than 20 times greater than the other two). +Use this option if the boundary regeneration has failed with the standard parameters and before using +the recovery version (command line option -C). +Note: when using this option, the speed of the meshing process may +decrease, and the quality may change. +Note: the boundary regeneration may fail with this option, in some rare cases.
  • + +
  • To use boundary recovery version - enables using a +boundary recovery module which tries to +create volume meshes starting from very poor quality surface meshes +(almost flat triangles on the surface, high density propagation, +extreme aspect ratios, etc.) which fails with the standard version. The +resulting volume mesh will however most likely have a very poor +quality (poor aspect ratio of elements, tetrahedra with a very small +positive volume).
  • + +
  • To use FEM correction - Applies finite-element correction by +replacing overconstrained elements where it is possible. At first the process +slices the overconstrained edges and at second the overconstrained +facets. This ensures that there are no edges with two boundary +vertices and that there are no facets with three boundary vertices. TetMesh-GHS3D gives the initial +and final overconstrained edges and facets. It also gives the facets +which have three edges on the boundary. +Note: when using this option, the speed of the meshing process may +decrease, quality may change, and the smallest volume may be smaller. +By default, the FEM correction is not used.
  • + +
  • Option as text - allows to input in the command line any text +for ghs3d, for example, advanced options.
  • + + + +\ref ghs3d_top "Back to top" + +\section ghs3d_enforced_vertices Enforced vertices + +\note This feature is currently available only on meshes with no +geometry attached. Such meshes can be obtained by +
      +
    • Copying an existing mesh
    • +
    • Importing a mesh from file
    • +
    • Applying a transformation to a mesh a get result in a new mesh
    • +
    + +\image html ghs3d_enforced_vertices.png + +GHS3D algorithm can locally make the mesh finer. It is possible to +define enforced vertices in the volume where the mesh will be detailed. +A node will be created at the enforced vertex coordinates. + +An enforced vertex is defined by: +
      +
    • A vertex
    • +
        +
      • from GEOM (Vertex, Compound)
      • +
      • or from (x,y,z) cartesian coordinates
      • +
      +
    • A constant physical size
    • +
    • If a group name is given, the created node will be added to the +group. If the group does not exist, it is created.
    • +
    +\ref ghs3d_top "Back to top" + +\section ghs3d_enforced_meshes Enforced Meshes + +\note This feature is currently only available on 2D meshes with no +geometry attached. Such meshes can be obtained by +
      +
    • Copying an existing 2D mesh
    • +
    • Importing a 2D mesh from file
    • +
    • Applying a transformation to a 2D mesh a get result in a new mesh
    • +
    + +\image html ghs3d_enforced_meshes.png + +GHS3D algorithm can be forced by other meshes, sub-meshes or +groups. The constraint elements should be contained +entirely into the solid mesh. +
      +
    • The constraint element types are: +
        +
      • NODE
      • +
      • EDGE
      • +
      • FACE
      • +
    • +
    • If a size is given, the mesh will be refined around the enforced +elements given the size (not available yet)
    • +
    • If a group name is given, the enforced elements will be added to +the group. If the group does not exist, it is created.
    • +
    + +
    See Also a sample TUI Script of the \ref tui_ghs3d "creation of a Ghs3D hypothesis", including enforced vertices and meshes. + +\ref ghs3d_top "Back to top" + + +*/ diff --git a/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc b/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc new file mode 100644 index 0000000..09825c1 --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/input/ghs3dplugin_python_interface.doc @@ -0,0 +1,240 @@ +/*! + +\page ghs3dplugin_python_interface_page Python Interface + +Python package \ref GHS3DPluginDC "GHS3DPlugin" defines several classes, destined for creation of the 3D meshes. + +Documentation for GHS3DPlugin package is available in linear form grouped by classes, declared in the GHS3DPluginDC.py file. + +Below you can see an example of usage of the GHS3DPlugin package for mesh generation: + +\anchor tui_ghs3d + +
      +
    1. \ref tui_ghs3d_basic "Construction of Mesh using Ghs3D algorithm"
    2. +
    3. \ref tui_ghs3d_enforced_vertices "Adding enforced vertices"
    4. +
    5. \ref tui_ghs3d_enforced_meshes "Adding enforced mesh"
    6. +
    + +\anchor tui_ghs3d_basic +

    Construction of Mesh using Ghs3D algorithm

    + +\code +import geompy +import smesh +import BLSURFPlugin +import GHS3DPlugin + +# create a box +box = geompy.MakeBoxDXDYDZ(200., 200., 200.) +geompy.addToStudy(box, "box") + +# create a mesh on the box +ghs3dMesh = smesh.Mesh(box,"box: Ghs3D and BLSurf mesh") + +# create a BLSurf algorithm for faces +BLSURF = ghs3dMesh.Triangle(algo=smesh.BLSURF) +GHS3D = ghs3dMesh.Tetrahedron(algo=smesh.GHS3D) + +# compute the mesh +ghs3dMesh.Compute() + +# End of script +\endcode + +\image html ghs3d_screenshot.png Ghs3d mesh withtout hypothesis + +\ref tui_ghs3d "Back to top" + +\anchor tui_ghs3d_enforced_vertices +

    Adding enforced vertices

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

    Adding enforced mesh

    + +\code + +# It is possible to constrain GHS3D with another mesh or group. +# The constraint can refer to the nodes, edges or faces. +# This feature is available only on 2D meshes without geometry. +# The constraining elements are called enforced elements for the mesh. +# They can be recovered using groups if necessary. + +# In the following examples, a box and a cylinder are meshed in 2D. +# The mesh of the cylinder will be used as a constraint for the +# 3D mesh of the box. + +import geompy +import smesh +import BLSURFPlugin +import GHS3DPlugin + +box = geompy.MakeBoxDXDYDZ(200, 200, 200) +geompy.addToStudy( box, "box" ) +cylindre = geompy.MakeCylinderRH(50, 50) +geompy.TranslateDXDYDZ(cylindre, 100, 100, 30) +face_cyl = geompy.ExtractShapes(cylindre, geompy.ShapeType["FACE"], True)[1] +geompy.addToStudy( cylindre, 'cylindre' ) +geompy.addToStudyInFather( cylindre, face_cyl, 'face_cyl' ) +p1 = geompy.MakeVertex(20, 20, 20) +p2 = geompy.MakeVertex(180, 180, 20) +c = geompy.MakeCompound([p1,p2]) +geompy.addToStudy( p1, "p1" ) +geompy.addToStudy( p2, "p2" ) +geompy.addToStudy( c, "c" ) + +# Create the 2D algorithm and hypothesis +BLSURF = smesh.CreateHypothesis('BLSURF', 'BLSURFEngine') +# For the box +BLSURF_Parameters = smesh.CreateHypothesis('BLSURF_Parameters', 'BLSURFEngine') +BLSURF_Parameters.SetPhysicalMesh( 1 ) +BLSURF_Parameters.SetPhySize( 200 ) +# For the cylinder +BLSURF_Parameters2 = smesh.CreateHypothesis('BLSURF_Parameters', 'BLSURFEngine') +BLSURF_Parameters2.SetGeometricMesh( 1 ) + +# Create the 3D algorithm and hypothesis +GHS3D = smesh.CreateHypothesis('GHS3D_3D', 'GHS3DEngine') +GHS3D_Parameters_node = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +#GHS3D_Parameters_node.SetToMeshHoles( 1 ) +GHS3D_Parameters_edge = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +#GHS3D_Parameters_edge.SetToMeshHoles( 1 ) +GHS3D_Parameters_face = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +GHS3D_Parameters_face.SetToMeshHoles( 1 ) # to mesh inside the cylinder +GHS3D_Parameters_mesh = smesh.CreateHypothesis('GHS3D_Parameters', 'GHS3DEngine') +GHS3D_Parameters_mesh.SetToMeshHoles( 1 ) # to mesh inside the cylinder + +# Create the mesh on the cylinder +Mesh_cylindre = smesh.Mesh(cylindre) +smesh.SetName(Mesh_cylindre,"Mesh_cylindre") +Mesh_cylindre.AddHypothesis( BLSURF ) +Mesh_cylindre.AddHypothesis( BLSURF_Parameters2 ) +# Create some groups +face_cyl_faces = Mesh_cylindre.GroupOnGeom(face_cyl,'group_face_cyl', smesh.FACE) +face_cyl_edges = Mesh_cylindre.GroupOnGeom(face_cyl,'group_edge_cyl', smesh.EDGE) +face_cyl_nodes = Mesh_cylindre.GroupOnGeom(face_cyl,'group_node_cyl', smesh.NODE) +Mesh_cylindre.Compute() + +# Create the mesh on the cylinder +Mesh_box_tri = smesh.Mesh(box) +smesh.SetName(Mesh_box_tri,"Mesh_box_tri") +Mesh_box_tri.AddHypothesis( BLSURF ) +Mesh_box_tri.AddHypothesis( BLSURF_Parameters ) +Mesh_box_tri.Compute() + +# Create 4 copies of the 2D mesh to test the 3 types of contraints (NODE, EDGE, FACE) +# from the whole mesh and from groups of elements. +# Then the 3D algo and hypothesis are assigned to them. + +mesh_mesh = smesh.CopyMesh( Mesh_box_tri, 'Enforced by faces of mesh', 0, 0) +mesh_mesh.AddHypothesis( GHS3D ) +mesh_mesh.AddHypothesis( GHS3D_Parameters_mesh) + +mesh_node = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of nodes', 0, 0) +mesh_node.AddHypothesis( GHS3D ) +mesh_node.AddHypothesis( GHS3D_Parameters_node) + +mesh_edge = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of edges', 0, 0) +mesh_edge.AddHypothesis( GHS3D ) +mesh_edge.AddHypothesis( GHS3D_Parameters_edge) + +mesh_face = smesh.CopyMesh( Mesh_box_tri, 'Enforced by group of faces', 0, 0) +mesh_face.AddHypothesis( GHS3D ) +mesh_face.AddHypothesis( GHS3D_Parameters_face) + +# Add the enforced elements +GHS3D_Parameters_mesh.SetEnforcedMeshWithGroup(Mesh_cylindre.GetMesh(),smesh.FACE,"faces from cylinder") +GHS3D_Parameters_node.SetEnforcedMeshWithGroup(face_cyl_nodes,smesh.NODE,"nodes from face_cyl_nodes") +GHS3D_Parameters_edge.SetEnforcedMeshWithGroup(face_cyl_edges,smesh.EDGE,"edges from face_cyl_edges") +GHS3D_Parameters_face.SetEnforcedMeshWithGroup(face_cyl_faces,smesh.FACE,"faces from face_cyl_faces") + +#Compute the meshes +mesh_node.Compute() +mesh_edge.Compute() +mesh_face.Compute() +mesh_mesh.Compute() + +# End of script + +\endcode + +\image html ghs3d_screenshot_enf3.png +\image html ghs3d_screenshot_enf4.png +\image html ghs3d_screenshot_enf5.png +\image html ghs3d_screenshot_enf6.png + +\ref tui_ghs3d "Back to top" + +*/ diff --git a/doc/salome/gui/GHS3DPLUGIN/input/index.doc b/doc/salome/gui/GHS3DPLUGIN/input/index.doc new file mode 100644 index 0000000..e39ba6d --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/input/index.doc @@ -0,0 +1,25 @@ +/*! + +\mainpage Introduction to GHS3DPLUGIN + +\note GHS3DPLUGIN plugin used GHS3D commercial mesher and require a +license to be used within the Mesh module. + +\n \b GHS3DPLUGIN plugin is destined for: + +
      +
    • Meshing 3D geometric entities.
    • + - Volumes are split into tetrahedral (pyramidal) elements. +
    • Generating 3D meshes from 2D meshes, working without geometrical objects.
    • +
    + +To manage parameters of the GHS3DPLUGIN use \subpage ghs3d_hypo_page and \subpage additional_hypo_page + +Also all GHS3DPLUGIN functionalities are accessible via +\subpage ghs3dplugin_python_interface_page "GHS3DPLUGIN Python interface". + + +\image html image2.gif "Example of a tetrahedral 3D mesh" + + +*/ diff --git a/doc/salome/gui/GHS3DPLUGIN/static/doxygen.css b/doc/salome/gui/GHS3DPLUGIN/static/doxygen.css new file mode 100755 index 0000000..7a2dcbd --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/static/doxygen.css @@ -0,0 +1,836 @@ +/* The standard CSS for doxygen */ + +body, table, div, p, dl { + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 12px; +} + +/* @group Heading Levels */ + +h1 { + font-size: 150%; +} + +h2 { + font-size: 120%; +} + +h3 { + font-size: 100%; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd, p.starttd { + margin-top: 2px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + padding: 2px; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #ffffff; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code { + color: #4665A2; +} + +a.codeRef { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +.fragment { + font-family: monospace, fixed; + font-size: 105%; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.version { + border:1px solid #0000FF; + color: #CCCCCC; + font-family: Arial, Helvetica, sans-serif; + font-size: 9pt; + text-align: center; + width:100px; + -moz-border-radius: 8px; + margin: 5px; +} + +div.footer1 { + background-color: #DFE5F1; + border: 1px solid #AAAAAA; + font-family: Arial, Helvetica, sans-serif; + font-size: 11px; + padding: 10px; + margin-top: 15px; +} + + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 10px; + margin-right: 10px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +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 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memItemLeft, .memItemRight, .memTemplParams { + border-top: 1px solid #C4CFE5; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.memitem { + padding: 0; + margin-bottom: 10px; +} + +.memname { + white-space: nowrap; + font-weight: bold; + margin-left: 6px; +} + +.memproto { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 8px; + border-top-left-radius: 8px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 8px; + -moz-border-radius-topleft: 8px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 8px; + -webkit-border-top-left-radius: 8px; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + +} + +.memdoc { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 2px 5px; + background-color: #FBFCFD; + border-top-width: 0; + /* opera specific markup */ + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 8px; + -moz-border-radius-bottomright: 8px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7F8FB 95%, #EEF1F7); + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 8px; + -webkit-border-bottom-right-radius: 8px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7F8FB), to(#EEF1F7)); +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} + +.params, .retval, .exception, .tparams { + border-spacing: 6px 2px; +} + +.params .paramname, .retval .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + + + + +/* @end */ + +/* @group Directory (tree) */ + +/* for the tree view */ + +.ftvtree { + font-family: sans-serif; + margin: 0px; +} + +/* these are for tree view when used as main index */ + +.directory { + font-size: 9pt; + font-weight: bold; + margin: 5px; +} + +.directory h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +/* +The following two styles can be used to replace the root node title +with an image of your choice. Simply uncomment the next two styles, +specify the name of your image and be sure to set 'height' to the +proper pixel height of your image. +*/ + +/* +.directory h3.swap { + height: 61px; + background-repeat: no-repeat; + background-image: url("yourimage.gif"); +} +.directory h3.swap span { + display: none; +} +*/ + +.directory > h3 { + margin-top: 0; +} + +.directory p { + margin: 0px; + white-space: nowrap; +} + +.directory div { + display: none; + margin: 0px; +} + +.directory img { + vertical-align: -30%; +} + +/* these are for tree view when not used as main index */ + +.directory-alt { + font-size: 100%; + font-weight: bold; +} + +.directory-alt h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +.directory-alt > h3 { + margin-top: 0; +} + +.directory-alt p { + margin: 0px; + white-space: nowrap; +} + +.directory-alt div { + display: none; + margin: 0px; +} + +.directory-alt img { + vertical-align: -30%; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable { + border-collapse:collapse; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; +} + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; +} + +.navpath li.navelem a:hover +{ + color:#6884BD; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#364D7C; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.ingroups +{ + font-size: 8pt; + padding-left: 5px; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + +.title { + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +dl +{ + padding: 0 0 0 10px; +} + +dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug +{ + border-left:4px solid; + padding: 0 0 0 6px; +} + +dl.note +{ + border-color: #D0D000; +} + +dl.warning, dl.attention +{ + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant +{ + border-color: #00D000; +} + +dl.deprecated +{ + border-color: #505050; +} + +dl.todo +{ + border-color: #00C0E0; +} + +dl.test +{ + border-color: #3030E0; +} + +dl.bug +{ + border-color: #C08050; +} + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectname +{ + background-color: #175783; + border: 1px solid; + height: 80px; + background-repeat: no-repeat; +/* font: 300% arial,sans-serif;*/ + margin: 0px; + padding: 0px; +} + +#projectbrief +{ + font: 120% arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + background: url("head.png"); + background-color: #175783; + border: 1px solid; + height: 80px; + background-repeat: no-repeat; + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #5373B4; +} + diff --git a/doc/salome/gui/GHS3DPLUGIN/static/footer.html b/doc/salome/gui/GHS3DPLUGIN/static/footer.html new file mode 100755 index 0000000..4c89a2b --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/static/footer.html @@ -0,0 +1,12 @@ + + + +
    +
    + Copyright © 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
    + Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
    +
    +
    + + + \ No newline at end of file diff --git a/doc/salome/gui/GHS3DPLUGIN/static/header.html.in b/doc/salome/gui/GHS3DPLUGIN/static/header.html.in new file mode 100755 index 0000000..4571b43 --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/static/header.html.in @@ -0,0 +1,20 @@ + + + + + +$title + +$treeview +$search +$mathjax + + + + +
    +
    Version: @VERSION@
    + +
    diff --git a/doc/salome/gui/GHS3DPLUGIN/static/header_py.html.in b/doc/salome/gui/GHS3DPLUGIN/static/header_py.html.in new file mode 100644 index 0000000..61414bb --- /dev/null +++ b/doc/salome/gui/GHS3DPLUGIN/static/header_py.html.in @@ -0,0 +1,21 @@ + + + + + +$title + +$treeview +$search +$mathjax + + + + +
    +
    Version: @VERSION@
    + + +
    diff --git a/doc/salome/gui/Makefile.am b/doc/salome/gui/Makefile.am new file mode 100644 index 0000000..ddbdb9e --- /dev/null +++ b/doc/salome/gui/Makefile.am @@ -0,0 +1,26 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +SUBDIRS = GHS3DPLUGIN + +usr_docs: + (cd GHS3DPLUGIN && $(MAKE) $(AM_MAKEFLAGS) usr_docs) + +docs: usr_docs diff --git a/idl/GHS3DPlugin_Algorithm.idl b/idl/GHS3DPlugin_Algorithm.idl index a402d78..8af4f1e 100644 --- a/idl/GHS3DPlugin_Algorithm.idl +++ b/idl/GHS3DPlugin_Algorithm.idl @@ -1,21 +1,22 @@ -// Copyright (C) 2004-2008 CEA/DEN, EDF R&D +// Copyright (C) 2004-2012 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 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : GHS3D_Algorithm.idl // Author : Julia DOROVSKIKH // $Header$ @@ -25,17 +26,41 @@ #include "SALOME_Exception.idl" #include "SMESH_Hypothesis.idl" +#include "SMESH_Mesh.idl" /*! * GHS3DPlugin: interfaces to GHS3D related hypotheses and algorithms */ module GHS3DPlugin { + typedef sequence TCoords; + struct GHS3DEnforcedVertex { + string name; + string geomEntry; + boolean isCompound; + TCoords coords; + string groupName; + double size; + }; + + typedef sequence GHS3DEnforcedVertexList; + + struct GHS3DEnforcedMesh { + string name; + string entry; + SMESH::ElementType elementType; + string groupName; + double size; + }; + + typedef sequence GHS3DEnforcedMeshList; + /*! * GHS3DPlugin_GHS3D: interface of "Tetrahedron (GHS3D)" algorithm */ interface GHS3DPlugin_GHS3D : SMESH::SMESH_3D_Algo { + SMESH::SMESH_Mesh importGMFMesh(in string aGMFFileName); }; /*! @@ -99,11 +124,57 @@ module GHS3DPlugin */ void SetToUseBoundaryRecoveryVersion(in boolean toUse); boolean GetToUseBoundaryRecoveryVersion(); + /*! + * Applies finite-element correction by replacing overconstrained elements where + * it is possible. The process is cutting first the overconstrained edges and + * second the overconstrained facets. This insure that no edges have two boundary + * vertices and that no facets have three boundary vertices. + */ + void SetFEMCorrection(in boolean toUseFem); + boolean GetFEMCorrection(); + /*! + * To removes initial central point. + */ + void SetToRemoveCentralPoint(in boolean toRemove); + boolean GetToRemoveCentralPoint(); /*! * To set hiden/undocumented/advanced options */ void SetTextOption(in string option); string GetTextOption(); + /*! + * To set an enforced vertex + */ + boolean SetEnforcedVertex(in double x, in double y, in double z, in double size) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexNamed(in double x, in double y, in double z, in double size, in string vertexName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexWithGroup(in double x, in double y, in double z, in double size, in string groupName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexNamedWithGroup(in double x, in double y, in double z, in double size, in string vertexName, in string groupName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexGeom(in GEOM::GEOM_Object theVertex, in double size) raises (SALOME::SALOME_Exception); + boolean SetEnforcedVertexGeomWithGroup(in GEOM::GEOM_Object theVertex, in double size, in string groupName) raises (SALOME::SALOME_Exception); + double GetEnforcedVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + double GetEnforcedVertexGeom(in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception); + boolean RemoveEnforcedVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + boolean RemoveEnforcedVertexGeom(in GEOM::GEOM_Object theVertex) raises (SALOME::SALOME_Exception); + GHS3DEnforcedVertexList GetEnforcedVertices(); + void ClearEnforcedVertices(); + /*! + * Set/get/unset an enforced vertex (private method for GUI) + */ + boolean p_SetEnforcedVertex(in double size, in double x, in double y, in double z, + in string theVertexName, in string theVertexEntry, in string groupName, + in boolean isCompound) raises (SALOME::SALOME_Exception); + + boolean SetEnforcedMesh(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType) raises (SALOME::SALOME_Exception); + boolean SetEnforcedMeshWithGroup(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in string groupName) raises (SALOME::SALOME_Exception); + boolean SetEnforcedMeshSize(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in double size) raises (SALOME::SALOME_Exception); + boolean SetEnforcedMeshSizeWithGroup(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, in double size, in string groupName) raises (SALOME::SALOME_Exception); + GHS3DEnforcedMeshList GetEnforcedMeshes(); + void ClearEnforcedMeshes(); + /*! + * Set/get/unset an enforced vertex (private method for GUI) + */ + boolean p_SetEnforcedMesh(in SMESH::SMESH_IDSource theSource, in SMESH::ElementType elementType, + in double size, in string groupName) raises (SALOME::SALOME_Exception); }; }; diff --git a/idl/Makefile.am b/idl/Makefile.am index 229ec1e..e675d27 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # This Makefile is responsible of generating the client and server # implementation of IDL interfaces for both C++ and python usage. # The building process of the C++ files is in charge of each source @@ -25,6 +26,8 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am BASEIDL_FILES = GHS3DPlugin_Algorithm.idl +BASEIDL_FILES_PY=$(BASEIDL_FILES:%.idl=%_idl.py) + # This variable defines the files to be installed dist_salomeidl_DATA = $(BASEIDL_FILES) @@ -41,18 +44,19 @@ GHS3DPlugin_AlgorithmDynSK.cc: GHS3DPlugin_AlgorithmSK.cc nodist_salomeinclude_HEADERS = $(BASEIDL_FILES:%.idl=%.hh) libSalomeIDLGHS3DPLUGIN_la_CPPFLAGS = \ - -I$(top_builddir)/salome_adm/unix \ -I$(top_builddir)/idl \ $(CORBA_CXXFLAGS) \ $(CORBA_INCLUDES) \ $(KERNEL_CXXFLAGS) \ $(GEOM_CXXFLAGS) \ + $(MED_CXXFLAGS) \ $(SMESH_CXXFLAGS) libSalomeIDLGHS3DPLUGIN_la_LDFLAGS = -no-undefined -version-info=0:0:0 libSalomeIDLGHS3DPLUGIN_la_LIBADD = \ $(KERNEL_LDFLAGS) -lSalomeIDLKernel \ $(GEOM_LDFLAGS) -lSalomeIDLGEOM \ + $(MED_LDFLAGS) -lSalomeIDLMED \ $(SMESH_LDFLAGS) -lSalomeIDLSMESH \ @CORBA_LIBS@ @@ -64,6 +68,7 @@ OMNIORB_IDLPYFLAGS = \ -I$(top_builddir)/idl/salome \ -I$(KERNEL_ROOT_DIR)/idl/salome \ -I$(GEOM_ROOT_DIR)/idl/salome \ + -I$(MED_ROOT_DIR)/idl/salome \ -I$(SMESH_ROOT_DIR)/idl/salome IDLCXXFLAGS = \ @@ -72,12 +77,13 @@ IDLCXXFLAGS = \ -I$(top_builddir)/idl/salome \ -I$(KERNEL_ROOT_DIR)/idl/salome \ -I$(GEOM_ROOT_DIR)/idl/salome \ - -I$(SMESH_ROOT_DIR)/idl/salome \ - -I$(top_builddir)/salome_adm/unix + -I$(MED_ROOT_DIR)/idl/salome \ + -I$(SMESH_ROOT_DIR)/idl/salome IDLPYFLAGS = \ @IDLPYFLAGS@ \ -I$(KERNEL_ROOT_DIR)/idl/salome \ -I$(GEOM_ROOT_DIR)/idl/salome \ + -I$(MED_ROOT_DIR)/idl/salome \ -I$(SMESH_ROOT_DIR)/idl/salome # potential problem on parallel make on the following - multiple outputs @@ -93,9 +99,15 @@ install-exec-local: $(BASEIDL_FILES:%=$(top_srcdir)/idl/%) $(OMNIORB_IDL) $(IDLPYFLAGS) -C$(DESTDIR)$(salomepythondir) $$file ; \ done -# uninstall-local removes too much, but it works in distcheck +# we want to remove only staff generated for IDL files and nothing more uninstall-local: - rm -rf $(DESTDIR)$(salomepythondir)/* + @for modulen in GHS3DPlugin ; do \ + test -d $(DESTDIR)$(salomepythondir)/$${modulen} && echo "Removing $(DESTDIR)$(salomepythondir)/$${modulen}" && rm -rf $(DESTDIR)$(salomepythondir)/$${modulen} ; \ + test -d $(DESTDIR)$(salomepythondir)/$${modulen}__POA && echo "Removing $(DESTDIR)$(salomepythondir)/$${modulen}__POA" && rm -rf $(DESTDIR)$(salomepythondir)/$${modulen}__POA ; \ + done ; \ + for filen in $(BASEIDL_FILES_PY) ; do \ + echo "Removing $(DESTDIR)$(salomepythondir)/$${filen}" && rm -f $(DESTDIR)$(salomepythondir)/$${filen}* ; \ + done mostlyclean-local: -rm -f *.hh *.cc .depidl @@ -109,7 +121,7 @@ mostlyclean-local: @for dep in $^ dummy; do \ if [ $$dep != "dummy" ]; then \ echo Building dependencies for $$dep; \ - $(CPP) $(C_DEPEND_FLAG) -x c -I$(srcdir) -I$(KERNEL_ROOT_DIR)/idl/salome -I$(GEOM_ROOT_DIR)/idl/salome -I$(SMESH_ROOT_DIR)/idl/salome -I$(top_builddir)/salome_adm/unix $$dep 2>/dev/null | \ + $(CPP) $(C_DEPEND_FLAG) -x c -I$(srcdir) -I$(KERNEL_ROOT_DIR)/idl/salome -I$(GEOM_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome -I$(SMESH_ROOT_DIR)/idl/salome $$dep 2>/dev/null | \ sed 's/\.o/\SK.cc/' >>$@; \ fi; \ done ; diff --git a/resources/GHS3DPlugin.xml b/resources/GHS3DPlugin.xml index 404c5bc..2c1ece4 100644 --- a/resources/GHS3DPlugin.xml +++ b/resources/GHS3DPlugin.xml @@ -1,7 +1,7 @@ +
    + +
    diff --git a/src/GHS3DPlugin/GHS3DPluginDC.py b/src/GHS3DPlugin/GHS3DPluginDC.py new file mode 100644 index 0000000..adc2dd9 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPluginDC.py @@ -0,0 +1,186 @@ +# Copyright (C) 2007-2012 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 +# + +from smesh import Mesh_Algorithm, AssureGeomPublished + +# import GHS3DPlugin module if possible +noGHS3DPlugin = 0 +try: + import GHS3DPlugin +except ImportError: + noGHS3DPlugin = 1 + pass + +# Optimization level of GHS3D +# V3.1 +None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3 +# V4.1 (partialy redefines V3.1). Issue 0020574 +None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4 + +GHS3D = "GHS3D_3D" + +## Tetrahedron GHS3D 3D algorithm +# It is created by calling Mesh.Tetrahedron( GHS3D, geom=0 ) +# +class GHS3D_Algorithm(Mesh_Algorithm): + + meshMethod = "Tetrahedron" + algoType = GHS3D + + ## Private constructor. + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + if noGHS3DPlugin: print "Warning: GHS3DPlugin module unavailable" + self.Create(mesh, geom, self.algoType, "libGHS3DEngine.so") + self.params = None + + ## Defines hypothesis having several parameters + # + def Parameters(self): + if not self.params: + self.params = self.Hypothesis("GHS3D_Parameters", [], + "libGHS3DEngine.so", UseExisting=0) + return self.params + + ## To mesh "holes" in a solid or not. Default is to mesh. + # + def SetToMeshHoles(self, toMesh): + self.Parameters().SetToMeshHoles(toMesh) + + ## Set Optimization level: + # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, + # Strong_Optimization. + # Default is Standard_Optimization + def SetOptimizationLevel(self, level): + self.Parameters().SetOptimizationLevel(level) + + ## Maximal size of memory to be used by the algorithm (in Megabytes). + # + def SetMaximumMemory(self, MB): + self.Parameters().SetMaximumMemory(MB) + + ## Initial size of memory to be used by the algorithm (in Megabytes) in + # automatic memory adjustment mode. + def SetInitialMemory(self, MB): + self.Parameters().SetInitialMemory(MB) + + ## Path to working directory. + # + def SetWorkingDirectory(self, path): + self.Parameters().SetWorkingDirectory(path) + + ## To keep working files or remove them. Log file remains in case of errors anyway. + def SetKeepFiles(self, toKeep): + self.Parameters().SetKeepFiles(toKeep) + + ## To set verbose level [0-10].
      + #
    • 0 - no standard output, + #
    • 2 - prints the data, quality statistics of the skin and final meshes and + # indicates when the final mesh is being saved. In addition the software + # gives indication regarding the CPU time. + #
    • 10 - same as 2 plus the main steps in the computation, quality statistics + # histogram of the skin mesh, quality statistics histogram together with + # the characteristics of the final mesh.
    + def SetVerboseLevel(self, level): + self.Parameters().SetVerboseLevel(level) + + ## To create new nodes. + def SetToCreateNewNodes(self, toCreate): + self.Parameters().SetToCreateNewNodes(toCreate) + + ## To use boundary recovery version which tries to create mesh on a very poor + # quality surface mesh. + def SetToUseBoundaryRecoveryVersion(self, toUse): + self.Parameters().SetToUseBoundaryRecoveryVersion(toUse) + + ## Applies finite-element correction by replacing overconstrained elements where + # it is possible. The process is cutting first the overconstrained edges and + # second the overconstrained facets. This insure that no edges have two boundary + # vertices and that no facets have three boundary vertices. + def SetFEMCorrection(self, toUseFem): + self.Parameters().SetFEMCorrection(toUseFem) + + ## To removes initial central point. + def SetToRemoveCentralPoint(self, toRemove): + self.Parameters().SetToRemoveCentralPoint(toRemove) + + ## To set an enforced vertex. + # @param x : x coordinate + # @param y : y coordinate + # @param z : z coordinate + # @param size : size of 1D element around enforced vertex + # @param vertexName : name of the enforced vertex + # @param groupName : name of the group + def SetEnforcedVertex(self, x, y, z, size, vertexName = "", groupName = ""): + if vertexName == "": + if groupName == "": + return self.Parameters().SetEnforcedVertex(x, y, z, size) + else: + return self.Parameters().SetEnforcedVertexWithGroup(x, y, z, size, groupName) + else: + if groupName == "": + return self.Parameters().SetEnforcedVertexNamed(x, y, z, size, vertexName) + else: + return self.Parameters().SetEnforcedVertexNamedWithGroup(x, y, z, size, vertexName, groupName) + + ## To set an enforced vertex given a GEOM vertex, group or compound. + # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace. + # @param size : size of 1D element around enforced vertex + # @param groupName : name of the group + def SetEnforcedVertexGeom(self, theVertex, size, groupName = ""): + AssureGeomPublished( self.mesh, theVertex ) + if groupName == "": + return self.Parameters().SetEnforcedVertexGeom(theVertex, size) + else: + return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size, groupName) + + ## To remove an enforced vertex. + # @param x : x coordinate + # @param y : y coordinate + # @param z : z coordinate + def RemoveEnforcedVertex(self, x, y, z): + return self.Parameters().RemoveEnforcedVertex(x, y, z) + + ## To remove an enforced vertex given a GEOM vertex, group or compound. + # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace. + def RemoveEnforcedVertexGeom(self, theVertex): + AssureGeomPublished( self.mesh, theVertex ) + return self.Parameters().RemoveEnforcedVertexGeom(theVertex) + + ## To set an enforced mesh with given size and add the enforced elements in the group "groupName". + # @param theSource : source mesh which provides constraint elements/nodes + # @param elementType : SMESH.ElementType (NODE, EDGE or FACE) + # @param size : size of elements around enforced elements. Unused if -1. + # @param groupName : group in which enforced elements will be added. Unused if "". + def SetEnforcedMesh(self, theSource, elementType, size = -1, groupName = ""): + if size < 0: + if groupName == "": + return self.Parameters().SetEnforcedMesh(theSource, elementType) + else: + return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName) + else: + if groupName == "": + return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size) + else: + return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName) + + ## Sets command line option as text. + def SetTextOption(self, option): + self.Parameters().SetTextOption(option) + diff --git a/src/GHS3DPlugin/GHS3DPlugin_Defs.hxx b/src/GHS3DPlugin/GHS3DPlugin_Defs.hxx new file mode 100644 index 0000000..2ec37bb --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_Defs.hxx @@ -0,0 +1,37 @@ +// Copyright (C) 2004-2012 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 : GHS3DPlugin_Defs.hxx +// Author : Alexander A. BORODIN +// +#ifndef _GHS3DPlugin_DEFS_HXX_ +#define _GHS3DPlugin_DEFS_HXX_ + +#ifdef WIN32 + #if defined GHS3DPLUGIN_EXPORTS || defined GHS3DEngine_EXPORTS + #define GHS3DPLUGIN_EXPORT __declspec( dllexport ) + #else + #define GHS3DPLUGIN_EXPORT __declspec( dllimport ) + #endif +#else + #define GHS3DPLUGIN_EXPORT +#endif + +#endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx new file mode 100644 index 0000000..6da9eec --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.cxx @@ -0,0 +1,4314 @@ +// Copyright (C) 2004-2012 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 : GHS3DPlugin_GHS3D.cxx +// Created : +// Author : Edward AGAPOV, modified by Lioka RAZAFINDRAZAKA (CEA) 09/02/2007 +// Project : SALOME +//============================================================================= +// +#include "GHS3DPlugin_GHS3D.hxx" +#include "GHS3DPlugin_Hypothesis.hxx" + +#include + +//#include "SMESH_Gen.hxx" +#include +#include "SMESH_Mesh.hxx" +#include "SMESH_Comment.hxx" +#include "SMESH_MesherHelper.hxx" +#include "SMESH_MeshEditor.hxx" +#include "SMESH_OctreeNode.hxx" +#include "SMESH_Group.hxx" + +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_FaceOfNodes.hxx" +#include "SMDS_VolumeOfNodes.hxx" + +#include "SMESHDS_Group.hxx" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utilities.h" + +#ifdef WIN32 +#include +#else +#include +#endif +#include + +//#include + + +#define castToNode(n) static_cast( n ); + +#ifdef _DEBUG_ +#define DUMP(txt) \ +// std::cout << txt +#else +#define DUMP(txt) +#endif + +extern "C" +{ +#ifndef WNT +#include +#include +#endif +#include +#include +} + +#define HOLE_ID -1 + +#ifndef GHS3D_VERSION +#define GHS3D_VERSION 41 +#endif + +typedef const list TTriaList; + +static void removeFile( const TCollection_AsciiString& fileName ) +{ + try { + OSD_File( fileName ).Remove(); + } + catch ( Standard_ProgramError ) { + MESSAGE("Can't remove file: " << fileName.ToCString() << " ; file does not exist or permission denied"); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_3D_Algo(hypId, studyId, gen) +{ + MESSAGE("GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D"); + _name = "GHS3D_3D"; + _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type + _onlyUnaryInput = false; // Compute() will be called on a compound of solids + _iShape=0; + _nbShape=0; + _compatibleHypothesis.push_back( GHS3DPlugin_Hypothesis::GetHypType()); + _compatibleHypothesis.push_back( StdMeshers_ViscousLayers::GetHypType() ); + _requireShape = false; // can work without shape_studyId + + smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject); + + MESSAGE("studyid = " << _studyId); + + myStudy = NULL; + myStudy = aStudyMgr->GetStudyByID(_studyId); + if (myStudy) + MESSAGE("myStudy->StudyId() = " << myStudy->StudyId()); + +#ifdef WITH_SMESH_CANCEL_COMPUTE + _compute_canceled = false; +#endif +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +GHS3DPlugin_GHS3D::~GHS3DPlugin_GHS3D() +{ + MESSAGE("GHS3DPlugin_GHS3D::~GHS3DPlugin_GHS3D"); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool GHS3DPlugin_GHS3D::CheckHypothesis ( SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + Hypothesis_Status& aStatus ) +{ + aStatus = SMESH_Hypothesis::HYP_OK; + + _hyp = 0; + _viscousLayersHyp = 0; + _keepFiles = false; + + const list & hyps = + GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliary=*/false); + list ::const_iterator h = hyps.begin(); + for ( ; h != hyps.end(); ++h ) + { + if ( !_hyp ) + _hyp = dynamic_cast< const GHS3DPlugin_Hypothesis*> ( *h ); + if ( !_viscousLayersHyp ) + _viscousLayersHyp = dynamic_cast< const StdMeshers_ViscousLayers*> ( *h ); + } + if ( _hyp ) + _keepFiles = _hyp->GetKeepFiles(); + + return true; +} + + +//======================================================================= +//function : entryToShape +//purpose : +//======================================================================= + +TopoDS_Shape GHS3DPlugin_GHS3D::entryToShape(std::string entry) +{ + MESSAGE("GHS3DPlugin_GHS3D::entryToShape "<FindObjectID( entry.c_str() ); + SALOMEDS::GenericAttribute_var anAttr; + + if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aVal = anIOR->Value(); + CORBA::Object_var obj = myStudy->ConvertIORToObject(aVal); + aGeomObj = GEOM::GEOM_Object::_narrow(obj); + } + if ( !aGeomObj->_is_nil() ) + S = smeshGen_i->GeomObjectToShape( aGeomObj.in() ); + return S; +} + +//======================================================================= +//function : findShape +//purpose : +//======================================================================= + +static TopoDS_Shape findShape(const SMDS_MeshNode *aNode[], + TopoDS_Shape aShape, + const TopoDS_Shape shape[], + double** box, + const int nShape, + TopAbs_State * state = 0) +{ + gp_XYZ aPnt(0,0,0); + int j, iShape, nbNode = 4; + + for ( j=0; jX(), aNode[j]->Y(), aNode[j]->Z() ); + if ( aNode[j]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE ) { + aPnt = p; + break; + } + aPnt += p / nbNode; + } + + BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion()); + if (state) *state = SC.State(); + if ( SC.State() != TopAbs_IN || aShape.IsNull() || aShape.ShapeType() != TopAbs_SOLID) { + for (iShape = 0; iShape < nShape; iShape++) { + aShape = shape[iShape]; + if ( !( aPnt.X() < box[iShape][0] || box[iShape][1] < aPnt.X() || + aPnt.Y() < box[iShape][2] || box[iShape][3] < aPnt.Y() || + aPnt.Z() < box[iShape][4] || box[iShape][5] < aPnt.Z()) ) { + BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion()); + if (state) *state = SC.State(); + if (SC.State() == TopAbs_IN) + break; + } + } + } + return aShape; +} + +//======================================================================= +//function : readMapIntLine +//purpose : +//======================================================================= + +static char* readMapIntLine(char* ptr, int tab[]) { + long int intVal; + std::cout << std::endl; + + for ( int i=0; i<17; i++ ) { + intVal = strtol(ptr, &ptr, 10); + if ( i < 3 ) + tab[i] = intVal; + } + return ptr; +} + +//================================================================================ +/*! + * \brief returns true if a triangle defined by the nodes is a temporary face on a + * side facet of pyramid and defines sub-domian inside the pyramid + */ +//================================================================================ + +static bool isTmpFace(const SMDS_MeshNode* node1, + const SMDS_MeshNode* node2, + const SMDS_MeshNode* node3) +{ + // find a pyramid sharing the 3 nodes + //const SMDS_MeshElement* pyram = 0; + SMDS_ElemIteratorPtr vIt1 = node1->GetInverseElementIterator(SMDSAbs_Volume); + while ( vIt1->more() ) + { + const SMDS_MeshElement* pyram = vIt1->next(); + if ( pyram->NbCornerNodes() != 5 ) continue; + int i2, i3; + if ( (i2 = pyram->GetNodeIndex( node2 )) >= 0 && + (i3 = pyram->GetNodeIndex( node3 )) >= 0 ) + { + // Triangle defines sub-domian inside the pyramid if it's + // normal points out of the pyram + + // make i2 and i3 hold indices of base nodes of the pyram while + // keeping the nodes order in the triangle + const int iApex = 4; + if ( i2 == iApex ) + i2 = i3, i3 = pyram->GetNodeIndex( node1 ); + else if ( i3 == iApex ) + i3 = i2, i2 = pyram->GetNodeIndex( node1 ); + + int i3base = (i2+1) % 4; // next index after i2 within the pyramid base + return ( i3base != i3 ); + } + } + return false; +} + +//======================================================================= +//function : findShapeID +//purpose : find the solid corresponding to GHS3D sub-domain following +// the technique proposed in GHS3D manual (available within +// ghs3d installation) in chapter "B.4 Subdomain (sub-region) assignment". +// In brief: normal of the triangle defined by the given nodes +// points out of the domain it is associated to +//======================================================================= + +static int findShapeID(SMESH_Mesh& mesh, + const SMDS_MeshNode* node1, + const SMDS_MeshNode* node2, + const SMDS_MeshNode* node3, + const bool toMeshHoles) +{ + const int invalidID = 0; + SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); + + // face the nodes belong to + const SMDS_MeshElement * face = meshDS->FindFace(node1,node2,node3); + if ( !face ) + return isTmpFace(node1, node2, node3) ? HOLE_ID : invalidID; +#ifdef _DEBUG_ + std::cout << "bnd face " << face->GetID() << " - "; +#endif + // geom face the face assigned to + SMESH_MeshEditor editor(&mesh); + int geomFaceID = editor.FindShape( face ); + if ( !geomFaceID ) + return isTmpFace(node1, node2, node3) ? HOLE_ID : invalidID; + TopoDS_Shape shape = meshDS->IndexToShape( geomFaceID ); + if ( shape.IsNull() || shape.ShapeType() != TopAbs_FACE ) + return invalidID; + TopoDS_Face geomFace = TopoDS::Face( shape ); + + // solids bounded by geom face + TopTools_IndexedMapOfShape solids, shells; + TopTools_ListIteratorOfListOfShape ansIt = mesh.GetAncestors(geomFace); + for ( ; ansIt.More(); ansIt.Next() ) { + switch ( ansIt.Value().ShapeType() ) { + case TopAbs_SOLID: + solids.Add( ansIt.Value() ); break; + case TopAbs_SHELL: + shells.Add( ansIt.Value() ); break; + default:; + } + } + // analyse found solids + if ( solids.Extent() == 0 || shells.Extent() == 0) + return invalidID; + + const TopoDS_Solid& solid1 = TopoDS::Solid( solids(1) ); + if ( solids.Extent() == 1 ) + { + if ( toMeshHoles ) + return meshDS->ShapeToIndex( solid1 ); + + //////////// UNCOMMENT AS SOON AS + //////////// http://tracker.dev.opencascade.org/view.php?id=23129 + //////////// IS SOLVED + // - Are we at a hole boundary face? + // if ( shells(1).IsSame( BRepTools::OuterShell( solid1 )) ) + // { // - No, but maybe a hole is bound by two shapes? Does shells(1) touches another shell? + // bool touch = false; + // TopExp_Explorer eExp( shells(1), TopAbs_EDGE ); + // // check if any edge of shells(1) belongs to another shell + // for ( ; eExp.More() && !touch; eExp.Next() ) { + // ansIt = mesh.GetAncestors( eExp.Current() ); + // for ( ; ansIt.More() && !touch; ansIt.Next() ) { + // if ( ansIt.Value().ShapeType() == TopAbs_SHELL ) + // touch = ( !ansIt.Value().IsSame( shells(1) )); + // } + // } + // if (!touch) + // return meshDS->ShapeToIndex( solid1 ); + // } + } + // find orientation of geom face within the first solid + TopExp_Explorer fExp( solid1, TopAbs_FACE ); + for ( ; fExp.More(); fExp.Next() ) + if ( geomFace.IsSame( fExp.Current() )) { + geomFace = TopoDS::Face( fExp.Current() ); + break; + } + if ( !fExp.More() ) + return invalidID; // face not found + + // normale to triangle + gp_Pnt node1Pnt ( node1->X(), node1->Y(), node1->Z() ); + gp_Pnt node2Pnt ( node2->X(), node2->Y(), node2->Z() ); + gp_Pnt node3Pnt ( node3->X(), node3->Y(), node3->Z() ); + gp_Vec vec12( node1Pnt, node2Pnt ); + gp_Vec vec13( node1Pnt, node3Pnt ); + gp_Vec meshNormal = vec12 ^ vec13; + if ( meshNormal.SquareMagnitude() < DBL_MIN ) + return invalidID; + + // get normale to geomFace at any node + bool geomNormalOK = false; + gp_Vec geomNormal; + const SMDS_MeshNode* nodes[3] = { node1, node2, node3 }; + SMESH_MesherHelper helper( mesh ); helper.SetSubShape( geomFace ); + for ( int i = 0; !geomNormalOK && i < 3; ++i ) + { + // find UV of i-th node on geomFace + const SMDS_MeshNode* nNotOnSeamEdge = 0; + if ( helper.IsSeamShape( nodes[i]->getshapeId() )) { + if ( helper.IsSeamShape( nodes[(i+1)%3]->getshapeId() )) + nNotOnSeamEdge = nodes[(i+2)%3]; + else + nNotOnSeamEdge = nodes[(i+1)%3]; + } + bool uvOK; + gp_XY uv = helper.GetNodeUV( geomFace, nodes[i], nNotOnSeamEdge, &uvOK ); + // check that uv is correct + if (uvOK) { + double tol = 1e-6; + TopoDS_Shape nodeShape = helper.GetSubShapeByNode( nodes[i], meshDS ); + if ( !nodeShape.IsNull() ) + switch ( nodeShape.ShapeType() ) + { + case TopAbs_FACE: tol = BRep_Tool::Tolerance( TopoDS::Face( nodeShape )); break; + case TopAbs_EDGE: tol = BRep_Tool::Tolerance( TopoDS::Edge( nodeShape )); break; + case TopAbs_VERTEX: tol = BRep_Tool::Tolerance( TopoDS::Vertex( nodeShape )); break; + default:; + } + gp_Pnt nodePnt ( nodes[i]->X(), nodes[i]->Y(), nodes[i]->Z() ); + BRepAdaptor_Surface surface( geomFace ); + uvOK = ( nodePnt.Distance( surface.Value( uv.X(), uv.Y() )) < 2 * tol ); + if ( uvOK ) { + // normale to geomFace at UV + gp_Vec du, dv; + surface.D1( uv.X(), uv.Y(), nodePnt, du, dv ); + geomNormal = du ^ dv; + if ( geomFace.Orientation() == TopAbs_REVERSED ) + geomNormal.Reverse(); + geomNormalOK = ( geomNormal.SquareMagnitude() > DBL_MIN * 1e3 ); + } + } + } + if ( !geomNormalOK) + return invalidID; + + // compare normals + bool isReverse = ( meshNormal * geomNormal ) < 0; + if ( !isReverse ) + return meshDS->ShapeToIndex( solid1 ); + + if ( solids.Extent() == 1 ) + return HOLE_ID; // we are inside a hole + else + return meshDS->ShapeToIndex( solids(2) ); +} + +//======================================================================= +//function : countShape +//purpose : +//======================================================================= + +// template < class Mesh, class Shape > +// static int countShape( Mesh* mesh, Shape shape ) { +// TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape ); +// TopTools_MapOfShape mapShape; +// int nbShape = 0; +// for ( ; expShape.More(); expShape.Next() ) { +// if (mapShape.Add(expShape.Current())) { +// nbShape++; +// } +// } +// return nbShape; +// } + +//======================================================================= +//function : getShape +//purpose : +//======================================================================= + +// template < class Mesh, class Shape, class Tab > +// void getShape(Mesh* mesh, Shape shape, Tab *t_Shape) { +// TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape ); +// TopTools_MapOfShape mapShape; +// for ( int i=0; expShape.More(); expShape.Next() ) { +// if (mapShape.Add(expShape.Current())) { +// t_Shape[i] = expShape.Current(); +// i++; +// } +// } +// return; +// } + +// //======================================================================= +// //function : findEdgeID +// //purpose : +// //======================================================================= +// +// static int findEdgeID(const SMDS_MeshNode* aNode, +// const SMESHDS_Mesh* theMesh, +// const int nEdge, +// const TopoDS_Shape* t_Edge) { +// +// TopoDS_Shape aPntShape, foundEdge; +// TopoDS_Vertex aVertex; +// gp_Pnt aPnt( aNode->X(), aNode->Y(), aNode->Z() ); +// +// int foundInd, ind; +// double nearest = RealLast(), *t_Dist; +// double epsilon = Precision::Confusion(); +// +// t_Dist = new double[ nEdge ]; +// aPntShape = BRepBuilderAPI_MakeVertex( aPnt ).Shape(); +// aVertex = TopoDS::Vertex( aPntShape ); +// +// for ( ind=0; ind < nEdge; ind++ ) { +// BRepExtrema_DistShapeShape aDistance ( aVertex, t_Edge[ind] ); +// t_Dist[ind] = aDistance.Value(); +// if ( t_Dist[ind] < nearest ) { +// nearest = t_Dist[ind]; +// foundEdge = t_Edge[ind]; +// foundInd = ind; +// if ( nearest < epsilon ) +// ind = nEdge; +// } +// } +// +// delete [] t_Dist; +// return theMesh->ShapeToIndex( foundEdge ); +// } + + +//======================================================================= +//function : readGMFFile +//purpose : read GMF file with geometry associated to mesh +// TODO +//======================================================================= + +// static bool readGMFFile( +// const int fileOpen, +// const char* theFileName, +// SMESH_Mesh& theMesh, +// const int nbShape, +// const TopoDS_Shape* tabShape, +// double** tabBox, +// map & theGhs3dIdToNodeMap, +// bool toMeshHoles, +// int nbEnforcedVertices, +// int nbEnforcedNodes) +// { +// TopoDS_Shape aShape; +// TopoDS_Vertex aVertex; +// SMESHDS_Mesh* theMeshDS = theMesh.GetMeshDS(); +// int nbElem = 0, nbRef = 0, IdShapeRef = 1; +// int *tabID; +// int aGMFNodeID = 0; +// int compoundID = +// nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() ); +// int tetraShapeID = compoundID; +// double epsilon = Precision::Confusion(); +// int *nodeAssigne, *GMFNodeAssigne; +// SMDS_MeshNode** GMFNode; +// TopoDS_Shape *tabCorner, *tabEdge; +// std::map tabRef; +// +// +// int ver, dim; +// MESSAGE("Read " << theFileName << " file"); +// int InpMsh = GmfOpenMesh(theFileName, GmfRead, &ver, &dim); +// if (!InpMsh) +// return false; +// +// // =========================== +// // Fill the tabID array: BEGIN +// // =========================== +// +// /* +// The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2) +// */ +// Kernel_Utils::Localizer loc; +// struct stat status; +// size_t length; +// +// char *ptr, *mapPtr; +// char *tetraPtr; +// int *tab = new int[3]; +// +// // Read the file state +// fstat(fileOpen, &status); +// length = status.st_size; +// +// // Mapping the result file into memory +// #ifdef WNT +// HANDLE fd = CreateFile(theFileName, GENERIC_READ, FILE_SHARE_READ, +// NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +// HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY, +// 0, (DWORD)length, NULL); +// ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 ); +// #else +// ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0); +// #endif +// mapPtr = ptr; +// +// ptr = readMapIntLine(ptr, tab); +// tetraPtr = ptr; +// +// nbElem = tab[0]; +// int nbNodes = tab[1]; +// +// for (int i=0; i < 4*nbElem; i++) +// strtol(ptr, &ptr, 10); +// +// for (int iNode=1; iNode <= nbNodes; iNode++) +// for (int iCoor=0; iCoor < 3; iCoor++) +// strtod(ptr, &ptr); +// +// +// // Reading the number of triangles which corresponds to the number of sub-domains +// int nbTriangle = strtol(ptr, &ptr, 10); +// +// +// // The keyword does not exist yet => to update when it is created +// // int nbTriangle = GmfStatKwd(InpMsh, GmfSubdomain); +// // int id_tri[3]; +// +// +// tabID = new int[nbTriangle]; +// for (int i=0; i < nbTriangle; i++) { +// tabID[i] = 0; +// int nodeId1, nodeId2, nodeId3; +// // find the solid corresponding to GHS3D sub-domain following +// // the technique proposed in GHS3D manual in chapter +// // "B.4 Subdomain (sub-region) assignment" +// +// nodeId1 = strtol(ptr, &ptr, 10); +// nodeId2 = strtol(ptr, &ptr, 10); +// nodeId3 = strtol(ptr, &ptr, 10); +// +// // // The keyword does not exist yet => to update when it is created +// // GmfGetLin(InpMsh, GmfSubdomain, &id_tri[0], &id_tri[1], &id_tri[2]); +// // nodeId1 = id_tri[0]; +// // nodeId2 = id_tri[1]; +// // nodeId3 = id_tri[2]; +// +// if ( nbTriangle > 1 ) { +// // get the nodes indices +// const SMDS_MeshNode* n1 = theGhs3dIdToNodeMap[ nodeId1 ]; +// const SMDS_MeshNode* n2 = theGhs3dIdToNodeMap[ nodeId2 ]; +// const SMDS_MeshNode* n3 = theGhs3dIdToNodeMap[ nodeId3 ]; +// try { +// OCC_CATCH_SIGNALS; +// tabID[i] = findShapeID( theMesh, n1, n2, n3, toMeshHoles ); +// // -- 0020330: Pb with ghs3d as a submesh +// // check that found shape is to be meshed +// if ( tabID[i] > 0 ) { +// const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( tabID[i] ); +// bool isToBeMeshed = false; +// for ( int iS = 0; !isToBeMeshed && iS < nbShape; ++iS ) +// isToBeMeshed = foundShape.IsSame( tabShape[ iS ]); +// if ( !isToBeMeshed ) +// tabID[i] = HOLE_ID; +// } +// // END -- 0020330: Pb with ghs3d as a submesh +// #ifdef _DEBUG_ +// std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl; +// #endif +// } +// catch ( Standard_Failure & ex) +// { +// #ifdef _DEBUG_ +// std::cout << i+1 << " subdomain: Exception caugt: " << ex.GetMessageString() << std::endl; +// #endif +// } +// catch (...) { +// #ifdef _DEBUG_ +// std::cout << i+1 << " subdomain: unknown exception caught " << std::endl; +// #endif +// } +// } +// } +// +// // =========================== +// // Fill the tabID array: END +// // =========================== +// +// +// tabRef[GmfVertices] = 3; +// tabRef[GmfCorners] = 1; +// tabRef[GmfEdges] = 2; +// tabRef[GmfRidges] = 1; +// tabRef[GmfTriangles] = 3; +// // tabRef[GmfQuadrilaterals] = 4; +// tabRef[GmfTetrahedra] = 4; +// // tabRef[GmfHexahedra] = 8; +// +// SMDS_NodeIteratorPtr itOnGMFInputNode = theMeshDS->nodesIterator(); +// while ( itOnGMFInputNode->more() ) +// theMeshDS->RemoveNode( itOnGMFInputNode->next() ); +// +// +// int nbVertices = GmfStatKwd(InpMsh, GmfVertices); +// int nbCorners = max(countShape( theMeshDS, TopAbs_VERTEX ) , GmfStatKwd(InpMsh, GmfCorners)); +// int nbShapeEdge = countShape( theMeshDS, TopAbs_EDGE ); +// +// tabCorner = new TopoDS_Shape[ nbCorners ]; +// tabEdge = new TopoDS_Shape[ nbShapeEdge ]; +// nodeAssigne = new int[ nbVertices + 1 ]; +// GMFNodeAssigne = new int[ nbVertices + 1 ]; +// GMFNode = new SMDS_MeshNode*[ nbVertices + 1 ]; +// +// getShape(theMeshDS, TopAbs_VERTEX, tabCorner); +// getShape(theMeshDS, TopAbs_EDGE, tabEdge); +// +// std::map ::const_iterator it = tabRef.begin(); +// for ( ; it != tabRef.end() ; ++it) +// { +// // int dummy; +// GmfKwdCod token = it->first; +// nbRef = it->second; +// +// nbElem = GmfStatKwd(InpMsh, token); +// if (nbElem > 0) { +// GmfGotoKwd(InpMsh, token); +// std::cout << "Read " << nbElem; +// } +// else +// continue; +// +// int id[nbElem*tabRef[token]]; +// int ghs3dShapeID[nbElem]; +// +// if (token == GmfVertices) { +// std::cout << " vertices" << std::endl; +// int aGMFID; +// +// float VerTab_f[nbElem][3]; +// double VerTab_d[nbElem][3]; +// SMDS_MeshNode * aGMFNode; +// +// for ( int iElem = 0; iElem < nbElem; iElem++ ) { +// aGMFID = iElem + 1; +// if (ver == GmfFloat) { +// GmfGetLin(InpMsh, token, &VerTab_f[nbElem][0], &VerTab_f[nbElem][1], &VerTab_f[nbElem][2], &ghs3dShapeID[iElem]); +// aGMFNode = theMeshDS->AddNode(VerTab_f[nbElem][0], VerTab_f[nbElem][1], VerTab_f[nbElem][2]); +// } +// else { +// GmfGetLin(InpMsh, token, &VerTab_d[nbElem][0], &VerTab_d[nbElem][1], &VerTab_d[nbElem][2], &ghs3dShapeID[iElem]); +// aGMFNode = theMeshDS->AddNode(VerTab_d[nbElem][0], VerTab_d[nbElem][1], VerTab_d[nbElem][2]); +// } +// GMFNode[ aGMFID ] = aGMFNode; +// nodeAssigne[ aGMFID ] = 0; +// GMFNodeAssigne[ aGMFID ] = 0; +// } +// } +// else if (token == GmfCorners && nbElem > 0) { +// std::cout << " corners" << std::endl; +// for ( int iElem = 0; iElem < nbElem; iElem++ ) +// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]); +// } +// else if (token == GmfRidges && nbElem > 0) { +// std::cout << " ridges" << std::endl; +// for ( int iElem = 0; iElem < nbElem; iElem++ ) +// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]); +// } +// else if (token == GmfEdges && nbElem > 0) { +// std::cout << " edges" << std::endl; +// for ( int iElem = 0; iElem < nbElem; iElem++ ) +// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &ghs3dShapeID[iElem]); +// } +// else if (token == GmfTriangles && nbElem > 0) { +// std::cout << " triangles" << std::endl; +// for ( int iElem = 0; iElem < nbElem; iElem++ ) +// GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &ghs3dShapeID[iElem]); +// } +// // else if (token == GmfQuadrilaterals && nbElem > 0) { +// // std::cout << " Quadrilaterals" << std::endl; +// // for ( int iElem = 0; iElem < nbElem; iElem++ ) +// // GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], &ghs3dShapeID[iElem]); +// // } +// else if (token == GmfTetrahedra && nbElem > 0) { +// std::cout << " Tetrahedra" << std::endl; +// for ( int iElem = 0; iElem < nbElem; iElem++ ) +// GmfGetLin(InpMsh, token, +// &id[iElem*tabRef[token]], +// &id[iElem*tabRef[token]+1], +// &id[iElem*tabRef[token]+2], +// &id[iElem*tabRef[token]+3], +// &ghs3dShapeID[iElem]); +// } +// // else if (token == GmfHexahedra && nbElem > 0) { +// // std::cout << " Hexahedra" << std::endl; +// // for ( int iElem = 0; iElem < nbElem; iElem++ ) +// // GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], +// // &id[iElem*tabRef[token]+4], &id[iElem*tabRef[token]+5], &id[iElem*tabRef[token]+6], &id[iElem*tabRef[token]+7], &ghs3dShapeID[iElem]); +// // } +// +// switch (token) { +// case GmfCorners: +// case GmfRidges: +// case GmfEdges: +// case GmfTriangles: +// // case GmfQuadrilaterals: +// case GmfTetrahedra: +// // case GmfHexahedra: +// { +// int nodeDim, shapeID, *nodeID; +// SMDS_MeshNode** node; +// // std::vector< SMDS_MeshNode* > enfNode( nbRef ); +// SMDS_MeshElement * aGMFElement; +// +// node = new SMDS_MeshNode*[nbRef]; +// nodeID = new int[ nbRef ]; +// +// for ( int iElem = 0; iElem < nbElem; iElem++ ) +// { +// for ( int iRef = 0; iRef < nbRef; iRef++ ) +// { +// aGMFNodeID = id[iElem*tabRef[token]+iRef]; // read nbRef aGMFNodeID +// node [ iRef ] = GMFNode[ aGMFNodeID ]; +// nodeID[ iRef ] = aGMFNodeID; +// } +// +// switch (token) +// { +// case GmfCorners: { +// nodeDim = 1; +// gp_Pnt GMFPnt ( node[0]->X(), node[0]->Y(), node[0]->Z() ); +// for ( int i=0; iAddEdge( node[0], node[1] ); +// int iNode = 1; +// if ( GMFNodeAssigne[ nodeID[0] ] == 0 || GMFNodeAssigne[ nodeID[0] ] == 2 ) +// iNode = 0; +// shapeID = findEdgeID( node[iNode], theMeshDS, nbShapeEdge, tabEdge ); +// break; +// } +// case GmfRidges: +// break; +// case GmfTriangles: { +// nodeDim = 3; +// aGMFElement = theMeshDS->AddFace( node[0], node[1], node[2]); +// shapeID = -1; +// break; +// } +// // case GmfQuadrilaterals: { +// // nodeDim = 4; +// // aGMFElement = theMeshDS->AddFace( node[0], node[1], node[2], node[3] ); +// // shapeID = -1; +// // break; +// // } +// case GmfTetrahedra: { +// +// // IN WORK +// TopoDS_Shape aSolid; +// // We always run GHS3D with "to mesh holes"==TRUE but we must not create +// // tetras within holes depending on hypo option, +// // so we first check if aTet is inside a hole and then create it +// if ( nbTriangle > 1 ) { +// tetraShapeID = HOLE_ID; // negative tetraShapeID means not to create tetras if !toMeshHoles +// int aGhs3dShapeID = ghs3dShapeID[iElem] - IdShapeRef; +// if ( tabID[ aGhs3dShapeID ] == 0 ) { +// TopAbs_State state; +// aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state); +// if ( toMeshHoles || state == TopAbs_IN ) +// tetraShapeID = theMeshDS->ShapeToIndex( aSolid ); +// tabID[ aGhs3dShapeID ] = tetraShapeID; +// } +// else +// tetraShapeID = tabID[ aGhs3dShapeID ]; +// } +// else if ( nbShape > 1 ) { +// // Case where nbTriangle == 1 while nbShape == 2 encountered +// // with compound of 2 boxes and "To mesh holes"==False, +// // so there are no subdomains specified for each tetrahedron. +// // Try to guess a solid by a node already bound to shape +// tetraShapeID = 0; +// for ( int i=0; i<4 && tetraShapeID==0; i++ ) { +// if ( nodeAssigne[ nodeID[i] ] == 1 && +// node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE && +// node[i]->getshapeId() > 1 ) +// { +// tetraShapeID = node[i]->getshapeId(); +// } +// } +// if ( tetraShapeID==0 ) { +// aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape); +// tetraShapeID = theMeshDS->ShapeToIndex( aSolid ); +// } +// } +// // set new nodes and tetrahedron onto the shape +// for ( int i=0; i<4; i++ ) { +// if ( nodeAssigne[ nodeID[i] ] == 0 ) { +// if ( tetraShapeID != HOLE_ID ) +// theMeshDS->SetNodeInVolume( node[i], tetraShapeID ); +// nodeAssigne[ nodeID[i] ] = tetraShapeID; +// } +// } +// if ( toMeshHoles || tetraShapeID != HOLE_ID ) { +// aGMFElement = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] ); +// theMeshDS->SetMeshElementOnShape( aGMFElement, tetraShapeID ); +// } +// +// // IN WORK +// +// nodeDim = 5; +// break; +// } +// // case GmfHexahedra: { +// // nodeDim = 6; +// // aGMFElement = theMeshDS->AddVolume( node[0], node[3], node[2], node[1], +// // node[4], node[7], node[6], node[5] ); +// // break; +// // } +// default: continue; +// } +// if (token != GmfRidges) +// { +// for ( int i=0; iSetNodeOnVertex( node[0], aVertex ); +// else if ( token == GmfEdges ) theMeshDS->SetNodeOnEdge( node[i], shapeID ); +// else if ( token == GmfTriangles ) theMeshDS->SetNodeOnFace( node[i], shapeID ); +// GMFNodeAssigne[ nodeID[i] ] = nodeDim; +// } +// } +// if ( token != "Corners" ) +// theMeshDS->SetMeshElementOnShape( aGMFElement, shapeID ); +// } +// } // for +// +// if ( !toMeshHoles ) { +// map ::iterator itOnNode = theGhs3dIdToNodeMap.find( nbVertices-(nbEnforcedVertices+nbEnforcedNodes) ); +// for ( ; itOnNode != theGhs3dIdToNodeMap.end(); ++itOnNode) { +// if ( nodeAssigne[ itOnNode->first ] == HOLE_ID ) +// theMeshDS->RemoveFreeNode( itOnNode->second, 0 ); +// } +// } +// +// delete [] node; +// delete [] nodeID; +// break; +// } // case GmfTetrahedra +// } // switch(token) +// } // for +// cout << std::endl; +// +// #ifdef WNT +// UnmapViewOfFile(mapPtr); +// CloseHandle(hMapObject); +// CloseHandle(fd); +// #else +// munmap(mapPtr, length); +// #endif +// close(fileOpen); +// +// delete [] tabID; +// delete [] tabCorner; +// delete [] tabEdge; +// delete [] nodeAssigne; +// delete [] GMFNodeAssigne; +// delete [] GMFNode; +// +// return true; +// } + + +//======================================================================= +//function : addElemInMeshGroup +//purpose : Update or create groups in mesh +//======================================================================= + +static void addElemInMeshGroup(SMESH_Mesh* theMesh, + const SMDS_MeshElement* anElem, + std::string groupName, + std::set groupsToRemove) +{ + bool groupDone = false; + SMESH_Mesh::GroupIteratorPtr grIt = theMesh->GetGroups(); + while (grIt->more()) { + SMESH_Group * group = grIt->next(); + if ( !group ) continue; + SMESHDS_GroupBase* groupDS = group->GetGroupDS(); + if ( !groupDS ) continue; + if ( groupDS->GetType()==anElem->GetType() &&groupName.compare(group->GetName())==0) { + SMESHDS_Group* aGroupDS = static_cast( groupDS ); + aGroupDS->SMDSGroup().Add(anElem); + groupDone = true; +// MESSAGE("Successfully added enforced element to existing group " << groupName); + break; + } + } + + if (!groupDone) + { + int groupId; + SMESH_Group* aGroup = theMesh->AddGroup(anElem->GetType(), groupName.c_str(), groupId); + aGroup->SetName( groupName.c_str() ); + SMESHDS_Group* aGroupDS = static_cast( aGroup->GetGroupDS() ); + aGroupDS->SMDSGroup().Add(anElem); +// MESSAGE("Successfully created enforced vertex group " << groupName); + groupDone = true; + } + if (!groupDone) + throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group")); +} + + +//======================================================================= +//function : updateMeshGroups +//purpose : Update or create groups in mesh +//======================================================================= + +static void updateMeshGroups(SMESH_Mesh* theMesh, std::set groupsToRemove) +{ + SMESH_Mesh::GroupIteratorPtr grIt = theMesh->GetGroups(); + while (grIt->more()) { + SMESH_Group * group = grIt->next(); + if ( !group ) continue; + SMESHDS_GroupBase* groupDS = group->GetGroupDS(); + if ( !groupDS ) continue; + std::string currentGroupName = (string)group->GetName(); + if (groupDS->IsEmpty() && groupsToRemove.find(currentGroupName) != groupsToRemove.end()) { + // Previous group created by enforced elements + MESSAGE("Delete previous group created by removed enforced elements: " << group->GetName()) + theMesh->RemoveGroup(groupDS->GetID()); + } + } +} + +//======================================================================= +//function : readGMFFile +//purpose : read GMF file w/o geometry associated to mesh +//======================================================================= + +static bool readGMFFile(const char* theFile, +#ifdef WITH_SMESH_CANCEL_COMPUTE + GHS3DPlugin_GHS3D* theAlgo, +#endif + SMESH_MesherHelper* theHelper, + TopoDS_Shape theSolid, + vector & theNodeByGhs3dId, + map & theNodeToGhs3dIdMap, + std::vector & aNodeGroupByGhs3dId, + std::vector & anEdgeGroupByGhs3dId, + std::vector & aFaceGroupByGhs3dId, + std::set & groupsToRemove + ) +{ + std::string tmpStr; + SMESHDS_Mesh* theMeshDS = theHelper->GetMeshDS(); + + int nbInitialNodes = theNodeByGhs3dId.size(); + int nbMeshNodes = theMeshDS->NbNodes(); + + const bool isQuadMesh = + theHelper->GetMesh()->NbEdges( ORDER_QUADRATIC ) || + theHelper->GetMesh()->NbFaces( ORDER_QUADRATIC ) || + theHelper->GetMesh()->NbVolumes( ORDER_QUADRATIC ); + +#ifdef _DEBUG_ + std::cout << "theNodeByGhs3dId.size(): " << nbInitialNodes << std::endl; + std::cout << "theHelper->GetMesh()->NbNodes(): " << nbMeshNodes << std::endl; + std::cout << "isQuadMesh: " << isQuadMesh << std::endl; +#endif + + if (theHelper->GetSubShapeID() != 0) + theHelper->IsQuadraticSubMesh( theHelper->GetSubShape() ); + + // --------------------------------- + // Read generated elements and nodes + // --------------------------------- + + int nbElem = 0, nbRef = 0; + int aGMFNodeID = 0/*, shapeID*/; + //int *nodeAssigne; + const SMDS_MeshNode** GMFNode; +#ifdef _DEBUG_ + std::map > subdomainId2tetraId; +#endif + std::map tabRef; + + tabRef[GmfVertices] = 3; // for new nodes and enforced nodes + tabRef[GmfCorners] = 1; + tabRef[GmfEdges] = 2; // for enforced edges + tabRef[GmfRidges] = 1; + tabRef[GmfTriangles] = 3; // for enforced faces + tabRef[GmfQuadrilaterals] = 4; + tabRef[GmfTetrahedra] = 4; // for new tetras + tabRef[GmfHexahedra] = 8; + + int ver, dim; + MESSAGE("Read " << theFile << " file"); + int InpMsh = GmfOpenMesh(theFile, GmfRead, &ver, &dim); + if (!InpMsh) + return false; + MESSAGE("Done "); + + // Issue 0020682. Avoid creating nodes and tetras at place where + // volumic elements already exist + SMESH_ElementSearcher* elemSearcher = 0; + vector< const SMDS_MeshElement* > foundVolumes; + if ( theHelper->GetMesh()->NbVolumes() > 0 ) + elemSearcher = SMESH_MeshEditor( theHelper->GetMesh() ).GetElementSearcher(); + + int nbVertices = GmfStatKwd(InpMsh, GmfVertices) - nbInitialNodes; + GMFNode = new const SMDS_MeshNode*[ nbVertices + 1 ]; + //nodeAssigne = new int[ nbVertices + 1 ]; + + std::map ::const_iterator it = tabRef.begin(); + for ( ; it != tabRef.end() ; ++it) + { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(theAlgo->computeCanceled()) { + GmfCloseMesh(InpMsh); + delete [] GMFNode; + //delete [] nodeAssigne; + return false; + } +#endif + int dummy; + GmfKwdCod token = it->first; + nbRef = it->second; + + nbElem = GmfStatKwd(InpMsh, token); + if (nbElem > 0) { + GmfGotoKwd(InpMsh, token); + std::cout << "Read " << nbElem; + } + else + continue; + + std::vector id (nbElem*tabRef[token]); // node ids + + if (token == GmfVertices) { + (nbElem <= 1) ? tmpStr = " vertex" : tmpStr = " vertices"; +// std::cout << nbInitialNodes << " from input mesh " << std::endl; + + // Remove orphan nodes from previous enforced mesh which was cleared +// if ( nbElem < nbMeshNodes ) { +// const SMDS_MeshNode* node; +// SMDS_NodeIteratorPtr nodeIt = theMeshDS->nodesIterator(); +// while ( nodeIt->more() ) +// { +// node = nodeIt->next(); +// if (theNodeToGhs3dIdMap.find(node) != theNodeToGhs3dIdMap.end()) +// theMeshDS->RemoveNode(node); +// } +// } + + + int aGMFID; + + float VerTab_f[3]; + double x, y, z; + const SMDS_MeshNode * aGMFNode; + + //shapeID = theMeshDS->ShapeToIndex( theSolid ); + for ( int iElem = 0; iElem < nbElem; iElem++ ) { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(theAlgo->computeCanceled()) { + GmfCloseMesh(InpMsh); + delete [] GMFNode; + //delete [] nodeAssigne; + return false; + } +#endif + if (ver == GmfFloat) { + GmfGetLin(InpMsh, token, &VerTab_f[0], &VerTab_f[1], &VerTab_f[2], &dummy); + x = VerTab_f[0]; + y = VerTab_f[1]; + z = VerTab_f[2]; + } + else { + GmfGetLin(InpMsh, token, &x, &y, &z, &dummy); + } + if (iElem >= nbInitialNodes) { + if ( elemSearcher && + elemSearcher->FindElementsByPoint( gp_Pnt(x,y,z), SMDSAbs_Volume, foundVolumes)) + aGMFNode = 0; + else + aGMFNode = theHelper->AddNode(x, y, z); + + aGMFID = iElem -nbInitialNodes +1; + GMFNode[ aGMFID ] = aGMFNode; + //nodeAssigne[ aGMFID ] = 0; + if (aGMFID-1 < aNodeGroupByGhs3dId.size() && !aNodeGroupByGhs3dId.at(aGMFID-1).empty()) + addElemInMeshGroup(theHelper->GetMesh(), aGMFNode, aNodeGroupByGhs3dId.at(aGMFID-1), groupsToRemove); + } + } + } + else if (token == GmfCorners && nbElem > 0) { + (nbElem <= 1) ? tmpStr = " corner" : tmpStr = " corners"; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]); + } + else if (token == GmfRidges && nbElem > 0) { + (nbElem <= 1) ? tmpStr = " ridge" : tmpStr = " ridges"; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]]); + } + else if (token == GmfEdges && nbElem > 0) { + (nbElem <= 1) ? tmpStr = " edge" : tmpStr = " edges"; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &dummy); + } + else if (token == GmfTriangles && nbElem > 0) { + (nbElem <= 1) ? tmpStr = " triangle" : tmpStr = " triangles"; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &dummy); + } + else if (token == GmfQuadrilaterals && nbElem > 0) { + (nbElem <= 1) ? tmpStr = " Quadrilateral" : tmpStr = " Quadrilaterals"; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], &dummy); + } + else if (token == GmfTetrahedra && nbElem > 0) { + (nbElem <= 1) ? tmpStr = " Tetrahedron" : tmpStr = " Tetrahedra"; + for ( int iElem = 0; iElem < nbElem; iElem++ ) { + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], &dummy); +#ifdef _DEBUG_ + subdomainId2tetraId[dummy].insert(iElem+1); +// MESSAGE("subdomainId2tetraId["< 0) { + (nbElem <= 1) ? tmpStr = " Hexahedron" : tmpStr = " Hexahedra"; + for ( int iElem = 0; iElem < nbElem; iElem++ ) + GmfGetLin(InpMsh, token, &id[iElem*tabRef[token]], &id[iElem*tabRef[token]+1], &id[iElem*tabRef[token]+2], &id[iElem*tabRef[token]+3], + &id[iElem*tabRef[token]+4], &id[iElem*tabRef[token]+5], &id[iElem*tabRef[token]+6], &id[iElem*tabRef[token]+7], &dummy); + } + std::cout << tmpStr << std::endl; + std::cout << std::endl; + + switch (token) { + case GmfCorners: + case GmfRidges: + case GmfEdges: + case GmfTriangles: + case GmfQuadrilaterals: + case GmfTetrahedra: + case GmfHexahedra: + { + std::vector< const SMDS_MeshNode* > node( nbRef ); + std::vector< int > nodeID( nbRef ); + std::vector< SMDS_MeshNode* > enfNode( nbRef ); + const SMDS_MeshElement* aCreatedElem; + + for ( int iElem = 0; iElem < nbElem; iElem++ ) + { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(theAlgo->computeCanceled()) { + GmfCloseMesh(InpMsh); + delete [] GMFNode; + //delete [] nodeAssigne; + return false; + } +#endif + // Check if elem is already in input mesh. If yes => skip + bool fullyCreatedElement = false; // if at least one of the nodes was created + for ( int iRef = 0; iRef < nbRef; iRef++ ) + { + aGMFNodeID = id[iElem*tabRef[token]+iRef]; // read nbRef aGMFNodeID + if (aGMFNodeID <= nbInitialNodes) // input nodes + { + aGMFNodeID--; + node[ iRef ] = theNodeByGhs3dId[aGMFNodeID]; + } + else + { + fullyCreatedElement = true; + aGMFNodeID -= nbInitialNodes; + nodeID[ iRef ] = aGMFNodeID ; + node [ iRef ] = GMFNode[ aGMFNodeID ]; + } + } + + switch (token) + { + case GmfEdges: + if (fullyCreatedElement) { + aCreatedElem = theHelper->AddEdge( node[0], node[1], /*id =*/0, /*force3d =*/false ); + if (anEdgeGroupByGhs3dId.size() && !anEdgeGroupByGhs3dId[iElem].empty()) + addElemInMeshGroup(theHelper->GetMesh(), aCreatedElem, anEdgeGroupByGhs3dId[iElem], groupsToRemove); + } + break; + case GmfTriangles: + if (fullyCreatedElement) { + aCreatedElem = theHelper->AddFace( node[0], node[1], node[2], /*id =*/0, /*force3d =*/false ); + // for ( int iRef = 0; iRef < nbRef; iRef++ ) + // nodeAssigne[ nodeID[ iRef ]] = 1; + if (aFaceGroupByGhs3dId.size() && !aFaceGroupByGhs3dId[iElem].empty()) + addElemInMeshGroup(theHelper->GetMesh(), aCreatedElem, aFaceGroupByGhs3dId[iElem], groupsToRemove); + } + break; + case GmfQuadrilaterals: + if (fullyCreatedElement) { + theHelper->AddFace( node[0], node[1], node[2], node[3], /*id =*/0, /*force3d =*/false ); + // for ( int iRef = 0; iRef < nbRef; iRef++ ) + // nodeAssigne[ nodeID[ iRef ]] = 1; + } + case GmfTetrahedra: + if ( elemSearcher ) { + // Issue 0020682. Avoid creating nodes and tetras at place where + // volumic elements already exist + if ( !node[1] || !node[0] || !node[2] || !node[3] ) + continue; + if ( elemSearcher->FindElementsByPoint((SMESH_TNodeXYZ(node[0]) + + SMESH_TNodeXYZ(node[1]) + + SMESH_TNodeXYZ(node[2]) + + SMESH_TNodeXYZ(node[3]) ) / 4., + SMDSAbs_Volume, foundVolumes )) + break; + } + theHelper->AddVolume( node[1], node[0], node[2], node[3], /*id =*/0, /*force3d =*/false ); +// theMeshDS->SetMeshElementOnShape( aTet, shapeID ); + break; + case GmfHexahedra: + if ( elemSearcher ) { + // Issue 0020682. Avoid creating nodes and tetras at place where + // volumic elements already exist + if ( !node[1] || !node[0] || !node[2] || !node[3] || !node[4] || !node[5] || !node[6] || !node[7]) + continue; + if ( elemSearcher->FindElementsByPoint((SMESH_TNodeXYZ(node[0]) + + SMESH_TNodeXYZ(node[1]) + + SMESH_TNodeXYZ(node[2]) + + SMESH_TNodeXYZ(node[3]) + + SMESH_TNodeXYZ(node[4]) + + SMESH_TNodeXYZ(node[5]) + + SMESH_TNodeXYZ(node[6]) + + SMESH_TNodeXYZ(node[7])) / 8., + SMDSAbs_Volume, foundVolumes )) + break; + } + theHelper->AddVolume( node[0], node[3], node[2], node[1], + node[4], node[7], node[6], node[5], /*id =*/0, /*force3d =*/false ); +// theMeshDS->SetMeshElementOnShape( aTet, shapeID ); + break; + default: continue; + } + } + break; + } + } + } + + // for ( int i = 0; i < nbVertices; ++i ) { + // if ( !nodeAssigne[ i+1 ]) + // theMeshDS->SetNodeInVolume( GMFNode[ i+1 ], shapeID ); + // } + + GmfCloseMesh(InpMsh); + delete [] GMFNode; + //delete [] nodeAssigne; +#ifdef _DEBUG_ + MESSAGE("Nb subdomains " << subdomainId2tetraId.size()); + std::map >::const_iterator subdomainIt = subdomainId2tetraId.begin(); + TCollection_AsciiString aSubdomainFileName = theFile; + aSubdomainFileName = aSubdomainFileName + ".subdomain"; + ofstream aSubdomainFile ( aSubdomainFileName.ToCString() , ios::out); + + aSubdomainFile << "Nb subdomains " << subdomainId2tetraId.size() << std::endl; + for(;subdomainIt != subdomainId2tetraId.end() ; ++subdomainIt) { + int subdomainId = subdomainIt->first; + std::set tetraIds = subdomainIt->second; + MESSAGE("Subdomain #"<::const_iterator tetraIdsIt = tetraIds.begin(); + aSubdomainFile << subdomainId << std::endl; + for(;tetraIdsIt != tetraIds.end() ; ++tetraIdsIt) { + aSubdomainFile << (*tetraIdsIt) << " "; + } + aSubdomainFile << std::endl; + } + aSubdomainFile.close(); +#endif + + return true; +} + +static bool writeGMFFile(const char* theMeshFileName, + const char* theRequiredFileName, + const char* theSolFileName, + const SMESH_ProxyMesh& theProxyMesh, + SMESH_Mesh * theMesh, + std::vector & theNodeByGhs3dId, + std::map & aNodeToGhs3dIdMap, + std::vector & aNodeGroupByGhs3dId, + std::vector & anEdgeGroupByGhs3dId, + std::vector & aFaceGroupByGhs3dId, + GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap & theEnforcedNodes, + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles, + std::map, std::string> & enfVerticesWithGroup, + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices) +{ + MESSAGE("writeGMFFile w/o geometry"); + std::string tmpStr; + int idx, idxRequired = 0, idxSol = 0; + const int dummyint = 0; + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt; + std::vector enfVertexSizes; + const SMDS_MeshElement* elem; + TIDSortedElemSet anElemSet, theKeptEnforcedEdges, theKeptEnforcedTriangles; + SMDS_ElemIteratorPtr nodeIt; + std::vector theEnforcedNodeByGhs3dId; + map anEnforcedNodeToGhs3dIdMap, anExistingEnforcedNodeToGhs3dIdMap; + std::vector< const SMDS_MeshElement* > foundElems; + map aNodeToTopAbs_StateMap; + int nbFoundElems; + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap::iterator elemIt; + TIDSortedElemSet::iterator elemSetIt; + bool isOK; + auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher()); + + int nbEnforcedVertices = theEnforcedVertices.size(); + + // count faces + int nbFaces = theProxyMesh.NbFaces(); + int nbNodes; + + // groups management + int usedEnforcedNodes = 0; + std::string gn = ""; + + if ( nbFaces == 0 ) + return false; + + idx = GmfOpenMesh(theMeshFileName, GmfWrite, GMFVERSION, GMFDIMENSION); + if (!idx) + return false; + + /* ========================== FACES ========================== */ + /* TRIANGLES ========================== */ + SMDS_ElemIteratorPtr eIt = theProxyMesh.GetFaces(); + while ( eIt->more() ) + { + elem = eIt->next(); + anElemSet.insert(elem); + nodeIt = elem->nodesIterator(); + nbNodes = elem->NbCornerNodes(); + while ( nodeIt->more() && nbNodes--) + { + // find GHS3D ID + const SMDS_MeshNode* node = castToNode( nodeIt->next() ); + int newId = aNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1 + aNodeToGhs3dIdMap.insert( make_pair( node, newId )); + } + } + + /* EDGES ========================== */ + + // Iterate over the enforced edges + for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { + elem = elemIt->first; + isOK = true; + nodeIt = elem->nodesIterator(); + nbNodes = 2; + while ( nodeIt->more() && nbNodes-- ) { + // find GHS3D ID + const SMDS_MeshNode* node = castToNode( nodeIt->next() ); + // Test if point is inside shape to mesh + gp_Pnt myPoint(node->X(),node->Y(),node->Z()); + TopAbs_State result = pntCls->GetPointState( myPoint ); + if ( result == TopAbs_OUT ) { + isOK = false; + break; + } + aNodeToTopAbs_StateMap.insert( make_pair( node, result )); + } + if (isOK) { + nodeIt = elem->nodesIterator(); + nbNodes = 2; + int newId = -1; + while ( nodeIt->more() && nbNodes-- ) { + // find GHS3D ID + const SMDS_MeshNode* node = castToNode( nodeIt->next() ); + gp_Pnt myPoint(node->X(),node->Y(),node->Z()); + nbFoundElems = pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems); +#ifdef _DEBUG_ + std::cout << "Node at "<X()<<", "<Y()<<", "<Z()<first; + isOK = true; + nodeIt = elem->nodesIterator(); + nbNodes = 3; + while ( nodeIt->more() && nbNodes--) { + // find GHS3D ID + const SMDS_MeshNode* node = castToNode( nodeIt->next() ); + // Test if point is inside shape to mesh + gp_Pnt myPoint(node->X(),node->Y(),node->Z()); + TopAbs_State result = pntCls->GetPointState( myPoint ); + if ( result == TopAbs_OUT ) { + isOK = false; + break; + } + aNodeToTopAbs_StateMap.insert( make_pair( node, result )); + } + if (isOK) { + nodeIt = elem->nodesIterator(); + nbNodes = 3; + int newId = -1; + while ( nodeIt->more() && nbNodes--) { + // find GHS3D ID + const SMDS_MeshNode* node = castToNode( nodeIt->next() ); + gp_Pnt myPoint(node->X(),node->Y(),node->Z()); + nbFoundElems = pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems); +#ifdef _DEBUG_ + std::cout << "Nb nodes found : "<::const_iterator n2id = aNodeToGhs3dIdMap.begin(); + for ( ; n2id != aNodeToGhs3dIdMap.end(); ++ n2id) + { +// std::cout << "n2id->first: "<first<second - 1 ] = n2id->first; // ghs3d ids count from 1 + } + + // put nodes to anEnforcedNodeToGhs3dIdMap vector +#ifdef _DEBUG_ + std::cout << "anEnforcedNodeToGhs3dIdMap.size(): "<second > aNodeToGhs3dIdMap.size()) { + theEnforcedNodeByGhs3dId[ n2id->second - aNodeToGhs3dIdMap.size() - 1 ] = n2id->first; // ghs3d ids count from 1 + } + } + + + /* ========================== NODES ========================== */ + vector theOrderedNodes, theRequiredNodes; + std::set< std::vector > nodesCoords; + vector::const_iterator ghs3dNodeIt = theNodeByGhs3dId.begin(); + vector::const_iterator after = theNodeByGhs3dId.end(); + + (theNodeByGhs3dId.size() <= 1) ? tmpStr = " node" : " nodes"; + std::cout << theNodeByGhs3dId.size() << tmpStr << " from mesh ..." << std::endl; + for ( ; ghs3dNodeIt != after; ++ghs3dNodeIt ) + { + const SMDS_MeshNode* node = *ghs3dNodeIt; + std::vector coords; + coords.push_back(node->X()); + coords.push_back(node->Y()); + coords.push_back(node->Z()); + nodesCoords.insert(coords); + theOrderedNodes.push_back(node); + } + + // Iterate over the enforced nodes given by enforced elements + ghs3dNodeIt = theEnforcedNodeByGhs3dId.begin(); + after = theEnforcedNodeByGhs3dId.end(); + (theEnforcedNodeByGhs3dId.size() <= 1) ? tmpStr = " node" : " nodes"; + std::cout << theEnforcedNodeByGhs3dId.size() << tmpStr << " from enforced elements ..." << std::endl; + for ( ; ghs3dNodeIt != after; ++ghs3dNodeIt ) + { + const SMDS_MeshNode* node = *ghs3dNodeIt; + std::vector coords; + coords.push_back(node->X()); + coords.push_back(node->Y()); + coords.push_back(node->Z()); +#ifdef _DEBUG_ + std::cout << "Node at " << node->X()<<", " <Y()<<", " <Z(); +#endif + + if (nodesCoords.find(coords) != nodesCoords.end()) { + // node already exists in original mesh +#ifdef _DEBUG_ + std::cout << " found" << std::endl; +#endif + continue; + } + + if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) { + // node already exists in enforced vertices +#ifdef _DEBUG_ + std::cout << " found" << std::endl; +#endif + continue; + } + +// gp_Pnt myPoint(node->X(),node->Y(),node->Z()); +// nbFoundElems = pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems); +// if (nbFoundElems ==0) { +// std::cout << " not found" << std::endl; +// if ((*aNodeToTopAbs_StateMap.find(node)).second == TopAbs_IN) { +// nodesCoords.insert(coords); +// theOrderedNodes.push_back(node); +// } +// } +// else { +// std::cout << " found in initial mesh" << std::endl; +// const SMDS_MeshNode* existingNode = (SMDS_MeshNode*) foundElems.at(0); +// nodesCoords.insert(coords); +// theOrderedNodes.push_back(existingNode); +// } + +#ifdef _DEBUG_ + std::cout << " not found" << std::endl; +#endif + + nodesCoords.insert(coords); + theOrderedNodes.push_back(node); +// theRequiredNodes.push_back(node); + } + + + // Iterate over the enforced nodes + GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator enfNodeIt; + (theEnforcedNodes.size() <= 1) ? tmpStr = " node" : " nodes"; + std::cout << theEnforcedNodes.size() << tmpStr << " from enforced nodes ..." << std::endl; + for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt) + { + const SMDS_MeshNode* node = enfNodeIt->first; + std::vector coords; + coords.push_back(node->X()); + coords.push_back(node->Y()); + coords.push_back(node->Z()); +#ifdef _DEBUG_ + std::cout << "Node at " << node->X()<<", " <Y()<<", " <Z(); +#endif + + // Test if point is inside shape to mesh + gp_Pnt myPoint(node->X(),node->Y(),node->Z()); + TopAbs_State result = pntCls->GetPointState( myPoint ); + if ( result == TopAbs_OUT ) { +#ifdef _DEBUG_ + std::cout << " out of volume" << std::endl; +#endif + continue; + } + + if (nodesCoords.find(coords) != nodesCoords.end()) { +#ifdef _DEBUG_ + std::cout << " found in nodesCoords" << std::endl; +#endif +// theRequiredNodes.push_back(node); + continue; + } + + if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) { +#ifdef _DEBUG_ + std::cout << " found in theEnforcedVertices" << std::endl; +#endif + continue; + } + +// nbFoundElems = pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems); +// if (nbFoundElems ==0) { +// std::cout << " not found" << std::endl; +// if (result == TopAbs_IN) { +// nodesCoords.insert(coords); +// theRequiredNodes.push_back(node); +// } +// } +// else { +// std::cout << " found in initial mesh" << std::endl; +// const SMDS_MeshNode* existingNode = (SMDS_MeshNode*) foundElems.at(0); +// // nodesCoords.insert(coords); +// theRequiredNodes.push_back(existingNode); +// } +// +// +// +// if (pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems) == 0) +// continue; + +// if ( result != TopAbs_IN ) +// continue; + +#ifdef _DEBUG_ + std::cout << " not found" << std::endl; +#endif + nodesCoords.insert(coords); +// theOrderedNodes.push_back(node); + theRequiredNodes.push_back(node); + } + int requiredNodes = theRequiredNodes.size(); + + int solSize = 0; + std::vector > ReqVerTab; + if (nbEnforcedVertices) { +// ReqVerTab.clear(); + (nbEnforcedVertices <= 1) ? tmpStr = " node" : " nodes"; + std::cout << nbEnforcedVertices << tmpStr << " from enforced vertices ..." << std::endl; + // Iterate over the enforced vertices + for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) { + double x = vertexIt->first[0]; + double y = vertexIt->first[1]; + double z = vertexIt->first[2]; + // Test if point is inside shape to mesh + gp_Pnt myPoint(x,y,z); + TopAbs_State result = pntCls->GetPointState( myPoint ); + if ( result == TopAbs_OUT ) + continue; + if (pntCls->FindElementsByPoint(myPoint, SMDSAbs_Node, foundElems) == 0) + continue; + +// if ( result != TopAbs_IN ) +// continue; + std::vector coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + ReqVerTab.push_back(coords); + enfVertexSizes.push_back(vertexIt->second); + solSize++; + } + } + + + // GmfVertices + std::cout << "Begin writting required nodes in GmfVertices" << std::endl; + std::cout << "Nb vertices: " << theOrderedNodes.size() << std::endl; + GmfSetKwd(idx, GmfVertices, theOrderedNodes.size()/*+solSize*/); + for (ghs3dNodeIt = theOrderedNodes.begin();ghs3dNodeIt != theOrderedNodes.end();++ghs3dNodeIt) { + GmfSetLin(idx, GmfVertices, (*ghs3dNodeIt)->X(), (*ghs3dNodeIt)->Y(), (*ghs3dNodeIt)->Z(), dummyint); + } + + std::cout << "End writting required nodes in GmfVertices" << std::endl; + + if (requiredNodes + solSize) { + std::cout << "Begin writting in req and sol file" << std::endl; + aNodeGroupByGhs3dId.resize( requiredNodes + solSize ); + idxRequired = GmfOpenMesh(theRequiredFileName, GmfWrite, GMFVERSION, GMFDIMENSION); + if (!idxRequired) { + GmfCloseMesh(idx); + return false; + } + idxSol = GmfOpenMesh(theSolFileName, GmfWrite, GMFVERSION, GMFDIMENSION); + if (!idxSol) { + GmfCloseMesh(idx); + if (idxRequired) + GmfCloseMesh(idxRequired); + return false; + } + int TypTab[] = {GmfSca}; + GmfSetKwd(idxRequired, GmfVertices, requiredNodes + solSize); + GmfSetKwd(idxSol, GmfSolAtVertices, requiredNodes + solSize, 1, TypTab); +// int usedEnforcedNodes = 0; +// std::string gn = ""; + for (ghs3dNodeIt = theRequiredNodes.begin();ghs3dNodeIt != theRequiredNodes.end();++ghs3dNodeIt) { + GmfSetLin(idxRequired, GmfVertices, (*ghs3dNodeIt)->X(), (*ghs3dNodeIt)->Y(), (*ghs3dNodeIt)->Z(), dummyint); + GmfSetLin(idxSol, GmfSolAtVertices, 0.0); + if (theEnforcedNodes.find((*ghs3dNodeIt)) != theEnforcedNodes.end()) + gn = theEnforcedNodes.find((*ghs3dNodeIt))->second; + aNodeGroupByGhs3dId[usedEnforcedNodes] = gn; + usedEnforcedNodes++; + } + + for (int i=0;isecond; +#ifdef _DEBUG_ + std::cout << "aNodeGroupByGhs3dId["<nodesIterator(); + int index=0; + while ( nodeIt->more() ) { + // find GHS3D ID + const SMDS_MeshNode* node = castToNode( nodeIt->next() ); + map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node); + if (it == anEnforcedNodeToGhs3dIdMap.end()) { + it = anExistingEnforcedNodeToGhs3dIdMap.find(node); + if (it == anEnforcedNodeToGhs3dIdMap.end()) + throw "Node not found"; + } + nedge[index] = it->second; + index++; + } + GmfSetLin(idx, GmfEdges, nedge[0], nedge[1], dummyint); + anEdgeGroupByGhs3dId[usedEnforcedEdges] = theEnforcedEdges.find(elem)->second; +// GmfSetLin(idxRequired, GmfEdges, nedge[0], nedge[1], dummyint); + usedEnforcedEdges++; + } +// GmfCloseMesh(idxRequired); + } + + + if (usedEnforcedEdges) { + GmfSetKwd(idx, GmfRequiredEdges, usedEnforcedEdges); + for (int enfID=1;enfID<=usedEnforcedEdges;enfID++) { + GmfSetLin(idx, GmfRequiredEdges, enfID); + } + } + + // GmfTriangles + int usedEnforcedTriangles = 0; + if (anElemSet.size()+theKeptEnforcedTriangles.size()) { + aFaceGroupByGhs3dId.resize( anElemSet.size()+theKeptEnforcedTriangles.size() ); + GmfSetKwd(idx, GmfTriangles, anElemSet.size()+theKeptEnforcedTriangles.size()); + int k=0; + for(elemSetIt = anElemSet.begin() ; elemSetIt != anElemSet.end() ; ++elemSetIt,++k) { + elem = (*elemSetIt); + nodeIt = elem->nodesIterator(); + int index=0; + for ( int j = 0; j < 3; ++j ) { + // find GHS3D ID + const SMDS_MeshNode* node = castToNode( nodeIt->next() ); + map< const SMDS_MeshNode*,int >::iterator it = aNodeToGhs3dIdMap.find(node); + if (it == aNodeToGhs3dIdMap.end()) + throw "Node not found"; + ntri[index] = it->second; + index++; + } + GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint); + aFaceGroupByGhs3dId[k] = ""; + } + if (theKeptEnforcedTriangles.size()) { + for(elemSetIt = theKeptEnforcedTriangles.begin() ; elemSetIt != theKeptEnforcedTriangles.end() ; ++elemSetIt,++k) { + elem = (*elemSetIt); + nodeIt = elem->nodesIterator(); + int index=0; + for ( int j = 0; j < 3; ++j ) { + // find GHS3D ID + const SMDS_MeshNode* node = castToNode( nodeIt->next() ); + map< const SMDS_MeshNode*,int >::iterator it = anEnforcedNodeToGhs3dIdMap.find(node); + if (it == anEnforcedNodeToGhs3dIdMap.end()) { + it = anExistingEnforcedNodeToGhs3dIdMap.find(node); + if (it == anEnforcedNodeToGhs3dIdMap.end()) + throw "Node not found"; + } + ntri[index] = it->second; + index++; + } + GmfSetLin(idx, GmfTriangles, ntri[0], ntri[1], ntri[2], dummyint); + aFaceGroupByGhs3dId[k] = theEnforcedTriangles.find(elem)->second; + usedEnforcedTriangles++; + } + } + } + + + if (usedEnforcedTriangles) { + GmfSetKwd(idx, GmfRequiredTriangles, usedEnforcedTriangles); + for (int enfID=1;enfID<=usedEnforcedTriangles;enfID++) + GmfSetLin(idx, GmfRequiredTriangles, anElemSet.size()+enfID); + } + + GmfCloseMesh(idx); + if (idxRequired) + GmfCloseMesh(idxRequired); + if (idxSol) + GmfCloseMesh(idxSol); + + return true; + +} + +// static bool writeGMFFile(const char* theMeshFileName, +// const char* theRequiredFileName, +// const char* theSolFileName, +// SMESH_MesherHelper& theHelper, +// const SMESH_ProxyMesh& theProxyMesh, +// std::map & theNodeId2NodeIndexMap, +// std::map & theSmdsToGhs3dIdMap, +// std::map & theGhs3dIdToNodeMap, +// TIDSortedNodeSet & theEnforcedNodes, +// TIDSortedElemSet & theEnforcedEdges, +// TIDSortedElemSet & theEnforcedTriangles, +// // TIDSortedElemSet & theEnforcedQuadrangles, +// GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices) +// { +// MESSAGE("writeGMFFile with geometry"); +// int idx, idxRequired, idxSol; +// int nbv, nbev, nben, aGhs3dID = 0; +// const int dummyint = 0; +// GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt; +// std::vector enfVertexSizes; +// TIDSortedNodeSet::const_iterator enfNodeIt; +// const SMDS_MeshNode* node; +// SMDS_NodeIteratorPtr nodeIt; +// +// idx = GmfOpenMesh(theMeshFileName, GmfWrite, GMFVERSION, GMFDIMENSION); +// if (!idx) +// return false; +// +// SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS(); +// +// /* ========================== NODES ========================== */ +// // NB_NODES +// nbv = theMeshDS->NbNodes(); +// if ( nbv == 0 ) +// return false; +// nbev = theEnforcedVertices.size(); +// nben = theEnforcedNodes.size(); +// +// // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by GHS3D +// // The problem is in nodes on degenerated edges, we need to skip nodes which are free +// // and replace not-free nodes on edges by the node on vertex +// TNodeNodeMap n2nDegen; // map a node on degenerated edge to a node on vertex +// TNodeNodeMap::iterator n2nDegenIt; +// if ( theHelper.HasDegeneratedEdges() ) +// { +// set checkedSM; +// for (TopExp_Explorer e(theMeshDS->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next()) +// { +// SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh( e.Current() ); +// if ( checkedSM.insert( sm->GetId() ).second && theHelper.IsDegenShape(sm->GetId() )) +// { +// if ( SMESHDS_SubMesh* smDS = sm->GetSubMeshDS() ) +// { +// TopoDS_Shape vertex = TopoDS_Iterator( e.Current() ).Value(); +// const SMDS_MeshNode* vNode = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), theMeshDS); +// { +// SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); +// while ( nIt->more() ) +// n2nDegen.insert( make_pair( nIt->next(), vNode )); +// } +// } +// } +// } +// } +// +// const bool isQuadMesh = +// theHelper.GetMesh()->NbEdges( ORDER_QUADRATIC ) || +// theHelper.GetMesh()->NbFaces( ORDER_QUADRATIC ) || +// theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC ); +// +// std::vector > VerTab; +// std::set > VerMap; +// VerTab.clear(); +// std::vector aVerTab; +// // Loop from 1 to NB_NODES +// +// nodeIt = theMeshDS->nodesIterator(); +// +// while ( nodeIt->more() ) +// { +// node = nodeIt->next(); +// if ( isQuadMesh && theHelper.IsMedium( node )) // Issue 0021238 +// continue; +// if ( n2nDegen.count( node ) ) // Issue 0020674 +// continue; +// +// std::vector coords; +// coords.push_back(node->X()); +// coords.push_back(node->Y()); +// coords.push_back(node->Z()); +// if (VerMap.find(coords) != VerMap.end()) { +// aGhs3dID = theSmdsToGhs3dIdMap[node->GetID()]; +// theGhs3dIdToNodeMap[theSmdsToGhs3dIdMap[node->GetID()]] = node; +// continue; +// } +// VerTab.push_back(coords); +// VerMap.insert(coords); +// aGhs3dID++; +// theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID )); +// theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node )); +// } +// +// +// /* ENFORCED NODES ========================== */ +// if (nben) { +// std::cout << "Add " << nben << " enforced nodes to input .mesh file" << std::endl; +// for(enfNodeIt = theEnforcedNodes.begin() ; enfNodeIt != theEnforcedNodes.end() ; ++enfNodeIt) { +// double x = (*enfNodeIt)->X(); +// double y = (*enfNodeIt)->Y(); +// double z = (*enfNodeIt)->Z(); +// // Test if point is inside shape to mesh +// gp_Pnt myPoint(x,y,z); +// BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh()); +// scl.Perform(myPoint, 1e-7); +// TopAbs_State result = scl.State(); +// if ( result != TopAbs_IN ) +// continue; +// std::vector coords; +// coords.push_back(x); +// coords.push_back(y); +// coords.push_back(z); +// if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) +// continue; +// if (VerMap.find(coords) != VerMap.end()) +// continue; +// VerTab.push_back(coords); +// VerMap.insert(coords); +// aGhs3dID++; +// theNodeId2NodeIndexMap.insert( make_pair( (*enfNodeIt)->GetID(), aGhs3dID )); +// } +// } +// +// +// /* ENFORCED VERTICES ========================== */ +// int solSize = 0; +// std::vector > ReqVerTab; +// ReqVerTab.clear(); +// if (nbev) { +// std::cout << "Add " << nbev << " enforced vertices to input .mesh file" << std::endl; +// for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) { +// double x = vertexIt->first[0]; +// double y = vertexIt->first[1]; +// double z = vertexIt->first[2]; +// // Test if point is inside shape to mesh +// gp_Pnt myPoint(x,y,z); +// BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh()); +// scl.Perform(myPoint, 1e-7); +// TopAbs_State result = scl.State(); +// if ( result != TopAbs_IN ) +// continue; +// enfVertexSizes.push_back(vertexIt->second); +// std::vector coords; +// coords.push_back(x); +// coords.push_back(y); +// coords.push_back(z); +// if (VerMap.find(coords) != VerMap.end()) +// continue; +// ReqVerTab.push_back(coords); +// VerMap.insert(coords); +// solSize++; +// } +// } +// +// +// /* ========================== FACES ========================== */ +// +// int nbTriangles = 0/*, nbQuadrangles = 0*/, aSmdsID; +// TopTools_IndexedMapOfShape facesMap, trianglesMap/*, quadranglesMap*/; +// TIDSortedElemSet::const_iterator elemIt; +// const SMESHDS_SubMesh* theSubMesh; +// TopoDS_Shape aShape; +// SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace; +// const SMDS_MeshElement* aFace; +// map::const_iterator itOnMap; +// std::vector > tt, qt,et; +// tt.clear(); +// qt.clear(); +// et.clear(); +// std::vector att, aqt, aet; +// +// TopExp::MapShapes( theMeshDS->ShapeToMesh(), TopAbs_FACE, facesMap ); +// +// for ( int i = 1; i <= facesMap.Extent(); ++i ) +// if (( theSubMesh = theProxyMesh.GetSubMesh( facesMap(i)))) +// { +// SMDS_ElemIteratorPtr it = theSubMesh->GetElements(); +// while (it->more()) +// { +// const SMDS_MeshElement *elem = it->next(); +// int nbCornerNodes = elem->NbCornerNodes(); +// if (nbCornerNodes == 3) +// { +// trianglesMap.Add(facesMap(i)); +// nbTriangles ++; +// } +// // else if (nbCornerNodes == 4) +// // { +// // quadranglesMap.Add(facesMap(i)); +// // nbQuadrangles ++; +// // } +// } +// } +// +// /* TRIANGLES ========================== */ +// if (nbTriangles) { +// for ( int i = 1; i <= trianglesMap.Extent(); i++ ) +// { +// aShape = trianglesMap(i); +// theSubMesh = theProxyMesh.GetSubMesh(aShape); +// if ( !theSubMesh ) continue; +// itOnSubMesh = theSubMesh->GetElements(); +// while ( itOnSubMesh->more() ) +// { +// aFace = itOnSubMesh->next(); +// itOnSubFace = aFace->nodesIterator(); +// att.clear(); +// for ( int j = 0; j < 3; ++j ) { +// // find GHS3D ID +// node = castToNode( itOnSubFace->next() ); +// if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() ) +// node = n2nDegenIt->second; +// aSmdsID = node->GetID(); +// itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID ); +// ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() ); +// att.push_back((*itOnMap).second); +// } +// tt.push_back(att); +// } +// } +// } +// +// if (theEnforcedTriangles.size()) { +// std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles to input .mesh file" << std::endl; +// // Iterate over the enforced triangles +// for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { +// aFace = (*elemIt); +// itOnSubFace = aFace->nodesIterator(); +// bool isOK = true; +// att.clear(); +// +// for ( int j = 0; j < 3; ++j ) { +// node = castToNode( itOnSubFace->next() ); +// if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() ) +// node = n2nDegenIt->second; +// // std::cout << node; +// double x = node->X(); +// double y = node->Y(); +// double z = node->Z(); +// // Test if point is inside shape to mesh +// gp_Pnt myPoint(x,y,z); +// BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh()); +// scl.Perform(myPoint, 1e-7); +// TopAbs_State result = scl.State(); +// if ( result != TopAbs_IN ) { +// isOK = false; +// theEnforcedTriangles.erase(elemIt); +// continue; +// } +// std::vector coords; +// coords.push_back(x); +// coords.push_back(y); +// coords.push_back(z); +// if (VerMap.find(coords) != VerMap.end()) { +// att.push_back(theNodeId2NodeIndexMap[node->GetID()]); +// continue; +// } +// VerTab.push_back(coords); +// VerMap.insert(coords); +// aGhs3dID++; +// theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID )); +// att.push_back(aGhs3dID); +// } +// if (isOK) +// tt.push_back(att); +// } +// } +// +// +// /* ========================== EDGES ========================== */ +// +// if (theEnforcedEdges.size()) { +// // Iterate over the enforced edges +// std::cout << "Add " << theEnforcedEdges.size() << " enforced edges to input .mesh file" << std::endl; +// for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { +// aFace = (*elemIt); +// bool isOK = true; +// itOnSubFace = aFace->nodesIterator(); +// aet.clear(); +// for ( int j = 0; j < 2; ++j ) { +// node = castToNode( itOnSubFace->next() ); +// if (( n2nDegenIt = n2nDegen.find( node )) != n2nDegen.end() ) +// node = n2nDegenIt->second; +// double x = node->X(); +// double y = node->Y(); +// double z = node->Z(); +// // Test if point is inside shape to mesh +// gp_Pnt myPoint(x,y,z); +// BRepClass3d_SolidClassifier scl(theMeshDS->ShapeToMesh()); +// scl.Perform(myPoint, 1e-7); +// TopAbs_State result = scl.State(); +// if ( result != TopAbs_IN ) { +// isOK = false; +// theEnforcedEdges.erase(elemIt); +// continue; +// } +// std::vector coords; +// coords.push_back(x); +// coords.push_back(y); +// coords.push_back(z); +// if (VerMap.find(coords) != VerMap.end()) { +// aet.push_back(theNodeId2NodeIndexMap[node->GetID()]); +// continue; +// } +// VerTab.push_back(coords); +// VerMap.insert(coords); +// +// aGhs3dID++; +// theNodeId2NodeIndexMap.insert( make_pair( node->GetID(), aGhs3dID )); +// aet.push_back(aGhs3dID); +// } +// if (isOK) +// et.push_back(aet); +// } +// } +// +// +// /* Write vertices number */ +// MESSAGE("Number of vertices: "<GetElements(); +// // for ( int j = 0; j < 4; ++j ) +// // { +// // aFace = itOnSubMesh->next(); +// // itOnSubFace = aFace->nodesIterator(); +// // aqt.clear(); +// // while ( itOnSubFace->more() ) { +// // // find GHS3D ID +// // aSmdsID = itOnSubFace->next()->GetID(); +// // itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID ); +// // ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() ); +// // aqt.push_back((*itOnMap).second); +// // } +// // qt.push_back(aqt); +// // } +// // } +// // } +// // +// // if (theEnforcedQuadrangles.size()) { +// // // Iterate over the enforced triangles +// // for(elemIt = theEnforcedQuadrangles.begin() ; elemIt != theEnforcedQuadrangles.end() ; ++elemIt) { +// // aFace = (*elemIt); +// // bool isOK = true; +// // itOnSubFace = aFace->nodesIterator(); +// // aqt.clear(); +// // for ( int j = 0; j < 4; ++j ) { +// // int aNodeID = itOnSubFace->next()->GetID(); +// // itOnMap = theNodeId2NodeIndexMap.find(aNodeID); +// // if (itOnMap != theNodeId2NodeIndexMap.end()) +// // aqt.push_back((*itOnMap).second); +// // else { +// // isOK = false; +// // theEnforcedQuadrangles.erase(elemIt); +// // break; +// // } +// // } +// // if (isOK) +// // qt.push_back(aqt); +// // } +// // } +// // +// +// // /* Write quadrilaterals number */ +// // if (qt.size()) { +// // GmfSetKwd(idx, GmfQuadrilaterals, qt.size()); +// // for (int i=0;i & theSmdsToGhs3dIdMap, + const map & theEnforcedNodeIdToGhs3dIdMap, + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles) +{ + // record structure: + // + // NB_ELEMS DUMMY_INT + // Loop from 1 to NB_ELEMS + // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT + + TopoDS_Shape aShape; + const SMESHDS_SubMesh* theSubMesh; + const SMDS_MeshElement* aFace; + const char* space = " "; + const int dummyint = 0; + map::const_iterator itOnMap; + SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace; + int nbNodes, aSmdsID; + + TIDSortedElemSet::const_iterator elemIt; + int nbEnforcedEdges = theEnforcedEdges.size(); + int nbEnforcedTriangles = theEnforcedTriangles.size(); + + // count triangles bound to geometry + int nbTriangles = 0; + + TopTools_IndexedMapOfShape facesMap, trianglesMap; + TopExp::MapShapes( theShape, TopAbs_FACE, facesMap ); + + int nbFaces = facesMap.Extent(); + + for ( int i = 1; i <= nbFaces; ++i ) + if (( theSubMesh = theMesh.GetSubMesh( facesMap(i)))) + nbTriangles += theSubMesh->NbElements(); + std::string tmpStr; + (nbFaces == 0 || nbFaces == 1) ? tmpStr = " shape " : tmpStr = " shapes " ; + std::cout << " " << nbFaces << tmpStr << "of 2D dimension"; + int nbEnforcedElements = nbEnforcedEdges+nbEnforcedTriangles; + if (nbEnforcedElements > 0) { + (nbEnforcedElements == 1) ? tmpStr = "shape:" : tmpStr = "shapes:"; + std::cout << " and" << std::endl; + std::cout << " " << nbEnforcedElements + << " enforced " << tmpStr << std::endl; + } + else + std::cout << std::endl; + if (nbEnforcedEdges) { + (nbEnforcedEdges == 1) ? tmpStr = "edge" : tmpStr = "edges"; + std::cout << " " << nbEnforcedEdges << " enforced " << tmpStr << std::endl; + } + if (nbEnforcedTriangles) { + (nbEnforcedTriangles == 1) ? tmpStr = "triangle" : tmpStr = "triangles"; + std::cout << " " << nbEnforcedTriangles << " enforced " << tmpStr << std::endl; + } + std::cout << std::endl; + +// theFile << space << nbTriangles << space << dummyint << std::endl; + std::ostringstream globalStream, localStream, aStream; + + for ( int i = 1; i <= facesMap.Extent(); i++ ) + { + aShape = facesMap(i); + theSubMesh = theMesh.GetSubMesh(aShape); + if ( !theSubMesh ) continue; + itOnSubMesh = theSubMesh->GetElements(); + while ( itOnSubMesh->more() ) + { + aFace = itOnSubMesh->next(); + nbNodes = aFace->NbCornerNodes(); + + localStream << nbNodes << space; + + itOnSubFace = aFace->nodesIterator(); + for ( int j = 0; j < 3; ++j ) { + // find GHS3D ID + aSmdsID = itOnSubFace->next()->GetID(); + itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID ); + // if ( itOnMap == theSmdsToGhs3dIdMap.end() ) { + // cout << "not found node: " << aSmdsID << endl; + // return false; + // } + ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() ); + + localStream << (*itOnMap).second << space ; + } + + // (NB_NODES + 1) times: DUMMY_INT + for ( int j=0; j<=nbNodes; j++) + localStream << dummyint << space ; + + localStream << std::endl; + } + } + + globalStream << localStream.str(); + localStream.str(""); + + // + // FACES : END + // + +// // +// // ENFORCED EDGES : BEGIN +// // +// +// // Iterate over the enforced edges +// int usedEnforcedEdges = 0; +// bool isOK; +// for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { +// aFace = (*elemIt); +// isOK = true; +// itOnSubFace = aFace->nodesIterator(); +// aStream.str(""); +// aStream << "2" << space ; +// for ( int j = 0; j < 2; ++j ) { +// aSmdsID = itOnSubFace->next()->GetID(); +// itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID); +// if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.end()) +// aStream << (*itOnMap).second << space; +// else { +// isOK = false; +// break; +// } +// } +// if (isOK) { +// for ( int j=0; j<=2; j++) +// aStream << dummyint << space ; +// // aStream << dummyint << space << dummyint; +// localStream << aStream.str() << std::endl; +// usedEnforcedEdges++; +// } +// } +// +// if (usedEnforcedEdges) { +// globalStream << localStream.str(); +// localStream.str(""); +// } +// +// // +// // ENFORCED EDGES : END +// // +// // +// +// // +// // ENFORCED TRIANGLES : BEGIN +// // +// // Iterate over the enforced triangles +// int usedEnforcedTriangles = 0; +// for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { +// aFace = (*elemIt); +// nbNodes = aFace->NbCornerNodes(); +// isOK = true; +// itOnSubFace = aFace->nodesIterator(); +// aStream.str(""); +// aStream << nbNodes << space ; +// for ( int j = 0; j < 3; ++j ) { +// aSmdsID = itOnSubFace->next()->GetID(); +// itOnMap = theEnforcedNodeIdToGhs3dIdMap.find(aSmdsID); +// if (itOnMap != theEnforcedNodeIdToGhs3dIdMap.end()) +// aStream << (*itOnMap).second << space; +// else { +// isOK = false; +// break; +// } +// } +// if (isOK) { +// for ( int j=0; j<=3; j++) +// aStream << dummyint << space ; +// localStream << aStream.str() << std::endl; +// usedEnforcedTriangles++; +// } +// } +// +// if (usedEnforcedTriangles) { +// globalStream << localStream.str(); +// localStream.str(""); +// } +// +// // +// // ENFORCED TRIANGLES : END +// // + + theFile + << nbTriangles/*+usedEnforcedTriangles+usedEnforcedEdges*/ + << " 0" << std::endl + << globalStream.str(); + + return true; +} + +//======================================================================= +//function : writePoints +//purpose : +//======================================================================= + +static bool writePoints (ofstream & theFile, + SMESH_MesherHelper& theHelper, + map & theSmdsToGhs3dIdMap, + map & theEnforcedNodeIdToGhs3dIdMap, + map & theGhs3dIdToNodeMap, + GHS3DPlugin_Hypothesis::TID2SizeMap & theNodeIDToSizeMap, + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues & theEnforcedVertices, + GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap & theEnforcedNodes, + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles) +{ + // record structure: + // + // NB_NODES + // Loop from 1 to NB_NODES + // X Y Z DUMMY_INT + + SMESHDS_Mesh * theMeshDS = theHelper.GetMeshDS(); + int nbNodes = theMeshDS->NbNodes(); + if ( nbNodes == 0 ) + return false; + + int nbEnforcedVertices = theEnforcedVertices.size(); + int nbEnforcedNodes = theEnforcedNodes.size(); + + const TopoDS_Shape shapeToMesh = theMeshDS->ShapeToMesh(); + + int aGhs3dID = 1; + SMDS_NodeIteratorPtr nodeIt = theMeshDS->nodesIterator(); + const SMDS_MeshNode* node; + + // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by GHS3D + // The problem is in nodes on degenerated edges, we need to skip nodes which are free + // and replace not-free nodes on degenerated edges by the node on vertex + TNodeNodeMap n2nDegen; // map a node on degenerated edge to a node on vertex + TNodeNodeMap::iterator n2nDegenIt; + if ( theHelper.HasDegeneratedEdges() ) + { + set checkedSM; + for (TopExp_Explorer e(theMeshDS->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next()) + { + SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh( e.Current() ); + if ( checkedSM.insert( sm->GetId() ).second && theHelper.IsDegenShape(sm->GetId() )) + { + if ( SMESHDS_SubMesh* smDS = sm->GetSubMeshDS() ) + { + TopoDS_Shape vertex = TopoDS_Iterator( e.Current() ).Value(); + const SMDS_MeshNode* vNode = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), theMeshDS); + { + SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); + while ( nIt->more() ) + n2nDegen.insert( make_pair( nIt->next(), vNode )); + } + } + } + } + nbNodes -= n2nDegen.size(); + } + + const bool isQuadMesh = + theHelper.GetMesh()->NbEdges( ORDER_QUADRATIC ) || + theHelper.GetMesh()->NbFaces( ORDER_QUADRATIC ) || + theHelper.GetMesh()->NbVolumes( ORDER_QUADRATIC ); + if ( isQuadMesh ) + { + // descrease nbNodes by nb of medium nodes + while ( nodeIt->more() ) + { + node = nodeIt->next(); + if ( !theHelper.IsDegenShape( node->getshapeId() )) + nbNodes -= int( theHelper.IsMedium( node )); + } + nodeIt = theMeshDS->nodesIterator(); + } + + const char* space = " "; + const int dummyint = 0; + + std::string tmpStr; + (nbNodes == 0 || nbNodes == 1) ? tmpStr = " node" : tmpStr = " nodes"; + // NB_NODES + std::cout << std::endl; + std::cout << "The initial 2D mesh contains :" << std::endl; + std::cout << " " << nbNodes << tmpStr << std::endl; + if (nbEnforcedVertices > 0) { + (nbEnforcedVertices == 1) ? tmpStr = "vertex" : tmpStr = "vertices"; + std::cout << " " << nbEnforcedVertices << " enforced " << tmpStr << std::endl; + } + if (nbEnforcedNodes > 0) { + (nbEnforcedNodes == 1) ? tmpStr = "node" : tmpStr = "nodes"; + std::cout << " " << nbEnforcedNodes << " enforced " << tmpStr << std::endl; + } + std::cout << std::endl; + std::cout << "Start writing in 'points' file ..." << std::endl; + + theFile << nbNodes << std::endl; + + // Loop from 1 to NB_NODES + + while ( nodeIt->more() ) + { + node = nodeIt->next(); + if ( isQuadMesh && theHelper.IsMedium( node )) // Issue 0021238 + continue; + if ( n2nDegen.count( node ) ) // Issue 0020674 + continue; + + theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID )); + theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node )); + aGhs3dID++; + + // X Y Z DUMMY_INT + theFile + << node->X() << space + << node->Y() << space + << node->Z() << space + << dummyint; + + theFile << std::endl; + + } + + // Iterate over the enforced nodes + std::map enfVertexIndexSizeMap; + if (nbEnforcedNodes) { + GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator nodeIt = theEnforcedNodes.begin(); + for( ; nodeIt != theEnforcedNodes.end() ; ++nodeIt) { + double x = nodeIt->first->X(); + double y = nodeIt->first->Y(); + double z = nodeIt->first->Z(); + // Test if point is inside shape to mesh + gp_Pnt myPoint(x,y,z); + BRepClass3d_SolidClassifier scl(shapeToMesh); + scl.Perform(myPoint, 1e-7); + TopAbs_State result = scl.State(); + if ( result != TopAbs_IN ) + continue; + std::vector coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + if (theEnforcedVertices.find(coords) != theEnforcedVertices.end()) + continue; + + double size = theNodeIDToSizeMap.find(nodeIt->first->GetID())->second; + // theGhs3dIdToNodeMap.insert( make_pair( nbNodes + i, (*nodeIt) )); + // MESSAGE("Adding enforced node (" << x << "," << y <<"," << z << ")"); + // X Y Z PHY_SIZE DUMMY_INT + theFile + << x << space + << y << space + << z << space + << size << space + << dummyint << space; + theFile << std::endl; + theEnforcedNodeIdToGhs3dIdMap.insert( make_pair( nodeIt->first->GetID(), aGhs3dID )); + enfVertexIndexSizeMap[aGhs3dID] = -1; + aGhs3dID++; + // else + // MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added "); + } + } + + if (nbEnforcedVertices) { + // Iterate over the enforced vertices + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues::const_iterator vertexIt = theEnforcedVertices.begin(); + for( ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) { + double x = vertexIt->first[0]; + double y = vertexIt->first[1]; + double z = vertexIt->first[2]; + // Test if point is inside shape to mesh + gp_Pnt myPoint(x,y,z); + BRepClass3d_SolidClassifier scl(shapeToMesh); + scl.Perform(myPoint, 1e-7); + TopAbs_State result = scl.State(); + if ( result != TopAbs_IN ) + continue; + MESSAGE("Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second); + // X Y Z PHY_SIZE DUMMY_INT + theFile + << x << space + << y << space + << z << space + << vertexIt->second << space + << dummyint << space; + theFile << std::endl; + enfVertexIndexSizeMap[aGhs3dID] = vertexIt->second; + aGhs3dID++; + } + } + + + std::cout << std::endl; + std::cout << "End writing in 'points' file." << std::endl; + + return true; +} + +//======================================================================= +//function : readResultFile +//purpose : readResultFile with geometry +//======================================================================= + +static bool readResultFile(const int fileOpen, +#ifdef WNT + const char* fileName, +#endif +#ifdef WITH_SMESH_CANCEL_COMPUTE + GHS3DPlugin_GHS3D* theAlgo, +#endif + SMESH_MesherHelper& theHelper, + TopoDS_Shape tabShape[], + double** tabBox, + const int nbShape, + map & theGhs3dIdToNodeMap, + std::map & theNodeId2NodeIndexMap, + bool toMeshHoles, + int nbEnforcedVertices, + int nbEnforcedNodes, + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges, + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles) +{ + MESSAGE("GHS3DPlugin_GHS3D::readResultFile()"); + Kernel_Utils::Localizer loc; + struct stat status; + size_t length; + + std::string tmpStr; + + char *ptr, *mapPtr; + char *tetraPtr; + char *shapePtr; + + SMESHDS_Mesh* theMeshDS = theHelper.GetMeshDS(); + + int nbElems, nbNodes, nbInputNodes; + int nbTriangle; + int ID, shapeID, ghs3dShapeID; + int IdShapeRef = 1; + int compoundID = + nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() ); + + int *tab, *tabID, *nodeID, *nodeAssigne; + double *coord; + const SMDS_MeshNode **node; + + tab = new int[3]; + nodeID = new int[4]; + coord = new double[3]; + node = new const SMDS_MeshNode*[4]; + + TopoDS_Shape aSolid; + SMDS_MeshNode * aNewNode; + map ::iterator itOnNode; + SMDS_MeshElement* aTet; +#ifdef _DEBUG_ + set shapeIDs; +#endif + + // Read the file state + fstat(fileOpen, &status); + length = status.st_size; + + // Mapping the result file into memory +#ifdef WNT + HANDLE fd = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY, + 0, (DWORD)length, NULL); + ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 ); +#else + ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0); +#endif + mapPtr = ptr; + + ptr = readMapIntLine(ptr, tab); + tetraPtr = ptr; + + nbElems = tab[0]; + nbNodes = tab[1]; + nbInputNodes = tab[2]; + + nodeAssigne = new int[ nbNodes+1 ]; + + if (nbShape > 0) + aSolid = tabShape[0]; + + // Reading the nodeId + for (int i=0; i < 4*nbElems; i++) + strtol(ptr, &ptr, 10); + + MESSAGE("nbInputNodes: "<computeCanceled()) + return false; +#endif + for (int iCoor=0; iCoor < 3; iCoor++) + coord[ iCoor ] = strtod(ptr, &ptr); + nodeAssigne[ iNode ] = 1; + if ( iNode > (nbInputNodes-(nbEnforcedVertices+nbEnforcedNodes)) ) { + // Creating SMESH nodes + // - for enforced vertices + // - for vertices of forced edges + // - for ghs3d nodes + nodeAssigne[ iNode ] = 0; + aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] ); + theGhs3dIdToNodeMap.insert(theGhs3dIdToNodeMap.end(), make_pair( iNode, aNewNode )); + } + } + + // Reading the number of triangles which corresponds to the number of sub-domains + nbTriangle = strtol(ptr, &ptr, 10); + + tabID = new int[nbTriangle]; + for (int i=0; i < nbTriangle; i++) { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(theAlgo->computeCanceled()) + return false; +#endif + tabID[i] = 0; + // find the solid corresponding to GHS3D sub-domain following + // the technique proposed in GHS3D manual in chapter + // "B.4 Subdomain (sub-region) assignment" + int nodeId1 = strtol(ptr, &ptr, 10); + int nodeId2 = strtol(ptr, &ptr, 10); + int nodeId3 = strtol(ptr, &ptr, 10); + if ( nbTriangle > 1 ) { + const SMDS_MeshNode* n1 = theGhs3dIdToNodeMap[ nodeId1 ]; + const SMDS_MeshNode* n2 = theGhs3dIdToNodeMap[ nodeId2 ]; + const SMDS_MeshNode* n3 = theGhs3dIdToNodeMap[ nodeId3 ]; + if (!n1 || !n2 || !n3) { + tabID[i] = HOLE_ID; + continue; + } + try { + OCC_CATCH_SIGNALS; +// tabID[i] = findShapeID( theHelper, n1, n2, n3, toMeshHoles ); + tabID[i] = findShapeID( *theHelper.GetMesh(), n1, n2, n3, toMeshHoles ); + // -- 0020330: Pb with ghs3d as a submesh + // check that found shape is to be meshed + if ( tabID[i] > 0 ) { + const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( tabID[i] ); + bool isToBeMeshed = false; + for ( int iS = 0; !isToBeMeshed && iS < nbShape; ++iS ) + isToBeMeshed = foundShape.IsSame( tabShape[ iS ]); + if ( !isToBeMeshed ) + tabID[i] = HOLE_ID; + } + // END -- 0020330: Pb with ghs3d as a submesh +#ifdef _DEBUG_ + std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl; +#endif + } + catch ( Standard_Failure & ex) + { +#ifdef _DEBUG_ + std::cout << i+1 << " subdomain: Exception caugt: " << ex.GetMessageString() << std::endl; +#endif + } + catch (...) { +#ifdef _DEBUG_ + std::cout << i+1 << " subdomain: unknown exception caught " << std::endl; +#endif + } + } + } + + shapePtr = ptr; + + if ( nbTriangle <= nbShape ) // no holes + toMeshHoles = true; // not avoid creating tetras in holes + + // Associating the tetrahedrons to the shapes + shapeID = compoundID; + for (int iElem = 0; iElem < nbElems; iElem++) { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(theAlgo->computeCanceled()) + return false; +#endif + for (int iNode = 0; iNode < 4; iNode++) { + ID = strtol(tetraPtr, &tetraPtr, 10); + itOnNode = theGhs3dIdToNodeMap.find(ID); + node[ iNode ] = itOnNode->second; + nodeID[ iNode ] = ID; + } + // We always run GHS3D with "to mesh holes"==TRUE but we must not create + // tetras within holes depending on hypo option, + // so we first check if aTet is inside a hole and then create it + //aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] ); + if ( nbTriangle > 1 ) { + shapeID = HOLE_ID; // negative shapeID means not to create tetras if !toMeshHoles + ghs3dShapeID = strtol(shapePtr, &shapePtr, 10) - IdShapeRef; + if ( tabID[ ghs3dShapeID ] == 0 ) { + TopAbs_State state; + aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state); + if ( toMeshHoles || state == TopAbs_IN ) + shapeID = theMeshDS->ShapeToIndex( aSolid ); + tabID[ ghs3dShapeID ] = shapeID; + } + else + shapeID = tabID[ ghs3dShapeID ]; + } + else if ( nbShape > 1 ) { + // Case where nbTriangle == 1 while nbShape == 2 encountered + // with compound of 2 boxes and "To mesh holes"==False, + // so there are no subdomains specified for each tetrahedron. + // Try to guess a solid by a node already bound to shape + shapeID = 0; + for ( int i=0; i<4 && shapeID==0; i++ ) { + if ( nodeAssigne[ nodeID[i] ] == 1 && + node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE && + node[i]->getshapeId() > 1 ) + { + shapeID = node[i]->getshapeId(); + } + } + if ( shapeID==0 ) { + aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape); + shapeID = theMeshDS->ShapeToIndex( aSolid ); + } + } + // set new nodes and tetrahedron onto the shape + for ( int i=0; i<4; i++ ) { + if ( nodeAssigne[ nodeID[i] ] == 0 ) { + if ( shapeID != HOLE_ID ) + theMeshDS->SetNodeInVolume( node[i], shapeID ); + nodeAssigne[ nodeID[i] ] = shapeID; + } + } + if ( toMeshHoles || shapeID != HOLE_ID ) { + aTet = theHelper.AddVolume( node[1], node[0], node[2], node[3], + /*id=*/0, /*force3d=*/false); + theMeshDS->SetMeshElementOnShape( aTet, shapeID ); + } +#ifdef _DEBUG_ + shapeIDs.insert( shapeID ); +#endif + } + + // Add enforced elements + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap::const_iterator elemIt; + const SMDS_MeshElement* anElem; + SMDS_ElemIteratorPtr itOnEnfElem; + map::const_iterator itOnMap; + shapeID = compoundID; + // Enforced edges + if (theEnforcedEdges.size()) { + (theEnforcedEdges.size() <= 1) ? tmpStr = " enforced edge" : " enforced edges"; + std::cout << "Add " << theEnforcedEdges.size() << tmpStr << std::endl; + std::vector< const SMDS_MeshNode* > node( 2 ); + // Iterate over the enforced edges + for(elemIt = theEnforcedEdges.begin() ; elemIt != theEnforcedEdges.end() ; ++elemIt) { + anElem = elemIt->first; + bool addElem = true; + itOnEnfElem = anElem->nodesIterator(); + for ( int j = 0; j < 2; ++j ) { + int aNodeID = itOnEnfElem->next()->GetID(); + itOnMap = theNodeId2NodeIndexMap.find(aNodeID); + if (itOnMap != theNodeId2NodeIndexMap.end()) { + itOnNode = theGhs3dIdToNodeMap.find((*itOnMap).second); + if (itOnNode != theGhs3dIdToNodeMap.end()) { + node.push_back((*itOnNode).second); +// shapeID =(*itOnNode).second->getshapeId(); + } + else + addElem = false; + } + else + addElem = false; + } + if (addElem) { + aTet = theHelper.AddEdge( node[0], node[1], 0, false); + theMeshDS->SetMeshElementOnShape( aTet, shapeID ); + } + } + } + // Enforced faces + if (theEnforcedTriangles.size()) { + (theEnforcedTriangles.size() <= 1) ? tmpStr = " enforced triangle" : " enforced triangles"; + std::cout << "Add " << theEnforcedTriangles.size() << " enforced triangles" << std::endl; + std::vector< const SMDS_MeshNode* > node( 3 ); + // Iterate over the enforced triangles + for(elemIt = theEnforcedTriangles.begin() ; elemIt != theEnforcedTriangles.end() ; ++elemIt) { + anElem = elemIt->first; + bool addElem = true; + itOnEnfElem = anElem->nodesIterator(); + for ( int j = 0; j < 3; ++j ) { + int aNodeID = itOnEnfElem->next()->GetID(); + itOnMap = theNodeId2NodeIndexMap.find(aNodeID); + if (itOnMap != theNodeId2NodeIndexMap.end()) { + itOnNode = theGhs3dIdToNodeMap.find((*itOnMap).second); + if (itOnNode != theGhs3dIdToNodeMap.end()) { + node.push_back((*itOnNode).second); +// shapeID =(*itOnNode).second->getshapeId(); + } + else + addElem = false; + } + else + addElem = false; + } + if (addElem) { + aTet = theHelper.AddFace( node[0], node[1], node[2], 0, false); + theMeshDS->SetMeshElementOnShape( aTet, shapeID ); + } + } + } + + // Remove nodes of tetras inside holes if !toMeshHoles + if ( !toMeshHoles ) { + itOnNode = theGhs3dIdToNodeMap.find( nbInputNodes ); + for ( ; itOnNode != theGhs3dIdToNodeMap.end(); ++itOnNode) { + ID = itOnNode->first; + if ( nodeAssigne[ ID ] == HOLE_ID ) + theMeshDS->RemoveFreeNode( itOnNode->second, 0 ); + } + } + + + if ( nbElems ) { + (nbElems <= 1) ? tmpStr = " tetrahedra" : " tetrahedrons"; + cout << nbElems << tmpStr << " have been associated to " << nbShape; + (nbShape <= 1) ? tmpStr = " shape" : " shapes"; + cout << tmpStr << endl; + } +#ifdef WNT + UnmapViewOfFile(mapPtr); + CloseHandle(hMapObject); + CloseHandle(fd); +#else + munmap(mapPtr, length); +#endif + close(fileOpen); + + delete [] tab; + delete [] tabID; + delete [] nodeID; + delete [] coord; + delete [] node; + delete [] nodeAssigne; + +#ifdef _DEBUG_ + shapeIDs.erase(-1); + if ( shapeIDs.size() != nbShape ) { + (shapeIDs.size() <= 1) ? tmpStr = " solid" : " solids"; + std::cout << "Only " << shapeIDs.size() << tmpStr << " of " << nbShape << " found" << std::endl; + for (int i=0; iShapeToIndex( tabShape[i] ); + if ( shapeIDs.find( shapeID ) == shapeIDs.end() ) + std::cout << " Solid #" << shapeID << " not found" << std::endl; + } + } +#endif + + return true; +} + + +//============================================================================= +/*! + *Here we are going to use the GHS3D mesher with geometry + */ +//============================================================================= + +bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, + const TopoDS_Shape& theShape) +{ + bool Ok(false); + //SMESHDS_Mesh* meshDS = theMesh.GetMeshDS(); + + // we count the number of shapes + // _nbShape = countShape( meshDS, TopAbs_SOLID ); -- 0020330: Pb with ghs3d as a submesh + _nbShape = 0; + TopExp_Explorer expBox ( theShape, TopAbs_SOLID ); + for ( ; expBox.More(); expBox.Next() ) + _nbShape++; + + // create bounding box for every shape inside the compound + + int iShape = 0; + TopoDS_Shape* tabShape; + double** tabBox; + tabShape = new TopoDS_Shape[_nbShape]; + tabBox = new double*[_nbShape]; + for (int i=0; i<_nbShape; i++) + tabBox[i] = new double[6]; + Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; + + for (expBox.ReInit(); expBox.More(); expBox.Next()) { + tabShape[iShape] = expBox.Current(); + Bnd_Box BoundingBox; + BRepBndLib::Add(expBox.Current(), BoundingBox); + BoundingBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); + tabBox[iShape][0] = Xmin; tabBox[iShape][1] = Xmax; + tabBox[iShape][2] = Ymin; tabBox[iShape][3] = Ymax; + tabBox[iShape][4] = Zmin; tabBox[iShape][5] = Zmax; + iShape++; + } + + // a unique working file name + // to avoid access to the same files by eg different users + TCollection_AsciiString aGenericName + = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str(); + + TCollection_AsciiString aResultFileName; + TCollection_AsciiString aLogFileName = aGenericName + ".log"; // log + // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2) +// TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName; +// TCollection_AsciiString aGenericNameRequired = aGenericName + "_required"; +// #ifdef _DEBUG_ +// aGMFFileName = aGenericName + ".mesh"; // GMF mesh file +// aResultFileName = aGenericName + "Vol.mesh"; // GMF mesh file +// aRequiredVerticesFileName = aGenericNameRequired + ".mesh"; // GMF required vertices mesh file +// aSolFileName = aGenericName + "_required.sol"; // GMF solution file +// #else +// aGMFFileName = aGenericName + ".meshb"; // GMF mesh file +// aResultFileName = aGenericName + "Vol.meshb"; // GMF mesh file +// aRequiredVerticesFileName = aGenericNameRequired + ".meshb"; // GMF required vertices mesh file +// aSolFileName = aGenericName + "_required.solb"; // GMF solution file +// #endif + + TCollection_AsciiString aFacesFileName, aPointsFileName, aBadResFileName, aBbResFileName; + + aFacesFileName = aGenericName + ".faces"; // in faces + aPointsFileName = aGenericName + ".points"; // in points + aResultFileName = aGenericName + ".noboite";// out points and volumes + aBadResFileName = aGenericName + ".boite"; // out bad result + aBbResFileName = aGenericName + ".bb"; // out vertex stepsize + + // ----------------- + // make input files + // ----------------- + + ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out); + ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out); + + Ok = + aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open(); + if (!Ok) { + INFOS( "Can't write into " << aFacesFileName); + return error(SMESH_Comment("Can't write into ") << aFacesFileName); + } + + std::map aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap; + std::map aGhs3dIdToNodeMap; + std::map nodeID2nodeIndexMap; + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues coordsSizeMap = GHS3DPlugin_Hypothesis::GetEnforcedVerticesCoordsSize(_hyp); + GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp); + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp); + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap enforcedTriangles = GHS3DPlugin_Hypothesis::GetEnforcedTriangles(_hyp); +// TIDSortedElemSet enforcedQuadrangles = GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(_hyp); + GHS3DPlugin_Hypothesis::TID2SizeMap nodeIDToSizeMap = GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(_hyp); + + int nbEnforcedVertices = coordsSizeMap.size(); + int nbEnforcedNodes = enforcedNodes.size(); + + std::string tmpStr; + (nbEnforcedNodes <= 1) ? tmpStr = "node" : "nodes"; + std::cout << nbEnforcedNodes << " enforced " << tmpStr << " from hypo" << std::endl; + (nbEnforcedVertices <= 1) ? tmpStr = "vertex" : "vertices"; + std::cout << nbEnforcedVertices << " enforced " << tmpStr << " from hypo" << std::endl; + + SMESH_MesherHelper helper( theMesh ); + helper.SetSubShape( theShape ); + + { + SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh )); + + // make prisms on quadrangles + if ( theMesh.NbQuadrangles() > 0 ) + { + vector components; + for (expBox.ReInit(); expBox.More(); expBox.Next()) + { + if ( _viscousLayersHyp ) + { + proxyMesh = _viscousLayersHyp->Compute( theMesh, expBox.Current() ); + if ( !proxyMesh ) + return false; + } + StdMeshers_QuadToTriaAdaptor* q2t = new StdMeshers_QuadToTriaAdaptor; + q2t->Compute( theMesh, expBox.Current(), proxyMesh.get() ); + components.push_back( SMESH_ProxyMesh::Ptr( q2t )); + } + proxyMesh.reset( new SMESH_ProxyMesh( components )); + } + // build viscous layers + else if ( _viscousLayersHyp ) + { + proxyMesh = _viscousLayersHyp->Compute( theMesh, theShape ); + if ( !proxyMesh ) + return false; + } + + Ok = (writePoints( aPointsFile, helper, + aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, aGhs3dIdToNodeMap, + nodeIDToSizeMap, + coordsSizeMap, enforcedNodes, enforcedEdges, enforcedTriangles) + && + writeFaces ( aFacesFile, *proxyMesh, theShape, + aSmdsToGhs3dIdMap, anEnforcedNodeIdToGhs3dIdMap, + enforcedEdges, enforcedTriangles )); +// Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(), +// helper, *proxyMesh, +// aNodeId2NodeIndexMap, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, +// enforcedNodes, enforcedEdges, enforcedTriangles, /*enforcedQuadrangles,*/ +// coordsSizeMap); + } + + // Write aSmdsToGhs3dIdMap to temp file + TCollection_AsciiString aSmdsToGhs3dIdMapFileName; + aSmdsToGhs3dIdMapFileName = aGenericName + ".ids"; // ids relation + ofstream aIdsFile ( aSmdsToGhs3dIdMapFileName.ToCString() , ios::out); + Ok = aIdsFile.rdbuf()->is_open(); + if (!Ok) { + INFOS( "Can't write into " << aSmdsToGhs3dIdMapFileName); + return error(SMESH_Comment("Can't write into ") << aSmdsToGhs3dIdMapFileName); + } + INFOS( "Writing ids relation into " << aSmdsToGhs3dIdMapFileName); + aIdsFile << "Smds Ghs3d" << std::endl; + map ::const_iterator myit; + for (myit=aSmdsToGhs3dIdMap.begin() ; myit != aSmdsToGhs3dIdMap.end() ; ++myit) { + aIdsFile << myit->first << " " << myit->second << std::endl; + } + + aIdsFile.close(); + aFacesFile.close(); + aPointsFile.close(); + + if ( ! Ok ) { + if ( !_keepFiles ) { +// removeFile( aGMFFileName ); +// removeFile( aRequiredVerticesFileName ); +// removeFile( aSolFileName ); + removeFile( aFacesFileName ); + removeFile( aPointsFileName ); + removeFile( aSmdsToGhs3dIdMapFileName ); + } + return error(COMPERR_BAD_INPUT_MESH); + } + removeFile( aResultFileName ); // needed for boundary recovery module usage + + // ----------------- + // run ghs3d mesher + // ----------------- + + TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() ); + cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read + cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file + // The output .mesh file does not contain yet the subdomain-info (Ghs3D 4.2) +// cmd += TCollection_AsciiString(" --in ") + aGenericName; +// cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired; +// cmd += TCollection_AsciiString(" --out ") + aResultGMFFileName; +// cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file + + std::cout << std::endl; + std::cout << "Ghs3d execution..." << std::endl; + std::cout << cmd << std::endl; + +#ifdef WITH_SMESH_CANCEL_COMPUTE + _compute_canceled = false; +#endif + + system( cmd.ToCString() ); // run + + std::cout << std::endl; + std::cout << "End of Ghs3d execution !" << std::endl; + + // -------------- + // read a result + // -------------- + + // Mapping the result file + + int fileOpen; + fileOpen = open( aResultFileName.ToCString(), O_RDONLY); + if ( fileOpen < 0 ) { + std::cout << std::endl; + std::cout << "Can't open the " << aResultFileName.ToCString() << " GHS3D output file" << std::endl; + std::cout << "Log: " << aLogFileName << std::endl; + Ok = false; + } + else { + bool toMeshHoles = + _hyp ? _hyp->GetToMeshHoles(true) : GHS3DPlugin_Hypothesis::DefaultMeshHoles(); + + helper.IsQuadraticSubMesh( theShape ); + helper.SetElementsOnShape( false ); + + Ok = readResultFile( fileOpen, +#ifdef WNT + aResultFileName.ToCString(), +#endif +#ifdef WITH_SMESH_CANCEL_COMPUTE + this, +#endif + /*theMesh, */helper, tabShape, tabBox, _nbShape, + aGhs3dIdToNodeMap, aNodeId2NodeIndexMap, + toMeshHoles, + nbEnforcedVertices, nbEnforcedNodes, + enforcedEdges, enforcedTriangles ); + +// Ok = readGMFFile( +// #ifndef GMF_HAS_SUBDOMAIN_INFO +// fileOpen, +// #endif +// aGenericName.ToCString(), theMesh, +// _nbShape, tabShape, tabBox, +// aGhs3dIdToNodeMap, toMeshHoles, +// nbEnforcedVertices, nbEnforcedNodes); + } + + + + + // --------------------- + // remove working files + // --------------------- + + if ( Ok ) + { + if ( !_keepFiles ) + removeFile( aLogFileName ); + } + else if ( OSD_File( aLogFileName ).Size() > 0 ) + { + // get problem description from the log file + _Ghs2smdsConvertor conv( aGhs3dIdToNodeMap ); + storeErrorDescription( aLogFileName, conv ); + } + else + { + // the log file is empty + removeFile( aLogFileName ); + INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" ); + error(COMPERR_ALGO_FAILED, "ghs3d: command not found" ); + } + + if ( !_keepFiles ) { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if (! Ok) + if(_compute_canceled) + removeFile( aLogFileName ); +#endif + removeFile( aFacesFileName ); + removeFile( aPointsFileName ); + removeFile( aResultFileName ); + removeFile( aBadResFileName ); + removeFile( aBbResFileName ); + removeFile( aSmdsToGhs3dIdMapFileName ); + } + std::cout << "<" << aResultFileName.ToCString() << "> GHS3D output file "; + if ( !Ok ) + std::cout << "not "; + std::cout << "treated !" << std::endl; + std::cout << std::endl; + + _nbShape = 0; // re-initializing _nbShape for the next Compute() method call + delete [] tabShape; + delete [] tabBox; + + return Ok; +} + +//============================================================================= +/*! + *Here we are going to use the GHS3D mesher w/o geometry + */ +//============================================================================= +bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, + SMESH_MesherHelper* theHelper) +{ + MESSAGE("GHS3DPlugin_GHS3D::Compute()"); + + //SMESHDS_Mesh* meshDS = theMesh.GetMeshDS(); + TopoDS_Shape theShape = theHelper->GetSubShape(); + + // a unique working file name + // to avoid access to the same files by eg different users + TCollection_AsciiString aGenericName + = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str(); + TCollection_AsciiString aGenericNameRequired = aGenericName + "_required"; + + TCollection_AsciiString aLogFileName = aGenericName + ".log"; // log + TCollection_AsciiString aResultFileName; + bool Ok; + + TCollection_AsciiString aGMFFileName, aRequiredVerticesFileName, aSolFileName; +//#ifdef _DEBUG_ + aGMFFileName = aGenericName + ".mesh"; // GMF mesh file + aResultFileName = aGenericName + "Vol.mesh"; // GMF mesh file + aRequiredVerticesFileName = aGenericNameRequired + ".mesh"; // GMF required vertices mesh file + aSolFileName = aGenericNameRequired + ".sol"; // GMF solution file +//#else +// aGMFFileName = aGenericName + ".meshb"; // GMF mesh file +// aResultFileName = aGenericName + "Vol.meshb"; // GMF mesh file +// aRequiredVerticesFileName = aGenericNameRequired + ".meshb"; // GMF required vertices mesh file +// aSolFileName = aGenericNameRequired + ".solb"; // GMF solution file +//#endif + + std::map nodeID2nodeIndexMap; + std::map, std::string> enfVerticesWithGroup; + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues coordsSizeMap; + TopoDS_Shape GeomShape; +// TopAbs_ShapeEnum GeomType; + std::vector coords; + gp_Pnt aPnt; + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* enfVertex; + + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp); + GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator enfVerIt = enfVertices.begin(); + + for ( ; enfVerIt != enfVertices.end() ; ++enfVerIt) + { + enfVertex = (*enfVerIt); +// if (enfVertex->geomEntry.empty() && enfVertex->coords.size()) { + if (enfVertex->coords.size()) { + coordsSizeMap.insert(make_pair(enfVertex->coords,enfVertex->size)); + enfVerticesWithGroup.insert(make_pair(enfVertex->coords,enfVertex->groupName)); +// MESSAGE("enfVerticesWithGroup.insert(make_pair(("<coords[0]<<","<coords[1]<<","<coords[2]<<"),\""<groupName<<"\"))"); + } + else { +// if (!enfVertex->geomEntry.empty()) { + GeomShape = entryToShape(enfVertex->geomEntry); +// GeomType = GeomShape.ShapeType(); + +// if (!enfVertex->isCompound) { +// // if (GeomType == TopAbs_VERTEX) { +// coords.clear(); +// aPnt = BRep_Tool::Pnt(TopoDS::Vertex(GeomShape)); +// coords.push_back(aPnt.X()); +// coords.push_back(aPnt.Y()); +// coords.push_back(aPnt.Z()); +// if (coordsSizeMap.find(coords) == coordsSizeMap.end()) { +// coordsSizeMap.insert(make_pair(coords,enfVertex->size)); +// enfVerticesWithGroup.insert(make_pair(coords,enfVertex->groupName)); +// } +// } +// +// // Group Management +// else { +// if (GeomType == TopAbs_COMPOUND){ + for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){ + coords.clear(); + if (it.Value().ShapeType() == TopAbs_VERTEX){ + aPnt = BRep_Tool::Pnt(TopoDS::Vertex(it.Value())); + coords.push_back(aPnt.X()); + coords.push_back(aPnt.Y()); + coords.push_back(aPnt.Z()); + if (coordsSizeMap.find(coords) == coordsSizeMap.end()) { + coordsSizeMap.insert(make_pair(coords,enfVertex->size)); + enfVerticesWithGroup.insert(make_pair(coords,enfVertex->groupName)); +// MESSAGE("enfVerticesWithGroup.insert(make_pair(("<groupName<<"\"))"); + } + } + } +// } + } + } + +// const SMDS_MeshNode* enfNode; + GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap enforcedNodes = GHS3DPlugin_Hypothesis::GetEnforcedNodes(_hyp); +// GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap::const_iterator enfNodeIt = enforcedNodes.begin(); +// for ( ; enfNodeIt != enforcedNodes.end() ; ++enfNodeIt) +// { +// enfNode = enfNodeIt->first; +// coords.clear(); +// coords.push_back(enfNode->X()); +// coords.push_back(enfNode->Y()); +// coords.push_back(enfNode->Z()); +// if (enfVerticesWithGro +// enfVerticesWithGroup.insert(make_pair(coords,enfNodeIt->second)); +// } + + + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap enforcedEdges = GHS3DPlugin_Hypothesis::GetEnforcedEdges(_hyp); + GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap enforcedTriangles = GHS3DPlugin_Hypothesis::GetEnforcedTriangles(_hyp); +// TIDSortedElemSet enforcedQuadrangles = GHS3DPlugin_Hypothesis::GetEnforcedQuadrangles(_hyp); + GHS3DPlugin_Hypothesis::TID2SizeMap nodeIDToSizeMap = GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(_hyp); + + std::string tmpStr; + + int nbEnforcedVertices = coordsSizeMap.size(); + int nbEnforcedNodes = enforcedNodes.size(); + (nbEnforcedNodes <= 1) ? tmpStr = "node" : tmpStr = "nodes"; + std::cout << nbEnforcedNodes << " enforced " << tmpStr << " from hypo" << std::endl; + (nbEnforcedVertices <= 1) ? tmpStr = "vertex" : tmpStr = "vertices"; + std::cout << nbEnforcedVertices << " enforced " << tmpStr << " from hypo" << std::endl; + + std::vector aNodeByGhs3dId, anEnforcedNodeByGhs3dId; + std::map aNodeToGhs3dIdMap; + std::vector aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId; + { + SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh )); + if ( theMesh.NbQuadrangles() > 0 ) + { + StdMeshers_QuadToTriaAdaptor* aQuad2Trias = new StdMeshers_QuadToTriaAdaptor; + aQuad2Trias->Compute( theMesh ); + proxyMesh.reset( aQuad2Trias ); + } + + Ok = writeGMFFile(aGMFFileName.ToCString(), aRequiredVerticesFileName.ToCString(), aSolFileName.ToCString(), + *proxyMesh, &theMesh, + aNodeByGhs3dId, aNodeToGhs3dIdMap, + aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId, + enforcedNodes, enforcedEdges, enforcedTriangles, + enfVerticesWithGroup, coordsSizeMap); + } + + // ----------------- + // run ghs3d mesher + // ----------------- + + TCollection_AsciiString cmd = TCollection_AsciiString((char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp, false ).c_str()); + + cmd += TCollection_AsciiString(" --in ") + aGenericName; + if ( nbEnforcedVertices + nbEnforcedNodes) + cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired; + cmd += TCollection_AsciiString(" --out ") + aResultFileName; + cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file + + std::cout << std::endl; + std::cout << "Ghs3d execution..." << std::endl; + std::cout << cmd << std::endl; + +#ifdef WITH_SMESH_CANCEL_COMPUTE + _compute_canceled = false; +#endif + + system( cmd.ToCString() ); // run + + std::cout << std::endl; + std::cout << "End of Ghs3d execution !" << std::endl; + + // -------------- + // read a result + // -------------- + GHS3DPlugin_Hypothesis::TSetStrings groupsToRemove = GHS3DPlugin_Hypothesis::GetGroupsToRemove(_hyp); + + Ok = readGMFFile(aResultFileName.ToCString(), +#ifdef WITH_SMESH_CANCEL_COMPUTE + this, +#endif + theHelper, theShape, aNodeByGhs3dId, aNodeToGhs3dIdMap, + aNodeGroupByGhs3dId, anEdgeGroupByGhs3dId, aFaceGroupByGhs3dId, + groupsToRemove); + + updateMeshGroups(theHelper->GetMesh(), groupsToRemove); + + if ( Ok ) { + GHS3DPlugin_Hypothesis* that = (GHS3DPlugin_Hypothesis*)this->_hyp; + if (that) + that->ClearGroupsToRemove(); + } + // --------------------- + // remove working files + // --------------------- + + if ( Ok ) + { + if ( !_keepFiles ) + removeFile( aLogFileName ); + } + else if ( OSD_File( aLogFileName ).Size() > 0 ) + { + // get problem description from the log file + _Ghs2smdsConvertor conv( aNodeByGhs3dId ); + storeErrorDescription( aLogFileName, conv ); + } + else { + // the log file is empty + removeFile( aLogFileName ); + INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" ); + error(COMPERR_ALGO_FAILED, "ghs3d: command not found" ); + } + + if ( !_keepFiles ) + { +#ifdef WITH_SMESH_CANCEL_COMPUTE + if (! Ok) + if(_compute_canceled) + removeFile( aLogFileName ); +#endif + removeFile( aGMFFileName ); + removeFile( aResultFileName ); + removeFile( aRequiredVerticesFileName ); + removeFile( aSolFileName ); + } + return Ok; +} + +#ifdef WITH_SMESH_CANCEL_COMPUTE +void GHS3DPlugin_GHS3D::CancelCompute() +{ + _compute_canceled = true; +#ifdef WNT +#else + TCollection_AsciiString aGenericName + = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str(); + TCollection_AsciiString cmd = + TCollection_AsciiString("ps ux | grep ") + aGenericName; + cmd += TCollection_AsciiString(" | grep -v grep | awk '{print $2}' | xargs kill -9 > /dev/null 2>&1"); + system( cmd.ToCString() ); +#endif +} +#endif + +//================================================================================ +/*! + * \brief Provide human readable text by error code reported by ghs3d + */ +//================================================================================ + +static string translateError(const int errNum) +{ + switch ( errNum ) { + case 0: + return "The surface mesh includes a face of type other than edge, " + "triangle or quadrilateral. This face type is not supported."; + case 1: + return "Not enough memory for the face table."; + case 2: + return "Not enough memory."; + case 3: + return "Not enough memory."; + case 4: + return "Face is ignored."; + case 5: + return "End of file. Some data are missing in the file."; + case 6: + return "Read error on the file. There are wrong data in the file."; + case 7: + return "the metric file is inadequate (dimension other than 3)."; + case 8: + return "the metric file is inadequate (values not per vertices)."; + case 9: + return "the metric file contains more than one field."; + case 10: + return "the number of values in the \".bb\" (metric file) is incompatible with the expected" + "value of number of mesh vertices in the \".noboite\" file."; + case 12: + return "Too many sub-domains."; + case 13: + return "the number of vertices is negative or null."; + case 14: + return "the number of faces is negative or null."; + case 15: + return "A face has a null vertex."; + case 22: + return "incompatible data."; + case 131: + return "the number of vertices is negative or null."; + case 132: + return "the number of vertices is negative or null (in the \".mesh\" file)."; + case 133: + return "the number of faces is negative or null."; + case 1000: + return "A face appears more than once in the input surface mesh."; + case 1001: + return "An edge appears more than once in the input surface mesh."; + case 1002: + return "A face has a vertex negative or null."; + case 1003: + return "NOT ENOUGH MEMORY."; + case 2000: + return "Not enough available memory."; + case 2002: + return "Some initial points cannot be inserted. The surface mesh is probably very bad " + "in terms of quality or the input list of points is wrong."; + case 2003: + return "Some vertices are too close to one another or coincident."; + case 2004: + return "Some vertices are too close to one another or coincident."; + case 2012: + return "A vertex cannot be inserted."; + case 2014: + return "There are at least two points considered as coincident."; + case 2103: + return "Some vertices are too close to one another or coincident."; + case 3000: + return "The surface mesh regeneration step has failed."; + case 3009: + return "Constrained edge cannot be enforced."; + case 3019: + return "Constrained face cannot be enforced."; + case 3029: + return "Missing faces."; + case 3100: + return "No guess to start the definition of the connected component(s)."; + case 3101: + return "The surface mesh includes at least one hole. The domain is not well defined."; + case 3102: + return "Impossible to define a component."; + case 3103: + return "The surface edge intersects another surface edge."; + case 3104: + return "The surface edge intersects the surface face."; + case 3105: + return "One boundary point lies within a surface face."; + case 3106: + return "One surface edge intersects a surface face."; + case 3107: + return "One boundary point lies within a surface edge."; + case 3108: + return "Insufficient memory ressources detected due to a bad quality surface mesh leading " + "to too many swaps."; + case 3109: + return "Edge is unique (i.e., bounds a hole in the surface)."; + case 3122: + return "Presumably, the surface mesh is not compatible with the domain being processed."; + case 3123: + return "Too many components, too many sub-domain."; + case 3209: + return "The surface mesh includes at least one hole. " + "Therefore there is no domain properly defined."; + case 3300: + return "Statistics."; + case 3400: + return "Statistics."; + case 3500: + return "Warning, it is dramatically tedious to enforce the boundary items."; + case 4000: + return "Not enough memory at this time, nevertheless, the program continues. " + "The expected mesh will be correct but not really as large as required."; + case 4002: + return "see above error code, resulting quality may be poor."; + case 4003: + return "Not enough memory at this time, nevertheless, the program continues (warning)."; + case 8000: + return "Unknown face type."; + case 8005: + case 8006: + return "End of file. Some data are missing in the file."; + case 9000: + return "A too small volume element is detected."; + case 9001: + return "There exists at least a null or negative volume element."; + case 9002: + return "There exist null or negative volume elements."; + case 9003: + return "A too small volume element is detected. A face is considered being degenerated."; + case 9100: + return "Some element is suspected to be very bad shaped or wrong."; + case 9102: + return "A too bad quality face is detected. This face is considered degenerated."; + case 9112: + return "A too bad quality face is detected. This face is degenerated."; + case 9122: + return "Presumably, the surface mesh is not compatible with the domain being processed."; + case 9999: + return "Abnormal error occured, contact hotline."; + case 23600: + return "Not enough memory for the face table."; + case 23601: + return "The algorithm cannot run further. " + "The surface mesh is probably very bad in terms of quality."; + case 23602: + return "Bad vertex number."; + } + return ""; +} + +//================================================================================ +/*! + * \brief Retrieve from a string given number of integers + */ +//================================================================================ + +static char* getIds( char* ptr, int nbIds, vector& ids ) +{ + ids.clear(); + ids.reserve( nbIds ); + while ( nbIds ) + { + while ( !isdigit( *ptr )) ++ptr; + if ( ptr[-1] == '-' ) --ptr; + ids.push_back( strtol( ptr, &ptr, 10 )); + --nbIds; + } + return ptr; +} + +//================================================================================ +/*! + * \brief Retrieve problem description form a log file + * \retval bool - always false + */ +//================================================================================ + +bool GHS3DPlugin_GHS3D::storeErrorDescription(const TCollection_AsciiString& logFile, + const _Ghs2smdsConvertor & toSmdsConvertor ) +{ +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(_compute_canceled) + return error(SMESH_Comment("interruption initiated by user")); +#endif + // open file +#ifdef WNT + int file = ::_open (logFile.ToCString(), _O_RDONLY|_O_BINARY); +#else + int file = ::open (logFile.ToCString(), O_RDONLY); +#endif + if ( file < 0 ) + return error( SMESH_Comment("See ") << logFile << " for problem description"); + + // get file size +// struct stat status; +// fstat(file, &status); +// size_t length = status.st_size; + off_t length = lseek( file, 0, SEEK_END); + lseek( file, 0, SEEK_SET); + + // read file + vector< char > buf( length ); + int nBytesRead = ::read (file, & buf[0], length); + ::close (file); + char* ptr = & buf[0]; + char* bufEnd = ptr + nBytesRead; + + SMESH_Comment errDescription; + + enum { NODE = 1, EDGE, TRIA, VOL, ID = 1 }; + + // look for errors "ERR #" + + set foundErrorStr; // to avoid reporting same error several times + set elemErrorNums; // not to report different types of errors with bad elements + while ( ++ptr < bufEnd ) + { + if ( strncmp( ptr, "ERR ", 4 ) != 0 ) + continue; + + list badElems; + vector nodeIds; + + ptr += 4; + char* errBeg = ptr; + int errNum = strtol(ptr, &ptr, 10); + switch ( errNum ) { // we treat errors enumerated in [SALOME platform 0019316] issue + case 0015: + // The face number (numfac) with vertices (f 1, f 2, f 3) has a null vertex. + ptr = getIds(ptr, NODE, nodeIds); + ptr = getIds(ptr, TRIA, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 1000: // ERR 1000 : 1 3 2 + // Face (f 1, f 2, f 3) appears more than once in the input surface mesh. + ptr = getIds(ptr, TRIA, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 1001: + // Edge (e1, e2) appears more than once in the input surface mesh + ptr = getIds(ptr, EDGE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 1002: + // Face (f 1, f 2, f 3) has a vertex negative or null + ptr = getIds(ptr, TRIA, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 2004: + // Vertex v1 and vertex v2 are too close to one another or coincident (warning). + ptr = getIds(ptr, NODE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + ptr = getIds(ptr, NODE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 2012: + // Vertex v1 cannot be inserted (warning). + ptr = getIds(ptr, NODE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 2014: + // There are at least two points whose distance is dist, i.e., considered as coincident + case 2103: // ERR 2103 : 16 WITH 3 + // Vertex v1 and vertex v2 are too close to one another or coincident (warning). + ptr = getIds(ptr, NODE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + ptr = getIds(ptr, NODE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 3009: + // Constrained edge (e1, e2) cannot be enforced (warning). + ptr = getIds(ptr, EDGE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 3019: + // Constrained face (f 1, f 2, f 3) cannot be enforced + ptr = getIds(ptr, TRIA, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 3103: // ERR 3103 : 1 2 WITH 7 3 + // The surface edge (e1, e2) intersects another surface edge (e3, e4) + ptr = getIds(ptr, EDGE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + ptr = getIds(ptr, EDGE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 3104: // ERR 3104 : 9 10 WITH 1 2 3 + // The surface edge (e1, e2) intersects the surface face (f 1, f 2, f 3) + ptr = getIds(ptr, EDGE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + ptr = getIds(ptr, TRIA, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 3105: // ERR 3105 : 8 IN 2 3 5 + // One boundary point (say p1) lies within a surface face (f 1, f 2, f 3) + ptr = getIds(ptr, NODE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + ptr = getIds(ptr, TRIA, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 3106: + // One surface edge (say e1, e2) intersects a surface face (f 1, f 2, f 3) + ptr = getIds(ptr, EDGE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + ptr = getIds(ptr, TRIA, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 3107: // ERR 3107 : 2 IN 4 1 + // One boundary point (say p1) lies within a surface edge (e1, e2) (stop). + ptr = getIds(ptr, NODE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + ptr = getIds(ptr, EDGE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 3109: // ERR 3109 : EDGE 5 6 UNIQUE + // Edge (e1, e2) is unique (i.e., bounds a hole in the surface) + ptr = getIds(ptr, EDGE, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + break; + case 9000: // ERR 9000 + // ELEMENT 261 WITH VERTICES : 7 396 -8 242 + // VOLUME : -1.11325045E+11 W.R.T. EPSILON 0. + // A too small volume element is detected. Are reported the index of the element, + // its four vertex indices, its volume and the tolerance threshold value + ptr = getIds(ptr, ID, nodeIds); + ptr = getIds(ptr, VOL, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + // even if all nodes found, volume it most probably invisible, + // add its faces to demenstrate it anyhow + { + vector faceNodes( nodeIds.begin(), --nodeIds.end() ); // 012 + badElems.push_back( toSmdsConvertor.getElement(faceNodes)); + faceNodes[2] = nodeIds[3]; // 013 + badElems.push_back( toSmdsConvertor.getElement(faceNodes)); + faceNodes[1] = nodeIds[2]; // 023 + badElems.push_back( toSmdsConvertor.getElement(faceNodes)); + faceNodes[0] = nodeIds[1]; // 123 + badElems.push_back( toSmdsConvertor.getElement(faceNodes)); + } + break; + case 9001: // ERR 9001 + // %% NUMBER OF NEGATIVE VOLUME TETS : 1 + // %% THE LARGEST NEGATIVE TET : 1.75376581E+11 + // %% NUMBER OF NULL VOLUME TETS : 0 + // There exists at least a null or negative volume element + break; + case 9002: + // There exist n null or negative volume elements + break; + case 9003: + // A too small volume element is detected + break; + case 9102: + // A too bad quality face is detected. This face is considered degenerated, + // its index, its three vertex indices together with its quality value are reported + break; // same as next + case 9112: // ERR 9112 + // FACE 2 WITH VERTICES : 4 2 5 + // SMALL INRADIUS : 0. + // A too bad quality face is detected. This face is degenerated, + // its index, its three vertex indices together with its inradius are reported + ptr = getIds(ptr, ID, nodeIds); + ptr = getIds(ptr, TRIA, nodeIds); + badElems.push_back( toSmdsConvertor.getElement(nodeIds)); + // add triangle edges as it most probably has zero area and hence invisible + { + vector edgeNodes(2); + edgeNodes[0] = nodeIds[0]; edgeNodes[1] = nodeIds[1]; // 0-1 + badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); + edgeNodes[1] = nodeIds[2]; // 0-2 + badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); + edgeNodes[0] = nodeIds[1]; // 1-2 + badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); + } + break; + } + + bool isNewError = foundErrorStr.insert( string( errBeg, ptr )).second; + if ( !isNewError ) + continue; // not to report same error several times + +// const SMDS_MeshElement* nullElem = 0; +// bool allElemsOk = ( find( badElems.begin(), badElems.end(), nullElem) == badElems.end()); + +// if ( allElemsOk && !badElems.empty() && !elemErrorNums.empty() ) { +// bool oneMoreErrorType = elemErrorNums.insert( errNum ).second; +// if ( oneMoreErrorType ) +// continue; // not to report different types of errors with bad elements +// } + + // store bad elements + //if ( allElemsOk ) { + list::iterator elem = badElems.begin(); + for ( ; elem != badElems.end(); ++elem ) + addBadInputElement( *elem ); + //} + + // make error text + string text = translateError( errNum ); + if ( errDescription.find( text ) == text.npos ) { + if ( !errDescription.empty() ) + errDescription << "\n"; + errDescription << text; + } + + } // end while + + if ( errDescription.empty() ) { // no errors found + char msgLic1[] = "connection to server failed"; + char msgLic2[] = " Dlim "; + if ( search( &buf[0], bufEnd, msgLic1, msgLic1 + strlen(msgLic1)) != bufEnd || + search( &buf[0], bufEnd, msgLic2, msgLic2 + strlen(msgLic2)) != bufEnd ) + errDescription << "Licence problems."; + else + { + char msg2[] = "SEGMENTATION FAULT"; + if ( search( &buf[0], bufEnd, msg2, msg2 + strlen(msg2)) != bufEnd ) + errDescription << "ghs3d: SEGMENTATION FAULT. "; + } + } + + if ( errDescription.empty() ) + errDescription << "See " << logFile << " for problem description"; + else + errDescription << "\nSee " << logFile << " for more information"; + + return error( errDescription ); +} + +//================================================================================ +/*! + * \brief Creates _Ghs2smdsConvertor + */ +//================================================================================ + +_Ghs2smdsConvertor::_Ghs2smdsConvertor( const map & ghs2NodeMap) + :_ghs2NodeMap( & ghs2NodeMap ), _nodeByGhsId( 0 ) +{ +} + +//================================================================================ +/*! + * \brief Creates _Ghs2smdsConvertor + */ +//================================================================================ + +_Ghs2smdsConvertor::_Ghs2smdsConvertor( const vector & nodeByGhsId) + : _ghs2NodeMap( 0 ), _nodeByGhsId( &nodeByGhsId ) +{ +} + +//================================================================================ +/*! + * \brief Return SMDS element by ids of GHS3D nodes + */ +//================================================================================ + +const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector& ghsNodes) const +{ + size_t nbNodes = ghsNodes.size(); + vector nodes( nbNodes, 0 ); + for ( size_t i = 0; i < nbNodes; ++i ) { + int ghsNode = ghsNodes[ i ]; + if ( _ghs2NodeMap ) { + map ::const_iterator in = _ghs2NodeMap->find( ghsNode); + if ( in == _ghs2NodeMap->end() ) + return 0; + nodes[ i ] = in->second; + } + else { + if ( ghsNode < 1 || ghsNode > _nodeByGhsId->size() ) + return 0; + nodes[ i ] = (*_nodeByGhsId)[ ghsNode-1 ]; + } + } + if ( nbNodes == 1 ) + return nodes[0]; + + if ( nbNodes == 2 ) { + const SMDS_MeshElement* edge= SMDS_Mesh::FindEdge( nodes[0], nodes[1] ); + if ( !edge ) + edge = new SMDS_LinearEdge( nodes[0], nodes[1] ); + return edge; + } + if ( nbNodes == 3 ) { + const SMDS_MeshElement* face = SMDS_Mesh::FindFace( nodes ); + if ( !face ) + face = new SMDS_FaceOfNodes( nodes[0], nodes[1], nodes[2] ); + return face; + } + if ( nbNodes == 4 ) + return new SMDS_VolumeOfNodes( nodes[0], nodes[1], nodes[2], nodes[3] ); + + return 0; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +bool GHS3DPlugin_GHS3D::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + int nbtri = 0, nbqua = 0; + double fullArea = 0.0; + for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face F = TopoDS::Face( exp.Current() ); + SMESH_subMesh *sm = aMesh.GetSubMesh(F); + MapShapeNbElemsItr anIt = aResMap.find(sm); + if( anIt==aResMap.end() ) { + SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); + smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED, + "Submesh can not be evaluated",this)); + return false; + } + std::vector aVec = (*anIt).second; + nbtri += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]); + nbqua += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]); + GProp_GProps G; + BRepGProp::SurfaceProperties(F,G); + double anArea = G.Mass(); + fullArea += anArea; + } + + // collect info from edges + int nb0d_e = 0, nb1d_e = 0; + bool IsQuadratic = false; + bool IsFirst = true; + TopTools_MapOfShape tmpMap; + for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + if( tmpMap.Contains(E) ) + continue; + tmpMap.Add(E); + SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current()); + MapShapeNbElemsItr anIt = aResMap.find(aSubMesh); + std::vector aVec = (*anIt).second; + nb0d_e += aVec[SMDSEntity_Node]; + nb1d_e += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]); + if(IsFirst) { + IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]); + IsFirst = false; + } + } + tmpMap.Clear(); + + double ELen = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) ); + + GProp_GProps G; + BRepGProp::VolumeProperties(aShape,G); + double aVolume = G.Mass(); + double tetrVol = 0.1179*ELen*ELen*ELen; + double CoeffQuality = 0.9; + int nbVols = int(aVolume/tetrVol/CoeffQuality); + int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2; + int nb1d_in = (int) ( nbVols*6 - nb1d_e - nb1d_f ) / 5; + std::vector aVec(SMDSEntity_Last); + for(int i=SMDSEntity_Node; i dummyNodeVector; + std::map dummyNodeMap; + std::map, std::string> dummyEnfVertGroup; + std::vector dummyElemGroup; + std::set dummyGroupsToRemove; + + bool ok = readGMFFile(theGMFFileName, +#ifdef WITH_SMESH_CANCEL_COMPUTE + this, +#endif + helper, theMesh.GetShapeToMesh(), dummyNodeVector, dummyNodeMap, dummyElemGroup, dummyElemGroup, dummyElemGroup, dummyGroupsToRemove); + theMesh.GetMeshDS()->Modified(); + return ok; +} diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx new file mode 100644 index 0000000..7b9b02e --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D.hxx @@ -0,0 +1,116 @@ +// Copyright (C) 2004-2012 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 : GHS3DPlugin_GHS3D.hxx +// Author : Edward AGAPOV, modified by Lioka RAZAFINDRAZAKA (CEA) 09/02/2007 +// Project : SALOME +//============================================================================= +// +#ifndef _GHS3DPlugin_GHS3D_HXX_ +#define _GHS3DPlugin_GHS3D_HXX_ + +#include "SMESH_3D_Algo.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_Gen_i.hxx" + +#include +#include + +extern "C" +{ + #include "libmesh5.h" +} + +#ifndef GMFVERSION +#define GMFVERSION GmfDouble +#endif +#define GMFDIMENSION 3 + +class GHS3DPlugin_Hypothesis; +class SMDS_MeshNode; +class SMESH_Mesh; +class StdMeshers_ViscousLayers; +class TCollection_AsciiString; +class _Ghs2smdsConvertor; +class TopoDS_Shape; + +class GHS3DPlugin_GHS3D: public SMESH_3D_Algo +{ +public: + GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~GHS3DPlugin_GHS3D(); + + virtual bool CheckHypothesis(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + Hypothesis_Status& aStatus); + + virtual bool Compute(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape); + +#ifdef WITH_SMESH_CANCEL_COMPUTE + virtual void CancelCompute(); + bool computeCanceled() { return _compute_canceled;}; +#endif + + virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap); + + virtual bool Compute(SMESH_Mesh& theMesh, + SMESH_MesherHelper* aHelper); + + bool importGMFMesh(const char* aGMFFileName, SMESH_Mesh& aMesh); + +private: + + bool storeErrorDescription(const TCollection_AsciiString& logFile, + const _Ghs2smdsConvertor & toSmdsConvertor ); + TopoDS_Shape entryToShape(std::string entry); + + int _iShape; + int _nbShape; + bool _keepFiles; + const GHS3DPlugin_Hypothesis* _hyp; + const StdMeshers_ViscousLayers* _viscousLayersHyp; + SALOMEDS::Study_var myStudy; + SMESH_Gen_i* smeshGen_i; + +#ifdef WITH_SMESH_CANCEL_COMPUTE + volatile bool _compute_canceled; +#endif + +}; + +/*! + * \brief Convertor of GHS3D elements to SMDS ones + */ +class _Ghs2smdsConvertor +{ + const std::map * _ghs2NodeMap; + const std::vector * _nodeByGhsId; + +public: + _Ghs2smdsConvertor( const std::map & ghs2NodeMap); + + _Ghs2smdsConvertor( const std::vector & nodeByGhsId); + + const SMDS_MeshElement* getElement(const std::vector& ghsNodes) const; +}; + +#endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx new file mode 100644 index 0000000..a9151b6 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.cxx @@ -0,0 +1,116 @@ +// Copyright (C) 2004-2012 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 +// + +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// File : GHS3DPlugin_GHS3D_i.cxx +// Author : Edward AGAPOV +// Module : GHS3DPlugin +// $Header$ +// +#include "GHS3DPlugin_GHS3D_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_Mesh_i.hxx" +#include "SMESH_Gen_i.hxx" +#include "GHS3DPlugin_GHS3D.hxx" +#include "SMESH_PythonDump.hxx" + +#include "utilities.h" +#include + +//============================================================================= +/*! + * GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i + * + * Constructor + */ +//============================================================================= + +GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_3D_Algo_i( thePOA ) +{ + MESSAGE( "GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i" ); + myBaseImpl = new ::GHS3DPlugin_GHS3D (theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i + * + * Destructor + */ +//============================================================================= + +GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i() +{ + MESSAGE( "GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i" ); +} + +//============================================================================= +/*! + * GHS3DPlugin_GHS3D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::GHS3DPlugin_GHS3D* GHS3DPlugin_GHS3D_i::GetImpl() +{ + MESSAGE( "GHS3DPlugin_GHS3D_i::GetImpl" ); + return ( ::GHS3DPlugin_GHS3D* )myBaseImpl; +} + +//============================================================================= +/*! + * GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i + * + * Destructor + */ +//============================================================================= + +SMESH::SMESH_Mesh_ptr GHS3DPlugin_GHS3D_i::importGMFMesh(const char* theGMFFileName) +{ + MESSAGE( "GHS3DPlugin_GHS3D_i::importGMFMesh" ); + SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen(); + SMESH::SMESH_Mesh_ptr theMesh = smeshGen->CreateEmptyMesh(); + smeshGen->RemoveLastFromPythonScript(smeshGen->GetCurrentStudy()->StudyId()); + SALOMEDS::SObject_ptr theSMesh = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(), theMesh); +#ifdef WINNT +#define SEP '\\' +#else +#define SEP '/' +#endif + string strFileName (theGMFFileName); + strFileName = strFileName.substr(strFileName.rfind(SEP)+1); + strFileName.erase(strFileName.rfind('.')); + smeshGen->SetName(theSMesh, strFileName.c_str()); + SMESH_Mesh_i* meshServant = dynamic_cast( smeshGen->GetServant( theMesh ).in() ); + ASSERT( meshServant ); + if ( meshServant ) { + if (GetImpl()->importGMFMesh(theGMFFileName, meshServant->GetImpl())) + SMESH::TPythonDump() << theSMesh << " = " << _this() << ".importGMFMesh( \"" << theGMFFileName << "\")"; + } + return theMesh; +} diff --git a/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.hxx b/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.hxx new file mode 100644 index 0000000..daea628 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_GHS3D_i.hxx @@ -0,0 +1,56 @@ +// Copyright (C) 2004-2012 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 : GHS3DPlugin_GHS3D_i.hxx +// Author : Edward AGAPOV +// Module : GHS3DPlugin +// $Header$ +// +#ifndef _GHS3DPlugin_GHS3D_I_HXX_ +#define _GHS3DPlugin_GHS3D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) +#include CORBA_SERVER_HEADER(SALOME_Exception) + +#include "SMESH_3D_Algo_i.hxx" +#include "GHS3DPlugin_GHS3D.hxx" + +// ====================================================== +// GHS3D 3d algorithm +// ====================================================== +class GHS3DPlugin_GHS3D_i: + public virtual POA_GHS3DPlugin::GHS3DPlugin_GHS3D, + public virtual SMESH_3D_Algo_i +{ +public: + // Constructor + GHS3DPlugin_GHS3D_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~GHS3DPlugin_GHS3D_i(); + + // Get implementation + ::GHS3DPlugin_GHS3D* GetImpl(); + + virtual SMESH::SMESH_Mesh_ptr importGMFMesh(const char* theGMFFileName); +}; + +#endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx new file mode 100644 index 0000000..7aa5341 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -0,0 +1,1356 @@ +// Copyright (C) 2004-2012 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 : GHS3DPlugin_Hypothesis.cxx +// Created : Wed Apr 2 12:36:29 2008 +// Author : Edward AGAPOV (eap) +//============================================================================= +// +#include "GHS3DPlugin_Hypothesis.hxx" +#include +#include +#include + +#include + +#ifdef WNT +#include +#define getpid _getpid +#endif + +//======================================================================= +//function : GHS3DPlugin_Hypothesis +//======================================================================= + +GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen) + : SMESH_Hypothesis(hypId, studyId, gen), + myToMeshHoles(DefaultMeshHoles()), + myMaximumMemory(-1), + myInitialMemory(-1), + myOptimizationLevel(DefaultOptimizationLevel()), + myWorkingDirectory(DefaultWorkingDirectory()), + myKeepFiles(DefaultKeepFiles()), + myVerboseLevel(DefaultVerboseLevel()), + myToCreateNewNodes(DefaultToCreateNewNodes()), + myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()), + myToUseFemCorrection(DefaultToUseFEMCorrection()), + myToRemoveCentralPoint(DefaultToRemoveCentralPoint()), + _enfVertexList(DefaultGHS3DEnforcedVertexList()), + _enfVertexCoordsSizeList(DefaultGHS3DEnforcedVertexCoordsValues()), + _enfVertexEntrySizeList(DefaultGHS3DEnforcedVertexEntryValues()), + _coordsEnfVertexMap(DefaultCoordsGHS3DEnforcedVertexMap()), + _geomEntryEnfVertexMap(DefaultGeomEntryGHS3DEnforcedVertexMap()), + _enfMeshList(DefaultGHS3DEnforcedMeshList()), + _entryEnfMeshMap(DefaultEntryGHS3DEnforcedMeshListMap()), + _enfNodes(TIDSortedNodeGroupMap()), + _enfEdges(TIDSortedElemGroupMap()), + _enfTriangles(TIDSortedElemGroupMap()), + _nodeIDToSizeMap(DefaultID2SizeMap()), + _elementIDToSizeMap(DefaultID2SizeMap()), + _groupsToRemove(DefaultGroupsToRemove()) +{ + _name = "GHS3D_Parameters"; + _param_algo_dim = 3; +} + +//======================================================================= +//function : SetToMeshHoles +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetToMeshHoles(bool toMesh) +{ + if ( myToMeshHoles != toMesh ) { + myToMeshHoles = toMesh; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetToMeshHoles +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetToMeshHoles(bool checkFreeOption) const +{ + if (checkFreeOption && !myTextOption.empty()) { + if ( myTextOption.find("-c 0")) + return true; + if ( myTextOption.find("-c 1")) + return false; + } + return myToMeshHoles; +} + +//======================================================================= +//function : SetMaximumMemory +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetMaximumMemory(short MB) +{ + if ( myMaximumMemory != MB ) { + myMaximumMemory = MB; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetMaximumMemory +// * automatic memory adjustment mode. Default is zero +//======================================================================= + +short GHS3DPlugin_Hypothesis::GetMaximumMemory() const +{ + return myMaximumMemory; +} + +//======================================================================= +//function : SetInitialMemory +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetInitialMemory(short MB) +{ + if ( myInitialMemory != MB ) { + myInitialMemory = MB; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetInitialMemory +//======================================================================= + +short GHS3DPlugin_Hypothesis::GetInitialMemory() const +{ + return myInitialMemory; +} + +//======================================================================= +//function : SetOptimizationLevel +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetOptimizationLevel(OptimizationLevel level) +{ + if ( myOptimizationLevel != level ) { + myOptimizationLevel = level; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetOptimizationLevel +//======================================================================= + +GHS3DPlugin_Hypothesis::OptimizationLevel GHS3DPlugin_Hypothesis::GetOptimizationLevel() const +{ + return (OptimizationLevel) myOptimizationLevel; +} + +//======================================================================= +//function : SetWorkingDirectory +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetWorkingDirectory(const std::string& path) +{ + if ( myWorkingDirectory != path ) { + myWorkingDirectory = path; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetWorkingDirectory +//======================================================================= + +std::string GHS3DPlugin_Hypothesis::GetWorkingDirectory() const +{ + return myWorkingDirectory; +} + +//======================================================================= +//function : SetKeepFiles +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetKeepFiles(bool toKeep) +{ + if ( myKeepFiles != toKeep ) { + myKeepFiles = toKeep; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetKeepFiles +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetKeepFiles() const +{ + return myKeepFiles; +} + +//======================================================================= +//function : SetVerboseLevel +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetVerboseLevel(short level) +{ + if ( myVerboseLevel != level ) { + myVerboseLevel = level; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetVerboseLevel +//======================================================================= + +short GHS3DPlugin_Hypothesis::GetVerboseLevel() const +{ + return myVerboseLevel; +} + +//======================================================================= +//function : SetToCreateNewNodes +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetToCreateNewNodes(bool toCreate) +{ + if ( myToCreateNewNodes != toCreate ) { + myToCreateNewNodes = toCreate; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetToCreateNewNodes +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetToCreateNewNodes() const +{ + return myToCreateNewNodes; +} + +//======================================================================= +//function : SetToUseBoundaryRecoveryVersion +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetToUseBoundaryRecoveryVersion(bool toUse) +{ + if ( myToUseBoundaryRecoveryVersion != toUse ) { + myToUseBoundaryRecoveryVersion = toUse; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetToUseBoundaryRecoveryVersion +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetToUseBoundaryRecoveryVersion() const +{ + return myToUseBoundaryRecoveryVersion; +} + +//======================================================================= +//function : SetFEMCorrection +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetFEMCorrection(bool toUseFem) +{ + if ( myToUseFemCorrection != toUseFem ) { + myToUseFemCorrection = toUseFem; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetFEMCorrection +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetFEMCorrection() const +{ + return myToUseFemCorrection; +} + +//======================================================================= +//function : SetToRemoveCentralPoint +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetToRemoveCentralPoint(bool toRemove) +{ + if ( myToRemoveCentralPoint != toRemove ) { + myToRemoveCentralPoint = toRemove; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetToRemoveCentralPoint +//======================================================================= + +bool GHS3DPlugin_Hypothesis::GetToRemoveCentralPoint() const +{ + return myToRemoveCentralPoint; +} + +//======================================================================= +//function : SetTextOption +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetTextOption(const std::string& option) +{ + if ( myTextOption != option ) { + myTextOption = option; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetTextOption +//======================================================================= + +std::string GHS3DPlugin_Hypothesis::GetTextOption() const +{ + return myTextOption; +} + +//======================================================================= +//function : SetEnforcedVertex +//======================================================================= + +bool GHS3DPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string theEntry, std::string theGroupName, + double size, double x, double y, double z, bool isCompound) +{ + MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedVertex(\""<< theName << "\", \""<< theEntry << "\", \"" << theGroupName << "\", " + << size << ", " << x << ", " << y << ", " << z << ", "<< isCompound << ")"); + + bool toNotify = false; + bool toCreate = true; + + TGHS3DEnforcedVertex *oldEnVertex; + TGHS3DEnforcedVertex *newEnfVertex = new TGHS3DEnforcedVertex(); + newEnfVertex->name = theName; + newEnfVertex->geomEntry = theEntry; + newEnfVertex->coords.clear(); + if (!isCompound) { + newEnfVertex->coords.push_back(x); + newEnfVertex->coords.push_back(y); + newEnfVertex->coords.push_back(z); + } + newEnfVertex->groupName = theGroupName; + newEnfVertex->size = size; + newEnfVertex->isCompound = isCompound; + + + // update _enfVertexList + TGHS3DEnforcedVertexList::iterator it = _enfVertexList.find(newEnfVertex); + if (it != _enfVertexList.end()) { + toCreate = false; + oldEnVertex = (*it); + MESSAGE("Enforced Vertex was found => Update"); + if (oldEnVertex->name != theName) { + MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theName << "\""); + oldEnVertex->name = theName; + toNotify = true; + } + if (oldEnVertex->groupName != theGroupName) { + MESSAGE("Update group name from \"" << oldEnVertex->groupName << "\" to \"" << theGroupName << "\""); + oldEnVertex->groupName = theGroupName; + toNotify = true; + } + if (oldEnVertex->size != size) { + MESSAGE("Update size from \"" << oldEnVertex->size << "\" to \"" << size << "\""); + oldEnVertex->size = size; + toNotify = true; + } + if (toNotify) { + // update map coords / enf vertex if needed + if (oldEnVertex->coords.size()) { + _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex; + _enfVertexCoordsSizeList[oldEnVertex->coords] = size; + } + + // update map geom entry / enf vertex if needed + if (oldEnVertex->geomEntry != "") { + _geomEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex; + _enfVertexEntrySizeList[oldEnVertex->geomEntry] = size; + } + } + } + +// //////// CREATE //////////// + if (toCreate) { + toNotify = true; + MESSAGE("Creating new enforced vertex"); + _enfVertexList.insert(newEnfVertex); + if (theEntry == "") { + _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex; + _enfVertexCoordsSizeList[newEnfVertex->coords] = size; + } + else { + _geomEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex; + _enfVertexEntrySizeList[newEnfVertex->geomEntry] = size; + } + } + + if (toNotify) + NotifySubMeshesHypothesisModification(); + + MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedVertex END"); + return toNotify; +} + + +//======================================================================= +//function : SetEnforcedMesh +//======================================================================= +bool GHS3DPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, double size, std::string groupName) +{ + TIDSortedElemSet theElemSet; + SMDS_ElemIteratorPtr eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType)); + while ( eIt->more() ) + theElemSet.insert( eIt->next() ); + MESSAGE("Add "<name = name; + newEnfMesh->entry = entry; + newEnfMesh->elementType = elementType; + newEnfMesh->size = size; + newEnfMesh->groupName = groupName; + + TGHS3DEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh); + if (it == _enfMeshList.end()) { + _entryEnfMeshMap[entry].insert(newEnfMesh); + _enfMeshList.insert(newEnfMesh); + } + } + return added; +} + +//======================================================================= +//function : SetEnforcedGroup +//======================================================================= +bool GHS3DPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, double size, std::string groupName) +{ + MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedGroup"); + TIDSortedElemSet theElemSet; + if ( theIDs->length() == 0 ){MESSAGE("The source group is empty");} + for (int i=0; i < theIDs->length(); i++) { + CORBA::Long ind = theIDs[i]; + if (elementType == SMESH::NODE) + { + const SMDS_MeshNode * node = theMeshDS->FindNode(ind); + if (node) + theElemSet.insert( node ); + } + else + { + const SMDS_MeshElement * elem = theMeshDS->FindElement(ind); + if (elem) + theElemSet.insert( elem ); + } + } + +// SMDS_ElemIteratorPtr it = theGroup->GetGroupDS()->GetElements(); +// while ( it->more() ) +// theElemSet.insert( it->next() ); + + MESSAGE("Add "<name = name; + newEnfMesh->entry = entry; + newEnfMesh->elementType = elementType; + newEnfMesh->size = size; + newEnfMesh->groupName = groupName; + + TGHS3DEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh); + if (it == _enfMeshList.end()) { + _entryEnfMeshMap[entry].insert(newEnfMesh); + _enfMeshList.insert(newEnfMesh); + } + } + return added; +} + +//======================================================================= +//function : SetEnforcedElements +//======================================================================= +bool GHS3DPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size, std::string groupName) +{ + MESSAGE("GHS3DPlugin_Hypothesis::SetEnforcedElements"); + TIDSortedElemSet::const_iterator it = theElemSet.begin(); + const SMDS_MeshElement* elem; + const SMDS_MeshNode* node; + bool added = false; + for (;it != theElemSet.end();++it) + { + elem = (*it); + switch (elementType) { + case SMESH::NODE: + node = dynamic_cast(elem); + if (node) { + _enfNodes.insert(make_pair(node,groupName)); + _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); + added = true; + } + else { + SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); + for (;nodeIt->more();) { + node = dynamic_cast(nodeIt->next()); + _enfNodes.insert(make_pair(node,groupName)); + _nodeIDToSizeMap.insert(make_pair(node->GetID(), size)); + } + added = true; + } + break; + case SMESH::EDGE: + if (elem->GetType() == SMDSAbs_Edge) { + _enfEdges.insert(make_pair(elem,groupName)); + _elementIDToSizeMap.insert(make_pair(elem->GetID(), size)); + added = true; + } + else if (elem->GetType() > SMDSAbs_Edge) { + SMDS_ElemIteratorPtr it = elem->edgesIterator(); + for (;it->more();) { + const SMDS_MeshElement* anEdge = it->next(); + _enfEdges.insert(make_pair(anEdge,groupName)); + _elementIDToSizeMap.insert(make_pair(anEdge->GetID(), size)); + } + added = true; + } + break; + case SMESH::FACE: + if (elem->GetType() == SMDSAbs_Face) + { + if (elem->NbCornerNodes() == 3) { + _enfTriangles.insert(make_pair(elem,groupName)); + _elementIDToSizeMap.insert(make_pair(elem->GetID(), size)); + added = true; + } + } + else if (elem->GetType() > SMDSAbs_Face) { // Group of faces + SMDS_ElemIteratorPtr it = elem->facesIterator(); + for (;it->more();) { + const SMDS_MeshElement* aFace = it->next(); + if (aFace->NbCornerNodes() == 3) { + _enfTriangles.insert(make_pair(aFace,groupName)); + _elementIDToSizeMap.insert(make_pair(aFace->GetID(), size)); + added = true; + } + } + } + break; + default: + break; + }; + } + if (added) + NotifySubMeshesHypothesisModification(); + return added; +} + + +//======================================================================= +//function : GetEnforcedVertex +//======================================================================= + +GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* GHS3DPlugin_Hypothesis::GetEnforcedVertex(double x, double y, double z) + throw (std::invalid_argument) +{ + std::vector coord(3); + coord[0] = x; + coord[1] = y; + coord[2] = z; + if (_coordsEnfVertexMap.count(coord)>0) + return _coordsEnfVertexMap[coord]; + std::ostringstream msg ; + msg << "No enforced vertex at " << x << ", " << y << ", " << z; + throw std::invalid_argument(msg.str()); +} + +GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* GHS3DPlugin_Hypothesis::GetEnforcedVertex(const std::string theEntry) + throw (std::invalid_argument) +{ + if (_geomEntryEnfVertexMap.count(theEntry)>0) + return _geomEntryEnfVertexMap[theEntry]; + + std::ostringstream msg ; + msg << "No enforced vertex with entry " << theEntry; + throw std::invalid_argument(msg.str()); +} + +//======================================================================= +//function : RemoveEnforcedVertex +//======================================================================= + +bool GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z, const std::string theEntry) + throw (std::invalid_argument) +{ + bool toNotify = false; + std::ostringstream msg; + TGHS3DEnforcedVertex *oldEnfVertex; + std::vector coords(3); + coords[0] = x; + coords[1] = y; + coords[2] = z; + + // check that enf vertex with given enf vertex entry exists + TGeomEntryGHS3DEnforcedVertexMap::iterator it_enfVertexEntry = _geomEntryEnfVertexMap.find(theEntry); + if (it_enfVertexEntry != _geomEntryEnfVertexMap.end()) { + // Success + MESSAGE("Found enforced vertex with geom entry " << theEntry); + oldEnfVertex = it_enfVertexEntry->second; + _geomEntryEnfVertexMap.erase(it_enfVertexEntry); + } else { + // Fail + MESSAGE("Enforced vertex with geom entry " << theEntry << " not found"); + // check that enf vertex with given coords exists + TCoordsGHS3DEnforcedVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords); + if (it_coords_enf != _coordsEnfVertexMap.end()) { + // Success + MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z); + oldEnfVertex = it_coords_enf->second; + _coordsEnfVertexMap.erase(it_coords_enf); + _enfVertexCoordsSizeList.erase(_enfVertexCoordsSizeList.find(coords)); + } else { + // Fail + MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found"); + throw std::invalid_argument(msg.str()); + } + } + + MESSAGE("Remove enf vertex from _enfVertexList"); + + // update _enfVertexList + TGHS3DEnforcedVertexList::iterator it = _enfVertexList.find(oldEnfVertex); + if (it != _enfVertexList.end()) { + if ((*it)->groupName != "") + _groupsToRemove.insert((*it)->groupName); + _enfVertexList.erase(it); + toNotify = true; + MESSAGE("Done"); + } + + if (toNotify) + NotifySubMeshesHypothesisModification(); + + return toNotify; +} + +//======================================================================= +//function : ClearEnforcedVertices +//======================================================================= +void GHS3DPlugin_Hypothesis::ClearEnforcedVertices() +{ + TGHS3DEnforcedVertexList::const_iterator it = _enfVertexList.begin(); + for(;it != _enfVertexList.end();++it) { + if ((*it)->groupName != "") + _groupsToRemove.insert((*it)->groupName); + } + _enfVertexList.clear(); + _coordsEnfVertexMap.clear(); + _geomEntryEnfVertexMap.clear(); + _enfVertexCoordsSizeList.clear(); + _enfVertexEntrySizeList.clear(); + NotifySubMeshesHypothesisModification(); +} + +//======================================================================= +//function : ClearEnforcedMeshes +//======================================================================= +void GHS3DPlugin_Hypothesis::ClearEnforcedMeshes() +{ + TGHS3DEnforcedMeshList::const_iterator it = _enfMeshList.begin(); + for(;it != _enfMeshList.end();++it) { + if ((*it)->groupName != "") + _groupsToRemove.insert((*it)->groupName); + } + _enfNodes.clear(); + _enfEdges.clear(); + _enfTriangles.clear(); + _nodeIDToSizeMap.clear(); + _elementIDToSizeMap.clear(); + _enfMeshList.clear(); + _entryEnfMeshMap.clear(); + NotifySubMeshesHypothesisModification(); +} + + +//======================================================================= +//function : SetGroupsToRemove +//======================================================================= + +void GHS3DPlugin_Hypothesis::ClearGroupsToRemove() +{ + _groupsToRemove.clear(); +} + + +//======================================================================= +//function : DefaultMeshHoles +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultMeshHoles() +{ + return false; // PAL19680 +} + +//======================================================================= +//function : DefaultMaximumMemory +//======================================================================= + +#ifndef WIN32 +#include +#else +#include +#endif + +short GHS3DPlugin_Hypothesis::DefaultMaximumMemory() +{ +#ifndef WIN32 + struct sysinfo si; + int err = sysinfo( &si ); + if ( err == 0 ) { + int ramMB = si.totalram * si.mem_unit / 1024 / 1024; + return (int) ( 0.7 * ramMB ); + } +#else + // See http://msdn.microsoft.com/en-us/library/aa366589.aspx + MEMORYSTATUSEX statex; + statex.dwLength = sizeof (statex); + int err = GlobalMemoryStatusEx (&statex); + if (err != 0) { + int totMB = + statex.ullTotalPhys / 1024 / 1024 + + statex.ullTotalPageFile / 1024 / 1024 + + statex.ullTotalVirtual / 1024 / 1024; + return (int) ( 0.7 * totMB ); + } +#endif + return 1024; +} + +//======================================================================= +//function : DefaultInitialMemory +//======================================================================= + +short GHS3DPlugin_Hypothesis::DefaultInitialMemory() +{ + return DefaultMaximumMemory(); +} + +//======================================================================= +//function : DefaultOptimizationLevel +//======================================================================= + +short GHS3DPlugin_Hypothesis::DefaultOptimizationLevel() +{ + return Medium; +} + +//======================================================================= +//function : DefaultWorkingDirectory +//======================================================================= + +std::string GHS3DPlugin_Hypothesis::DefaultWorkingDirectory() +{ + TCollection_AsciiString aTmpDir; + + char *Tmp_dir = getenv("SALOME_TMP_DIR"); + if(Tmp_dir != NULL) { + aTmpDir = Tmp_dir; + } + else { +#ifdef WIN32 + aTmpDir = TCollection_AsciiString("C:\\"); +#else + aTmpDir = TCollection_AsciiString("/tmp/"); +#endif + } + return aTmpDir.ToCString(); +} + +//======================================================================= +//function : DefaultKeepFiles +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultKeepFiles() +{ + return false; +} + +//======================================================================= +//function : DefaultVerboseLevel +//======================================================================= + +short GHS3DPlugin_Hypothesis::DefaultVerboseLevel() +{ + return 10; +} + +//======================================================================= +//function : DefaultToCreateNewNodes +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultToCreateNewNodes() +{ + return true; +} + +//======================================================================= +//function : DefaultToUseBoundaryRecoveryVersion +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultToUseBoundaryRecoveryVersion() +{ + return false; +} + +//======================================================================= +//function : DefaultToUseFEMCorrection +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultToUseFEMCorrection() +{ + return false; +} + +//======================================================================= +//function : DefaultToRemoveCentralPoint +//======================================================================= + +bool GHS3DPlugin_Hypothesis::DefaultToRemoveCentralPoint() +{ + return false; +} + +// //======================================================================= +// //function : DefaultID2SizeMap +// //======================================================================= +// +// GHS3DPlugin_Hypothesis::TID2SizeMap GHS3DPlugin_Hypothesis::DefaultID2SizeMap() +// { +// return GHS3DPlugin_Hypothesis::TID2SizeMap(); +// } + + +//======================================================================= +//function : SaveTo +//======================================================================= + +std::ostream & GHS3DPlugin_Hypothesis::SaveTo(std::ostream & save) +{ + save << (int) myToMeshHoles << " "; + save << myMaximumMemory << " "; + save << myInitialMemory << " "; + save << myOptimizationLevel << " "; + save << myWorkingDirectory << " "; + save << (int)myKeepFiles << " "; + save << myVerboseLevel << " "; + save << (int)myToCreateNewNodes << " "; + save << (int)myToUseBoundaryRecoveryVersion << " "; + save << (int)myToUseFemCorrection << " "; + save << (int)myToRemoveCentralPoint << " "; + if (!myTextOption.empty()) { + save << "__OPTIONS_BEGIN__ "; + save << myTextOption << " "; + save << "__OPTIONS_END__ "; + } + + + TGHS3DEnforcedVertexList::iterator it = _enfVertexList.begin(); + if (it != _enfVertexList.end()) { + save << "__ENFORCED_VERTICES_BEGIN__ "; + for ( ; it != _enfVertexList.end(); ++it ) { + TGHS3DEnforcedVertex *enfVertex = (*it); + save << " " << "__BEGIN_VERTEX__"; + if (!enfVertex->name.empty()) { + save << " " << "__BEGIN_NAME__"; + save << " " << enfVertex->name; + save << " " << "__END_NAME__"; + } + if (!enfVertex->geomEntry.empty()) { + save << " " << "__BEGIN_ENTRY__"; + save << " " << enfVertex->geomEntry; + save << " " << enfVertex->isCompound; + save << " " << "__END_ENTRY__"; + } + if (!enfVertex->groupName.empty()) { + save << " " << "__BEGIN_GROUP__"; + save << " " << enfVertex->groupName; + save << " " << "__END_GROUP__"; + } + if (enfVertex->coords.size()) { + save << " " << "__BEGIN_COORDS__"; + for (int i=0;icoords.size();i++) + save << " " << enfVertex->coords[i]; + save << " " << "__END_COORDS__"; + } + save << " " << "__BEGIN_SIZE__"; + save << " " << enfVertex->size; + save << " " << "__END_SIZE__"; + save << " " << "__END_VERTEX__"; + } + save << "__ENFORCED_VERTICES_END__ "; + } + + return save; +} + +//======================================================================= +//function : LoadFrom +//======================================================================= + +std::istream & GHS3DPlugin_Hypothesis::LoadFrom(std::istream & load) +{ + bool isOK = true; + int i; + + isOK = (load >> i); + if (isOK) + myToMeshHoles = i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myMaximumMemory = i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myInitialMemory = i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myOptimizationLevel = i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> myWorkingDirectory); + if (isOK) { + if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty + myKeepFiles = false; + myWorkingDirectory.clear(); + } + else if ( myWorkingDirectory == "1" ) { + myKeepFiles = true; + myWorkingDirectory.clear(); + } + } + else + load.clear(ios::badbit | load.rdstate()); + + if ( !myWorkingDirectory.empty() ) { + isOK = (load >> i); + if (isOK) + myKeepFiles = i; + else + load.clear(ios::badbit | load.rdstate()); + } + + isOK = (load >> i); + if (isOK) + myVerboseLevel = (short) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myToCreateNewNodes = (bool) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myToUseBoundaryRecoveryVersion = (bool) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myToUseFemCorrection = (bool) i; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + myToRemoveCentralPoint = (bool) i; + else + load.clear(ios::badbit | load.rdstate()); + + std::string separator; + bool hasOptions = false; + bool hasEnforcedVertices = false; + isOK = (load >> separator); + + if (isOK) { + if (separator == "__OPTIONS_BEGIN__") + hasOptions = true; + else if (separator == "__ENFORCED_VERTICES_BEGIN__") + hasEnforcedVertices = true; + } + + if (hasOptions) { + std::string txt; + while (isOK) { + isOK = (load >> txt); + if (isOK) { + if (txt == "__OPTIONS_END__") { + if (!myTextOption.empty()) { + // Remove last space + myTextOption.erase(myTextOption.end()-1); + } + isOK = false; + break; + } + myTextOption += txt; + myTextOption += " "; + } + } + } + + if (hasOptions) { + isOK = (load >> separator); + if (isOK && separator == "__ENFORCED_VERTICES_BEGIN__") + hasEnforcedVertices = true; + } + + if (hasEnforcedVertices) { + std::string txt, name, entry, groupName; + double size, coords[3]; + bool isCompound; + bool hasCoords = false; + while (isOK) { + isOK = (load >> txt); // __BEGIN_VERTEX__ + if (isOK) { + if (txt == "__ENFORCED_VERTICES_END__") + isOK = false; + + TGHS3DEnforcedVertex *enfVertex = new TGHS3DEnforcedVertex(); + while (isOK) { + isOK = (load >> txt); + if (txt == "__END_VERTEX__") { + enfVertex->name = name; + enfVertex->geomEntry = entry; + enfVertex->isCompound = isCompound; + enfVertex->groupName = groupName; + enfVertex->coords.clear(); + if (hasCoords) + enfVertex->coords.assign(coords,coords+3); + + _enfVertexList.insert(enfVertex); + + if (enfVertex->coords.size()) + _coordsEnfVertexMap[enfVertex->coords] = enfVertex; + if (!enfVertex->geomEntry.empty()) + _geomEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex; + + name.clear(); + entry.clear(); + groupName.clear(); + hasCoords = false; + isOK = false; + } + + if (txt == "__BEGIN_NAME__") { // __BEGIN_NAME__ + while (isOK && (txt != "__END_NAME__")) { + isOK = (load >> txt); + if (txt != "__END_NAME__") { + if (!name.empty()) + name += " "; + name += txt; + } + } + MESSAGE("name: " <> entry); + isOK = (load >> isCompound); + isOK = (load >> txt); // __END_ENTRY__ + if (txt != "__END_ENTRY__") + throw std::exception(); + MESSAGE("entry: " << entry); + } + + if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__ + while (isOK && (txt != "__END_GROUP__")) { + isOK = (load >> txt); + if (txt != "__END_GROUP__") { + if (!groupName.empty()) + groupName += " "; + groupName += txt; + } + } + MESSAGE("groupName: " << groupName); + } + + if (txt == "__BEGIN_COORDS__") { // __BEGIN_COORDS__ + hasCoords = true; + isOK = (load >> coords[0] >> coords[1] >> coords[2]); + isOK = (load >> txt); // __END_COORDS__ + if (txt != "__END_COORDS__") + throw std::exception(); + MESSAGE("coords: " << coords[0] <<","<< coords[1] <<","<< coords[2]); + } + + if (txt == "__BEGIN_SIZE__") { // __BEGIN_ENTRY__ + isOK = (load >> size); + isOK = (load >> txt); // __END_ENTRY__ + if (txt != "__END_SIZE__") { + throw std::exception(); + } + MESSAGE("size: " << size); + } + } + } + } + } + + return load; +} + +//======================================================================= +//function : SetParametersByMesh +//======================================================================= + +bool GHS3DPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&) +{ + return false; +} + + +//================================================================================ +/*! + * \brief Return false + */ +//================================================================================ + +bool GHS3DPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& /*dflts*/, + const SMESH_Mesh* /*theMesh*/) +{ + return false; +} + +//================================================================================ +/*! + * \brief Return command to run ghs3d mesher excluding file prefix (-f) + */ +//================================================================================ + +std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp, + const bool hasShapeToMesh) +{ + TCollection_AsciiString cmd; + if (hasShapeToMesh) + cmd = "ghs3d-41"; // to use old mesh2 format + else + cmd = "ghs3d"; // to use new mesh format + // check if any option is overridden by hyp->myTextOption + bool m = hyp ? ( hyp->myTextOption.find("-m") == std::string::npos ) : true; + bool M = hyp ? ( hyp->myTextOption.find("-M") == std::string::npos ) : true; + bool c = hyp ? ( hyp->myTextOption.find("-c") == std::string::npos ) : true; + bool o = hyp ? ( hyp->myTextOption.find("-o") == std::string::npos ) : true; + bool p0 = hyp ? ( hyp->myTextOption.find("-p0") == std::string::npos ) : true; + bool C = hyp ? ( hyp->myTextOption.find("-C") == std::string::npos ) : true; + bool v = hyp ? ( hyp->myTextOption.find("-v") == std::string::npos ) : true; + bool fem = hyp ? ( hyp->myTextOption.find("-FEM")== std::string::npos ) : true; + bool rem = hyp ? ( hyp->myTextOption.find("-no_initial_central_point")== std::string::npos ) : true; + + // if use boundary recovery version, few options are allowed + bool useBndRecovery = !C; + if ( !useBndRecovery && hyp ) + useBndRecovery = hyp->myToUseBoundaryRecoveryVersion; + + // ghs3d needs to know amount of memory it may use (MB). + // Default memory is defined at ghs3d installation but it may be not enough, + // so allow to use about all available memory + if ( m ) { + short aMaximumMemory = hyp ? hyp->myMaximumMemory : -1; + cmd += " -m "; + if ( aMaximumMemory < 0 ) + cmd += DefaultMaximumMemory(); + else + cmd += aMaximumMemory; + } + if ( M && !useBndRecovery ) { + short aInitialMemory = hyp ? hyp->myInitialMemory : -1; + cmd += " -M "; + if ( aInitialMemory > 0 ) + cmd += aInitialMemory; + else + cmd += "100"; + } + // component to mesh + // 0 , all components to be meshed + // 1 , only the main ( outermost ) component to be meshed + if ( c && !useBndRecovery ) { + // We always run GHS3D with "to mesh holes'==TRUE (see PAL19680) + if ( hasShapeToMesh ) + cmd += " -c 0"; + else { + bool aToMeshHoles = hyp ? hyp->myToMeshHoles : DefaultMeshHoles(); + if ( aToMeshHoles ) + cmd += " -c 0"; + else + cmd += " -c 1"; + } + } + + // optimization level + if ( o && hyp && !useBndRecovery ) { + if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 5 ) { + const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" }; + cmd += " -o "; + cmd += level[ hyp->myOptimizationLevel ]; + } + } + + // to create internal nodes + if ( p0 && hyp && !hyp->myToCreateNewNodes ) { + cmd += " -p0"; + } + + // verbose mode + if ( v && hyp ) { + cmd += " -v "; + cmd += hyp->myVerboseLevel; + } + + // boundary recovery version + if ( useBndRecovery ) { + cmd += " -C"; + } + + // to use FEM correction + if ( fem && hyp && hyp->myToUseFemCorrection) { + cmd += " -FEM"; + } + + // to remove initial central point. + if ( rem && hyp && hyp->myToRemoveCentralPoint) { + cmd += " -no_initial_central_point"; + } + + // options as text + if ( hyp && !hyp->myTextOption.empty() ) { + cmd += " "; + cmd += (char*) hyp->myTextOption.c_str(); + } + +#ifdef WNT + cmd += " < NUL"; +#endif + + return cmd.ToCString(); +} + +//================================================================================ +/*! + * \brief Return a unique file name + */ +//================================================================================ + +std::string GHS3DPlugin_Hypothesis::GetFileName(const GHS3DPlugin_Hypothesis* hyp) +{ + std::string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory(); + const char lastChar = *aTmpDir.rbegin(); +#ifdef WIN32 + if(lastChar != '\\') aTmpDir+='\\'; +#else + if(lastChar != '/') aTmpDir+='/'; +#endif + + TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str(); + aGenericName += "GHS3D_"; + aGenericName += getpid(); + aGenericName += "_"; + aGenericName += Abs((Standard_Integer)(long) aGenericName.ToCString()); + + return aGenericName.ToCString(); +} + + +//================================================================================ +/*! +* \brief Return the enforced vertices +*/ +//================================================================================ + +GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList GHS3DPlugin_Hypothesis::GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetEnforcedVertices():DefaultGHS3DEnforcedVertexList(); +} + +GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexCoordsValues GHS3DPlugin_Hypothesis::GetEnforcedVerticesCoordsSize (const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetEnforcedVerticesCoordsSize(): DefaultGHS3DEnforcedVertexCoordsValues(); +} + +GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexEntryValues GHS3DPlugin_Hypothesis::GetEnforcedVerticesEntrySize (const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetEnforcedVerticesEntrySize(): DefaultGHS3DEnforcedVertexEntryValues(); +} + +GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap GHS3DPlugin_Hypothesis::GetEnforcedVerticesByCoords (const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetEnforcedVerticesByCoords(): DefaultCoordsGHS3DEnforcedVertexMap(); +} + +GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap GHS3DPlugin_Hypothesis::GetEnforcedVerticesByEntry (const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetEnforcedVerticesByEntry(): DefaultGeomEntryGHS3DEnforcedVertexMap(); +} + +GHS3DPlugin_Hypothesis::TIDSortedNodeGroupMap GHS3DPlugin_Hypothesis::GetEnforcedNodes(const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetEnforcedNodes():DefaultIDSortedNodeGroupMap(); +} + +GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap GHS3DPlugin_Hypothesis::GetEnforcedEdges(const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetEnforcedEdges():DefaultIDSortedElemGroupMap(); +} + +GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap GHS3DPlugin_Hypothesis::GetEnforcedTriangles(const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetEnforcedTriangles():DefaultIDSortedElemGroupMap(); +} + +GHS3DPlugin_Hypothesis::TID2SizeMap GHS3DPlugin_Hypothesis::GetNodeIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetNodeIDToSizeMap(): DefaultID2SizeMap(); +} + +GHS3DPlugin_Hypothesis::TID2SizeMap GHS3DPlugin_Hypothesis::GetElementIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetElementIDToSizeMap(): DefaultID2SizeMap(); +} + +GHS3DPlugin_Hypothesis::TSetStrings GHS3DPlugin_Hypothesis::GetGroupsToRemove(const GHS3DPlugin_Hypothesis* hyp) +{ + return hyp ? hyp->_GetGroupsToRemove(): DefaultGroupsToRemove(); +} diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx new file mode 100644 index 0000000..93723bb --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx @@ -0,0 +1,341 @@ +// Copyright (C) 2004-2012 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 +// + +// GHS3DPlugin : C++ implementation +// File : GHS3DPlugin_Hypothesis.hxx +// Created : Wed Apr 2 12:21:17 2008 +// Author : Edward AGAPOV (eap) +// +#ifndef GHS3DPlugin_Hypothesis_HeaderFile +#define GHS3DPlugin_Hypothesis_HeaderFile + +#include "GHS3DPlugin_Defs.hxx" + +#include + +#include "SMESH_Hypothesis.hxx" +#include "SMESH_Mesh_i.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_TypeDefs.hxx" +#include "utilities.h" + +#include +#include +#include +#include + +class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis: public SMESH_Hypothesis +{ +public: + + GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen); + + typedef std::map,double> TGHS3DEnforcedVertexCoordsValues; + typedef std::map TGHS3DEnforcedVertexEntryValues; + + struct TGHS3DEnforcedVertex { + std::string name; + std::string geomEntry; + bool isCompound; + std::vector coords; + std::string groupName; + double size; + }; + + struct CompareGHS3DEnforcedVertex { + bool operator () (const TGHS3DEnforcedVertex* e1, const TGHS3DEnforcedVertex* e2) const { + if (e1 && e2) { + if (e1->coords.size() && e2->coords.size()) + return (e1->coords < e2->coords); + else + return (e1->geomEntry < e2->geomEntry); + } + return false; + } + }; + typedef std::set< TGHS3DEnforcedVertex*, CompareGHS3DEnforcedVertex > TGHS3DEnforcedVertexList; + // Map Coords / Enforced node + typedef std::map< std::vector, TGHS3DEnforcedVertex* > TCoordsGHS3DEnforcedVertexMap; + // Map geom entry / Enforced node + typedef std::map< std::string, TGHS3DEnforcedVertex* > TGeomEntryGHS3DEnforcedVertexMap; + // Map groupName / Enforced node + typedef std::map< std::string, TGHS3DEnforcedVertexList > TGroupNameGHS3DEnforcedVertexMap; + + //////////////////// + // Enforced meshes + //////////////////// + + struct TGHS3DEnforcedMesh { + std::string name; + std::string entry; + SMESH::ElementType elementType; + std::string groupName; + double size; + }; + + struct CompareGHS3DEnforcedMesh { + bool operator () (const TGHS3DEnforcedMesh* e1, const TGHS3DEnforcedMesh* e2) const { + if (e1 && e2) { + if (e1->entry == e2->entry) + return (e1->elementType < e2->elementType); + else + return (e1->entry < e2->entry); + } + else + return false; + } + }; + typedef std::set< TGHS3DEnforcedMesh*, CompareGHS3DEnforcedMesh > TGHS3DEnforcedMeshList; + // Map mesh entry / Enforced mesh list + // ex: 0:1:2:1 -> [ ("Mesh_1", "0:1:2:1", TopAbs_NODE, "", -1), + // ("Mesh_1", "0:1:2:1", TopAbs_EDGE, "edge group", 5)] + typedef std::map< std::string, TGHS3DEnforcedMeshList > TEntryGHS3DEnforcedMeshListMap; + + typedef std::map TID2SizeMap; + + typedef std::map TIDSortedElemGroupMap; + typedef std::map TIDSortedNodeGroupMap; + typedef std::set TSetStrings; + + static const char* GetHypType() { return "GHS3D_Parameters"; } + /*! + * To mesh "holes" in a solid or not. Default is to mesh. + */ + void SetToMeshHoles(bool toMesh); + bool GetToMeshHoles(bool checkFreeOption = false) const; + /*! + * Maximal size of memory to be used by the algorithm (in Megabytes) + */ + void SetMaximumMemory(short MB); + short GetMaximumMemory() const; + /*! + * Initial size of memory to be used by the algorithm (in Megabytes) in + * automatic memory adjustment mode. Default is zero + */ + void SetInitialMemory(short MB); + short GetInitialMemory() const; + /*! + * Optimization level: 0-none, 1-light, 2-medium, 3-standard+, 4-strong. Default is medium + */ + enum OptimizationLevel { None = 0, Light, Medium, StandardPlus, Strong }; + void SetOptimizationLevel(OptimizationLevel level); + OptimizationLevel GetOptimizationLevel() const; + /*! + * Path to working directory + */ + void SetWorkingDirectory(const std::string& path); + std::string GetWorkingDirectory() const; + /*! + * To keep working files or remove them. Log file remains in case of errors anyway. + */ + void SetKeepFiles(bool toKeep); + bool GetKeepFiles() const; + /*! + * Verbose level [0-10] + * 0 - no standard output, + * 2 - prints the data, quality statistics of the skin and final meshes and + * indicates when the final mesh is being saved. In addition the software + * gives indication regarding the CPU time. + * 10 - same as 2 plus the main steps in the computation, quality statistics + * histogram of the skin mesh, quality statistics histogram together with + * the characteristics of the final mesh. + */ + void SetVerboseLevel(short level); + short GetVerboseLevel() const; + /*! + * To create new nodes + */ + void SetToCreateNewNodes(bool toCreate); + bool GetToCreateNewNodes() const; + /*! + * To use boundary recovery version which tries to create mesh on a very poor + * quality surface mesh + */ + void SetToUseBoundaryRecoveryVersion(bool toUse); + bool GetToUseBoundaryRecoveryVersion() const; + /*! + * Applies finite-element correction by replacing overconstrained elements where + * it is possible. The process is cutting first the overconstrained edges and + * second the overconstrained facets. This insure that no edges have two boundary + * vertices and that no facets have three boundary vertices. + */ + void SetFEMCorrection(bool toUseFem); + bool GetFEMCorrection() const; + /*! + * To removes initial central point. + */ + void SetToRemoveCentralPoint(bool toRemove); + bool GetToRemoveCentralPoint() const; + /*! + * To set hiden/undocumented/advanced options + */ + void SetTextOption(const std::string& option); + std::string GetTextOption() const; + + +// struct TEnforcedEdge { +// long ID; +// long node1; +// long node2; +// std::string groupName; +// }; + + + /*! + * \brief Return command to run ghs3d mesher excluding file prefix (-f) + */ + static std::string CommandToRun(const GHS3DPlugin_Hypothesis* hyp, + const bool hasShapeToMesh=true); + /*! + * \brief Return a unique file name + */ + static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp); + + /*! + * To set an enforced vertex + */ + bool SetEnforcedVertex(std::string aName, std::string anEntry, std::string aGroupName, + double size, double x=0.0, double y=0.0, double z=0.0, bool isCompound = false); + TGHS3DEnforcedVertex* GetEnforcedVertex(double x, double y, double z) throw (std::invalid_argument); + TGHS3DEnforcedVertex* GetEnforcedVertex(const std::string anEntry) throw (std::invalid_argument); + bool RemoveEnforcedVertex(double x=0.0, double y=0.0, double z=0.0, const std::string anEntry="" ) throw (std::invalid_argument); + const TGHS3DEnforcedVertexCoordsValues _GetEnforcedVerticesCoordsSize() const {return _enfVertexCoordsSizeList; } + const TGHS3DEnforcedVertexEntryValues _GetEnforcedVerticesEntrySize() const {return _enfVertexEntrySizeList; } + const TGHS3DEnforcedVertexList _GetEnforcedVertices() const { return _enfVertexList; } + const TCoordsGHS3DEnforcedVertexMap _GetEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; } + const TGeomEntryGHS3DEnforcedVertexMap _GetEnforcedVerticesByEntry() const { return _geomEntryEnfVertexMap; } + void ClearEnforcedVertices(); + + /*! + * To set enforced elements + */ + bool SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, double size, std::string groupName = ""); + bool SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, double size, std::string groupName = ""); + bool SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, double size, std::string groupName = ""); + const TGHS3DEnforcedMeshList _GetEnforcedMeshes() const { return _enfMeshList; } + const TEntryGHS3DEnforcedMeshListMap _GetEnforcedMeshesByEntry() const { return _entryEnfMeshMap; } + void ClearEnforcedMeshes(); + const TIDSortedNodeGroupMap _GetEnforcedNodes() const { return _enfNodes; } + const TIDSortedElemGroupMap _GetEnforcedEdges() const { return _enfEdges; } + const TIDSortedElemGroupMap _GetEnforcedTriangles() const { return _enfTriangles; } + const TID2SizeMap _GetNodeIDToSizeMap() const {return _nodeIDToSizeMap; } + const TID2SizeMap _GetElementIDToSizeMap() const {return _elementIDToSizeMap; } + const TSetStrings _GetGroupsToRemove() const {return _groupsToRemove; } + /*! + * \brief Return the enforced vertices + */ + static TGHS3DEnforcedVertexList GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp); + static TGHS3DEnforcedVertexCoordsValues GetEnforcedVerticesCoordsSize(const GHS3DPlugin_Hypothesis* hyp); + static TGHS3DEnforcedVertexEntryValues GetEnforcedVerticesEntrySize(const GHS3DPlugin_Hypothesis* hyp); + static TCoordsGHS3DEnforcedVertexMap GetEnforcedVerticesByCoords(const GHS3DPlugin_Hypothesis* hyp); + static TGeomEntryGHS3DEnforcedVertexMap GetEnforcedVerticesByEntry(const GHS3DPlugin_Hypothesis* hyp); + + static TGHS3DEnforcedMeshList GetEnforcedMeshes(const GHS3DPlugin_Hypothesis* hyp); + static TEntryGHS3DEnforcedMeshListMap GetEnforcedMeshesByEntry(const GHS3DPlugin_Hypothesis* hyp); + static TIDSortedNodeGroupMap GetEnforcedNodes(const GHS3DPlugin_Hypothesis* hyp); + static TIDSortedElemGroupMap GetEnforcedEdges(const GHS3DPlugin_Hypothesis* hyp); + static TIDSortedElemGroupMap GetEnforcedTriangles(const GHS3DPlugin_Hypothesis* hyp); + static TID2SizeMap GetNodeIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp); + static TID2SizeMap GetElementIDToSizeMap(const GHS3DPlugin_Hypothesis* hyp); + static TSetStrings GetGroupsToRemove(const GHS3DPlugin_Hypothesis* hyp); + void ClearGroupsToRemove(); + + static bool DefaultMeshHoles(); + static short DefaultMaximumMemory(); + static short DefaultInitialMemory(); + static short DefaultOptimizationLevel(); + static std::string DefaultWorkingDirectory(); + static bool DefaultKeepFiles(); + static short DefaultVerboseLevel(); + static bool DefaultToCreateNewNodes(); + static bool DefaultToUseBoundaryRecoveryVersion(); + static bool DefaultToUseFEMCorrection(); + static bool DefaultToRemoveCentralPoint(); + + static TGHS3DEnforcedVertex DefaultGHS3DEnforcedVertex() {return TGHS3DEnforcedVertex();} + static TGHS3DEnforcedVertexList DefaultGHS3DEnforcedVertexList() {return TGHS3DEnforcedVertexList();} + static TGHS3DEnforcedVertexCoordsValues DefaultGHS3DEnforcedVertexCoordsValues() {return TGHS3DEnforcedVertexCoordsValues();} + static TGHS3DEnforcedVertexEntryValues DefaultGHS3DEnforcedVertexEntryValues() {return TGHS3DEnforcedVertexEntryValues();} + static TCoordsGHS3DEnforcedVertexMap DefaultCoordsGHS3DEnforcedVertexMap() {return TCoordsGHS3DEnforcedVertexMap();} + static TGeomEntryGHS3DEnforcedVertexMap DefaultGeomEntryGHS3DEnforcedVertexMap() {return TGeomEntryGHS3DEnforcedVertexMap();} + static TGroupNameGHS3DEnforcedVertexMap DefaultGroupNameGHS3DEnforcedVertexMap() {return TGroupNameGHS3DEnforcedVertexMap();} + + static TGHS3DEnforcedMesh DefaultGHS3DEnforcedMesh() {return TGHS3DEnforcedMesh();} + static TGHS3DEnforcedMeshList DefaultGHS3DEnforcedMeshList() {return TGHS3DEnforcedMeshList();} + static TEntryGHS3DEnforcedMeshListMap DefaultEntryGHS3DEnforcedMeshListMap() {return TEntryGHS3DEnforcedMeshListMap();} + static TIDSortedNodeGroupMap DefaultIDSortedNodeGroupMap() {return TIDSortedNodeGroupMap();} + static TIDSortedElemGroupMap DefaultIDSortedElemGroupMap() {return TIDSortedElemGroupMap();} + static TID2SizeMap DefaultID2SizeMap() {return TID2SizeMap();} + static TSetStrings DefaultGroupsToRemove() {return TSetStrings();} + + // Persistence + virtual std::ostream & SaveTo(std::ostream & save); + virtual std::istream & LoadFrom(std::istream & load); + friend GHS3DPLUGIN_EXPORT std::ostream & operator <<(std::ostream & save, GHS3DPlugin_Hypothesis & hyp); + friend GHS3DPLUGIN_EXPORT std::istream & operator >>(std::istream & load, GHS3DPlugin_Hypothesis & hyp); + + /*! + * \brief Does nothing + */ + virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + + /*! + * \brief Does nothing + */ + virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); + +private: + + bool myToMeshHoles; + short myMaximumMemory; + short myInitialMemory; + short myOptimizationLevel; + bool myKeepFiles; + std::string myWorkingDirectory; + short myVerboseLevel; + bool myToCreateNewNodes; + bool myToUseBoundaryRecoveryVersion; + bool myToUseFemCorrection; + bool myToRemoveCentralPoint; + std::string myTextOption; + + TGHS3DEnforcedVertexList _enfVertexList; + TGHS3DEnforcedVertexCoordsValues _enfVertexCoordsSizeList; + TGHS3DEnforcedVertexEntryValues _enfVertexEntrySizeList; + // map to get "manual" enf vertex (through the coordinates) + TCoordsGHS3DEnforcedVertexMap _coordsEnfVertexMap; + // map to get "geom" enf vertex (through the geom entries) + TGeomEntryGHS3DEnforcedVertexMap _geomEntryEnfVertexMap; + + + TGHS3DEnforcedMeshList _enfMeshList; + // map to get enf meshes through the entries + TEntryGHS3DEnforcedMeshListMap _entryEnfMeshMap; + TIDSortedNodeGroupMap _enfNodes; + TIDSortedElemGroupMap _enfEdges; + TIDSortedElemGroupMap _enfTriangles; + TID2SizeMap _nodeIDToSizeMap; + TID2SizeMap _elementIDToSizeMap; + std::map _entryToElemsMap; + + TSetStrings _groupsToRemove; +}; + + +#endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx new file mode 100644 index 0000000..5b8466b --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx @@ -0,0 +1,1163 @@ +// Copyright (C) 2004-2012 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 : GHS3DPlugin_Hypothesis_i.cxx +// Created : Wed Apr 2 13:53:01 2008 +// Author : Edward AGAPOV (eap) +// +#include "GHS3DPlugin_Hypothesis_i.hxx" + +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" +//#include "SMESH_Mesh.hxx" +//#include "SMESH_ProxyMesh.hxx" +//#include + +#include "Utils_CorbaException.hxx" +#include "utilities.h" +#include "SMESH_Mesh_i.hxx" +#include "SMESH_Group_i.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_TypeDefs.hxx" +#include "SMESHDS_GroupBase.hxx" + +// SALOME KERNEL includes +#include "SALOMEDSClient.hxx" +#include +// // IDL headers +// #include +// #include CORBA_SERVER_HEADER(SALOMEDS) + +#ifndef GHS3D_VERSION +#define GHS3D_VERSION 41 +#endif +//======================================================================= +//function : GHS3DPlugin_Hypothesis_i +//======================================================================= + +GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" ); + myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(), + theStudyId, + theGenImpl); +} + +//======================================================================= +//function : ~GHS3DPlugin_Hypothesis_i +//======================================================================= + +GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i() +{ + MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" ); +} + +//======================================================================= +//function : SetToMeshHoles +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetToMeshHoles(toMesh); + SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )"; +} + +//======================================================================= +//function : GetToMeshHoles +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetToMeshHoles(); +} + +//======================================================================= +//function : SetMaximumMemory +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB) + throw ( SALOME::SALOME_Exception ) +{ + if ( MB == 0 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); + this->GetImpl()->SetMaximumMemory(MB); + SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )"; +} + +//======================================================================= +//function : GetMaximumMemory +//======================================================================= + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetMaximumMemory(); +} + +//======================================================================= +//function : SetInitialMemory +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB) + throw ( SALOME::SALOME_Exception ) +{ + if ( MB == 0 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); + this->GetImpl()->SetInitialMemory(MB); + SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )"; +} + +//======================================================================= +//function : GetInitialMemory +//======================================================================= + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetInitialMemory(); +} + +//======================================================================= +//function : SetOptimizationLevel +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level) + throw ( SALOME::SALOME_Exception ) +{ + ::GHS3DPlugin_Hypothesis::OptimizationLevel l = + (::GHS3DPlugin_Hypothesis::OptimizationLevel) level; + if ( l < ::GHS3DPlugin_Hypothesis::None || + l > ::GHS3DPlugin_Hypothesis::Strong ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM ); + + ASSERT(myBaseImpl); + this->GetImpl()->SetOptimizationLevel(l); + SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )"; +} + +//======================================================================= +//function : GetOptimizationLevel +//======================================================================= + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetOptimizationLevel(); +} + +//======================================================================= +//function : SetWorkingDirectory +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception ) +{ + if (!path ) + THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM ); + + string file(path); + const char lastChar = *file.rbegin(); +#ifdef WIN32 + if ( lastChar != '\\' ) file += '\\'; +#else + if ( lastChar != '/' ) file += '/'; +#endif + file += "GHS3D.log"; + SMESH_Mesh_i::PrepareForWriting (file.c_str()); + + ASSERT(myBaseImpl); + this->GetImpl()->SetWorkingDirectory(path); + SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )"; +} + +//======================================================================= +//function : GetWorkingDirectory +//======================================================================= + +char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory() +{ + ASSERT(myBaseImpl); + return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() ); +} + +//======================================================================= +//function : SetKeepFiles +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetKeepFiles(toKeep); + SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )"; +} + +//======================================================================= +//function : GetKeepFiles +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetKeepFiles(); +} + +//======================================================================= +//function : SetVerboseLevel +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level) + throw ( SALOME::SALOME_Exception ) +{ + if (level < 0 || level > 10 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]", + SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); + this->GetImpl()->SetVerboseLevel(level); + SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )"; +} + +//======================================================================= +//function : GetVerboseLevel +//======================================================================= + +CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetVerboseLevel(); +} + +//======================================================================= +//function : SetToCreateNewNodes +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetToCreateNewNodes(toCreate); + SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )"; +} + +//======================================================================= +//function : GetToCreateNewNodes +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetToCreateNewNodes(); +} + +//======================================================================= +//function : SetToUseBoundaryRecoveryVersion +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse); + SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )"; +} + +//======================================================================= +//function : GetToUseBoundaryRecoveryVersion +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetToUseBoundaryRecoveryVersion(); +} + +//======================================================================= +//function : SetFEMCorrection +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetFEMCorrection(toUseFem); + SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )"; +} + +//======================================================================= +//function : GetFEMCorrection +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetFEMCorrection(); +} + +//======================================================================= +//function : SetToRemoveCentralPoint +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetToRemoveCentralPoint(toRemove); + SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )"; +} + +//======================================================================= +//function : GetToRemoveCentralPoint +//======================================================================= + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetToRemoveCentralPoint(); +} + +//======================================================================= +//function : SetTextOption +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option) +{ + ASSERT(myBaseImpl); + this->GetImpl()->SetTextOption(option); + SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )"; +} + +//======================================================================= +//function : GetTextOption +//======================================================================= + +char* GHS3DPlugin_Hypothesis_i::GetTextOption() +{ + ASSERT(myBaseImpl); + return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() ); +} + +//======================================================================= +//function : SetEnforcedVertex +//======================================================================= + +bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")"); + return p_SetEnforcedVertex(size, x, y, z); +} + +bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")"); + return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", ""); +} + +bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")"); + return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName); +} + +bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")"); + return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName); +} + +bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + + string theVertexEntry = theVertex->GetStudyEntry(); + CORBA::Double x = 0, y = 0, z = 0; + CORBA::Boolean isCompound = false; + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + if (theVertexEntry.empty()) { + string aName; + if (theVertex->GetShapeType() == GEOM::VERTEX) { + aName = "Vertex_"; + } + if (theVertex->GetShapeType() == GEOM::COMPOUND) { + aName = "Compound_"; + isCompound = true; + } + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + if (theVertex->GetShapeType() == GEOM::VERTEX) { + GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() ); + if (CORBA::is_nil(measureOp)) + return false; + + measureOp->PointCoordinates (theVertex, x, y, z); + MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z); + } + + string theVertexName = theVertex->GetName(); + MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")"); + + return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound); +} + +bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + + string theVertexEntry = theVertex->GetStudyEntry(); + CORBA::Double x = 0, y = 0, z = 0; + CORBA::Boolean isCompound = false; + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + if (theVertexEntry.empty()) { + string aName; + if (theVertex->GetShapeType() == GEOM::VERTEX) { + aName = "Vertex_"; + } + if (theVertex->GetShapeType() == GEOM::COMPOUND) { + aName = "Compound_"; + isCompound = true; + } + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + if (theVertex->GetShapeType() == GEOM::VERTEX) { + GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() ); + if (CORBA::is_nil(measureOp)) + return false; + + measureOp->PointCoordinates (theVertex, x, y, z); + MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z); + } + + string theVertexName = theVertex->GetName(); + MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")"); + + return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound); +} + +bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* theVertexName, const char* theVertexEntry, const char* theGroupName, + CORBA::Boolean isCompound) + throw (SALOME::SALOME_Exception) { + ASSERT(myBaseImpl); + MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")"); + bool newValue = false; + + ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList; + ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList; + if (string(theVertexEntry).empty()) { + coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords(); + std::vector coords; + coords.push_back(x); + coords.push_back(y); + coords.push_back(z); + if (coordsList.find(coords) == coordsList.end()) { + MESSAGE("Coords not found: add it in coordsList"); + newValue = true; + } + else { + MESSAGE("Coords already found, compare names"); + ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z); + if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) { + MESSAGE("The names or size are different: update"); +// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); + newValue = true; + } + else { + MESSAGE("The names and size are identical"); + } + } + + if (newValue) { + if (string(theVertexName).empty()) { + if (string(theGroupName).empty()) + SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")"; + else + SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")"; + } + else { + if (string(theGroupName).empty()) + SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")"; + else + SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")"; + } + } + } + else { +// if (isCompound || (!isCompound && !string(theVertexEntry).empty())) { + enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry(); +// ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry); + if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) { + MESSAGE("Geom entry not found: add it in enfVertexEntryList"); + newValue = true; + } + else { + MESSAGE("Geom entry already found, compare names"); + ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(theVertexEntry); + if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) { + MESSAGE("The names or size are different: update"); +// this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z); + newValue = true; + } + else { + MESSAGE("The names and size are identical"); + } + } + + if (newValue) { + if (string(theGroupName).empty()) + SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeom(" << theVertexEntry << ", " << size << ")"; + else + SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexGeomWithGroup(" << theVertexEntry << ", " << size << ", \"" << theGroupName << "\")"; + } + } + + if (newValue) + this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound); + + MESSAGE("IDL : SetEnforcedVertexEntry END"); + return newValue; +} + +//======================================================================= +//function : GetEnforcedVertex +//======================================================================= + +CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + try { + bool isDone = this->GetImpl()->GetEnforcedVertex(x,y,z)->size; + SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertex(" << x << ", " << y << ", " << z << ")"; + return isDone; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 513; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +//======================================================================= +//function : GetEnforcedVertex +//======================================================================= + +CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + + string theVertexEntry = theVertex->GetStudyEntry(); + if (theVertexEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + string theVertexName = theVertex->GetName(); + + try { + bool isDone = this->GetImpl()->GetEnforcedVertex(theVertexName)->size; + SMESH::TPythonDump() << "aSize = " << _this() << ".GetEnforcedVertexGeom(" << theVertex << ")"; + return isDone; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 538; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +//======================================================================= +//function : GetEnforcedVertices +//======================================================================= + +GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices() +{ + ASSERT(myBaseImpl); + GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList(); + + const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList enfVertexList = this->GetImpl()->_GetEnforcedVertices(); + result->length( enfVertexList.size() ); + + ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertexList::const_iterator it = enfVertexList.begin(); + + for (int i = 0 ; it != enfVertexList.end(); ++it, ++i ) { + ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex* currentVertex = (*it); + GHS3DPlugin::GHS3DEnforcedVertex_var enfVertex = new GHS3DPlugin::GHS3DEnforcedVertex(); + // Name + enfVertex->name = CORBA::string_dup(currentVertex->name.c_str()); + // Geom Vertex Entry + enfVertex->geomEntry = CORBA::string_dup(currentVertex->geomEntry.c_str()); + // Coords + GHS3DPlugin::TCoords_var coords = new GHS3DPlugin::TCoords(); + coords->length(currentVertex->coords.size()); + for (int ind = 0; ind < currentVertex->coords.size(); ind++) + coords[ind] = currentVertex->coords[ind]; + enfVertex->coords = coords; + // Group Name + enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str()); + // Size + enfVertex->size = currentVertex->size; + // isCompound + enfVertex->isCompound = currentVertex->isCompound; + + result[i]=enfVertex; + } + +// SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; + + return result._retn(); +} + +//======================================================================= +//function : RemoveEnforcedVertex +//======================================================================= + +bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + try { + bool res = this->GetImpl()->RemoveEnforcedVertex(x,y,z); + SMESH::TPythonDump() << " isDone = " << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )"; + return res; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 625; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +bool GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + + if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) { + MESSAGE("theVertex shape type is not VERTEX or COMPOUND"); + THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM); + } + + string theVertexEntry = theVertex->GetStudyEntry(); + if (theVertexEntry.empty()) { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry.empty()) + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + try { + bool res = this->GetImpl()->RemoveEnforcedVertex(0,0,0, theVertexEntry.c_str()); + SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom( " << theVertexEntry.c_str() << " )"; + return res; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 648; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} + +//======================================================================= +//function : ClearEnforcedVertices +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices() +{ + ASSERT(myBaseImpl); + this->GetImpl()->ClearEnforcedVertices(); + SMESH::TPythonDump () << _this() << ".ClearEnforcedVertices() "; +} + +//======================================================================= +//function : ClearEnforcedMeshes +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::ClearEnforcedMeshes() +{ + ASSERT(myBaseImpl); + this->GetImpl()->ClearEnforcedMeshes(); + SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() "; +} + +//======================================================================= +//function : GetEnforcedMeshes +//======================================================================= + +GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes() +{ + ASSERT(myBaseImpl); + GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList(); + + const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes(); + result->length( enfMeshList.size() ); + + ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin(); + + for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) { + ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it); + GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh(); + // Name + enfMesh->name = CORBA::string_dup(currentMesh->name.c_str()); + // Mesh Entry + enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str()); + // isCompound + enfMesh->elementType = currentMesh->elementType; + // Group Name + enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str()); + // Size + enfMesh->size = currentMesh->size; + + result[i]=enfMesh; + } + +// SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()"; + + return result._retn(); +} + +/*! + * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName. + */ +bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theGroupName) + throw (SALOME::SALOME_Exception) +{ +#if GHS3D_VERSION >= 42 + return p_SetEnforcedMesh(theSource, theType, -1.0, theGroupName); +// bool res = p_SetEnforcedMesh(theSource, theType, -1.0, theGroupName); +// SMESH_Mesh_i* theMesh_i = SMESH::DownCast( theSource); +// SMESH_Group_i* theGroup_i = SMESH::DownCast( theSource); +// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast( theSource); +// if (theGroup_i || theGroupOnGeom_i) +// { +// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " +// << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; +// } +// else if (theMesh_i) +// { +// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " +// << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )"; +// } +// return res; +#else + SALOME::ExceptionStruct ExDescription; + ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 719; + throw SALOME::SALOME_Exception(ExDescription); +#endif +} + +/*! + * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. + */ +bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType) + throw (SALOME::SALOME_Exception) +{ +// MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh"); +#if GHS3D_VERSION >= 42 + return p_SetEnforcedMesh(theSource, theType); +// bool res = p_SetEnforcedMesh(theSource, theType); +// SMESH_Mesh_i* theMesh_i = SMESH::DownCast( theSource); +// SMESH_Group_i* theGroup_i = SMESH::DownCast( theSource); +// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast( theSource); +// if (theGroup_i || theGroupOnGeom_i) +// { +// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " +// << theSource << ", " << theType << " )"; +// } +// else if (theMesh_i) +// { +// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " +// << theSource << ".GetMesh(), " << theType << " )"; +// } +// return res; +#else + SALOME::ExceptionStruct ExDescription; + ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 750; + throw SALOME::SALOME_Exception(ExDescription); +#endif +} + +/*! + * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size. The elements will be grouped in theGroupName. + */ +bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName) + throw (SALOME::SALOME_Exception) +{ +#if GHS3D_VERSION >= 42 + if (theSize < 0) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = "Size cannot be negative"; + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 781; + throw SALOME::SALOME_Exception(ExDescription); + } + + return p_SetEnforcedMesh(theSource, theType, theSize, theGroupName); +// bool res = p_SetEnforcedMesh(theSource, theType, theSize, theGroupName); +// SMESH_Mesh_i* theMesh_i = SMESH::DownCast( theSource); +// SMESH_Group_i* theGroup_i = SMESH::DownCast( theSource); +// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast( theSource); +// if (theGroup_i || theGroupOnGeom_i) +// { +// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( " +// << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )"; +// } +// else if (theMesh_i) +// { +// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( " +// << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )"; +// } +// return res; +#else + SALOME::ExceptionStruct ExDescription; + ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 750; + throw SALOME::SALOME_Exception(ExDescription); +#endif +} + +/*! + * \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource and a size. + */ +bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize) + throw (SALOME::SALOME_Exception) +{ +#if GHS3D_VERSION >= 42 + if (theSize < 0) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = "Size cannot be negative"; + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 781; + throw SALOME::SALOME_Exception(ExDescription); + } + return p_SetEnforcedMesh(theSource, theType, theSize); +// bool res = p_SetEnforcedMesh(theSource, theType, theSize); +// SMESH_Mesh_i* theMesh_i = SMESH::DownCast( theSource); +// SMESH_Group_i* theGroup_i = SMESH::DownCast( theSource); +// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast( theSource); +// if (theGroup_i || theGroupOnGeom_i) +// { +// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( " +// << theSource << ", " << theType << ", " << theSize << " )"; +// } +// else if (theMesh_i) +// { +// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( " +// << theSource << ".GetMesh(), " << theType << ", " << theSize << " )"; +// } +// return res; +#else + SALOME::ExceptionStruct ExDescription; + ExDescription.text = "Bad version of GHS3D. It must >= 4.2."; + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 750; + throw SALOME::SALOME_Exception(ExDescription); +#endif +} + +bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName) + throw (SALOME::SALOME_Exception) +{ + MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh"); + ASSERT(myBaseImpl); + + if (CORBA::is_nil( theSource )) + { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = "The source mesh CORBA object is NULL"; + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 840; + throw SALOME::SALOME_Exception(ExDescription); + } + + if ((theType != SMESH::NODE) && (theType != SMESH::EDGE) && (theType != SMESH::FACE)) + { + return false; +// SALOME::ExceptionStruct ExDescription; +// ExDescription.text = "Bad elementType"; +// ExDescription.type = SALOME::BAD_PARAM; +// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; +// ExDescription.lineNumber = 840; +// throw SALOME::SALOME_Exception(ExDescription); + } + + SMESH::array_of_ElementType_var types = theSource->GetTypes(); + switch (theType) { + case SMESH::NODE: + MESSAGE("Required type is NODE"); + break; + case SMESH::EDGE: + MESSAGE("Required type is EDGE"); + break; + case SMESH::FACE: + MESSAGE("Required type is FACE"); + break; + default: + break; + } +// MESSAGE("Required type is "<length();i++){MESSAGE(types[i]);} + if ( types->length() >= 1 && types[types->length()-1] < theType) + { + return false; +// SALOME::ExceptionStruct ExDescription; +// ExDescription.text = "The source mesh has bad type"; +// ExDescription.type = SALOME::BAD_PARAM; +// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; +// ExDescription.lineNumber = 840; +// throw SALOME::SALOME_Exception(ExDescription); + } + + SMESH_Mesh_i* theMesh_i = SMESH::DownCast( theSource); + SMESH_Group_i* theGroup_i = SMESH::DownCast( theSource); + SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast( theSource); + TIDSortedElemSet theElemSet; + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource); + if (theMesh_i) + { + try { + bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName); + if (theSize > 0) { + if (theGroupName != "") { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( " + << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( " + << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )"; + } + } + else { + if (theGroupName != "") { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + << theSource << ".GetMesh(), " << theType << " )"; + } + } + return res; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 840; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + } + else if (theGroup_i && types->length() == 1 && types[0] == theType) + { + MESSAGE("The source is a group") + try { + bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName); + if (theSize > 0) { + if (theGroupName != "") { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( " + << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( " + << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )"; + } + } + else { + if (theGroupName != "") { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + << theSource << ", " << theType << " )"; + } + } + return res; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 840; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + } + else if (theGroupOnGeom_i && types->length() == 1 && types[0] == theType) + { + MESSAGE("The source is a group on geom") + try { + bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName); + if (theSize > 0) { + if (theGroupName != "") { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( " + << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( " + << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )"; + } + } + else { + if (theGroupName != "") { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( " + << theSource << ", " << theType << ", \"" << theGroupName << "\" )"; + } + else { + SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( " + << theSource << ", " << theType << " )"; + } + } + return res; + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx"; + ExDescription.lineNumber = 840; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + } + return false; +} +//============================================================================= +/*! + * Get implementation + */ +//============================================================================= + +::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl() +{ + return (::GHS3DPlugin_Hypothesis*)myBaseImpl; +} + +//================================================================================ +/*! + * \brief Verify whether hypothesis supports given entity type + */ +//================================================================================ + +CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_3D; +} + diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx new file mode 100644 index 0000000..7ca3cac --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx @@ -0,0 +1,163 @@ +// Copyright (C) 2004-2012 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 +// + +// GHS3DPlugin : C++ implementation +// File : GHS3DPlugin_Hypothesis_i.hxx +// Date : 03/04/2006 +// Project : SALOME +// +#ifndef _GHS3DPlugin_Hypothesis_i_HXX_ +#define _GHS3DPlugin_Hypothesis_i_HXX_ + +#include "GHS3DPlugin_Defs.hxx" + +#include +#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) + +#include "SMESH_Hypothesis_i.hxx" +#include "SMESH_Mesh_i.hxx" +#include "GHS3DPlugin_Hypothesis.hxx" + +class SMESH_Gen; + +// GHS3DPlugin parameters hypothesis + +class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i: + public virtual POA_GHS3DPlugin::GHS3DPlugin_Hypothesis, + public virtual SMESH_Hypothesis_i +{ + public: + // Constructor + GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl); + // Destructor + virtual ~GHS3DPlugin_Hypothesis_i(); + + /*! + * To mesh "holes" in a solid or not. Default is to mesh. + */ + void SetToMeshHoles(CORBA::Boolean toMesh); + CORBA::Boolean GetToMeshHoles(); + /*! + * Maximal size of memory to be used by the algorithm (in Megabytes) + */ + void SetMaximumMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetMaximumMemory(); + /*! + * Initial size of memory to be used by the algorithm (in Megabytes) in + * automatic memory adjustment mode. Default is zero + */ + void SetInitialMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetInitialMemory(); + /*! + * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium + */ + void SetOptimizationLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetOptimizationLevel(); + /*! + * Path to working directory + */ + void SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception ); + char* GetWorkingDirectory(); + /*! + * To keep working files or remove them. Log file remains in case of errors anyway. + */ + void SetKeepFiles(CORBA::Boolean toKeep); + CORBA::Boolean GetKeepFiles(); + /*! + * Verbose level [0-10] + * 0 - no standard output, + * 2 - prints the data, quality statistics of the skin and final meshes and + * indicates when the final mesh is being saved. In addition the software + * gives indication regarding the CPU time. + * 10 - same as 2 plus the main steps in the computation, quality statistics + * histogram of the skin mesh, quality statistics histogram together with + * the characteristics of the final mesh. + */ + void SetVerboseLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetVerboseLevel(); + /*! + * To create new nodes + */ + void SetToCreateNewNodes(CORBA::Boolean toCreate); + CORBA::Boolean GetToCreateNewNodes(); + /*! + * To use boundary recovery version which tries to create mesh on a very poor + * quality surface mesh + */ + void SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse); + CORBA::Boolean GetToUseBoundaryRecoveryVersion(); + /*! + * Applies finite-element correction by replacing overconstrained elements where + * it is possible. The process is cutting first the overconstrained edges and + * second the overconstrained facets. This insure that no edges have two boundary + * vertices and that no facets have three boundary vertices. + */ + void SetFEMCorrection(CORBA::Boolean toUseFem); + CORBA::Boolean GetFEMCorrection(); + /*! + * To removes initial central point. + */ + void SetToRemoveCentralPoint(CORBA::Boolean toRemove); + CORBA::Boolean GetToRemoveCentralPoint(); + /*! + * To set hiden/undocumented/advanced options + */ + void SetTextOption(const char* option); + char* GetTextOption(); + /*! + * To set an enforced vertex + */ + bool p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x = 0, CORBA::Double y = 0, CORBA::Double z = 0, + const char* theVertexName = "", const char* theVertexEntry = "", const char* theGroupName = "", + CORBA::Boolean isCompound = false) + throw (SALOME::SALOME_Exception); + bool SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size) throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName) throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName) throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName) throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size) throw (SALOME::SALOME_Exception); + bool SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName) throw (SALOME::SALOME_Exception); + CORBA::Double GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); + CORBA::Double GetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception); + bool RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); + bool RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex) throw (SALOME::SALOME_Exception); + GHS3DPlugin::GHS3DEnforcedVertexList* GetEnforcedVertices(); + void ClearEnforcedVertices(); + /*! + * To set an enforced mesh + */ + bool p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size = -1, const char* theGroupName="") throw (SALOME::SALOME_Exception); + bool SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType) throw (SALOME::SALOME_Exception); + bool SetEnforcedMeshWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, const char* theGroupName) throw (SALOME::SALOME_Exception); + bool SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size) throw (SALOME::SALOME_Exception); + bool SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType elementType, double size, const char* theGroupName) throw (SALOME::SALOME_Exception); + GHS3DPlugin::GHS3DEnforcedMeshList* GetEnforcedMeshes(); + void ClearEnforcedMeshes(); + + // Get implementation + ::GHS3DPlugin_Hypothesis* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + +}; + +#endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_i.cxx new file mode 100644 index 0000000..7539de5 --- /dev/null +++ b/src/GHS3DPlugin/GHS3DPlugin_i.cxx @@ -0,0 +1,68 @@ +// Copyright (C) 2004-2012 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 +// + +// SMESH GHS3DPlugin : implementaion of SMESH idl descriptions +// File : GHS3DPlugin.cxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ +// +#include "SMESH_Hypothesis_i.hxx" + +#include "utilities.h" + +#include "GHS3DPlugin_GHS3D_i.hxx" +#include "GHS3DPlugin_Hypothesis_i.hxx" + +template class GHS3DPlugin_Creator_i:public HypothesisCreator_i +{ + // as we have 'module GHS3DPlugin' in GHS3DPlugin_Algorithm.idl + virtual std::string GetModuleName() { return "GHS3DPlugin"; } +}; + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ + GHS3DPLUGIN_EXPORT GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName); + + GHS3DPLUGIN_EXPORT + GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName) + { + MESSAGE("GetHypothesisCreator " << aHypName); + + GenericHypothesisCreator_i* aCreator = 0; + + // Hypotheses + + // Algorithm + if (strcmp(aHypName, "GHS3D_3D") == 0) + aCreator = new GHS3DPlugin_Creator_i; + // Hypothesis + else if (strcmp(aHypName, "GHS3D_Parameters") == 0) + aCreator = new GHS3DPlugin_Creator_i; + else ; + + return aCreator; + } +} diff --git a/src/GHS3DPlugin/Makefile.am b/src/GHS3DPlugin/Makefile.am new file mode 100644 index 0000000..a761826 --- /dev/null +++ b/src/GHS3DPlugin/Makefile.am @@ -0,0 +1,68 @@ +# Copyright (C) 2004-2012 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 +# + +# -* Makefile *- +# Author : Edward AGAPOV (OCC) +# Modified by : Alexander BORODIN (OCN) - autotools usage +# Module : GHS3DPLUGIN +# Date : 10/01/2004 +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# header files +salomeinclude_HEADERS = \ + libmesh5.h \ + GHS3DPlugin_Defs.hxx \ + GHS3DPlugin_GHS3D.hxx \ + GHS3DPlugin_GHS3D_i.hxx \ + GHS3DPlugin_Hypothesis.hxx \ + GHS3DPlugin_Hypothesis_i.hxx + +# Libraries targets +lib_LTLIBRARIES = libGHS3DEngine.la + +dist_libGHS3DEngine_la_SOURCES = \ + libmesh5.c \ + GHS3DPlugin_GHS3D.cxx \ + GHS3DPlugin_GHS3D_i.cxx \ + GHS3DPlugin_i.cxx \ + GHS3DPlugin_Hypothesis.cxx \ + GHS3DPlugin_Hypothesis_i.cxx + +libGHS3DEngine_la_CPPFLAGS = \ + $(KERNEL_CXXFLAGS) \ + $(CAS_CPPFLAGS) \ + $(GEOM_CXXFLAGS) \ + $(MED_CXXFLAGS) \ + $(SMESH_CXXFLAGS) \ + $(VTK_INCLUDES) \ + $(BOOST_CPPFLAGS) \ + $(CORBA_CXXFLAGS) \ + $(CORBA_INCLUDES) \ + -I$(top_builddir)/idl + +libGHS3DEngine_la_LDFLAGS = \ + ../../idl/libSalomeIDLGHS3DPLUGIN.la \ + $(CAS_KERNEL) -lTKBRep -lTKG2d -lTKG3d -lTKTopAlgo -lTKGeomBase -lTKGeomAlgo -lTKCDF \ + $(MED_LDFLAGS) -lSalomeIDLMED \ + $(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine -lSMESHDS -lSMDS -lStdMeshers \ + $(KERNEL_LDFLAGS) -lSalomeGenericObj -lSALOMELocalTrace -lSALOMEBasics -lSalomeNS -lOpUtil + +# Scripts to be installed. +dist_salomescript_DATA= GHS3DPluginDC.py diff --git a/src/GHS3DPlugin/libmesh5.c b/src/GHS3DPlugin/libmesh5.c new file mode 100644 index 0000000..4277b97 --- /dev/null +++ b/src/GHS3DPlugin/libmesh5.c @@ -0,0 +1,1192 @@ + + +/*----------------------------------------------------------*/ +/* */ +/* LIBMESH V 5.45 */ +/* */ +/*----------------------------------------------------------*/ +/* */ +/* Description: handle .meshb file format I/O */ +/* Author: Loic MARECHAL */ +/* Creation date: feb 16 2007 */ +/* Last modification: feb 08 2011 */ +/* */ +/*----------------------------------------------------------*/ + + +/*----------------------------------------------------------*/ +/* Includes */ +/*----------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include "libmesh5.h" + + +/*----------------------------------------------------------*/ +/* Defines */ +/*----------------------------------------------------------*/ + +#define Asc 1 +#define Bin 2 +#define MshFil 4 +#define SolFil 8 +#define MaxMsh 100 +#define InfKwd 1 +#define RegKwd 2 +#define SolKwd 3 +#define WrdSiz 4 +#define BufSiz 10000 + + +/*----------------------------------------------------------*/ +/* Structures */ +/*----------------------------------------------------------*/ + +typedef struct +{ + int typ, SolSiz, NmbWrd, NmbLin, NmbTyp, TypTab[ GmfMaxTyp ]; + long pos; + char fmt[ GmfMaxTyp*9 ]; +}KwdSct; + +typedef struct +{ + int dim, ver, mod, typ, cod, pos; + long NexKwdPos; + KwdSct KwdTab[ GmfMaxKwd + 1 ]; + FILE *hdl; + int *IntBuf; + float *FltBuf; + unsigned char *buf; + char FilNam[ GmfStrSiz ]; + double DblBuf[1000/8]; + unsigned char blk[ BufSiz + 1000 ]; +}GmfMshSct; + + +/*----------------------------------------------------------*/ +/* Global variables */ +/*----------------------------------------------------------*/ + +int GmfIniFlg=0; +GmfMshSct *GmfMshTab[ MaxMsh + 1 ]; +char *GmfKwdFmt[ GmfMaxKwd + 1 ][4] = +{ {"Reserved", "", "", ""}, + {"MeshVersionFormatted", "", "", "i"}, + {"Reserved", "", "", ""}, + {"Dimension", "", "", "i"}, + {"Vertices", "Vertex", "i", "dri"}, + {"Edges", "Edge", "i", "iii"}, + {"Triangles", "Triangle", "i", "iiii"}, + {"Quadrilaterals", "Quadrilateral", "i", "iiiii"}, + {"Tetrahedra", "Tetrahedron", "i", "iiiii"}, + {"Prisms", "Prism", "i", "iiiiiii"}, + {"Hexahedra", "Hexahedron", "i", "iiiiiiiii"}, + {"IterationsAll", "IterationAll","","i"}, + {"TimesAll", "TimeAll","","r"}, + {"Corners", "Corner", "i", "i"}, + {"Ridges", "Ridge", "i", "i"}, + {"RequiredVertices", "RequiredVertex", "i", "i"}, + {"RequiredEdges", "RequiredEdge", "i", "i"}, + {"RequiredTriangles", "RequiredTriangle", "i", "i"}, + {"RequiredQuadrilaterals", "RequiredQuadrilateral", "i", "i"}, + {"TangentAtEdgeVertices", "TangentAtEdgeVertex", "i", "iii"}, + {"NormalAtVertices", "NormalAtVertex", "i", "ii"}, + {"NormalAtTriangleVertices", "NormalAtTriangleVertex", "i", "iii"}, + {"NormalAtQuadrilateralVertices", "NormalAtQuadrilateralVertex", "i", "iiii"}, + {"AngleOfCornerBound", "", "", "r"}, + {"TrianglesP2", "TriangleP2", "i", "iiiiiii"}, + {"EdgesP2", "EdgeP2", "i", "iiii"}, + {"SolAtPyramids", "SolAtPyramid", "i", "sr"}, + {"QuadrilateralsQ2", "QuadrilateralQ2", "i", "iiiiiiiiii"}, + {"ISolAtPyramids", "ISolAtPyramid", "i", "iiiii"}, + {"Reserved", "", "", ""}, + {"TetrahedraP2", "TetrahedronP2", "i", "iiiiiiiiiii"}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"HexahedraQ2", "HexahedronQ2", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Polyhedra", "Polyhedron", "i", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"}, + {"Polygons", "Polygon", "", "iiiiiiiii"}, + {"Reserved", "", "", ""}, + {"Pyramids", "Pyramid", "i", "iiiiii"}, + {"BoundingBox", "", "", "drdr"}, + {"Body","i", "drdrdrdr"}, + {"PrivateTable", "PrivateTable", "i", "i"}, + {"Reserved", "", "", ""}, + {"End", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Reserved", "", "", ""}, + {"Tangents", "Tangent", "i", "dr"}, + {"Normals", "Normal", "i", "dr"}, + {"TangentAtVertices", "TangentAtVertex", "i", "ii"}, + {"SolAtVertices", "SolAtVertex", "i", "sr"}, + {"SolAtEdges", "SolAtEdge", "i", "sr"}, + {"SolAtTriangles", "SolAtTriangle", "i", "sr"}, + {"SolAtQuadrilaterals", "SolAtQuadrilateral", "i", "sr"}, + {"SolAtTetrahedra", "SolAtTetrahedron", "i", "sr"}, + {"SolAtPrisms", "SolAtPrism", "i", "sr"}, + {"SolAtHexahedra", "SolAtHexahedron", "i", "sr"}, + {"DSolAtVertices", "DSolAtVertex", "i", "sr"}, + {"ISolAtVertices", "ISolAtVertex", "i", "i"}, + {"ISolAtEdges", "ISolAtEdge", "i", "ii"}, + {"ISolAtTriangles", "ISolAtTriangle", "i", "iii"}, + {"ISolAtQuadrilaterals", "ISolAtQuadrilateral", "i", "iiii"}, + {"ISolAtTetrahedra", "ISolAtTetrahedron", "i", "iiii"}, + {"ISolAtPrisms", "ISolAtPrism", "i", "iiiiii"}, + {"ISolAtHexahedra", "ISolAtHexahedron", "i", "iiiiiiii"}, + {"Iterations", "","","i"}, + {"Time", "","","r"}, + {"Reserved", "","",""} + }; + + +/*----------------------------------------------------------*/ +/* Prototypes of local procedures */ +/*----------------------------------------------------------*/ + +static void ScaWrd(GmfMshSct *, unsigned char *); +static void ScaDblWrd(GmfMshSct *, unsigned char *); +static void ScaBlk(GmfMshSct *, unsigned char *, int); +static long GetPos(GmfMshSct *); +static void RecWrd(GmfMshSct *, unsigned char *); +static void RecDblWrd(GmfMshSct *, unsigned char *); +static void RecBlk(GmfMshSct *, unsigned char *, int); +static void SetPos(GmfMshSct *, long); +static int ScaKwdTab(GmfMshSct *); +static void ExpFmt(GmfMshSct *, int); +static void ScaKwdHdr(GmfMshSct *, int); + + +/*----------------------------------------------------------*/ +/* Open a mesh file in read or write mod */ +/*----------------------------------------------------------*/ + +int GmfOpenMesh(const char *FilNam, int mod, ...) +{ + int i, KwdCod, res, *PtrVer, *PtrDim, MshIdx=0; + char str[ GmfStrSiz ]; + va_list VarArg; + GmfMshSct *msh; + + if(!GmfIniFlg) + { + for(i=0;i<=MaxMsh;i++) + GmfMshTab[i] = NULL; + + GmfIniFlg = 1; + } + + /*---------------------*/ + /* MESH STRUCTURE INIT */ + /*---------------------*/ + + for(i=1;i<=MaxMsh;i++) + if(!GmfMshTab[i]) + { + MshIdx = i; + break; + } + + if( !MshIdx || !(msh = calloc(1, sizeof(GmfMshSct))) ) + return(0); + + /* Copy the FilNam into the structure */ + + if(strlen(FilNam) + 7 >= GmfStrSiz) + return(0); + + strcpy(msh->FilNam, FilNam); + + /* Store the opening mod (read or write) and guess the filetype (binary or ascii) depending on the extension */ + + msh->mod = mod; + msh->buf = (void *)msh->DblBuf; + msh->FltBuf = (void *)msh->DblBuf; + msh->IntBuf = (void *)msh->DblBuf; + + if(strstr(msh->FilNam, ".meshb")) + msh->typ |= (Bin | MshFil); + else if(strstr(msh->FilNam, ".mesh")) + msh->typ |= (Asc | MshFil); + else if(strstr(msh->FilNam, ".solb")) + msh->typ |= (Bin | SolFil); + else if(strstr(msh->FilNam, ".sol")) + msh->typ |= (Asc | SolFil); + else + return(0); + + /* Open the file in the required mod and initialyse the mesh structure */ + + if(msh->mod == GmfRead) + { + + /*-----------------------*/ + /* OPEN FILE FOR READING */ + /*-----------------------*/ + + va_start(VarArg, mod); + PtrVer = va_arg(VarArg, int *); + PtrDim = va_arg(VarArg, int *); + va_end(VarArg); + + /* Create the name string and open the file */ + + if(!(msh->hdl = fopen(msh->FilNam, "rb"))) + return(0); + + /* Read the endian coding tag, the mesh version and the mesh dimension (mandatory kwd) */ + + if(msh->typ & Bin) + { + fread((unsigned char *)&msh->cod, WrdSiz, 1, msh->hdl); + + if( (msh->cod != 1) && (msh->cod != 16777216) ) + return(0); + + ScaWrd(msh, (unsigned char *)&msh->ver); + + if( (msh->ver < 1) || (msh->ver > 3) ) + return(0); + + if( (msh->ver == 3) && (sizeof(long) == 4) ) + return(0); + + ScaWrd(msh, (unsigned char *)&KwdCod); + + if(KwdCod != GmfDimension) + return(0); + + GetPos(msh); + ScaWrd(msh, (unsigned char *)&msh->dim); + } + else + { + do + { + res = fscanf(msh->hdl, "%s", str); + }while( (res != EOF) && strcmp(str, "MeshVersionFormatted") ); + + if(res == EOF) + return(0); + + fscanf(msh->hdl, "%d", &msh->ver); + + if( (msh->ver < 1) || (msh->ver > 3) ) + return(0); + + do + { + res = fscanf(msh->hdl, "%s", str); + }while( (res != EOF) && strcmp(str, "Dimension") ); + + if(res == EOF) + return(0); + + fscanf(msh->hdl, "%d", &msh->dim); + } + + if( (msh->dim != 2) && (msh->dim != 3) ) + return(0); + + (*PtrVer) = msh->ver; + (*PtrDim) = msh->dim; + + /*------------*/ + /* KW READING */ + /*------------*/ + + /* Read the list of kw present in the file */ + + if(!ScaKwdTab(msh)) + return(0); + + GmfMshTab[ MshIdx ] = msh; + + return(MshIdx); + } + else if(msh->mod == GmfWrite) + { + + /*-----------------------*/ + /* OPEN FILE FOR WRITING */ + /*-----------------------*/ + + msh->cod = 1; + + /* Check if the user provided a valid version number and dimension */ + + va_start(VarArg, mod); + msh->ver = va_arg(VarArg, int); + msh->dim = va_arg(VarArg, int); + va_end(VarArg); + + if( (msh->ver < 1) || (msh->ver > 3) ) + return(0); + + if( (msh->ver == 3) && (sizeof(long) == 4) ) + return(0); + + if( (msh->dim != 2) && (msh->dim != 3) ) + return(0); + + /* Create the mesh file */ + + if(!(msh->hdl = fopen(msh->FilNam, "wb"))) + return(0); + + GmfMshTab[ MshIdx ] = msh; + + + /*------------*/ + /* KW WRITING */ + /*------------*/ + + /* Write the mesh version and dimension */ + + if(msh->typ & Asc) + { + fprintf(msh->hdl, "%s %d\n\n", GmfKwdFmt[ GmfVersionFormatted ][0], msh->ver); + fprintf(msh->hdl, "%s %d\n", GmfKwdFmt[ GmfDimension ][0], msh->dim); + } + else + { + RecWrd(msh, (unsigned char *)&msh->cod); + RecWrd(msh, (unsigned char *)&msh->ver); + GmfSetKwd(MshIdx, GmfDimension, 0); + RecWrd(msh, (unsigned char *)&msh->dim); + } + + return(MshIdx); + } + else + return(0); +} + + +/*----------------------------------------------------------*/ +/* Close a meshfile in the right way */ +/*----------------------------------------------------------*/ + +int GmfCloseMesh(int MshIdx) +{ + int res = 1; + GmfMshSct *msh; + + if( (MshIdx < 1) || (MshIdx > MaxMsh) ) + return(0); + + msh = GmfMshTab[ MshIdx ]; + RecBlk(msh, msh->buf, 0); + + /* In write down the "End" kw in write mode */ + + if(msh->mod == GmfWrite) { + if(msh->typ & Asc) + fprintf(msh->hdl, "\n%s\n", GmfKwdFmt[ GmfEnd ][0]); + else + GmfSetKwd(MshIdx, GmfEnd, 0); + } + + /* Close the file and free the mesh structure */ + + if(fclose(msh->hdl)) + res = 0; + + free(msh); + GmfMshTab[ MshIdx ] = NULL; + + return(res); +} + + +/*----------------------------------------------------------*/ +/* Read the number of lines and set the position to this kwd*/ +/*----------------------------------------------------------*/ + +int GmfStatKwd(int MshIdx, int KwdCod, ...) +{ + int i, *PtrNmbTyp, *PtrSolSiz, *TypTab; + GmfMshSct *msh; + KwdSct *kwd; + va_list VarArg; + + if( (MshIdx < 1) || (MshIdx > MaxMsh) ) + return(0); + + msh = GmfMshTab[ MshIdx ]; + + if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) ) + return(0); + + kwd = &msh->KwdTab[ KwdCod ]; + + if(!kwd->NmbLin) + return(0); + + /* Read further arguments if this kw is a sol */ + + if(kwd->typ == SolKwd) + { + va_start(VarArg, KwdCod); + + PtrNmbTyp = va_arg(VarArg, int *); + *PtrNmbTyp = kwd->NmbTyp; + + PtrSolSiz = va_arg(VarArg, int *); + *PtrSolSiz = kwd->SolSiz; + + TypTab = va_arg(VarArg, int *); + + for(i=0;iNmbTyp;i++) + TypTab[i] = kwd->TypTab[i]; + + va_end(VarArg); + } + + return(kwd->NmbLin); +} + + +/*----------------------------------------------------------*/ +/* Set the current file position to a given kwd */ +/*----------------------------------------------------------*/ + +int GmfGotoKwd(int MshIdx, int KwdCod) +{ + GmfMshSct *msh; + KwdSct *kwd; + + if( (MshIdx < 1) || (MshIdx > MaxMsh) ) + return(0); + + msh = GmfMshTab[ MshIdx ]; + + if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) ) + return(0); + + kwd = &msh->KwdTab[ KwdCod ]; + + if(!kwd->NmbLin) + return(0); + + return(fseek(msh->hdl, kwd->pos, SEEK_SET)); +} + + +/*----------------------------------------------------------*/ +/* Write the kwd and set the number of lines */ +/*----------------------------------------------------------*/ + +int GmfSetKwd(int MshIdx, int KwdCod, ...) +{ + int i, NmbLin=0, *TypTab; + long CurPos; + va_list VarArg; + GmfMshSct *msh; + KwdSct *kwd; + + if( (MshIdx < 1) || (MshIdx > MaxMsh) ) + return(0); + + msh = GmfMshTab[ MshIdx ]; + RecBlk(msh, msh->buf, 0); + + if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) ) + return(0); + + kwd = &msh->KwdTab[ KwdCod ]; + + /* Read further arguments if this kw has a header */ + + if(strlen(GmfKwdFmt[ KwdCod ][2])) + { + va_start(VarArg, KwdCod); + NmbLin = va_arg(VarArg, int); + + if(!strcmp(GmfKwdFmt[ KwdCod ][3], "sr")) + { + kwd->NmbTyp = va_arg(VarArg, int); + TypTab = va_arg(VarArg, int *); + + for(i=0;iNmbTyp;i++) + kwd->TypTab[i] = TypTab[i]; + } + + va_end(VarArg); + } + + /* Setup the kwd info */ + + ExpFmt(msh, KwdCod); + + if(!kwd->typ) + return(0); + else if(kwd->typ == InfKwd) + kwd->NmbLin = 1; + else + kwd->NmbLin = NmbLin; + + /* Store the next kwd position in binary file */ + + if( (msh->typ & Bin) && msh->NexKwdPos ) + { + CurPos = ftell(msh->hdl); + fseek(msh->hdl, msh->NexKwdPos, SEEK_SET); + SetPos(msh, CurPos); + fseek(msh->hdl, CurPos, SEEK_SET); + } + + /* Write the header */ + + if(msh->typ & Asc) + { + fprintf(msh->hdl, "\n%s\n", GmfKwdFmt[ KwdCod ][0]); + + if(kwd->typ != InfKwd) + fprintf(msh->hdl, "%d\n", kwd->NmbLin); + + /* In case of solution field, write the extended header */ + + if(kwd->typ == SolKwd) + { + fprintf(msh->hdl, "%d ", kwd->NmbTyp); + + for(i=0;iNmbTyp;i++) + fprintf(msh->hdl, "%d ", kwd->TypTab[i]); + + fprintf(msh->hdl, "\n\n"); + } + } + else + { + RecWrd(msh, (unsigned char *)&KwdCod); + msh->NexKwdPos = ftell(msh->hdl); + SetPos(msh, 0); + + if(kwd->typ != InfKwd) + RecWrd(msh, (unsigned char *)&kwd->NmbLin); + + /* In case of solution field, write the extended header at once */ + + if(kwd->typ == SolKwd) + { + RecWrd(msh, (unsigned char *)&kwd->NmbTyp); + + for(i=0;iNmbTyp;i++) + RecWrd(msh, (unsigned char *)&kwd->TypTab[i]); + } + } + msh->pos = 0; + return(kwd->NmbLin); +} + + +/*----------------------------------------------------------*/ +/* Read a full line from the current kwd */ +/*----------------------------------------------------------*/ + +void GmfGetLin(int MshIdx, int KwdCod, ...) +{ + int i, j; + float *FltSolTab; + double *DblSolTab; + va_list VarArg; + GmfMshSct *msh = GmfMshTab[ MshIdx ]; + KwdSct *kwd = &msh->KwdTab[ KwdCod ]; + + /* Start decoding the arguments */ + + va_start(VarArg, KwdCod); + + if(kwd->typ != SolKwd) + { + if(msh->ver == 1) + { + if(msh->typ & Asc) + { + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'r') + fscanf(msh->hdl, "%f", va_arg(VarArg, float *)); + else + fscanf(msh->hdl, "%d", va_arg(VarArg, int *)); + } + else + { + ScaBlk(msh, msh->buf, kwd->SolSiz); + + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'r') + *(va_arg(VarArg, float *)) = msh->FltBuf[i]; + else + *(va_arg(VarArg, int *)) = msh->IntBuf[i]; + } + } + else + { + if(msh->typ & Asc) + { + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'r') + fscanf(msh->hdl, "%lf", va_arg(VarArg, double *)); + else + fscanf(msh->hdl, "%d", va_arg(VarArg, int *)); + } + else + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'r') + ScaDblWrd(msh, (unsigned char *)va_arg(VarArg, double *)); + else + ScaWrd(msh, (unsigned char *)va_arg(VarArg, int *)); + } + } + else + { + if(msh->ver == 1) + { + FltSolTab = va_arg(VarArg, float *); + + if(msh->typ & Asc) + for(j=0;jSolSiz;j++) + fscanf(msh->hdl, "%f", &FltSolTab[j]); + else + ScaBlk(msh, (unsigned char *)FltSolTab, kwd->NmbWrd); + } + else + { + DblSolTab = va_arg(VarArg, double *); + + if(msh->typ & Asc) + for(j=0;jSolSiz;j++) + fscanf(msh->hdl, "%lf", &DblSolTab[j]); + else + for(j=0;jSolSiz;j++) + ScaDblWrd(msh, (unsigned char *)&DblSolTab[j]); + } + } + + va_end(VarArg); +} + + +/*----------------------------------------------------------*/ +/* Write a full line from the current kwd */ +/*----------------------------------------------------------*/ + +void GmfSetLin(int MshIdx, int KwdCod, ...) +{ + int i, j, pos, *IntBuf; + float *FltSolTab; + double *DblSolTab, *DblBuf; + va_list VarArg; + GmfMshSct *msh = GmfMshTab[ MshIdx ]; + KwdSct *kwd = &msh->KwdTab[ KwdCod ]; + + /* Start decoding the arguments */ + + va_start(VarArg, KwdCod); + + if(kwd->typ != SolKwd) + { + if(msh->ver == 1) + { + if(msh->typ & Asc) + { + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'r') + fprintf(msh->hdl, "%g ", (float)va_arg(VarArg, double)); + else + fprintf(msh->hdl, "%d ", va_arg(VarArg, int)); + } + else + { + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'r') + msh->FltBuf[i] = va_arg(VarArg, double); + else + msh->IntBuf[i] = va_arg(VarArg, int); + + RecBlk(msh, msh->buf, kwd->SolSiz); + } + } + else + { + if(msh->typ & Asc) + { + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'r') + fprintf(msh->hdl, "%.15lg ", va_arg(VarArg, double)); + else + fprintf(msh->hdl, "%d ", va_arg(VarArg, int)); + } + else + { + pos = 0; + + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'r') + { + DblBuf = (void *)&msh->buf[ pos ]; + *DblBuf = va_arg(VarArg, double); + pos += 8; + } + else + { + IntBuf = (void *)&msh->buf[ pos ]; + *IntBuf = va_arg(VarArg, int); + pos += 4; + } + RecBlk(msh, msh->buf, kwd->NmbWrd); + } + } + } + else + { + if(msh->ver == 1) + { + FltSolTab = va_arg(VarArg, float *); + + if(msh->typ & Asc) + for(j=0;jSolSiz;j++) + fprintf(msh->hdl, "%g ", FltSolTab[j]); + else + RecBlk(msh, (unsigned char *)FltSolTab, kwd->NmbWrd); + } + else + { + DblSolTab = va_arg(VarArg, double *); + + if(msh->typ & Asc) + for(j=0;jSolSiz;j++) + fprintf(msh->hdl, "%.15lg ", DblSolTab[j]); + else + RecBlk(msh, (unsigned char *)DblSolTab, kwd->NmbWrd); + } + } + + va_end(VarArg); + + if(msh->typ & Asc) + fprintf(msh->hdl, "\n"); +} + + +/*----------------------------------------------------------*/ +/* Private procedure for transmesh : copy a whole line */ +/*----------------------------------------------------------*/ + +void GmfCpyLin(int InpIdx, int OutIdx, int KwdCod) +{ + double d; + float f; + int i, a; + GmfMshSct *InpMsh = GmfMshTab[ InpIdx ], *OutMsh = GmfMshTab[ OutIdx ]; + KwdSct *kwd = &InpMsh->KwdTab[ KwdCod ]; + + for(i=0;iSolSiz;i++) + { + if(kwd->fmt[i] == 'r') + { + if(InpMsh->ver == 1) + { + if(InpMsh->typ & Asc) + fscanf(InpMsh->hdl, "%f", &f); + else + ScaWrd(InpMsh, (unsigned char *)&f); + + d = f; + } + else + { + if(InpMsh->typ & Asc) + fscanf(InpMsh->hdl, "%lf", &d); + else + ScaDblWrd(InpMsh, (unsigned char *)&d); + + f = (float)d; + } + + if(OutMsh->ver == 1) + if(OutMsh->typ & Asc) + fprintf(OutMsh->hdl, "%g ", f); + else + RecWrd(OutMsh, (unsigned char *)&f); + else + if(OutMsh->typ & Asc) + fprintf(OutMsh->hdl, "%.15g ", d); + else + RecDblWrd(OutMsh, (unsigned char *)&d); + } + else + { + if(InpMsh->typ & Asc) + fscanf(InpMsh->hdl, "%d", &a); + else + ScaWrd(InpMsh, (unsigned char *)&a); + + if(OutMsh->typ & Asc) + fprintf(OutMsh->hdl, "%d ", a); + else + RecWrd(OutMsh, (unsigned char *)&a); + } + } + + if(OutMsh->typ & Asc) + fprintf(OutMsh->hdl, "\n"); +} + + +/*----------------------------------------------------------*/ +/* Find every kw present in a meshfile */ +/*----------------------------------------------------------*/ + +static int ScaKwdTab(GmfMshSct *msh) +{ + int KwdCod; + long NexPos, CurPos, EndPos; + char str[ GmfStrSiz ]; + + if(msh->typ & Asc) + { + /* Scan each string in the file until the end */ + + while(fscanf(msh->hdl, "%s", str) != EOF) + { + /* Fast test in order to reject quickly the numeric values */ + + if(isalpha(str[0])) + { + /* Search which kwd code this string is associated with, + then get its header and save the curent position in file (just before the data) */ + + for(KwdCod=1; KwdCod<= GmfMaxKwd; KwdCod++) + if(!strcmp(str, GmfKwdFmt[ KwdCod ][0])) + { + ScaKwdHdr(msh, KwdCod); + break; + } + } + else if(str[0] == '#') + while(fgetc(msh->hdl) != '\n'); + } + } + else + { + /* Get file size */ + + CurPos = ftell(msh->hdl); + fseek(msh->hdl, 0, SEEK_END); + EndPos = ftell(msh->hdl); + fseek(msh->hdl, CurPos, SEEK_SET); + + /* Jump through kwd positions in the file */ + + do + { + /* Get the kwd code and the next kwd position */ + + ScaWrd(msh, (unsigned char *)&KwdCod); + NexPos = GetPos(msh); + + if(NexPos > EndPos) + return(0); + + /* Check if this kwd belongs to this mesh version */ + + if( (KwdCod >= 1) && (KwdCod <= GmfMaxKwd) ) + ScaKwdHdr(msh, KwdCod); + + /* Go to the next kwd */ + + if(NexPos) + fseek(msh->hdl, NexPos, SEEK_SET); + }while(NexPos && (KwdCod != GmfEnd)); + } + + return(1); +} + + +/*----------------------------------------------------------*/ +/* Read and setup the keyword's header */ +/*----------------------------------------------------------*/ + +static void ScaKwdHdr(GmfMshSct *msh, int KwdCod) +{ + int i; + KwdSct *kwd = &msh->KwdTab[ KwdCod ]; + + if(!strcmp("i", GmfKwdFmt[ KwdCod ][2])) + { + if(msh->typ & Asc) + fscanf(msh->hdl, "%d", &kwd->NmbLin); + else + ScaWrd(msh, (unsigned char *)&kwd->NmbLin); + } + else + kwd->NmbLin = 1; + + if(!strcmp("sr", GmfKwdFmt[ KwdCod ][3])) + { + if(msh->typ & Asc) + { + fscanf(msh->hdl, "%d", &kwd->NmbTyp); + + for(i=0;iNmbTyp;i++) + fscanf(msh->hdl, "%d", &kwd->TypTab[i]); + } + else + { + ScaWrd(msh, (unsigned char *)&kwd->NmbTyp); + + for(i=0;iNmbTyp;i++) + ScaWrd(msh, (unsigned char *)&kwd->TypTab[i]); + } + } + + ExpFmt(msh, KwdCod); + kwd->pos = ftell(msh->hdl); +} + + +/*----------------------------------------------------------*/ +/* Expand the compacted format and compute the line size */ +/*----------------------------------------------------------*/ + +static void ExpFmt(GmfMshSct *msh, int KwdCod) +{ + int i, j, TmpSiz=0; + char chr, *InpFmt = GmfKwdFmt[ KwdCod ][3]; + KwdSct *kwd = &msh->KwdTab[ KwdCod ]; + + /* Set the kwd's type */ + + if(!strlen(GmfKwdFmt[ KwdCod ][2])) + kwd->typ = InfKwd; + else if(!strcmp(InpFmt, "sr")) + kwd->typ = SolKwd; + else + kwd->typ = RegKwd; + + /* Get the solution-field's size */ + + if(kwd->typ == SolKwd) + for(i=0;iNmbTyp;i++) + switch(kwd->TypTab[i]) + { + case GmfSca : TmpSiz += 1; break; + case GmfVec : TmpSiz += msh->dim; break; + case GmfSymMat : TmpSiz += (msh->dim * (msh->dim+1)) / 2; break; + case GmfMat : TmpSiz += msh->dim * msh->dim; break; + } + + /* Scan each character from the format string */ + + i = kwd->SolSiz = kwd->NmbWrd = 0; + + while(i < strlen(InpFmt)) + { + chr = InpFmt[ i++ ]; + + if(chr == 'd') + { + chr = InpFmt[i++]; + + for(j=0;jdim;j++) + kwd->fmt[ kwd->SolSiz++ ] = chr; + } + else if(chr == 's') + { + chr = InpFmt[i++]; + + for(j=0;jfmt[ kwd->SolSiz++ ] = chr; + } + else + kwd->fmt[ kwd->SolSiz++ ] = chr; + } + + for(i=0;iSolSiz;i++) + if(kwd->fmt[i] == 'i') + kwd->NmbWrd++; + else if(msh->ver >= 2) + kwd->NmbWrd += 2; + else + kwd->NmbWrd++; +} + + +/*----------------------------------------------------------*/ +/* Read a four bytes word from a mesh file */ +/*----------------------------------------------------------*/ + +static void ScaWrd(GmfMshSct *msh, unsigned char *wrd) +{ + unsigned char swp; + + fread(wrd, WrdSiz, 1, msh->hdl); + + if(msh->cod == 1) + return; + + swp = wrd[3]; + wrd[3] = wrd[0]; + wrd[0] = swp; + + swp = wrd[2]; + wrd[2] = wrd[1]; + wrd[1] = swp; +} + + +/*----------------------------------------------------------*/ +/* Read an eight bytes word from a mesh file */ +/*----------------------------------------------------------*/ + +static void ScaDblWrd(GmfMshSct *msh, unsigned char *wrd) +{ + int i; + unsigned char swp; + + fread(wrd, WrdSiz, 2, msh->hdl); + + if(msh->cod == 1) + return; + + for(i=0;i<4;i++) + { + swp = wrd[7-i]; + wrd[7-i] = wrd[i]; + wrd[i] = swp; + } +} + + +/*----------------------------------------------------------*/ +/* Read ablock of four bytes word from a mesh file */ +/*----------------------------------------------------------*/ + +static void ScaBlk(GmfMshSct *msh, unsigned char *blk, int siz) +{ + int i, j; + unsigned char swp, *wrd; + + fread(blk, WrdSiz, siz, msh->hdl); + + if(msh->cod == 1) + return; + + for(i=0;iver >= 3) + ScaDblWrd(msh, (unsigned char*)&pos); + else + { + ScaWrd(msh, (unsigned char*)&IntVal); + pos = IntVal; + } + + return(pos); +} + + +/*----------------------------------------------------------*/ +/* Write a four bytes word to a mesh file */ +/*----------------------------------------------------------*/ + +static void RecWrd(GmfMshSct *msh, unsigned char *wrd) +{ + fwrite(wrd, WrdSiz, 1, msh->hdl); +} + + +/*----------------------------------------------------------*/ +/* Write an eight bytes word to a mesh file */ +/*----------------------------------------------------------*/ + +static void RecDblWrd(GmfMshSct *msh, unsigned char *wrd) +{ + fwrite(wrd, WrdSiz, 2, msh->hdl); +} + + +/*----------------------------------------------------------*/ +/* Write a block of four bytes word to a mesh file */ +/*----------------------------------------------------------*/ + +static void RecBlk(GmfMshSct *msh, unsigned char *blk, int siz) +{ + /* Copy this line-block into the main mesh buffer */ + + if(siz) + { + memcpy(&msh->blk[ msh->pos ], blk, siz * WrdSiz); + msh->pos += siz * WrdSiz; + } + + /* When the buffer is full or this procedure is called with a 0 size, flush the cache on disk */ + + if( (msh->pos > BufSiz) || (!siz && msh->pos) ) + { + fwrite(msh->blk, 1, msh->pos, msh->hdl); + msh->pos = 0; + } +} + + +/*----------------------------------------------------------*/ +/* Read a 4 or 8 bytes position in mesh file */ +/*----------------------------------------------------------*/ + +static void SetPos(GmfMshSct *msh, long pos) +{ + int IntVal; + + if(msh->ver >= 3) + RecDblWrd(msh, (unsigned char*)&pos); + else + { + IntVal = pos; + RecWrd(msh, (unsigned char*)&IntVal); + } +} diff --git a/src/GHS3DPlugin/libmesh5.h b/src/GHS3DPlugin/libmesh5.h new file mode 100755 index 0000000..cfaf9fb --- /dev/null +++ b/src/GHS3DPlugin/libmesh5.h @@ -0,0 +1,152 @@ + + +/*----------------------------------------------------------*/ +/* */ +/* LIBMESH V 5.45 */ +/* */ +/*----------------------------------------------------------*/ +/* */ +/* Description: handle .meshb file format I/O */ +/* Author: Loic MARECHAL */ +/* Creation date: feb 16 2007 */ +/* Last modification: sep 27 2010 */ +/* */ +/*----------------------------------------------------------*/ + + +/*----------------------------------------------------------*/ +/* Defines */ +/*----------------------------------------------------------*/ + +#define GmfStrSiz 1024 +#define GmfMaxTyp 1000 +#define GmfMaxKwd 79 +#define GmfMshVer 1 +#define GmfRead 1 +#define GmfWrite 2 +#define GmfSca 1 +#define GmfVec 2 +#define GmfSymMat 3 +#define GmfMat 4 +#define GmfFloat 1 +#define GmfDouble 2 + +enum GmfKwdCod +{ + GmfReserved1, \ + GmfVersionFormatted, \ + GmfReserved2, \ + GmfDimension, \ + GmfVertices, \ + GmfEdges, \ + GmfTriangles, \ + GmfQuadrilaterals, \ + GmfTetrahedra, \ + GmfPrisms, \ + GmfHexahedra, \ + GmfIterationsAll, \ + GmfTimesAll, \ + GmfCorners, \ + GmfRidges, \ + GmfRequiredVertices, \ + GmfRequiredEdges, \ + GmfRequiredTriangles, \ + GmfRequiredQuadrilaterals, \ + GmfTangentAtEdgeVertices, \ + GmfNormalAtVertices, \ + GmfNormalAtTriangleVertices, \ + GmfNormalAtQuadrilateralVertices, \ + GmfAngleOfCornerBound, \ + GmfTrianglesP2, \ + GmfEdgesP2, \ + GmfSolAtPyramids, \ + GmfQuadrilateralsQ2, \ + GmfISolAtPyramids, \ + GmfReserved6, \ + GmfTetrahedraP2, \ + GmfReserved7, \ + GmfReserved8, \ + GmfHexahedraQ2, \ + GmfReserved9, \ + GmfReserved10, \ + GmfReserved17, \ + GmfReserved18, \ + GmfReserved19, \ + GmfReserved20, \ + GmfReserved21, \ + GmfReserved22, \ + GmfReserved23, \ + GmfReserved24, \ + GmfReserved25, \ + GmfReserved26, \ + GmfPolyhedra, \ + GmfPolygons, \ + GmfReserved29, \ + GmfPyramids, \ + GmfBoundingBox, \ + GmfBody, \ + GmfPrivateTable, \ + GmfReserved33, \ + GmfEnd, \ + GmfReserved34, \ + GmfReserved35, \ + GmfReserved36, \ + GmfReserved37, \ + GmfTangents, \ + GmfNormals, \ + GmfTangentAtVertices, \ + GmfSolAtVertices, \ + GmfSolAtEdges, \ + GmfSolAtTriangles, \ + GmfSolAtQuadrilaterals, \ + GmfSolAtTetrahedra, \ + GmfSolAtPrisms, \ + GmfSolAtHexahedra, \ + GmfDSolAtVertices, \ + GmfISolAtVertices, \ + GmfISolAtEdges, \ + GmfISolAtTriangles, \ + GmfISolAtQuadrilaterals, \ + GmfISolAtTetrahedra, \ + GmfISolAtPrisms, \ + GmfISolAtHexahedra, \ + GmfIterations, \ + GmfTime, \ + GmfReserved38 +}; + + +/*----------------------------------------------------------*/ +/* External procedures */ +/*----------------------------------------------------------*/ + +extern int GmfOpenMesh(const char *, int, ...); +extern int GmfCloseMesh(int); +extern int GmfStatKwd(int, int, ...); +extern int GmfGotoKwd(int, int); +extern int GmfSetKwd(int, int, ...); +extern void GmfGetLin(int, int, ...); +extern void GmfSetLin(int, int, ...); + + +/*----------------------------------------------------------*/ +/* Fortran 77 API */ +/*----------------------------------------------------------*/ + +#if defined(F77_NO_UNDER_SCORE) +#define call(x) x +#else +#define call(x) x ## _ +#endif + + +/*----------------------------------------------------------*/ +/* Transmesh private API */ +/*----------------------------------------------------------*/ + +#ifdef TRANSMESH + +extern char *GmfKwdFmt[ GmfMaxKwd + 1 ][4]; +extern int GmfCpyLin(int, int, int); + +#endif diff --git a/src/GHS3DPlugin_Defs.hxx b/src/GHS3DPlugin_Defs.hxx deleted file mode 100644 index 5476008..0000000 --- a/src/GHS3DPlugin_Defs.hxx +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2004-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 : GHS3DPlugin_Defs.hxx -// Author : Alexander A. BORODIN -// -#ifndef _GHS3DPlugin_DEFS_HXX_ -#define _GHS3DPlugin_DEFS_HXX_ - -#ifdef WIN32 - #ifdef GHS3DPLUGIN_EXPORTS - #define GHS3DPLUGIN_EXPORT __declspec( dllexport ) - #else - #define GHS3DPLUGIN_EXPORT __declspec( dllimport ) - #endif -#else - #define GHS3DPLUGIN_EXPORT -#endif - -#endif diff --git a/src/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin_GHS3D.cxx deleted file mode 100644 index 195de5c..0000000 --- a/src/GHS3DPlugin_GHS3D.cxx +++ /dev/null @@ -1,1698 +0,0 @@ -// Copyright (C) 2004-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 : GHS3DPlugin_GHS3D.cxx -// Created : -// Author : Edward AGAPOV, modified by Lioka RAZAFINDRAZAKA (CEA) 09/02/2007 -// Project : SALOME -// $Header$ -//============================================================================= -// -using namespace std; - -#include "GHS3DPlugin_GHS3D.hxx" -#include "GHS3DPlugin_Hypothesis.hxx" - -#include "SMESH_Gen.hxx" -#include "SMESH_Mesh.hxx" -#include "SMESH_Comment.hxx" -#include "SMESH_MesherHelper.hxx" -#include "SMESH_MeshEditor.hxx" - -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" -#include "SMDS_FaceOfNodes.hxx" -#include "SMDS_VolumeOfNodes.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -//#include -//#include - -#include "utilities.h" - -#ifndef WIN32 -#include -#endif - -//#include - - -#define castToNode(n) static_cast( n ); - -#ifdef _DEBUG_ -#define DUMP(txt) \ -// cout << txt -#else -#define DUMP(txt) -#endif - -extern "C" -{ -#ifndef WNT -#include -#include -#endif -#include -#include -} - -#define HOLE_ID -1 - -//============================================================================= -/*! - * - */ -//============================================================================= - -GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_3D_Algo(hypId, studyId, gen) -{ - MESSAGE("GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D"); - _name = "GHS3D_3D"; - _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type - _onlyUnaryInput = false; // Compute() will be called on a compound of solids - _iShape=0; - _nbShape=0; - _compatibleHypothesis.push_back("GHS3D_Parameters"); - _requireShape = false; // can work without shape -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -GHS3DPlugin_GHS3D::~GHS3DPlugin_GHS3D() -{ - MESSAGE("GHS3DPlugin_GHS3D::~GHS3DPlugin_GHS3D"); -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -bool GHS3DPlugin_GHS3D::CheckHypothesis ( SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape, - Hypothesis_Status& aStatus ) -{ - aStatus = SMESH_Hypothesis::HYP_OK; - - // there is only one compatible Hypothesis so far - _hyp = 0; - _keepFiles = false; - const list & hyps = GetUsedHypothesis(aMesh, aShape); - if ( !hyps.empty() ) - _hyp = static_cast ( hyps.front() ); - if ( _hyp ) - _keepFiles = _hyp->GetKeepFiles(); - - return true; -} - -//======================================================================= -//function : findShape -//purpose : -//======================================================================= - -static TopoDS_Shape findShape(const SMDS_MeshNode *aNode[], - TopoDS_Shape aShape, - const TopoDS_Shape shape[], - double** box, - const int nShape, - TopAbs_State * state = 0) -{ - gp_XYZ aPnt(0,0,0); - int j, iShape, nbNode = 4; - - for ( j=0; jX(), aNode[j]->Y(), aNode[j]->Z() ); - aPnt /= nbNode; - - BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion()); - if (state) *state = SC.State(); - if ( SC.State() != TopAbs_IN || aShape.IsNull() || aShape.ShapeType() != TopAbs_SOLID) { - for (iShape = 0; iShape < nShape; iShape++) { - aShape = shape[iShape]; - if ( !( aPnt.X() < box[iShape][0] || box[iShape][1] < aPnt.X() || - aPnt.Y() < box[iShape][2] || box[iShape][3] < aPnt.Y() || - aPnt.Z() < box[iShape][4] || box[iShape][5] < aPnt.Z()) ) { - BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion()); - if (state) *state = SC.State(); - if (SC.State() == TopAbs_IN) - break; - } - } - } - return aShape; -} - -//======================================================================= -//function : readMapIntLine -//purpose : -//======================================================================= - -static char* readMapIntLine(char* ptr, int tab[]) { - long int intVal; - cout << endl; - - for ( int i=0; i<17; i++ ) { - intVal = strtol(ptr, &ptr, 10); - if ( i < 3 ) - tab[i] = intVal; - } - return ptr; -} - -//======================================================================= -//function : countShape -//purpose : -//======================================================================= - -template < class Mesh, class Shape > -static int countShape( Mesh* mesh, Shape shape ) { - TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape ); - int nbShape = 0; - for ( ; expShape.More(); expShape.Next() ) { - nbShape++; - } - return nbShape; -} - -//======================================================================= -//function : writeFaces -//purpose : -//======================================================================= - -static bool writeFaces (ofstream & theFile, - SMESHDS_Mesh * theMesh, - const map & theSmdsToGhs3dIdMap) -{ - // record structure: - // - // NB_ELEMS DUMMY_INT - // Loop from 1 to NB_ELEMS - // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT - - int nbShape = countShape( theMesh, TopAbs_FACE ); - - int *tabID; tabID = new int[nbShape]; - TopoDS_Shape *tabShape; tabShape = new TopoDS_Shape[nbShape]; - TopoDS_Shape aShape; - SMESHDS_SubMesh* theSubMesh; - const SMDS_MeshElement* aFace; - const char* space = " "; - const int dummyint = 0; - map::const_iterator itOnMap; - SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace; - int shapeID, nbNodes, aSmdsID; - bool idFound; - - cout << " " << theMesh->NbFaces() << " shapes of 2D dimension" << endl; - cout << endl; - - theFile << space << theMesh->NbFaces() << space << dummyint << endl; - - TopExp_Explorer expface( theMesh->ShapeToMesh(), TopAbs_FACE ); - for ( int i = 0; expface.More(); expface.Next(), i++ ) { - tabID[i] = 0; - aShape = expface.Current(); - shapeID = theMesh->ShapeToIndex( aShape ); - idFound = false; - for ( int j=0; j<=i; j++) { - if ( shapeID == tabID[j] ) { - idFound = true; - break; - } - } - if ( ! idFound ) { - tabID[i] = shapeID; - tabShape[i] = aShape; - } - } - for ( int i =0; i < nbShape; i++ ) { - if ( tabID[i] != 0 ) { - aShape = tabShape[i]; - shapeID = tabID[i]; - theSubMesh = theMesh->MeshElements( aShape ); - if ( !theSubMesh ) continue; - itOnSubMesh = theSubMesh->GetElements(); - while ( itOnSubMesh->more() ) { - aFace = itOnSubMesh->next(); - nbNodes = aFace->NbNodes(); - - theFile << space << nbNodes; - - itOnSubFace = aFace->nodesIterator(); - while ( itOnSubFace->more() ) { - // find GHS3D ID - aSmdsID = itOnSubFace->next()->GetID(); - itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID ); - ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() ); - - theFile << space << (*itOnMap).second; - } - - // (NB_NODES + 1) times: DUMMY_INT - for ( int j=0; j<=nbNodes; j++) - theFile << space << dummyint; - - theFile << endl; - } - } - } - - delete [] tabID; - delete [] tabShape; - - return true; -} - -//======================================================================= -//function : writeFaces -//purpose : Write Faces in case if generate 3D mesh w/o geometry -//======================================================================= - -static bool writeFaces (ofstream & theFile, - SMESHDS_Mesh * theMesh, - vector & theNodeByGhs3dId) -{ - // record structure: - // - // NB_ELEMS DUMMY_INT - // Loop from 1 to NB_ELEMS - // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT - - - int nbFaces = 0; - list< const SMDS_MeshElement* > faces; - list< const SMDS_MeshElement* >::iterator f; - map< const SMDS_MeshNode*,int >::iterator it; - SMDS_ElemIteratorPtr nodeIt; - const SMDS_MeshElement* elem; - int nbNodes; - - const char* space = " "; - const int dummyint = 0; - - //get all faces from mesh - SMDS_FaceIteratorPtr eIt = theMesh->facesIterator(); - while ( eIt->more() ) { - const SMDS_MeshElement* elem = eIt->next(); - if ( !elem ) - return false; - faces.push_back( elem ); - nbFaces++; - } - - if ( nbFaces == 0 ) - return false; - - cout << "The initial 2D mesh contains " << nbFaces << " faces and "; - - // NB_ELEMS DUMMY_INT - theFile << space << nbFaces << space << dummyint << endl; - - // Loop from 1 to NB_ELEMS - - map aNodeToGhs3dIdMap; - f = faces.begin(); - for ( ; f != faces.end(); ++f ) - { - // NB_NODES PER FACE - elem = *f; - nbNodes = elem->NbNodes(); - theFile << space << nbNodes; - - // NODE_NB_1 NODE_NB_2 ... - nodeIt = elem->nodesIterator(); - while ( nodeIt->more() ) - { - // find GHS3D ID - const SMDS_MeshNode* node = castToNode( nodeIt->next() ); - int newId = aNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1 - it = aNodeToGhs3dIdMap.insert( make_pair( node, newId )).first; - theFile << space << it->second; - } - - // (NB_NODES + 1) times: DUMMY_INT - for ( int i=0; i<=nbNodes; i++) - theFile << space << dummyint; - - theFile << endl; - } - - // put nodes to theNodeByGhs3dId vector - theNodeByGhs3dId.resize( aNodeToGhs3dIdMap.size() ); - map::const_iterator n2id = aNodeToGhs3dIdMap.begin(); - for ( ; n2id != aNodeToGhs3dIdMap.end(); ++ n2id) - { - theNodeByGhs3dId[ n2id->second - 1 ] = n2id->first; // ghs3d ids count from 1 - } - - return true; -} - -//======================================================================= -//function : writePoints -//purpose : -//======================================================================= - -static bool writePoints (ofstream & theFile, - SMESHDS_Mesh * theMesh, - map & theSmdsToGhs3dIdMap, - map & theGhs3dIdToNodeMap) -{ - // record structure: - // - // NB_NODES - // Loop from 1 to NB_NODES - // X Y Z DUMMY_INT - - int nbNodes = theMesh->NbNodes(); - if ( nbNodes == 0 ) - return false; - - const char* space = " "; - const int dummyint = 0; - - int aGhs3dID = 1; - SMDS_NodeIteratorPtr it = theMesh->nodesIterator(); - const SMDS_MeshNode* node; - - // NB_NODES - theFile << space << nbNodes << endl; - cout << endl; - cout << "The initial 2D mesh contains :" << endl; - cout << " " << nbNodes << " vertices" << endl; - - // Loop from 1 to NB_NODES - - while ( it->more() ) - { - node = it->next(); - theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID )); - theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node )); - aGhs3dID++; - - // X Y Z DUMMY_INT - theFile - << space << node->X() - << space << node->Y() - << space << node->Z() - << space << dummyint; - - theFile << endl; - } - - return true; -} - -//======================================================================= -//function : writePoints -//purpose : -//======================================================================= - -static bool writePoints (ofstream & theFile, - SMESHDS_Mesh * theMesh, - const vector & theNodeByGhs3dId) -{ - // record structure: - // - // NB_NODES - // Loop from 1 to NB_NODES - // X Y Z DUMMY_INT - - //int nbNodes = theMesh->NbNodes(); - int nbNodes = theNodeByGhs3dId.size(); - if ( nbNodes == 0 ) - return false; - - const char* space = " "; - const int dummyint = 0; - - const SMDS_MeshNode* node; - - // NB_NODES - theFile << space << nbNodes << endl; - cout << nbNodes << " nodes" << endl; - - // Loop from 1 to NB_NODES - - vector::const_iterator nodeIt = theNodeByGhs3dId.begin(); - vector::const_iterator after = theNodeByGhs3dId.end(); - for ( ; nodeIt != after; ++nodeIt ) - { - node = *nodeIt; - - // X Y Z DUMMY_INT - theFile - << space << node->X() - << space << node->Y() - << space << node->Z() - << space << dummyint; - - theFile << endl; - } - - return true; -} - -//======================================================================= -//function : findShapeID -//purpose : find the solid corresponding to GHS3D sub-domain following -// the technique proposed in GHS3D manual in chapter -// "B.4 Subdomain (sub-region) assignment" -//======================================================================= - -static int findShapeID(SMESH_Mesh& mesh, - const SMDS_MeshNode* node1, - const SMDS_MeshNode* node2, - const SMDS_MeshNode* node3, - const bool toMeshHoles) -{ - const int invalidID = 0; - SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); - - // face th enodes belong to - const SMDS_MeshElement * face = meshDS->FindFace(node1,node2,node3); - if ( !face ) - return invalidID; - - // geom face the face assigned to - SMESH_MeshEditor editor(&mesh); - int geomFaceID = editor.FindShape( face ); - if ( !geomFaceID ) - return invalidID; - TopoDS_Shape shape = meshDS->IndexToShape( geomFaceID ); - if ( shape.IsNull() || shape.ShapeType() != TopAbs_FACE ) - return invalidID; - TopoDS_Face geomFace = TopoDS::Face( shape ); - - // solids bounded by geom face - TopTools_IndexedMapOfShape solids, shells; - TopTools_ListIteratorOfListOfShape ansIt = mesh.GetAncestors(geomFace); - for ( ; ansIt.More(); ansIt.Next() ) { - switch ( ansIt.Value().ShapeType() ) { - case TopAbs_SOLID: - solids.Add( ansIt.Value() ); break; - case TopAbs_SHELL: - shells.Add( ansIt.Value() ); break; - default:; - } - } - // analyse found solids - if ( solids.Extent() == 0 || shells.Extent() == 0) - return invalidID; - - const TopoDS_Solid& solid1 = TopoDS::Solid( solids(1) ); - if ( solids.Extent() == 1 ) - { - if ( toMeshHoles ) - return meshDS->ShapeToIndex( solid1 ); - - // - are we at a hole boundary face? - if ( shells(1).IsSame( BRepTools::OuterShell( solid1 )) ) - return meshDS->ShapeToIndex( solid1 ); // - no - } - - // find orientation of geom face within the first solid - TopExp_Explorer fExp( solid1, TopAbs_FACE ); - for ( ; fExp.More(); fExp.Next() ) - if ( geomFace.IsSame( fExp.Current() )) { - geomFace = TopoDS::Face( fExp.Current() ); - break; - } - if ( !fExp.More() ) - return invalidID; // face not found - - // find UV of node1 on geomFace - SMESH_MesherHelper helper( mesh ); - gp_XY uv = helper.GetNodeUV( geomFace, node1 ); - - // check that uv is correct - gp_Pnt node1Pnt ( node1->X(), node1->Y(), node1->Z() ); - double tol = BRep_Tool::Tolerance( geomFace ); - BRepAdaptor_Surface surface( geomFace ); - if ( node1Pnt.Distance( surface.Value( uv.X(), uv.Y() )) > 2 * tol ) { - // project node1 onto geomFace to get right UV - GeomAPI_ProjectPointOnSurf projector( node1Pnt, surface.Surface().Surface() ); - if ( !projector.IsDone() || projector.NbPoints() < 1 ) - return invalidID; - Quantity_Parameter U,V; - projector.LowerDistanceParameters(U,V); - uv = gp_XY( U,V ); - } - // normale to face at node1 - gp_Pnt node2Pnt ( node2->X(), node2->Y(), node2->Z() ); - gp_Pnt node3Pnt ( node3->X(), node3->Y(), node3->Z() ); - gp_Vec vec12( node1Pnt, node2Pnt ); - gp_Vec vec13( node1Pnt, node3Pnt ); - gp_Vec meshNormal = vec12 ^ vec13; - if ( meshNormal.SquareMagnitude() < DBL_MIN ) - return invalidID; - - // normale to geomFace at UV - gp_Vec du, dv; - surface.D1( uv.X(), uv.Y(), node1Pnt, du, dv ); - gp_Vec geomNormal = du ^ dv; - if ( geomNormal.SquareMagnitude() < DBL_MIN ) - return findShapeID( mesh, node2, node3, node1, toMeshHoles ); - if ( geomFace.Orientation() == TopAbs_REVERSED ) - geomNormal.Reverse(); - - // compare normals - bool isReverse = ( meshNormal * geomNormal ) < 0; - if ( !isReverse ) - return meshDS->ShapeToIndex( solid1 ); - - if ( solids.Extent() == 1 ) - return HOLE_ID; // we are inside a hole - else - return meshDS->ShapeToIndex( solids(2) ); -} - -//======================================================================= -//function : readResultFile -//purpose : -//======================================================================= - -static bool readResultFile(const int fileOpen, - SMESH_Mesh& theMesh, - TopoDS_Shape tabShape[], - double** tabBox, - const int nbShape, - map & theGhs3dIdToNodeMap, - bool toMeshHoles) -{ - struct stat status; - size_t length; - - char *ptr, *mapPtr; - char *tetraPtr; - char *shapePtr; - - SMESHDS_Mesh* theMeshDS = theMesh.GetMeshDS(); - - int fileStat; - int nbElems, nbNodes, nbInputNodes; - int nodeId/*, triangleId*/; - int nbTriangle; - int ID, shapeID, ghs3dShapeID; - int IdShapeRef = 1; - int compoundID = - nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() ); - - int *tab, *tabID, *nodeID, *nodeAssigne; - double *coord; - const SMDS_MeshNode **node; - - tab = new int[3]; - //tabID = new int[nbShape]; - nodeID = new int[4]; - coord = new double[3]; - node = new const SMDS_MeshNode*[4]; - - TopoDS_Shape aSolid; - SMDS_MeshNode * aNewNode; - map ::iterator itOnNode; - SMDS_MeshElement* aTet; -#ifdef _DEBUG_ - set shapeIDs; -#endif - - // Read the file state - fileStat = fstat(fileOpen, &status); - length = status.st_size; - - // Mapping the result file into memory - ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0); - mapPtr = ptr; - - ptr = readMapIntLine(ptr, tab); - tetraPtr = ptr; - - nbElems = tab[0]; - nbNodes = tab[1]; - nbInputNodes = tab[2]; - - nodeAssigne = new int[ nbNodes+1 ]; - - if (nbShape > 0) - aSolid = tabShape[0]; - - // Reading the nodeId - for (int i=0; i < 4*nbElems; i++) - nodeId = strtol(ptr, &ptr, 10); - - // Reading the nodeCoor and update the nodeMap - for (int iNode=1; iNode <= nbNodes; iNode++) { - for (int iCoor=0; iCoor < 3; iCoor++) - coord[ iCoor ] = strtod(ptr, &ptr); - nodeAssigne[ iNode ] = 1; - if ( iNode > nbInputNodes ) { - nodeAssigne[ iNode ] = 0; - aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] ); - theGhs3dIdToNodeMap.insert(theGhs3dIdToNodeMap.end(), make_pair( iNode, aNewNode )); - } - } - - // Reading the number of triangles which corresponds to the number of sub-domains - nbTriangle = strtol(ptr, &ptr, 10); - - tabID = new int[nbTriangle]; - for (int i=0; i < nbTriangle; i++) { - tabID[i] = 0; - // find the solid corresponding to GHS3D sub-domain following - // the technique proposed in GHS3D manual in chapter - // "B.4 Subdomain (sub-region) assignment" - int nodeId1 = strtol(ptr, &ptr, 10); - int nodeId2 = strtol(ptr, &ptr, 10); - int nodeId3 = strtol(ptr, &ptr, 10); - if ( nbTriangle > 1 ) { - const SMDS_MeshNode* n1 = theGhs3dIdToNodeMap[ nodeId1 ]; - const SMDS_MeshNode* n2 = theGhs3dIdToNodeMap[ nodeId2 ]; - const SMDS_MeshNode* n3 = theGhs3dIdToNodeMap[ nodeId3 ]; - try { - OCC_CATCH_SIGNALS; - tabID[i] = findShapeID( theMesh, n1, n2, n3, toMeshHoles ); -#ifdef _DEBUG_ - cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << endl; -#endif - } catch ( Standard_Failure ) { - } catch (...) {} - } - } - - shapePtr = ptr; - - if ( nbTriangle <= nbShape ) // no holes - toMeshHoles = true; // not avoid creating tetras in holes - - // Associating the tetrahedrons to the shapes - shapeID = compoundID; - for (int iElem = 0; iElem < nbElems; iElem++) { - for (int iNode = 0; iNode < 4; iNode++) { - ID = strtol(tetraPtr, &tetraPtr, 10); - itOnNode = theGhs3dIdToNodeMap.find(ID); - node[ iNode ] = itOnNode->second; - nodeID[ iNode ] = ID; - } - // We always run GHS3D with "to mesh holes'==TRUE but we must not create - // tetras within holes depending on hypo option, - // so we first check if aTet is inside a hole and then create it - //aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] ); - if ( nbTriangle > 1 ) { - shapeID = HOLE_ID; // negative shapeID means not to create tetras if !toMeshHoles - ghs3dShapeID = strtol(shapePtr, &shapePtr, 10) - IdShapeRef; - if ( tabID[ ghs3dShapeID ] == 0 ) { - TopAbs_State state; - aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state); - if ( toMeshHoles || state == TopAbs_IN ) - shapeID = theMeshDS->ShapeToIndex( aSolid ); - tabID[ ghs3dShapeID ] = shapeID; - } - else - shapeID = tabID[ ghs3dShapeID ]; - } - else if ( nbShape > 1 ) { - // Case where nbTriangle == 1 while nbShape == 2 encountered - // with compound of 2 boxes and "To mesh holes"==False, - // so there are no subdomains specified for each tetrahedron. - // Try to guess a solid by a node already bound to shape - shapeID = 0; - for ( int i=0; i<4 && shapeID==0; i++ ) { - if ( nodeAssigne[ nodeID[i] ] == 1 && - node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE && - node[i]->GetPosition()->GetShapeId() > 1 ) - { - shapeID = node[i]->GetPosition()->GetShapeId(); - } - } - if ( shapeID==0 ) { - aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape); - shapeID = theMeshDS->ShapeToIndex( aSolid ); - } - } - // set new nodes and tetrahedron onto the shape - for ( int i=0; i<4; i++ ) { - if ( nodeAssigne[ nodeID[i] ] == 0 ) { - if ( shapeID != HOLE_ID ) - theMeshDS->SetNodeInVolume( node[i], shapeID ); - nodeAssigne[ nodeID[i] ] = shapeID; - } - } - if ( toMeshHoles || shapeID != HOLE_ID ) { - aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] ); - theMeshDS->SetMeshElementOnShape( aTet, shapeID ); - } -#ifdef _DEBUG_ - shapeIDs.insert( shapeID ); -#endif - } - // Remove nodes of tetras inside holes if !toMeshHoles - if ( !toMeshHoles ) { - itOnNode = theGhs3dIdToNodeMap.find( nbInputNodes ); - for ( ; itOnNode != theGhs3dIdToNodeMap.end(); ++itOnNode) { - ID = itOnNode->first; - if ( nodeAssigne[ ID ] == HOLE_ID ) - theMeshDS->RemoveFreeNode( itOnNode->second, 0 ); - } - } - - if ( nbElems ) - cout << nbElems << " tetrahedrons have been associated to " << nbShape << " shapes" << endl; - munmap(mapPtr, length); - close(fileOpen); - - delete [] tab; - delete [] tabID; - delete [] nodeID; - delete [] coord; - delete [] node; - delete [] nodeAssigne; - -#ifdef _DEBUG_ - if ( shapeIDs.size() != nbShape ) { - cout << "Only " << shapeIDs.size() << " solids of " << nbShape << " found" << endl; - for (int i=0; iShapeToIndex( tabShape[i] ); - if ( shapeIDs.find( shapeID ) == shapeIDs.end() ) - cout << " Solid #" << shapeID << " not found" << endl; - } - } -#endif - - return true; -} - -//======================================================================= -//function : readResultFile -//purpose : -//======================================================================= - -static bool readResultFile(const int fileOpen, - SMESHDS_Mesh* theMeshDS, - TopoDS_Shape aSolid, - vector & theNodeByGhs3dId) { - - struct stat status; - size_t length; - - char *ptr, *mapPtr; - char *tetraPtr; - char *shapePtr; - - int fileStat; - int nbElems, nbNodes, nbInputNodes; - int nodeId, triangleId; - int nbTriangle; - int ID, shapeID; - - int *tab; - double *coord; - const SMDS_MeshNode **node; - - tab = new int[3]; - coord = new double[3]; - node = new const SMDS_MeshNode*[4]; - - SMDS_MeshNode * aNewNode; - map ::iterator IdNode; - SMDS_MeshElement* aTet; - - // Read the file state - fileStat = fstat(fileOpen, &status); - length = status.st_size; - - // Mapping the result file into memory - ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0); - mapPtr = ptr; - - ptr = readMapIntLine(ptr, tab); - tetraPtr = ptr; - - nbElems = tab[0]; - nbNodes = tab[1]; - nbInputNodes = tab[2]; - - theNodeByGhs3dId.resize( nbNodes ); - - // Reading the nodeId - for (int i=0; i < 4*nbElems; i++) - nodeId = strtol(ptr, &ptr, 10); - - // Reading the nodeCoor and update the nodeMap - shapeID = theMeshDS->ShapeToIndex( aSolid ); - for (int iNode=0; iNode < nbNodes; iNode++) { - for (int iCoor=0; iCoor < 3; iCoor++) - coord[ iCoor ] = strtod(ptr, &ptr); - if ((iNode+1) > nbInputNodes) { - aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] ); - theMeshDS->SetNodeInVolume( aNewNode, shapeID ); - theNodeByGhs3dId[ iNode ] = aNewNode; - } - } - - // Reading the triangles - nbTriangle = strtol(ptr, &ptr, 10); - - for (int i=0; i < 3*nbTriangle; i++) - triangleId = strtol(ptr, &ptr, 10); - - shapePtr = ptr; - - // Associating the tetrahedrons to the shapes - for (int iElem = 0; iElem < nbElems; iElem++) { - for (int iNode = 0; iNode < 4; iNode++) { - ID = strtol(tetraPtr, &tetraPtr, 10); - node[ iNode ] = theNodeByGhs3dId[ ID-1 ]; - } - aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] ); - shapeID = theMeshDS->ShapeToIndex( aSolid ); - theMeshDS->SetMeshElementOnShape( aTet, shapeID ); - } - if ( nbElems ) - cout << nbElems << " tetrahedrons have been associated to " << nbTriangle << " shapes" << endl; - munmap(mapPtr, length); - close(fileOpen); - - delete [] tab; - delete [] coord; - delete [] node; - - return true; -} - -//============================================================================= -/*! - *Here we are going to use the GHS3D mesher - */ -//============================================================================= - -bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, - const TopoDS_Shape& theShape) -{ - bool Ok(false); - SMESHDS_Mesh* meshDS = theMesh.GetMeshDS(); - - _nbShape = countShape( meshDS, TopAbs_SOLID ); // we count the number of shapes - - // create bounding box for every shape inside the compound - - int iShape = 0; - TopoDS_Shape* tabShape; - double** tabBox; - tabShape = new TopoDS_Shape[_nbShape]; - tabBox = new double*[_nbShape]; - for (int i=0; i<_nbShape; i++) - tabBox[i] = new double[6]; - Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; - - TopExp_Explorer expBox (meshDS->ShapeToMesh(), TopAbs_SOLID); - for (; expBox.More(); expBox.Next()) { - tabShape[iShape] = expBox.Current(); - Bnd_Box BoundingBox; - BRepBndLib::Add(expBox.Current(), BoundingBox); - BoundingBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); - tabBox[iShape][0] = Xmin; tabBox[iShape][1] = Xmax; - tabBox[iShape][2] = Ymin; tabBox[iShape][3] = Ymax; - tabBox[iShape][4] = Zmin; tabBox[iShape][5] = Zmax; - iShape++; - } - - // a unique working file name - // to avoid access to the same files by eg different users - TCollection_AsciiString aGenericName - = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str(); - - TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName; - TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName; - aFacesFileName = aGenericName + ".faces"; // in faces - aPointsFileName = aGenericName + ".points"; // in points - aResultFileName = aGenericName + ".noboite";// out points and volumes - aBadResFileName = aGenericName + ".boite"; // out bad result - aBbResFileName = aGenericName + ".bb"; // out vertex stepsize - aLogFileName = aGenericName + ".log"; // log - - // ----------------- - // make input files - // ----------------- - - ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out); - ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out); - - Ok = -#ifdef WIN32 - aFacesFile->is_open() && aPointsFile->is_open(); -#else - aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open(); -#endif - if (!Ok) { - INFOS( "Can't write into " << aFacesFileName); - return error(SMESH_Comment("Can't write into ") << aFacesFileName); - } - map aSmdsToGhs3dIdMap; - map aGhs3dIdToNodeMap; - - Ok = writePoints( aPointsFile, meshDS, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap ) && - writeFaces ( aFacesFile, meshDS, aSmdsToGhs3dIdMap ); - - aFacesFile.close(); - aPointsFile.close(); - - if ( ! Ok ) { - if ( !_keepFiles ) { - OSD_File( aFacesFileName ).Remove(); - OSD_File( aPointsFileName ).Remove(); - } - return error(COMPERR_BAD_INPUT_MESH); - } - OSD_File( aResultFileName ).Remove(); // needed for boundary recovery module usage - - // ----------------- - // run ghs3d mesher - // ----------------- - - TCollection_AsciiString cmd( (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() ); - cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read - cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file - - cout << endl; - cout << "Ghs3d execution..." << endl; - cout << cmd << endl; - - system( cmd.ToCString() ); // run - - cout << endl; - cout << "End of Ghs3d execution !" << endl; - - // -------------- - // read a result - // -------------- - - // Mapping the result file - - int fileOpen; - fileOpen = open( aResultFileName.ToCString(), O_RDONLY); - if ( fileOpen < 0 ) { - cout << endl; - cout << "Can't open the " << aResultFileName.ToCString() << " GHS3D output file" << endl; - cout << "Log: " << aLogFileName << endl; - Ok = false; - } - else { - bool toMeshHoles = - _hyp ? _hyp->GetToMeshHoles(true) : GHS3DPlugin_Hypothesis::DefaultMeshHoles(); - Ok = readResultFile( fileOpen, theMesh, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap, - toMeshHoles ); - } - - // --------------------- - // remove working files - // --------------------- - - if ( Ok ) - { - if ( !_keepFiles ) - OSD_File( aLogFileName ).Remove(); - } - else if ( OSD_File( aLogFileName ).Size() > 0 ) - { - // get problem description from the log file - _Ghs2smdsConvertor conv( aGhs3dIdToNodeMap ); - storeErrorDescription( aLogFileName, conv ); - } - else - { - // the log file is empty - OSD_File( aLogFileName ).Remove(); - INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" ); - error(COMPERR_ALGO_FAILED, "ghs3d: command not found" ); - } - - if ( !_keepFiles ) { - OSD_File( aFacesFileName ).Remove(); - OSD_File( aPointsFileName ).Remove(); - OSD_File( aResultFileName ).Remove(); - OSD_File( aBadResFileName ).Remove(); - OSD_File( aBbResFileName ).Remove(); - } - cout << "<" << aResultFileName.ToCString() << "> GHS3D output file "; - if ( !Ok ) - cout << "not "; - cout << "treated !" << endl; - cout << endl; - - _nbShape = 0; // re-initializing _nbShape for the next Compute() method call - delete [] tabShape; - delete [] tabBox; - - return Ok; -} - -//============================================================================= -/*! - *Here we are going to use the GHS3D mesher w/o geometry - */ -//============================================================================= -bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh, - SMESH_MesherHelper* aHelper) -{ - MESSAGE("GHS3DPlugin_GHS3D::Compute()"); - - SMESHDS_Mesh* meshDS = theMesh.GetMeshDS(); - TopoDS_Shape theShape = aHelper->GetSubShape(); - - // a unique working file name - // to avoid access to the same files by eg different users - TCollection_AsciiString aGenericName - = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str(); - - TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName; - TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName; - aFacesFileName = aGenericName + ".faces"; // in faces - aPointsFileName = aGenericName + ".points"; // in points - aResultFileName = aGenericName + ".noboite";// out points and volumes - aBadResFileName = aGenericName + ".boite"; // out bad result - aBbResFileName = aGenericName + ".bb"; // out vertex stepsize - aLogFileName = aGenericName + ".log"; // log - - // ----------------- - // make input files - // ----------------- - - ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out); - ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out); - bool Ok = -#ifdef WIN32 - aFacesFile->is_open() && aPointsFile->is_open(); -#else - aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open(); -#endif - - if (!Ok) - return error( SMESH_Comment("Can't write into ") << aPointsFileName); - - vector aNodeByGhs3dId; - - Ok = (writeFaces ( aFacesFile, meshDS, aNodeByGhs3dId ) && - writePoints( aPointsFile, meshDS, aNodeByGhs3dId)); - - aFacesFile.close(); - aPointsFile.close(); - - if ( ! Ok ) { - if ( !_keepFiles ) { - OSD_File( aFacesFileName ).Remove(); - OSD_File( aPointsFileName ).Remove(); - } - return error(COMPERR_BAD_INPUT_MESH); - } - OSD_File( aResultFileName ).Remove(); // needed for boundary recovery module usage - - // ----------------- - // run ghs3d mesher - // ----------------- - - TCollection_AsciiString cmd = - (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp, false ).c_str(); - cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read - cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file - - system( cmd.ToCString() ); // run - - // -------------- - // read a result - // -------------- - int fileOpen; - fileOpen = open( aResultFileName.ToCString(), O_RDONLY); - if ( fileOpen < 0 ) { - cout << endl; - cout << "Error when opening the " << aResultFileName.ToCString() << " file" << endl; - cout << "Log: " << aLogFileName << endl; - cout << endl; - Ok = false; - } - else { - Ok = readResultFile( fileOpen, meshDS, theShape ,aNodeByGhs3dId ); - } - - // --------------------- - // remove working files - // --------------------- - - if ( Ok ) - { - if ( !_keepFiles ) - OSD_File( aLogFileName ).Remove(); - } - else if ( OSD_File( aLogFileName ).Size() > 0 ) - { - // get problem description from the log file - _Ghs2smdsConvertor conv( aNodeByGhs3dId ); - storeErrorDescription( aLogFileName, conv ); - } - else { - // the log file is empty - OSD_File( aLogFileName ).Remove(); - INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" ); - error(COMPERR_ALGO_FAILED, "ghs3d: command not found" ); - } - - if ( !_keepFiles ) - { - OSD_File( aFacesFileName ).Remove(); - OSD_File( aPointsFileName ).Remove(); - OSD_File( aResultFileName ).Remove(); - OSD_File( aBadResFileName ).Remove(); - OSD_File( aBbResFileName ).Remove(); - } - - return Ok; -} - -//================================================================================ -/*! - * \brief Provide human readable text by error code reported by ghs3d - */ -//================================================================================ - -static string translateError(const int errNum) -{ - switch ( errNum ) { - case 0: - return "The surface mesh includes a face of type other than edge, " - "triangle or quadrilateral. This face type is not supported."; - case 1: - return "Not enough memory for the face table."; - case 2: - return "Not enough memory."; - case 3: - return "Not enough memory."; - case 4: - return "Face is ignored."; - case 5: - return "End of file. Some data are missing in the file."; - case 6: - return "Read error on the file. There are wrong data in the file."; - case 7: - return "the metric file is inadequate (dimension other than 3)."; - case 8: - return "the metric file is inadequate (values not per vertices)."; - case 9: - return "the metric file contains more than one field."; - case 10: - return "the number of values in the \".bb\" (metric file) is incompatible with the expected" - "value of number of mesh vertices in the \".noboite\" file."; - case 12: - return "Too many sub-domains."; - case 13: - return "the number of vertices is negative or null."; - case 14: - return "the number of faces is negative or null."; - case 15: - return "A face has a null vertex."; - case 22: - return "incompatible data."; - case 131: - return "the number of vertices is negative or null."; - case 132: - return "the number of vertices is negative or null (in the \".mesh\" file)."; - case 133: - return "the number of faces is negative or null."; - case 1000: - return "A face appears more than once in the input surface mesh."; - case 1001: - return "An edge appears more than once in the input surface mesh."; - case 1002: - return "A face has a vertex negative or null."; - case 1003: - return "NOT ENOUGH MEMORY."; - case 2000: - return "Not enough available memory."; - case 2002: - return "Some initial points cannot be inserted. The surface mesh is probably very bad " - "in terms of quality or the input list of points is wrong."; - case 2003: - return "Some vertices are too close to one another or coincident."; - case 2004: - return "Some vertices are too close to one another or coincident."; - case 2012: - return "A vertex cannot be inserted."; - case 2014: - return "There are at least two points considered as coincident."; - case 2103: - return "Some vertices are too close to one another or coincident."; - case 3000: - return "The surface mesh regeneration step has failed."; - case 3009: - return "Constrained edge cannot be enforced."; - case 3019: - return "Constrained face cannot be enforced."; - case 3029: - return "Missing faces."; - case 3100: - return "No guess to start the definition of the connected component(s)."; - case 3101: - return "The surface mesh includes at least one hole. The domain is not well defined."; - case 3102: - return "Impossible to define a component."; - case 3103: - return "The surface edge intersects another surface edge."; - case 3104: - return "The surface edge intersects the surface face."; - case 3105: - return "One boundary point lies within a surface face."; - case 3106: - return "One surface edge intersects a surface face."; - case 3107: - return "One boundary point lies within a surface edge."; - case 3108: - return "Insufficient memory ressources detected due to a bad quality surface mesh leading " - "to too many swaps."; - case 3109: - return "Edge is unique (i.e., bounds a hole in the surface)."; - case 3122: - return "Presumably, the surface mesh is not compatible with the domain being processed."; - case 3123: - return "Too many components, too many sub-domain."; - case 3209: - return "The surface mesh includes at least one hole. " - "Therefore there is no domain properly defined."; - case 3300: - return "Statistics."; - case 3400: - return "Statistics."; - case 3500: - return "Warning, it is dramatically tedious to enforce the boundary items."; - case 4000: - return "Not enough memory at this time, nevertheless, the program continues. " - "The expected mesh will be correct but not really as large as required."; - case 4002: - return "see above error code, resulting quality may be poor."; - case 4003: - return "Not enough memory at this time, nevertheless, the program continues (warning)."; - case 8000: - return "Unknown face type."; - case 8005: - case 8006: - return "End of file. Some data are missing in the file."; - case 9000: - return "A too small volume element is detected."; - case 9001: - return "There exists at least a null or negative volume element."; - case 9002: - return "There exist null or negative volume elements."; - case 9003: - return "A too small volume element is detected. A face is considered being degenerated."; - case 9100: - return "Some element is suspected to be very bad shaped or wrong."; - case 9102: - return "A too bad quality face is detected. This face is considered degenerated."; - case 9112: - return "A too bad quality face is detected. This face is degenerated."; - case 9122: - return "Presumably, the surface mesh is not compatible with the domain being processed."; - case 9999: - return "Abnormal error occured, contact hotline."; - case 23600: - return "Not enough memory for the face table."; - case 23601: - return "The algorithm cannot run further. " - "The surface mesh is probably very bad in terms of quality."; - case 23602: - return "Bad vertex number."; - } - return ""; -} - -//================================================================================ -/*! - * \brief Retrieve from a string given number of integers - */ -//================================================================================ - -static char* getIds( char* ptr, int nbIds, vector& ids ) -{ - ids.clear(); - ids.reserve( nbIds ); - while ( nbIds ) - { - while ( !isdigit( *ptr )) ++ptr; - if ( ptr[-1] == '-' ) --ptr; - ids.push_back( strtol( ptr, &ptr, 10 )); - --nbIds; - } - return ptr; -} - -//================================================================================ -/*! - * \brief Retrieve problem description form a log file - * \retval bool - always false - */ -//================================================================================ - -bool GHS3DPlugin_GHS3D::storeErrorDescription(const TCollection_AsciiString& logFile, - const _Ghs2smdsConvertor & toSmdsConvertor ) -{ - // open file -#ifdef WNT - int file = ::_open (logFile.ToCString(), _O_RDONLY|_O_BINARY); -#else - int file = ::open (logFile.ToCString(), O_RDONLY); -#endif - if ( file < 0 ) - return error( SMESH_Comment("See ") << logFile << " for problem description"); - - // get file size -// struct stat status; -// fstat(file, &status); -// size_t length = status.st_size; - off_t length = lseek( file, 0, SEEK_END); - lseek( file, 0, SEEK_SET); - - // read file - vector< char > buf( length ); - int nBytesRead = ::read (file, & buf[0], length); - ::close (file); - char* ptr = & buf[0]; - char* bufEnd = ptr + nBytesRead; - - SMESH_Comment errDescription; - - enum { NODE = 1, EDGE, TRIA, VOL, ID = 1 }; - - // look for errors "ERR #" - - set foundErrorStr; // to avoid reporting same error several times - set elemErrorNums; // not to report different types of errors with bad elements - while ( ++ptr < bufEnd ) - { - if ( strncmp( ptr, "ERR ", 4 ) != 0 ) - continue; - - list badElems; - vector nodeIds; - - ptr += 4; - char* errBeg = ptr; - int errNum = strtol(ptr, &ptr, 10); - switch ( errNum ) { // we treat errors enumerated in [SALOME platform 0019316] issue - case 0015: - // The face number (numfac) with vertices (f 1, f 2, f 3) has a null vertex. - ptr = getIds(ptr, NODE, nodeIds); - ptr = getIds(ptr, TRIA, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 1000: // ERR 1000 : 1 3 2 - // Face (f 1, f 2, f 3) appears more than once in the input surface mesh. - ptr = getIds(ptr, TRIA, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 1001: - // Edge (e1, e2) appears more than once in the input surface mesh - ptr = getIds(ptr, EDGE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 1002: - // Face (f 1, f 2, f 3) has a vertex negative or null - ptr = getIds(ptr, TRIA, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 2004: - // Vertex v1 and vertex v2 are too close to one another or coincident (warning). - ptr = getIds(ptr, NODE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - ptr = getIds(ptr, NODE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 2012: - // Vertex v1 cannot be inserted (warning). - ptr = getIds(ptr, NODE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 2014: - // There are at least two points whose distance is dist, i.e., considered as coincident - case 2103: // ERR 2103 : 16 WITH 3 - // Vertex v1 and vertex v2 are too close to one another or coincident (warning). - ptr = getIds(ptr, NODE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - ptr = getIds(ptr, NODE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 3009: - // Constrained edge (e1, e2) cannot be enforced (warning). - ptr = getIds(ptr, EDGE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 3019: - // Constrained face (f 1, f 2, f 3) cannot be enforced - ptr = getIds(ptr, TRIA, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 3103: // ERR 3103 : 1 2 WITH 7 3 - // The surface edge (e1, e2) intersects another surface edge (e3, e4) - ptr = getIds(ptr, EDGE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - ptr = getIds(ptr, EDGE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 3104: // ERR 3104 : 9 10 WITH 1 2 3 - // The surface edge (e1, e2) intersects the surface face (f 1, f 2, f 3) - ptr = getIds(ptr, EDGE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - ptr = getIds(ptr, TRIA, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 3105: // ERR 3105 : 8 IN 2 3 5 - // One boundary point (say p1) lies within a surface face (f 1, f 2, f 3) - ptr = getIds(ptr, NODE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - ptr = getIds(ptr, TRIA, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 3106: - // One surface edge (say e1, e2) intersects a surface face (f 1, f 2, f 3) - ptr = getIds(ptr, EDGE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - ptr = getIds(ptr, TRIA, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 3107: // ERR 3107 : 2 IN 4 1 - // One boundary point (say p1) lies within a surface edge (e1, e2) (stop). - ptr = getIds(ptr, NODE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - ptr = getIds(ptr, EDGE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 3109: // ERR 3109 : EDGE 5 6 UNIQUE - // Edge (e1, e2) is unique (i.e., bounds a hole in the surface) - ptr = getIds(ptr, EDGE, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - break; - case 9000: // ERR 9000 - // ELEMENT 261 WITH VERTICES : 7 396 -8 242 - // VOLUME : -1.11325045E+11 W.R.T. EPSILON 0. - // A too small volume element is detected. Are reported the index of the element, - // its four vertex indices, its volume and the tolerance threshold value - ptr = getIds(ptr, ID, nodeIds); - ptr = getIds(ptr, VOL, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - // even if all nodes found, volume it most probably invisible, - // add its faces to demenstrate it anyhow - { - vector faceNodes( nodeIds.begin(), --nodeIds.end() ); // 012 - badElems.push_back( toSmdsConvertor.getElement(faceNodes)); - faceNodes[2] = nodeIds[3]; // 013 - badElems.push_back( toSmdsConvertor.getElement(faceNodes)); - faceNodes[1] = nodeIds[2]; // 023 - badElems.push_back( toSmdsConvertor.getElement(faceNodes)); - faceNodes[0] = nodeIds[1]; // 123 - badElems.push_back( toSmdsConvertor.getElement(faceNodes)); - } - break; - case 9001: // ERR 9001 - // %% NUMBER OF NEGATIVE VOLUME TETS : 1 - // %% THE LARGEST NEGATIVE TET : 1.75376581E+11 - // %% NUMBER OF NULL VOLUME TETS : 0 - // There exists at least a null or negative volume element - break; - case 9002: - // There exist n null or negative volume elements - break; - case 9003: - // A too small volume element is detected - break; - case 9102: - // A too bad quality face is detected. This face is considered degenerated, - // its index, its three vertex indices together with its quality value are reported - break; // same as next - case 9112: // ERR 9112 - // FACE 2 WITH VERTICES : 4 2 5 - // SMALL INRADIUS : 0. - // A too bad quality face is detected. This face is degenerated, - // its index, its three vertex indices together with its inradius are reported - ptr = getIds(ptr, ID, nodeIds); - ptr = getIds(ptr, TRIA, nodeIds); - badElems.push_back( toSmdsConvertor.getElement(nodeIds)); - // add triangle edges as it most probably has zero area and hence invisible - { - vector edgeNodes(2); - edgeNodes[0] = nodeIds[0]; edgeNodes[1] = nodeIds[1]; // 0-1 - badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); - edgeNodes[1] = nodeIds[2]; // 0-2 - badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); - edgeNodes[0] = nodeIds[1]; // 1-2 - badElems.push_back( toSmdsConvertor.getElement(edgeNodes)); - } - break; - } - - bool isNewError = foundErrorStr.insert( string( errBeg, ptr )).second; - if ( !isNewError ) - continue; // not to report same error several times - -// const SMDS_MeshElement* nullElem = 0; -// bool allElemsOk = ( find( badElems.begin(), badElems.end(), nullElem) == badElems.end()); - -// if ( allElemsOk && !badElems.empty() && !elemErrorNums.empty() ) { -// bool oneMoreErrorType = elemErrorNums.insert( errNum ).second; -// if ( oneMoreErrorType ) -// continue; // not to report different types of errors with bad elements -// } - - // store bad elements - //if ( allElemsOk ) { - list::iterator elem = badElems.begin(); - for ( ; elem != badElems.end(); ++elem ) - addBadInputElement( *elem ); - //} - - // make error text - string text = translateError( errNum ); - if ( errDescription.find( text ) == text.npos ) { - if ( !errDescription.empty() ) - errDescription << "\n"; - errDescription << text; - } - - } // end while - - if ( errDescription.empty() ) { // no errors found - char msg[] = "connection to server failed"; - if ( search( &buf[0], bufEnd, msg, msg + strlen(msg)) != bufEnd ) - errDescription << "Licence problems."; - } - - if ( errDescription.empty() ) - errDescription << "See " << logFile << " for problem description"; - else - errDescription << "\nSee " << logFile << " for more information"; - - return error( errDescription ); -} - -//================================================================================ -/*! - * \brief Creates _Ghs2smdsConvertor - */ -//================================================================================ - -_Ghs2smdsConvertor::_Ghs2smdsConvertor( const map & ghs2NodeMap) - :_ghs2NodeMap( & ghs2NodeMap ), _nodeByGhsId( 0 ) -{ -} - -//================================================================================ -/*! - * \brief Creates _Ghs2smdsConvertor - */ -//================================================================================ - -_Ghs2smdsConvertor::_Ghs2smdsConvertor( const vector & nodeByGhsId) - : _ghs2NodeMap( 0 ), _nodeByGhsId( &nodeByGhsId ) -{ -} - -//================================================================================ -/*! - * \brief Return SMDS element by ids of GHS3D nodes - */ -//================================================================================ - -const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector& ghsNodes) const -{ - size_t nbNodes = ghsNodes.size(); - vector nodes( nbNodes, 0 ); - for ( size_t i = 0; i < nbNodes; ++i ) { - int ghsNode = ghsNodes[ i ]; - if ( _ghs2NodeMap ) { - map ::const_iterator in = _ghs2NodeMap->find( ghsNode); - if ( in == _ghs2NodeMap->end() ) - return 0; - nodes[ i ] = in->second; - } - else { - if ( ghsNode < 1 || ghsNode > _nodeByGhsId->size() ) - return 0; - nodes[ i ] = (*_nodeByGhsId)[ ghsNode-1 ]; - } - } - if ( nbNodes == 1 ) - return nodes[0]; - - if ( nbNodes == 2 ) { - const SMDS_MeshElement* edge= SMDS_Mesh::FindEdge( nodes[0], nodes[1] ); - if ( !edge ) - edge = new SMDS_MeshEdge( nodes[0], nodes[1] ); - return edge; - } - if ( nbNodes == 3 ) { - const SMDS_MeshElement* face = SMDS_Mesh::FindFace( nodes ); - if ( !face ) - face = new SMDS_FaceOfNodes( nodes[0], nodes[1], nodes[2] ); - return face; - } - if ( nbNodes == 4 ) - return new SMDS_VolumeOfNodes( nodes[0], nodes[1], nodes[2], nodes[3] ); - - return 0; -} - diff --git a/src/GHS3DPlugin_GHS3D.hxx b/src/GHS3DPlugin_GHS3D.hxx deleted file mode 100644 index 8c9d7e3..0000000 --- a/src/GHS3DPlugin_GHS3D.hxx +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2004-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 : GHS3DPlugin_GHS3D.hxx -// Author : Edward AGAPOV, modified by Lioka RAZAFINDRAZAKA (CEA) 09/02/2007 -// Project : SALOME -// $Header$ -//============================================================================= -// -#ifndef _GHS3DPlugin_GHS3D_HXX_ -#define _GHS3DPlugin_GHS3D_HXX_ - -#include "SMESH_3D_Algo.hxx" - -#include -#include - -class SMESH_Mesh; -class GHS3DPlugin_Hypothesis; -class SMDS_MeshNode; -class TCollection_AsciiString; -class _Ghs2smdsConvertor; - -class GHS3DPlugin_GHS3D: public SMESH_3D_Algo -{ -public: - GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen); - virtual ~GHS3DPlugin_GHS3D(); - - virtual bool CheckHypothesis(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape, - Hypothesis_Status& aStatus); - - virtual bool Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape); - - virtual bool Compute(SMESH_Mesh& theMesh, - SMESH_MesherHelper* aHelper); - -private: - - bool storeErrorDescription(const TCollection_AsciiString& logFile, - const _Ghs2smdsConvertor & toSmdsConvertor ); - - int _iShape; - int _nbShape; - bool _keepFiles; - const GHS3DPlugin_Hypothesis* _hyp; -}; - -/*! - * \brief Convertor of GHS3D elements to SMDS ones - */ -class _Ghs2smdsConvertor -{ - const std::map * _ghs2NodeMap; - const std::vector * _nodeByGhsId; - -public: - _Ghs2smdsConvertor( const std::map & ghs2NodeMap); - - _Ghs2smdsConvertor( const std::vector & nodeByGhsId); - - const SMDS_MeshElement* getElement(const std::vector& ghsNodes) const; -}; - -#endif diff --git a/src/GHS3DPlugin_GHS3D_i.cxx b/src/GHS3DPlugin_GHS3D_i.cxx deleted file mode 100644 index 21469d3..0000000 --- a/src/GHS3DPlugin_GHS3D_i.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2004-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 -// -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses -// File : GHS3DPlugin_GHS3D_i.cxx -// Author : Edward AGAPOV -// Module : GHS3DPlugin -// $Header$ -// -using namespace std; -#include "GHS3DPlugin_GHS3D_i.hxx" -#include "SMESH_Gen.hxx" -#include "GHS3DPlugin_GHS3D.hxx" - -#include "utilities.h" - -//============================================================================= -/*! - * GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i - * - * Constructor - */ -//============================================================================= - -GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i (PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ) - : SALOME::GenericObj_i( thePOA ), - SMESH_Hypothesis_i( thePOA ), - SMESH_Algo_i( thePOA ), - SMESH_3D_Algo_i( thePOA ) -{ - MESSAGE( "GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i" ); - myBaseImpl = new ::GHS3DPlugin_GHS3D (theGenImpl->GetANewId(), - theStudyId, - theGenImpl ); -} - -//============================================================================= -/*! - * GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i - * - * Destructor - */ -//============================================================================= - -GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i() -{ - MESSAGE( "GHS3DPlugin_GHS3D_i::~GHS3DPlugin_GHS3D_i" ); -} - -//============================================================================= -/*! - * GHS3DPlugin_GHS3D_i::GetImpl - * - * Get implementation - */ -//============================================================================= - -::GHS3DPlugin_GHS3D* GHS3DPlugin_GHS3D_i::GetImpl() -{ - MESSAGE( "GHS3DPlugin_GHS3D_i::GetImpl" ); - return ( ::GHS3DPlugin_GHS3D* )myBaseImpl; -} - diff --git a/src/GHS3DPlugin_GHS3D_i.hxx b/src/GHS3DPlugin_GHS3D_i.hxx deleted file mode 100644 index 6fea6fc..0000000 --- a/src/GHS3DPlugin_GHS3D_i.hxx +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2004-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 : GHS3DPlugin_GHS3D_i.hxx -// Author : Edward AGAPOV -// Module : GHS3DPlugin -// $Header$ -// -#ifndef _GHS3DPlugin_GHS3D_I_HXX_ -#define _GHS3DPlugin_GHS3D_I_HXX_ - -#include -#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) -#include CORBA_SERVER_HEADER(SALOME_Exception) - -#include "SMESH_3D_Algo_i.hxx" -#include "GHS3DPlugin_GHS3D.hxx" - -// ====================================================== -// GHS3D 3d algorithm -// ====================================================== -class GHS3DPlugin_GHS3D_i: - public virtual POA_GHS3DPlugin::GHS3DPlugin_GHS3D, - public virtual SMESH_3D_Algo_i -{ -public: - // Constructor - GHS3DPlugin_GHS3D_i (PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ); - // Destructor - virtual ~GHS3DPlugin_GHS3D_i(); - - // Get implementation - ::GHS3DPlugin_GHS3D* GetImpl(); -}; - -#endif diff --git a/src/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin_Hypothesis.cxx deleted file mode 100644 index 3a29541..0000000 --- a/src/GHS3DPlugin_Hypothesis.cxx +++ /dev/null @@ -1,628 +0,0 @@ -// Copyright (C) 2004-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 : GHS3DPlugin_Hypothesis.cxx -// Created : Wed Apr 2 12:36:29 2008 -// Author : Edward AGAPOV (eap) -//============================================================================= -// -#include "GHS3DPlugin_Hypothesis.hxx" - -#include - -//======================================================================= -//function : GHS3DPlugin_Hypothesis -//======================================================================= - -GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen) - : SMESH_Hypothesis(hypId, studyId, gen) -{ - _name = "GHS3D_Parameters"; - _param_algo_dim = 3; - - myToMeshHoles = DefaultMeshHoles(); - myMaximumMemory = -1;//DefaultMaximumMemory(); - myInitialMemory = -1;//DefaultInitialMemory(); - myOptimizationLevel = DefaultOptimizationLevel(); - myWorkingDirectory = DefaultWorkingDirectory(); - myKeepFiles = DefaultKeepFiles(); - myVerboseLevel = DefaultVerboseLevel(); - myToCreateNewNodes = DefaultToCreateNewNodes(); - myToUseBoundaryRecoveryVersion = DefaultToUseBoundaryRecoveryVersion(); -} - -//======================================================================= -//function : SetToMeshHoles -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetToMeshHoles(bool toMesh) -{ - if ( myToMeshHoles != toMesh ) { - myToMeshHoles = toMesh; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetToMeshHoles -//======================================================================= - -bool GHS3DPlugin_Hypothesis::GetToMeshHoles(bool checkFreeOption) const -{ - if (checkFreeOption && !myTextOption.empty()) { - if ( myTextOption.find("-c 0")) - return true; - if ( myTextOption.find("-c 1")) - return false; - } - return myToMeshHoles; -} - -//======================================================================= -//function : SetMaximumMemory -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetMaximumMemory(short MB) -{ - if ( myMaximumMemory != MB ) { - myMaximumMemory = MB; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetMaximumMemory -// * automatic memory adjustment mode. Default is zero -//======================================================================= - -short GHS3DPlugin_Hypothesis::GetMaximumMemory() const -{ - return myMaximumMemory; -} - -//======================================================================= -//function : SetInitialMemory -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetInitialMemory(short MB) -{ - if ( myInitialMemory != MB ) { - myInitialMemory = MB; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetInitialMemory -//======================================================================= - -short GHS3DPlugin_Hypothesis::GetInitialMemory() const -{ - return myInitialMemory; -} - -//======================================================================= -//function : SetOptimizationLevel -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetOptimizationLevel(OptimizationLevel level) -{ - if ( myOptimizationLevel != level ) { - myOptimizationLevel = level; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetOptimizationLevel -//======================================================================= - -GHS3DPlugin_Hypothesis::OptimizationLevel GHS3DPlugin_Hypothesis::GetOptimizationLevel() const -{ - return (OptimizationLevel) myOptimizationLevel; -} - -//======================================================================= -//function : SetWorkingDirectory -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetWorkingDirectory(const string& path) -{ - if ( myWorkingDirectory != path ) { - myWorkingDirectory = path; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetWorkingDirectory -//======================================================================= - -string GHS3DPlugin_Hypothesis::GetWorkingDirectory() const -{ - return myWorkingDirectory; -} - -//======================================================================= -//function : SetKeepFiles -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetKeepFiles(bool toKeep) -{ - if ( myKeepFiles != toKeep ) { - myKeepFiles = toKeep; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetKeepFiles -//======================================================================= - -bool GHS3DPlugin_Hypothesis::GetKeepFiles() const -{ - return myKeepFiles; -} - -//======================================================================= -//function : SetVerboseLevel -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetVerboseLevel(short level) -{ - if ( myVerboseLevel != level ) { - myVerboseLevel = level; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetVerboseLevel -//======================================================================= - -short GHS3DPlugin_Hypothesis::GetVerboseLevel() const -{ - return myVerboseLevel; -} - -//======================================================================= -//function : SetToCreateNewNodes -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetToCreateNewNodes(bool toCreate) -{ - if ( myToCreateNewNodes != toCreate ) { - myToCreateNewNodes = toCreate; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetToCreateNewNodes -//======================================================================= - -bool GHS3DPlugin_Hypothesis::GetToCreateNewNodes() const -{ - return myToCreateNewNodes; -} - -//======================================================================= -//function : SetToUseBoundaryRecoveryVersion -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetToUseBoundaryRecoveryVersion(bool toUse) -{ - if ( myToUseBoundaryRecoveryVersion != toUse ) { - myToUseBoundaryRecoveryVersion = toUse; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetToUseBoundaryRecoveryVersion -//======================================================================= - -bool GHS3DPlugin_Hypothesis::GetToUseBoundaryRecoveryVersion() const -{ - return myToUseBoundaryRecoveryVersion; -} - -//======================================================================= -//function : SetTextOption -//======================================================================= - -void GHS3DPlugin_Hypothesis::SetTextOption(const string& option) -{ - if ( myTextOption != option ) { - myTextOption = option; - NotifySubMeshesHypothesisModification(); - } -} - -//======================================================================= -//function : GetTextOption -//======================================================================= - -string GHS3DPlugin_Hypothesis::GetTextOption() const -{ - return myTextOption; -} - - -//======================================================================= -//function : DefaultMeshHoles -//======================================================================= - -bool GHS3DPlugin_Hypothesis::DefaultMeshHoles() -{ - return false; // PAL19680 -} - -//======================================================================= -//function : DefaultMaximumMemory -//======================================================================= - -#ifndef WIN32 -#include -#endif - -short GHS3DPlugin_Hypothesis::DefaultMaximumMemory() -{ -#ifndef WIN32 - struct sysinfo si; - int err = sysinfo( &si ); - if ( err == 0 ) { - int ramMB = si.totalram * si.mem_unit / 1024 / 1024; - return (short) ( 0.7 * ramMB ); - } -#endif - return -1; -} - -//======================================================================= -//function : DefaultInitialMemory -//======================================================================= - -short GHS3DPlugin_Hypothesis::DefaultInitialMemory() -{ - return DefaultMaximumMemory(); -} - -//======================================================================= -//function : DefaultOptimizationLevel -//======================================================================= - -short GHS3DPlugin_Hypothesis::DefaultOptimizationLevel() -{ - return Medium; -} - -//======================================================================= -//function : DefaultWorkingDirectory -//======================================================================= - -string GHS3DPlugin_Hypothesis::DefaultWorkingDirectory() -{ - TCollection_AsciiString aTmpDir; - - char *Tmp_dir = getenv("SALOME_TMP_DIR"); - if(Tmp_dir != NULL) { - aTmpDir = Tmp_dir; - } - else { -#ifdef WIN32 - aTmpDir = TCollection_AsciiString("C:\\"); -#else - aTmpDir = TCollection_AsciiString("/tmp/"); -#endif - } - return aTmpDir.ToCString(); -} - -//======================================================================= -//function : DefaultKeepFiles -//======================================================================= - -bool GHS3DPlugin_Hypothesis::DefaultKeepFiles() -{ - return false; -} - -//======================================================================= -//function : DefaultVerboseLevel -//======================================================================= - -short GHS3DPlugin_Hypothesis::DefaultVerboseLevel() -{ - return 10; -} - -//======================================================================= -//function : DefaultToCreateNewNodes -//======================================================================= - -bool GHS3DPlugin_Hypothesis::DefaultToCreateNewNodes() -{ - return true; -} - -//======================================================================= -//function : DefaultToUseBoundaryRecoveryVersion -//======================================================================= - -bool GHS3DPlugin_Hypothesis::DefaultToUseBoundaryRecoveryVersion() -{ - return false; -} - -//======================================================================= -//function : SaveTo -//======================================================================= - -ostream & GHS3DPlugin_Hypothesis::SaveTo(ostream & save) -{ - save << (int) myToMeshHoles << " "; - save << myMaximumMemory << " "; - save << myInitialMemory << " "; - save << myOptimizationLevel << " "; - save << myWorkingDirectory << " "; - save << (int)myKeepFiles << " "; - save << myVerboseLevel << " "; - save << (int)myToCreateNewNodes << " "; - save << (int)myToUseBoundaryRecoveryVersion << " "; - save << myTextOption << " "; - return save; -} - -//======================================================================= -//function : LoadFrom -//======================================================================= - -istream & GHS3DPlugin_Hypothesis::LoadFrom(istream & load) -{ - bool isOK = true; - int i; - - isOK = (load >> i); - if (isOK) - myToMeshHoles = i; - else - load.clear(ios::badbit | load.rdstate()); - - isOK = (load >> i); - if (isOK) - myMaximumMemory = i; - else - load.clear(ios::badbit | load.rdstate()); - - isOK = (load >> i); - if (isOK) - myInitialMemory = i; - else - load.clear(ios::badbit | load.rdstate()); - - isOK = (load >> i); - if (isOK) - myOptimizationLevel = i; - else - load.clear(ios::badbit | load.rdstate()); - - isOK = (load >> myWorkingDirectory); - if (isOK) { - if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty - myKeepFiles = false; - myWorkingDirectory.clear(); - } - else if ( myWorkingDirectory == "1" ) { - myKeepFiles = true; - myWorkingDirectory.clear(); - } - } - else - load.clear(ios::badbit | load.rdstate()); - - if ( !myWorkingDirectory.empty() ) { - isOK = (load >> i); - if (isOK) - myKeepFiles = i; - else - load.clear(ios::badbit | load.rdstate()); - } - - isOK = (load >> i); - if (isOK) - myVerboseLevel = (short) i; - else - load.clear(ios::badbit | load.rdstate()); - - isOK = (load >> i); - if (isOK) - myToCreateNewNodes = (bool) i; - else - load.clear(ios::badbit | load.rdstate()); - - isOK = (load >> i); - if (isOK) - myToUseBoundaryRecoveryVersion = (bool) i; - else - load.clear(ios::badbit | load.rdstate()); - - isOK = (load >> myTextOption); - while (isOK) { - string txt; - if (load >> txt) { - myTextOption += " "; - myTextOption += txt; - } - else - isOK = false; - } -// else -// load.clear(ios::badbit | load.rdstate()); - - return load; -} - -//======================================================================= -//function : SetParametersByMesh -//======================================================================= - -bool GHS3DPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&) -{ - return false; -} - - -//================================================================================ -/*! - * \brief Return false - */ -//================================================================================ - -bool GHS3DPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& /*dflts*/, - const SMESH_Mesh* /*theMesh*/) -{ - return false; -} - -//================================================================================ -/*! - * \brief Return command to run ghs3d mesher excluding file prefix (-f) - */ -//================================================================================ - -string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp, - const bool hasShapeToMesh) -{ -#ifndef WIN32 - TCollection_AsciiString cmd( "ghs3d" ); -#else - TCollection_AsciiString cmd( "ghs3d.exe" ); -#endif - // check if any option is overridden by hyp->myTextOption - bool m = hyp ? ( hyp->myTextOption.find("-m") == string::npos ) : true; - bool M = hyp ? ( hyp->myTextOption.find("-M") == string::npos ) : true; - bool c = hyp ? ( hyp->myTextOption.find("-c") == string::npos ) : true; - bool o = hyp ? ( hyp->myTextOption.find("-o") == string::npos ) : true; - bool p0= hyp ? ( hyp->myTextOption.find("-p0")== string::npos ) : true; - bool C = hyp ? ( hyp->myTextOption.find("-C") == string::npos ) : true; - bool v = hyp ? ( hyp->myTextOption.find("-v") == string::npos ) : true; - - // if use boundary recovery version, few options are allowed - bool useBndRecovery = !C; - if ( !useBndRecovery && hyp ) - useBndRecovery = hyp->myToUseBoundaryRecoveryVersion; - - // ghs3d needs to know amount of memory it may use (MB). - // Default memory is defined at ghs3d installation but it may be not enough, - // so allow to use about all available memory - if ( m ) { - short aMaximumMemory = hyp ? hyp->myMaximumMemory : -1; - cmd += " -m "; - if ( aMaximumMemory < 0 ) - cmd += DefaultMaximumMemory(); - else - cmd += aMaximumMemory; - } - if ( M && !useBndRecovery ) { - short aInitialMemory = hyp ? hyp->myInitialMemory : -1; - cmd += " -M "; - if ( aInitialMemory > 0 ) - cmd += aInitialMemory; - else - cmd += "100"; - } - // component to mesh - // 0 , all components to be meshed - // 1 , only the main ( outermost ) component to be meshed - if ( c && !useBndRecovery ) { - // We always run GHS3D with "to mesh holes'==TRUE (see PAL19680) - if ( hasShapeToMesh ) - cmd += " -c 0"; - else { - bool aToMeshHoles = hyp ? hyp->myToMeshHoles : DefaultMeshHoles(); - if ( aToMeshHoles ) - cmd += " -c 0"; - else - cmd += " -c 1"; - } - } - - // optimization level - if ( o && hyp && !useBndRecovery ) { - if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 4 ) { - char* level[] = { "none" , "light" , "standard" , "strong" }; - cmd += " -o "; - cmd += level[ hyp->myOptimizationLevel ]; - } - } - - // to create internal nodes - if ( p0 && hyp && !hyp->myToCreateNewNodes ) { - cmd += " -p0"; - } - - // verbose mode - if ( v && hyp ) { - cmd += " -v "; - cmd += hyp->myVerboseLevel; - } - - // boundary recovery version - if ( useBndRecovery ) { - cmd += " -C"; - } - - // options as text - if ( hyp && !hyp->myTextOption.empty() ) { - cmd += " "; - cmd += (char*) hyp->myTextOption.c_str(); - } - - return cmd.ToCString(); -} - -//================================================================================ -/*! - * \brief Return a unique file name - */ -//================================================================================ - -string GHS3DPlugin_Hypothesis::GetFileName(const GHS3DPlugin_Hypothesis* hyp) -{ - string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory(); - const char lastChar = *aTmpDir.rbegin(); -#ifdef WIN32 - if(lastChar != '\\') aTmpDir+='\\'; -#else - if(lastChar != '/') aTmpDir+='/'; -#endif - - TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str(); - aGenericName += "GHS3D_"; -#ifdef WIN32 - aGenericName += GetCurrentProcessId(); -#else - aGenericName += getpid(); -#endif - aGenericName += "_"; - aGenericName += Abs((Standard_Integer)(long) aGenericName.ToCString()); - - return aGenericName.ToCString(); -} diff --git a/src/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin_Hypothesis.hxx deleted file mode 100644 index 1c59739..0000000 --- a/src/GHS3DPlugin_Hypothesis.hxx +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (C) 2004-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 -// -// GHS3DPlugin : C++ implementation -// File : GHS3DPlugin_Hypothesis.hxx -// Created : Wed Apr 2 12:21:17 2008 -// Author : Edward AGAPOV (eap) -// -#ifndef GHS3DPlugin_Hypothesis_HeaderFile -#define GHS3DPlugin_Hypothesis_HeaderFile - -#include "GHS3DPlugin_Defs.hxx" - -#include - -using namespace std; - -class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis: public SMESH_Hypothesis -{ -public: - - GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen); - - /*! - * To mesh "holes" in a solid or not. Default is to mesh. - */ - void SetToMeshHoles(bool toMesh); - bool GetToMeshHoles(bool checkFreeOption = false) const; - /*! - * Maximal size of memory to be used by the algorithm (in Megabytes) - */ - void SetMaximumMemory(short MB); - short GetMaximumMemory() const; - /*! - * Initial size of memory to be used by the algorithm (in Megabytes) in - * automatic memory adjustment mode. Default is zero - */ - void SetInitialMemory(short MB); - short GetInitialMemory() const; - /*! - * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium - */ - enum OptimizationLevel { None = 0, Light, Medium, Strong }; - void SetOptimizationLevel(OptimizationLevel level); - OptimizationLevel GetOptimizationLevel() const; - /*! - * Path to working directory - */ - void SetWorkingDirectory(const string& path); - string GetWorkingDirectory() const; - /*! - * To keep working files or remove them. Log file remains in case of errors anyway. - */ - void SetKeepFiles(bool toKeep); - bool GetKeepFiles() const; - /*! - * Verbose level [0-10] - * 0 - no standard output, - * 2 - prints the data, quality statistics of the skin and final meshes and - * indicates when the final mesh is being saved. In addition the software - * gives indication regarding the CPU time. - * 10 - same as 2 plus the main steps in the computation, quality statistics - * histogram of the skin mesh, quality statistics histogram together with - * the characteristics of the final mesh. - */ - void SetVerboseLevel(short level); - short GetVerboseLevel() const; - /*! - * To create new nodes - */ - void SetToCreateNewNodes(bool toCreate); - bool GetToCreateNewNodes() const; - /*! - * To use boundary recovery version which tries to create mesh on a very poor - * quality surface mesh - */ - void SetToUseBoundaryRecoveryVersion(bool toUse); - bool GetToUseBoundaryRecoveryVersion() const; - /*! - * To set hiden/undocumented/advanced options - */ - void SetTextOption(const string& option); - string GetTextOption() const; - - static bool DefaultMeshHoles(); - static short DefaultMaximumMemory(); - static short DefaultInitialMemory(); - static short DefaultOptimizationLevel(); - static string DefaultWorkingDirectory(); - static bool DefaultKeepFiles(); - static short DefaultVerboseLevel(); - static bool DefaultToCreateNewNodes(); - static bool DefaultToUseBoundaryRecoveryVersion(); - - /*! - * \brief Return command to run ghs3d mesher excluding file prefix (-f) - */ - static std::string CommandToRun(const GHS3DPlugin_Hypothesis* hyp, - const bool hasShapeToMesh=true); - /*! - * \brief Return a unique file name - */ - static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp); - - // Persistence - virtual ostream & SaveTo(ostream & save); - virtual istream & LoadFrom(istream & load); - friend GHS3DPLUGIN_EXPORT ostream & operator <<(ostream & save, GHS3DPlugin_Hypothesis & hyp); - friend GHS3DPLUGIN_EXPORT istream & operator >>(istream & load, GHS3DPlugin_Hypothesis & hyp); - - /*! - * \brief Does nothing - */ - virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); - - /*! - * \brief Does nothing - */ - virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); - -private: - - bool myToMeshHoles; - short myMaximumMemory; - short myInitialMemory; - short myOptimizationLevel; - bool myKeepFiles; - string myWorkingDirectory; - short myVerboseLevel; - bool myToCreateNewNodes; - bool myToUseBoundaryRecoveryVersion; - string myTextOption; - -}; - - -#endif diff --git a/src/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin_Hypothesis_i.cxx deleted file mode 100644 index 3cec323..0000000 --- a/src/GHS3DPlugin_Hypothesis_i.cxx +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright (C) 2004-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 : GHS3DPlugin_Hypothesis_i.cxx -// Created : Wed Apr 2 13:53:01 2008 -// Author : Edward AGAPOV (eap) -// -#include "GHS3DPlugin_Hypothesis_i.hxx" - -#include -#include - -#include -#include -#include - -//======================================================================= -//function : GHS3DPlugin_Hypothesis_i -//======================================================================= - -GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl) - : SALOME::GenericObj_i( thePOA ), - SMESH_Hypothesis_i( thePOA ) -{ - MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" ); - myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(), - theStudyId, - theGenImpl); -} - -//======================================================================= -//function : ~GHS3DPlugin_Hypothesis_i -//======================================================================= - -GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i() -{ - MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" ); -} - -//======================================================================= -//function : SetToMeshHoles -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh) -{ - ASSERT(myBaseImpl); - this->GetImpl()->SetToMeshHoles(toMesh); - SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )"; -} - -//======================================================================= -//function : GetToMeshHoles -//======================================================================= - -CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles() -{ - ASSERT(myBaseImpl); - return this->GetImpl()->GetToMeshHoles(); -} - -//======================================================================= -//function : SetMaximumMemory -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB) - throw ( SALOME::SALOME_Exception ) -{ - if ( MB == 0 ) - THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); - ASSERT(myBaseImpl); - this->GetImpl()->SetMaximumMemory(MB); - SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )"; -} - -//======================================================================= -//function : GetMaximumMemory -//======================================================================= - -CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory() -{ - ASSERT(myBaseImpl); - return this->GetImpl()->GetMaximumMemory(); -} - -//======================================================================= -//function : SetInitialMemory -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB) - throw ( SALOME::SALOME_Exception ) -{ - if ( MB == 0 ) - THROW_SALOME_CORBA_EXCEPTION( "Invalid memory size",SALOME::BAD_PARAM ); - ASSERT(myBaseImpl); - this->GetImpl()->SetInitialMemory(MB); - SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )"; -} - -//======================================================================= -//function : GetInitialMemory -//======================================================================= - -CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory() -{ - ASSERT(myBaseImpl); - return this->GetImpl()->GetInitialMemory(); -} - -//======================================================================= -//function : SetOptimizationLevel -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level) - throw ( SALOME::SALOME_Exception ) -{ - ::GHS3DPlugin_Hypothesis::OptimizationLevel l = - (::GHS3DPlugin_Hypothesis::OptimizationLevel) level; - if ( l < ::GHS3DPlugin_Hypothesis::None || - l > ::GHS3DPlugin_Hypothesis::Strong ) - THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM ); - - ASSERT(myBaseImpl); - this->GetImpl()->SetOptimizationLevel(l); - SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )"; -} - -//======================================================================= -//function : GetOptimizationLevel -//======================================================================= - -CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel() -{ - ASSERT(myBaseImpl); - return this->GetImpl()->GetOptimizationLevel(); -} - -//======================================================================= -//function : SetWorkingDirectory -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception ) -{ - if (!path ) - THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM ); - - string file(path); - const char lastChar = *file.rbegin(); -#ifdef WIN32 - if ( lastChar != '\\' ) file += '\\'; -#else - if ( lastChar != '/' ) file += '/'; -#endif - file += "GHS3D.log"; - SMESH_Mesh_i::PrepareForWriting (file.c_str()); - - ASSERT(myBaseImpl); - this->GetImpl()->SetWorkingDirectory(path); - SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )"; -} - -//======================================================================= -//function : GetWorkingDirectory -//======================================================================= - -char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory() -{ - ASSERT(myBaseImpl); - return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() ); -} - -//======================================================================= -//function : SetKeepFiles -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep) -{ - ASSERT(myBaseImpl); - this->GetImpl()->SetKeepFiles(toKeep); - SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )"; -} - -//======================================================================= -//function : GetKeepFiles -//======================================================================= - -CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles() -{ - ASSERT(myBaseImpl); - return this->GetImpl()->GetKeepFiles(); -} - -//======================================================================= -//function : SetVerboseLevel -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetVerboseLevel(CORBA::Short level) - throw ( SALOME::SALOME_Exception ) -{ - if (level < 0 || level > 10 ) - THROW_SALOME_CORBA_EXCEPTION( "Invalid verbose level, valid range is [0-10]", - SALOME::BAD_PARAM ); - ASSERT(myBaseImpl); - this->GetImpl()->SetVerboseLevel(level); - SMESH::TPythonDump() << _this() << ".SetVerboseLevel( " << level << " )"; -} - -//======================================================================= -//function : GetVerboseLevel -//======================================================================= - -CORBA::Short GHS3DPlugin_Hypothesis_i::GetVerboseLevel() -{ - ASSERT(myBaseImpl); - return this->GetImpl()->GetVerboseLevel(); -} - -//======================================================================= -//function : SetToCreateNewNodes -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetToCreateNewNodes(CORBA::Boolean toCreate) -{ - ASSERT(myBaseImpl); - this->GetImpl()->SetToCreateNewNodes(toCreate); - SMESH::TPythonDump() << _this() << ".SetToCreateNewNodes( " << toCreate << " )"; -} - -//======================================================================= -//function : GetToCreateNewNodes -//======================================================================= - -CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToCreateNewNodes() -{ - ASSERT(myBaseImpl); - return this->GetImpl()->GetToCreateNewNodes(); -} - -//======================================================================= -//function : SetToUseBoundaryRecoveryVersion -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse) -{ - ASSERT(myBaseImpl); - this->GetImpl()->SetToUseBoundaryRecoveryVersion(toUse); - SMESH::TPythonDump() << _this() << ".SetToUseBoundaryRecoveryVersion( " << toUse << " )"; -} - -//======================================================================= -//function : GetToUseBoundaryRecoveryVersion -//======================================================================= - -CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion() -{ - ASSERT(myBaseImpl); - return this->GetImpl()->GetToUseBoundaryRecoveryVersion(); -} - -//======================================================================= -//function : SetTextOption -//======================================================================= - -void GHS3DPlugin_Hypothesis_i::SetTextOption(const char* option) -{ - ASSERT(myBaseImpl); - this->GetImpl()->SetTextOption(option); - SMESH::TPythonDump() << _this() << ".SetTextOption( '" << option << "' )"; -} - -//======================================================================= -//function : GetTextOption -//======================================================================= - -char* GHS3DPlugin_Hypothesis_i::GetTextOption() -{ - ASSERT(myBaseImpl); - return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() ); -} - -//============================================================================= -/*! - * Get implementation - */ -//============================================================================= - -::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl() -{ - return (::GHS3DPlugin_Hypothesis*)myBaseImpl; -} - -//================================================================================ -/*! - * \brief Verify whether hypothesis supports given entity type - */ -//================================================================================ - -CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type ) -{ - return type == SMESH::DIM_3D; -} - diff --git a/src/GHS3DPlugin_Hypothesis_i.hxx b/src/GHS3DPlugin_Hypothesis_i.hxx deleted file mode 100644 index 60704e4..0000000 --- a/src/GHS3DPlugin_Hypothesis_i.hxx +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2004-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 -// -// GHS3DPlugin : C++ implementation -// File : GHS3DPlugin_Hypothesis_i.hxx -// Date : 03/04/2006 -// Project : SALOME -// -#ifndef _GHS3DPlugin_Hypothesis_i_HXX_ -#define _GHS3DPlugin_Hypothesis_i_HXX_ - -#include "GHS3DPlugin_Defs.hxx" - -#include -#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) - -#include "SMESH_Hypothesis_i.hxx" -#include "GHS3DPlugin_Hypothesis.hxx" - -class SMESH_Gen; - -// GHS3DPlugin parameters hypothesis - -class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i: - public virtual POA_GHS3DPlugin::GHS3DPlugin_Hypothesis, - public virtual SMESH_Hypothesis_i -{ - public: - // Constructor - GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl); - // Destructor - virtual ~GHS3DPlugin_Hypothesis_i(); - - /*! - * To mesh "holes" in a solid or not. Default is to mesh. - */ - void SetToMeshHoles(CORBA::Boolean toMesh); - CORBA::Boolean GetToMeshHoles(); - /*! - * Maximal size of memory to be used by the algorithm (in Megabytes) - */ - void SetMaximumMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); - CORBA::Short GetMaximumMemory(); - /*! - * Initial size of memory to be used by the algorithm (in Megabytes) in - * automatic memory adjustment mode. Default is zero - */ - void SetInitialMemory(CORBA::Short MB) throw ( SALOME::SALOME_Exception ); - CORBA::Short GetInitialMemory(); - /*! - * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium - */ - void SetOptimizationLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception ); - CORBA::Short GetOptimizationLevel(); - /*! - * Path to working directory - */ - void SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception ); - char* GetWorkingDirectory(); - /*! - * To keep working files or remove them. Log file remains in case of errors anyway. - */ - void SetKeepFiles(CORBA::Boolean toKeep); - CORBA::Boolean GetKeepFiles(); - /*! - * Verbose level [0-10] - * 0 - no standard output, - * 2 - prints the data, quality statistics of the skin and final meshes and - * indicates when the final mesh is being saved. In addition the software - * gives indication regarding the CPU time. - * 10 - same as 2 plus the main steps in the computation, quality statistics - * histogram of the skin mesh, quality statistics histogram together with - * the characteristics of the final mesh. - */ - void SetVerboseLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception ); - CORBA::Short GetVerboseLevel(); - /*! - * To create new nodes - */ - void SetToCreateNewNodes(CORBA::Boolean toCreate); - CORBA::Boolean GetToCreateNewNodes(); - /*! - * To use boundary recovery version which tries to create mesh on a very poor - * quality surface mesh - */ - void SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse); - CORBA::Boolean GetToUseBoundaryRecoveryVersion(); - /*! - * To set hiden/undocumented/advanced options - */ - void SetTextOption(const char* option); - char* GetTextOption(); - - // Get implementation - ::GHS3DPlugin_Hypothesis* GetImpl(); - - // Verify whether hypothesis supports given entity type - CORBA::Boolean IsDimSupported( SMESH::Dimension type ); -}; - -#endif diff --git a/src/GHS3DPlugin_i.cxx b/src/GHS3DPlugin_i.cxx deleted file mode 100644 index 20188c2..0000000 --- a/src/GHS3DPlugin_i.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2004-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 -// -// SMESH GHS3DPlugin : implementaion of SMESH idl descriptions -// File : GHS3DPlugin.cxx -// Author : Julia DOROVSKIKH -// Module : SMESH -// $Header$ -// -using namespace std; -#include "SMESH_Hypothesis_i.hxx" - -#include "utilities.h" - -#include "GHS3DPlugin_GHS3D_i.hxx" -#include "GHS3DPlugin_Hypothesis_i.hxx" - -template class GHS3DPlugin_Creator_i:public HypothesisCreator_i -{ - // as we have 'module GHS3DPlugin' in GHS3DPlugin_Algorithm.idl - virtual std::string GetModuleName() { return "GHS3DPlugin"; } -}; - -//============================================================================= -/*! - * - */ -//============================================================================= - -extern "C" -{ - GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName) - { - MESSAGE("GetHypothesisCreator " << aHypName); - - GenericHypothesisCreator_i* aCreator = 0; - - // Hypotheses - - // Algorithm - if (strcmp(aHypName, "GHS3D_3D") == 0) - aCreator = new GHS3DPlugin_Creator_i; - // Hypothesis - else if (strcmp(aHypName, "GHS3D_Parameters") == 0) - aCreator = new GHS3DPlugin_Creator_i; - else ; - - return aCreator; - } -} diff --git a/src/GUI/GHS3DPluginGUI.cxx b/src/GUI/GHS3DPluginGUI.cxx new file mode 100644 index 0000000..905c9b3 --- /dev/null +++ b/src/GUI/GHS3DPluginGUI.cxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2012 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 : GHS3DPluginGUI.cxx +// Authors : Gilles DAVID (Euriware) +// --- +// +#include "GHS3DPluginGUI_HypothesisCreator.h" + +//============================================================================= +/*! GetHypothesisCreator + * + */ +//============================================================================= +extern "C" +{ + GHS3DPLUGINGUI_EXPORT + SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType ) + { + SMESHGUI_GenericHypothesisCreator* aCreator = NULL; + if ( aHypType == "GHS3D_Parameters" ) + aCreator = new GHS3DPluginGUI_HypothesisCreator( aHypType ); + return aCreator; + } +} diff --git a/src/GUI/GHS3DPluginGUI_Enums.h b/src/GUI/GHS3DPluginGUI_Enums.h new file mode 100644 index 0000000..8516565 --- /dev/null +++ b/src/GUI/GHS3DPluginGUI_Enums.h @@ -0,0 +1,84 @@ +// Copyright (C) 2004-2012 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 +// + +// GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin +// File : GHS3DPluginGUI_Enums.h +// Author : Gilles DAVID (Euriware) +// Module : GHS3DPlugin +// +#ifndef GHS3DPLUGINGUI_Enums_HeaderFile +#define GHS3DPLUGINGUI_Enums_HeaderFile + +// tabs +enum { + STD_TAB = 0, + ADV_TAB, + ENF_VER_TAB, + ENF_MESH_TAB +}; + +// Enforced vertices array columns +enum { + ENF_VER_NAME_COLUMN = 0, + ENF_VER_X_COLUMN, + ENF_VER_Y_COLUMN, + ENF_VER_Z_COLUMN, + ENF_VER_SIZE_COLUMN, + ENF_VER_ENTRY_COLUMN, + ENF_VER_COMPOUND_COLUMN, + ENF_VER_GROUP_COLUMN, + ENF_VER_NB_COLUMNS +}; + +// Enforced meshes array columns +enum { + ENF_MESH_NAME_COLUMN = 0, + ENF_MESH_ENTRY_COLUMN, + ENF_MESH_CONSTRAINT_COLUMN, + ENF_MESH_SIZE_COLUMN, + ENF_MESH_GROUP_COLUMN, + ENF_MESH_NB_COLUMNS +}; + +// Enforced vertices widget inputs +enum { + ENF_VER_WARNING = 0, + ENF_VER_VERTEX /*= 0*/, + ENF_VER_X_COORD, + ENF_VER_Y_COORD, + ENF_VER_Z_COORD, + ENF_VER_SIZE, + ENF_VER_GROUP, + ENF_VER_BTN, + ENF_VER_NB_LINES +}; + +// Enforced meshes widget inputs +enum { + ENF_MESH_WARNING = 0, + ENF_MESH_MESH /*= 0*/, + ENF_MESH_CONSTRAINT, + ENF_MESH_SIZE, + ENF_MESH_GROUP, + ENF_MESH_BTN, + ENF_MESH_NB_LINES +}; + + +#endif diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx index 411036e..6c097cc 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx @@ -1,21 +1,22 @@ -// Copyright (C) 2004-2008 CEA/DEN, EDF R&D +// Copyright (C) 2004-2012 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 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin // File : GHS3DPluginGUI_HypothesisCreator.cxx // Author : Michael Zorin @@ -23,44 +24,74 @@ // $Header: // #include "GHS3DPluginGUI_HypothesisCreator.h" +// #include "GHS3DPluginGUI_EnforcedDelegates.h" +#include "GHS3DPluginGUI_Enums.h" + +#include "GeometryGUI.h" #include +#include #include +#include +#include +#include -#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) - -#include +#include #include -#include +#include #include +#include #include +#include + +#include -#include #include +#include +#include #include -#include #include +#include #include #include #include #include #include #include +#include + +#include +#include +#include -enum { - STD_TAB = 0, - ADV_TAB -}; +#include +#include + +#include namespace { -#ifndef WIN32 +#ifdef WIN32 +#include +#else #include #endif int maxAvailableMemory() { -#ifndef WIN32 +#ifdef WIN32 + // See http://msdn.microsoft.com/en-us/library/aa366589.aspx + MEMORYSTATUSEX statex; + statex.dwLength = sizeof (statex); + int err = GlobalMemoryStatusEx (&statex); + if (err != 0) { + int totMB = + statex.ullTotalPhys / 1024 / 1024 + + statex.ullTotalPageFile / 1024 / 1024 + + statex.ullTotalVirtual / 1024 / 1024; + return (int) ( 0.7 * totMB ); + } +#else struct sysinfo si; int err = sysinfo( &si ); if ( err == 0 ) { @@ -70,17 +101,284 @@ namespace { return (int) ( 0.7 * totMB ); } #endif - return 100000; + return 0; } } +// +// BEGIN EnforcedVertexTableWidgetDelegate +// + +EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent) + : QItemDelegate(parent) +{ +} + +QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem & option , + const QModelIndex & index ) const +{ + QModelIndex father = index.parent(); + QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString(); + + if (index.column() == ENF_VER_X_COLUMN || + index.column() == ENF_VER_Y_COLUMN || + index.column() == ENF_VER_Z_COLUMN || + index.column() == ENF_VER_SIZE_COLUMN) { + SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent); + if (index.column() == ENF_VER_SIZE_COLUMN) + editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); + else + editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + editor->setReadOnly(!entry.isEmpty()); + editor->setDisabled(!entry.isEmpty()); + return editor; + } +// else if (index.column() == ENF_VER_COMPOUND_COLUMN) { +// QCheckBox *editor = new QCheckBox(parent); +// editor->setDisabled(!entry.isEmpty()); +// return editor; +// } + else if (index.column() == ENF_VER_GROUP_COLUMN || + index.column() == ENF_VER_NAME_COLUMN) { +// else { + QLineEdit *editor = new QLineEdit(parent); + if (index.column() != ENF_VER_GROUP_COLUMN) { + editor->setReadOnly(!entry.isEmpty()); + editor->setDisabled(!entry.isEmpty()); + } + return editor; + } + return QItemDelegate::createEditor(parent, option, index); +} + +void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const +{ + if (index.column() == ENF_VER_X_COLUMN || + index.column() == ENF_VER_Y_COLUMN || + index.column() == ENF_VER_Z_COLUMN || + index.column() == ENF_VER_SIZE_COLUMN) + { + SMESHGUI_SpinBox *lineEdit = qobject_cast(editor); + lineEdit->SetValue(index.data().toDouble()); + } + else if (index.column() == ENF_VER_COMPOUND_COLUMN) { + QCheckBox *checkBox = qobject_cast(editor); + checkBox->setChecked(index.data().toBool()); + } + else { + QItemDelegate::setEditorData(editor, index); + } +} + +void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const +{ + QModelIndex parent = index.parent(); + + QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString(); + bool isCompound = parent.child(index.row(), ENF_VER_COMPOUND_COLUMN).data(Qt::CheckStateRole).toBool(); + + if (index.column() == ENF_VER_X_COLUMN || + index.column() == ENF_VER_Y_COLUMN || + index.column() == ENF_VER_Z_COLUMN) { + SMESHGUI_SpinBox *lineEdit = qobject_cast(editor); + if (!isCompound && !vertexExists(model, index, lineEdit->GetString())) + model->setData(index, lineEdit->GetValue(), Qt::EditRole); + } + else if (index.column() == ENF_VER_SIZE_COLUMN) + { + SMESHGUI_SpinBox *lineEdit = qobject_cast(editor); + const double newsize = lineEdit->GetValue(); + if (newsize > 0) + model->setData(index, newsize, Qt::EditRole); + } + else if (index.column() == ENF_VER_NAME_COLUMN) { + QLineEdit *lineEdit = qobject_cast(editor); + QString value = lineEdit->text(); + if (entry.isEmpty() && !vertexExists(model, index, value)) + model->setData(index, value, Qt::EditRole); + } + else if (index.column() == ENF_VER_ENTRY_COLUMN) { + QLineEdit *lineEdit = qobject_cast(editor); + QString value = lineEdit->text(); + if (! vertexExists(model, index, value)) + model->setData(index, value, Qt::EditRole); + } + else if (index.column() == ENF_VER_COMPOUND_COLUMN) { + QCheckBox *checkBox = qobject_cast(editor); + model->setData(index, checkBox->isChecked(), Qt::CheckStateRole); + } + else { + QItemDelegate::setModelData(editor, model, index); + } +} + +void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &/* index */) const +{ + editor->setGeometry(option.rect); +} + +bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model, + const QModelIndex &index, + QString value) const +{ + bool exists = false; + QModelIndex parent = index.parent(); + int row = index.row(); + int col = index.column(); + + if (parent.isValid() && !value.isEmpty()) { + if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) { + double x, y, z; + if (col == ENF_VER_X_COLUMN) { + x = value.toDouble(); + y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble(); + z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble(); + } + if (col == ENF_VER_Y_COLUMN) { + y = value.toDouble(); + x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble(); + z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble(); + } + if (col == ENF_VER_Z_COLUMN) { + z = value.toDouble(); + x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble(); + y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble(); + } + int nbChildren = model->rowCount(parent); + for (int i = 0 ; i < nbChildren ; i++) { + if (i != row) { + double childX = parent.child(i, ENF_VER_X_COLUMN).data().toDouble(); + double childY = parent.child(i, ENF_VER_Y_COLUMN).data().toDouble(); + double childZ = parent.child(i, ENF_VER_Z_COLUMN).data().toDouble(); + if ((childX == x) && (childY == y) && (childZ == z)) { + exists = true; + break; + } + } + } + } + else if (col == ENF_VER_NAME_COLUMN) { + QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString(); + if (name == value) + exists = true; + } + } + + return exists; +} + +// +// END EnforcedVertexTableWidgetDelegate +// + +// +// BEGIN EnforcedMeshTableWidgetDelegate +// + +EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent) + : QItemDelegate(parent) +{ +} + +QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem & option , + const QModelIndex & index ) const +{ + if (index.column() == ENF_MESH_SIZE_COLUMN) { + SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent); + editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); + return editor; + } + return QItemDelegate::createEditor(parent, option, index); +} + +void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const +{ + if (index.column() == ENF_MESH_SIZE_COLUMN) { + SMESHGUI_SpinBox *spinBox = qobject_cast(editor); + spinBox->SetValue(index.data().toDouble()); + } + else + QItemDelegate::setEditorData(editor, index); +} + +void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const +{ + if (index.column() == ENF_MESH_SIZE_COLUMN) + { + SMESHGUI_SpinBox *spinBox = qobject_cast(editor); + const double newsize = spinBox->GetValue(); + if (newsize > 0) + model->setData(index, newsize, Qt::EditRole); + } + else + QItemDelegate::setModelData(editor, model, index); + +} + +void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &/* index */) const +{ + editor->setGeometry(option.rect); +} + +// bool EnforcedMeshTableWidgetDelegate::enfMeshExists(QAbstractItemModel *model, +// const QModelIndex &index, +// QString value) const +// { +// bool exists = false; +// QModelIndex parent = index.parent(); +// int row = index.row(); +// int col = index.column(); +// return exists; +// } + +// +// END EnforcedMeshTableWidgetDelegate +// + + GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QString& theHypType ) : SMESHGUI_GenericHypothesisCreator( theHypType ) { + GeomToolSelected = NULL; + GeomToolSelected = getGeomSelectionTool(); + + iconVertex = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX"))); + iconCompound = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND"))); +// mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI()); + myEnfMeshConstraintLabels << tr( "GHS3D_ENF_MESH_CONSTRAINT_NODE" ) << tr( "GHS3D_ENF_MESH_CONSTRAINT_EDGE" ) << tr("GHS3D_ENF_MESH_CONSTRAINT_FACE"); } GHS3DPluginGUI_HypothesisCreator::~GHS3DPluginGUI_HypothesisCreator() { + GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myEnfMeshWdg->deactivateSelection(); +} + +/** + * \brief {Get or create the geom selection tool for active study} + * */ +GeomSelectionTools* GHS3DPluginGUI_HypothesisCreator::getGeomSelectionTool() +{ + GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) { + that->GeomToolSelected = new GeomSelectionTools(aStudy); + } + return that->GeomToolSelected; +} + +GEOM::GEOM_Gen_var GHS3DPluginGUI_HypothesisCreator::getGeomEngine() +{ + return GeometryGUI::GetGeomGen(); } QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() @@ -114,15 +412,15 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), myStdGroup ); aStdLayout->addWidget( myToMeshHolesCheck, row++, 0, 1, 2 ); - aStdLayout->addWidget( new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0 ); + aStdLayout->addWidget( new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0, 1, 1 ); myOptimizationLevelCombo = new QComboBox( myStdGroup ); aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 ); QStringList types; - types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STRONG" ); + types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" ); myOptimizationLevelCombo->addItems( types ); - aStdLayout->setRowStretch( row, 5 ); + aStdLayout->setRowStretch( row, 10 ); // advanced parameters myAdvGroup = new QWidget(); @@ -160,31 +458,208 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myToCreateNewNodesCheck = new QCheckBox( tr( "TO_ADD_NODES" ), myAdvGroup ); + myRemoveInitialCentralPointCheck = new QCheckBox( tr( "NO_INITIAL_CENTRAL_POINT" ), myAdvGroup ); + myBoundaryRecoveryCheck = new QCheckBox( tr( "RECOVERY_VERSION" ), myAdvGroup ); + + myFEMCorrectionCheck = new QCheckBox( tr( "FEM_CORRECTION" ), myAdvGroup ); QLabel* aTextOptionLabel = new QLabel( tr( "TEXT_OPTION" ), myAdvGroup ); myTextOption = new QLineEdit( myAdvGroup ); - anAdvLayout->addWidget( myMaximumMemoryCheck, 0, 0, 1, 1 ); - anAdvLayout->addWidget( myMaximumMemorySpin, 0, 1, 1, 1 ); - anAdvLayout->addWidget( aMegabyteLabel, 0, 2, 1, 1 ); - anAdvLayout->addWidget( myInitialMemoryCheck, 1, 0, 1, 1 ); - anAdvLayout->addWidget( myInitialMemorySpin, 1, 1, 1, 1 ); - anAdvLayout->addWidget( aMegabyteLabel2, 1, 2, 1, 1 ); - anAdvLayout->addWidget( aWorkinDirLabel, 2, 0, 1, 1 ); - anAdvLayout->addWidget( myWorkingDir, 2, 1, 1, 2 ); - anAdvLayout->addWidget( dirBtn, 2, 3, 1, 1 ); - anAdvLayout->addWidget( myKeepFiles, 3, 0, 1, 4 ); - anAdvLayout->addWidget( aVerboseLevelLabel, 4, 0, 1, 1 ); - anAdvLayout->addWidget( myVerboseLevelSpin, 4, 1, 1, 1 ); - anAdvLayout->addWidget( myToCreateNewNodesCheck, 5, 0, 1, 4 ); - anAdvLayout->addWidget( myBoundaryRecoveryCheck, 6, 0, 1, 4 ); - anAdvLayout->addWidget( aTextOptionLabel, 7, 0, 1, 1 ); - anAdvLayout->addWidget( myTextOption, 7, 1, 1, 2 ); + anAdvLayout->addWidget( myMaximumMemoryCheck, 0, 0, 1, 1 ); + anAdvLayout->addWidget( myMaximumMemorySpin, 0, 1, 1, 1 ); + anAdvLayout->addWidget( aMegabyteLabel, 0, 2, 1, 1 ); + anAdvLayout->addWidget( myInitialMemoryCheck, 1, 0, 1, 1 ); + anAdvLayout->addWidget( myInitialMemorySpin, 1, 1, 1, 1 ); + anAdvLayout->addWidget( aMegabyteLabel2, 1, 2, 1, 1 ); + anAdvLayout->addWidget( aWorkinDirLabel, 2, 0, 1, 1 ); + anAdvLayout->addWidget( myWorkingDir, 2, 1, 1, 2 ); + anAdvLayout->addWidget( dirBtn, 2, 3, 1, 1 ); + anAdvLayout->addWidget( myKeepFiles, 3, 0, 1, 4 ); + anAdvLayout->addWidget( aVerboseLevelLabel, 4, 0, 1, 1 ); + anAdvLayout->addWidget( myVerboseLevelSpin, 4, 1, 1, 1 ); + anAdvLayout->addWidget( myToCreateNewNodesCheck, 5, 0, 1, 4 ); + anAdvLayout->addWidget( myRemoveInitialCentralPointCheck, 6, 0, 1, 4 ); + anAdvLayout->addWidget( myBoundaryRecoveryCheck, 7, 0, 1, 4 ); + anAdvLayout->addWidget( myFEMCorrectionCheck, 8, 0, 1, 4 ); + anAdvLayout->addWidget( aTextOptionLabel, 9, 0, 1, 1 ); + anAdvLayout->addWidget( myTextOption, 9, 1, 1, 2 ); + + // Enforced vertices parameters + myEnfGroup = new QWidget(); + QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup); + + myEnforcedTableWidget = new QTableWidget(myEnfGroup); + myEnforcedTableWidget ->setMinimumWidth(300); + myEnforcedTableWidget->setRowCount( 0 ); + myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS ); + myEnforcedTableWidget->setSortingEnabled(true); + QStringList enforcedHeaders; + enforcedHeaders << tr( "GHS3D_ENF_NAME_COLUMN" ) + << tr( "GHS3D_ENF_VER_X_COLUMN" )<< tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" ) + << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN") << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" ); + + myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders); + myEnforcedTableWidget->verticalHeader()->hide(); + myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true); + myEnforcedTableWidget->setAlternatingRowColors(true); + myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); + myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems); + myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive); + myEnforcedTableWidget->resizeColumnsToContents(); + myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN); + myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN); + + myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate()); + +// VERTEX SELECTION + TColStd_MapOfInteger shapeTypes; + shapeTypes.Add( TopAbs_VERTEX ); + shapeTypes.Add( TopAbs_COMPOUND ); + + SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes); + myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false); + myEnfVertexWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }"); + + QLabel* myXCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_X_LABEL" ), myEnfGroup ); + myXCoord = new SMESHGUI_SpinBox(myEnfGroup); + myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + QLabel* myYCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Y_LABEL" ), myEnfGroup ); + myYCoord = new SMESHGUI_SpinBox(myEnfGroup); + myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + QLabel* myZCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Z_LABEL" ), myEnfGroup ); + myZCoord = new SMESHGUI_SpinBox(myEnfGroup); + myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + QLabel* mySizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfGroup ); + mySizeValue = new SMESHGUI_SpinBox(myEnfGroup); + mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + + QLabel* myGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfGroup ); + myGroupName = new QLineEdit(myEnfGroup); + + addVertexButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfGroup); + addVertexButton->setEnabled(false); + removeVertexButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfGroup); +// myGlobalGroupName = new QCheckBox(tr("GHS3D_ENF_VER_GROUPS"), myEnfGroup); +// myGlobalGroupName->setChecked(false); + + QGroupBox* GroupBox = new QGroupBox( myEnfGroup ); + QLabel* info = new QLabel( GroupBox ); + info->setText( tr( "GHS3D_ENF_VER_INFO" ) ); + info->setWordWrap( true ); + QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox ); + GroupBoxVLayout->setSpacing( 6 ); + GroupBoxVLayout->setMargin( 11 ); + GroupBoxVLayout->addWidget( info ); + + + anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 ); + anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1); + + QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup); + anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2); + anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1); + anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1); + anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1); + anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1); + anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1); + anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1); + anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1); + anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1); + anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1); + anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1); + anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1); + + anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1); + anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10); + + + // Enforced meshes parameters + myEnfMeshGroup = new QWidget(); + QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup); + + myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup); + myEnforcedMeshTableWidget->setRowCount( 0 ); + myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS ); + myEnforcedMeshTableWidget->setSortingEnabled(true); + myEnforcedMeshTableWidget->verticalHeader()->hide(); + QStringList enforcedMeshHeaders; + enforcedMeshHeaders << tr( "GHS3D_ENF_NAME_COLUMN" ) + << tr( "GHS3D_ENF_ENTRY_COLUMN" ) + << tr( "GHS3D_ENF_MESH_CONSTRAINT_COLUMN" ) + << tr( "GHS3D_ENF_SIZE_COLUMN" ) + << tr( "GHS3D_ENF_GROUP_COLUMN" ); + myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders); + myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true); + myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive); + myEnforcedMeshTableWidget->setAlternatingRowColors(true); + myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); + myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems); + myEnforcedMeshTableWidget->resizeColumnsToContents(); + myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN); + + myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate()); + +// myEnfMesh = SMESH::SMESH_Mesh::_nil(); +// myEnfMeshArray = new SMESH::mesh_array(); + + myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( IDSOURCE, myEnfMeshGroup, /*multiSel=*/true); + myEnfMeshWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_MESH"), "QLineEdit { color: grey }"); + + myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg); + + QLabel* myMeshConstraintLabel = new QLabel( tr( "GHS3D_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup ); + myEnfMeshConstraint = new QComboBox(myEnfMeshGroup); + myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels); + myEnfMeshConstraint->setEditable(false); + myEnfMeshConstraint->setCurrentIndex(0); + + QLabel* myMeshSizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfMeshGroup ); + myMeshSizeValue = new SMESHGUI_SpinBox(myEnfMeshGroup); + myMeshSizeValue->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); + QLabel* myMeshGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfMeshGroup ); + myMeshGroupName = new QLineEdit(myEnfMeshGroup); + + addEnfMeshButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfMeshGroup); +// addEnfMeshButton->setEnabled(false); + removeEnfMeshButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfMeshGroup); + + QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup ); + QLabel* info2 = new QLabel( GroupBox2 ); + info2->setText( tr( "GHS3D_ENF_MESH_INFO" ) ); + info2->setWordWrap( true ); + QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 ); + GroupBox2VLayout->setSpacing( 6 ); + GroupBox2VLayout->setMargin( 11 ); + GroupBox2VLayout->addWidget( info2 ); + + anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 ); + anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1); + + QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup); + anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2); + anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1); + anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1); + anEnfMeshLayout2->addWidget(myMeshSizeLabel, ENF_MESH_SIZE, 0, 1, 1); + anEnfMeshLayout2->addWidget(myMeshSizeValue, ENF_MESH_SIZE, 1, 1, 1); + anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1); + anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1); + anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1); + anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1); + anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1); + + anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1); + anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10); + // add tabs tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) ); tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) ); + tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) ); + tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "GHS3D_ENFORCED_MESHES" ) ); tab->setCurrentIndex( STD_TAB ); // connections @@ -192,10 +667,758 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() connect( myInitialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); connect( myBoundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); connect( dirBtn, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) ); + connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) ); + connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) ); + connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) ); + connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) ); + connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) ); + connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); + connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) ); + connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) ); + connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) ); + connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) ); + + connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) ); + connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) ); +// connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) ); +// connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) ); +// connect( myMeshSizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkEnfMeshIsDefined() ) ); +// connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) ); return fr; } +/** + * This method checks if an enforced vertex is defined; +**/ +void GHS3DPluginGUI_HypothesisCreator::clearEnfVertexSelection() +{ + if (myEnfVertexWdg->NbObjects() != 0) { + disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); + disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) ); + myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil()); + connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); + connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) ); + } + GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; + that->checkVertexIsDefined(); +} + +/** + * This method checks if an enforced vertex is defined; +**/ +void GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined() +{ + bool enfVertexIsDefined = false; + enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() && + (!myEnfVertexWdg->NbObjects() == 0 || + (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty() + && !myYCoord->GetString().isEmpty() + && !myZCoord->GetString().isEmpty()))); + emit vertexDefined(enfVertexIsDefined); +} + +/** + * This method checks if an enforced mesh is defined; +**/ +void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined() +{ + emit enfMeshDefined((!myMeshSizeValue->GetString().isEmpty() && !myEnfVertexWdg->NbObjects() == 0)); +} + +/** + * This method resets the content of the X, Y, Z, size and GroupName widgets; +**/ +void GHS3DPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets() +{ + myXCoord->setCleared(true); + myYCoord->setCleared(true); + myZCoord->setCleared(true); +// mySizeValue->setCleared(true); + myXCoord->setText(""); + myYCoord->setText(""); + myZCoord->setText(""); +// mySizeValue->setText(""); +// myGroupName->setText(""); + addVertexButton->setEnabled(false); +} + +/** GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item) +This method updates the tooltip of a modified item. The QLineEdit widgets content +is synchronized with the coordinates of the enforced vertex clicked in the tree widget. +*/ +void GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) { +// MESSAGE("GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues"); + int row = myEnforcedTableWidget->row(item); + + QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole); + QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole); + QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole); + QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole); + QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole); + QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole); + QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString(); + + clearEnforcedVertexWidgets(); + + if ( !x.isNull() || !entry.isNull()) { + QString toolTip = vertexName.toString(); + toolTip += QString("("); + if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) { + toolTip += x.toString(); + toolTip += QString(", ") + y.toString(); + toolTip += QString(", ") + z.toString(); + } + else + toolTip += entry.toString(); + toolTip += QString(")"); + + if (!size.isNull()) + toolTip += QString("=") + size.toString(); + + if (!groupName.isEmpty()) + toolTip += QString(" [") + groupName + QString("]"); + +// MESSAGE("Tooltip: " << toolTip.toStdString()); + for (int col=0;colitem(row,col)->setToolTip(toolTip); + + if (!x.isNull()) { + disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + myXCoord->SetValue(x.toDouble()); + myYCoord->SetValue(y.toDouble()); + myZCoord->SetValue(z.toDouble()); + connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + } + if (!size.isNull()) + mySizeValue->SetValue(size.toDouble()); + + if (!groupName.isEmpty()) + myGroupName->setText(groupName); + } +} + +void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex() { + int nbSelEnfVertex = myEnfVertexWdg->NbObjects(); + clearEnforcedVertexWidgets(); + if (nbSelEnfVertex == 1) + { + if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() ) + return ; + + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1); + if (myEnfVertex == GEOM::GEOM_Object::_nil()) + return; + if (myEnfVertex->GetShapeType() == GEOM::VERTEX) { + GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; + GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() ); + if (CORBA::is_nil(measureOp)) + return; + + CORBA::Double x,y,z; + measureOp->PointCoordinates (myEnfVertex, x, y, z); + if ( measureOp->IsDone() ) + { + disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + myXCoord->SetValue(x); + myYCoord->SetValue(y); + myZCoord->SetValue(z); + connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + } + } + } +} + +/** GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() +This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates +of the enforced vertex clicked in the tree widget. +*/ +void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() { + clearEnforcedVertexWidgets(); + QList items = myEnforcedTableWidget->selectedItems(); +// myEnfVertexWdg->disconnect(SIGNAL(contentModified())); + disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); + if (! items.isEmpty()) { + QTableWidgetItem *item; + int row; + QVariant entry; + if (items.size() == 1) { + item = items[0]; + row = myEnforcedTableWidget->row(item); + QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole); + QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole); + QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole); + QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole); + entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole); + if (!entry.isNull()) { + SMESH::string_array_var objIds = new SMESH::string_array; + objIds->length(1); + objIds[0] = entry.toString().toStdString().c_str(); + myEnfVertexWdg->SetObjects(objIds); + } + else { + myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil()); + } + QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole); + if (!x.isNull()/* && entry.isNull()*/) { +// disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) ); + disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + myXCoord->SetValue(x.toDouble()); + myYCoord->SetValue(y.toDouble()); + myZCoord->SetValue(z.toDouble()); + connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) ); + } + if (!size.isNull()) + mySizeValue->SetValue(size.toDouble()); + + if (!group.isNull() && (!x.isNull() || !entry.isNull())) + myGroupName->setText(group.toString()); + } + else { + QList entryList; + for (int i = 0; i < items.size(); ++i) { + item = items[i]; + row = myEnforcedTableWidget->row(item); + entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole); + if (!entry.isNull()) + entryList << entry.toString(); + } + if (entryList.size() > 0) { + SMESH::string_array_var objIds = new SMESH::string_array; + objIds->length(entryList.size()); + for (int i = 0; i < entryList.size() ; i++) + objIds[i] = entryList.at(i).toStdString().c_str(); + myEnfVertexWdg->SetObjects(objIds); + } + else { + myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil()); + } + } + } + else { + myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil()); + } + connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); + GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; + that->checkVertexIsDefined(); +} + +/** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( meshName, geomEntry, elemType, size, groupName) +This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName. +*/ +void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, double size, std::string groupName) +{ + MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", " << size << ", \"" << groupName << "\")"); + bool okToCreate = true; + QString itemEntry = ""; + int itemElementType = 0; + int rowCount = myEnforcedMeshTableWidget->rowCount(); + bool allColumns = true; + for (int row = 0;row(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) { + allColumns = false; + MESSAGE("allColumns = false"); + break; + } + } + else if (myEnforcedMeshTableWidget->item(row, col) == 0) { + allColumns = false; + MESSAGE("allColumns = false"); + break; + } + if (col == ENF_MESH_CONSTRAINT_COLUMN) { + QComboBox* itemComboBox = qobject_cast(myEnforcedMeshTableWidget->cellWidget(row, col)); + itemElementType = itemComboBox->currentIndex(); + MESSAGE("itemElementType: " << itemElementType); + } + else if (col == ENF_MESH_ENTRY_COLUMN) + itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString(); + } + + if (!allColumns) + break; + + if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) { +// // update size +// if (itemSize != size) { +// MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\""); +// myEnforcedMeshTableWidget->item(row, ENF_MESH_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size)); +// } +// // update group name +// if (itemGroupName.toStdString() != groupName) { +// MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\""); +// myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str())); +// } + okToCreate = false; + break; + } // if + } // for + + + if (!okToCreate) + return; + + MESSAGE("Creation of enforced mesh"); + + myEnforcedMeshTableWidget->setRowCount(rowCount+1); + myEnforcedMeshTableWidget->setSortingEnabled(false); + + for (int col=0;colpalette(); + pal.setColor(QPalette::Button, Qt::white); + comboBox->setPalette(pal); + comboBox->insertItems(0,myEnfMeshConstraintLabels); + comboBox->setEditable(false); + comboBox->setCurrentIndex(elementType); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString()); + myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox); + } + else { + QTableWidgetItem* item = new QTableWidgetItem(); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + switch (col) { + case ENF_MESH_NAME_COLUMN: + item->setData( 0, name.c_str() ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_ENTRY_COLUMN: + item->setData( 0, entry.c_str() ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_SIZE_COLUMN: + item->setData( 0, size ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_GROUP_COLUMN: + item->setData( 0, groupName.c_str() ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + default: + break; + } + } + MESSAGE("Done"); + } + +// connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) ); + + myEnforcedMeshTableWidget->setSortingEnabled(true); +// myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); +// updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); + +} + +/** GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName) +This method adds in the tree widget an enforced vertex with given size and coords (x,y,z) or GEOM vertex or compound and with optionally groupName. +*/ +void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound) +{ + MESSAGE("addEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ", \"" << vertexName << ", \"" << geomEntry << "\", \"" << groupName << "\", " << isCompound << ")"); + myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *))); + bool okToCreate = true; + double itemX,itemY,itemZ,itemSize = 0; + QString itemEntry, itemGroupName = QString(""); +// bool itemIsCompound; + int rowCount = myEnforcedTableWidget->rowCount(); + QVariant data; + bool allColumns; + for (int row = 0;rowitem(row, col) == 0) { + allColumns = false; + break; + } + + data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole); + if (!data.isNull()) { + switch (col) { + case ENF_VER_GROUP_COLUMN: + itemGroupName = data.toString(); + break; + case ENF_VER_ENTRY_COLUMN: + itemEntry = data.toString(); + break; +// case ENF_VER_COMPOUND_COLUMN: +// itemIsCompound = data.toBool(); +// break; + case ENF_VER_X_COLUMN: + itemX = data.toDouble(); + break; + case ENF_VER_Y_COLUMN: + itemY = data.toDouble(); + break; + case ENF_VER_Z_COLUMN: + itemZ = data.toDouble(); + break; + case ENF_VER_SIZE_COLUMN: + itemSize = data.toDouble(); + break; + default: + break; + } + } + } + + if (!allColumns) + break; + + + if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) { + // update size + if (itemSize != size) { + MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\""); + myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size)); + } + // update group name + if (itemGroupName.toStdString() != groupName) { + MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\""); + myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str())); + } + okToCreate = false; + break; + } // if + } // for + if (!okToCreate) { + if (geomEntry.empty()) { + MESSAGE("Vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); + } + else { + MESSAGE("Vertex with entry " << geomEntry << " already exist: dont create again"); + } + return; + } + + if (geomEntry.empty()) { + MESSAGE("Vertex with coords " << x << ", " << y << ", " << z<< " is created"); + } + else { + MESSAGE("Vertex with geom entry " << geomEntry << " is created"); + } + + int vertexIndex=0; + int indexRef = -1; + QString myVertexName; + while(indexRef != vertexIndex) { + indexRef = vertexIndex; + if (vertexName.empty()) + myVertexName = QString("Vertex #%1").arg(vertexIndex); + else + myVertexName = QString(vertexName.c_str()); + + for (int row = 0;rowitem(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString(); + if (myVertexName == name) { + vertexIndex++; + break; + } + } + } + + MESSAGE("myVertexName is \"" << myVertexName.toStdString() << "\""); + myEnforcedTableWidget->setRowCount(rowCount+1); + myEnforcedTableWidget->setSortingEnabled(false); + for (int col=0;colsetFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + switch (col) { + case ENF_VER_NAME_COLUMN: + item->setData( Qt::EditRole, myVertexName ); + if (!geomEntry.empty()) { + if (isCompound) + item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + else + item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + } + break; + case ENF_VER_X_COLUMN: + if (!isCompound) + item->setData( 0, QVariant(x) ); + break; + case ENF_VER_Y_COLUMN: + if (!isCompound) + item->setData( 0, QVariant(y) ); + break; + case ENF_VER_Z_COLUMN: + if (!isCompound) + item->setData( 0, QVariant(z) ); + break; + case ENF_VER_SIZE_COLUMN: + item->setData( 0, QVariant(size) ); + break; + case ENF_VER_ENTRY_COLUMN: + if (!geomEntry.empty()) + item->setData( 0, QString(geomEntry.c_str()) ); + break; + case ENF_VER_COMPOUND_COLUMN: + item->setData( Qt::CheckStateRole, isCompound ); + item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); + break; + case ENF_VER_GROUP_COLUMN: + if (!groupName.empty()) + item->setData( 0, QString(groupName.c_str()) ); + break; + default: + break; + } + + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedTableWidget->setItem(rowCount,col,item); + MESSAGE("Done"); + } + + connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) ); + + myEnforcedTableWidget->setSortingEnabled(true); +// myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); + updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); +} + +/** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh() +This method is called when a item is added into the enforced meshes tree widget +*/ +void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh() +{ + MESSAGE("GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()"); + + GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; + + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myEnfMeshWdg->deactivateSelection(); + + for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column) + myEnforcedMeshTableWidget->resizeColumnToContents(column); + + // Vertex selection + int selEnfMeshes = myEnfMeshWdg->NbObjects(); + if (selEnfMeshes == 0) + return; + + std::string groupName = myMeshGroupName->text().toStdString(); +// if (myGlobalGroupName->isChecked()) +// groupName = myGlobalGroupName->text().toStdString(); + + if (boost::trim_copy(groupName).empty()) + groupName = ""; + + + double size = -1; + if (!myMeshSizeValue->GetString().isEmpty()) + size = myMeshSizeValue->GetValue(); +// if (size < 0) +// return; + + int elementType = myEnfMeshConstraint->currentIndex(); + + + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil; + QString meshEntry = myEnfMeshWdg->GetValue(); + MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString()); + + if (selEnfMeshes == 1) + { + MESSAGE("1 SMESH object selected"); +// myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >(); +// std::string entry = myEnfMeshWdg->GetValue(); + aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str()); + CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy); + if (!CORBA::is_nil(anObj)) { +// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface( aSObj ); + addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, size, groupName); + } + } + else + { + MESSAGE(selEnfMeshes << " SMESH objects selected"); + QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts); + QStringListIterator meshEntriesIt (meshEntries); + while (meshEntriesIt.hasNext()) { + aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str()); + CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy); + if (!CORBA::is_nil(anObj)) { +// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface( aSObj ); + addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, size, groupName); + } + } + } + + myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil()); + + for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column) + myEnforcedMeshTableWidget->resizeColumnToContents(column); +} + + +/** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex() +This method is called when a item is added into the enforced vertices tree widget +*/ +void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex() +{ + MESSAGE("GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()"); + + GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; + + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myEnfVertexWdg->deactivateSelection(); + + for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column) + myEnforcedTableWidget->resizeColumnToContents(column); + + // Vertex selection + int selEnfVertex = myEnfVertexWdg->NbObjects(); + bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty()); + if ((selEnfVertex == 0) && coordsEmpty) + return; + + std::string groupName = myGroupName->text().toStdString(); +// if (myGlobalGroupName->isChecked()) +// groupName = myGlobalGroupName->text().toStdString(); + + if (boost::trim_copy(groupName).empty()) + groupName = ""; + + double size = mySizeValue->GetValue(); + + if (selEnfVertex <= 1) + { + MESSAGE("0 or 1 GEOM object selected"); + double x = 0, y = 0, z=0; + if (myXCoord->GetString() != "") { + x = myXCoord->GetValue(); + y = myYCoord->GetValue(); + z = myZCoord->GetValue(); + } + if (selEnfVertex == 1) { + MESSAGE("1 GEOM object selected"); + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(); + std::string entry = ""; + if (myEnfVertex != GEOM::GEOM_Object::_nil()) + entry = myEnfVertex->GetStudyEntry(); + addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND); + } + else { + MESSAGE("0 GEOM object selected"); + MESSAGE("Coords: ("<GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() ); + if (CORBA::is_nil(measureOp)) + return; + + CORBA::Double x = 0, y = 0,z = 0; + for (int j = 0 ; j < selEnfVertex ; j++) + { + myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j); + if (myEnfVertex == GEOM::GEOM_Object::_nil()) + continue; + if (myEnfVertex->GetShapeType() == GEOM::VERTEX) { + measureOp->PointCoordinates (myEnfVertex, x, y, z); + if ( measureOp->IsDone() ) + addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName); + } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) { + addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true); + } + } + } + + myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil()); + + for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column) + myEnforcedTableWidget->resizeColumnToContents(column); +} + +/** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh() +This method is called when a item is removed from the enforced meshes tree widget +*/ +void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh() +{ + QList selectedRows; + QList selectedItems = myEnforcedMeshTableWidget->selectedItems(); + QTableWidgetItem* item; + int row; + foreach( item, selectedItems ) { + row = item->row(); + if (!selectedRows.contains( row ) ) + selectedRows.append(row); + } + + qSort( selectedRows ); + QListIterator it( selectedRows ); + it.toBack(); + while ( it.hasPrevious() ) { + row = it.previous(); + MESSAGE("delete row #"<< row); + myEnforcedMeshTableWidget->removeRow(row ); + } + + myEnforcedMeshTableWidget->selectionModel()->clearSelection(); +} + +/** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() +This method is called when a item is removed from the enforced vertices tree widget +*/ +void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() +{ + QList selectedRows; + QList selectedItems = myEnforcedTableWidget->selectedItems(); + QTableWidgetItem* item; + int row; + foreach( item, selectedItems ) { + row = item->row(); + if (!selectedRows.contains( row ) ) + selectedRows.append(row); + } + + qSort( selectedRows ); + QListIterator it( selectedRows ); + it.toBack(); + while ( it.hasPrevious() ) { + row = it.previous(); + MESSAGE("delete row #"<< row); + myEnforcedTableWidget->removeRow(row ); + } + + myEnforcedTableWidget->selectionModel()->clearSelection(); +} + void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked() { QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myWorkingDir->text(), QString() ); @@ -211,108 +1434,334 @@ void GHS3DPluginGUI_HypothesisCreator::updateWidgets() myOptimizationLevelCombo->setEnabled( !myBoundaryRecoveryCheck->isChecked() ); } -bool GHS3DPluginGUI_HypothesisCreator::checkParams() const +bool GHS3DPluginGUI_HypothesisCreator::checkParams(QString& msg) const { + MESSAGE("GHS3DPluginGUI_HypothesisCreator::checkParams"); + if ( !QFileInfo( myWorkingDir->text().trimmed() ).isWritable() ) { SUIT_MessageBox::warning( dlg(), - tr( "SMESH_WRN_WARNING" ), - tr( "GHS3D_PERMISSION_DENIED" ) ); + tr( "SMESH_WRN_WARNING" ), + tr( "GHS3D_PERMISSION_DENIED" ) ); return false; } + return true; } void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const { + MESSAGE("GHS3DPluginGUI_HypothesisCreator::retrieveParams"); + GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; GHS3DHypothesisData data; readParamsFromHypo( data ); if ( myName ) myName->setText( data.myName ); - myToMeshHolesCheck ->setChecked ( data.myToMeshHoles ); - myOptimizationLevelCombo->setCurrentIndex( data.myOptimizationLevel ); - myMaximumMemoryCheck ->setChecked ( data.myMaximumMemory > 0 ); - myMaximumMemorySpin ->setValue ( qMax( data.myMaximumMemory, - myMaximumMemorySpin->minimum() )); - myInitialMemoryCheck ->setChecked ( data.myInitialMemory > 0 ); - myInitialMemorySpin ->setValue ( qMax( data.myInitialMemory, - myInitialMemorySpin->minimum() )); - myWorkingDir ->setText ( data.myWorkingDir ); - myKeepFiles ->setChecked ( data.myKeepFiles ); - myVerboseLevelSpin ->setValue ( data.myVerboseLevel ); - myToCreateNewNodesCheck ->setChecked ( data.myToCreateNewNodes ); - myBoundaryRecoveryCheck ->setChecked ( data.myBoundaryRecovery ); - myTextOption ->setText ( data.myTextOption ); - - GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this; - that->updateWidgets(); -} - -QString GHS3DPluginGUI_HypothesisCreator::storeParams() const -{ - GHS3DHypothesisData data; - readParamsFromWidgets( data ); - storeParamsToHypo( data ); - - QString valStr = ""; + myToMeshHolesCheck ->setChecked ( data.myToMeshHoles ); + myOptimizationLevelCombo ->setCurrentIndex( data.myOptimizationLevel ); + myMaximumMemoryCheck ->setChecked ( data.myMaximumMemory > 0 ); + myMaximumMemorySpin ->setValue ( qMax( data.myMaximumMemory, + myMaximumMemorySpin->minimum() )); + myInitialMemoryCheck ->setChecked ( data.myInitialMemory > 0 ); + myInitialMemorySpin ->setValue ( qMax( data.myInitialMemory, + myInitialMemorySpin->minimum() )); + myWorkingDir ->setText ( data.myWorkingDir ); + myKeepFiles ->setChecked ( data.myKeepFiles ); + myVerboseLevelSpin ->setValue ( data.myVerboseLevel ); + myToCreateNewNodesCheck ->setChecked ( data.myToCreateNewNodes ); + myRemoveInitialCentralPointCheck ->setChecked ( data.myRemoveInitialCentralPoint ); + myBoundaryRecoveryCheck ->setChecked ( data.myBoundaryRecovery ); + myFEMCorrectionCheck ->setChecked ( data.myFEMCorrection ); + myTextOption ->setText ( data.myTextOption ); - if ( !data.myBoundaryRecovery ) - valStr = "-c " + QString::number( !data.myToMeshHoles ); + TEnfVertexList::const_iterator it; + int rowCount = 0; + myEnforcedTableWidget->setSortingEnabled(false); + myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *))); + for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ ) + { + TEnfVertex* enfVertex = (*it); + myEnforcedTableWidget->setRowCount(rowCount+1); - if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 4 && !data.myBoundaryRecovery) { - char* level[] = { "none" , "light" , "standard" , "strong" }; - valStr += " -o "; - valStr += level[ data.myOptimizationLevel ]; - } - if ( data.myMaximumMemory > 0 ) { - valStr += " -m "; - valStr += QString::number( data.myMaximumMemory ); - } - if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) { - valStr += " -M "; - valStr += QString::number( data.myInitialMemory ); + for (int col=0;colisCompound: " << enfVertex->isCompound); + QTableWidgetItem* item = new QTableWidgetItem(); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + switch (col) { + case ENF_VER_NAME_COLUMN: + item->setData( 0, enfVertex->name.c_str() ); + if (!enfVertex->geomEntry.empty()) { + if (enfVertex->isCompound) + item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + else + item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation))); + + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + } + break; + case ENF_VER_X_COLUMN: + if (!enfVertex->isCompound) { + item->setData( 0, enfVertex->coords.at(0) ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + } + break; + case ENF_VER_Y_COLUMN: + if (!enfVertex->isCompound) { + item->setData( 0, enfVertex->coords.at(1) ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + } + break; + case ENF_VER_Z_COLUMN: + if (!enfVertex->isCompound) { + item->setData( 0, enfVertex->coords.at(2) ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + } + break; + case ENF_VER_SIZE_COLUMN: + item->setData( 0, enfVertex->size ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + break; + case ENF_VER_ENTRY_COLUMN: + item->setData( 0, enfVertex->geomEntry.c_str() ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + break; + case ENF_VER_COMPOUND_COLUMN: + item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable); + item->setData( Qt::CheckStateRole, enfVertex->isCompound ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << enfVertex->isCompound); + break; + case ENF_VER_GROUP_COLUMN: + item->setData( 0, enfVertex->groupName.c_str() ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + break; + default: + break; + } + + myEnforcedTableWidget->setItem(rowCount,col,item); + MESSAGE("Done"); + } + that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); + rowCount++; } - valStr += " -v "; - valStr += QString::number( data.myVerboseLevel ); - if ( !data.myToCreateNewNodes ) - valStr += " -p0"; + connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) ); + myEnforcedTableWidget->setSortingEnabled(true); + + for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column) + myEnforcedTableWidget->resizeColumnToContents(column); - if ( data.myBoundaryRecovery ) - valStr += " -C"; + // Update Enforced meshes QTableWidget + TEnfMeshList::const_iterator itMesh; + rowCount = 0; + myEnforcedMeshTableWidget->setSortingEnabled(false); +// myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *))); + for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ ) + { + TEnfMesh* enfMesh = (*itMesh); + myEnforcedMeshTableWidget->setRowCount(rowCount+1); - valStr += " "; - valStr += data.myTextOption; + for (int col=0;colpalette(); + pal.setColor(QPalette::Button, Qt::white); + comboBox->setPalette(pal); + comboBox->insertItems(0,myEnfMeshConstraintLabels); + comboBox->setEditable(false); + comboBox->setCurrentIndex(enfMesh->elementType); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString()); + myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox); + } + else { + QTableWidgetItem* item = new QTableWidgetItem(); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled); + switch (col) { + case ENF_MESH_NAME_COLUMN: + item->setData( 0, enfMesh->name.c_str() ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_ENTRY_COLUMN: + item->setData( 0, enfMesh->entry.c_str() ); + item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_SIZE_COLUMN: + item->setData( 0, enfMesh->size ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + case ENF_MESH_GROUP_COLUMN: + item->setData( 0, enfMesh->groupName.c_str() ); + MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString()); + myEnforcedMeshTableWidget->setItem(rowCount,col,item); + break; + default: + break; + } + } + +// myEnforcedMeshTableWidget->setItem(rowCount,col,item); + MESSAGE("Done"); + } +// that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN)); + rowCount++; + } +// connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) ); + myEnforcedMeshTableWidget->setSortingEnabled(true); + + for (int col=0;colresizeColumnToContents(col); + + that->updateWidgets(); + that->checkVertexIsDefined(); +} + +QString GHS3DPluginGUI_HypothesisCreator::storeParams() const +{ + MESSAGE("GHS3DPluginGUI_HypothesisCreator::storeParams"); + GHS3DHypothesisData data; + readParamsFromWidgets( data ); + storeParamsToHypo( data ); + + QString valStr = ""; + + if ( !data.myBoundaryRecovery ) + valStr = "-c " + QString::number( !data.myToMeshHoles ); + + if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) { + const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" }; + valStr += " -o "; + valStr += level[ data.myOptimizationLevel ]; + } + if ( data.myMaximumMemory > 0 ) { + valStr += " -m "; + valStr += QString::number( data.myMaximumMemory ); + } + if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) { + valStr += " -M "; + valStr += QString::number( data.myInitialMemory ); + } + valStr += " -v "; + valStr += QString::number( data.myVerboseLevel ); + + if ( !data.myToCreateNewNodes ) + valStr += " -p0"; + + if ( data.myRemoveInitialCentralPoint ) + valStr += " -no_initial_central_point"; + + if ( data.myBoundaryRecovery ) + valStr += " -C"; + + if ( data.myFEMCorrection ) + valStr += " -FEM"; + + valStr += " "; + valStr += data.myTextOption; + +// valStr += " #BEGIN ENFORCED VERTICES#"; +// // Add size map parameters storage +// for (int i=0 ; irowCount() ; i++) { +// valStr += " ("; +// double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble(); +// double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble(); +// double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble(); +// double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble(); +// valStr += QString::number( x ); +// valStr += ","; +// valStr += QString::number( y ); +// valStr += ","; +// valStr += QString::number( z ); +// valStr += ")="; +// valStr += QString::number( size ); +// if (i!=mySmpModel->rowCount()-1) +// valStr += ";"; +// } +// valStr += " #END ENFORCED VERTICES#"; +// MESSAGE(valStr.toStdString()); return valStr; } bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data ) const { + MESSAGE("GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo"); GHS3DPlugin::GHS3DPlugin_Hypothesis_var h = GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( initParamsHypothesis() ); HypothesisData* data = SMESH::GetHypothesisData( hypType() ); h_data.myName = isCreation() && data ? hypName() : ""; - h_data.myToMeshHoles = h->GetToMeshHoles(); - h_data.myMaximumMemory = h->GetMaximumMemory(); - h_data.myInitialMemory = h->GetInitialMemory(); - h_data.myInitialMemory = h->GetInitialMemory(); - h_data.myOptimizationLevel = h->GetOptimizationLevel(); - h_data.myKeepFiles = h->GetKeepFiles(); - h_data.myWorkingDir = h->GetWorkingDirectory(); - h_data.myVerboseLevel = h->GetVerboseLevel(); - h_data.myToCreateNewNodes = h->GetToCreateNewNodes(); - h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion(); - h_data.myTextOption = h->GetTextOption(); + h_data.myToMeshHoles = h->GetToMeshHoles(); + h_data.myMaximumMemory = h->GetMaximumMemory(); + h_data.myInitialMemory = h->GetInitialMemory(); + h_data.myInitialMemory = h->GetInitialMemory(); + h_data.myOptimizationLevel = h->GetOptimizationLevel(); + h_data.myKeepFiles = h->GetKeepFiles(); + h_data.myWorkingDir = h->GetWorkingDirectory(); + h_data.myVerboseLevel = h->GetVerboseLevel(); + h_data.myToCreateNewNodes = h->GetToCreateNewNodes(); + h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint(); + h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion(); + h_data.myFEMCorrection = h->GetFEMCorrection(); + h_data.myTextOption = h->GetTextOption(); + GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices(); + MESSAGE("vertices->length(): " << vertices->length()); + h_data.myEnforcedVertices.clear(); + for (int i=0 ; ilength() ; i++) { + TEnfVertex* myVertex = new TEnfVertex(); + myVertex->name = CORBA::string_dup(vertices[i].name.in()); + myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in()); + myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in()); + myVertex->size = vertices[i].size; + myVertex->isCompound = vertices[i].isCompound; + if (vertices[i].coords.length()) { + for (int c = 0; c < vertices[i].coords.length() ; c++) + myVertex->coords.push_back(vertices[i].coords[c]); + MESSAGE("Add enforced vertex ("<< myVertex->coords.at(0) << ","<< myVertex->coords.at(1) << ","<< myVertex->coords.at(2) << ") ="<< myVertex->size); + } + h_data.myEnforcedVertices.insert(myVertex); + } + + GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes(); + MESSAGE("enfMeshes->length(): " << enfMeshes->length()); + h_data.myEnforcedMeshes.clear(); + for (int i=0 ; ilength() ; i++) { + TEnfMesh* myEnfMesh = new TEnfMesh(); + myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in()); + myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in()); + myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in()); + myEnfMesh->size = enfMeshes[i].size; + switch (enfMeshes[i].elementType) { + case SMESH::NODE: + myEnfMesh->elementType = 0; + break; + case SMESH::EDGE: + myEnfMesh->elementType = 1; + break; + case SMESH::FACE: + myEnfMesh->elementType = 2; + break; + default: + break; + } +// myEnfMesh->elementType = enfMeshes[i].elementType; + h_data.myEnforcedMeshes.insert(myEnfMesh); + } return true; } bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const { + MESSAGE("GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo"); GHS3DPlugin::GHS3DPlugin_Hypothesis_var h = GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() ); @@ -340,11 +1789,84 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD h->SetVerboseLevel ( h_data.myVerboseLevel ); if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes ) h->SetToCreateNewNodes( h_data.myToCreateNewNodes ); + if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint ) + h->SetToRemoveCentralPoint( h_data.myRemoveInitialCentralPoint ); if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery ) h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery ); + if ( h->GetFEMCorrection() != h_data.myFEMCorrection ) + h->SetFEMCorrection( h_data.myFEMCorrection ); if ( h->GetTextOption() != h_data.myTextOption ) h->SetTextOption ( h_data.myTextOption.toLatin1().constData() ); - } + + // Enforced vertices + int nbVertex = (int) h_data.myEnforcedVertices.size(); + GHS3DPlugin::GHS3DEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices(); + int nbVertexHyp = vertexHyp->length(); + + MESSAGE("Store params for size maps: " << nbVertex << " enforced vertices"); + MESSAGE("h->GetEnforcedVertices()->length(): " << nbVertexHyp); + + // 1. Clear all enforced vertices in hypothesis + // 2. Add new enforced vertex according to h_data + if ( nbVertexHyp > 0) + h->ClearEnforcedVertices(); + + TEnfVertexList::const_iterator it; + double x = 0, y = 0, z = 0; + for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) { + TEnfVertex* enfVertex = (*it); + x =y =z = 0; + if (enfVertex->coords.size()) { + x = enfVertex->coords.at(0); + y = enfVertex->coords.at(1); + z = enfVertex->coords.at(2); + } + ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound); + } // for + + // Enforced Meshes + int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size(); + GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes(); + int nbEnfMeshListHyp = enfMeshListHyp->length(); + + MESSAGE("Store params for size maps: " << nbEnfMeshes << " enforced meshes"); + MESSAGE("h->GetEnforcedMeshes()->length(): " << nbEnfMeshListHyp); + + // 1. Clear all enforced vertices in hypothesis + // 2. Add new enforced vertex according to h_data + if ( nbEnfMeshListHyp > 0) + h->ClearEnforcedMeshes(); + + TEnfMeshList::const_iterator itEnfMesh; + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) { + TEnfMesh* enfMesh = (*itEnfMesh); + + _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str()); + SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface( aSObj ); + SMESH::ElementType elementType; + MESSAGE("enfMesh->elementType: " << enfMesh->elementType); + switch(enfMesh->elementType) { + case 0: + elementType = SMESH::NODE; + break; + case 1: + elementType = SMESH::EDGE; + break; + case 2: + elementType = SMESH::FACE; + break; + default: + break; + } + + ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->size, enfMesh->groupName.c_str()); + } // for + } // try +// catch(const std::exception& ex) { +// std::cout << "Exception: " << ex.what() << std::endl; +// throw ex; +// } catch ( const SALOME::SALOME_Exception& ex ) { SalomeApp_Tools::QtCatchCorbaException( ex ); @@ -355,17 +1877,72 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisData& h_data ) const { - h_data.myName = myName ? myName->text() : ""; - h_data.myToMeshHoles = myToMeshHolesCheck->isChecked(); - h_data.myMaximumMemory = myMaximumMemoryCheck->isChecked() ? myMaximumMemorySpin->value() : -1; - h_data.myInitialMemory = myInitialMemoryCheck->isChecked() ? myInitialMemorySpin->value() : -1; - h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex(); - h_data.myKeepFiles = myKeepFiles->isChecked(); - h_data.myWorkingDir = myWorkingDir->text().trimmed(); - h_data.myVerboseLevel = myVerboseLevelSpin->value(); - h_data.myToCreateNewNodes = myToCreateNewNodesCheck->isChecked(); - h_data.myBoundaryRecovery = myBoundaryRecoveryCheck->isChecked(); - h_data.myTextOption = myTextOption->text(); + MESSAGE("GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets"); + h_data.myName = myName ? myName->text() : ""; + h_data.myToMeshHoles = myToMeshHolesCheck->isChecked(); + h_data.myMaximumMemory = myMaximumMemoryCheck->isChecked() ? myMaximumMemorySpin->value() : -1; + h_data.myInitialMemory = myInitialMemoryCheck->isChecked() ? myInitialMemorySpin->value() : -1; + h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex(); + h_data.myKeepFiles = myKeepFiles->isChecked(); + h_data.myWorkingDir = myWorkingDir->text().trimmed(); + h_data.myVerboseLevel = myVerboseLevelSpin->value(); + h_data.myToCreateNewNodes = myToCreateNewNodesCheck->isChecked(); + h_data.myRemoveInitialCentralPoint = myRemoveInitialCentralPointCheck->isChecked(); + h_data.myBoundaryRecovery = myBoundaryRecoveryCheck->isChecked(); + h_data.myFEMCorrection = myFEMCorrectionCheck->isChecked(); + h_data.myTextOption = myTextOption->text(); + + // Enforced vertices + h_data.myEnforcedVertices.clear(); + QVariant valueX, valueY, valueZ; + for (int row=0 ; rowrowCount() ; row++) { + + TEnfVertex *myVertex = new TEnfVertex(); + myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString(); + MESSAGE("Add new enforced vertex \"" << myVertex->name << "\"" ); + myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString(); + if (myVertex->geomEntry.size()) + MESSAGE("Geom entry is \"" << myVertex->geomEntry << "\"" ); + myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString(); + if (myVertex->groupName.size()) + MESSAGE("Group name is \"" << myVertex->groupName << "\"" ); + valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole); + valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole); + valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole); + if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) { + myVertex->coords.push_back(valueX.toDouble()); + myVertex->coords.push_back(valueY.toDouble()); + myVertex->coords.push_back(valueZ.toDouble()); + MESSAGE("Coords are (" << myVertex->coords.at(0) << ", " + << myVertex->coords.at(1) << ", " + << myVertex->coords.at(2) << ")"); + } + myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble(); + MESSAGE("Size is " << myVertex->size); + myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool(); + MESSAGE("Is compound ? " << myVertex->isCompound); + h_data.myEnforcedVertices.insert(myVertex); + } + + // Enforced meshes + h_data.myEnforcedMeshes.clear(); + + for (int row=0 ; rowrowCount() ; row++) { + + TEnfMesh *myEnfMesh = new TEnfMesh(); + myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString(); + MESSAGE("Add new enforced mesh \"" << myEnfMesh->name << "\"" ); + myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString(); + MESSAGE("Entry is \"" << myEnfMesh->entry << "\"" ); + myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString(); + MESSAGE("Group name is \"" << myEnfMesh->groupName << "\"" ); + myEnfMesh->size = myEnforcedMeshTableWidget->item(row,ENF_MESH_SIZE_COLUMN)->data(Qt::EditRole).toDouble(); + MESSAGE("Size is " << myEnfMesh->size); + QComboBox* combo = qobject_cast(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN)); + myEnfMesh->elementType = combo->currentIndex(); + MESSAGE("Element type: " << myEnfMesh->elementType); + h_data.myEnforcedMeshes.insert(myEnfMesh); + } return true; } @@ -389,19 +1966,3 @@ QString GHS3DPluginGUI_HypothesisCreator::helpPage() const { return "ghs3d_hypo_page.html"; } - -//============================================================================= -/*! GetHypothesisCreator - * - */ -//============================================================================= -extern "C" -{ - GHS3DPLUGIN_EXPORT - SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType ) - { - if ( aHypType == "GHS3D_Parameters" ) - return new GHS3DPluginGUI_HypothesisCreator( aHypType ); - return 0; - } -} diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h index 55c7433..693f9ce 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h @@ -1,21 +1,22 @@ -// Copyright (C) 2004-2008 CEA/DEN, EDF R&D +// Copyright (C) 2004-2012 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 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. +// 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 +// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin // File : GHS3DPluginGUI_HypothesisCreator.h // Author : Michael Zorin @@ -24,35 +25,134 @@ #ifndef GHS3DPLUGINGUI_HypothesisCreator_HeaderFile #define GHS3DPLUGINGUI_HypothesisCreator_HeaderFile -#include "GHS3DPlugin_Defs.hxx" +#ifdef WIN32 + #if defined GHS3DPluginGUI_EXPORTS + #define GHS3DPLUGINGUI_EXPORT __declspec( dllexport ) + #else + #define GHS3DPLUGINGUI_EXPORT __declspec( dllimport ) + #endif +#else + #define GHS3DPLUGINGUI_EXPORT +#endif + #include +#include +#include + +#include +#include +#include +#include +#include +#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm) +#include CORBA_SERVER_HEADER(SMESH_Gen) +#include CORBA_SERVER_HEADER(SMESH_Mesh) class QWidget; class QComboBox; class QCheckBox; class QLineEdit; class QSpinBox; +class QTableWidget; +class QTableWidgetItem; +class QHeaderView; + +class SMESHGUI_SpinBox; +class StdMeshersGUI_ObjectReferenceParamWdg; +class LightApp_SelectionMgr; +class SUIT_SelectionFilter; + +class QTEnfVertex +{ + +public: + QTEnfVertex(double size, double x=0., double y=0., double z=0., QString name="", QString geomEntry="", QString groupName="", bool isCompound = false); + +private: + bool operator == (const QTEnfVertex* other) const { + if (other) { + if (this->coords.size() && other->coords.size()) + return (this->coords == other->coords); + else + return (this->geomEntry == other->geomEntry); + } + } + + QString name; + QString geomEntry; + bool isCompound; + QString groupName; + double size; + std::vector coords; +}; + +typedef QList< QTEnfVertex* > QEnfVertexList; + +// Enforced vertex +struct TEnfVertex{ + std::string name; + std::string geomEntry; + bool isCompound; + std::vector coords; + std::string groupName; + double size; +}; + +struct CompareEnfVertices +{ + bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const { + if (e1 && e2) { + if (e1->coords.size() && e2->coords.size()) + return (e1->coords < e2->coords); + else + return (e1->geomEntry < e2->geomEntry); + } + return false; + } +}; + +// List of enforced vertices +typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList; + +// Enforced mesh +struct TEnfMesh{ + std::string name; + std::string entry; + int elementType; + std::string groupName; + double size; +}; + +struct CompareEnfMeshes +{ + bool operator () (const TEnfMesh* e1, const TEnfMesh* e2) const { + if (e1 && e2) { + if (e1->entry == e2->entry) + return (e1->elementType < e2->elementType); + else + return (e1->entry < e2->entry); + } + else + return false; + } +}; +// List of enforced meshes +typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList; typedef struct { - bool myToMeshHoles; - int myMaximumMemory; - int myInitialMemory; - int myOptimizationLevel; - bool myKeepFiles; - QString myWorkingDir; - QString myName; + bool myToMeshHoles,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint; + int myMaximumMemory,myInitialMemory,myOptimizationLevel; + QString myName,myWorkingDir,myTextOption; short myVerboseLevel; - bool myToCreateNewNodes; - bool myBoundaryRecovery; - QString myTextOption; - + TEnfVertexList myEnforcedVertices; + TEnfMeshList myEnforcedMeshes; } GHS3DHypothesisData; /*! \brief Class for creation of GHS3D2D and GHS3D3D hypotheses */ -class GHS3DPLUGIN_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator +class GHS3DPLUGINGUI_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator { Q_OBJECT @@ -60,7 +160,7 @@ public: GHS3DPluginGUI_HypothesisCreator( const QString& ); virtual ~GHS3DPluginGUI_HypothesisCreator(); - virtual bool checkParams() const; + virtual bool checkParams(QString& msg) const; virtual QString helpPage() const; protected: @@ -73,31 +173,126 @@ protected: virtual QString type() const; protected slots: - void onDirBtnClicked(); - void updateWidgets(); - + void onDirBtnClicked(); + void updateWidgets(); + + void addEnforcedVertex(double x=0, double y=0, double z=0, double size = 0, + std::string vertexName = "", std::string geomEntry = "", std::string groupName = "", + bool isCompound = false); + void onAddEnforcedVertex(); + void onRemoveEnforcedVertex(); + void synchronizeCoords(); + void updateEnforcedVertexValues(QTableWidgetItem* ); + void onSelectEnforcedVertex(); + void clearEnforcedVertexWidgets(); + void checkVertexIsDefined(); + void clearEnfVertexSelection(); + + void addEnforcedMesh(std::string name, std::string entry, int elementType, double size = 0, std::string groupName = ""); + void onAddEnforcedMesh(); + void onRemoveEnforcedMesh(); + //void synchronizeEnforcedMesh(); + void checkEnfMeshIsDefined(); + +signals: + void vertexDefined(bool); + void enfMeshDefined(bool); + private: - bool readParamsFromHypo( GHS3DHypothesisData& ) const; - bool readParamsFromWidgets( GHS3DHypothesisData& ) const; - bool storeParamsToHypo( const GHS3DHypothesisData& ) const; + bool readParamsFromHypo( GHS3DHypothesisData& ) const; + bool readParamsFromWidgets( GHS3DHypothesisData& ) const; + bool storeParamsToHypo( const GHS3DHypothesisData& ) const; + GeomSelectionTools* getGeomSelectionTool(); + GEOM::GEOM_Gen_var getGeomEngine(); private: - QWidget* myStdGroup; - QLineEdit* myName; - QCheckBox* myToMeshHolesCheck; - QComboBox* myOptimizationLevelCombo; - - QWidget* myAdvGroup; - QCheckBox* myMaximumMemoryCheck; - QSpinBox* myMaximumMemorySpin; - QCheckBox* myInitialMemoryCheck; - QSpinBox* myInitialMemorySpin; - QLineEdit* myWorkingDir; - QCheckBox* myKeepFiles; - QSpinBox* myVerboseLevelSpin; - QCheckBox* myToCreateNewNodesCheck; - QCheckBox* myBoundaryRecoveryCheck; - QLineEdit* myTextOption; + QWidget* myStdGroup; + QLineEdit* myName; + QCheckBox* myToMeshHolesCheck; + QComboBox* myOptimizationLevelCombo; + + QWidget* myAdvGroup; + QCheckBox* myMaximumMemoryCheck; + QSpinBox* myMaximumMemorySpin; + QCheckBox* myInitialMemoryCheck; + QSpinBox* myInitialMemorySpin; + QLineEdit* myWorkingDir; + QCheckBox* myKeepFiles; + QSpinBox* myVerboseLevelSpin; + QCheckBox* myToCreateNewNodesCheck; + QCheckBox* myRemoveInitialCentralPointCheck; + QCheckBox* myBoundaryRecoveryCheck; + QCheckBox* myFEMCorrectionCheck; + QLineEdit* myTextOption; + + QWidget* myEnfGroup; + QPixmap iconVertex, iconCompound; + StdMeshersGUI_ObjectReferenceParamWdg *myEnfVertexWdg; + GEOM::GEOM_Object_var myEnfVertex; + QTableWidget* myEnforcedTableWidget; + SMESHGUI_SpinBox* myXCoord; + SMESHGUI_SpinBox* myYCoord; + SMESHGUI_SpinBox* myZCoord; + SMESHGUI_SpinBox* mySizeValue; + QLineEdit* myGroupName; +// QGroupBox* makeGroupsCheck; +// QCheckBox* myGlobalGroupName; + QPushButton* addVertexButton; + QPushButton* removeVertexButton; + + QWidget* myEnfMeshGroup; + StdMeshersGUI_ObjectReferenceParamWdg *myEnfMeshWdg; +// SMESH::SMESH_IDSource_var myEnfMesh; + QComboBox* myEnfMeshConstraint; + QStringList myEnfMeshConstraintLabels; +// SMESH::mesh_array_var myEnfMeshArray; + QTableWidget* myEnforcedMeshTableWidget; + SMESHGUI_SpinBox* myMeshSizeValue; + QLineEdit* myMeshGroupName; + QPushButton* addEnfMeshButton; + QPushButton* removeEnfMeshButton; + + GeomSelectionTools* GeomToolSelected; +// SVTK_Selector* mySelector; +// LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ +}; + +class EnforcedVertexTableWidgetDelegate : public QItemDelegate +{ + Q_OBJECT + +public: + EnforcedVertexTableWidgetDelegate(QObject *parent = 0); + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const; + + void updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &index) const; + + bool vertexExists(QAbstractItemModel *model, const QModelIndex &index, QString value) const; +}; + +class EnforcedMeshTableWidgetDelegate : public QItemDelegate +{ + Q_OBJECT + +public: + EnforcedMeshTableWidgetDelegate(QObject *parent = 0); + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const; + + void updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &index) const; }; #endif diff --git a/src/GUI/GHS3DPlugin_images.ts b/src/GUI/GHS3DPlugin_images.ts index 14c420b..7f59dfe 100644 --- a/src/GUI/GHS3DPlugin_images.ts +++ b/src/GUI/GHS3DPlugin_images.ts @@ -1,25 +1,6 @@ + - - + @default diff --git a/src/GUI/GHS3DPlugin_msg_en.ts b/src/GUI/GHS3DPlugin_msg_en.ts index cf795b8..65569d8 100644 --- a/src/GUI/GHS3DPlugin_msg_en.ts +++ b/src/GUI/GHS3DPlugin_msg_en.ts @@ -1,110 +1,207 @@ + - - - - @default - - GHS3D_ADV_ARGS - Advanced - - - GHS3D_HYPOTHESIS - GHS3D - - - GHS3D_OPTIMIZATIOL_LEVEL - Optimization level - - - GHS3D_PERMISSION_DENIED - Working directory is not writable - - - GHS3D_STD_ARGS - Parameters - - - GHS3D_TITLE - Hypothesis Construction - - - GHS3D_TO_MESH_HOLES - To mesh holes - - - INIT_MEMORY_SIZE - Initial memory size - - - KEEP_WORKING_FILES - To keep working files - - - LEVEL_LIGHT - Light - - - LEVEL_MEDIUM - Medium (standard) - - - LEVEL_NONE - None - - - LEVEL_STRONG - Strong - - - MAX_MEMORY_SIZE - Maximum memory size - - - MEGABYTE - Megabytes - - - RECOVERY_VERSION - To use boundary recovery version - - - SELECT_DIR - ... - - - TEXT_OPTION - Option as text - - - TO_ADD_NODES - To create new nodes - - - VERBOSE_LEVEL - Verbose level - - - WORKING_DIR - Working directory - - + + + @default + + GHS3D_ADV_ARGS + Advanced + + + GHS3D_HYPOTHESIS + GHS3D + + + GHS3D_OPTIMIZATIOL_LEVEL + Optimization level + + + GHS3D_PERMISSION_DENIED + Working directory is not writable + + + GHS3D_STD_ARGS + Parameters + + + GHS3D_TITLE + Hypothesis Construction + + + GHS3D_TO_MESH_HOLES + To mesh holes + + + INIT_MEMORY_SIZE + Initial memory size + + + KEEP_WORKING_FILES + To keep working files + + + LEVEL_NONE + None + + + LEVEL_LIGHT + Light + + + LEVEL_MEDIUM + Medium (standard) + + + LEVEL_STANDARDPLUS + Standard+ + + + LEVEL_STRONG + Strong + + + MAX_MEMORY_SIZE + Maximum memory size + + + MEGABYTE + Megabytes + + + NO_INITIAL_CENTRAL_POINT + To remove initial central point + + + RECOVERY_VERSION + To use boundary recovery version + + + FEM_CORRECTION + To use FEM correction + + + SELECT_DIR + ... + + + TEXT_OPTION + Option as text + + + TO_ADD_NODES + To create new nodes + + + VERBOSE_LEVEL + Verbose level + + + WORKING_DIR + Working directory + + + GHS3D_ENFORCED_VERTICES + Enforced vertices + + + GHS3D_ENFORCED_MESHES + Enforced meshes + + + GHS3D_ENF_NAME_COLUMN + Name + + + GHS3D_ENF_VER_X_COLUMN + X + + + GHS3D_ENF_VER_Y_COLUMN + Y + + + GHS3D_ENF_VER_Z_COLUMN + Z + + + GHS3D_ENF_SIZE_COLUMN + Size + + + GHS3D_ENF_ENTRY_COLUMN + Vertex Entry + + + GHS3D_ENF_MESH_CONSTRAINT_COLUMN + Constraint + + + GHS3D_ENF_VER_COMPOUND_COLUMN + Compound + + + GHS3D_ENF_GROUP_COLUMN + Group + + + GHS3D_ENF_SELECT_VERTEX + Select a vertex + + + GHS3D_ENF_SELECT_MESH + Select a mesh + + + GHS3D_ENF_VER_X_LABEL + X: + + + GHS3D_ENF_VER_Y_LABEL + Y: + + + GHS3D_ENF_VER_Z_LABEL + Z: + + + GHS3D_ENF_MESH_CONSTRAINT_LABEL + Constraint: + + + GHS3D_ENF_MESH_CONSTRAINT_NODE + Nodes + + + GHS3D_ENF_MESH_CONSTRAINT_EDGE + Edges + + + GHS3D_ENF_MESH_CONSTRAINT_FACE + Faces + + + GHS3D_ENF_SIZE_LABEL + Size: + + + GHS3D_ENF_GROUP_LABEL + Group: + + + GHS3D_ENF_ADD + Add + + + GHS3D_ENF_REMOVE + Remove + + + GHS3D_ENF_VER_INFO + <b>Warning</b>: Enforced vertices are currently only taken into account for meshes w/o associated geometry. + + + GHS3D_ENF_MESH_INFO + <b>Warning</b>: Enforced meshes are currently only taken into account for meshes w/o associated geometry. + + diff --git a/src/GUI/GHS3DPlugin_msg_fr.ts b/src/GUI/GHS3DPlugin_msg_fr.ts new file mode 100755 index 0000000..86452f3 --- /dev/null +++ b/src/GUI/GHS3DPlugin_msg_fr.ts @@ -0,0 +1,207 @@ + + + + + @default + + GHS3D_ADV_ARGS + Avancé + + + GHS3D_HYPOTHESIS + GHS3D + + + GHS3D_OPTIMIZATIOL_LEVEL + Niveau d'optimisation + + + GHS3D_PERMISSION_DENIED + Il n'est pas possible d'écrire dans le répertoire + + + GHS3D_STD_ARGS + Paramètres + + + GHS3D_TITLE + Construction de l'hypothèse + + + GHS3D_TO_MESH_HOLES + Mailler les trous + + + INIT_MEMORY_SIZE + Taille initiale de la mémoire + + + KEEP_WORKING_FILES + Conserver les fichiers temporaires + + + LEVEL_NONE + Zéro + + + LEVEL_LIGHT + Léger + + + LEVEL_MEDIUM + Moyen (standard) + + + LEVEL_STANDARDPLUS + Standard+ + + + LEVEL_STRONG + Fort + + + MAX_MEMORY_SIZE + Taille maximale de la mémoire + + + MEGABYTE + Megabytes + + + NO_INITIAL_CENTRAL_POINT + Supprimer le point central initial + + + RECOVERY_VERSION + Utiliser la version de restauration des frontières + + + FEM_CORRECTION + Utiliser correction FEM + + + SELECT_DIR + ... + + + TEXT_OPTION + Option comme texte + + + TO_ADD_NODES + Créer de nouveaux nœuds + + + VERBOSE_LEVEL + Niveau de verbosité + + + WORKING_DIR + Répertoire de travail + + + GHS3D_ENFORCED_VERTICES + Points de passage + + + GHS3D_ENFORCED_MESHES + Maillages de contrainte + + + GHS3D_ENF_NAME_COLUMN + Nom + + + GHS3D_ENF_VER_X_COLUMN + X + + + GHS3D_ENF_VER_Y_COLUMN + Y + + + GHS3D_ENF_VER_Z_COLUMN + Z + + + GHS3D_ENF_SIZE_COLUMN + Taille + + + GHS3D_ENF_ENTRY_COLUMN + ID de point + + + GHS3D_ENF_MESH_CONSTRAINT_COLUMN + Contrainte + + + GHS3D_ENF_VER_COMPOUND_COLUMN + Compound + + + GHS3D_ENF_GROUP_COLUMN + Groupe + + + GHS3D_ENF_SELECT_VERTEX + Sélectionnez une/des point(s) + + + GHS3D_ENF_SELECT_MESH + Sélectionnez une/des maillage(s) + + + GHS3D_ENF_VER_X_LABEL + X: + + + GHS3D_ENF_VER_Y_LABEL + Y: + + + GHS3D_ENF_VER_Z_LABEL + Z: + + + GHS3D_ENF_MESH_CONSTRAINT_LABEL + Contrainte: + + + GHS3D_ENF_MESH_CONSTRAINT_NODE + Noeuds + + + GHS3D_ENF_MESH_CONSTRAINT_EDGE + Segments + + + GHS3D_ENF_MESH_CONSTRAINT_FACE + Faces + + + GHS3D_ENF_SIZE_LABEL + Taille: + + + GHS3D_ENF_GROUP_LABEL + Groupe: + + + GHS3D_ENF_ADD + Ajouter + + + GHS3D_ENF_REMOVE + Supprimer + + + GHS3D_ENF_VER_INFO + <b>Attention</b>: Les points de passage ne sont pris en compte que pour des maillage sans géométrie associée. + + + GHS3D_ENF_MESH_INFO + <b>Attention</b>: Les éléments de contraintes ne sont pris en compte que pour des maillage sans géométrie associée. + + + diff --git a/src/GUI/Makefile.am b/src/GUI/Makefile.am index 83b7dd9..e0331d3 100644 --- a/src/GUI/Makefile.am +++ b/src/GUI/Makefile.am @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # -* Makefile *- # Author : Edward AGAPOV (OCC) # Modified by : Alexander BORODIN (OCN) - autotools usage @@ -25,37 +26,49 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am # header files -salomeinclude_HEADERS = +salomeinclude_HEADERS = \ + GHS3DPluginGUI_HypothesisCreator.h \ + GHS3DPluginGUI_Enums.h # Libraries targets lib_LTLIBRARIES = libGHS3DPluginGUI.la -dist_libGHS3DPluginGUI_la_SOURCES = GHS3DPluginGUI_HypothesisCreator.cxx - -MOC_FILES = GHS3DPluginGUI_HypothesisCreator_moc.cxx -nodist_libGHS3DPluginGUI_la_SOURCES= $(MOC_FILES) - -libGHS3DPluginGUI_la_CPPFLAGS = \ - $(QT_INCLUDES) \ - $(KERNEL_CXXFLAGS) \ - $(GUI_CXXFLAGS) \ - $(GEOM_CXXFLAGS) \ - $(MED_CXXFLAGS) \ - $(SMESH_CXXFLAGS) \ - $(BOOST_CPPFLAGS) \ - $(CORBA_CXXFLAGS) \ - $(CORBA_INCLUDES) \ - $(CAS_CPPFLAGS) \ - -I$(srcdir)/.. \ - -I$(top_builddir)/idl \ - -I$(top_builddir)/salome_adm/unix +dist_libGHS3DPluginGUI_la_SOURCES = \ + GHS3DPluginGUI.cxx \ + GHS3DPluginGUI_HypothesisCreator.cxx + +MOC_FILES = \ + GHS3DPluginGUI_HypothesisCreator_moc.cxx + +nodist_libGHS3DPluginGUI_la_SOURCES= \ + $(MOC_FILES) + +libGHS3DPluginGUI_la_CPPFLAGS = \ + $(QT_INCLUDES) \ + $(CAS_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) \ + $(GUI_CXXFLAGS) \ + $(GEOM_CXXFLAGS) \ + $(MED_CXXFLAGS) \ + $(SMESH_CXXFLAGS) \ + $(BOOST_CPPFLAGS) \ + $(CORBA_CXXFLAGS) \ + $(CORBA_INCLUDES) \ + -I$(srcdir)/../GHS3DPlugin \ + -I$(top_builddir)/idl libGHS3DPluginGUI_la_LDFLAGS = \ ../../idl/libSalomeIDLGHS3DPLUGIN.la \ - $(SMESH_LDFLAGS) -lSMESH \ + $(QT_LIBS) \ + $(KERNEL_LDFLAGS) -lSALOMELocalTrace \ + $(MED_LDFLAGS) -lSalomeIDLMED \ + $(GEOM_LDFLAGS) -lGEOM \ + $(SMESH_LDFLAGS) -lSMESH -lGeomSelectionTools -lStdMeshersGUI -lSMESHFiltersSelection \ + $(GUI_LDFLAGS) -lsuit -lqtx -lSalomeApp \ $(CAS_KERNEL) # resources files nodist_salomeres_DATA= \ GHS3DPlugin_images.qm \ - GHS3DPlugin_msg_en.qm + GHS3DPlugin_msg_en.qm \ + GHS3DPlugin_msg_fr.qm diff --git a/src/Makefile.am b/src/Makefile.am index e42af47..4f68158 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,21 +1,22 @@ -# Copyright (C) 2004-2008 CEA/DEN, EDF R&D +# Copyright (C) 2004-2012 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 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. +# 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 +# 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 +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + # -* Makefile *- # Author : Edward AGAPOV (OCC) # Modified by : Alexander BORODIN (OCN) - autotools usage @@ -24,43 +25,10 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am +SUBDIRS = GHS3DPlugin + if GHS3DPLUGIN_ENABLE_GUI - SUBDIRS = GUI + SUBDIRS += GUI endif -DIST_SUBDIRS = GUI - -# header files -salomeinclude_HEADERS = \ - GHS3DPlugin_Defs.hxx \ - GHS3DPlugin_GHS3D.hxx \ - GHS3DPlugin_GHS3D_i.hxx \ - GHS3DPlugin_Hypothesis.hxx \ - GHS3DPlugin_Hypothesis_i.hxx - -# Libraries targets -lib_LTLIBRARIES = libGHS3DEngine.la - -dist_libGHS3DEngine_la_SOURCES = \ - GHS3DPlugin_GHS3D.cxx \ - GHS3DPlugin_GHS3D_i.cxx \ - GHS3DPlugin_i.cxx \ - GHS3DPlugin_Hypothesis.cxx \ - GHS3DPlugin_Hypothesis_i.cxx - -libGHS3DEngine_la_CPPFLAGS = \ - $(KERNEL_CXXFLAGS) \ - $(CAS_CPPFLAGS) \ - $(GEOM_CXXFLAGS) \ - $(MED_CXXFLAGS) \ - $(SMESH_CXXFLAGS) \ - $(BOOST_CPPFLAGS) \ - $(CORBA_CXXFLAGS) \ - $(CORBA_INCLUDES) \ - -I$(top_builddir)/idl \ - -I$(top_builddir)/salome_adm/unix - -libGHS3DEngine_la_LDFLAGS = \ - ../idl/libSalomeIDLGHS3DPLUGIN.la \ - $(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine - $(KERNEL_LDFLAGS) -lSalomeGenericObj +DIST_SUBDIRS = GHS3DPlugin GUI