diff --git a/Makefile.am b/Makefile.am index 893cd5c..6c9e9d1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 @@ -41,11 +39,11 @@ else !NETGENPLUGIN_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 = NETGENPLUGIN_version.h diff --git a/NETGENPLUGIN_version.h.in b/NETGENPLUGIN_version.h.in index 8f1132a..d90a928 100644 --- a/NETGENPLUGIN_version.h.in +++ b/NETGENPLUGIN_version.h.in @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 : NETGENPLUGIN_version.h // Author : Vadim SANDLER // Module : SALOME @@ -32,5 +33,6 @@ #define NETGENPLUGIN_VERSION_STR "@VERSION@" #define NETGENPLUGIN_VERSION @XVERSION@ +#define NETGENPLUGIN_DEVELOPMENT @VERSION_DEV@ #endif // __NETGENPLUGIN_VERSION_H__ diff --git a/adm_local/Makefile.am b/adm_local/Makefile.am index f35273f..9863d29 100644 --- a/adm_local/Makefile.am +++ b/adm_local/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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/cmake_files/FindNETGEN.cmake b/adm_local/cmake_files/FindNETGEN.cmake new file mode 100644 index 0000000..65dc9ee --- /dev/null +++ b/adm_local/cmake_files/FindNETGEN.cmake @@ -0,0 +1,82 @@ +# 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 +# + +SET(NETGENHOME $ENV{NETGENHOME}) +FIND_PATH(NETGEN_INCLUDES_DIR nglib.h ${NETGENHOME}/include) +SET(NETGEN_INCLUDES) +SET(NETGEN_INCLUDES ${NETGEN_INCLUDES} -I${NETGEN_INCLUDES_DIR}) +SET(NETGEN_INCLUDES ${NETGEN_INCLUDES} -DNO_PARALLEL_THREADS -DOCCGEOMETRY) + +FIND_LIBRARY(NETGEN_LIB_nglib nglib PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + +IF(NETGEN_LIB_nglib) + SET(NETGEN_NEW ON) + SET(NETGEN_INCLUDES ${NETGEN_INCLUDES} -I${NETGENHOME}/share/netgen/include -DNETGEN_NEW) +ELSE(NETGEN_LIB_nglib) + SET(NETGEN_NEW OFF) +ENDIF(NETGEN_LIB_nglib) + +IF(NETGEN_NEW) + SET(NETGEN_LIBS) + IF(WINDOWS) + FIND_LIBRARY(NETGEN_LIB_csg csg PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_gen gen PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_geom2d geom2d PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_gprim gprim PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_interface interface PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_la la PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_mesh mesh PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_occ occ PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_stl stl PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_csg}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_gen}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_geom2d}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_gprim}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_interface}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_la}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_mesh}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_occ}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_stl}) + ENDIF(WINDOWS) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_nglib}) +ELSE(NETGEN_NEW) + FIND_LIBRARY(NETGEN_LIB_csg csg PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_gen gen PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_geom2d geom2d PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_gprim gprim PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_la la PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_mesh mesh PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_nginterface nginterface PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_occ occ PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_opti opti PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + FIND_LIBRARY(NETGEN_LIB_stlgeom stlgeom PATHS ${NETGENHOME}/lib ${NETGENHOME}/lib/LINUX) + SET(NETGEN_LIBS) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_csg}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_gen}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_geom2d}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_gprim}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_la}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_mesh}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_nginterface}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_occ}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_opti}) + SET(NETGEN_LIBS ${NETGEN_LIBS} ${NETGEN_LIB_stlgeom}) +ENDIF(NETGEN_NEW) + +SET(CMAKE_BUILD 1) diff --git a/adm_local/unix/Makefile.am b/adm_local/unix/Makefile.am index 5f6d5f7..0d5ee76 100644 --- a/adm_local/unix/Makefile.am +++ b/adm_local/unix/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 ef7b6d6..77cb591 100644 --- a/adm_local/unix/config_files/Makefile.am +++ b/adm_local/unix/config_files/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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_NETGEN.m4 b/adm_local/unix/config_files/check_NETGEN.m4 index c33735f..2738aeb 100644 --- a/adm_local/unix/config_files/check_NETGEN.m4 +++ b/adm_local/unix/config_files/check_NETGEN.m4 @@ -1,24 +1,25 @@ -dnl Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE dnl -dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 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_NETGEN],[ AC_REQUIRE([AC_PROG_CXX])dnl @@ -35,6 +36,8 @@ AC_ARG_WITH(netgen, NETGEN_INCLUDES="" NETGEN_LIBS_DIR="" +NETGEN_LIBS="" +NETGEN_NEW=no Netgen_ok=no @@ -52,29 +55,29 @@ fi if test "x$NETGEN_HOME" != "x"; then - echo - echo - echo ------------------------------------------------- + if test -f ${NETGEN_HOME}/lib/libnglib.so ; then + NETGEN_NEW=yes + fi + + echo ---------------------------------------------------------- + echo ---------------------------------------------------------- echo You are about to choose to use somehow the echo Netgen Library to generate Tetrahedric mesh. - echo - echo WARNING echo ---------------------------------------------------------- echo ---------------------------------------------------------- echo You are strongly advised to consult the file - echo NETGENPLUGIN_SRC/src/NETGEN/ReadMeForNgUsers, particularly about - echo assumptions made on the installation of the Netgen + echo NETGENPLUGIN_SRC/src/NETGEN/ReadMeForNgUsers, particularly + echo about assumptions made on the installation of the Netgen echo application and libraries. - echo Ask your system administrator for those details. echo ---------------------------------------------------------- echo ---------------------------------------------------------- - echo - echo - - NETGEN_INCLUDES="-I${NETGEN_HOME}/include" - + + if test "$NETGEN_NEW" = "yes" ; then + NETGEN_INCLUDES="${NETGEN_INCLUDES} -DNETGEN_NEW -I${NETGEN_HOME}/share/netgen/include" + fi + # check ${NETGEN_HOME}/lib/LINUX directory for libraries if test -f ${NETGEN_HOME}/lib/LINUX/libcsg.a ; then NETGEN_LIBS_DIR="${NETGEN_HOME}/lib/LINUX" @@ -91,18 +94,20 @@ if test "x$NETGEN_HOME" != "x"; then CPPFLAGS_old="$CPPFLAGS" CXXFLAGS_old="$CXXFLAGS" - CPPFLAGS="$NETGEN_INCLUDES $CAS_CPPFLAGS $CPPFLAGS" - CXXFLAGS="$NETGEN_INCLUDES $CAS_CPPFLAGS $CXXFLAGS" + CPPFLAGS="$CAS_CPPFLAGS $NETGEN_INCLUDES $CPPFLAGS" + CXXFLAGS="$CAS_CPPFLAGS $NETGEN_INCLUDES $CXXFLAGS" AC_MSG_CHECKING(for Netgen header file) AC_CHECK_HEADER(nglib.h,Netgen_ok=yes,Netgen_ok=no) if test "x$Netgen_ok" == "xyes"; then + if test "$NETGEN_NEW" = "no" ; then + AC_MSG_CHECKING(for Netgen libraries) - LDFLAGS_old="$LDFLAGS" - LDFLAGS="-L. -lNETGEN $CAS_LDPATH -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKSTL -lTKTopAlgo $LDFLAGS" + LIBS_old="$LIBS" + LIBS="-L. -lNETGEN $CAS_LDPATH -lTKernel -lTKMath -lTKG3d -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKSTL -lTKTopAlgo $LIBS" AC_TRY_COMPILE(#include #include @@ -127,24 +132,102 @@ namespace nglib { rm -rf linopt.o bfgs.o linsearch.o global.o bisect.o meshtool.o refine.o ruler3.o improve3.o adfront3.o tetrarls.o prism2rls.o profiler.o pyramidrls.o pyramid2rls.o netrule3.o ruler2.o meshclass.o improve2.o adfront2.o netrule2.o triarls.o geomsearch.o secondorder.o meshtype.o parser3.o quadrls.o specials.o parser2.o meshing2.o meshing3.o meshfunc.o localh.o improve2gen.o delaunay.o boundarylayer.o msghandler.o meshfunc2d.o smoothing2.o smoothing3.o topology.o curvedelems_new.o clusters.o zrefine.o ngexception.o geomtest3d.o geom2d.o geom2dmesh.o geom3d.o adtree.o transform3d.o geomfuncs.o polynomial.o densemat.o vector.o basemat.o sparsmat.o algprim.o brick.o manifold.o bspline2d.o meshsurf.o csgeom.o polyhedra.o curve2d.o singularref.o edgeflw.o solid.o explicitcurve2d.o specpoin.o gencyl.o revolution.o genmesh.o genmesh2d.o spline3d.o surface.o identify.o triapprox.o meshstlsurface.o stlline.o stltopology.o stltool.o stlgeom.o stlgeomchart.o stlgeommesh.o table.o optmem.o spbita2d.o hashtabl.o sort.o flags.o seti.o bitarray.o array.o symbolta.o mystring.o moveablemem.o spline.o splinegeometry.o ngnewdelete.o nglib.o hprefinement.o Partition_Inter2d.o Partition_Loop.o Partition_Loop3d.o Partition_Inter3d.o Partition_Loop2d.o Partition_Spliter.o occgeom.o occgenmesh.o occmeshsurf.o csgparser.o dynamicmem.o extrusion.o occconstruction.o parthreads.o readuser.o writeabaqus.o writediffpack.o writeelmer.o writefeap.o writefluent.o writegmsh.o writejcm.o writepermas.o writetecplot.o writetochnog.o writeuser.o wuchemnitz.o, Netgen_ok=no) - AC_CACHE_VAL(salome_netgen_lib,[ - AC_TRY_LINK( -#include -#include -namespace nglib { -#include "nglib.h" -} -#define OCCGEOMETRY -#include -,nglib::Ng_Init(); - netgen::OCCGeometry occgeo; - nglib::Ng_Exit();, - eval "salome_netgen_lib=yes";rm -rf libNETGEN.so,eval "salome_netgen_lib=no";rm -rf libNETGEN.so) - ]) - Netgen_ok="$salome_netgen_lib" + AC_CACHE_VAL(salome_cv_netgen_lib,[ + AC_TRY_LINK([ + #include + #include + namespace nglib { + #include "nglib.h" + } + #define OCCGEOMETRY + #include + ],[ + nglib::Ng_Init(); + netgen::OCCGeometry occgeo; + nglib::Ng_Exit(); + ], + [eval "salome_cv_netgen_lib=yes";rm -rf libNETGEN.so], + [eval "salome_cv_netgen_lib=no";rm -rf libNETGEN.so]) + ]) + Netgen_ok="$salome_cv_netgen_lib" + else - LDFLAGS="$LDFLAGS_old" + LIBS_old="$LIBS" + LIBS="-L${NETGEN_LIBS_DIR} -lnglib $CAS_LDPATH -lTKernel -lTKMath -lTKG3d -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKSTL -lTKTopAlgo -lTKGeomBase $LIBS" + + AC_MSG_CHECKING(for official Netgen libraries) + AC_CACHE_VAL(salome_cv_netgen_lib,[ + AC_TRY_LINK([ + #include + #include + namespace nglib { + #include "nglib.h" + } + ],[ + nglib::Ng_Init(); + nglib::Ng_Exit(); + ], + [eval "salome_cv_netgen_lib=yes"], + [eval "salome_cv_netgen_lib=no"]) + ]) + Netgen_ok="$salome_cv_netgen_lib" + + if test "$Netgen_ok" = "yes" ; then + AC_MSG_RESULT(yes) + AC_MSG_CHECKING(for occ support in Netgen libraries) + AC_CACHE_VAL(salome_cv_netgen_occ_lib,[ + AC_TRY_LINK([ + #include + #include + #define OCCGEOMETRY + namespace nglib { + #include "nglib.h" + } + ],[ + nglib::Ng_Init(); + nglib::Ng_OCC_Geometry * ng_occ_geom = nglib::Ng_OCC_NewGeometry(); + nglib::Ng_Exit(); + ], + [eval "salome_cv_netgen_occ_lib=yes"], + [eval "salome_cv_netgen_occ_lib=no"]) + ]) + Netgen_ok="$salome_cv_netgen_occ_lib" + fi + + if test "$Netgen_ok" = "yes" ; then + AC_MSG_RESULT(yes) + AC_MSG_CHECKING(for salome patch in Netgen installation) + AC_CACHE_VAL(salome_cv_netgen_salome_patch_lib,[ + AC_TRY_LINK([ + #include + #include + #define OCCGEOMETRY + namespace nglib { + #include "nglib.h" + } + #include + ],[ + nglib::Ng_Init(); + netgen::OCCGeometry occgeo; + nglib::Ng_Exit(); + ], + [eval "salome_cv_netgen_salome_patch_lib=yes"], + [eval "salome_cv_netgen_salome_patch_lib=no"]) + ]) + Netgen_ok="$salome_cv_netgen_salome_patch_lib" + fi + + if test "x$Netgen_ok" == xno ; then + AC_MSG_RESULT(no) + AC_MSG_ERROR(Netgen is not properly installed. Read NETGENPLUGIN_SRC/src/NETGEN/ReadMeForNgUsers for details.) + fi + + NETGEN_LIBS="-L${NETGEN_LIBS_DIR} -lnglib" + + fi + + LIBS="$LIBS_old" fi CPPFLAGS="$CPPFLAGS_old" @@ -152,14 +235,21 @@ namespace nglib { if test "x$Netgen_ok" == xno ; then AC_MSG_RESULT(no) - AC_MSG_WARN(Netgen libraries not found or not properly installed) + AC_MSG_ERROR(Netgen libraries not found or not properly installed) else AC_MSG_RESULT(yes) fi + +else + + AC_MSG_ERROR(Netgen libraries not found. Please define NETGENHOME or use --with-netgen option) + fi AC_SUBST(NETGEN_INCLUDES) AC_SUBST(NETGEN_LIBS_DIR) +AC_SUBST(NETGEN_LIBS) +AM_CONDITIONAL(NETGEN_NEW, [test x"$NETGEN_NEW" = x"yes"]) AC_LANG_RESTORE diff --git a/adm_local/unix/config_files/check_NETGENPLUGIN.m4 b/adm_local/unix/config_files/check_NETGENPLUGIN.m4 index 9ceac78..6d94051 100644 --- a/adm_local/unix/config_files/check_NETGENPLUGIN.m4 +++ b/adm_local/unix/config_files/check_NETGENPLUGIN.m4 @@ -1,24 +1,25 @@ -dnl Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE dnl -dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 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 Salome NETGEN mesh plugin module # distribution diff --git a/adm_local/unix/make_common_starter.am b/adm_local/unix/make_common_starter.am index 36ad8c3..4f70a70 100644 --- a/adm_local/unix/make_common_starter.am +++ b/adm_local/unix/make_common_starter.am @@ -1,24 +1,30 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 88eceb7..d636593 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 : KERNEL diff --git a/bin/VERSION.in b/bin/VERSION.in index b5e9383..85a021f 100755 --- a/bin/VERSION.in +++ b/bin/VERSION.in @@ -1 +1,3 @@ -THIS IS SALOME - NETGENPLUGIN VERSION: @VERSION@ +[SALOME NETGENPLUGIN] : @VERSION@ +[DEVELOPMENT] : @VERSION_DEV@ +[DESCRIPTION] : Netgen meshing plug-in for SALOME Mesh module diff --git a/build_cmake b/build_cmake new file mode 100755 index 0000000..79de542 --- /dev/null +++ b/build_cmake @@ -0,0 +1,27 @@ +#!/bin/sh +# 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 +# + +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 --netgenplugin +status=$? +cd ${CURRENT_DIR} +exit $status diff --git a/build_cmake.bat b/build_cmake.bat new file mode 100644 index 0000000..0c3a272 --- /dev/null +++ b/build_cmake.bat @@ -0,0 +1,20 @@ +@REM Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +@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 --netgenplugin diff --git a/build_configure b/build_configure index 4e3b7e4..e7120c7 100755 --- a/build_configure +++ b/build_configure @@ -1,25 +1,26 @@ #!/bin/bash -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS # -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. +# This library is 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 @@ -30,7 +31,6 @@ # ORIG_DIR=`pwd` CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` -NETGENPLUGIN_WITH_GUI="yes" ######################################################################## # Test if the KERNEL_ROOT_DIR is set correctly @@ -46,27 +46,6 @@ fi # echo "failed : KERNEL_SRC variable is not correct !" # exit #fi -for option -do - case $option in - -with-gui | --with-gui) - NETGENPLUGIN_WITH_GUI="yes" - break;; - -without-gui | --without-gui | -with-gui=no | --with-gui=no) - NETGENPLUGIN_WITH_GUI="no" - break;; - esac -done - -######################################################################## -# Test if the GUI_ROOT_DIR is set correctly - -if test ${NETGENPLUGIN_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 MED_ROOT_DIR is set correctly @@ -96,40 +75,17 @@ cd ${CONF_DIR} ABS_CONF_DIR=`pwd` ####################################################################### -# Update configure.ac script: to set NETGENPLUGIN_WITH_GUI variable -sed -e s/NETGENPLUGIN_WITH_GUI=[a-z]*/NETGENPLUGIN_WITH_GUI=${NETGENPLUGIN_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 ${NETGENPLUGIN_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 \ @@ -150,10 +106,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 @@ -173,11 +129,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 f57f7b3..1f4c3ce 100755 --- a/clean_configure +++ b/clean_configure @@ -1,35 +1,28 @@ #!/bin/sh -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 ltmain.sh missing py-compile ) diff --git a/configure.ac b/configure.ac index 5855ffc..e4c8b86 100644 --- a/configure.ac +++ b/configure.ac @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 @@ -31,14 +29,16 @@ # Reorganization for usage of autotools # Created from configure.in.base # -AC_INIT([Salome2 Project NETGENPLUGIN module], [5.1.0], [webmaster.salome@opencascade.com], [SalomeNETGENPLUGIN]) -AC_CONFIG_AUX_DIR(salome_adm/unix/config_files) +AC_INIT([Salome2 Project NETGENPLUGIN module], [6.5.0], [webmaster.salome@opencascade.com], [SalomeNETGENPLUGIN]) +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=netgenplugin @@ -80,6 +80,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 ! @@ -101,7 +102,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 + INSTALL='\${KERNEL_ROOT_DIR}'/adm_local/unix/config_files/install-sh ;; esac @@ -161,7 +162,15 @@ dnl testing MPICH dnl --------------------------------------------- dnl -CHECK_MPICH +dnl CHECK_MPICH + +echo +echo --------------------------------------------- +echo testing MPI +echo --------------------------------------------- +echo + +CHECK_MPI echo echo --------------------------------------------- @@ -237,11 +246,34 @@ AC_SUBST_FILE(CORBA) corba=make_$ORB CORBA=adm_local/unix/$corba -NETGENPLUGIN_WITH_GUI=yes +echo +echo --------------------------------------------- +echo Testing GUI +echo --------------------------------------------- +echo -AM_CONDITIONAL(NETGENPLUGIN_ENABLE_GUI, [test "${NETGENPLUGIN_WITH_GUI}" = "yes"]) +CHECK_GUI_MODULE -if test "${NETGENPLUGIN_WITH_GUI}" = "yes"; then +gui_ok=no +if test "${SalomeGUI_need}" != "no" -a "${FullGUI_ok}" = "yes" ; then + gui_ok=yes +fi + +AM_CONDITIONAL(NETGENPLUGIN_ENABLE_GUI, [test "${gui_ok}" = "yes"]) + +if test "${SalomeGUI_need}" == "yes"; then + if test "${FullGUI_ok}" != "yes"; then + AC_MSG_WARN(For configure NETGENPLUGIN 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 "${gui_ok}" = "yes"; then echo echo --------------------------------------------- echo testing openGL @@ -257,36 +289,16 @@ if test "${NETGENPLUGIN_WITH_GUI}" = "yes"; then echo CHECK_QT - - 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 - - CHECK_CORBA_IN_GUI - if test "x${CORBA_IN_GUI}" != "xyes"; then - echo "failed : For configure NETGENPLUGIN module necessary full GUI !" - exit - fi fi +echo +echo --------------------------------------------- +echo testing VTK +echo --------------------------------------------- +echo + +CHECK_VTK + echo echo --------------------------------------------- echo testing HDF5 @@ -357,14 +369,17 @@ echo Summary echo --------------------------------------------- echo +AM_CONDITIONAL(CMAKE_BUILD, false) #AM_CONDITIONAL( USE_GFORTRAN, [test "$F77" = "gfortran"]) echo Configure -if test "${NETGENPLUGIN_WITH_GUI}" = "yes"; then -variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok SMesh_ok Netgen_ok" -fi -if test "${NETGENPLUGIN_WITH_GUI}" = "no"; then -variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok SMesh_ok Netgen_ok" + +if test "${gui_ok}" = "yes"; then + variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok gui_ok Geom_ok SMesh_ok Netgen_ok" +elif test "${SalomeGUI_need}" != "no"; then + variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok gui_ok Geom_ok SMesh_ok Netgen_ok" +else + variables="cc_ok boost_ok lex_yacc_ok python_ok swig_ok threads_ok vtk_ok hdf5_ok omniORB_ok occ_ok doxygen_ok graphviz_ok Kernel_ok Geom_ok SMesh_ok Netgen_ok" fi for var in $variables @@ -385,6 +400,9 @@ else AC_SUBST(SETX) SETX="set -x" fi +dnl Build with SMESH cancel compute feature +AC_DEFINE(WITH_SMESH_CANCEL_COMPUTE) + dnl copy shells and utilities contained in the bin directory dnl excluding .in files (treated in AC-OUTPUT below) and CVS dnl directory @@ -400,23 +418,41 @@ echo # chmod +x ./bin/salome/*; #]) +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 \ - ./NETGENPLUGIN_version.h \ - ./src/Makefile \ - ./src/GUI/Makefile \ - ./src/NETGEN/Makefile \ - ./src/NETGENPlugin/Makefile \ - ./resources/Makefile \ - ./idl/Makefile \ + adm_local/Makefile \ + adm_local/unix/Makefile \ + adm_local/unix/config_files/Makefile \ + bin/VERSION \ + bin/Makefile \ + NETGENPLUGIN_version.h \ + doc/Makefile \ + doc/salome/Makefile \ + doc/salome/gui/Makefile \ + doc/salome/gui/NETGENPLUGIN/Makefile \ + doc/salome/gui/NETGENPLUGIN/doxyfile \ + doc/salome/gui/NETGENPLUGIN/doxyfile_py \ + doc/salome/gui/NETGENPLUGIN/static/header.html \ + doc/salome/gui/NETGENPLUGIN/static/header_py.html \ + src/Makefile \ + src/GUI/Makefile \ + src/NETGEN/Makefile \ + src/NETGENPlugin/Makefile \ + resources/Makefile \ + idl/Makefile \ Makefile \ ]) diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..570ccb2 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,32 @@ +# 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 +# + +# -* Makefile *- +# Author : Patrick GOLDBRONN (CEA) +# Date : 30/11/2001 +# Modified by : Alexander BORODIN (OCN) - autotools usage +# $Header$ +# source path +# +SUBDIRS = salome + +usr_docs: + (cd salome && $(MAKE) $(AM_MAKEFLAGS) usr_docs) + +docs: usr_docs \ No newline at end of file diff --git a/doc/salome/Makefile.am b/doc/salome/Makefile.am new file mode 100644 index 0000000..9ded0be --- /dev/null +++ b/doc/salome/Makefile.am @@ -0,0 +1,34 @@ +# 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 +# + +# -* Makefile *- +# Author : Patrick GOLDBRONN (CEA) +# Date : 30/11/2001 +# Modified by : Alexander BORODIN (OCN) - autotools usage +# $Header: +# +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/Makefile.am b/doc/salome/gui/Makefile.am new file mode 100644 index 0000000..7a41bf6 --- /dev/null +++ b/doc/salome/gui/Makefile.am @@ -0,0 +1,32 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# File : Makefile.in +# Author : Vasily Rusyaev (Open Cascade NN) +# Modified by : Alexander BORODIN (OCN) - autotools usage +# Module : doc +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +SUBDIRS = NETGENPLUGIN + +usr_docs: + (cd NETGENPLUGIN && $(MAKE) $(AM_MAKEFLAGS) usr_docs) + +docs: usr_docs diff --git a/doc/salome/gui/NETGENPLUGIN/Makefile.am b/doc/salome/gui/NETGENPLUGIN/Makefile.am new file mode 100755 index 0000000..c075ffe --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/Makefile.am @@ -0,0 +1,67 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# File : Makefile.in +# Author : Vasily Rusyaev (Open Cascade NN) +# Modified by : Alexander BORODIN (OCN) - autotools usage +# Module : doc +# +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +EXTRA_DIST += images input static/footer.html static/doxygen.css + +guidocdir = $(docdir)/gui/NETGENPLUGIN +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/NETGENPLUGIN + @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/NETGENPLUGIN ;; \ + esac ; \ + done ; + cp -rp $(srcdir)/images/head.png $(DESTDIR)$(docdir)/gui/NETGENPLUGIN/netgenpluginpy_doc ; + +uninstall-local: + rm -rf $(DESTDIR)$(docdir)/gui/NETGENPLUGIN \ No newline at end of file diff --git a/doc/salome/gui/NETGENPLUGIN/doxyfile.in b/doc/salome/gui/NETGENPLUGIN/doxyfile.in new file mode 100755 index 0000000..510aa76 --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/doxyfile.in @@ -0,0 +1,115 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "SALOME NETGENPLUGIN 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 + + +#--------------------------------------------------------------------------- +# 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 + +#--------------------------------------------------------------------------- +#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 = netgenpluginpy_doc.tag=../NETGENPLUGIN/netgenpluginpy_doc +SEARCHENGINE = YES diff --git a/doc/salome/gui/NETGENPLUGIN/doxyfile_py.in b/doc/salome/gui/NETGENPLUGIN/doxyfile_py.in new file mode 100755 index 0000000..58fba65 --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/doxyfile_py.in @@ -0,0 +1,162 @@ +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = "SALOME NETGENPLUGIN 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/NETGENPlugin/NETGENPluginDC.py +FILE_PATTERNS = +IMAGE_PATH = @srcdir@/images +RECURSIVE = NO +EXAMPLE_PATH = + +#--------------------------------------------------------------------------- +#HTML related options +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = netgenpluginpy_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 = netgenpluginpy_doc.tag +SEARCHENGINE = YES \ No newline at end of file diff --git a/doc/salome/gui/NETGENPLUGIN/images/head.png b/doc/salome/gui/NETGENPLUGIN/images/head.png new file mode 100755 index 0000000..307d9ef Binary files /dev/null and b/doc/salome/gui/NETGENPLUGIN/images/head.png differ diff --git a/doc/salome/gui/NETGENPLUGIN/images/image1.png b/doc/salome/gui/NETGENPLUGIN/images/image1.png new file mode 100755 index 0000000..da6b149 Binary files /dev/null and b/doc/salome/gui/NETGENPLUGIN/images/image1.png differ diff --git a/doc/salome/gui/NETGENPLUGIN/images/image2.gif b/doc/salome/gui/NETGENPLUGIN/images/image2.gif new file mode 100755 index 0000000..1983513 Binary files /dev/null and b/doc/salome/gui/NETGENPLUGIN/images/image2.gif differ diff --git a/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d.png b/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d.png new file mode 100644 index 0000000..97b9548 Binary files /dev/null and b/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d.png differ diff --git a/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d_only.png b/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d_only.png new file mode 100644 index 0000000..ece6fd1 Binary files /dev/null and b/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d_only.png differ diff --git a/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d_simple.png b/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d_simple.png new file mode 100644 index 0000000..f8d1166 Binary files /dev/null and b/doc/salome/gui/NETGENPLUGIN/images/netgen2d3d_simple.png differ diff --git a/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png b/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png new file mode 100644 index 0000000..f7bcd18 Binary files /dev/null and b/doc/salome/gui/NETGENPLUGIN/images/netgen3d_local_size.png differ diff --git a/doc/salome/gui/NETGENPLUGIN/input/additional_hypo.doc b/doc/salome/gui/NETGENPLUGIN/input/additional_hypo.doc new file mode 100644 index 0000000..44766e8 --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/input/additional_hypo.doc @@ -0,0 +1,28 @@ +/*! + +\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. + +Following additional hypotheses can be used together with NETGEN algoritm: +
    + +
  • Quadrangle Preference - This additional hypothesis can be used together with Netgen 2D algorithm. +It allows Netgen 2D to build quadrangular meshes.
  • +
    +This hypothesis has one restriction on its work: the total quantity of +segments on all four sides of the face must be even (divisible by 2). + + +
  • Viscous Layers additional hypothesis can be used together with NETGEN 3D. +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 described above hypothesis please refer SALOME Mesh User's Guide. +*/ + + diff --git a/doc/salome/gui/NETGENPLUGIN/input/index.doc b/doc/salome/gui/NETGENPLUGIN/input/index.doc new file mode 100644 index 0000000..df3ed3a --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/input/index.doc @@ -0,0 +1,20 @@ +/*! + +\mainpage Introduction to NETGENPLUGIN + +\b NETGENPLUGIN plugin is destined for: +- Meshing 1D, 2D and 3D geometric entities. + - Faces are split into triangular elements. + - Volumes are split into tetrahedral (pyramidal) elements. +- Generating 3D meshes from 2D meshes, working without geometrical objects. + +To manage parameters of the NETGENPLUGIN use \subpage netgen_2d_3d_hypo_page and \subpage additional_hypo_page. + +Also all NETGENPLUGIN functionalities are accessible via +\subpage netgenplugin_python_interface_page "NETGENPLUGIN Python interface". + +\image html image1.png "Example of a triangular 2D mesh" + +\image html image2.gif "Example of a tetrahedral 3D mesh" + +*/ \ No newline at end of file diff --git a/doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc b/doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc new file mode 100644 index 0000000..7a75cdd --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/input/netgen_2d_3d_hypo.doc @@ -0,0 +1,100 @@ +/*! + +\page netgen_2d_3d_hypo_page Netgen 2D and 3D hypotheses + +Netgen 2D Parameters and Netgen 3D Parameters hypotheses work only with +Netgen 1D-2D, Netgen 2D, Netgen 1D-2D-3D and +Netgen 3D algorithms. Netgen 1D-2D and Netgen +1D-2D-3D algorithms do not require definition of lower-level +hypotheses and algorithms (2D and 1D for meshing 3D objects and 1D for +meshing 2D objects). + +\image html netgen2d3d.png +
Dialog boxes of Netgen 1D-2D and Netgen +1D-2D-3D algorithms
+
+ +\image html netgen2d3d_only.png +
Dialog boxes of Netgen 2D and Netgen 3D +algorithms
+ +- Name - allows to define the name for the algorithm (Netgen +2D (or 3D) Parameters by default). +- Max Size - maximum linear dimensions for mesh cells. +- Min Size - minimum linear dimensions for mesh cells. It is +ignored if it is more than Max Size. +- Second Order - if this box is checked in, the algorithm will +create second order nodes on the mesh, which actually will become +\ref adding_quadratic_elements_page "Quadratic". +- Fineness - ranging from Very Coarse to Very Fine allows to set the +level of meshing detalization using the three parameters below. You +can select Custom to define them manually. +- Growth rate - allows to define how much the linear dimensions of +two adjacent cells can differ (i.e. 0.3 means 30%). +- Nb. Segs per Edge and Nb Segs per Radius - allows to define the +minimum number of mesh segments in which edges and radiuses will be +split. +- Allow Quadrangles - allows to use quadrangle elements in a +triangle 2D mesh. This checkbox is not present in Netgen 3D parameters +because currently building a tetrahedral mesh with quadrangle faces is +not possible. +- Optimize - if this box is checked in, the algorithm will try to +create regular (possessing even sides) elements. + +\image html netgen3d_local_size.png + +- Local sizes - allows to define size of elements on and +around specified geometrical edges and vertices. To define the local +size it is necessary to select a geometrical edge or vertex in the +object browser or in the viewer, and to click On Edge or On +Vertex correspondingly. Name of the geometrical object and +a default Value will be added in the table where the +Value can be changed. +- Remove - deletes a selected row from the table. + +\image html netgen2d3d_simple.png + +Netgen 2D simple parameters and Netgen 3D simple +parameters allow defining the size of elements for each +dimension. + +\b 1D group allows defining the size of 1D elements in either of two ways: +- Number of Segments has the same sense as \ref +number_of_segments_anchor "Number of segments" hypothesis with +equidistant distribution. +- Local Length has the same sense as \ref +average_length_anchor "Local Length" hypothesis. + +\b 2D group allows defining the size of 2D elements +- Length from edges if checked in, acts like \ref +length_from_edges_anchor "Length from Edges" hypothesis, else +- Max. Element Area defines the maximum element area like \ref +max_element_area_anchor "Max Element Area" hypothesis. +- Allow Quadrangles - allows to use quadrangle elements in a +triangle 2D mesh. This checkbox is not present in Netgen 3D simple parameters +because currently building a tetrahedral mesh with quadrangle faces is +not possible. + +\b 3D groups allows defining the size of 3D elements. +- Length from faces if checked in, the area of sides of +volumic elements will be equal to an average area of 2D elements, else +- Max. Element Volume defines the maximum element volume like +\ref max_element_volume_hypo_page "Max Element Volume" +hypothesis. + +\note Netgen algorithm does not strictly follow the input +parameters. The actual mesh can be more or less dense than +required. There are several factors in it: +- NETGEN does not actually use "NbOfSegments" parameter for discretization of +edge. This parameter is used only to define the local element size +(size at the given point), so local sizes of adjacent edges influence +each other. +- NETGEN additionally restricts the element size according to edge curvature. +- The local size of edges influences the size of close triangles. +- The order of elements and their size in the 1D mesh generated by +NETGEN differ from those in the 1D mesh generated by Regular_1D +algorithm, resulting in different 2D and 3D meshes. + +*/ + + diff --git a/doc/salome/gui/NETGENPLUGIN/input/netgenplugin_python_interface.doc b/doc/salome/gui/NETGENPLUGIN/input/netgenplugin_python_interface.doc new file mode 100644 index 0000000..87905e7 --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/input/netgenplugin_python_interface.doc @@ -0,0 +1,59 @@ +/*! + +\page netgenplugin_python_interface_page Python Interface + +Python package \ref NETGENPluginDC "NETGENPlugin" defines several classes, destined for creation of the 2D and 3D meshes. + +Documentation for NETGENPlugin package is available in linear form grouped by classes, declared in the NETGENPluginDC.py file. + +Below you can see an example of usage of the NETGENPlugin package for mesh generation: + +\code + +import geompy +import smesh + +# create a box +box = geompy.MakeBoxDXDYDZ(10., 10., 10.) +geompy.addToStudy(box, "Box") + + +# 1. Create a triangular 2D mesh on the box with NETGEN_1D2D algorithm +triaN = smesh.Mesh(box, "Box : triangular mesh by NETGEN_1D2D") + +# create a Netgen_1D2D algorithm for solids +algo2D = triaN.Triangle(smesh.NETGEN_1D2D) + +# define hypotheses +n12_params = algo2D.Parameters() + +# define number of segments +n12_params.SetNbSegPerEdge(19) + +# define max element +n12_params.SetMaxSize(300) + +# 2. Create a tetrahedral mesh on the box with NETGEN_1D2D3D algorithm (full netgen) +tetraN = smesh.Mesh(box, "Box : tetrahedrical mesh by NETGEN_1D2D3D") + +# create a Netgen_1D2D3D algorithm for solids +algo3D = tetraN.Tetrahedron(smesh.FULL_NETGEN) + +# define hypotheses +n123_params = algo3D.Parameters() + +# define number of segments +n123_params.SetNbSegPerEdge(11) + +# define max element size +n123_params.SetMaxSize(300) + +# compute the meshes +triaN.Compute() +tetraN.Compute() + +\endcode + +*/ + + diff --git a/doc/salome/gui/NETGENPLUGIN/static/doxygen.css b/doc/salome/gui/NETGENPLUGIN/static/doxygen.css new file mode 100755 index 0000000..7a2dcbd --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/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/NETGENPLUGIN/static/footer.html b/doc/salome/gui/NETGENPLUGIN/static/footer.html new file mode 100755 index 0000000..4c89a2b --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/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/NETGENPLUGIN/static/header.html.in b/doc/salome/gui/NETGENPLUGIN/static/header.html.in new file mode 100755 index 0000000..4571b43 --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/static/header.html.in @@ -0,0 +1,20 @@ + + + + + +$title + +$treeview +$search +$mathjax + + + + +
+
Version: @VERSION@
+ +
diff --git a/doc/salome/gui/NETGENPLUGIN/static/header_py.html.in b/doc/salome/gui/NETGENPLUGIN/static/header_py.html.in new file mode 100644 index 0000000..61414bb --- /dev/null +++ b/doc/salome/gui/NETGENPLUGIN/static/header_py.html.in @@ -0,0 +1,21 @@ + + + + + +$title + +$treeview +$search +$mathjax + + + + +
+
Version: @VERSION@
+ + +
diff --git a/idl/Makefile.am b/idl/Makefile.am index c496875..da889b2 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 @@ -28,6 +26,8 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am BASEIDL_FILES= NETGENPlugin_Algorithm.idl +BASEIDL_FILES_PY=$(BASEIDL_FILES:%.idl=%_idl.py) + # This variable defines the files to be installed dist_salomeidl_DATA = $(BASEIDL_FILES) @@ -46,7 +46,6 @@ libSalomeIDLNETGENPLUGIN_la_CPPFLAGS = \ $(SMESH_CXXFLAGS) \ @CORBA_CXXFLAGS@ \ @CORBA_INCLUDES@ \ - -I$(top_builddir)/salome_adm/unix \ -I$(top_builddir)/idl libSalomeIDLNETGENPLUGIN_la_LDFLAGS = -no-undefined -version-info=0:0:0 @@ -71,8 +70,7 @@ 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$(SMESH_ROOT_DIR)/idl/salome IDLPYFLAGS = \ @IDLPYFLAGS@ \ -I$(KERNEL_ROOT_DIR)/idl/salome \ @@ -92,9 +90,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 NETGENPlugin ; 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 @@ -108,7 +112,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$(SMESH_ROOT_DIR)/idl/salome $$dep 2>/dev/null | \ sed 's/\.o/\SK.cc/' >>$@; \ fi; \ done ; diff --git a/idl/NETGENPlugin_Algorithm.idl b/idl/NETGENPlugin_Algorithm.idl index f968db2..1dd6fc0 100644 --- a/idl/NETGENPlugin_Algorithm.idl +++ b/idl/NETGENPlugin_Algorithm.idl @@ -1,39 +1,41 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 : NETGENPlugin_Algorithm.idl // Author : Julia DOROVSKIKH -// $Header$ // #ifndef _SMESH_NETGENALGORITHM_IDL_ #define _SMESH_NETGENALGORITHM_IDL_ #include "SALOME_Exception.idl" #include "SMESH_Hypothesis.idl" +#include "GEOM_Gen.idl" /*! * NETGENPlugin: interfaces to NETGEN related hypotheses and algorithms */ module NETGENPlugin { + typedef sequence string_array; /*! * NETGENPlugin_NETGEN_3D: interface of "Tetrahedron (Netgen)" algorithm */ @@ -72,6 +74,9 @@ module NETGENPlugin void SetMaxSize(in double value); double GetMaxSize(); + void SetMinSize(in double value); + double GetMinSize(); + void SetSecondOrder(in boolean value); boolean GetSecondOrder(); @@ -89,6 +94,15 @@ module NETGENPlugin void SetNbSegPerRadius(in double value); double GetNbSegPerRadius(); + + void SetQuadAllowed(in boolean value); + boolean GetQuadAllowed(); + + void SetLocalSizeOnShape(in GEOM::GEOM_Object GeomObj, in double localSize); + void SetLocalSizeOnEntry(in string entry, in double localSize); + double GetLocalSizeOnEntry(in string entry); + string_array GetLocalSizeEntries(); + void UnsetLocalSizeOnEntry(in string entry); }; /*! @@ -96,8 +110,20 @@ module NETGENPlugin */ interface NETGENPlugin_Hypothesis_2D : NETGENPlugin_Hypothesis { - void SetQuadAllowed(in boolean value); - boolean GetQuadAllowed(); + }; + + /*! + * interface of "NETGEN 2D parameters" hypothesis used by NETGENPlugin_NETGEN_2D_ONLY algoritm + */ + interface NETGENPlugin_Hypothesis_2D_ONLY : NETGENPlugin_Hypothesis_2D + { + }; + + /*! + * interface of "NETGEN 3D parameters" hypothesis used by NETGENPlugin_NETGEN_3D algorithm + */ + interface NETGENPlugin_Hypothesis_3D : NETGENPlugin_Hypothesis + { }; /*! @@ -139,6 +165,15 @@ module NETGENPlugin * Can be zero in case of LengthFromEdges() */ double GetMaxElementArea(); + + /*! + * Enables/disables generation of quadrangular faces + */ + void SetAllowQuadrangles(in boolean toAllow); + /*! + * Returns true if generation of quadrangular faces is enabled + */ + boolean GetAllowQuadrangles(); }; /*! diff --git a/resources/Makefile.am b/resources/Makefile.am index d11fed6..dfcdf8f 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 diff --git a/resources/NETGENPlugin.xml b/resources/NETGENPlugin.xml index 248e1e1..2848836 100644 --- a/resources/NETGENPlugin.xml +++ b/resources/NETGENPlugin.xml @@ -1,7 +1,7 @@ +
+ +
diff --git a/src/GUI/Makefile.am b/src/GUI/Makefile.am index a2f52dc..537055e 100644 --- a/src/GUI/Makefile.am +++ b/src/GUI/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 : Makefile.in # Author : Michael Sazonov # Modified by : Alexander BORODIN (OCN) - autotools usage @@ -51,8 +49,9 @@ nodist_libNETGENPluginGUI_la_SOURCES= \ # additionnal information to compil and link file libNETGENPluginGUI_la_CPPFLAGS = \ - $(QT_INCLUDES) \ $(CAS_CPPFLAGS) \ + $(NETGEN_INCLUDES) \ + $(QT_INCLUDES) \ $(PYTHON_INCLUDES) \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ @@ -63,16 +62,19 @@ libNETGENPluginGUI_la_CPPFLAGS = \ $(CORBA_CXXFLAGS) \ $(CORBA_INCLUDES) \ -I$(srcdir)/../NETGENPlugin \ - -I$(top_builddir)/idl \ - -I$(top_builddir)/salome_adm/unix + -I$(top_builddir)/idl libNETGENPluginGUI_la_LDFLAGS = \ + ../../idl/libSalomeIDLNETGENPLUGIN.la \ ../NETGENPlugin/libNETGENEngine.la \ - ${SMESH_LDFLAGS} -lSMESH \ + ${QT_MT_LIBS} \ + ${GUI_LDFLAGS} -lSalomeApp -lqtx -lsuit -lSalomeObject -lLightApp \ + ${SMESH_LDFLAGS} -lSMESH -lGeomSelectionTools \ $(CAS_KERNEL) # resources files nodist_salomeres_DATA= \ NETGENPlugin_images.qm \ - NETGENPlugin_msg_en.qm + NETGENPlugin_msg_en.qm \ + NETGENPlugin_msg_fr.qm diff --git a/src/GUI/NETGENPluginGUI.cxx b/src/GUI/NETGENPluginGUI.cxx index d455547..1484062 100755 --- a/src/GUI/NETGENPluginGUI.cxx +++ b/src/GUI/NETGENPluginGUI.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin GUI: GUI for plugged-in mesher NETGENPlugin // File : NETGENPluginGUI.cxx // Author : Michael Zorin @@ -40,7 +41,8 @@ extern "C" SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType ) { SMESHGUI_GenericHypothesisCreator* aCreator = NULL; - if( aHypType=="NETGEN_Parameters_2D" || aHypType=="NETGEN_Parameters" ) + if( aHypType=="NETGEN_Parameters_2D" || aHypType=="NETGEN_Parameters" || + aHypType=="NETGEN_Parameters_2D_ONLY" || aHypType=="NETGEN_Parameters_3D" ) aCreator = new NETGENPluginGUI_HypothesisCreator( aHypType ); else if ( aHypType=="NETGEN_SimpleParameters_2D" || aHypType=="NETGEN_SimpleParameters_3D" ) diff --git a/src/GUI/NETGENPluginGUI.h b/src/GUI/NETGENPluginGUI.h index ca882b4..2b5063e 100755 --- a/src/GUI/NETGENPluginGUI.h +++ b/src/GUI/NETGENPluginGUI.h @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin GUI: GUI for plugged-in mesher NETGENPlugin // File : NETGENPluginGUI.h // Author : Alexander A. BORODIN @@ -26,7 +24,7 @@ // $Header: // #ifdef WIN32 - #ifdef NETGENPLUGIN_GUI_EXPORTS + #if defined NETGENPLUGIN_GUI_EXPORTS || defined NETGENPluginGUI_EXPORTS #define NETGENPLUGIN_GUI_EXPORT __declspec( dllexport ) #else #define NETGENPLUGIN_GUI_EXPORT __declspec( dllimport ) diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx index fc9d196..58f599f 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx @@ -1,35 +1,36 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin GUI: GUI for plugged-in mesher NETGENPlugin // File : NETGENPluginGUI_HypothesisCreator.cxx // Author : Michael Zorin // Module : NETGENPlugin -// $Header: // #include "NETGENPluginGUI_HypothesisCreator.h" #include #include -#include +#include +#include #include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm) @@ -37,8 +38,8 @@ #include #include - -#include +#include +#include #include #include @@ -48,21 +49,51 @@ #include #include #include +#include +#include +#include - enum Fineness - { - VeryCoarse, - Coarse, - Moderate, - Fine, - VeryFine, - UserDefined - }; +enum Fineness + { + VeryCoarse, + Coarse, + Moderate, + Fine, + VeryFine, + UserDefined + }; + +enum { + STD_TAB = 0, + LSZ_TAB +}; + +enum { + LSZ_ENTRY_COLUMN = 0, + LSZ_NAME_COLUMN, + LSZ_LOCALSIZE_COLUMN, + LSZ_NB_COLUMNS +}; + +enum { + LSZ_BTNS = 0, + LSZ_VERTEX_BTN, + LSZ_EDGE_BTN, +#ifdef NETGEN_NEW + LSZ_FACE_BTN, +#endif + LSZ_SEPARATOR2, + LSZ_REMOVE_BTN +}; NETGENPluginGUI_HypothesisCreator::NETGENPluginGUI_HypothesisCreator( const QString& theHypType ) -: SMESHGUI_GenericHypothesisCreator( theHypType ), - myIs2D(false) + : SMESHGUI_GenericHypothesisCreator( theHypType ) { + myGeomSelectionTools = NULL; + myLocalSizeMap.clear(); + myIs2D = ( theHypType.startsWith("NETGEN_Parameters_2D")); + myIsONLY = ( theHypType == "NETGEN_Parameters_2D_ONLY" || + theHypType == "NETGEN_Parameters_3D"); } NETGENPluginGUI_HypothesisCreator::~NETGENPluginGUI_HypothesisCreator() @@ -75,12 +106,19 @@ bool NETGENPluginGUI_HypothesisCreator::checkParams(QString& msg) const readParamsFromHypo( data_old ); readParamsFromWidgets( data_new ); bool res = storeParamsToHypo( data_new ); - storeParamsToHypo( data_old ); + //storeParamsToHypo( data_old ); -- issue 0021364: Dump of netgen parameters has duplicate lines res = myMaxSize->isValid(msg,true) && res; + res = myMinSize->isValid(msg,true) && res; res = myGrowthRate->isValid(msg,true) && res; ; - res = myNbSegPerEdge->isValid(msg,true) && res; - res = myNbSegPerRadius->isValid(msg,true) && res; + if ( myNbSegPerEdge ) + res = myNbSegPerEdge->isValid(msg,true) && res; + if ( myNbSegPerRadius ) + res = myNbSegPerRadius->isValid(msg,true) && res; + + if ( !res ) // -- issue 0021364: Dump of netgen parameters has duplicate lines + storeParamsToHypo( data_old ); + return res; } @@ -92,8 +130,12 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() lay->setMargin( 5 ); lay->setSpacing( 0 ); - QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr ); - lay->addWidget( GroupC1 ); + QTabWidget* tab = new QTabWidget( fr ); + tab->setTabShape( QTabWidget::Rounded ); + tab->setTabPosition( QTabWidget::North ); + lay->addWidget( tab ); + QWidget* GroupC1 = new QWidget(); + tab->insertTab( STD_TAB, GroupC1, tr( "SMESH_ARGUMENTS" ) ); QGridLayout* aGroupLayout = new QGridLayout( GroupC1 ); aGroupLayout->setSpacing( 6 ); @@ -105,23 +147,31 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() { aGroupLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), GroupC1 ), row, 0 ); myName = new QLineEdit( GroupC1 ); + myName->setMinimumWidth(160); aGroupLayout->addWidget( myName, row, 1 ); row++; } aGroupLayout->addWidget( new QLabel( tr( "NETGEN_MAX_SIZE" ), GroupC1 ), row, 0 ); - myMaxSize = new SalomeApp_DoubleSpinBox( GroupC1 ); - myMaxSize->setDecimals( 7 ); - myMaxSize->setMinimum( 1e-07 ); - myMaxSize->setMaximum( 1e+06 ); - myMaxSize->setSingleStep( 10 ); + myMaxSize = new SMESHGUI_SpinBox( GroupC1 ); + myMaxSize->RangeStepAndValidator( 1e-07, 1e+06, 10., "length_precision" ); aGroupLayout->addWidget( myMaxSize, row, 1 ); row++; - - mySecondOrder = new QCheckBox( tr( "NETGEN_SECOND_ORDER" ), GroupC1 ); - aGroupLayout->addWidget( mySecondOrder, row, 0 ); + + aGroupLayout->addWidget( new QLabel( tr( "NETGEN_MIN_SIZE" ), GroupC1 ), row, 0 ); + myMinSize = new SMESHGUI_SpinBox( GroupC1 ); + myMinSize->RangeStepAndValidator( 0.0, 1e+06, 10., "length_precision" ); + aGroupLayout->addWidget( myMinSize, row, 1 ); row++; - + + mySecondOrder = 0; + if ( !myIsONLY ) + { + mySecondOrder = new QCheckBox( tr( "NETGEN_SECOND_ORDER" ), GroupC1 ); + aGroupLayout->addWidget( mySecondOrder, row, 0 ); + row++; + } + aGroupLayout->addWidget( new QLabel( tr( "NETGEN_FINENESS" ), GroupC1 ), row, 0 ); myFineness = new QComboBox( GroupC1 ); QStringList types; @@ -132,43 +182,88 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() row++; aGroupLayout->addWidget( new QLabel( tr( "NETGEN_GROWTH_RATE" ), GroupC1 ), row, 0 ); - myGrowthRate = new SalomeApp_DoubleSpinBox( GroupC1 ); - myGrowthRate->setMinimum( 0.1 ); - myGrowthRate->setMaximum( 10 ); - myGrowthRate->setSingleStep( 0.1 ); + myGrowthRate = new SMESHGUI_SpinBox( GroupC1 ); + myGrowthRate->RangeStepAndValidator( .0001, 10., .1, "parametric_precision" ); aGroupLayout->addWidget( myGrowthRate, row, 1 ); row++; - const double VALUE_MAX = 1.0e+6; + myNbSegPerEdge = 0; + myNbSegPerRadius = 0; + if ( !myIsONLY ) + { + const double VALUE_MAX = 1.0e+6; - aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), GroupC1 ), row, 0 ); - myNbSegPerEdge = new SalomeApp_DoubleSpinBox( GroupC1 ); - myNbSegPerEdge->setMinimum( 0.2 ); - myNbSegPerEdge->setMaximum( VALUE_MAX ); // (PAL14890) max value in native netgen gui is 5 - aGroupLayout->addWidget( myNbSegPerEdge, row, 1 ); - row++; - - aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), GroupC1 ), row, 0 ); - myNbSegPerRadius = new SalomeApp_DoubleSpinBox( GroupC1 ); - myNbSegPerRadius->setMinimum( 0.2 ); - myNbSegPerRadius->setMaximum( VALUE_MAX ); // (PAL14890) max value in native netgen gui is 5 - aGroupLayout->addWidget( myNbSegPerRadius, row, 1 ); - row++; + aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), GroupC1 ), row, 0 ); + myNbSegPerEdge = new SMESHGUI_SpinBox( GroupC1 ); + myNbSegPerEdge->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" ); + aGroupLayout->addWidget( myNbSegPerEdge, row, 1 ); + row++; - if ( hypType()=="NETGEN_Parameters_2D" ) + aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), GroupC1 ), row, 0 ); + myNbSegPerRadius = new SMESHGUI_SpinBox( GroupC1 ); + myNbSegPerRadius->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" ); + aGroupLayout->addWidget( myNbSegPerRadius, row, 1 ); + row++; + } + myAllowQuadrangles = 0; + if ( true /*myIs2D*/ ) // issue 0021676 { myAllowQuadrangles = new QCheckBox( tr( "NETGEN_ALLOW_QUADRANGLES" ), GroupC1 ); aGroupLayout->addWidget( myAllowQuadrangles, row, 0 ); - myIs2D = true; row++; } myOptimize = new QCheckBox( tr( "NETGEN_OPTIMIZE" ), GroupC1 ); aGroupLayout->addWidget( myOptimize, row, 0 ); row++; - + connect( myFineness, SIGNAL( activated( int ) ), this, SLOT( onFinenessChanged() ) ); - + + myLocalSizeTable = 0; + if ( !myIsONLY ) + { + QWidget* localSizeGroup = new QWidget(); + QGridLayout* localSizeLayout = new QGridLayout(localSizeGroup); + + myLocalSizeTable = new QTableWidget(0, LSZ_NB_COLUMNS, localSizeGroup); + localSizeLayout->addWidget(myLocalSizeTable, 1, 0, 8, 1); + QStringList localSizeHeaders; + localSizeHeaders << tr( "LSZ_ENTRY_COLUMN" )<< tr( "LSZ_NAME_COLUMN" ) << tr( "LSZ_LOCALSIZE_COLUMN" ); + myLocalSizeTable->setHorizontalHeaderLabels(localSizeHeaders); + myLocalSizeTable->horizontalHeader()->hideSection(LSZ_ENTRY_COLUMN); + myLocalSizeTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive); + myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN); + myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN); + myLocalSizeTable->setAlternatingRowColors(true); + myLocalSizeTable->verticalHeader()->hide(); + + QPushButton* addVertexButton = new QPushButton(tr("NETGEN_LSZ_VERTEX"), localSizeGroup); + localSizeLayout->addWidget(addVertexButton, LSZ_VERTEX_BTN, 1, 1, 1); + QPushButton* addEdgeButton = new QPushButton(tr("NETGEN_LSZ_EDGE"), localSizeGroup); + localSizeLayout->addWidget(addEdgeButton, LSZ_EDGE_BTN, 1, 1, 1); +#ifdef NETGEN_NEW + QPushButton* addFaceButton = new QPushButton(tr("NETGEN_LSZ_FACE"), localSizeGroup); + localSizeLayout->addWidget(addFaceButton, LSZ_FACE_BTN, 1, 1, 1); +#endif + + QFrame *line2 = new QFrame(localSizeGroup); + line2->setFrameShape(QFrame::HLine); + line2->setFrameShadow(QFrame::Sunken); + localSizeLayout->addWidget(line2, LSZ_SEPARATOR2, 1, 1, 1); + + QPushButton* removeButton = new QPushButton(tr("NETGEN_LSZ_REMOVE"), localSizeGroup); + localSizeLayout->addWidget(removeButton, LSZ_REMOVE_BTN, 1, 1, 1); + + connect( addVertexButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnVertex())); + connect( addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnEdge())); +#ifdef NETGEN_NEW + connect( addFaceButton, SIGNAL(clicked()), this, SLOT(onAddLocalSizeOnFace())); +#endif + connect( removeButton, SIGNAL(clicked()), this, SLOT(onRemoveLocalSizeOnShape())); + connect( myLocalSizeTable, SIGNAL(cellChanged(int, int)), this, SLOT(onSetLocalSize(int, int))); + + tab->insertTab(LSZ_TAB, localSizeGroup, tr("NETGEN_LOCAL_SIZE")); + } return fr; } @@ -183,9 +278,16 @@ void NETGENPluginGUI_HypothesisCreator::retrieveParams() const myMaxSize->setValue( data.myMaxSize ); else myMaxSize->setText( data.myMaxSizeVar ); - - mySecondOrder->setChecked( data.mySecondOrder ); - myOptimize->setChecked( data.myOptimize ); + + if(data.myMinSizeVar.isEmpty()) + myMinSize->setValue( data.myMinSize ); + else + myMinSize->setText( data.myMinSizeVar ); + + if ( mySecondOrder ) + mySecondOrder->setChecked( data.mySecondOrder ); + if ( myOptimize ) + myOptimize->setChecked( data.myOptimize ); myFineness->setCurrentIndex( data.myFineness ); if(data.myGrowthRateVar.isEmpty()) @@ -193,24 +295,53 @@ void NETGENPluginGUI_HypothesisCreator::retrieveParams() const else myGrowthRate->setText( data.myGrowthRateVar ); - if(data.myNbSegPerEdgeVar.isEmpty()) - myNbSegPerEdge->setValue( data.myNbSegPerEdge ); - else - myNbSegPerEdge->setText( data.myNbSegPerEdgeVar ); - - if(data.myNbSegPerRadiusVar.isEmpty()) - myNbSegPerRadius->setValue( data.myNbSegPerRadius ); - else - myNbSegPerRadius->setText( data.myNbSegPerRadiusVar ); - - if (myIs2D) + if ( myNbSegPerEdge ) + { + if(data.myNbSegPerEdgeVar.isEmpty()) + myNbSegPerEdge->setValue( data.myNbSegPerEdge ); + else + myNbSegPerEdge->setText( data.myNbSegPerEdgeVar ); + } + if ( myNbSegPerRadius ) + { + if(data.myNbSegPerRadiusVar.isEmpty()) + myNbSegPerRadius->setValue( data.myNbSegPerRadius ); + else + myNbSegPerRadius->setText( data.myNbSegPerRadiusVar ); + } + if (myAllowQuadrangles) myAllowQuadrangles->setChecked( data.myAllowQuadrangles ); // update widgets bool isCustom = (myFineness->currentIndex() == UserDefined); myGrowthRate->setEnabled(isCustom); - myNbSegPerEdge->setEnabled(isCustom); - myNbSegPerRadius->setEnabled(isCustom); + if ( myNbSegPerEdge ) + myNbSegPerEdge->setEnabled(isCustom); + if ( myNbSegPerRadius ) + myNbSegPerRadius->setEnabled(isCustom); + + if ( myLocalSizeTable ) + { + NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this; + QMapIterator i(myLocalSizeMap); + GeomSelectionTools* geomSelectionTools = that->getGeomSelectionTools(); + while (i.hasNext()) { + i.next(); + const QString entry = i.key(); + std::string shapeName = geomSelectionTools->getNameFromEntry(entry.toStdString()); + const QString localSize = i.value(); + int row = myLocalSizeTable->rowCount(); + myLocalSizeTable->setRowCount(row+1); + myLocalSizeTable->setItem(row, LSZ_ENTRY_COLUMN, new QTableWidgetItem(entry)); + myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->setFlags(0); + myLocalSizeTable->setItem(row, LSZ_NAME_COLUMN, new QTableWidgetItem(QString::fromStdString(shapeName))); + myLocalSizeTable->item(row, LSZ_NAME_COLUMN)->setFlags(0); + myLocalSizeTable->setItem(row, LSZ_LOCALSIZE_COLUMN, new QTableWidgetItem(localSize)); + myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled); + } + myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN); + myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN); + } } QString NETGENPluginGUI_HypothesisCreator::storeParams() const @@ -220,6 +351,7 @@ QString NETGENPluginGUI_HypothesisCreator::storeParams() const storeParamsToHypo( data ); QString valStr = tr("NETGEN_MAX_SIZE") + " = " + QString::number( data.myMaxSize ) + "; "; + valStr += tr("NETGEN_MIN_SIZE") + " = " + QString::number( data.myMinSize ) + "; "; if ( data.mySecondOrder ) valStr += tr("NETGEN_SECOND_ORDER") + "; "; if ( data.myOptimize ) @@ -242,30 +374,49 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromHypo( NetgenHypothesisData HypothesisData* data = SMESH::GetHypothesisData( hypType() ); h_data.myName = isCreation() && data ? data->Label : ""; - SMESH::ListOfParameters_var aParameters = h->GetLastParameters(); - h_data.myMaxSize = h->GetMaxSize(); - h_data.myMaxSizeVar = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString(""); + h_data.myMaxSizeVar = getVariableName("SetMaxSize"); h_data.mySecondOrder = h->GetSecondOrder(); h_data.myOptimize = h->GetOptimize(); h_data.myFineness = (int) h->GetFineness(); h_data.myGrowthRate = h->GetGrowthRate(); - h_data.myGrowthRateVar = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString(""); + h_data.myGrowthRateVar = getVariableName("SetGrowthRate"); h_data.myNbSegPerEdge = h->GetNbSegPerEdge(); - h_data.myNbSegPerEdgeVar = (aParameters->length() > 2) ? QString(aParameters[2].in()) : QString(""); + h_data.myNbSegPerEdgeVar = getVariableName("SetNbSegPerEdge"); h_data.myNbSegPerRadius = h->GetNbSegPerRadius(); - h_data.myNbSegPerRadiusVar = (aParameters->length() > 3) ? QString(aParameters[3].in()) : QString(""); + h_data.myNbSegPerRadiusVar = getVariableName("SetNbSegPerRadius"); + h_data.myMinSize = h->GetMinSize(); + h_data.myMinSizeVar = getVariableName("SetMinSize"); if ( myIs2D ) { NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d = - NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( initParamsHypothesis() ); + NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( initParamsHypothesis() ); if ( !h_2d->_is_nil() ) - h_data.myAllowQuadrangles = h_2d->GetQuadAllowed(); + h_data.myAllowQuadrangles = h_2d->GetQuadAllowed(); } + NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this; + NETGENPlugin::string_array_var myEntries = h->GetLocalSizeEntries(); + for ( int i=0 ; ilength() ; i++ ) + { + QString entry = myEntries[i].in(); + double val = h->GetLocalSizeOnEntry(entry.toStdString().c_str()); + std::ostringstream tmp; + tmp << val; + QString valstring = QString::fromStdString(tmp.str()); + if (myLocalSizeMap.contains(entry)) + { + if (myLocalSizeMap[entry] == "__TO_DELETE__") + { + continue; + } + } + that->myLocalSizeMap[entry] = valstring; + } + return true; } @@ -279,9 +430,8 @@ bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesi { if( isCreation() ) SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.toLatin1().data() ); - QStringList aVariablesList; + h->SetVarParameter( h_data.myMaxSizeVar.toLatin1().constData(), "SetMaxSize"); h->SetMaxSize( h_data.myMaxSize ); - aVariablesList.append(h_data.myMaxSizeVar); h->SetSecondOrder( h_data.mySecondOrder ); h->SetOptimize( h_data.myOptimize ); int fineness = h_data.myFineness; @@ -289,32 +439,42 @@ bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesi if( fineness==UserDefined ) { - h->SetGrowthRate( h_data.myGrowthRate ); - h->SetNbSegPerEdge( h_data.myNbSegPerEdge ); - h->SetNbSegPerRadius( h_data.myNbSegPerRadius ); - - aVariablesList.append(h_data.myGrowthRateVar); - aVariablesList.append(h_data.myNbSegPerEdgeVar); - aVariablesList.append(h_data.myNbSegPerRadiusVar); + h->SetVarParameter( h_data.myGrowthRateVar.toLatin1().constData(), "SetGrowthRate"); + h->SetGrowthRate( h_data.myGrowthRate ); + h->SetVarParameter( h_data.myNbSegPerEdgeVar.toLatin1().constData(), "SetNbSegPerEdge"); + h->SetNbSegPerEdge( h_data.myNbSegPerEdge ); + h->SetVarParameter( h_data.myNbSegPerRadiusVar.toLatin1().constData(), "SetNbSegPerRadius"); + h->SetNbSegPerRadius( h_data.myNbSegPerRadius ); } + h->SetVarParameter( h_data.myMinSizeVar.toLatin1().constData(), "SetMinSize"); + h->SetMinSize( h_data.myMinSize ); if ( myIs2D ) { - NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d = - NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( h ); - - if ( !h_2d->_is_nil() ) - h_2d->SetQuadAllowed( h_data.myAllowQuadrangles ); + NETGENPlugin::NETGENPlugin_Hypothesis_2D_var h_2d = + NETGENPlugin::NETGENPlugin_Hypothesis_2D::_narrow( h ); + + if ( !h_2d->_is_nil() ) + h_2d->SetQuadAllowed( h_data.myAllowQuadrangles ); } - h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); - if( fineness==UserDefined ) - { - h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); - h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); - h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); - } - + QMapIterator i(myLocalSizeMap); + while (i.hasNext()) { + i.next(); + const QString entry = i.key(); + const QString localSize = i.value(); + if (localSize == "__TO_DELETE__") + { + h->UnsetLocalSizeOnEntry(entry.toLatin1().constData()); + } + else + { + std::istringstream tmp(localSize.toLatin1().constData()); + double val; + tmp >> val; + h->SetLocalSizeOnEntry(entry.toLatin1().constData(), val); + } + } } catch(const SALOME::SALOME_Exception& ex) { @@ -329,21 +489,40 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromWidgets( NetgenHypothesisD h_data.myName = myName ? myName->text() : ""; h_data.myMaxSize = myMaxSize->value(); h_data.myMaxSizeVar = myMaxSize->text(); - h_data.mySecondOrder = mySecondOrder->isChecked(); - h_data.myOptimize = myOptimize->isChecked(); + h_data.myMinSize = myMinSize->value(); + h_data.myMinSizeVar = myMinSize->text(); + if ( mySecondOrder ) + h_data.mySecondOrder = mySecondOrder->isChecked(); + if ( myOptimize ) + h_data.myOptimize = myOptimize->isChecked(); h_data.myFineness = myFineness->currentIndex(); h_data.myGrowthRate = myGrowthRate->value(); - h_data.myNbSegPerEdge = myNbSegPerEdge->value(); - h_data.myNbSegPerRadius = myNbSegPerRadius->value(); + if ( myNbSegPerEdge ) + h_data.myNbSegPerEdge = myNbSegPerEdge->value(); + if ( myNbSegPerRadius ) + h_data.myNbSegPerRadius = myNbSegPerRadius->value(); - h_data.myGrowthRateVar = myGrowthRate->text(); - h_data.myNbSegPerEdgeVar = myNbSegPerEdge->text(); - h_data.myNbSegPerRadiusVar = myNbSegPerRadius->text(); + h_data.myGrowthRateVar = myGrowthRate->text(); + if ( myNbSegPerEdge ) + h_data.myNbSegPerEdgeVar = myNbSegPerEdge->text(); + if ( myNbSegPerRadius ) + h_data.myNbSegPerRadiusVar = myNbSegPerRadius->text(); - if ( myIs2D ) + if ( myAllowQuadrangles ) h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked(); - + + if ( myLocalSizeTable ) + { + NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this; + int nbRows = myLocalSizeTable->rowCount(); + for(int row=0 ; row < nbRows ; row++) + { + QString entry = myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->text(); + QString localSize = myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->text().trimmed(); + that->myLocalSizeMap[entry] = localSize; + } + } return true; } @@ -352,49 +531,175 @@ void NETGENPluginGUI_HypothesisCreator::onFinenessChanged() bool isCustom = (myFineness->currentIndex() == UserDefined); myGrowthRate->setEnabled(isCustom); - myNbSegPerEdge->setEnabled(isCustom); - myNbSegPerRadius->setEnabled(isCustom); + if ( myNbSegPerEdge ) + myNbSegPerEdge->setEnabled(isCustom); + if ( myNbSegPerRadius ) + myNbSegPerRadius->setEnabled(isCustom); if (!isCustom) { double aGrowthRate, aNbSegPerEdge, aNbSegPerRadius; switch ( myFineness->currentIndex() ) - { - case VeryCoarse: - aGrowthRate = 0.7; - aNbSegPerEdge = 0.3; - aNbSegPerRadius = 1; - break; - case Coarse: - aGrowthRate = 0.5; - aNbSegPerEdge = 0.5; - aNbSegPerRadius = 1.5; - break; - case Fine: - aGrowthRate = 0.2; - aNbSegPerEdge = 2; - aNbSegPerRadius = 3; - break; - case VeryFine: - aGrowthRate = 0.1; - aNbSegPerEdge = 3; - aNbSegPerRadius = 5; - break; - case Moderate: - default: - aGrowthRate = 0.3; - aNbSegPerEdge = 1; - aNbSegPerRadius = 2; - break; - } + { + case VeryCoarse: + aGrowthRate = 0.7; + aNbSegPerEdge = 0.3; + aNbSegPerRadius = 1; + break; + case Coarse: + aGrowthRate = 0.5; + aNbSegPerEdge = 0.5; + aNbSegPerRadius = 1.5; + break; + case Fine: + aGrowthRate = 0.2; + aNbSegPerEdge = 2; + aNbSegPerRadius = 3; + break; + case VeryFine: + aGrowthRate = 0.1; + aNbSegPerEdge = 3; + aNbSegPerRadius = 5; + break; + case Moderate: + default: + aGrowthRate = 0.3; + aNbSegPerEdge = 1; + aNbSegPerRadius = 2; + break; + } myGrowthRate->setValue( aGrowthRate ); - myNbSegPerEdge->setValue( aNbSegPerEdge ); - myNbSegPerRadius->setValue( aNbSegPerRadius ); + if ( myNbSegPerEdge ) + myNbSegPerEdge->setValue( aNbSegPerEdge ); + if ( myNbSegPerRadius ) + myNbSegPerRadius->setValue( aNbSegPerRadius ); } } +void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnVertex() +{ + addLocalSizeOnShape(TopAbs_VERTEX); +} + +void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnEdge() +{ + addLocalSizeOnShape(TopAbs_EDGE); +} + +void NETGENPluginGUI_HypothesisCreator::onAddLocalSizeOnFace() +{ + addLocalSizeOnShape(TopAbs_FACE); +} + +void NETGENPluginGUI_HypothesisCreator::addLocalSizeOnShape(TopAbs_ShapeEnum typeShapeAsked) +{ + NETGENPlugin::NETGENPlugin_Hypothesis_var h = NETGENPlugin::NETGENPlugin_Hypothesis::_narrow(initParamsHypothesis()); + GeomSelectionTools* geomSelectionTools = getGeomSelectionTools(); + LightApp_SelectionMgr* mySel = geomSelectionTools->selectionMgr(); + SALOME_ListIO ListSelectedObjects; + mySel->selectedObjects(ListSelectedObjects, NULL, false ); + SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects); + for (Object_It ; Object_It.More() ; Object_It.Next()) + { + Handle(SALOME_InteractiveObject) anObject = Object_It.Value(); + std::string entry, shapeName; + entry = geomSelectionTools->getEntryOfObject(anObject); + shapeName = anObject->getName(); + TopAbs_ShapeEnum shapeType; + shapeType = geomSelectionTools->entryToShapeType(entry); + if (shapeType == TopAbs_SHAPE) + { + // E.A. if shapeType == TopAbs_SHAPE, it is NOT a TopoDS_Shape !!! + continue; + } + // -- + if(shapeType != typeShapeAsked) + { + continue; + } + // -- + myLocalSizeTable->setFocus(); + QString shapeEntry; + shapeEntry = QString::fromStdString(entry); + if (myLocalSizeMap.contains(shapeEntry)) + { + if (myLocalSizeMap[shapeEntry] != "__TO_DELETE__") + { + continue; + } + } + double phySize = h->GetMaxSize(); + std::ostringstream oss; + oss << phySize; + QString localSize; + localSize = QString::fromStdString(oss.str()); + // -- + int row = myLocalSizeTable->rowCount() ; + myLocalSizeTable->setRowCount(row+1); + myLocalSizeTable->setItem(row, LSZ_ENTRY_COLUMN, new QTableWidgetItem(shapeEntry)); + myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN )->setFlags(0); + myLocalSizeTable->setItem(row, LSZ_NAME_COLUMN, new QTableWidgetItem(QString::fromStdString(shapeName))); + myLocalSizeTable->item(row, LSZ_NAME_COLUMN )->setFlags(0); + myLocalSizeTable->setItem(row, LSZ_LOCALSIZE_COLUMN, new QTableWidgetItem(localSize)); + myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN )->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsEnabled); + myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN); + myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN); + myLocalSizeTable->clearSelection(); + myLocalSizeTable->scrollToItem( myLocalSizeTable->item( row, LSZ_LOCALSIZE_COLUMN ) ); + // -- + } +} + +void NETGENPluginGUI_HypothesisCreator::onRemoveLocalSizeOnShape() +{ + QList selectedRows; + QList selected = myLocalSizeTable->selectedItems(); + QTableWidgetItem* item; + int row; + foreach(item, selected) { + row = item->row(); + if (!selectedRows.contains(row)) + selectedRows.append( row ); + } + qSort( selectedRows ); + QListIterator it( selectedRows ); + it.toBack(); + while (it.hasPrevious()) + { + row = it.previous(); + QString entry = myLocalSizeTable->item(row,LSZ_ENTRY_COLUMN)->text(); + if (myLocalSizeMap.contains(entry)) + { + myLocalSizeMap[entry] = "__TO_DELETE__"; + } + myLocalSizeTable->removeRow(row ); + } + myLocalSizeTable->resizeColumnToContents(LSZ_NAME_COLUMN); + myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN); +} + +void NETGENPluginGUI_HypothesisCreator::onSetLocalSize(int row,int col) +{ + if (col == LSZ_LOCALSIZE_COLUMN) { + QString entry = myLocalSizeTable->item(row, LSZ_ENTRY_COLUMN)->text(); + QString localSize = myLocalSizeTable->item(row, LSZ_LOCALSIZE_COLUMN)->text().trimmed(); + myLocalSizeMap[entry] = localSize; + myLocalSizeTable->resizeColumnToContents(LSZ_LOCALSIZE_COLUMN); + } +} + +GeomSelectionTools* NETGENPluginGUI_HypothesisCreator::getGeomSelectionTools() +{ + _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); + if (myGeomSelectionTools == NULL || myGeomSelectionTools->getMyStudy() != aStudy) { + delete myGeomSelectionTools; + myGeomSelectionTools = new GeomSelectionTools(aStudy); + } + return myGeomSelectionTools; +} + QString NETGENPluginGUI_HypothesisCreator::caption() const { return tr( QString( "NETGEN_%1_TITLE" ).arg(myIs2D?QString("2D"):QString("3D")).toLatin1().data() ); diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.h b/src/GUI/NETGENPluginGUI_HypothesisCreator.h index a23739e..f636dcc 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.h +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.h @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin GUI: GUI for plugged-in mesher NETGENPlugin // File : NETGENPluginGUI_HypothesisCreator.h // Author : Michael Zorin @@ -32,18 +33,22 @@ #include -class SalomeApp_DoubleSpinBox; +#include + +class SMESHGUI_SpinBox; +class GeomSelectionTools; class QComboBox; class QCheckBox; class QLineEdit; +class QTableWidget; typedef struct { - double myMaxSize, myGrowthRate, myNbSegPerEdge, myNbSegPerRadius; + double myMaxSize, myMinSize, myGrowthRate, myNbSegPerEdge, myNbSegPerRadius; int myFineness; bool mySecondOrder, myAllowQuadrangles, myOptimize; QString myName; - QString myMaxSizeVar, myGrowthRateVar, myNbSegPerEdgeVar, myNbSegPerRadiusVar; + QString myMaxSizeVar, myMinSizeVar, myGrowthRateVar, myNbSegPerEdgeVar, myNbSegPerRadiusVar; } NetgenHypothesisData; /*! @@ -71,24 +76,37 @@ protected: protected slots: virtual void onFinenessChanged(); + virtual void onAddLocalSizeOnVertex(); + virtual void onAddLocalSizeOnEdge(); + virtual void onAddLocalSizeOnFace(); + virtual void onRemoveLocalSizeOnShape(); + virtual void onSetLocalSize(int,int); private: bool readParamsFromHypo( NetgenHypothesisData& ) const; bool readParamsFromWidgets( NetgenHypothesisData& ) const; bool storeParamsToHypo( const NetgenHypothesisData& ) const; + GeomSelectionTools* getGeomSelectionTools(); + void addLocalSizeOnShape(TopAbs_ShapeEnum); private: QLineEdit* myName; - SalomeApp_DoubleSpinBox* myMaxSize; + SMESHGUI_SpinBox* myMaxSize; + SMESHGUI_SpinBox* myMinSize; QCheckBox* mySecondOrder; QCheckBox* myOptimize; QComboBox* myFineness; - SalomeApp_DoubleSpinBox* myGrowthRate; - SalomeApp_DoubleSpinBox* myNbSegPerEdge; - SalomeApp_DoubleSpinBox* myNbSegPerRadius; + SMESHGUI_SpinBox* myGrowthRate; + SMESHGUI_SpinBox* myNbSegPerEdge; + SMESHGUI_SpinBox* myNbSegPerRadius; QCheckBox* myAllowQuadrangles; bool myIs2D; + bool myIsONLY; + + QTableWidget* myLocalSizeTable; + GeomSelectionTools* myGeomSelectionTools; + QMap myLocalSizeMap; }; #endif diff --git a/src/GUI/NETGENPluginGUI_SimpleCreator.cxx b/src/GUI/NETGENPluginGUI_SimpleCreator.cxx index 596a34d..12fa4b8 100644 --- a/src/GUI/NETGENPluginGUI_SimpleCreator.cxx +++ b/src/GUI/NETGENPluginGUI_SimpleCreator.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 : NETGENPluginGUI_SimpleCreator.cxx // Author : Open CASCADE S.A.S. // SMESH includes @@ -28,7 +26,6 @@ #include #include #include -#include // IDL includes #include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm) @@ -74,6 +71,7 @@ NETGENPluginGUI_SimpleCreator::NETGENPluginGUI_SimpleCreator(const QString& theH myLengthRadioBut(0), myLenFromEdgesCheckBox(0), myArea(0), + myAllowQuadCheckBox(0), myLenFromFacesCheckBox(0), myVolume(0) { @@ -86,12 +84,15 @@ NETGENPluginGUI_SimpleCreator::~NETGENPluginGUI_SimpleCreator() bool NETGENPluginGUI_SimpleCreator::checkParams(QString& msg) const { bool result = true; - result = myNbSeg->isValid(msg,true) && result; - result = myLength->isValid(msg,true) && result; - result = myArea->isValid(msg,true) && result; - if (myVolume) + if ( myNbSeg->isEnabled() ) + result = myNbSeg->isValid(msg,true) && result; + if ( myLength->isEnabled() ) + result = myLength->isValid(msg,true) && result; + if ( myArea->isEnabled() ) + result = myArea->isValid(msg,true) && result; + if (myVolume && myVolume->isEnabled() ) result = myVolume->isValid(msg,true) && result; - + return result; } @@ -151,7 +152,7 @@ QFrame* NETGENPluginGUI_SimpleCreator::buildFrame() // * local length myLengthRadioBut = new QRadioButton( tr( "SMESH_LOCAL_LENGTH_HYPOTHESIS" ), dimGroup ); myLength = new SMESHGUI_SpinBox( dimGroup ); - myLength->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 0.1, 6 ); + myLength->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 0.1, "length_precision" ); myLength->setValue( 1. ); dimLay->addWidget( myLengthRadioBut, dimRow, 0 ); dimLay->addWidget( myLength, dimRow, 1 ); @@ -178,13 +179,22 @@ QFrame* NETGENPluginGUI_SimpleCreator::buildFrame() // * max area dimLay->addWidget( new QLabel( tr( "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" ), dimGroup), dimRow, 0); myArea = new SMESHGUI_SpinBox( dimGroup ); - myArea->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 0.1, 6 ); + myArea->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 0.1, "area_precision" ); myArea->setValue( 1. ); dimLay->addWidget( myArea, dimRow, 1 ); dimRow++; + // * allow quadrangles + const bool is3D = ( hypType()=="NETGEN_SimpleParameters_3D" ); + if ( !is3D ) + { + myAllowQuadCheckBox = new QCheckBox( tr( "NETGEN_ALLOW_QUADRANGLES" ), dimGroup ); + dimLay->addWidget( myAllowQuadCheckBox, dimRow, 0, 1, 2 ); + dimRow++; + } + // 3D params group - if ( hypType()=="NETGEN_SimpleParameters_3D" ) + if ( is3D ) { dimGroup = new QGroupBox( tr( "NG_3D" ), argGroup ); argLay->addWidget( dimGroup, argRow, 0, 1, 2 ); @@ -205,7 +215,7 @@ QFrame* NETGENPluginGUI_SimpleCreator::buildFrame() // * max volume dimLay->addWidget(new QLabel( tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"), dimGroup), dimRow, 0); myVolume = new SMESHGUI_SpinBox( dimGroup ); - myVolume->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 0.1, 6 ); + myVolume->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 0.1, "volume_precision" ); myVolume->setValue( 1. ); dimLay->addWidget( myVolume, dimRow, 1 ); dimRow++; @@ -225,20 +235,18 @@ void NETGENPluginGUI_SimpleCreator::retrieveParams() const if ( isCreation() ) myName->setText( hypName() ); - // set default real values + // Set default values NETGENPlugin_SimpleHypothesis_2D_var h = NETGENPlugin_SimpleHypothesis_2D::_narrow( initParamsHypothesis( hasInitParamsHypothesis() )); - if ( double len = h->GetLocalLength() ) + int dfltNbSeg = (int) h->GetNumberOfSegments(); + myNbSeg->setValue( dfltNbSeg ); + if ( double len = h->GetLocalLength() ) { myLength->setValue( len ); - if ( double area = h->GetMaxElementArea() ) - myArea->setValue( area ); - if ( myVolume ) { - NETGENPlugin_SimpleHypothesis_3D_var h3d = - NETGENPlugin_SimpleHypothesis_3D::_narrow( initParamsHypothesis( hasInitParamsHypothesis()) ); - if ( double volume = (double) h3d->GetMaxElementVolume() ) - myVolume->setValue( volume ); + myArea->setValue( len * len ); + if ( myVolume ) + myVolume->setValue( len * len * len ); } h = NETGENPlugin_SimpleHypothesis_2D::_narrow( hypothesis() ); @@ -248,14 +256,14 @@ void NETGENPluginGUI_SimpleCreator::retrieveParams() const SMESH::ListOfParameters_var aParameters = h->GetLastParameters(); // 1D - int nbSeg = (int) h->GetNumberOfSegments(); + int nbSeg = isCreation() ? dfltNbSeg : (int) h->GetNumberOfSegments(); myNbSegRadioBut->setChecked( nbSeg ); myLengthRadioBut->setChecked( !nbSeg ); QString aPrm; if ( nbSeg ) { myLength->setEnabled( false ); myNbSeg->setEnabled( true ); - aPrm = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString(""); + aPrm = getVariableName("SetNumberOfSegments"); if(aPrm.isEmpty()) myNbSeg->setValue( nbSeg ); else @@ -264,7 +272,7 @@ void NETGENPluginGUI_SimpleCreator::retrieveParams() const else { myNbSeg->setEnabled( false ); myLength->setEnabled( true ); - aPrm = (aParameters->length() > 0) ? QString(aParameters[0].in()) : QString(""); + aPrm = getVariableName("SetLocalLength"); if(aPrm.isEmpty()) myLength->setValue( h->GetLocalLength() ); else @@ -275,7 +283,7 @@ void NETGENPluginGUI_SimpleCreator::retrieveParams() const if ( double area = h->GetMaxElementArea() ) { myLenFromEdgesCheckBox->setChecked( false ); myArea->setEnabled( true ); - aPrm = (aParameters->length() > 1) ? QString(aParameters[1].in()) : QString(""); + aPrm = getVariableName("SetMaxElementArea"); if(aPrm.isEmpty()) myArea->setValue( area ); else @@ -285,6 +293,8 @@ void NETGENPluginGUI_SimpleCreator::retrieveParams() const myLenFromEdgesCheckBox->setChecked( true ); myArea->setEnabled( false ); } + if ( myAllowQuadCheckBox ) + myAllowQuadCheckBox->setChecked( h->GetAllowQuadrangles() ); // 3D if ( myVolume ) { @@ -292,7 +302,7 @@ void NETGENPluginGUI_SimpleCreator::retrieveParams() const if ( double volume = (double) h->GetMaxElementVolume() ) { myLenFromFacesCheckBox->setChecked( false ); myVolume->setEnabled( true ); - aPrm = (aParameters->length() > 2) ? QString(aParameters[2].in()) : QString(""); + aPrm = getVariableName("SetMaxElementVolume"); if(aPrm.isEmpty()) myVolume->setValue( volume ); else @@ -319,49 +329,43 @@ QString NETGENPluginGUI_SimpleCreator::storeParams() const // 1D - QStringList aVariablesList; if ( myNbSeg->isEnabled() ) { + h->SetVarParameter( myNbSeg->text().toLatin1().constData(), "SetNumberOfSegments"); h->SetNumberOfSegments( myNbSeg->value() ); valStr += "nbSeg=" + myNbSeg->text(); - aVariablesList.append(myNbSeg->text()); } else { + h->SetVarParameter( myLength->text().toLatin1().constData(), "SetLocalLength"); h->SetLocalLength( myLength->value() ); valStr += "len=" + myLength->text(); - aVariablesList.append(myLength->text()); } - h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); - // 2D if ( myArea->isEnabled() ) { + h->SetVarParameter( myArea->text().toLatin1().constData(), "SetMaxElementArea"); h->SetMaxElementArea( myArea->value() ); valStr += "; area=" + myArea->text(); - aVariablesList.append(myArea->text()); } else { h->LengthFromEdges(); valStr += "; lenFromEdges"; - aVariablesList.append(QString()); } - - h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); + if ( myAllowQuadCheckBox ) + h->SetAllowQuadrangles( myAllowQuadCheckBox->isChecked() ); // 3D if ( myVolume ) { NETGENPlugin_SimpleHypothesis_3D_var h = NETGENPlugin_SimpleHypothesis_3D::_narrow( hypothesis() ); if ( myVolume->isEnabled() ) { + h->SetVarParameter( myVolume->text().toLatin1().constData(), "SetMaxElementVolume"); h->SetMaxElementVolume( myVolume->value() ); valStr += "; vol=" + myVolume->text(); - aVariablesList.append( myVolume->text()); } else { h->LengthFromFaces(); valStr += "; lenFromFaces"; - aVariablesList.append(QString()); } - h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); } } catch(const SALOME::SALOME_Exception& ex) diff --git a/src/GUI/NETGENPluginGUI_SimpleCreator.h b/src/GUI/NETGENPluginGUI_SimpleCreator.h index 4b7bb88..a275463 100644 --- a/src/GUI/NETGENPluginGUI_SimpleCreator.h +++ b/src/GUI/NETGENPluginGUI_SimpleCreator.h @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 : NETGENPluginGUI_SimpleCreator.h // Author : Open CASCADE S.A.S. // @@ -69,6 +67,7 @@ private: QCheckBox* myLenFromEdgesCheckBox; SMESHGUI_SpinBox* myArea; + QCheckBox* myAllowQuadCheckBox; QCheckBox* myLenFromFacesCheckBox; SMESHGUI_SpinBox* myVolume; diff --git a/src/GUI/NETGENPlugin_images.ts b/src/GUI/NETGENPlugin_images.ts index 92ae658..121c504 100644 --- a/src/GUI/NETGENPlugin_images.ts +++ b/src/GUI/NETGENPlugin_images.ts @@ -1,28 +1,6 @@ + - - + @default @@ -45,13 +23,17 @@ ICON_SMESH_TREE_ALGO_NETGEN_2D mesh_tree_algo_netgen_2d.png + + ICON_SMESH_TREE_ALGO_NETGEN_2D_ONLY + mesh_tree_algo_netgen_2d.png + ICON_SMESH_TREE_ALGO_NETGEN_2D3D mesh_tree_algo_netgen_2d3d.png ICON_SMESH_TREE_ALGO_NETGEN_3D - mesh_tree_algo_tetra.png + mesh_tree_algo_netgen_2d3d.png ICON_SMESH_TREE_HYPO_NETGEN_Parameters diff --git a/src/GUI/NETGENPlugin_msg_en.ts b/src/GUI/NETGENPlugin_msg_en.ts index 42ef251..55e4ceb 100644 --- a/src/GUI/NETGENPlugin_msg_en.ts +++ b/src/GUI/NETGENPlugin_msg_en.ts @@ -1,137 +1,151 @@ + - - - - @default - - NETGEN_2D_HYPOTHESIS - Netgen 2D - - - NETGEN_2D_TITLE - Hypothesis Construction - - - NETGEN_3D_HYPOTHESIS - Netgen 3D - - - NETGEN_3D_TITLE - Hypothesis Construction - - - NETGEN_SimpleParameters_3D_HYPOTHESIS - Netgen 3D simple parameters - - - NETGEN_SimpleParameters_3D_TITLE - Hypothesis Construction - - - NETGEN_SimpleParameters_2D_HYPOTHESIS - Netgen 2D simple parameters - - - NETGEN_SimpleParameters_2D_TITLE - Hypothesis Construction - - - NETGEN_ALLOW_QUADRANGLES - Allow Quadrangles - - - NETGEN_COARSE - Coarse - - - NETGEN_CUSTOM - Custom - - - NETGEN_FINE - Fine - - - NETGEN_FINENESS - Fineness - - - NETGEN_GROWTH_RATE - Growth Rate - - - NETGEN_MAX_SIZE - Max. Size - - - NETGEN_MODERATE - Moderate - - - NETGEN_OPTIMIZE - Optimize - - - NETGEN_SECOND_ORDER - Second Order - - - NETGEN_SEG_PER_EDGE - Nb. Segs per Edge - - - NETGEN_SEG_PER_RADIUS - Nb. Segs per Radius - - - NETGEN_VERYCOARSE - Very Coarse - - - NETGEN_VERYFINE - Very Fine - - - NG_1D - 1D - - - NG_2D - 2D - - - NG_3D - 3D - - - NG_LENGTH_FROM_EDGES - Length from edges - - - NG_LENGTH_FROM_FACES - Length from faces - - + + + @default + + NETGEN_2D_HYPOTHESIS + Netgen 2D + + + NETGEN_2D_TITLE + Hypothesis Construction + + + NETGEN_3D_HYPOTHESIS + Netgen 3D + + + NETGEN_3D_TITLE + Hypothesis Construction + + + NETGEN_SimpleParameters_3D_HYPOTHESIS + Netgen 3D simple parameters + + + NETGEN_SimpleParameters_3D_TITLE + Hypothesis Construction + + + NETGEN_SimpleParameters_2D_HYPOTHESIS + Netgen 2D simple parameters + + + NETGEN_SimpleParameters_2D_TITLE + Hypothesis Construction + + + NETGEN_ALLOW_QUADRANGLES + Allow Quadrangles + + + NETGEN_COARSE + Coarse + + + NETGEN_CUSTOM + Custom + + + NETGEN_FINE + Fine + + + NETGEN_FINENESS + Fineness + + + NETGEN_GROWTH_RATE + Growth Rate + + + NETGEN_MAX_SIZE + Max. Size + + + NETGEN_MIN_SIZE + Min. Size + + + NETGEN_MODERATE + Moderate + + + NETGEN_OPTIMIZE + Optimize + + + NETGEN_SECOND_ORDER + Second Order + + + NETGEN_SEG_PER_EDGE + Nb. Segs per Edge + + + NETGEN_SEG_PER_RADIUS + Nb. Segs per Radius + + + NETGEN_VERYCOARSE + Very Coarse + + + NETGEN_VERYFINE + Very Fine + + + NG_1D + 1D + + + NG_2D + 2D + + + NG_3D + 3D + + + NG_LENGTH_FROM_EDGES + Length from edges + + + NG_LENGTH_FROM_FACES + Length from faces + + + NETGEN_LOCAL_SIZE + Local sizes + + + NETGEN_LSZ_VERTEX + On Vertex + + + NETGEN_LSZ_EDGE + On Edge + + + NETGEN_LSZ_FACE + On Sub-Face + + + NETGEN_LSZ_REMOVE + Remove + + + LSZ_ENTRY_COLUMN + Entry + + + LSZ_NAME_COLUMN + Name + + + LSZ_LOCALSIZE_COLUMN + Value + + diff --git a/src/GUI/NETGENPlugin_msg_fr.ts b/src/GUI/NETGENPlugin_msg_fr.ts new file mode 100755 index 0000000..01acbc0 --- /dev/null +++ b/src/GUI/NETGENPlugin_msg_fr.ts @@ -0,0 +1,151 @@ + + + + + @default + + NETGEN_2D_HYPOTHESIS + Netgen 2D + + + NETGEN_2D_TITLE + Construction d'une hypothèse + + + NETGEN_3D_HYPOTHESIS + Netgen 3D + + + NETGEN_3D_TITLE + Construction d'une hypothèse + + + NETGEN_SimpleParameters_3D_HYPOTHESIS + Netgen 3D paramètres simplifiés + + + NETGEN_SimpleParameters_3D_TITLE + Construction d'une hypothèse + + + NETGEN_SimpleParameters_2D_HYPOTHESIS + Netgen 2D paramètres simplifiés + + + NETGEN_SimpleParameters_2D_TITLE + Construction d'une hypothèse + + + NETGEN_ALLOW_QUADRANGLES + Autoriser les quadrangles + + + NETGEN_COARSE + Grossier + + + NETGEN_CUSTOM + Personnalisé + + + NETGEN_FINE + Fin + + + NETGEN_FINENESS + Finesse + + + NETGEN_GROWTH_RATE + Taux d'accroissement + + + NETGEN_MAX_SIZE + Taille maximale + + + NETGEN_MIN_SIZE + Taille minimale + + + NETGEN_MODERATE + Moyen + + + NETGEN_OPTIMIZE + Optimiser + + + NETGEN_SECOND_ORDER + Second ordre + + + NETGEN_SEG_PER_EDGE + Nb. segments par arête + + + NETGEN_SEG_PER_RADIUS + Nb. segments par rayon + + + NETGEN_VERYCOARSE + Très grossier + + + NETGEN_VERYFINE + Très fin + + + NG_1D + 1D + + + NG_2D + 2D + + + NG_3D + 3D + + + NG_LENGTH_FROM_EDGES + Longueur à partir des arêtes + + + NG_LENGTH_FROM_FACES + Longueur à partir des faces + + + NETGEN_LOCAL_SIZE + Tailles locales + + + NETGEN_LSZ_VERTEX + Sur un point + + + NETGEN_LSZ_EDGE + Sur une arête + + + NETGEN_LSZ_FACE + Sur une sous-face + + + NETGEN_LSZ_REMOVE + Supprimer + + + LSZ_ENTRY_COLUMN + Entrée + + + LSZ_NAME_COLUMN + Nom + + + LSZ_LOCALSIZE_COLUMN + Valeur + + + diff --git a/src/Makefile.am b/src/Makefile.am index 7251f43..0b988a7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 : Makefile.in # Author : Patrick GOLDBRONN (CEA) # Modified by : Alexander BORODIN (OCN) - autotools usage @@ -27,7 +25,15 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am -SUBDIRS = NETGEN NETGENPlugin +SUBDIRS = +if CMAKE_BUILD +else +if NETGEN_NEW +else + SUBDIRS += NETGEN +endif +endif +SUBDIRS += NETGENPlugin if NETGENPLUGIN_ENABLE_GUI SUBDIRS += GUI diff --git a/src/NETGEN/Makefile.am b/src/NETGEN/Makefile.am index 0ac0539..c494321 100644 --- a/src/NETGEN/Makefile.am +++ b/src/NETGEN/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 diff --git a/src/NETGEN/ReadMeForNgUsers b/src/NETGEN/ReadMeForNgUsers index 0b7cb28..7d982a8 100644 --- a/src/NETGEN/ReadMeForNgUsers +++ b/src/NETGEN/ReadMeForNgUsers @@ -1,3 +1,41 @@ +# ------------------------------------------------------------------ +# ------------------------------------------------------------------ +# Notes for Netgen >= 4.9 +# ------------------------------------------------------------------ +# ------------------------------------------------------------------ + +Netgen can be find at http://www.hpfem.jku.at/netgen/ + +1. How to build Netgen for Netgen Plugin +------------------------------ + +1.1. Download Netgen archive (here netgen-4.9.12.tar.gz) and unpack it + +1.2. Configure the netgen compilation. The "good" options are + ../netgen-4.9.12/configure \ + --prefix=THE_INSTALLATION_PATH \ + --with-occ=${CASROOT} \ + CXXFLAGS="-I${TOGL_HOME}/include" \ + LDFLAGS="-L${TOGL_HOME}/lib/Togl1.7" + +1.3. Compile the netgen product + make then make install + +1.4. Patch the installation directory to copy include files + needed by NETGEN Plugin. Use the script + NETGENPLUGIN_SRC/src/NETGEN/netgen_copy_include_for_salome + to achieve that. The first argument is the directory containing + the Netgen sources. The second argument is THE_INSTALLATION_PATH + +Erwan ADAM +erwan.adam@cea.fr + +# ------------------------------------------------------------------ +# ------------------------------------------------------------------ +# Notes for Netgen 4.5 +# ------------------------------------------------------------------ +# ------------------------------------------------------------------ + The Netgen 4.5 from the web location : http://www.hpfem.jku.at/netgen/ (CVS access) is used in the SMESH Module of Salome3 distribution. @@ -92,3 +130,8 @@ The suggested patch alters some Netgen sources to compile them. Michael SAZONOV m-sazonov@opencascade.com + +# ------------------------------------------------------------------ +# ------------------------------------------------------------------ +# ------------------------------------------------------------------ +# ------------------------------------------------------------------ diff --git a/src/NETGEN/netgen45ForSalome.patch b/src/NETGEN/netgen45ForSalome.patch index fac1fc0..b77fc51 100644 --- a/src/NETGEN/netgen45ForSalome.patch +++ b/src/NETGEN/netgen45ForSalome.patch @@ -1,6 +1,66 @@ -diff -Naur netgen-4.5.old/libsrc/csg/meshsurf.cpp netgen-4.5.new/libsrc/csg/meshsurf.cpp ---- netgen-4.5.old/libsrc/csg/meshsurf.cpp 2006-02-14 11:54:35.000000000 +0300 -+++ netgen-4.5.new/libsrc/csg/meshsurf.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/csg/algprim.cpp netgen-4.5_new/libsrc/csg/algprim.cpp +--- netgen-4.5_orig/libsrc/csg/algprim.cpp 2006-01-25 16:30:28.000000000 +0300 ++++ netgen-4.5_new/libsrc/csg/algprim.cpp 2010-11-25 10:11:30.000000000 +0300 +@@ -108,7 +108,7 @@ + void Plane :: GetPrimitiveData (char *& classname, + ARRAY & coeffs) const + { +- classname = "plane"; ++ classname = (char*)"plane"; + coeffs.SetSize (6); + coeffs.Elem(1) = p(0); + coeffs.Elem(2) = p(1); +@@ -355,7 +355,7 @@ + + void Sphere :: GetPrimitiveData (char *& classname, ARRAY & coeffs) const + { +- classname = "sphere"; ++ classname = (char*)"sphere"; + coeffs.SetSize (4); + coeffs.Elem(1) = c(0); + coeffs.Elem(2) = c(1); +@@ -760,7 +760,7 @@ + + void Cylinder :: GetPrimitiveData (char *& classname, ARRAY & coeffs) const + { +- classname = "cylinder"; ++ classname = (char*)"cylinder"; + coeffs.SetSize (7); + coeffs.Elem(1) = a(0); + coeffs.Elem(2) = a(1); +@@ -1243,7 +1243,7 @@ + + void Cone :: GetPrimitiveData (char *& classname, ARRAY & coeffs) const + { +- classname = "cone"; ++ classname = (char*)"cone"; + coeffs.SetSize (8); + coeffs.Elem(1) = a(0); + coeffs.Elem(2) = a(1); +@@ -1446,7 +1446,7 @@ + + void Torus :: GetPrimitiveData (char *& classname, ARRAY & coeffs) const + { +- classname = "torus"; ++ classname = (char*)"torus"; + coeffs.SetSize (8); + coeffs.Elem(1) = c(0); + coeffs.Elem(2) = c(1); +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/csg/brick.cpp netgen-4.5_new/libsrc/csg/brick.cpp +--- netgen-4.5_orig/libsrc/csg/brick.cpp 2006-02-08 15:23:15.000000000 +0300 ++++ netgen-4.5_new/libsrc/csg/brick.cpp 2010-11-25 10:11:30.000000000 +0300 +@@ -345,7 +345,7 @@ + void Brick :: + GetPrimitiveData (char *& classname, ARRAY & coeffs) const + { +- classname = "brick"; ++ classname = (char*)"brick"; + coeffs.SetSize(12); + coeffs.Elem(1) = p1(0); + coeffs.Elem(2) = p1(1); +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/csg/meshsurf.cpp netgen-4.5_new/libsrc/csg/meshsurf.cpp +--- netgen-4.5_orig/libsrc/csg/meshsurf.cpp 2006-02-14 11:54:35.000000000 +0300 ++++ netgen-4.5_new/libsrc/csg/meshsurf.cpp 2010-11-25 10:11:30.000000000 +0300 @@ -77,11 +77,12 @@ } @@ -15,9 +75,9 @@ diff -Naur netgen-4.5.old/libsrc/csg/meshsurf.cpp netgen-4.5.new/libsrc/csg/mesh } void MeshOptimize2dSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2, -diff -Naur netgen-4.5.old/libsrc/csg/meshsurf.hpp netgen-4.5.new/libsrc/csg/meshsurf.hpp ---- netgen-4.5.old/libsrc/csg/meshsurf.hpp 2004-01-20 14:49:44.000000000 +0300 -+++ netgen-4.5.new/libsrc/csg/meshsurf.hpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/csg/meshsurf.hpp netgen-4.5_new/libsrc/csg/meshsurf.hpp +--- netgen-4.5_orig/libsrc/csg/meshsurf.hpp 2004-01-20 14:49:44.000000000 +0300 ++++ netgen-4.5_new/libsrc/csg/meshsurf.hpp 2010-11-25 10:11:30.000000000 +0300 @@ -45,7 +45,7 @@ MeshOptimize2dSurfaces (const CSGeometry & ageometry); @@ -27,9 +87,104 @@ diff -Naur netgen-4.5.old/libsrc/csg/meshsurf.hpp netgen-4.5.new/libsrc/csg/mesh /// virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const; /// -diff -Naur netgen-4.5.old/libsrc/interface/Makefile netgen-4.5.new/libsrc/interface/Makefile ---- netgen-4.5.old/libsrc/interface/Makefile 2005-08-09 18:14:59.000000000 +0400 -+++ netgen-4.5.new/libsrc/interface/Makefile 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/csg/polyhedra.cpp netgen-4.5_new/libsrc/csg/polyhedra.cpp +--- netgen-4.5_orig/libsrc/csg/polyhedra.cpp 2006-02-09 13:33:11.000000000 +0300 ++++ netgen-4.5_new/libsrc/csg/polyhedra.cpp 2010-11-25 10:11:30.000000000 +0300 +@@ -287,7 +287,7 @@ + void Polyhedra :: GetPrimitiveData (char *& classname, + ARRAY & coeffs) const + { +- classname = "Polyhedra"; ++ classname = (char*)"Polyhedra"; + coeffs.SetSize(0); + coeffs.Append (points.Size()); + coeffs.Append (faces.Size()); +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/csg/surface.cpp netgen-4.5_new/libsrc/csg/surface.cpp +--- netgen-4.5_orig/libsrc/csg/surface.cpp 2006-02-08 15:23:16.000000000 +0300 ++++ netgen-4.5_new/libsrc/csg/surface.cpp 2010-11-25 10:11:30.000000000 +0300 +@@ -215,7 +215,7 @@ + void Primitive :: GetPrimitiveData (char *& classname, + ARRAY & coeffs) const + { +- classname = "undef"; ++ classname = (char*)"undef"; + coeffs.SetSize (0); + } + +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/general/profiler.cpp netgen-4.5_new/libsrc/general/profiler.cpp +--- netgen-4.5_orig/libsrc/general/profiler.cpp 2006-01-11 13:05:59.000000000 +0300 ++++ netgen-4.5_new/libsrc/general/profiler.cpp 2010-11-25 10:11:30.000000000 +0300 +@@ -34,8 +34,14 @@ + { + StopTimer (total_timer); + +- ofstream prof ("netgen.prof"); +- Print (prof); ++ char* env; ++ if ((env = getenv("NETGEN_PROF")) && !strcmp(env, "1")) { ++ ofstream prof ("netgen.prof"); ++ Print (prof); ++ } ++ else if ((env = getenv("NETGEN_PROF")) && !strcmp(env, "0")) { ++ Print (std::cout); ++ } + } + + +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/geom2d/genmesh2d.cpp netgen-4.5_new/libsrc/geom2d/genmesh2d.cpp +--- netgen-4.5_orig/libsrc/geom2d/genmesh2d.cpp 2006-02-16 19:17:47.000000000 +0300 ++++ netgen-4.5_new/libsrc/geom2d/genmesh2d.cpp 2010-11-25 10:11:30.000000000 +0300 +@@ -121,11 +121,11 @@ + + int hsteps = mp.optsteps2d; + +- mp.optimize2d = "smcm"; ++ mp.optimize2d = (char*)"smcm"; + mp.optsteps2d = hsteps/2; + Optimize2d (*mesh, mp); + +- mp.optimize2d = "Smcm"; ++ mp.optimize2d = (char*)"Smcm"; + mp.optsteps2d = (hsteps+1)/2; + Optimize2d (*mesh, mp); + +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/gprim/geom2d.hpp netgen-4.5_new/libsrc/gprim/geom2d.hpp +--- netgen-4.5_orig/libsrc/gprim/geom2d.hpp 2004-01-20 14:49:44.000000000 +0300 ++++ netgen-4.5_new/libsrc/gprim/geom2d.hpp 2010-11-25 10:11:30.000000000 +0300 +@@ -53,7 +53,7 @@ + int IsOnLongLine (const Line2d & l, const Point2d & p); + int Hit (const Line2d & l1, const Line2d & l2, double heps = EPSGEOM); + ostream & operator<<(ostream & s, const Line2d & l); +-Point2d CrossPoint (const PLine2d & l1, const PLine2d & l2); ++Point2d CrossPoint (const Line2d & l1, const Line2d & l2); + int Parallel (const PLine2d & l1, const PLine2d & l2, double peps = EPSGEOM); + int IsOnLine (const PLine2d & l, const Point2d & p, double heps = EPSGEOM); + int IsOnLongLine (const PLine2d & l, const Point2d & p); +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/gprim/geom3d.hpp netgen-4.5_new/libsrc/gprim/geom3d.hpp +--- netgen-4.5_orig/libsrc/gprim/geom3d.hpp 2004-08-30 16:04:04.000000000 +0400 ++++ netgen-4.5_new/libsrc/gprim/geom3d.hpp 2010-11-25 10:11:30.000000000 +0300 +@@ -25,6 +25,7 @@ + inline Point3d Center (const Point3d & p1, const Point3d & p2, const Point3d & p3); + inline Point3d Center (const Point3d & p1, const Point3d & p2, + const Point3d & p3, const Point3d & p4); ++inline double Dist2 (const Point3d & p1, const Point3d & p2); + ostream & operator<<(ostream & s, const Point3d & p); + inline Vec3d operator- (const Vec3d & p1, const Vec3d & v); + inline Vec3d operator+ (const Vec3d & p1, const Vec3d & v); +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/include/mystdlib.h netgen-4.5_new/libsrc/include/mystdlib.h +--- netgen-4.5_orig/libsrc/include/mystdlib.h 2006-01-16 17:16:56.000000000 +0300 ++++ netgen-4.5_new/libsrc/include/mystdlib.h 2010-11-25 10:11:30.000000000 +0300 +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + #endif + + +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/interface/Makefile netgen-4.5_new/libsrc/interface/Makefile +--- netgen-4.5_orig/libsrc/interface/Makefile 2005-08-09 18:14:59.000000000 +0400 ++++ netgen-4.5_new/libsrc/interface/Makefile 2010-11-25 10:11:30.000000000 +0300 @@ -1,4 +1,5 @@ -src = nginterface.cpp writeuser.cpp writediffpack.cpp writeabaqus.cpp writefluent.cpp writepermas.cpp writetochnog.cpp writetecplot.cpp wuchemnitz.cpp writetochnog.cpp writefeap.cpp writeelmer.cpp writegmsh.cpp writejcm.cpp readuser.cpp importsolution.cpp +#src = nginterface.cpp writeuser.cpp writediffpack.cpp writeabaqus.cpp writefluent.cpp writepermas.cpp writetochnog.cpp writetecplot.cpp wuchemnitz.cpp writetochnog.cpp writefeap.cpp writeelmer.cpp writegmsh.cpp writejcm.cpp readuser.cpp importsolution.cpp @@ -37,9 +192,9 @@ diff -Naur netgen-4.5.old/libsrc/interface/Makefile netgen-4.5.new/libsrc/interf # lib = nginterface libpath = libsrc/interface -diff -Naur netgen-4.5.old/libsrc/interface/nglib.cpp netgen-4.5.new/libsrc/interface/nglib.cpp ---- netgen-4.5.old/libsrc/interface/nglib.cpp 2005-10-18 17:53:18.000000000 +0400 -+++ netgen-4.5.new/libsrc/interface/nglib.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/interface/nglib.cpp netgen-4.5_new/libsrc/interface/nglib.cpp +--- netgen-4.5_orig/libsrc/interface/nglib.cpp 2005-10-18 17:53:18.000000000 +0400 ++++ netgen-4.5_new/libsrc/interface/nglib.cpp 2010-11-25 10:11:30.000000000 +0300 @@ -56,7 +56,8 @@ void Ng_Exit () @@ -50,9 +205,33 @@ diff -Naur netgen-4.5.old/libsrc/interface/nglib.cpp netgen-4.5.new/libsrc/inter } -diff -Naur netgen-4.5.old/libsrc/makefile.inc netgen-4.5.new/libsrc/makefile.inc ---- netgen-4.5.old/libsrc/makefile.inc 2005-09-02 17:17:51.000000000 +0400 -+++ netgen-4.5.new/libsrc/makefile.inc 2008-02-12 14:59:55.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/interface/writeuser.cpp netgen-4.5_new/libsrc/interface/writeuser.cpp +--- netgen-4.5_orig/libsrc/interface/writeuser.cpp 2005-08-09 18:14:59.000000000 +0400 ++++ netgen-4.5_new/libsrc/interface/writeuser.cpp 2010-11-25 10:11:30.000000000 +0300 +@@ -17,7 +17,7 @@ + + void RegisterUserFormats (ARRAY & names) + { +- char *types[] = ++ const char *types[] = + { + "Neutral Format", + "Surface Mesh Format" , +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/linalg/densemat.hpp netgen-4.5_new/libsrc/linalg/densemat.hpp +--- netgen-4.5_orig/libsrc/linalg/densemat.hpp 2005-12-09 15:26:19.000000000 +0300 ++++ netgen-4.5_new/libsrc/linalg/densemat.hpp 2010-11-25 10:11:30.000000000 +0300 +@@ -14,6 +14,8 @@ + + #include + ++class DenseMatrix; ++void CalcAtA (const DenseMatrix & a, DenseMatrix & m2); + + class DenseMatrix + { +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/makefile.inc netgen-4.5_new/libsrc/makefile.inc +--- netgen-4.5_orig/libsrc/makefile.inc 2005-09-02 17:17:51.000000000 +0400 ++++ netgen-4.5_new/libsrc/makefile.inc 2010-11-25 10:11:30.000000000 +0300 @@ -8,17 +8,14 @@ LIBSRC_DIR=$(CPP_DIR)/libsrc LIB_DIR=$(CPP_DIR)/lib/$(MACHINE) @@ -76,9 +255,9 @@ diff -Naur netgen-4.5.old/libsrc/makefile.inc netgen-4.5.new/libsrc/makefile.inc # ARFLAGS = r # -diff -Naur netgen-4.5.old/libsrc/makefile.mach.LINUX netgen-4.5.new/libsrc/makefile.mach.LINUX ---- netgen-4.5.old/libsrc/makefile.mach.LINUX 2004-10-11 23:49:26.000000000 +0400 -+++ netgen-4.5.new/libsrc/makefile.mach.LINUX 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/makefile.mach.LINUX netgen-4.5_new/libsrc/makefile.mach.LINUX +--- netgen-4.5_orig/libsrc/makefile.mach.LINUX 2004-10-11 23:49:26.000000000 +0400 ++++ netgen-4.5_new/libsrc/makefile.mach.LINUX 2010-11-25 10:11:30.000000000 +0300 @@ -16,7 +16,7 @@ # CFLAGS2 = @@ -88,29 +267,9 @@ diff -Naur netgen-4.5.old/libsrc/makefile.mach.LINUX netgen-4.5.new/libsrc/makef -ftemplate-depth-99 -finline-limit=10000 \ -Wdisabled-optimization -funroll-loops -DnoNGSOLVE -diff -Naur netgen-4.5.old/libsrc/meshing/meshtype.cpp netgen-4.5.new/libsrc/meshing/meshtype.cpp ---- netgen-4.5.old/libsrc/meshing/meshtype.cpp 2006-02-10 13:11:08.000000000 +0300 -+++ netgen-4.5.new/libsrc/meshing/meshtype.cpp 2008-03-14 13:19:53.000000000 +0300 -@@ -1,4 +1,5 @@ - #include -+#include - - #include "meshing.hpp" - -@@ -774,7 +775,7 @@ - frob /= 2; - - double det = trans.Det(); -- if (det <= 0) -+ if (det <= DBL_MIN) - err += 1e12; - else - err += frob * frob / det; - - -diff -Naur netgen-4.5.old/libsrc/meshing/improve2.cpp netgen-4.5.new/libsrc/meshing/improve2.cpp ---- netgen-4.5.old/libsrc/meshing/improve2.cpp 2006-01-11 19:08:19.000000000 +0300 -+++ netgen-4.5.new/libsrc/meshing/improve2.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/meshing/improve2.cpp netgen-4.5_new/libsrc/meshing/improve2.cpp +--- netgen-4.5_orig/libsrc/meshing/improve2.cpp 2006-01-11 19:08:19.000000000 +0300 ++++ netgen-4.5_new/libsrc/meshing/improve2.cpp 2010-11-25 10:11:30.000000000 +0300 @@ -4,7 +4,7 @@ #include @@ -120,9 +279,9 @@ diff -Naur netgen-4.5.old/libsrc/meshing/improve2.cpp netgen-4.5.new/libsrc/mesh #endif namespace netgen -diff -Naur netgen-4.5.old/libsrc/meshing/improve2.hpp netgen-4.5.new/libsrc/meshing/improve2.hpp ---- netgen-4.5.old/libsrc/meshing/improve2.hpp 2004-10-12 23:22:55.000000000 +0400 -+++ netgen-4.5.new/libsrc/meshing/improve2.hpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/meshing/improve2.hpp netgen-4.5_new/libsrc/meshing/improve2.hpp +--- netgen-4.5_orig/libsrc/meshing/improve2.hpp 2004-10-12 23:22:55.000000000 +0400 ++++ netgen-4.5_new/libsrc/meshing/improve2.hpp 2010-11-25 10:11:30.000000000 +0300 @@ -32,17 +32,16 @@ /// virtual void SelectSurfaceOfPoint (const Point3d & p, @@ -149,9 +308,51 @@ diff -Naur netgen-4.5.old/libsrc/meshing/improve2.hpp netgen-4.5.new/libsrc/mesh /// virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const; -diff -Naur netgen-4.5.old/libsrc/meshing/smoothing2.cpp netgen-4.5.new/libsrc/meshing/smoothing2.cpp ---- netgen-4.5.old/libsrc/meshing/smoothing2.cpp 2006-01-11 19:08:20.000000000 +0300 -+++ netgen-4.5.new/libsrc/meshing/smoothing2.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/meshing/meshtype.cpp netgen-4.5_new/libsrc/meshing/meshtype.cpp +--- netgen-4.5_orig/libsrc/meshing/meshtype.cpp 2006-02-10 13:11:08.000000000 +0300 ++++ netgen-4.5_new/libsrc/meshing/meshtype.cpp 2010-11-25 10:11:30.000000000 +0300 +@@ -1,4 +1,5 @@ + #include ++#include + + #include "meshing.hpp" + +@@ -774,7 +775,7 @@ + frob /= 2; + + double det = trans.Det(); +- if (det <= 0) ++ if (det <= DBL_MIN) + err += 1e12; + else + err += frob * frob / det; +@@ -2222,9 +2223,9 @@ + + MeshingParameters :: MeshingParameters () + { +- optimize3d = "cmdmstm"; ++ optimize3d = (char*)"cmdmstm"; + optsteps3d = 3; +- optimize2d = "smsmsmSmSmSm"; ++ optimize2d = (char*)"smsmsmSmSmSm"; + optsteps2d = 3; + opterrpow = 2; + blockfill = 1; +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/meshing/meshtype.hpp netgen-4.5_new/libsrc/meshing/meshtype.hpp +--- netgen-4.5_orig/libsrc/meshing/meshtype.hpp 2006-02-10 13:11:08.000000000 +0300 ++++ netgen-4.5_new/libsrc/meshing/meshtype.hpp 2010-11-25 10:11:30.000000000 +0300 +@@ -13,7 +13,7 @@ + Classes for NETGEN + */ + +- ++class Mesh; + enum ELEMENT_TYPE { + SEGMENT = 1, SEGMENT3 = 2, + TRIG = 10, QUAD=11, TRIG6 = 12, QUAD6 = 13, QUAD8 = 14, +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/meshing/smoothing2.cpp netgen-4.5_new/libsrc/meshing/smoothing2.cpp +--- netgen-4.5_orig/libsrc/meshing/smoothing2.cpp 2006-01-11 19:08:20.000000000 +0300 ++++ netgen-4.5_new/libsrc/meshing/smoothing2.cpp 2010-11-25 10:11:30.000000000 +0300 @@ -300,7 +300,7 @@ double Opti2SurfaceMinFunction :: FuncGrad (const Vector & x, Vector & grad) const @@ -270,9 +471,119 @@ diff -Naur netgen-4.5.old/libsrc/meshing/smoothing2.cpp netgen-4.5.new/libsrc/me if (moveisok) { for (j = 0; j < locelements.Size(); j++) -diff -Naur netgen-4.5.old/libsrc/occ/occconstruction.cpp netgen-4.5.new/libsrc/occ/occconstruction.cpp ---- netgen-4.5.old/libsrc/occ/occconstruction.cpp 2005-12-06 18:15:53.000000000 +0300 -+++ netgen-4.5.new/libsrc/occ/occconstruction.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/Partition_Inter2d.cxx netgen-4.5_new/libsrc/occ/Partition_Inter2d.cxx +--- netgen-4.5_orig/libsrc/occ/Partition_Inter2d.cxx 2005-06-09 18:51:10.000000000 +0400 ++++ netgen-4.5_new/libsrc/occ/Partition_Inter2d.cxx 2010-11-25 10:11:31.000000000 +0300 +@@ -29,10 +29,10 @@ + // $Header$ + + //using namespace std; +-#include "Partition_Inter2d.ixx" +- + #include "utilities.h" + ++#include "Partition_Inter2d.ixx" ++ + #include + #include + #include +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/Partition_Inter3d.cxx netgen-4.5_new/libsrc/occ/Partition_Inter3d.cxx +--- netgen-4.5_orig/libsrc/occ/Partition_Inter3d.cxx 2005-06-09 18:51:10.000000000 +0400 ++++ netgen-4.5_new/libsrc/occ/Partition_Inter3d.cxx 2010-11-25 10:11:31.000000000 +0300 +@@ -29,13 +29,17 @@ + // $Header$ + + //using namespace std; ++ ++#include "utilities.h" ++ + #include "Partition_Inter2d.hxx" + #include "Partition_Inter3d.ixx" +-#include "utilities.h" + + #include + #include + #include ++//using namespace std; ++ + #include + #include + #include +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/Partition_Loop.cxx netgen-4.5_new/libsrc/occ/Partition_Loop.cxx +--- netgen-4.5_orig/libsrc/occ/Partition_Loop.cxx 2005-06-09 18:51:10.000000000 +0400 ++++ netgen-4.5_new/libsrc/occ/Partition_Loop.cxx 2010-11-25 10:11:31.000000000 +0300 +@@ -29,12 +29,14 @@ + // $Header$ + + //using namespace std; +-#include + +-#include "Partition_Loop.ixx" + + #include "utilities.h" + ++#include ++ ++#include "Partition_Loop.ixx" ++ + #include + #include + #include +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/Partition_Loop2d.cxx netgen-4.5_new/libsrc/occ/Partition_Loop2d.cxx +--- netgen-4.5_orig/libsrc/occ/Partition_Loop2d.cxx 2005-06-09 18:51:10.000000000 +0400 ++++ netgen-4.5_new/libsrc/occ/Partition_Loop2d.cxx 2010-11-25 10:11:31.000000000 +0300 +@@ -12,9 +12,11 @@ + // $Header$ + + //using namespace std; +-#include "Partition_Loop2d.ixx" ++ + + #include "utilities.h" ++ ++#include "Partition_Loop2d.ixx" + #include + + #include +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/Partition_Loop3d.cxx netgen-4.5_new/libsrc/occ/Partition_Loop3d.cxx +--- netgen-4.5_orig/libsrc/occ/Partition_Loop3d.cxx 2005-06-09 18:51:10.000000000 +0400 ++++ netgen-4.5_new/libsrc/occ/Partition_Loop3d.cxx 2010-11-25 10:11:31.000000000 +0300 +@@ -10,6 +10,11 @@ + // Module : GEOM + + //using namespace std; ++ ++ ++ ++#include "utilities.h" ++ + #include "Partition_Loop3d.ixx" + + #include +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/Partition_Spliter.cxx netgen-4.5_new/libsrc/occ/Partition_Spliter.cxx +--- netgen-4.5_orig/libsrc/occ/Partition_Spliter.cxx 2005-07-11 10:33:27.000000000 +0400 ++++ netgen-4.5_new/libsrc/occ/Partition_Spliter.cxx 2010-11-25 10:11:31.000000000 +0300 +@@ -29,14 +29,15 @@ + // $Header$ + + //using namespace std; ++ ++#include "utilities.h" ++ + #include "Partition_Inter2d.hxx" + #include "Partition_Inter3d.hxx" + #include "Partition_Loop2d.hxx" + #include "Partition_Loop3d.hxx" + #include "Partition_Spliter.ixx" + +-#include "utilities.h" +- + #include + #include + #include +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/occconstruction.cpp netgen-4.5_new/libsrc/occ/occconstruction.cpp +--- netgen-4.5_orig/libsrc/occ/occconstruction.cpp 2005-12-06 18:15:53.000000000 +0300 ++++ netgen-4.5_new/libsrc/occ/occconstruction.cpp 2010-11-25 10:11:30.000000000 +0300 @@ -28,8 +28,8 @@ #include #include @@ -284,9 +595,9 @@ diff -Naur netgen-4.5.old/libsrc/occ/occconstruction.cpp netgen-4.5.new/libsrc/o #include #include namespace netgen -diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/occgenmesh.cpp ---- netgen-4.5.old/libsrc/occ/occgenmesh.cpp 2006-02-07 13:12:48.000000000 +0300 -+++ netgen-4.5.new/libsrc/occ/occgenmesh.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/occgenmesh.cpp netgen-4.5_new/libsrc/occ/occgenmesh.cpp +--- netgen-4.5_orig/libsrc/occ/occgenmesh.cpp 2006-02-07 13:12:48.000000000 +0300 ++++ netgen-4.5_new/libsrc/occ/occgenmesh.cpp 2010-11-25 10:11:30.000000000 +0300 @@ -28,7 +28,7 @@ return Point<3> (p.X(), p.Y(), p.Z()); } @@ -296,7 +607,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc ARRAY & ps, ARRAY & params, Mesh & mesh) -@@ -49,23 +49,19 @@ +@@ -49,23 +49,18 @@ hvalue[0] = 0; pnt = c->Value(s0); @@ -309,11 +620,12 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc { oldpnt = pnt; pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0)); -+ double dist = pnt.Distance(oldpnt); - hvalue[i] = hvalue[i-1] + - 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))* +- hvalue[i] = hvalue[i-1] + +- 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))* - pnt.Distance(oldpnt); -+ dist; ++ double dist = pnt.Distance(oldpnt); ++ hvalue[i] = hvalue[i-1] + min( 1.0, ++ 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*dist); //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl; @@ -324,7 +636,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc } // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS])); -@@ -74,7 +70,7 @@ +@@ -74,13 +69,16 @@ ps.SetSize(nsubedges-1); params.SetSize(nsubedges+1); @@ -333,7 +645,17 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc int i1 = 0; do { -@@ -112,7 +108,7 @@ + if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i) + { +- params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0); ++ // EAP. For nsubedges comparable to DIVIDEEDGESECTIONS (issue 0021073) ++ double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]); ++ params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0); ++ //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0); + pnt = c->Value(params[i]); + ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z())); + i++; +@@ -112,7 +110,7 @@ static void FindEdges (OCCGeometry & geom, Mesh & mesh) { @@ -342,7 +664,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc multithread.task = "Edge meshing"; (*testout) << "edge meshing" << endl; -@@ -124,6 +120,7 @@ +@@ -124,6 +122,7 @@ (*testout) << "nedges = " << nedges << endl; double eps = 1e-6 * geom.GetBoundingBox().Diam(); @@ -350,7 +672,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc for (int i = 1; i <= nvertices; i++) { -@@ -133,7 +130,7 @@ +@@ -133,7 +132,7 @@ bool exists = 0; if (merge_solids) for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++) @@ -359,7 +681,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc { exists = 1; break; -@@ -163,6 +160,7 @@ +@@ -163,6 +162,7 @@ { TopoDS_Face face = TopoDS::Face(exp1.Current()); int facenr = geom.fmap.FindIndex(face); @@ -367,7 +689,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc if (face2solid[0][facenr-1] == 0) face2solid[0][facenr-1] = solidnr; -@@ -184,6 +182,9 @@ +@@ -184,6 +184,9 @@ int facenr = 0; int edgenr = 0; @@ -377,7 +699,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc (*testout) << "faces = " << geom.fmap.Extent() << endl; int curr = 0; -@@ -232,6 +233,11 @@ +@@ -232,6 +235,11 @@ continue; } @@ -389,7 +711,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) == geom.vmap.FindIndex(TopExp::LastVertex (edge))) { -@@ -276,8 +282,8 @@ +@@ -276,8 +284,8 @@ pnums.Last() = -1; for (PointIndex pi = 1; pi < first_ep; pi++) { @@ -400,7 +722,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc } } -@@ -287,7 +293,7 @@ +@@ -287,7 +295,7 @@ bool exists = 0; int j; for (j = first_ep; j <= mesh.GetNP(); j++) @@ -409,7 +731,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc { exists = 1; break; -@@ -394,7 +400,7 @@ +@@ -394,7 +402,7 @@ int i, j, k; int changed; @@ -418,7 +740,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc multithread.task = "Surface meshing"; geom.facemeshstatus = 0; -@@ -751,7 +760,7 @@ +@@ -751,7 +759,7 @@ multithread.task = savetask; } @@ -427,7 +749,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc { double hret; kappa *= mparam.curvaturesafety; -@@ -779,7 +788,7 @@ +@@ -779,7 +787,7 @@ double nq = n*q; Point<3> p = p0 + 0.5*n; @@ -436,7 +758,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc if (lambda >= 0 && lambda <= 1) { -@@ -799,55 +808,55 @@ +@@ -799,55 +807,55 @@ @@ -512,7 +834,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc //(*testout) << "curvature " << curvature << endl; -@@ -886,51 +895,47 @@ +@@ -886,51 +894,47 @@ pm1.SetX(0.5*(par0.X()+par2.X())); pm1.SetY(0.5*(par0.Y()+par2.Y())); pm2.SetX(0.5*(par1.X()+par0.X())); pm2.SetY(0.5*(par1.Y()+par0.Y())); @@ -579,7 +901,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; */ } -@@ -970,7 +975,7 @@ +@@ -970,7 +974,7 @@ if (mparam.uselocalh) { @@ -588,7 +910,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc multithread.percent = 0; mesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading); -@@ -1075,7 +1080,6 @@ +@@ -1075,7 +1079,6 @@ if (triangulation.IsNull()) continue; BRepAdaptor_Surface sf(face, Standard_True); @@ -596,7 +918,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc int ntriangles = triangulation -> NbTriangles(); for (int j = 1; j <= ntriangles; j++) -@@ -1096,7 +1100,7 @@ +@@ -1096,7 +1099,7 @@ maxside = max (maxside, p[1].Distance(p[2])); //cout << "\rFace " << i << " pos11 ntriangles " << ntriangles << " maxside " << maxside << flush; @@ -605,9 +927,9 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/oc //cout << "\rFace " << i << " pos12 ntriangles " << ntriangles << flush; } } -diff -Naur netgen-4.5.old/libsrc/occ/occgeom.cpp netgen-4.5.new/libsrc/occ/occgeom.cpp ---- netgen-4.5.old/libsrc/occ/occgeom.cpp 2006-01-25 16:35:50.000000000 +0300 -+++ netgen-4.5.new/libsrc/occ/occgeom.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/occgeom.cpp netgen-4.5_new/libsrc/occ/occgeom.cpp +--- netgen-4.5_orig/libsrc/occ/occgeom.cpp 2006-01-25 16:35:50.000000000 +0300 ++++ netgen-4.5_new/libsrc/occ/occgeom.cpp 2010-11-25 10:11:31.000000000 +0300 @@ -7,6 +7,8 @@ #include "ShapeAnalysis_ShapeContents.hxx" #include "ShapeAnalysis_CheckSmallFace.hxx" @@ -650,7 +972,7 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgeom.cpp netgen-4.5.new/libsrc/occ/occge BRepTools::Clean (shape); //WriteOCC_STL("test.stl"); - BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar.occdeflection, true); -+ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar_occdeflection, true); ++ BRepMesh_IncrementalMesh (shape, vispar_occdeflection, true); cout << "done" << endl; @@ -784,9 +1106,29 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgeom.cpp netgen-4.5.new/libsrc/occ/occge return true; } -diff -Naur netgen-4.5.old/libsrc/occ/occgeom.hpp netgen-4.5.new/libsrc/occ/occgeom.hpp ---- netgen-4.5.old/libsrc/occ/occgeom.hpp 2006-01-25 16:35:50.000000000 +0300 -+++ netgen-4.5.new/libsrc/occ/occgeom.hpp 2008-02-12 14:57:01.000000000 +0300 +@@ -1190,16 +1189,16 @@ + return occgeo; + } + +- char * shapesname[] = ++ const char * shapesname[] = + {" ", "CompSolids", "Solids", "Shells", + + "Faces", "Wires", "Edges", "Vertices"}; + +- char * shapename[] = ++ const char * shapename[] = + {" ", "CompSolid", "Solid", "Shell", + "Face", "Wire", "Edge", "Vertex"}; + +- char * orientationstring[] = ++ const char * orientationstring[] = + {"+", "-"}; + + void OCCGeometry :: RecursiveTopologyTree (const TopoDS_Shape & sh, +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/occgeom.hpp netgen-4.5_new/libsrc/occ/occgeom.hpp +--- netgen-4.5_orig/libsrc/occ/occgeom.hpp 2006-01-25 16:35:50.000000000 +0300 ++++ netgen-4.5_new/libsrc/occ/occgeom.hpp 2010-11-25 10:11:31.000000000 +0300 @@ -15,8 +15,6 @@ #include "Geom_Curve.hxx" #include "Geom2d_Curve.hxx" @@ -863,9 +1205,9 @@ diff -Naur netgen-4.5.old/libsrc/occ/occgeom.hpp netgen-4.5.new/libsrc/occ/occge OCCSurface GetSurface (int surfi) { cout << "OCCGeometry::GetSurface using PLANESPACE" << endl; -diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.cpp netgen-4.5.new/libsrc/occ/occmeshsurf.cpp ---- netgen-4.5.old/libsrc/occ/occmeshsurf.cpp 2006-01-25 16:36:26.000000000 +0300 -+++ netgen-4.5.new/libsrc/occ/occmeshsurf.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/occmeshsurf.cpp netgen-4.5_new/libsrc/occ/occmeshsurf.cpp +--- netgen-4.5_orig/libsrc/occ/occmeshsurf.cpp 2006-01-25 16:36:26.000000000 +0300 ++++ netgen-4.5_new/libsrc/occ/occmeshsurf.cpp 2010-11-25 10:11:31.000000000 +0300 @@ -5,6 +5,8 @@ #include #include @@ -981,9 +1323,9 @@ diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.cpp netgen-4.5.new/libsrc/occ/o -diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.hpp netgen-4.5.new/libsrc/occ/occmeshsurf.hpp ---- netgen-4.5.old/libsrc/occ/occmeshsurf.hpp 2005-06-09 18:51:10.000000000 +0400 -+++ netgen-4.5.new/libsrc/occ/occmeshsurf.hpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/occmeshsurf.hpp netgen-4.5_new/libsrc/occ/occmeshsurf.hpp +--- netgen-4.5_orig/libsrc/occ/occmeshsurf.hpp 2005-06-09 18:51:10.000000000 +0400 ++++ netgen-4.5_new/libsrc/occ/occmeshsurf.hpp 2010-11-25 10:11:31.000000000 +0300 @@ -151,7 +151,7 @@ MeshOptimize2dOCCSurfaces (const OCCGeometry & ageometry); @@ -1003,9 +1345,20 @@ diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.hpp netgen-4.5.new/libsrc/occ/o }; -diff -Naur netgen-4.5.old/libsrc/stlgeom/meshstlsurface.cpp netgen-4.5.new/libsrc/stlgeom/meshstlsurface.cpp ---- netgen-4.5.old/libsrc/stlgeom/meshstlsurface.cpp 2006-01-11 19:08:20.000000000 +0300 -+++ netgen-4.5.new/libsrc/stlgeom/meshstlsurface.cpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/occ/utilities.h netgen-4.5_new/libsrc/occ/utilities.h +--- netgen-4.5_orig/libsrc/occ/utilities.h 2005-02-11 14:35:43.000000000 +0300 ++++ netgen-4.5_new/libsrc/occ/utilities.h 2010-11-25 10:11:31.000000000 +0300 +@@ -33,6 +33,7 @@ + + #include + #include ++#include + #include + // #include "SALOME_Log.hxx" + +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.cpp netgen-4.5_new/libsrc/stlgeom/meshstlsurface.cpp +--- netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.cpp 2006-01-11 19:08:20.000000000 +0300 ++++ netgen-4.5_new/libsrc/stlgeom/meshstlsurface.cpp 2010-11-25 10:11:31.000000000 +0300 @@ -946,20 +946,23 @@ } @@ -1054,9 +1407,9 @@ diff -Naur netgen-4.5.old/libsrc/stlgeom/meshstlsurface.cpp netgen-4.5.new/libsr void MeshOptimizeSTLSurface :: GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const { n = geom.GetChartNormalVector(); -diff -Naur netgen-4.5.old/libsrc/stlgeom/meshstlsurface.hpp netgen-4.5.new/libsrc/stlgeom/meshstlsurface.hpp ---- netgen-4.5.old/libsrc/stlgeom/meshstlsurface.hpp 2004-09-30 17:13:56.000000000 +0400 -+++ netgen-4.5.new/libsrc/stlgeom/meshstlsurface.hpp 2008-02-12 14:57:01.000000000 +0300 +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.hpp netgen-4.5_new/libsrc/stlgeom/meshstlsurface.hpp +--- netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.hpp 2004-09-30 17:13:56.000000000 +0400 ++++ netgen-4.5_new/libsrc/stlgeom/meshstlsurface.hpp 2010-11-25 10:11:31.000000000 +0300 @@ -79,12 +79,10 @@ virtual void SelectSurfaceOfPoint (const Point3d & p, const PointGeomInfo & gi); @@ -1071,14 +1424,48 @@ diff -Naur netgen-4.5.old/libsrc/stlgeom/meshstlsurface.hpp netgen-4.5.new/libsr virtual void GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const; }; -diff -Naur netgen-4.5.old/makeForSalome.sh netgen-4.5.new/makeForSalome.sh ---- netgen-4.5.old/makeForSalome.sh 1970-01-01 03:00:00.000000000 +0300 -+++ netgen-4.5.new/makeForSalome.sh 2008-02-12 14:57:01.000000000 +0300 -@@ -0,0 +1,31 @@ +diff -Naur --exclude=CVS netgen-4.5_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.5_new/libsrc/stlgeom/stlgeommesh.cpp +--- netgen-4.5_orig/libsrc/stlgeom/stlgeommesh.cpp 2004-08-10 03:39:45.000000000 +0400 ++++ netgen-4.5_new/libsrc/stlgeom/stlgeommesh.cpp 2010-11-25 10:11:31.000000000 +0300 +@@ -1437,7 +1437,7 @@ + + if (!optstring || strlen(optstring) == 0) + { +- mparam.optimize2d = "smcm"; ++ mparam.optimize2d = (char*)"smcm"; + } + else + { +@@ -1453,7 +1453,7 @@ + mparam.grading); + mesh -> LoadLocalMeshSize (mparam.meshsizefilename); + mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac); +- mparam.optimize2d = "cmsmSm"; ++ mparam.optimize2d = (char*)"cmsmSm"; + STLSurfaceOptimization (*stlgeometry, *mesh, mparam); + #ifdef STAT_STREAM + (*statout) << GetTime() << " & "; +@@ -1559,7 +1559,7 @@ + + if (!optstring || strlen(optstring) == 0) + { +- mparam.optimize3d = "cmdmstm"; ++ mparam.optimize3d = (char*)"cmdmstm"; + } + else + { +diff -Naur --exclude=CVS netgen-4.5_orig/makeForSalome.sh netgen-4.5_new/makeForSalome.sh +--- netgen-4.5_orig/makeForSalome.sh 1970-01-01 03:00:00.000000000 +0300 ++++ netgen-4.5_new/makeForSalome.sh 2010-11-25 10:11:31.000000000 +0300 +@@ -0,0 +1,35 @@ +#! /bin/sh +cp ngtcltk/ngnewdelete.* libsrc/interface/ + -+MACHINE=LINUX ++if test `uname -m` = "x86_64" ; then ++ MACHINE=LINUX64 ++else ++ MACHINE=LINUX ++fi +export MACHINE +make -C libsrc/csg +make -C libsrc/general @@ -1102,128 +1489,7 @@ diff -Naur netgen-4.5.old/makeForSalome.sh netgen-4.5.new/makeForSalome.sh +fi + +cp libsrc/interface/nglib.h libsrc/general/*.hpp libsrc/csg/*.hpp libsrc/geom2d/*.hpp \ -+ libsrc/gprim/*.hpp libsrc/linalg/*.hpp libsrc/meshing/*.hpp \ -+ libsrc/occ/*.hpp libsrc/opti/*.hpp libsrc/include/mydefs.hpp \ -+ libsrc/stlgeom/*.hpp libsrc/include/mystdlib.h \ -+ install/include -diff -Naur netgen-4.5.old/libsrc/occ/Partition_Inter2d.cxx netgen-4.5.new/libsrc/occ/Partition_Inter2d.cxx ---- netgen-4.5.old/libsrc/occ/Partition_Inter2d.cxx 2005-06-09 18:51:10.000000000 +0400 -+++ netgen-4.5.new/libsrc/occ/Partition_Inter2d.cxx 2008-02-26 12:34:14.000000000 +0300 -@@ -29,10 +29,10 @@ - // $Header$ - - //using namespace std; --#include "Partition_Inter2d.ixx" -- - #include "utilities.h" - -+#include "Partition_Inter2d.ixx" -+ - #include - #include - #include -diff -Naur netgen-4.5.old/libsrc/occ/Partition_Inter3d.cxx netgen-4.5.new/libsrc/occ/Partition_Inter3d.cxx ---- netgen-4.5.old/libsrc/occ/Partition_Inter3d.cxx 2005-06-09 18:51:10.000000000 +0400 -+++ netgen-4.5.new/libsrc/occ/Partition_Inter3d.cxx 2008-02-26 12:36:27.000000000 +0300 -@@ -29,13 +29,17 @@ - // $Header$ - - //using namespace std; -+ -+#include "utilities.h" -+ - #include "Partition_Inter2d.hxx" - #include "Partition_Inter3d.ixx" --#include "utilities.h" - - #include - #include - #include -+//using namespace std; -+ - #include - #include - #include -diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop2d.cxx netgen-4.5.new/libsrc/occ/Partition_Loop2d.cxx ---- netgen-4.5.old/libsrc/occ/Partition_Loop2d.cxx 2005-06-09 18:51:10.000000000 +0400 -+++ netgen-4.5.new/libsrc/occ/Partition_Loop2d.cxx 2008-02-26 12:37:10.000000000 +0300 -@@ -12,9 +12,11 @@ - // $Header$ - - //using namespace std; --#include "Partition_Loop2d.ixx" -+ - - #include "utilities.h" -+ -+#include "Partition_Loop2d.ixx" - #include - - #include -diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop3d.cxx netgen-4.5.new/libsrc/occ/Partition_Loop3d.cxx ---- netgen-4.5.old/libsrc/occ/Partition_Loop3d.cxx 2005-06-09 18:51:10.000000000 +0400 -+++ netgen-4.5.new/libsrc/occ/Partition_Loop3d.cxx 2008-02-26 12:39:32.000000000 +0300 -@@ -10,6 +10,11 @@ - // Module : GEOM - - //using namespace std; -+ -+ -+ -+#include "utilities.h" -+ - #include "Partition_Loop3d.ixx" - - #include -diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop.cxx netgen-4.5.new/libsrc/occ/Partition_Loop.cxx ---- netgen-4.5.old/libsrc/occ/Partition_Loop.cxx 2005-06-09 18:51:10.000000000 +0400 -+++ netgen-4.5.new/libsrc/occ/Partition_Loop.cxx 2008-02-26 12:40:41.000000000 +0300 -@@ -29,12 +29,14 @@ - // $Header$ - - //using namespace std; --#include - --#include "Partition_Loop.ixx" - - #include "utilities.h" - -+#include -+ -+#include "Partition_Loop.ixx" -+ - #include - #include - #include -diff -Naur netgen-4.5.old/libsrc/occ/Partition_Spliter.cxx netgen-4.5.new/libsrc/occ/Partition_Spliter.cxx ---- netgen-4.5.old/libsrc/occ/Partition_Spliter.cxx 2005-07-11 10:33:27.000000000 +0400 -+++ netgen-4.5.new/libsrc/occ/Partition_Spliter.cxx 2008-02-26 12:41:32.000000000 +0300 -@@ -29,14 +29,15 @@ - // $Header$ - - //using namespace std; -+ -+#include "utilities.h" -+ - #include "Partition_Inter2d.hxx" - #include "Partition_Inter3d.hxx" - #include "Partition_Loop2d.hxx" - #include "Partition_Loop3d.hxx" - #include "Partition_Spliter.ixx" - --#include "utilities.h" -- - #include - #include - #include -diff -Naur netgen-4.5.old/libsrc/occ/utilities.h netgen-4.5.new/libsrc/occ/utilities.h ---- netgen-4.5.old/libsrc/occ/utilities.h 2005-02-11 14:35:43.000000000 +0300 -+++ netgen-4.5.new/libsrc/occ/utilities.h 2008-02-26 12:28:02.000000000 +0300 -@@ -33,6 +33,7 @@ - - #include - #include -+#include - #include - // #include "SALOME_Log.hxx" - ++ libsrc/gprim/*.hpp libsrc/linalg/*.hpp libsrc/meshing/*.hpp \ ++ libsrc/occ/*.hpp libsrc/opti/*.hpp libsrc/include/mydefs.hpp \ ++ libsrc/stlgeom/*.hpp libsrc/include/mystdlib.h \ ++ install/include diff --git a/src/NETGEN/netgen49ForSalome.patch b/src/NETGEN/netgen49ForSalome.patch new file mode 100644 index 0000000..0be0d34 --- /dev/null +++ b/src/NETGEN/netgen49ForSalome.patch @@ -0,0 +1,1014 @@ +diff -Naur netgen-4.9.13_orig/libsrc/meshing/meshtype.cpp netgen-4.9.13_new/libsrc/meshing/meshtype.cpp +--- netgen-4.9.13_orig/libsrc/meshing/meshtype.cpp 2009-09-13 14:28:38.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/meshing/meshtype.cpp 2011-12-20 14:50:26.000000000 +0400 +@@ -1,4 +1,5 @@ + #include ++#include // to get DBL_MIN defined + + #include "meshing.hpp" + +@@ -650,7 +651,8 @@ + + double det = trans.Det(); + +- if (det <= 0) ++ // if (det <= 0) ++ if (det <= DBL_MIN) // avoid FPE + err += 1e12; + else + err += frob * frob / det; +@@ -706,7 +708,8 @@ + + double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1); + +- if (det <= 0) ++ // if (det <= 0) ++ if (det <= DBL_MIN) // avoid FPE + { + dd = 0; + return 1e12; +@@ -790,7 +793,8 @@ + = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0) + + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0); + +- if (det <= 0) ++ // if (det <= 0) ++ if (det <= DBL_MIN) // avoid FPE + err += 1e12; + else + { +@@ -840,7 +844,8 @@ + frob /= 2; + + double det = trans.Det(); +- if (det <= 0) ++ //if (det <= 0) ++ if (det <= DBL_MIN) // avoid FPE + err += 1e12; + else + err += frob * frob / det; +@@ -1857,7 +1862,8 @@ + case PYRAMID: + { + double noz = 1-p(2); +- if (noz == 0.0) noz = 1e-10; ++ //if (noz == 0.0) noz = 1e-10; ++ if (noz <= DBL_MIN) noz = 1e-10; // avoid FPE + + double xi = p(0) / noz; + double eta = p(1) / noz; +@@ -2035,7 +2041,8 @@ + + double det = -trans.Det(); + +- if (det <= 0) ++ //if (det <= 0) ++ if (det <= DBL_MIN) // avoid FPE + err += 1e12; + else + err += frob * frob * frob / det; +@@ -2107,7 +2114,8 @@ + ddet *= -1; + + +- if (det <= 0) ++ //if (det <= 0) ++ if (det <= DBL_MIN) // avoid FPE + err += 1e12; + else + { +@@ -2189,7 +2197,7 @@ + + det *= -1; + +- if (det <= 0) ++ if (det <= DBL_MIN) + err += 1e12; + else + { +@@ -2522,10 +2530,10 @@ + + MeshingParameters :: MeshingParameters () + { +- optimize3d = "cmdmustm"; ++ optimize3d = (char*)"cmdmustm"; // optimize3d = "cmdmustm"; + //optimize3d = "cmdmstm"; + optsteps3d = 3; +- optimize2d = "smsmsmSmSmSm"; ++ optimize2d = (char*)"smsmsmSmSmSm"; // optimize2d = "smsmsmSmSmSm"; + optsteps2d = 3; + opterrpow = 2; + blockfill = 1; +diff -Naur netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp netgen-4.9.13_new/libsrc/meshing/meshtype.hpp +--- netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp 2009-11-09 13:50:43.000000000 +0300 ++++ netgen-4.9.13_new/libsrc/meshing/meshtype.hpp 2011-12-20 14:50:26.000000000 +0400 +@@ -12,6 +12,7 @@ + Classes for NETGEN + */ + ++class Mesh; // added due to compilation errors on some platforms + + enum ELEMENT_TYPE { + SEGMENT = 1, SEGMENT3 = 2, +diff -Naur netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp +--- netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp 2009-11-09 13:47:09.000000000 +0300 ++++ netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp 2011-12-20 14:50:26.000000000 +0400 +@@ -302,7 +302,8 @@ + vgrad = 0; + badness = 0; + +- meshthis -> GetNormalVector (surfi, sp1, gi1, n); ++ //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n); ++ n = normal; + pp1 = sp1 + x(0) * t1 + x(1) * t2; + + // meshthis -> ProjectPoint (surfi, pp1); +@@ -360,7 +361,8 @@ + vgrad = 0; + badness = 0; + +- meshthis -> GetNormalVector (surfi, sp1, gi1, n); ++ //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n); ++ n = normal; + + pp1 = sp1 + x(0) * t1 + x(1) * t2; + +@@ -514,7 +516,8 @@ + vgrad = 0; + badness = 0; + +- meshthis -> GetNormalVector (surfi, sp1, gi1, n); ++ //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n); ++ n = normal; + + pp1 = sp1 + x(0) * t1 + x(1) * t2; + +@@ -586,7 +589,8 @@ + vgrad = 0; + badness = 0; + +- meshthis -> GetNormalVector (surfi, sp1, gi1, n); ++ //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n); ++ n = normal; + + // pp1 = sp1; + // pp1.Add2 (x.Get(1), t1, x.Get(2), t2); +@@ -973,7 +977,7 @@ + { + mesh[pi] = Point<3> (origp); + } +- ++ break; // exit as is not used anymore + } + } + +diff -Naur netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp netgen-4.9.13_new/libsrc/occ/occconstruction.cpp +--- netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp 2009-08-24 06:32:47.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/occ/occconstruction.cpp 2011-12-20 14:50:26.000000000 +0400 +@@ -28,7 +28,7 @@ + #include + #include + #include +-#include ++//#include + //#include + #include + #include +diff -Naur netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp +--- netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp 2010-03-16 09:30:07.000000000 +0300 ++++ netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp 2011-12-20 14:50:26.000000000 +0400 +@@ -15,6 +15,8 @@ + + #define DIVIDEEDGESECTIONS 1000 + #define IGNORECURVELENGTH 1e-4 ++// a small value used to avoid FPE ++#define VSMALL 1e-10 + + + bool merge_solids = 1; +@@ -26,7 +28,8 @@ + double nq = n*q; + + Point<3> p = p0 + 0.5*n; +- double lambda = (p-l.p0)*n / nq; ++ // double lambda = (p-l.p0)*n / nq; -- avoid FPE ++ double lambda = (fabs(nq) > 1e-10) ? (p-l.p0)*n / nq : -1; + + if (lambda >= 0 && lambda <= 1) + { +@@ -54,6 +57,8 @@ + + + ++ ++ static // useless out of this file + double ComputeH (double kappa) + { + double hret; +@@ -62,7 +67,8 @@ + if (mparam.maxh * kappa < 1) + hret = mparam.maxh; + else +- hret = 1 / kappa; ++ // hret = 1 / kappa; -- avoid FPE ++ hret = 1 / (kappa + VSMALL); + + if (mparam.maxh < hret) + hret = mparam.maxh; +@@ -71,8 +77,7 @@ + } + + +- +- ++ static // useless out of this file + void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2, + BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0) + { +@@ -168,8 +173,8 @@ + if(h < 1e-4*maxside) + return; + +- +- if (h > 30) return; ++ // commented to restrict H on a large sphere for example ++ //if (h > 30) return; + } + + if (h < maxside && depth < 10) +@@ -228,6 +233,7 @@ + + + ++ static // useless out of this file + void DivideEdge (TopoDS_Edge & edge, Array & ps, + Array & params, Mesh & mesh) + { +@@ -247,8 +253,8 @@ + hvalue[0] = 0; + pnt = c->Value(s0); + +- double olddist = 0; +- double dist = 0; ++ //double olddist = 0; -- useless variables ++ //double dist = 0; + + int tmpVal = (int)(DIVIDEEDGESECTIONS); + +@@ -256,15 +262,19 @@ + { + oldpnt = pnt; + pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0)); ++ // -- no more than 1 segment per /DIVIDEEDGESECTIONS + hvalue[i] = hvalue[i-1] + +- 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))* +- pnt.Distance(oldpnt); ++ // 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))* ++ // pnt.Distance(oldpnt); ++ min( 1.0, ++ 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))* ++ pnt.Distance(oldpnt)); + + //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) + // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl; + +- olddist = dist; +- dist = pnt.Distance(oldpnt); ++ //olddist = dist; -- useless variables ++ //dist = pnt.Distance(oldpnt); + } + + // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS])); +@@ -279,7 +289,10 @@ + { + if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i) + { +- params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0); ++ // -- for nsubedges comparable to DIVIDEEDGESECTIONS ++ //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0); ++ double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]); ++ params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0); + pnt = c->Value(params[i]); + ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z())); + i++; +@@ -323,6 +336,7 @@ + (*testout) << "nedges = " << nedges << endl; + + double eps = 1e-6 * geom.GetBoundingBox().Diam(); ++ const double eps2 = eps * eps; // -- small optimization + + for (int i = 1; i <= nvertices; i++) + { +@@ -332,7 +346,8 @@ + bool exists = 0; + if (merge_solids) + for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++) +- if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps) ++ //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps) ++ if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization + { + exists = 1; + break; +@@ -362,6 +377,7 @@ + { + TopoDS_Face face = TopoDS::Face(exp1.Current()); + int facenr = geom.fmap.FindIndex(face); ++ if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes + + if (face2solid[0][facenr-1] == 0) + face2solid[0][facenr-1] = solidnr; +@@ -381,6 +397,7 @@ + int facenr = 0; + int edgenr = 0; + ++ edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes + + (*testout) << "faces = " << geom.fmap.Extent() << endl; + int curr = 0; +@@ -442,6 +459,7 @@ + //(*testout) << "ignoring degenerated edge" << endl; + continue; + } ++ if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes + + if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) == + geom.vmap.FindIndex(TopExp::LastVertex (edge))) +@@ -479,15 +497,64 @@ + } + else + { +- Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge))); +- Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge))); ++ TopoDS_Iterator vIt( edge, false ); ++ TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next(); ++ TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() ); ++ if ( v1.Orientation() == TopAbs_REVERSED ) ++ std::swap( v1, v2 ); ++ const bool isClosedEdge = v1.IsSame( v2 ); ++ ++ Point<3> fp = occ2ng (BRep_Tool::Pnt (v1)); ++ Point<3> lp = occ2ng (BRep_Tool::Pnt (v2)); ++ double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp )); ++ if ( isClosedEdge ) ++ tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 ); + + pnums[0] = -1; + pnums.Last() = -1; + for (PointIndex pi = 1; pi < first_ep; pi++) + { +- if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi; +- if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi; ++ if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi; ++ if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi; ++ } ++ if (( isClosedEdge && pnums[0] != pnums.Last() ) || ++ ( !isClosedEdge && pnums[0] == pnums.Last() )) ++ pnums[0] = pnums.Last() = -1; ++ if ( pnums[0] == -1 || pnums.Last() == -1 ) ++ { ++ // take into account a possible large gap between a vertex and an edge curve ++ // end and a large vertex tolerance covering the whole edge ++ if ( pnums[0] == -1 ) ++ { ++ double tol = BRep_Tool::Tolerance( v1 ); ++ for (PointIndex pi = 1; pi < first_ep; pi++) ++ if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol) ++ pnums[0] = pi; ++ ++ if ( pnums[0] == -1 ) ++ pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 ); ++ } ++ if ( isClosedEdge ) ++ { ++ pnums.Last() = pnums[0]; ++ } ++ else ++ { ++ if ( pnums.Last() == -1 ) ++ { ++ double tol = BRep_Tool::Tolerance( v2 ); ++ for (PointIndex pi = 1; pi < first_ep; pi++) ++ if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol) ++ pnums.Last() = pi; ++ ++ if ( pnums.Last() == -1 ) ++ pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 ); ++ } ++ ++ if ( Dist2( fp, mesh[PointIndex(pnums[0])]) > ++ Dist2( lp, mesh[PointIndex(pnums.Last())])) ++ std::swap( pnums[0], pnums.Last() ); ++ } + } + } + +@@ -633,7 +700,8 @@ + } + + (*testout) << "mesh face " << k << endl; +- multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); ++ // multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE ++ multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL); + geom.facemeshstatus[k-1] = -1; + + +@@ -901,7 +969,8 @@ + // if (k != 36) continue; + + // (*testout) << "optimize face " << k << endl; +- multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); ++ //multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE ++ multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL); + + FaceDescriptor & fd = mesh.GetFaceDescriptor(k); + +@@ -1456,3 +1525,4 @@ + } + + #endif ++ +diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.cpp netgen-4.9.13_new/libsrc/occ/occgeom.cpp +--- netgen-4.9.13_orig/libsrc/occ/occgeom.cpp 2010-03-05 16:16:21.000000000 +0300 ++++ netgen-4.9.13_new/libsrc/occ/occgeom.cpp 2011-12-20 14:50:26.000000000 +0400 +@@ -8,6 +8,8 @@ + #include "ShapeAnalysis_CheckSmallFace.hxx" + #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx" + #include "ShapeAnalysis_Surface.hxx" ++#include // -- to optimize Project() and FastProject() ++#include + #include "BRepAlgoAPI_Fuse.hxx" + #include "BRepCheck_Analyzer.hxx" + #include "BRepLib.hxx" +@@ -16,10 +18,17 @@ + #include "ShapeFix_FixSmallFace.hxx" + #include "Partition_Spliter.hxx" + +- + namespace netgen + { +- void OCCGeometry :: PrintNrShapes () ++ // free data used to optimize Project() and FastProject() ++ OCCGeometry::~OCCGeometry() ++ { ++ NCollection_DataMap::Iterator it(fclsmap); ++ for (; it.More(); it.Next()) ++ delete it.Value(); ++ } ++ ++ void OCCGeometry :: PrintNrShapes () + { + TopExp_Explorer e; + int count = 0; +@@ -951,25 +960,58 @@ + } + + ++ // returns a projector and a classifier for the given surface ++ void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj, ++ BRepTopAdaptor_FClass2d*& cls) const ++ { ++ //MSV: organize caching projector in the map ++ if (fprjmap.IsBound(surfi)) ++ { ++ proj = fprjmap.Find(surfi); ++ cls = fclsmap.Find(surfi); ++ } ++ else ++ { ++ const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi)); ++ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); ++ proj = new ShapeAnalysis_Surface(aSurf); ++ fprjmap.Bind(surfi, proj); ++ cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion()); ++ fclsmap.Bind(surfi, cls); ++ } ++ } + +- +- void OCCGeometry :: Project (int surfi, Point<3> & p) const ++ // void OCCGeometry :: Project (int surfi, Point<3> & p) const ++ bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const + { + static int cnt = 0; + if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl; + + gp_Pnt pnt(p(0), p(1), p(2)); + +- double u,v; +- Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); +- Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf ); +- gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) ); +- suval.Coord( u, v); +- pnt = thesurf->Value( u, v ); +- +- ++ // -- Optimization: use cached projector and classifier ++ // double u,v; ++ // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); ++ // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf ); ++ // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) ); ++ // suval.Coord( u, v); ++ // pnt = thesurf->Value( u, v ); ++ ++ Handle(ShapeAnalysis_Surface) proj; ++ BRepTopAdaptor_FClass2d *cls; ++ GetFaceTools(surfi, proj, cls); ++ ++ gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion()); ++ if (cls->Perform(p2d) == TopAbs_OUT) ++ { ++ return false; ++ } ++ pnt = proj->Value(p2d); ++ p2d.Coord(u, v); ++ + p = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); + ++ return true; + } + + +@@ -979,54 +1021,69 @@ + { + gp_Pnt p(ap(0), ap(1), ap(2)); + +- Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); +- +- gp_Pnt x = surface->Value (u,v); +- +- if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true; +- +- gp_Vec du, dv; +- +- surface->D1(u,v,x,du,dv); +- +- int count = 0; +- +- gp_Pnt xold; +- gp_Vec n; +- double det, lambda, mu; +- +- do { +- count++; +- +- n = du^dv; +- +- det = Det3 (n.X(), du.X(), dv.X(), +- n.Y(), du.Y(), dv.Y(), +- n.Z(), du.Z(), dv.Z()); +- +- if (det < 1e-15) return false; +- +- lambda = Det3 (n.X(), p.X()-x.X(), dv.X(), +- n.Y(), p.Y()-x.Y(), dv.Y(), +- n.Z(), p.Z()-x.Z(), dv.Z())/det; +- +- mu = Det3 (n.X(), du.X(), p.X()-x.X(), +- n.Y(), du.Y(), p.Y()-x.Y(), +- n.Z(), du.Z(), p.Z()-x.Z())/det; +- +- u += lambda; +- v += mu; +- +- xold = x; +- surface->D1(u,v,x,du,dv); +- +- } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50); +- +- // (*testout) << "FastProject count: " << count << endl; +- +- if (count == 50) return false; +- +- ap = Point<3> (x.X(), x.Y(), x.Z()); ++ // -- Optimization: use cached projector and classifier ++ // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); ++ // ++ // gp_Pnt x = surface->Value (u,v); ++ // ++ // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true; ++ // ++ // gp_Vec du, dv; ++ // ++ // surface->D1(u,v,x,du,dv); ++ // ++ // int count = 0; ++ // ++ // gp_Pnt xold; ++ // gp_Vec n; ++ // double det, lambda, mu; ++ // ++ // do { ++ // count++; ++ // ++ // n = du^dv; ++ // ++ // det = Det3 (n.X(), du.X(), dv.X(), ++ // n.Y(), du.Y(), dv.Y(), ++ // n.Z(), du.Z(), dv.Z()); ++ // ++ // if (det < 1e-15) return false; ++ // ++ // lambda = Det3 (n.X(), p.X()-x.X(), dv.X(), ++ // n.Y(), p.Y()-x.Y(), dv.Y(), ++ // n.Z(), p.Z()-x.Z(), dv.Z())/det; ++ // ++ // mu = Det3 (n.X(), du.X(), p.X()-x.X(), ++ // n.Y(), du.Y(), p.Y()-x.Y(), ++ // n.Z(), du.Z(), p.Z()-x.Z())/det; ++ // ++ // u += lambda; ++ // v += mu; ++ // ++ // xold = x; ++ // surface->D1(u,v,x,du,dv); ++ // ++ // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50); ++ // ++ // // (*testout) << "FastProject count: " << count << endl; ++ // ++ // if (count == 50) return false; ++ // ++ // ap = Point<3> (x.X(), x.Y(), x.Z()); ++ Handle(ShapeAnalysis_Surface) proj; ++ BRepTopAdaptor_FClass2d *cls; ++ GetFaceTools(surfi, proj, cls); ++ ++ gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion()); ++ if (cls->Perform(p2d) == TopAbs_OUT) ++ { ++ //cout << "Projection fails" << endl; ++ return false; ++ } ++ ++ p = proj->Value(p2d); ++ p2d.Coord(u, v); ++ ap = Point<3> (p.X(), p.Y(), p.Z()); + + return true; + } +diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.hpp netgen-4.9.13_new/libsrc/occ/occgeom.hpp +--- netgen-4.9.13_orig/libsrc/occ/occgeom.hpp 2010-01-14 19:56:19.000000000 +0300 ++++ netgen-4.9.13_new/libsrc/occ/occgeom.hpp 2011-12-20 14:50:26.000000000 +0400 +@@ -15,8 +15,8 @@ + #include "Geom_Curve.hxx" + #include "Geom2d_Curve.hxx" + #include "Geom_Surface.hxx" +-#include "GeomAPI_ProjectPointOnSurf.hxx" +-#include "GeomAPI_ProjectPointOnCurve.hxx" ++// #include "GeomAPI_ProjectPointOnSurf.hxx" ++// #include "GeomAPI_ProjectPointOnCurve.hxx" + #include "BRepTools.hxx" + #include "TopExp.hxx" + #include "BRepBuilderAPI_MakeVertex.hxx" +@@ -42,8 +42,8 @@ + #include "Geom_Curve.hxx" + #include "Geom2d_Curve.hxx" + #include "Geom_Surface.hxx" +-#include "GeomAPI_ProjectPointOnSurf.hxx" +-#include "GeomAPI_ProjectPointOnCurve.hxx" ++// #include "GeomAPI_ProjectPointOnSurf.hxx" ++// #include "GeomAPI_ProjectPointOnCurve.hxx" + #include "TopoDS_Wire.hxx" + #include "BRepTools_WireExplorer.hxx" + #include "BRepTools.hxx" +@@ -68,7 +68,7 @@ + #include "IGESToBRep_Reader.hxx" + #include "Interface_Static.hxx" + #include "GeomAPI_ExtremaCurveCurve.hxx" +-#include "Standard_ErrorHandler.hxx" ++//#include "Standard_ErrorHandler.hxx" + #include "Standard_Failure.hxx" + #include "ShapeUpgrade_ShellSewing.hxx" + #include "ShapeFix_Shape.hxx" +@@ -80,6 +80,10 @@ + #include "ShapeAnalysis.hxx" + #include "ShapeBuild_ReShape.hxx" + ++// -- Optimization: to use cached projector and classifier ++#include ++class Handle_ShapeAnalysis_Surface; ++class BRepTopAdaptor_FClass2d; + + // Philippose - 29/01/2009 + // OpenCascade XDE Support +@@ -190,6 +194,9 @@ + class OCCGeometry : public NetgenGeometry + { + Point<3> center; ++ // -- Optimization: to use cached projector and classifier ++ mutable NCollection_DataMap fprjmap; ++ mutable NCollection_DataMap fclsmap; + + public: + TopoDS_Shape shape; +@@ -241,6 +248,8 @@ + vmap.Clear(); + } + ++ ~OCCGeometry(); // -- to free cached projector and classifier ++ + void BuildFMap(); + + Box<3> GetBoundingBox() +@@ -260,9 +269,14 @@ + Point<3> Center() + { return center;} + +- void Project (int surfi, Point<3> & p) const; ++ // void Project (int surfi, Point<3> & p) const; -- optimization ++ bool Project (int surfi, Point<3> & p, double& u, double& v) const; + bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const; + ++ // -- Optimization: to use cached projector and classifier ++ void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj, ++ BRepTopAdaptor_FClass2d*& cls) const; ++ + OCCSurface GetSurface (int surfi) + { + cout << "OCCGeometry::GetSurface using PLANESPACE" << endl; +diff -Naur netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp +--- netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp 2009-08-24 06:32:47.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp 2011-12-20 14:50:26.000000000 +0400 +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include // -- moved here from occgeom.hpp + + + namespace netgen +@@ -434,23 +435,33 @@ + + void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const + { +- geometry.Project (surfind, p); ++ // geometry.Project (surfind, p); -- signature of Project() changed for optimization ++ double u, v; ++ geometry.Project (surfind, p, u, v); + } + + + int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const + { +- double u = gi.u; +- double v = gi.v; ++ //double u = gi.u; ++ //double v = gi.v; + + Point<3> hp = p; +- if (geometry.FastProject (surfind, hp, u, v)) +- { +- p = hp; +- return 1; +- } +- ProjectPoint (surfind, p); +- return CalcPointGeomInfo (surfind, gi, p); ++ // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo() ++ // if (geometry.FastProject (surfind, hp, u, v)) ++ // { ++ // p = hp; ++ // return 1; ++ // } ++ // ProjectPoint (surfind, p); ++ // return CalcPointGeomInfo (surfind, gi, p); ++ bool ok; ++ if (gi.trignum > 0) ++ ok = geometry.FastProject (surfind, hp, gi.u, gi.v); ++ else ++ ok = geometry.Project (surfind, hp, gi.u, gi.v); ++ p = hp; ++ return ok; + } + + +@@ -680,7 +691,8 @@ + if (!geometry.FastProject (surfi, hnewp, u, v)) + { + // cout << "Fast projection to surface fails! Using OCC projection" << endl; +- geometry.Project (surfi, hnewp); ++ // geometry.Project (surfi, hnewp); -- Project() changed for optimization ++ geometry.Project (surfi, hnewp, u, v); + } + + newgi.trignum = 1; +@@ -689,7 +701,7 @@ + } + + newp = hnewp; +- } ++ }//; -- to compile with -Wall -pedantic + + + void OCCRefinementSurfaces :: +@@ -708,14 +720,18 @@ + hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); + newp = hnewp; + newgi = ap1; +- }; ++ } + + + void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) + { + if (surfi > 0) +- geometry.Project (surfi, p); +- }; ++ // geometry.Project (surfi, p); -- Project() changed for optimization ++ { ++ double u, v; ++ geometry.Project (surfi, p, u, v); ++ } ++ }//; -- to compile with -Wall -pedantic + + void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) + { +@@ -723,9 +739,10 @@ + if (!geometry.FastProject (surfi, p, gi.u, gi.v)) + { + cout << "Fast projection to surface fails! Using OCC projection" << endl; +- geometry.Project (surfi, p); ++ double u, v; ++ geometry.Project (surfi, p, u, v); + } +- }; ++ } + + + +diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx +--- netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx 2009-08-24 06:12:24.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx 2011-12-20 14:50:26.000000000 +0400 +@@ -86,6 +86,9 @@ + #include + #include + #include ++ ++#include ++ + #include + + //======================================================================= +@@ -243,7 +246,12 @@ + Standard_Integer i, nbExt = anExtPS.NbExt(); + Extrema_POnSurf aPOnSurf; + for (i = 1; i <= nbExt; ++i ) ++#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400 ++// porting to OCCT6.5.1 ++ if (anExtPS.SquareDistance( i ) <= TolE * TolE) { ++#else + if (anExtPS.Value( i ) <= TolE) { ++#endif + aPOnSurf = anExtPS.Point( i ); + break; + } +diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx +--- netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx 2009-08-24 06:12:24.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx 2011-12-20 14:53:39.000000000 +0400 +@@ -22,7 +22,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -51,6 +50,15 @@ + #include + #include + ++#include ++ ++#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400 ++// porting to OCCT6.5.1 ++#include ++#else ++#include ++#endif ++ + //======================================================================= + //function : Partition_Loop2d + //purpose : +@@ -209,7 +217,7 @@ + Cc->D1(uc, PC, CTg1); + if (!isForward) CTg1.Reverse(); + +- Standard_Real anglemin = 3 * PI, tolAng = 1.e-8; ++ Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8; + + // select an edge whose first derivative is most left of CTg1 + // ie an angle between Tg1 and CTg1 is least +@@ -233,7 +241,7 @@ + // -PI < angle < PI + Standard_Real angle = Tg1.Angle(CTg1); + +- if (PI - Abs(angle) <= tolAng) ++ if (M_PI - Abs(angle) <= tolAng) + { + // an angle is too close to PI; assure that an angle sign really + // reflects an edge position: +PI - an edge is worst, +@@ -519,7 +527,12 @@ + DC.Initialize( DegEdge, F ); + + // avoid intersecting twice the same edge ++#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400 ++// porting to OCCT6.5.1 ++ TopTools_DataMapOfShapeReal EUMap ( EdgesList.Extent() ); ++#else + BRepOffset_DataMapOfShapeReal EUMap ( EdgesList.Extent() ); ++#endif + + Standard_Real U, f, l; + BRep_Tool::Range (DegEdge, f, l); +diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx +--- netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx 2009-08-24 06:12:24.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx 2011-12-20 14:53:05.000000000 +0400 +@@ -178,7 +178,7 @@ + } + } + +- Standard_Real anglemax = - PI; ++ Standard_Real anglemax = - M_PI; + TopoDS_Edge SelectedEdge; + for ( itl.Initialize(LE); itl.More(); itl.Next()) { + const TopoDS_Edge& E = TopoDS::Edge(itl.Value()); +diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx +--- netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx 2009-08-24 06:12:24.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx 2011-12-20 14:50:26.000000000 +0400 +@@ -79,6 +79,8 @@ + #include + #include + ++#include ++ + #ifdef DEB + //# define PART_PERF + #endif +@@ -1169,7 +1171,12 @@ + for (; j<=nbj && ok; ++j) { + if (Extrema.IsMin(j)) { + hasMin = Standard_True; ++#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400 ++// porting to OCCT6.5.1 ++ ok = Extrema.SquareDistance(j) <= tol * tol; ++#else + ok = Extrema.Value(j) <= tol; ++#endif + } + } + } +diff -Naur netgen-4.9.13_orig/libsrc/occ/utilities.h netgen-4.9.13_new/libsrc/occ/utilities.h +--- netgen-4.9.13_orig/libsrc/occ/utilities.h 2009-08-24 06:12:24.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/occ/utilities.h 2011-12-20 14:50:26.000000000 +0400 +@@ -33,6 +33,7 @@ + + #include + #include ++#include + #include + // #include "SALOME_Log.hxx" + +diff -Naur netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp +--- netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp 2009-08-10 15:40:51.000000000 +0400 ++++ netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp 2011-12-20 14:50:26.000000000 +0400 +@@ -1435,7 +1435,8 @@ + + if (!optstring || strlen(optstring) == 0) + { +- mparam.optimize2d = "smcm"; ++ //mparam.optimize2d = (char*)"smcm"; ++ mparam.optimize2d = (char*)"smcm"; + } + else + { +@@ -1451,7 +1452,8 @@ + mparam.grading); + mesh -> LoadLocalMeshSize (mparam.meshsizefilename); + mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac); +- mparam.optimize2d = "cmsmSm"; ++ //mparam.optimize2d = (char*)"cmsmSm"; ++ mparam.optimize2d = (char*)"cmsmSm"; + STLSurfaceOptimization (*stlgeometry, *mesh, mparam); + #ifdef STAT_STREAM + (*statout) << GetTime() << " & "; +@@ -1557,7 +1559,8 @@ + + if (!optstring || strlen(optstring) == 0) + { +- mparam.optimize3d = "cmdmstm"; ++ //mparam.optimize3d = "cmdmstm"; ++ mparam.optimize3d = (char*)"cmdmstm"; + } + else + { +diff -Naur netgen-4.9.13_orig/nglib/nglib.h netgen-4.9.13_new/nglib/nglib.h +--- netgen-4.9.13_orig/nglib/nglib.h 2010-05-18 15:20:25.000000000 +0400 ++++ netgen-4.9.13_new/nglib/nglib.h 2011-12-20 14:50:26.000000000 +0400 +@@ -24,7 +24,7 @@ + // Philippose - 14.02.2009 + // Modifications for creating a DLL in Windows + #ifdef WIN32 +- #ifdef NGLIB_EXPORTS || nglib_EXPORTS ++ #if defined NGLIB_EXPORTS || defined nglib_EXPORTS + #define DLL_HEADER __declspec(dllexport) + #else + #define DLL_HEADER __declspec(dllimport) diff --git a/src/NETGEN/netgen_copy_include_for_salome b/src/NETGEN/netgen_copy_include_for_salome new file mode 100755 index 0000000..f54ade7 --- /dev/null +++ b/src/NETGEN/netgen_copy_include_for_salome @@ -0,0 +1,39 @@ +#!/bin/sh + +src_dir=$1 +install_dir=$2 + +if ! test -d $src_dir/libsrc ; then + echo "No dir $src_dir/libsrc ... Bye" + exit 1 +fi +if ! test -d $install_dir/share/netgen ; then + echo "No dir $install_dir/share/netgen ... Bye" + exit 1 +fi + +dest_dir=$install_dir/share/netgen/include +mkdir -p $dest_dir > /dev/null 2>&1 +cp -af $src_dir/libsrc/csg/*.hpp $dest_dir +cp -af $src_dir/libsrc/general/*.hpp $dest_dir +cp -af $src_dir/libsrc/geom2d/*.hpp $dest_dir +cp -af $src_dir/libsrc/gprim/*.hpp $dest_dir +cp -af $src_dir/libsrc/interface/*.hpp $dest_dir +cp -af $src_dir/libsrc/linalg/*.hpp $dest_dir +cp -af $src_dir/libsrc/meshing/*.hpp $dest_dir +cp -af $src_dir/libsrc/stlgeom/*.hpp $dest_dir +cp -af $src_dir/libsrc/visualization/*.hpp $dest_dir + +cp -af $src_dir/libsrc/occ/*.hpp $dest_dir +cp -af $src_dir/libsrc/occ/*.hxx $dest_dir +cp -af $src_dir/libsrc/occ/*.ixx $dest_dir +cp -af $src_dir/libsrc/occ/*.jxx $dest_dir +cp -af $src_dir/libsrc/occ/*.h $dest_dir + +cp -af $src_dir/libsrc/include/mystdlib.h $dest_dir +cp -af $src_dir/libsrc/include/mydefs.hpp $dest_dir +# cp -af $src_dir/libsrc/include/parallel.hpp $dest_dir + +rm -f $dest_dir/ngexception.hpp +rm -f $dest_dir/paralleltop.hpp +rm -f $dest_dir/soldata.hpp diff --git a/src/NETGENPlugin/Makefile.am b/src/NETGENPlugin/Makefile.am index de09762..a580ac9 100644 --- a/src/NETGENPlugin/Makefile.am +++ b/src/NETGENPlugin/Makefile.am @@ -1,24 +1,22 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE # -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. # -# This library is 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 @@ -41,6 +39,8 @@ salomeinclude_HEADERS = \ NETGENPlugin_Hypothesis_i.hxx \ NETGENPlugin_Hypothesis_2D.hxx \ NETGENPlugin_Hypothesis_2D_i.hxx \ + NETGENPlugin_Hypothesis_3D_i.hxx \ + NETGENPlugin_Hypothesis_2D_ONLY_i.hxx \ NETGENPlugin_SimpleHypothesis_2D.hxx \ NETGENPlugin_SimpleHypothesis_3D.hxx \ NETGENPlugin_SimpleHypothesis_2D_i.hxx \ @@ -64,6 +64,8 @@ dist_libNETGENEngine_la_SOURCES = \ NETGENPlugin_Hypothesis_i.cxx \ NETGENPlugin_Hypothesis_2D.cxx \ NETGENPlugin_Hypothesis_2D_i.cxx \ + NETGENPlugin_Hypothesis_3D_i.cxx \ + NETGENPlugin_Hypothesis_2D_ONLY_i.cxx \ NETGENPlugin_Mesher.cxx \ NETGENPlugin_SimpleHypothesis_2D.cxx \ NETGENPlugin_SimpleHypothesis_3D.cxx \ @@ -77,16 +79,28 @@ libNETGENEngine_la_CPPFLAGS = \ $(MED_CXXFLAGS) \ $(GEOM_CXXFLAGS) \ $(CAS_CPPFLAGS) \ + $(VTK_INCLUDES) \ $(NETGEN_INCLUDES) \ $(SMESH_CXXFLAGS) \ $(CORBA_CXXFLAGS) \ $(CORBA_INCLUDES) \ $(BOOST_CPPFLAGS) \ - -I$(top_builddir)/idl \ - -I$(top_builddir)/salome_adm/unix + -I$(top_builddir)/idl -libNETGENEngine_la_LDFLAGS = \ - ../NETGEN/libNETGEN.la \ +if ! NETGEN_NEW +libNETGENEngine_la_LDFLAGS = ../NETGEN/libNETGEN.la +else +libNETGENEngine_la_LDFLAGS = $(NETGEN_LIBS) +endif + +libNETGENEngine_la_LDFLAGS += \ ../../idl/libSalomeIDLNETGENPLUGIN.la \ - $(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine -lStdMeshersEngine \ - $(KERNEL_LDFLAGS) -lSalomeGenericObj + $(CAS_LDPATH) -lTKernel -lTKBRep -lTKShHealing -lTKSTEP -lTKXSBase -lTKIGES -lTKMesh -lTKSTL -lTKG3d -lTKTopAlgo -lTKG2d -lTKBool -lTKGeomAlgo -lTKOffset -lTKGeomBase -lTKBO \ + -lTKMath -lTKFillet -lTKMeshVS -lTKPrim -lTKSTEPBase -lTKSTEPAttr -lTKSTEP209 -lTKXDESTEP -lTKXDEIGES -lTKXCAF -lTKLCAF -lFWOSPlugin \ + $(GEOM_LDFLAGS) -lGEOMbasic \ + $(MED_LDFLAGS) -lSalomeIDLMED \ + $(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine -lSMESHUtils -lStdMeshersEngine -lStdMeshers -lSMESHDS -lSMDS -lSMESHControls \ + $(KERNEL_LDFLAGS) -lSalomeGenericObj -lSalomeNS -lSALOMELocalTrace -lOpUtil + +# Scripts to be installed. +dist_salomescript_DATA= NETGENPluginDC.py diff --git a/src/NETGENPlugin/NETGENPluginDC.py b/src/NETGENPlugin/NETGENPluginDC.py new file mode 100644 index 0000000..9568df6 --- /dev/null +++ b/src/NETGENPlugin/NETGENPluginDC.py @@ -0,0 +1,306 @@ +# 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 +# + +from smesh import Mesh_Algorithm, AssureGeomPublished, ParseParameters, IsEqual + +# import NETGENPlugin module if possible +noNETGENPlugin = 0 +try: + import NETGENPlugin +except ImportError: + noNETGENPlugin = 1 + pass + +# Types of algorithms +NETGEN_3D = "NETGEN_3D" +NETGEN_1D2D3D = "NETGEN_2D3D" +NETGEN_1D2D = "NETGEN_2D" +NETGEN_2D = "NETGEN_2D_ONLY" +NETGEN_FULL = NETGEN_1D2D3D +NETGEN = NETGEN_3D +FULL_NETGEN = NETGEN_FULL + +SOLE = 0 +SIMPLE = 1 + +# Fineness enumeration +VeryCoarse = 0 +Coarse = 1 +Moderate = 2 +Fine = 3 +VeryFine = 4 +Custom = 5 + +## Base of all NETGEN algorithms. +# +class NETGEN_Algorithm(Mesh_Algorithm): + + def __init__(self, mesh, geom=0): + Mesh_Algorithm.__init__(self) + if noNETGENPlugin: print "Warning: NETGENPlugin module unavailable" + self.Create(mesh, geom, self.algoType, "libNETGENEngine.so") + self.params = None + + ## Sets MaxSize + # + def SetMaxSize(self, theSize): + if self.Parameters(): + self.params.SetMaxSize(theSize) + + ## Sets MinSize + # + def SetMinSize(self, theSize): + if self.Parameters(): + self.params.SetMinSize(theSize) + + + ## Sets Optimize flag + # + def SetOptimize(self, theVal): + if self.Parameters(): + self.params.SetOptimize(theVal) + + ## Sets Fineness + # @param theFineness is: + # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom + # + def SetFineness(self, theFineness): + if self.Parameters(): + self.params.SetFineness(theFineness) + + ## Sets GrowthRate + # + def SetGrowthRate(self, theRate): + if self.Parameters(): + self.params.SetGrowthRate(theRate) + + ## Defines hypothesis having several parameters + # + def Parameters(self, which=SOLE): + if self.algoType == NETGEN_1D2D: + if which == SIMPLE: + hypType = "NETGEN_SimpleParameters_2D" + else: + hypType = "NETGEN_Parameters_2D" + elif self.algoType == NETGEN_1D2D3D: + if which == SIMPLE: + hypType = "NETGEN_SimpleParameters_3D" + else: + hypType = "NETGEN_Parameters" + elif self.algoType == NETGEN_2D: + hypType = "NETGEN_Parameters_2D_ONLY" + else: + hypType = "NETGEN_Parameters_3D" + + if self.params and self.params.GetName() != hypType: + self.mesh.RemoveHypothesis( self.params, self.geom ) + self.params = None + if not self.params: + self.params = self.Hypothesis(hypType, [],"libNETGENEngine.so",UseExisting=0) + + return self.params + + + +## Defines a tetrahedron 1D-2D-3D algorithm +# It is created by calling Mesh.Triangle( NETGEN_1D2D3D, geom=0 ) +# +class NETGEN_1D2D3D_Algorithm(NETGEN_Algorithm): + + meshMethod = "Tetrahedron" + algoType = NETGEN_1D2D3D + + ## Private constructor. + def __init__(self, mesh, geom=0): + NETGEN_Algorithm.__init__(self, mesh, geom) + + ## Sets SecondOrder flag + # + def SetSecondOrder(self, theVal): + if self.Parameters(): + self.params.SetSecondOrder(theVal) + + ## Sets NbSegPerEdge + # + def SetNbSegPerEdge(self, theVal): + if self.Parameters(): + self.params.SetNbSegPerEdge(theVal) + + ## Sets NbSegPerRadius + # + def SetNbSegPerRadius(self, theVal): + if self.Parameters(): + self.params.SetNbSegPerRadius(theVal) + + ## Sets QuadAllowed flag. + def SetQuadAllowed(self, toAllow=True): + if self.Parameters(): + self.params.SetQuadAllowed(toAllow) + + + ## Sets number of segments overriding the value set by SetLocalLength() + # + def SetNumberOfSegments(self, theVal): + self.Parameters(SIMPLE).SetNumberOfSegments(theVal) + + ## Sets number of segments overriding the value set by SetNumberOfSegments() + # + def SetLocalLength(self, theVal): + self.Parameters(SIMPLE).SetLocalLength(theVal) + + ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis. + # Overrides value set by LengthFromEdges() + def MaxElementArea(self, area): + self.Parameters(SIMPLE).SetMaxElementArea(area) + + ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis + # Overrides value set by MaxElementArea() + def LengthFromEdges(self): + self.Parameters(SIMPLE).LengthFromEdges() + + ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis + # Overrides value set by MaxElementVolume() + def LengthFromFaces(self): + self.Parameters(SIMPLE).LengthFromFaces() + + ## Defines "MaxElementVolume" parameter of NETGEN_SimpleParameters_3D hypothesis + # Overrides value set by LengthFromFaces() + def MaxElementVolume(self, vol): + self.Parameters(SIMPLE).SetMaxElementVolume(vol) + + +## Triangle NETGEN 1D-2D algorithm. +# It is created by calling Mesh.Triangle( NETGEN_1D2D, geom=0 ) +# +class NETGEN_1D2D_Algorithm(NETGEN_1D2D3D_Algorithm): + + meshMethod = "Triangle" + algoType = NETGEN_1D2D + + ## Private constructor. + def __init__(self, mesh, geom=0): + NETGEN_1D2D3D_Algorithm.__init__(self, mesh, geom) + + + +## Triangle NETGEN 2D algorithm +# It is created by calling Mesh.Triangle( NETGEN_2D, geom=0 ) +# +class NETGEN_2D_Only_Algorithm(NETGEN_Algorithm): + + meshMethod = "Triangle" + algoType = NETGEN_2D + + ## Private constructor. + def __init__(self, mesh, geom=0): + NETGEN_Algorithm.__init__(self, mesh, geom) + + ## Sets QuadAllowed flag. + def SetQuadAllowed(self, toAllow=True): + if self.Parameters(): + self.params.SetQuadAllowed(toAllow) + + ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle + # @param area for the maximum area of each triangle + # @param UseExisting if ==true - searches for an existing hypothesis created with the + # same parameters, else (default) - creates a new one + # + def MaxElementArea(self, area, UseExisting=0): + compFun = lambda hyp, args: IsEqual(hyp.GetMaxElementArea(), args[0]) + hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting, + CompareMethod=compFun) + hyp.SetMaxElementArea(area) + return hyp + + ## Defines "LengthFromEdges" hypothesis to build triangles + # based on the length of the edges taken from the wire + # + def LengthFromEdges(self): + hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp) + return hyp + + ## Sets QuadAllowed flag. + def SetQuadAllowed(self, toAllow=True): + if not self.params: + # use simple hyps + hasSimpleHyps = False + simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"] + for hyp in self.mesh.GetHypothesisList( self.geom ): + if hyp.GetName() in simpleHyps: + hasSimpleHyps = True + if hyp.GetName() == "QuadranglePreference": + if not toAllow: # remove QuadranglePreference + self.mesh.RemoveHypothesis( self.geom, hyp ) + else: + return hyp + return None + pass + pass + if hasSimpleHyps: + if toAllow: # add QuadranglePreference + return self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp) + return None + pass + self.Parameters().SetQuadAllowed( toAllow ) + return self.params + +## Defines a tetrahedron 3D algorithm +# It is created by calling Mesh.Tetrahedron() +# +class NETGEN_3D_Algorithm(NETGEN_Algorithm): + + meshMethod = "Tetrahedron" + algoType = NETGEN + isDefault = True + + ## Private constructor. + def __init__(self, mesh, geom=0): + NETGEN_Algorithm.__init__(self, mesh, geom) + + ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron + # @param vol for the maximum volume of each tetrahedron + # @param UseExisting if ==true - searches for the existing hypothesis created with + # the same parameters, else (default) - creates a new one + def MaxElementVolume(self, vol, UseExisting=0): + compFun = lambda hyp, args: IsEqual(hyp.GetMaxElementVolume(), args[0]) + hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting, + CompareMethod=compFun) + hyp.SetMaxElementVolume(vol) + return hyp + + +# Class just to create NETGEN_1D2D by calling Mesh.Triangle(NETGEN) +class NETGEN_1D2D_Algorithm_2(NETGEN_1D2D_Algorithm): + + algoType = NETGEN + + ## Private constructor. + def __init__(self, mesh, geom=0): + self.algoType = NETGEN_1D2D + NETGEN_1D2D_Algorithm.__init__(self,mesh, geom) + + +# Class just to create NETGEN_1D2D3D by calling Mesh.Netgen() +class NETGEN_1D2D3D_Algorithm_2(NETGEN_1D2D3D_Algorithm): + + meshMethod = "Netgen" + + ## Private constructor. + def __init__(self, mesh, geom=0): + NETGEN_1D2D3D_Algorithm.__init__(self,mesh, geom) diff --git a/src/NETGENPlugin/NETGENPlugin_Defs.hxx b/src/NETGENPlugin/NETGENPlugin_Defs.hxx index 2eb36ac..f1297ee 100755 --- a/src/NETGENPlugin/NETGENPlugin_Defs.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Defs.hxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 : NETGENPlugin_Defs.hxx // Author : Alexander A. BORODIN @@ -27,7 +28,7 @@ #define _NETGENPlugin_DEFS_HXX_ #ifdef WIN32 - #ifdef NETGENPLUGIN_EXPORTS + #if defined NETGENPLUGIN_EXPORTS || defined NETGENEngine_EXPORTS #define NETGENPLUGIN_EXPORT __declspec( dllexport ) #else #define NETGENPLUGIN_EXPORT __declspec( dllimport ) diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx index 75100b5..853e76c 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis.cxx @@ -1,31 +1,36 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis.cxx // Author : Michael Sazonov (OCN) // Date : 28/03/2006 // Project : SALOME // -#include +#include "NETGENPlugin_Hypothesis.hxx" + +#include "NETGENPlugin_Mesher.hxx" +#include "SMESH_Mesh.hxx" + #include using namespace std; @@ -39,15 +44,19 @@ NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen), _maxSize (GetDefaultMaxSize()), + _minSize (0), _growthRate (GetDefaultGrowthRate()), _nbSegPerEdge (GetDefaultNbSegPerEdge()), _nbSegPerRadius(GetDefaultNbSegPerRadius()), _fineness (GetDefaultFineness()), _secondOrder (GetDefaultSecondOrder()), - _optimize (GetDefaultOptimize()) + _optimize (GetDefaultOptimize()), + _localSize (GetDefaultLocalSize()), + _quadAllowed (GetDefaultQuadAllowed()) { _name = "NETGEN_Parameters"; _param_algo_dim = 3; + _localSize.clear(); } //============================================================================= @@ -64,6 +73,20 @@ void NETGENPlugin_Hypothesis::SetMaxSize(double theSize) } } +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::SetMinSize(double theSize) +{ + if (theSize != _minSize) + { + _minSize = theSize; + NotifySubMeshesHypothesisModification(); + } +} + //============================================================================= /*! * @@ -183,6 +206,69 @@ void NETGENPlugin_Hypothesis::SetNbSegPerRadius(double theVal) } } +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::SetLocalSizeOnEntry(const std::string& entry, double localSize) +{ + if(_localSize[entry] != localSize) + { + _localSize[entry] = localSize; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +double NETGENPlugin_Hypothesis::GetLocalSizeOnEntry(const std::string& entry) +{ + TLocalSize::iterator it = _localSize.find( entry ); + if ( it != _localSize.end() ) + return it->second; + else + return -1.0; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::UnsetLocalSizeOnEntry(const std::string& entry) +{ + _localSize.erase(entry); + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void NETGENPlugin_Hypothesis::SetQuadAllowed(bool theVal) +{ + if (theVal != _quadAllowed) + { + _quadAllowed = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool NETGENPlugin_Hypothesis::GetDefaultQuadAllowed() +{ + return false; +} + //============================================================================= /*! * @@ -197,6 +283,18 @@ ostream & NETGENPlugin_Hypothesis::SaveTo(ostream & save) save << " " << (int)_secondOrder << " " << (int)_optimize; + TLocalSize::iterator it_sm = _localSize.begin(); + if (it_sm != _localSize.end()) { + save << " " << "__LOCALSIZE_BEGIN__"; + for ( ; it_sm != _localSize.end(); ++it_sm ) { + save << " " << it_sm->first + << " " << it_sm->second << "%#"; // "%#" is a mark of value end + } + save << " " << "__LOCALSIZE_END__"; + } + save << " " << _minSize; + save << " " << _quadAllowed; + return save; } @@ -255,6 +353,38 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load) _optimize = (bool) is; else load.clear(ios::badbit | load.rdstate()); + + std::string option_or_sm; + bool hasLocalSize = false; + + isOK = (load >> option_or_sm); + if (isOK) + if (option_or_sm == "__LOCALSIZE_BEGIN__") + hasLocalSize = true; + + std::string smEntry, smValue; + while (isOK && hasLocalSize) { + isOK = (load >> smEntry); + if (isOK) { + if (smEntry == "__LOCALSIZE_END__") + break; + isOK = (load >> smValue); + } + if (isOK) { + std::istringstream tmp(smValue); + double val; + tmp >> val; + _localSize[ smEntry ] = val; + } + } + + if ( !hasLocalSize && !option_or_sm.empty() ) + _minSize = atof( option_or_sm.c_str() ); + + isOK = ( load >> _quadAllowed ); + if ( !isOK ) + _quadAllowed = GetDefaultQuadAllowed(); + return load; } @@ -301,10 +431,16 @@ bool NETGENPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, //================================================================================ bool NETGENPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, - const SMESH_Mesh* /*theMesh*/) + const SMESH_Mesh* theMesh) { _nbSegPerEdge = dflts._nbSegments; _maxSize = dflts._elemLength; + + if ( dflts._shape && !dflts._shape->IsNull() ) + _minSize = NETGENPlugin_Mesher::GetDefaultMinSize( *dflts._shape, _maxSize ); + else if ( theMesh && theMesh->HasShapeToMesh() ) + _minSize = NETGENPlugin_Mesher::GetDefaultMinSize( theMesh->GetShapeToMesh(), _maxSize ); + return _nbSegPerEdge && _maxSize > 0; } diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx index 3654f86..c96c8c8 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis.hxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis.hxx // Author : Michael Sazonov (OCN) @@ -33,6 +34,8 @@ #include "SMESH_Hypothesis.hxx" #include "Utils_SALOME_Exception.hxx" +#include + // Parameters for work of NETGEN // @@ -47,6 +50,9 @@ public: void SetMaxSize(double theSize); double GetMaxSize() const { return _maxSize; } + void SetMinSize(double theSize); + double GetMinSize() const { return _minSize; } + void SetSecondOrder(bool theVal); bool GetSecondOrder() const { return _secondOrder; } @@ -77,6 +83,16 @@ public: void SetNbSegPerRadius(double theVal); double GetNbSegPerRadius() const { return _nbSegPerRadius; } + typedef std::map TLocalSize; + static TLocalSize GetDefaultLocalSize() { return TLocalSize(); } + void SetLocalSizeOnEntry(const std::string& entry, double localSize); + double GetLocalSizeOnEntry(const std::string& entry); + const TLocalSize& GetLocalSizesAndEntries() const { return _localSize; } + void UnsetLocalSizeOnEntry(const std::string& entry); + + void SetQuadAllowed(bool theVal); + bool GetQuadAllowed() const { return _quadAllowed; } + // the default values (taken from NETGEN 4.5 sources) static double GetDefaultMaxSize(); @@ -86,6 +102,7 @@ public: static double GetDefaultNbSegPerRadius(); static bool GetDefaultSecondOrder(); static bool GetDefaultOptimize(); + static bool GetDefaultQuadAllowed(); // Persistence virtual ostream & SaveTo(ostream & save); @@ -108,13 +125,15 @@ public: virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); private: - double _maxSize; + double _maxSize, _minSize; double _growthRate; double _nbSegPerEdge; double _nbSegPerRadius; Fineness _fineness; bool _secondOrder; bool _optimize; + TLocalSize _localSize; + bool _quadAllowed; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cxx index eac7350..0a488ad 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.cxx @@ -1,33 +1,33 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis_2D.cxx // Author : Michael Sazonov (OCN) // Date : 28/03/2006 // Project : SALOME -// $Header$ //============================================================================= // -#include +#include "NETGENPlugin_Hypothesis_2D.hxx" #include using namespace std; diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.hxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.hxx index 07f1195..babfc87 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D.hxx @@ -1,30 +1,30 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis_2D.hxx // Author : Michael Sazonov (OCN) // Date : 27/03/2006 // Project : SALOME -// $Header$ //============================================================================= // #ifndef _NETGENPlugin_Hypothesis_2D_HXX_ diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_ONLY_i.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_ONLY_i.cxx new file mode 100644 index 0000000..b4152b4 --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_ONLY_i.cxx @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// NETGENPlugin : C++ implementation +// File : NETGENPlugin_Hypothesis_2D_ONLY_i.cxx +// Project : SALOME +//============================================================================= +// +#include "NETGENPlugin_Hypothesis_2D_ONLY_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +NETGENPlugin_Hypothesis_2D_ONLY_i:: +NETGENPlugin_Hypothesis_2D_ONLY_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + NETGENPlugin_Hypothesis_2D_i( thePOA, theStudyId, theGenImpl ) +{ + MESSAGE( "NETGENPlugin_Hypothesis_2D_ONLY_i::NETGENPlugin_Hypothesis_2D_ONLY_i" ); + myBaseImpl = new ::NETGENPlugin_Hypothesis_2D (theGenImpl->GetANewId(), + theStudyId, + theGenImpl); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= + +NETGENPlugin_Hypothesis_2D_ONLY_i::~NETGENPlugin_Hypothesis_2D_ONLY_i() +{ + MESSAGE( "NETGENPlugin_Hypothesis_2D_ONLY_i::~NETGENPlugin_Hypothesis_2D_ONLY_i" ); +} +//================================================================================ +/*! + * \brief Redefine hypothesis type + */ +//================================================================================ + +char* NETGENPlugin_Hypothesis_2D_ONLY_i::GetName() +{ + return CORBA::string_dup("NETGEN_Parameters_2D_ONLY"); +} diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_ONLY_i.hxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_ONLY_i.hxx new file mode 100644 index 0000000..616dbc9 --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_ONLY_i.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// NETGENPlugin : C++ implementation +// File : NETGENPlugin_Hypothesis_2D_ONLY_i.hxx +// Project : SALOME +//============================================================================= +// +#ifndef _NETGENPlugin_Hypothesis_2D_ONLY_i_HXX_ +#define _NETGENPlugin_Hypothesis_2D_ONLY_i_HXX_ + +#include "NETGENPlugin_Defs.hxx" + +#include +#include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm) + +#include "NETGENPlugin_Hypothesis_2D_i.hxx" + +class SMESH_Gen; + +// NETGENPlugin parameters hypothesis ("2D only" case) + +class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_2D_ONLY_i: + public virtual POA_NETGENPlugin::NETGENPlugin_Hypothesis_2D_ONLY, + public NETGENPlugin_Hypothesis_2D_i +{ + public: + // Constructor + NETGENPlugin_Hypothesis_2D_ONLY_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl); + // Destructor + virtual ~NETGENPlugin_Hypothesis_2D_ONLY_i(); + + char* GetName(); +}; + +#endif diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.cxx index cdb595c..86e5888 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.cxx @@ -1,30 +1,30 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis_2D_i.cxx // Author : Michael Sazonov (OCN) // Date : 03/04/2006 // Project : SALOME -// $Header$ //============================================================================= // #include "NETGENPlugin_Hypothesis_2D_i.hxx" @@ -78,13 +78,16 @@ NETGENPlugin_Hypothesis_2D_i::~NETGENPlugin_Hypothesis_2D_i() * Set QuadAllowed flag */ //============================================================================= -void NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed (CORBA::Boolean theValue) -{ - MESSAGE("NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed"); - ASSERT(myBaseImpl); - this->GetImpl()->SetQuadAllowed(theValue); - SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )"; -} +// void NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed (CORBA::Boolean theValue) +// { +// if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetQuadAllowed(), +// theValue, +// METH_SetQuadAllowed )) +// { +// this->GetImpl()->SetQuadAllowed(theValue); +// SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )"; +// } +// } //============================================================================= /*! @@ -93,12 +96,10 @@ void NETGENPlugin_Hypothesis_2D_i::SetQuadAllowed (CORBA::Boolean theValue) * Get QuadAllowed flag */ //============================================================================= -CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed() -{ - MESSAGE("NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed"); - ASSERT(myBaseImpl); - return this->GetImpl()->GetQuadAllowed(); -} +// CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed() +// { +// return this->GetImpl()->GetQuadAllowed(); +// } //============================================================================= /*! @@ -109,7 +110,6 @@ CORBA::Boolean NETGENPlugin_Hypothesis_2D_i::GetQuadAllowed() //============================================================================= ::NETGENPlugin_Hypothesis_2D* NETGENPlugin_Hypothesis_2D_i::GetImpl() { - MESSAGE("NETGENPlugin_Hypothesis_2D_i::GetImpl"); return (::NETGENPlugin_Hypothesis_2D*)myBaseImpl; } diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.hxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.hxx index 1a94bc6..e6d0c55 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_2D_i.hxx @@ -1,30 +1,30 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis_2D_i.hxx // Author : Michael Sazonov (OCN) // Date : 03/04/2006 // Project : SALOME -// $Header$ //============================================================================= // #ifndef _NETGENPlugin_Hypothesis_2D_i_HXX_ @@ -54,14 +54,20 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_2D_i: // Destructor virtual ~NETGENPlugin_Hypothesis_2D_i(); - void SetQuadAllowed(CORBA::Boolean theVal); - CORBA::Boolean GetQuadAllowed(); - // Get implementation ::NETGENPlugin_Hypothesis_2D* GetImpl(); // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + protected: + + // to remember whether a parameter is already set (issue 0021364) + // enum SettingMethod + // { + // METH_SetQuadAllowed = NETGENPlugin_Hypothesis_i::METH_LAST * 2, + // METH_LAST = METH_SetQuadAllowed + // }; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_3D_i.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_3D_i.cxx new file mode 100644 index 0000000..051d337 --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_3D_i.cxx @@ -0,0 +1,71 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// NETGENPlugin : C++ implementation +// File : NETGENPlugin_Hypothesis_3D_i.cxx +// Project : SALOME +//============================================================================= +// +#include "NETGENPlugin_Hypothesis_3D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +using namespace std; + +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +NETGENPlugin_Hypothesis_3D_i:: +NETGENPlugin_Hypothesis_3D_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + NETGENPlugin_Hypothesis_i( thePOA, theStudyId, theGenImpl ) +{ + MESSAGE( "NETGENPlugin_Hypothesis_3D_i::NETGENPlugin_Hypothesis_3D_i" ); +} + +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +NETGENPlugin_Hypothesis_3D_i::~NETGENPlugin_Hypothesis_3D_i() +{ + MESSAGE( "NETGENPlugin_Hypothesis_3D_i::~NETGENPlugin_Hypothesis_3D_i" ); +} + +//================================================================================ +/*! + * \brief Redefine hypothesis type + */ +//================================================================================ + +char* NETGENPlugin_Hypothesis_3D_i::GetName() +{ + return CORBA::string_dup("NETGEN_Parameters_3D"); +} diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_3D_i.hxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_3D_i.hxx new file mode 100644 index 0000000..0cb7b9f --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_3D_i.hxx @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// NETGENPlugin : C++ implementation +// File : NETGENPlugin_Hypothesis_2D_i.hxx +// Project : SALOME +//============================================================================= +// +#ifndef _NETGENPlugin_Hypothesis_3D_i_HXX_ +#define _NETGENPlugin_Hypothesis_3D_i_HXX_ + +#include "NETGENPlugin_Defs.hxx" + +#include +#include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm) + +#include "NETGENPlugin_Hypothesis_i.hxx" + +class SMESH_Gen; + +// NETGENPlugin parameters hypothesis (3D "only" case) + +class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_3D_i: + public virtual POA_NETGENPlugin::NETGENPlugin_Hypothesis_3D, + public NETGENPlugin_Hypothesis_i +{ + public: + // Constructor + NETGENPlugin_Hypothesis_3D_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl); + + // Get type name of hypothesis + char* GetName(); + + // Destructor + virtual ~NETGENPlugin_Hypothesis_3D_i(); +}; + +#endif diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx index f13e9db..17bdd35 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx @@ -1,41 +1,56 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis_i.cxx // Author : Michael Sazonov (OCN) // Date : 03/04/2006 // Project : SALOME -// $Header$ //============================================================================= // #include "NETGENPlugin_Hypothesis_i.hxx" #include "SMESH_Gen.hxx" #include "SMESH_PythonDump.hxx" +#include "GEOM_Object.hxx" #include "Utils_CorbaException.hxx" #include "utilities.h" using namespace std; +//============================================================================= +/*! + * Specialization of isToSetParameter for double + */ +//============================================================================= + +template<> +bool NETGENPlugin_Hypothesis_i::isToSetParameter(double curValue, + double newValue, + /*SettingMethod*/int meth) +{ + return isToSetParameter(true, (fabs(curValue - newValue) < 1e-20), meth); +} + //============================================================================= /*! * NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i @@ -48,7 +63,8 @@ NETGENPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA, int theStudyId, ::SMESH_Gen* theGenImpl) : SALOME::GenericObj_i( thePOA ), - SMESH_Hypothesis_i( thePOA ) + SMESH_Hypothesis_i( thePOA ), + mySetMethodFlags(0) { MESSAGE( "NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i" ); myBaseImpl = new ::NETGENPlugin_Hypothesis (theGenImpl->GetANewId(), @@ -77,10 +93,11 @@ NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i() //============================================================================= void NETGENPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue) { - MESSAGE("NETGENPlugin_Hypothesis_i::SetMaxSize"); - ASSERT(myBaseImpl); - this->GetImpl()->SetMaxSize(theValue); - SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theValue << " )"; + if ( isToSetParameter( GetMaxSize(), theValue, METH_SetMaxSize )) + { + this->GetImpl()->SetMaxSize(theValue); + SMESH::TPythonDump() << _this() << ".SetMaxSize( " << SMESH::TVar(theValue) << " )"; + } } //============================================================================= @@ -92,11 +109,37 @@ void NETGENPlugin_Hypothesis_i::SetMaxSize (CORBA::Double theValue) //============================================================================= CORBA::Double NETGENPlugin_Hypothesis_i::GetMaxSize() { - MESSAGE("NETGENPlugin_Hypothesis_i::GetMaxSize"); - ASSERT(myBaseImpl); return this->GetImpl()->GetMaxSize(); } +//============================================================================= +/*! + * NETGENPlugin_Hypothesis_i::SetMinSize + * + * Set MinSize + */ +//============================================================================= +void NETGENPlugin_Hypothesis_i::SetMinSize (CORBA::Double theValue) +{ + if ( isToSetParameter( GetMinSize(), theValue, METH_SetMinSize )) + { + this->GetImpl()->SetMinSize(theValue); + SMESH::TPythonDump() << _this() << ".SetMinSize( " << SMESH::TVar(theValue) << " )"; + } +} + +//============================================================================= +/*! + * NETGENPlugin_Hypothesis_i::GetMinSize + * + * Get MinSize + */ +//============================================================================= +CORBA::Double NETGENPlugin_Hypothesis_i::GetMinSize() +{ + return this->GetImpl()->GetMinSize(); +} + //============================================================================= /*! * NETGENPlugin_Hypothesis_i::SetSecondOrder @@ -106,10 +149,11 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetMaxSize() //============================================================================= void NETGENPlugin_Hypothesis_i::SetSecondOrder (CORBA::Boolean theValue) { - MESSAGE("NETGENPlugin_Hypothesis_i::SetSecondOrder"); - ASSERT(myBaseImpl); - this->GetImpl()->SetSecondOrder(theValue); - SMESH::TPythonDump() << _this() << ".SetSecondOrder( " << theValue << " )"; + if ( isToSetParameter( GetSecondOrder(), theValue, METH_SetSecondOrder )) + { + this->GetImpl()->SetSecondOrder(theValue); + SMESH::TPythonDump() << _this() << ".SetSecondOrder( " << theValue << " )"; + } } //============================================================================= @@ -121,8 +165,6 @@ void NETGENPlugin_Hypothesis_i::SetSecondOrder (CORBA::Boolean theValue) //============================================================================= CORBA::Boolean NETGENPlugin_Hypothesis_i::GetSecondOrder() { - MESSAGE("NETGENPlugin_Hypothesis_i::GetSecondOrder"); - ASSERT(myBaseImpl); return this->GetImpl()->GetSecondOrder(); } @@ -135,10 +177,11 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetSecondOrder() //============================================================================= void NETGENPlugin_Hypothesis_i::SetOptimize (CORBA::Boolean theValue) { - MESSAGE("NETGENPlugin_Hypothesis_i::SetOptimize"); - ASSERT(myBaseImpl); - this->GetImpl()->SetOptimize(theValue); - SMESH::TPythonDump() << _this() << ".SetOptimize( " << theValue << " )"; + if ( isToSetParameter( GetOptimize(), theValue, METH_SetOptimize )) + { + this->GetImpl()->SetOptimize(theValue); + SMESH::TPythonDump() << _this() << ".SetOptimize( " << theValue << " )"; + } } //============================================================================= @@ -150,8 +193,6 @@ void NETGENPlugin_Hypothesis_i::SetOptimize (CORBA::Boolean theValue) //============================================================================= CORBA::Boolean NETGENPlugin_Hypothesis_i::GetOptimize() { - MESSAGE("NETGENPlugin_Hypothesis_i::GetOptimize"); - ASSERT(myBaseImpl); return this->GetImpl()->GetOptimize(); } @@ -164,10 +205,11 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::GetOptimize() //============================================================================= void NETGENPlugin_Hypothesis_i::SetFineness (CORBA::Long theValue) { - MESSAGE("NETGENPlugin_Hypothesis_i::SetFineness"); - ASSERT(myBaseImpl); - this->GetImpl()->SetFineness((::NETGENPlugin_Hypothesis::Fineness)theValue); - SMESH::TPythonDump() << _this() << ".SetFineness( " << theValue << " )"; + if ( isToSetParameter( GetFineness(), theValue, METH_SetFineness )) + { + this->GetImpl()->SetFineness((::NETGENPlugin_Hypothesis::Fineness)theValue); + SMESH::TPythonDump() << _this() << ".SetFineness( " << theValue << " )"; + } } //============================================================================= @@ -179,8 +221,6 @@ void NETGENPlugin_Hypothesis_i::SetFineness (CORBA::Long theValue) //============================================================================= CORBA::Long NETGENPlugin_Hypothesis_i::GetFineness() { - MESSAGE("NETGENPlugin_Hypothesis_i::GetFineness"); - ASSERT(myBaseImpl); return this->GetImpl()->GetFineness(); } @@ -193,10 +233,11 @@ CORBA::Long NETGENPlugin_Hypothesis_i::GetFineness() //============================================================================= void NETGENPlugin_Hypothesis_i::SetGrowthRate (CORBA::Double theValue) { - MESSAGE("NETGENPlugin_Hypothesis_i::SetGrowthRate"); - ASSERT(myBaseImpl); - this->GetImpl()->SetGrowthRate(theValue); - SMESH::TPythonDump() << _this() << ".SetGrowthRate( " << theValue << " )"; + if ( isToSetParameter( GetGrowthRate(), theValue, METH_SetGrowthRate )) + { + this->GetImpl()->SetGrowthRate(theValue); + SMESH::TPythonDump() << _this() << ".SetGrowthRate( " << SMESH::TVar(theValue) << " )"; + } } //============================================================================= @@ -208,8 +249,6 @@ void NETGENPlugin_Hypothesis_i::SetGrowthRate (CORBA::Double theValue) //============================================================================= CORBA::Double NETGENPlugin_Hypothesis_i::GetGrowthRate() { - MESSAGE("NETGENPlugin_Hypothesis_i::GetGrowthRate"); - ASSERT(myBaseImpl); return this->GetImpl()->GetGrowthRate(); } @@ -222,10 +261,11 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetGrowthRate() //============================================================================= void NETGENPlugin_Hypothesis_i::SetNbSegPerEdge (CORBA::Double theValue) { - MESSAGE("NETGENPlugin_Hypothesis_i::SetNbSegPerEdge"); - ASSERT(myBaseImpl); - this->GetImpl()->SetNbSegPerEdge(theValue); - SMESH::TPythonDump() << _this() << ".SetNbSegPerEdge( " << theValue << " )"; + if ( isToSetParameter( GetNbSegPerEdge(), theValue, METH_SetNbSegPerEdge )) + { + this->GetImpl()->SetNbSegPerEdge(theValue); + SMESH::TPythonDump() << _this() << ".SetNbSegPerEdge( " << SMESH::TVar(theValue) << " )"; + } } //============================================================================= @@ -237,8 +277,6 @@ void NETGENPlugin_Hypothesis_i::SetNbSegPerEdge (CORBA::Double theValue) //============================================================================= CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerEdge() { - MESSAGE("NETGENPlugin_Hypothesis_i::GetNbSegPerEdge"); - ASSERT(myBaseImpl); return this->GetImpl()->GetNbSegPerEdge(); } @@ -251,10 +289,11 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerEdge() //============================================================================= void NETGENPlugin_Hypothesis_i::SetNbSegPerRadius (CORBA::Double theValue) { - MESSAGE("NETGENPlugin_Hypothesis_i::SetNbSegPerRadius"); - ASSERT(myBaseImpl); - this->GetImpl()->SetNbSegPerRadius(theValue); - SMESH::TPythonDump() << _this() << ".SetNbSegPerRadius( " << theValue << " )"; + if ( isToSetParameter( GetNbSegPerRadius(), theValue, METH_SetNbSegPerRadius )) + { + this->GetImpl()->SetNbSegPerRadius(theValue); + SMESH::TPythonDump() << _this() << ".SetNbSegPerRadius( " << SMESH::TVar(theValue) << " )"; + } } //============================================================================= @@ -266,11 +305,84 @@ void NETGENPlugin_Hypothesis_i::SetNbSegPerRadius (CORBA::Double theValue) //============================================================================= CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerRadius() { - MESSAGE("NETGENPlugin_Hypothesis_i::GetNbSegPerRadius"); - ASSERT(myBaseImpl); return this->GetImpl()->GetNbSegPerRadius(); } +//============================================================================= + +void NETGENPlugin_Hypothesis_i::SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, + CORBA::Double localSize) +{ + string entry; + entry = GeomObj->GetStudyEntry(); + SetLocalSizeOnEntry(entry.c_str(), localSize); +} + +//============================================================================= + +void NETGENPlugin_Hypothesis_i::SetLocalSizeOnEntry(const char* entry, + CORBA::Double localSize) +{ + if ( isToSetParameter( GetLocalSizeOnEntry(entry), localSize, METH_SetLocalSizeOnEntry )) + { + this->GetImpl()->SetLocalSizeOnEntry(entry, localSize); + SMESH::TPythonDump() + << _this() << ".SetLocalSizeOnShape(" << entry << ", " << localSize << ")"; + } +} + +//============================================================================= + +CORBA::Double NETGENPlugin_Hypothesis_i::GetLocalSizeOnEntry(const char* entry) +{ + return this->GetImpl()->GetLocalSizeOnEntry(entry); +} + +//============================================================================= + +NETGENPlugin::string_array* NETGENPlugin_Hypothesis_i::GetLocalSizeEntries() +{ + NETGENPlugin::string_array_var result = new NETGENPlugin::string_array(); + const ::NETGENPlugin_Hypothesis::TLocalSize localSizes = + this->GetImpl()->GetLocalSizesAndEntries(); + result->length(localSizes.size()); + ::NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin(); + for (int i=0 ; it != localSizes.end() ; i++, it++) + { + string entry = (*it).first; + result[i] = CORBA::string_dup(entry.c_str()); + } + return result._retn(); +} + +//============================================================================= + +void NETGENPlugin_Hypothesis_i::UnsetLocalSizeOnEntry(const char* entry) +{ + this->GetImpl()->UnsetLocalSizeOnEntry(entry); + SMESH::TPythonDump() << _this() << ".UnsetLocalSizeOnEntry(" << entry << ")"; +} + +//============================================================================= + +void NETGENPlugin_Hypothesis_i::SetQuadAllowed (CORBA::Boolean theValue) +{ + if ( NETGENPlugin_Hypothesis_i::isToSetParameter( GetQuadAllowed(), + theValue, + METH_SetQuadAllowed )) + { + this->GetImpl()->SetQuadAllowed(theValue); + SMESH::TPythonDump() << _this() << ".SetQuadAllowed( " << theValue << " )"; + } +} + +//============================================================================= + +CORBA::Boolean NETGENPlugin_Hypothesis_i::GetQuadAllowed() +{ + return this->GetImpl()->GetQuadAllowed(); +} + //============================================================================= /*! * NETGENPlugin_Hypothesis_i::GetImpl @@ -280,7 +392,6 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetNbSegPerRadius() //============================================================================= ::NETGENPlugin_Hypothesis* NETGENPlugin_Hypothesis_i::GetImpl() { - MESSAGE("NETGENPlugin_Hypothesis_i::GetImpl"); return (::NETGENPlugin_Hypothesis*)myBaseImpl; } @@ -297,3 +408,42 @@ CORBA::Boolean NETGENPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type { return type == SMESH::DIM_3D; } + +//================================================================================ +/*! + * \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook + */ +//================================================================================ + +int NETGENPlugin_Hypothesis_i::getParamIndex(const TCollection_AsciiString& method, + int nbVars) const +{ + if ( method == "SetMaxSize" ) return 0; + if ( method == "SetGrowthRate" ) return 1; + if ( method == "SetNbSegPerEdge" ) return 2; + if ( method == "SetNbSegPerRadius" ) return 3; + if ( method == "SetMinSize" ) return nbVars-1; + + return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value +} + +//================================================================================ +/*! + * \brief Method used to convert variable parameters stored in an old study + * into myMethod2VarParams. It should return a method name for an index of + * variable parameters. Index is countered from zero + */ +//================================================================================ + +std::string NETGENPlugin_Hypothesis_i::getMethodOfParameter(const int paramIndex, + int nbVars) const +{ + switch ( paramIndex ) { + case 0: return "SetMaxSize"; + case 1: return nbVars == 2 ? "SetMinSize" : "SetGrowthRate"; + case 2: return "SetNbSegPerEdge"; + case 3: return "SetNbSegPerRadius"; + case 4: return "SetMinSize"; + } + return ""; +} diff --git a/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx b/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx index 94ad126..95435b0 100644 --- a/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Hypothesis_i.hxx @@ -1,30 +1,30 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Hypothesis_i.hxx // Author : Michael Sazonov (OCN) // Date : 03/04/2006 // Project : SALOME -// $Header$ //============================================================================= // #ifndef _NETGENPlugin_Hypothesis_i_HXX_ @@ -39,6 +39,7 @@ #include "NETGENPlugin_Hypothesis.hxx" class SMESH_Gen; +//class GEOM_Object; // NETGENPlugin parameters hypothesis @@ -57,6 +58,9 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i: void SetMaxSize(CORBA::Double theSize); CORBA::Double GetMaxSize(); + void SetMinSize(CORBA::Double theSize); + CORBA::Double GetMinSize(); + void SetSecondOrder(CORBA::Boolean theVal); CORBA::Boolean GetSecondOrder(); @@ -75,11 +79,64 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i: void SetNbSegPerRadius(CORBA::Double theVal); CORBA::Double GetNbSegPerRadius(); + void SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize); + void SetLocalSizeOnEntry(const char* entry, CORBA::Double localSize); + CORBA::Double GetLocalSizeOnEntry(const char* entry); + NETGENPlugin::string_array* GetLocalSizeEntries(); + void UnsetLocalSizeOnEntry(const char* entry); + + void SetQuadAllowed(CORBA::Boolean theVal); + CORBA::Boolean GetQuadAllowed(); + // Get implementation ::NETGENPlugin_Hypothesis* GetImpl(); // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + protected: + + // to remember whether a parameter is already set (issue 0021364) + enum SettingMethod + { + METH_SetMaxSize = 1, + METH_SetMinSize = 2, + METH_SetSecondOrder = 4, + METH_SetOptimize = 8, + METH_SetFineness = 16, + METH_SetGrowthRate = 32, + METH_SetNbSegPerEdge = 64, + METH_SetNbSegPerRadius = 128, + METH_SetLocalSizeOnEntry = 256, + METH_SetQuadAllowed = METH_SetLocalSizeOnEntry * 2, + METH_LAST = METH_SetQuadAllowed + }; + int mySetMethodFlags; + + // Return true if a parameter is not yet set, else return true if a parameter changes. + // PythonDumping depends on the result of this function. + // Checking only change of a parameter is not enough because then the default values are + // not dumped and if the defaults will change then the behaviour of scripts + // created without dump of the default parameters will also change what is not good. + template + bool isToSetParameter(T curValue, T newValue, /*SettingMethod*/int meth) + { + if ( mySetMethodFlags & meth ) // already set, check if a value is changing + return ( curValue != newValue ); + else + return ( mySetMethodFlags |= meth ); // == return true + } + + public: + // method intended to remove explicit treatment of Netgen hypotheses from + // SMESH_NoteBook to assure backward compatibility after implemeneting + // issue 0021308: Remove hard-coded dependency of the external mesh plugins + virtual int getParamIndex(const TCollection_AsciiString& method, int nbVars) const; + + // method used to convert variable parameters stored in an old study + // into myMethod2VarParams. It should return a method name for an index of + // variable parameters. Index is countered from zero + virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index 0d86eca..9249d95 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -1,74 +1,108 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Mesher.cxx // Author : Michael Sazonov (OCN) // Date : 31/03/2006 // Project : SALOME -// $Header$ //============================================================================= -// + #include "NETGENPlugin_Mesher.hxx" #include "NETGENPlugin_Hypothesis_2D.hxx" #include "NETGENPlugin_SimpleHypothesis_3D.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 +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include // Netgen include files -namespace nglib { -#include -} +#ifndef OCCGEOMETRY #define OCCGEOMETRY +#endif #include #include //#include namespace netgen { extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*); + //extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh); extern MeshingParameters mparam; + extern volatile multithreadt multithread; } +#include +#include + +using namespace nglib; using namespace std; +#ifdef _DEBUG_ +#define nodeVec_ACCESS(index) ((SMDS_MeshNode*) nodeVec.at((index))) +#else +#define nodeVec_ACCESS(index) ((SMDS_MeshNode*) nodeVec[index]) +#endif + +#ifdef NETGEN_NEW +#define NGPOINT_COORDS(p) p(0),p(1),p(2) +#else +#define NGPOINT_COORDS(p) p.X(),p.Y(),p.Z() +#endif + +// dump elements added to ng mesh +//#define DUMP_SEGMENTS +//#define DUMP_TRIANGLES +//#define DUMP_TRIANGLES_SCRIPT "/tmp/trias.py" //!< debug addIntVerticesInSolids() + +TopTools_IndexedMapOfShape ShapesWithLocalSize; +std::map VertexId2LocalSize; +std::map EdgeId2LocalSize; +std::map FaceId2LocalSize; + //============================================================================= /*! * @@ -82,9 +116,14 @@ NETGENPlugin_Mesher::NETGENPlugin_Mesher (SMESH_Mesh* mesh, _shape (aShape), _isVolume(isVolume), _optimize(true), + _fineness(NETGENPlugin_Hypothesis::GetDefaultFineness()), _simpleHyp(NULL) { defaultParameters(); + ShapesWithLocalSize.Clear(); + VertexId2LocalSize.clear(); + EdgeId2LocalSize.clear(); + FaceId2LocalSize.clear(); } //================================================================================ @@ -95,13 +134,10 @@ NETGENPlugin_Mesher::NETGENPlugin_Mesher (SMESH_Mesh* mesh, void NETGENPlugin_Mesher::defaultParameters() { -#ifdef WNT - netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters(); -#else netgen::MeshingParameters& mparams = netgen::mparam; -#endif // maximal mesh edge size - mparams.maxh = NETGENPlugin_Hypothesis::GetDefaultMaxSize(); + mparams.maxh = 0;//NETGENPlugin_Hypothesis::GetDefaultMaxSize(); + mparams.minh = 0; // minimal number of segments per edge mparams.segmentsperedge = NETGENPlugin_Hypothesis::GetDefaultNbSegPerEdge(); // rate of growth of size between elements @@ -115,6 +151,35 @@ void NETGENPlugin_Mesher::defaultParameters() mparams.quad = 0; else mparams.quad = NETGENPlugin_Hypothesis_2D::GetDefaultQuadAllowed() ? 1 : 0; + _fineness = NETGENPlugin_Hypothesis::GetDefaultFineness(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SetLocalSize(TopoDS_Shape GeomShape, double LocalSize) +{ + TopAbs_ShapeEnum GeomType = GeomShape.ShapeType(); + if (GeomType == TopAbs_COMPOUND) { + for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()) { + SetLocalSize(it.Value(), LocalSize); + } + return; + } + int key; + if (! ShapesWithLocalSize.Contains(GeomShape)) + key = ShapesWithLocalSize.Add(GeomShape); + else + key = ShapesWithLocalSize.FindIndex(GeomShape); + if (GeomType == TopAbs_VERTEX) { + VertexId2LocalSize[key] = LocalSize; + } else if (GeomType == TopAbs_EDGE) { + EdgeId2LocalSize[key] = LocalSize; + } else if (GeomType == TopAbs_FACE) { + FaceId2LocalSize[key] = LocalSize; + } } //============================================================================= @@ -126,14 +191,12 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp) { if (hyp) { -#ifdef WNT - netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters(); -#else netgen::MeshingParameters& mparams = netgen::mparam; -#endif // Initialize global NETGEN parameters: // maximal mesh segment size mparams.maxh = hyp->GetMaxSize(); + // maximal mesh element linear size + mparams.minh = hyp->GetMinSize(); // minimal number of segments per edge mparams.segmentsperedge = hyp->GetNbSegPerEdge(); // rate of growth of size between elements @@ -143,12 +206,40 @@ void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp) // create elements of second order mparams.secondorder = hyp->GetSecondOrder() ? 1 : 0; // quad-dominated surface meshing - // only triangles are allowed for volumic mesh - if (!_isVolume) - mparams.quad = static_cast - (hyp)->GetQuadAllowed() ? 1 : 0; + // only triangles are allowed for volumic mesh (before realizing IMP 0021676) + //if (!_isVolume) + mparams.quad = hyp->GetQuadAllowed() ? 1 : 0; _optimize = hyp->GetOptimize(); + _fineness = hyp->GetFineness(); _simpleHyp = NULL; + + SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject); + SALOMEDS::Study_var myStudy = aStudyMgr->GetStudyByID(hyp->GetStudyId()); + + const NETGENPlugin_Hypothesis::TLocalSize localSizes = hyp->GetLocalSizesAndEntries(); + NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin(); + for (it ; it != localSizes.end() ; it++) + { + std::string entry = (*it).first; + double val = (*it).second; + // -- + GEOM::GEOM_Object_var aGeomObj; + TopoDS_Shape S = TopoDS_Shape(); + SALOMEDS::SObject_var aSObj = myStudy->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() ); + // -- + SetLocalSize(S, val); + } } } @@ -188,6 +279,171 @@ Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2) aLink1.n1 == aLink2.n2 && aLink1.n2 == aLink2.n1); } +namespace +{ + //================================================================================ + /*! + * \brief return id of netgen point corresponding to SMDS node + */ + //================================================================================ + typedef map< const SMDS_MeshNode*, int > TNode2IdMap; + + int ngNodeId( const SMDS_MeshNode* node, + netgen::Mesh& ngMesh, + TNode2IdMap& nodeNgIdMap) + { + int newNgId = ngMesh.GetNP() + 1; + + TNode2IdMap::iterator node_id = nodeNgIdMap.insert( make_pair( node, newNgId )).first; + + if ( node_id->second == newNgId) + { +#if defined(DUMP_SEGMENTS) || defined(DUMP_TRIANGLES) + cout << "Ng " << newNgId << " - " << node; +#endif + netgen::MeshPoint p( netgen::Point<3> (node->X(), node->Y(), node->Z()) ); + ngMesh.AddPoint( p ); + } + return node_id->second; + } + + //================================================================================ + /*! + * \brief Return computed EDGEs connected to the given one + */ + //================================================================================ + + list< TopoDS_Edge > getConnectedEdges( const TopoDS_Edge& edge, + const TopoDS_Face& face, + const set< SMESH_subMesh* > & computedSM, + const SMESH_MesherHelper& helper, + map< SMESH_subMesh*, set< int > >& addedEdgeSM2Faces) + { + // get ordered EDGEs + TopoDS_Vertex v1; + list< TopoDS_Edge > edges; + list< int > nbEdgesInWire; + int nbWires = SMESH_Block::GetOrderedEdges( face, v1, edges, nbEdgesInWire); + + // find within + list< TopoDS_Edge >::iterator eItFwd = edges.begin(); + for ( ; eItFwd != edges.end(); ++eItFwd ) + if ( edge.IsSame( *eItFwd )) + break; + if ( eItFwd == edges.end()) return list< TopoDS_Edge>(); + + if ( eItFwd->Orientation() >= TopAbs_INTERNAL ) + { + // connected INTERNAL edges returned from GetOrderedEdges() are wrongly oriented + // so treat each INTERNAL edge separately + TopoDS_Edge e = *eItFwd; + edges.clear(); + edges.push_back( e ); + return edges; + } + + // get all computed EDGEs connected to + + list< TopoDS_Edge >::iterator eItBack = eItFwd, ePrev; + TopoDS_Vertex vCommon; + TopTools_MapOfShape eAdded; // map used not to add a seam edge twice to + eAdded.Add( edge ); + + // put edges before to back + while ( edges.begin() != eItFwd ) + edges.splice( edges.end(), edges, edges.begin() ); + + // search forward + ePrev = eItFwd; + while ( ++eItFwd != edges.end() ) + { + SMESH_subMesh* sm = helper.GetMesh()->GetSubMesh( *eItFwd ); + + bool connected = TopExp::CommonVertex( *ePrev, *eItFwd, vCommon ); + bool computed = sm->IsMeshComputed(); + bool added = addedEdgeSM2Faces[ sm ].count( helper.GetSubShapeID() ); + bool doubled = !eAdded.Add( *eItFwd ); + bool orientOK = (( ePrev ->Orientation() < TopAbs_INTERNAL ) == + ( eItFwd->Orientation() < TopAbs_INTERNAL ) ); + if ( !connected || !computed || !orientOK || added || doubled ) + { + // stop advancement; move edges from tail to head + while ( edges.back() != *ePrev ) + edges.splice( edges.begin(), edges, --edges.end() ); + break; + } + ePrev = eItFwd; + } + // search backward + while ( eItBack != edges.begin() ) + { + ePrev = eItBack; + --eItBack; + SMESH_subMesh* sm = helper.GetMesh()->GetSubMesh( *eItBack ); + + bool connected = TopExp::CommonVertex( *ePrev, *eItBack, vCommon ); + bool computed = sm->IsMeshComputed(); + bool added = addedEdgeSM2Faces[ sm ].count( helper.GetSubShapeID() ); + bool doubled = !eAdded.Add( *eItBack ); + bool orientOK = (( ePrev ->Orientation() < TopAbs_INTERNAL ) == + ( eItBack->Orientation() < TopAbs_INTERNAL ) ); + if ( !connected || !computed || !orientOK || added || doubled) + { + // stop advancement + edges.erase( edges.begin(), ePrev ); + break; + } + } + if ( edges.front() != edges.back() ) + { + // assure that the 1st vertex is meshed + TopoDS_Edge eLast = edges.back(); + while ( !SMESH_Algo::VertexNode( SMESH_MesherHelper::IthVertex( 0, edges.front()), helper.GetMeshDS()) + && + edges.front() != eLast ) + edges.splice( edges.end(), edges, edges.begin() ); + } + return edges; + } + + //================================================================================ + /*! + * \brief Make triangulation of a shape precise enough + */ + //================================================================================ + + void updateTriangulation( const TopoDS_Shape& shape ) + { + // static set< Poly_Triangulation* > updated; + + // TopLoc_Location loc; + // TopExp_Explorer fExp( shape, TopAbs_FACE ); + // for ( ; fExp.More(); fExp.Next() ) + // { + // Handle(Poly_Triangulation) triangulation = + // BRep_Tool::Triangulation ( TopoDS::Face( fExp.Current() ), loc); + // if ( triangulation.IsNull() || + // updated.insert( triangulation.operator->() ).second ) + // { + // BRepTools::Clean (shape); + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + BRepMesh_IncrementalMesh e(shape, 0.01, true); + + } + catch (Standard_Failure) + { + } + // updated.erase( triangulation.operator->() ); + // triangulation = BRep_Tool::Triangulation ( TopoDS::Face( fExp.Current() ), loc); + // updated.insert( triangulation.operator->() ); + // } + // } + } +} + //================================================================================ /*! * \brief Initialize netgen::OCCGeometry with OCCT shape @@ -197,16 +453,11 @@ Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2) void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo, const TopoDS_Shape& shape, SMESH_Mesh& mesh, - list< SMESH_subMesh* > * meshedSM) + list< SMESH_subMesh* > * meshedSM, + NETGENPlugin_Internals* intern) { - BRepTools::Clean (shape); - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, 0.01, true); - } catch (Standard_Failure) { - } + updateTriangulation( shape ); + Bnd_Box bb; BRepBndLib::Add (shape, bb); double x1,y1,z1,x2,y2,z2; @@ -220,7 +471,6 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo, occgeo.shape = shape; occgeo.changed = 1; - //occgeo.BuildFMap(); // fill maps of shapes of occgeo with not yet meshed subshapes @@ -243,12 +493,18 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo, // to find a right orientation of subshapes (PAL20462) TopTools_IndexedMapOfShape subShapes; TopExp::MapShapes(root->GetSubShape(), subShapes); - while ( smIt->more() ) { + while ( smIt->more() ) + { SMESH_subMesh* sm = smIt->next(); - if ( sm->IsEmpty() ) { - TopoDS_Shape shape = sm->GetSubShape(); + TopoDS_Shape shape = sm->GetSubShape(); + if ( intern && intern->isShapeToPrecompute( shape )) + continue; + if ( !meshedSM || sm->IsEmpty() ) + { if ( shape.ShapeType() != TopAbs_VERTEX ) - shape = subShapes( subShapes.FindIndex( shape ));// - shape->index->oriented shape + shape = subShapes( subShapes.FindIndex( shape ));// shape -> index -> oriented shape + if ( shape.Orientation() >= TopAbs_INTERNAL ) + shape.Orientation( TopAbs_FORWARD ); // isuue 0020676 switch ( shape.ShapeType() ) { case TopAbs_FACE : occgeo.fmap.Add( shape ); break; case TopAbs_EDGE : occgeo.emap.Add( shape ); break; @@ -258,36 +514,91 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo, } } // collect submeshes of meshed shapes - else if (meshedSM) { - meshedSM->push_back( sm ); + else if (meshedSM) + { + const int dim = SMESH_Gen::GetShapeDim( shape ); + meshedSM[ dim ].push_back( sm ); } } } occgeo.facemeshstatus.SetSize (occgeo.fmap.Extent()); occgeo.facemeshstatus = 0; - +#ifdef NETGEN_NEW + occgeo.face_maxh_modified.SetSize(occgeo.fmap.Extent()); + occgeo.face_maxh_modified = 0; + occgeo.face_maxh.SetSize(occgeo.fmap.Extent()); + occgeo.face_maxh = netgen::mparam.maxh; +#endif } //================================================================================ /*! - * \brief return id of netgen point corresponding to SMDS node + * \brief Return a default min size value suitable for the given geometry. */ //================================================================================ -static int ngNodeId( const SMDS_MeshNode* node, - netgen::Mesh& ngMesh, - map< const SMDS_MeshNode*, int >& nodeNgIdMap) +double NETGENPlugin_Mesher::GetDefaultMinSize(const TopoDS_Shape& geom, + const double maxSize) { - int newNgId = ngMesh.GetNP() + 1; + updateTriangulation( geom ); - pair< map< const SMDS_MeshNode*, int >::iterator, bool > it_isNew = - nodeNgIdMap.insert( make_pair( node, newNgId )); - - if ( it_isNew.second ) { - netgen::MeshPoint p( netgen::Point<3> (node->X(), node->Y(), node->Z()) ); - ngMesh.AddPoint( p ); + TopLoc_Location loc; + int i1, i2, i3; + const int* pi[4] = { &i1, &i2, &i3, &i1 }; + double minh = 1e100; + Bnd_B3d bb; + TopExp_Explorer fExp( geom, TopAbs_FACE ); + for ( ; fExp.More(); fExp.Next() ) + { + Handle(Poly_Triangulation) triangulation = + BRep_Tool::Triangulation ( TopoDS::Face( fExp.Current() ), loc); + if ( triangulation.IsNull() ) continue; + const double fTol = BRep_Tool::Tolerance( TopoDS::Face( fExp.Current() )); + const TColgp_Array1OfPnt& points = triangulation->Nodes(); + const Poly_Array1OfTriangle& trias = triangulation->Triangles(); + for ( int iT = trias.Lower(); iT <= trias.Upper(); ++iT ) + { + trias(iT).Get( i1, i2, i3 ); + for ( int j = 0; j < 3; ++j ) + { + double dist2 = points(*pi[j]).SquareDistance( points( *pi[j+1] )); + if ( dist2 < minh && fTol*fTol < dist2 ) + minh = dist2; + bb.Add( points(*pi[j])); + } + } } - return it_isNew.first->second; + if ( minh > 0.25 * bb.SquareExtent() ) // simple geometry, rough triangulation + { + minh = 1e-3 * sqrt( bb.SquareExtent()); + //cout << "BND BOX minh = " <ShapeToIndex( face ) << endl + << "\tface index: " << seg.si << endl + << "\tp1: " << seg[0] << endl + << "\tp2: " << seg[1] << endl + << "\tp0 param: " << seg.epgeominfo[ 0 ].dist << endl + << "\tp0 uv: " << seg.epgeominfo[ 0 ].u <<", "<< seg.epgeominfo[ 0 ].v << endl + //<< "\tp0 edge: " << seg.epgeominfo[ 0 ].edgenr << endl + << "\tp1 param: " << seg.epgeominfo[ 1 ].dist << endl + << "\tp1 uv: " << seg.epgeominfo[ 1 ].u <<", "<< seg.epgeominfo[ 1 ].v << endl; + //<< "\tp1 edge: " << seg.epgeominfo[ 1 ].edgenr << endl; +#endif if ( isSeam ) { - if ( helper.GetPeriodicIndex() == 1 ) { + if ( helper.GetPeriodicIndex() && 1 ) { seg.epgeominfo[ 0 ].u = otherSeamParam; seg.epgeominfo[ 1 ].u = otherSeamParam; swap (seg.epgeominfo[0].v, seg.epgeominfo[1].v); @@ -400,10 +760,26 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom, seg.epgeominfo[ 1 ].v = otherSeamParam; swap (seg.epgeominfo[0].u, seg.epgeominfo[1].u); } - swap (seg.p1, seg.p2); + swap (seg[0], seg[1]); swap (seg.epgeominfo[0].dist, seg.epgeominfo[1].dist); seg.edgenr = ngMesh.GetNSeg() + 1; // segment id ngMesh.AddSegment (seg); +#ifdef DUMP_SEGMENTS + cout << "Segment: " << seg.edgenr << endl + << "\t is SEAM (reverse) of the previous. " + << " Other " << (helper.GetPeriodicIndex() && 1 ? "U" : "V") + << " = " << otherSeamParam << endl; +#endif + } + else if ( fOri == TopAbs_INTERNAL ) + { + swap (seg[0], seg[1]); + swap( seg.epgeominfo[0], seg.epgeominfo[1] ); + seg.edgenr = ngMesh.GetNSeg() + 1; // segment id + ngMesh.AddSegment (seg); +#ifdef DUMP_SEGMENTS + cout << "Segment: " << seg.edgenr << endl << "\t is REVERSE of the previous" << endl; +#endif } } } // loop on geomEdge ancestors @@ -415,69 +791,135 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom, // ---------------------- const TopoDS_Face& geomFace = TopoDS::Face( sm->GetSubShape() ); helper.SetSubShape( geomFace ); + bool isInternalFace = ( geomFace.Orientation() == TopAbs_INTERNAL ); - // find solids geomFace bounds + // Find solids the geomFace bounds int solidID1 = 0, solidID2 = 0; - const TopTools_ListOfShape& ancestors = _mesh->GetAncestors( geomFace ); - TopTools_ListIteratorOfListOfShape ancestorIt ( ancestors ); - for ( ; ancestorIt.More(); ancestorIt.Next() ) + StdMeshers_QuadToTriaAdaptor* quadAdaptor = + dynamic_cast( proxyMesh.get() ); + if ( quadAdaptor ) { - const TopoDS_Shape & solid = ancestorIt.Value(); - if ( solid.ShapeType() == TopAbs_SOLID ) { - int id = occgeom.somap.FindIndex ( solid ); + solidID1 = occgeom.somap.FindIndex( quadAdaptor->GetShape() ); + } + else + { + PShapeIteratorPtr solidIt = helper.GetAncestors( geomFace, *sm->GetFather(), TopAbs_SOLID); + while ( const TopoDS_Shape * solid = solidIt->next() ) + { + int id = occgeom.somap.FindIndex ( *solid ); if ( solidID1 && id != solidID1 ) solidID2 = id; else solidID1 = id; } } - faceID++; - _faceDescriptors[ faceID ].first = solidID1; - _faceDescriptors[ faceID ].second = solidID2; + // Add ng face descriptors of meshed faces + faceNgID++; + ngMesh.AddFaceDescriptor (netgen::FaceDescriptor(faceNgID, solidID1, solidID2, 0)); + + // if second oreder is required, even already meshed faces must be passed to NETGEN + int fID = occgeom.fmap.Add( geomFace ); + while ( fID < faceNgID ) // geomFace is already in occgeom.fmap, add a copy + fID = occgeom.fmap.Add( BRepBuilderAPI_Copy( geomFace, /*copyGeom=*/false )); + // Problem with the second order in a quadrangular mesh remains. + // 1) All quadrangles geberated by NETGEN are moved to an inexistent face + // by FillSMesh() (find AddFaceDescriptor) + // 2) Temporary triangles generated by StdMeshers_QuadToTriaAdaptor + // are on faces where quadrangles were. + // Due to these 2 points, wrong geom faces are used while conversion to qudratic + // of the mentioned above quadrangles and triangles + + // Orient the face correctly in solidID1 (issue 0020206) + bool reverse = false; + if ( solidID1 ) { + TopoDS_Shape solid = occgeom.somap( solidID1 ); + TopAbs_Orientation faceOriInSolid = helper.GetSubShapeOri( solid, geomFace ); + if ( faceOriInSolid >= 0 ) + reverse = SMESH_Algo::IsReversedSubMesh + ( TopoDS::Face( geomFace.Oriented( faceOriInSolid )), helper.GetMeshDS() ); + } + + // Add surface elements + + netgen::Element2d tri(3); + tri.SetIndex ( faceNgID ); + + +#ifdef DUMP_TRIANGLES + cout << "SMESH face " << helper.GetMeshDS()->ShapeToIndex( geomFace ) + << " internal="<GetSubMesh( geomFace ); - // add surface elements SMDS_ElemIteratorPtr faces = smDS->GetElements(); - while ( faces->more() ) { - + while ( faces->more() ) + { const SMDS_MeshElement* f = faces->next(); - if ( f->NbNodes() % 3 != 0 ) { // not triangle - for ( ancestorIt.Initialize(ancestors); ancestorIt.More(); ancestorIt.Next() ) - if ( ancestorIt.Value().ShapeType() == TopAbs_SOLID ) { - sm = _mesh->GetSubMesh( ancestorIt.Value() ); - break; - } + if ( f->NbNodes() % 3 != 0 ) // not triangle + { + PShapeIteratorPtr solidIt=helper.GetAncestors(geomFace,*sm->GetFather(),TopAbs_SOLID); + if ( const TopoDS_Shape * solid = solidIt->next() ) + sm = _mesh->GetSubMesh( *solid ); SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); smError.reset( new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH,"Not triangle submesh")); smError->myBadElements.push_back( f ); return false; } - netgen::Element2d tri(3); - tri.SetIndex ( faceID ); - - for ( int i = 0; i < 3; ++i ) { + for ( int i = 0; i < 3; ++i ) + { const SMDS_MeshNode* node = f->GetNode( i ), * inFaceNode=0; - if ( helper.IsSeamShape( node->GetPosition()->GetShapeId() )) - if ( helper.IsSeamShape( f->GetNode( i+1 )->GetPosition()->GetShapeId() )) - inFaceNode = f->GetNode( i-1 ); + + // get node UV on face + int shapeID = node->getshapeId(); + if ( helper.IsSeamShape( shapeID )) + if ( helper.IsSeamShape( f->GetNodeWrap( i+1 )->getshapeId() )) + inFaceNode = f->GetNodeWrap( i-1 ); else - inFaceNode = f->GetNode( i+1 ); - + inFaceNode = f->GetNodeWrap( i+1 ); gp_XY uv = helper.GetNodeUV( geomFace, node, inFaceNode ); - tri.GeomInfoPi(i+1).u = uv.X(); - tri.GeomInfoPi(i+1).v = uv.Y(); - tri.PNum(i+1) = ngNodeId( node, ngMesh, nodeNgIdMap ); + + int ind = reverse ? 3-i : i+1; + tri.GeomInfoPi(ind).u = uv.X(); + tri.GeomInfoPi(ind).v = uv.Y(); + tri.PNum (ind) = ngNodeId( node, ngMesh, nodeNgIdMap ); } ngMesh.AddSurfaceElement (tri); +#ifdef DUMP_TRIANGLES + cout << tri << endl; +#endif + if ( isInternalFace ) + { + swap( tri[1], tri[2] ); + ngMesh.AddSurfaceElement (tri); +#ifdef DUMP_TRIANGLES + cout << tri << endl; +#endif + } } break; - } // + } // case TopAbs_FACE case TopAbs_VERTEX: { // VERTEX // -------------------------- - SMDS_NodeIteratorPtr nodeIt = smDS->GetNodes(); - if ( nodeIt->more() ) - ngNodeId( nodeIt->next(), ngMesh, nodeNgIdMap ); + // issue 0021405. Add node only if a VERTEX is shared by a not meshed EDGE, + // else netgen removes a free node and nodeVector becomes invalid + PShapeIteratorPtr ansIt = helper.GetAncestors( sm->GetSubShape(), + *sm->GetFather(), + TopAbs_EDGE ); + bool toAdd = false; + while ( const TopoDS_Shape* e = ansIt->next() ) + { + SMESH_subMesh* eSub = helper.GetMesh()->GetSubMesh( *e ); + if (( toAdd = eSub->IsEmpty() )) break; + } + if ( toAdd ) + { + SMDS_NodeIteratorPtr nodeIt = smDS->GetNodes(); + if ( nodeIt->more() ) + ngNodeId( nodeIt->next(), ngMesh, nodeNgIdMap ); + } break; } default:; @@ -486,25 +928,892 @@ bool NETGENPlugin_Mesher::fillNgMesh(netgen::OCCGeometry& occgeom, // fill nodeVec nodeVec.resize( ngMesh.GetNP() + 1 ); - map< const SMDS_MeshNode*, int >::iterator node_NgId, nodeNgIdEnd = nodeNgIdMap.end(); + TNode2IdMap::iterator node_NgId, nodeNgIdEnd = nodeNgIdMap.end(); for ( node_NgId = nodeNgIdMap.begin(); node_NgId != nodeNgIdEnd; ++node_NgId) - nodeVec[ node_NgId->second ] = (SMDS_MeshNode*) node_NgId->first; + nodeVec[ node_NgId->second ] = node_NgId->first; return true; } +//================================================================================ +/*! + * \brief Duplicate mesh faces on internal geom faces + */ +//================================================================================ + +void NETGENPlugin_Mesher::fixIntFaces(const netgen::OCCGeometry& occgeom, + netgen::Mesh& ngMesh, + NETGENPlugin_Internals& internalShapes) +{ + SMESHDS_Mesh* meshDS = internalShapes.getMesh().GetMeshDS(); + + // find ng indices of internal faces + set ngFaceIds; + for ( int ngFaceID = 1; ngFaceID <= occgeom.fmap.Extent(); ++ngFaceID ) + { + int smeshID = meshDS->ShapeToIndex( occgeom.fmap( ngFaceID )); + if ( internalShapes.isInternalShape( smeshID )) + ngFaceIds.insert( ngFaceID ); + } + if ( !ngFaceIds.empty() ) + { + // duplicate faces + int i, nbFaces = ngMesh.GetNSE(); + for (int i = 1; i <= nbFaces; ++i) + { + netgen::Element2d elem = ngMesh.SurfaceElement(i); + if ( ngFaceIds.count( elem.GetIndex() )) + { + swap( elem[1], elem[2] ); + ngMesh.AddSurfaceElement (elem); + } + } + } +} + +namespace +{ + //================================================================================ + // define gp_XY_Subtracted pointer to function calling gp_XY::Subtracted(gp_XY) + gp_XY_FunPtr(Subtracted); + //gp_XY_FunPtr(Added); + + //================================================================================ + /*! + * \brief Evaluate distance between two 2d points along the surface + */ + //================================================================================ + + double evalDist( const gp_XY& uv1, + const gp_XY& uv2, + const Handle(Geom_Surface)& surf, + const int stopHandler=-1) + { + if ( stopHandler > 0 ) // continue recursion + { + gp_XY mid = SMESH_MesherHelper::GetMiddleUV( surf, uv1, uv2 ); + return evalDist( uv1,mid, surf, stopHandler-1 ) + evalDist( mid,uv2, surf, stopHandler-1 ); + } + double dist3D = surf->Value( uv1.X(), uv1.Y() ).Distance( surf->Value( uv2.X(), uv2.Y() )); + if ( stopHandler == 0 ) // stop recursion + return dist3D; + + // start recursion if necessary + double dist2D = SMESH_MesherHelper::applyIn2D(surf, uv1, uv2, gp_XY_Subtracted, 0).Modulus(); + if ( fabs( dist3D - dist2D ) < dist2D * 1e-10 ) + return dist3D; // equal parametrization of a planar surface + + return evalDist( uv1, uv2, surf, 3 ); // start recursion + } + + //================================================================================ + /*! + * \brief Data of vertex internal in geom face + */ + //================================================================================ + + struct TIntVData + { + gp_XY uv; //!< UV in face parametric space + int ngId; //!< ng id of corrsponding node + gp_XY uvClose; //!< UV of closest boundary node + int ngIdClose; //!< ng id of closest boundary node + }; + + //================================================================================ + /*! + * \brief Data of vertex internal in solid + */ + //================================================================================ + + struct TIntVSoData + { + int ngId; //!< ng id of corresponding node + int ngIdClose; //!< ng id of closest 2d mesh element + int ngIdCloseN; //!< ng id of closest node of the closest 2d mesh element + }; + + inline double dist2(const netgen::MeshPoint& p1, const netgen::MeshPoint& p2) + { + return gp_Pnt( NGPOINT_COORDS(p1)).SquareDistance( gp_Pnt( NGPOINT_COORDS(p2))); + } +} + +//================================================================================ +/*! + * \brief Make netgen take internal vertices in faces into account by adding + * segments including internal vertices + * + * This function works in supposition that 1D mesh is already computed in ngMesh + */ +//================================================================================ + +void NETGENPlugin_Mesher::addIntVerticesInFaces(const netgen::OCCGeometry& occgeom, + netgen::Mesh& ngMesh, + vector& nodeVec, + NETGENPlugin_Internals& internalShapes) +{ + if ( nodeVec.size() < ngMesh.GetNP() ) + nodeVec.resize( ngMesh.GetNP(), 0 ); + + SMESHDS_Mesh* meshDS = internalShapes.getMesh().GetMeshDS(); + SMESH_MesherHelper helper( internalShapes.getMesh() ); + + const map >& face2Vert = internalShapes.getFacesWithVertices(); + map >::const_iterator f2v = face2Vert.begin(); + for ( ; f2v != face2Vert.end(); ++f2v ) + { + const TopoDS_Face& face = TopoDS::Face( meshDS->IndexToShape( f2v->first )); + if ( face.IsNull() ) continue; + int faceNgID = occgeom.fmap.FindIndex (face); + if ( faceNgID < 0 ) continue; + + TopLoc_Location loc; + Handle(Geom_Surface) surf = BRep_Tool::Surface(face,loc); + + helper.SetSubShape( face ); + helper.SetElementsOnShape( true ); + + // Get data of internal vertices and add them to ngMesh + + multimap< double, TIntVData > dist2VData; // sort vertices by distance from boundary nodes + + int i, nbSegInit = ngMesh.GetNSeg(); + + // boundary characteristics + double totSegLen2D = 0; + int totNbSeg = 0; + + const list& iVertices = f2v->second; + list::const_iterator iv = iVertices.begin(); + for ( int nbV = 0; iv != iVertices.end(); ++iv, nbV++ ) + { + TIntVData vData; + // get node on vertex + const TopoDS_Vertex V = TopoDS::Vertex( meshDS->IndexToShape( *iv )); + const SMDS_MeshNode * nV = SMESH_Algo::VertexNode( V, meshDS ); + if ( !nV ) + { + SMESH_subMesh* sm = helper.GetMesh()->GetSubMesh( V ); + sm->ComputeStateEngine( SMESH_subMesh::COMPUTE ); + nV = SMESH_Algo::VertexNode( V, meshDS ); + if ( !nV ) continue; + } + // add ng node + netgen::MeshPoint mp( netgen::Point<3> (nV->X(), nV->Y(), nV->Z()) ); + ngMesh.AddPoint ( mp, 1, netgen::EDGEPOINT ); + vData.ngId = ngMesh.GetNP(); + nodeVec.push_back( nV ); + + // get node UV + bool uvOK = false; + vData.uv = helper.GetNodeUV( face, nV, 0, &uvOK ); + if ( !uvOK ) helper.CheckNodeUV( face, nV, vData.uv, BRep_Tool::Tolerance(V),/*force=*/1); + + // loop on all segments of the face to find the node closest to vertex and to count + // average segment 2d length + double closeDist2 = numeric_limits::max(), dist2; + int ngIdLast = 0; + for (i = 1; i <= ngMesh.GetNSeg(); ++i) + { + netgen::Segment & seg = ngMesh.LineSegment(i); + if ( seg.si != faceNgID ) continue; + gp_XY uv[2]; + for ( int iEnd = 0; iEnd < 2; ++iEnd) + { + uv[iEnd].SetCoord( seg.epgeominfo[iEnd].u, seg.epgeominfo[iEnd].v ); + if ( ngIdLast == seg[ iEnd ] ) continue; + dist2 = helper.applyIn2D(surf, uv[iEnd], vData.uv, gp_XY_Subtracted,0).SquareModulus(); + if ( dist2 < closeDist2 ) + vData.ngIdClose = seg[ iEnd ], vData.uvClose = uv[iEnd], closeDist2 = dist2; + ngIdLast = seg[ iEnd ]; + } + if ( !nbV ) + { + totSegLen2D += helper.applyIn2D(surf, uv[0], uv[1], gp_XY_Subtracted, false).Modulus(); + totNbSeg++; + } + } + dist2VData.insert( make_pair( closeDist2, vData )); + } + + if ( totNbSeg == 0 ) break; + double avgSegLen2d = totSegLen2D / totNbSeg; + + // Loop on vertices to add segments + + multimap< double, TIntVData >::iterator dist_vData = dist2VData.begin(); + for ( ; dist_vData != dist2VData.end(); ++dist_vData ) + { + double closeDist2 = dist_vData->first, dist2; + TIntVData & vData = dist_vData->second; + + // try to find more close node among segments added for internal vertices + for (i = nbSegInit+1; i <= ngMesh.GetNSeg(); ++i) + { + netgen::Segment & seg = ngMesh.LineSegment(i); + if ( seg.si != faceNgID ) continue; + gp_XY uv[2]; + for ( int iEnd = 0; iEnd < 2; ++iEnd) + { + uv[iEnd].SetCoord( seg.epgeominfo[iEnd].u, seg.epgeominfo[iEnd].v ); + dist2 = helper.applyIn2D(surf, uv[iEnd], vData.uv, gp_XY_Subtracted,0).SquareModulus(); + if ( dist2 < closeDist2 ) + vData.ngIdClose = seg[ iEnd ], vData.uvClose = uv[iEnd], closeDist2 = dist2; + } + } + // decide whether to use the closest node as the second end of segment or to + // create a new point + int segEnd1 = vData.ngId; + int segEnd2 = vData.ngIdClose; // to use closest node + gp_XY uvV = vData.uv, uvP = vData.uvClose; + double segLenHint = ngMesh.GetH( ngMesh.Point( vData.ngId )); + double nodeDist2D = sqrt( closeDist2 ); + double nodeDist3D = evalDist( vData.uv, vData.uvClose, surf ); + bool avgLenOK = ( avgSegLen2d < 0.75 * nodeDist2D ); + bool hintLenOK = ( segLenHint < 0.75 * nodeDist3D ); + //cout << "uvV " << uvV.X() <<","<Value( uvP.X(), uvP.Y() ).Transformed( loc ); + + netgen::MeshPoint mp( netgen::Point<3> (P.X(), P.Y(), P.Z())); + ngMesh.AddPoint ( mp, 1, netgen::EDGEPOINT ); + segEnd2 = ngMesh.GetNP(); + //cout << "Middle " << r << " uv " << uvP.X() << "," << uvP.Y() << "( " << ngMesh.Point(segEnd2).X()<<","< segEnd2 ) swap( segEnd1, segEnd2 ), swap( uvV, uvP ); + seg[0] = segEnd1; // ng node id + seg[1] = segEnd2; // ng node id + seg.edgenr = ngMesh.GetNSeg() + 1;// segment id + seg.si = faceNgID; + + seg.epgeominfo[ 0 ].dist = 0; // param on curve + seg.epgeominfo[ 0 ].u = uvV.X(); + seg.epgeominfo[ 0 ].v = uvV.Y(); + seg.epgeominfo[ 1 ].dist = 1; // param on curve + seg.epgeominfo[ 1 ].u = uvP.X(); + seg.epgeominfo[ 1 ].v = uvP.Y(); + +// seg.epgeominfo[ 0 ].edgenr = 10; // = geom.emap.FindIndex(edge); +// seg.epgeominfo[ 1 ].edgenr = 10; // = geom.emap.FindIndex(edge); + + ngMesh.AddSegment (seg); + + // add reverse segment + swap (seg[0], seg[1]); + swap( seg.epgeominfo[0], seg.epgeominfo[1] ); + seg.edgenr = ngMesh.GetNSeg() + 1; // segment id + ngMesh.AddSegment (seg); + } + + } +} + +//================================================================================ +/*! + * \brief Make netgen take internal vertices in solids into account by adding + * faces including internal vertices + * + * This function works in supposition that 2D mesh is already computed in ngMesh + */ +//================================================================================ + +void NETGENPlugin_Mesher::addIntVerticesInSolids(const netgen::OCCGeometry& occgeom, + netgen::Mesh& ngMesh, + vector& nodeVec, + NETGENPlugin_Internals& internalShapes) +{ +#ifdef DUMP_TRIANGLES_SCRIPT + // create a python script making a mesh containing triangles added for internal vertices + ofstream py(DUMP_TRIANGLES_SCRIPT); + py << "from smesh import * "<< endl + << "m = Mesh(name='triangles')" << endl; +#endif + if ( nodeVec.size() < ngMesh.GetNP() ) + nodeVec.resize( ngMesh.GetNP(), 0 ); + + SMESHDS_Mesh* meshDS = internalShapes.getMesh().GetMeshDS(); + SMESH_MesherHelper helper( internalShapes.getMesh() ); + + const map >& so2Vert = internalShapes.getSolidsWithVertices(); + map >::const_iterator s2v = so2Vert.begin(); + for ( ; s2v != so2Vert.end(); ++s2v ) + { + const TopoDS_Shape& solid = meshDS->IndexToShape( s2v->first ); + if ( solid.IsNull() ) continue; + int solidNgID = occgeom.somap.FindIndex (solid); + if ( solidNgID < 0 && !occgeom.somap.IsEmpty() ) continue; + + helper.SetSubShape( solid ); + helper.SetElementsOnShape( true ); + + // find ng indices of faces within the solid + set ngFaceIds; + for (TopExp_Explorer fExp(solid, TopAbs_FACE); fExp.More(); fExp.Next() ) + ngFaceIds.insert( occgeom.fmap.FindIndex( fExp.Current() )); + if ( ngFaceIds.size() == 1 && *ngFaceIds.begin() == 0 ) + ngFaceIds.insert( 1 ); + + // Get data of internal vertices and add them to ngMesh + + multimap< double, TIntVSoData > dist2VData; // sort vertices by distance from ng faces + + int i, nbFaceInit = ngMesh.GetNSE(); + + // boundary characteristics + double totSegLen = 0; + int totNbSeg = 0; + + const list& iVertices = s2v->second; + list::const_iterator iv = iVertices.begin(); + for ( int nbV = 0; iv != iVertices.end(); ++iv, nbV++ ) + { + TIntVSoData vData; + const TopoDS_Vertex V = TopoDS::Vertex( meshDS->IndexToShape( *iv )); + + // get node on vertex + const SMDS_MeshNode * nV = SMESH_Algo::VertexNode( V, meshDS ); + if ( !nV ) + { + SMESH_subMesh* sm = helper.GetMesh()->GetSubMesh( V ); + sm->ComputeStateEngine( SMESH_subMesh::COMPUTE ); + nV = SMESH_Algo::VertexNode( V, meshDS ); + if ( !nV ) continue; + } + // add ng node + netgen::MeshPoint mpV( netgen::Point<3> (nV->X(), nV->Y(), nV->Z()) ); + ngMesh.AddPoint ( mpV, 1, netgen::FIXEDPOINT ); + vData.ngId = ngMesh.GetNP(); + nodeVec.push_back( nV ); + + // loop on all 2d elements to find the one closest to vertex and to count + // average segment length + double closeDist2 = numeric_limits::max(), avgDist2; + for (i = 1; i <= ngMesh.GetNSE(); ++i) + { + const netgen::Element2d& elem = ngMesh.SurfaceElement(i); + if ( !ngFaceIds.count( elem.GetIndex() )) continue; + avgDist2 = 0; + multimap< double, int> dist2nID; // sort nodes of element by distance from V + for ( int j = 0; j < elem.GetNP(); ++j) + { + netgen::MeshPoint mp = ngMesh.Point( elem[j] ); + double d2 = dist2( mpV, mp ); + dist2nID.insert( make_pair( d2, elem[j] )); + avgDist2 += d2 / elem.GetNP(); + if ( !nbV ) + totNbSeg++, totSegLen+= sqrt( dist2( mp, ngMesh.Point( elem[(j+1)%elem.GetNP()]))); + } + double dist = dist2nID.begin()->first; //avgDist2; + if ( dist < closeDist2 ) + vData.ngIdClose= i, vData.ngIdCloseN= dist2nID.begin()->second, closeDist2= dist; + } + dist2VData.insert( make_pair( closeDist2, vData )); + } + + if ( totNbSeg == 0 ) break; + double avgSegLen = totSegLen / totNbSeg; + + // Loop on vertices to add triangles + + multimap< double, TIntVSoData >::iterator dist_vData = dist2VData.begin(); + for ( ; dist_vData != dist2VData.end(); ++dist_vData ) + { + double closeDist2 = dist_vData->first; + TIntVSoData & vData = dist_vData->second; + + const netgen::MeshPoint& mpV = ngMesh.Point( vData.ngId ); + + // try to find more close face among ones added for internal vertices + for (i = nbFaceInit+1; i <= ngMesh.GetNSE(); ++i) + { + double avgDist2 = 0; + multimap< double, int> dist2nID; + const netgen::Element2d& elem = ngMesh.SurfaceElement(i); + for ( int j = 0; j < elem.GetNP(); ++j) + { + double d = dist2( mpV, ngMesh.Point( elem[j] )); + dist2nID.insert( make_pair( d, elem[j] )); + avgDist2 += d / elem.GetNP(); + if ( avgDist2 < closeDist2 ) + vData.ngIdClose= i, vData.ngIdCloseN= dist2nID.begin()->second, closeDist2= avgDist2; + } + } + // sort nodes of the closest face by angle with vector from V to the closest node + const double tol = numeric_limits::min(); + map< double, int > angle2ID; + const netgen::Element2d& closeFace = ngMesh.SurfaceElement( vData.ngIdClose ); + netgen::MeshPoint mp[2]; + mp[0] = ngMesh.Point( vData.ngIdCloseN ); + gp_XYZ p1( NGPOINT_COORDS( mp[0] )); + gp_XYZ pV( NGPOINT_COORDS( mpV )); + gp_Vec v2p1( pV, p1 ); + double distN1 = v2p1.Magnitude(); + if ( distN1 <= tol ) continue; + v2p1 /= distN1; + for ( int j = 0; j < closeFace.GetNP(); ++j) + { + mp[1] = ngMesh.Point( closeFace[j] ); + gp_Vec v2p( pV, gp_Pnt( NGPOINT_COORDS( mp[1] )) ); + angle2ID.insert( make_pair( v2p1.Angle( v2p ), closeFace[j])); + } + // get node with angle of 60 degrees or greater + map< double, int >::iterator angle_id = angle2ID.lower_bound( 60. * M_PI / 180. ); + if ( angle_id == angle2ID.end() ) angle_id = --angle2ID.end(); + const double minAngle = 30. * M_PI / 180.; + const double angle = angle_id->first; + bool angleOK = ( angle > minAngle ); + + // find points to create a triangle + netgen::Element2d tri(3); + tri.SetIndex ( 1 ); + tri[0] = vData.ngId; + tri[1] = vData.ngIdCloseN; // to use the closest nodes + tri[2] = angle_id->second; // to use the node with best angle + + // decide whether to use the closest node and the node with best angle or to create new ones + for ( int isBestAngleN = 0; isBestAngleN < 2; ++isBestAngleN ) + { + bool createNew = !angleOK, distOK = true; + double distFromV; + int triInd = isBestAngleN ? 2 : 1; + mp[isBestAngleN] = ngMesh.Point( tri[triInd] ); + if ( isBestAngleN ) + { + if ( angleOK ) + { + double distN2 = sqrt( dist2( mpV, mp[isBestAngleN])); + createNew = ( fabs( distN2 - distN1 ) > 0.25 * distN1 ); + } + else if ( angle < tol ) + { + v2p1.SetX( v2p1.X() + 1e-3 ); + } + distFromV = distN1; + } + else + { + double segLenHint = ngMesh.GetH( ngMesh.Point( vData.ngId )); + bool avgLenOK = ( avgSegLen < 0.75 * distN1 ); + bool hintLenOK = ( segLenHint < 0.75 * distN1 ); + createNew = (createNew || avgLenOK || hintLenOK ); + // we create a new node not closer than 0.5 to the closest face + // in order not to clash with other close face + double r = min( 0.5, ( hintLenOK ? segLenHint : avgSegLen ) / distN1 ); + distFromV = r * distN1; + } + if ( createNew ) + { + // create a new point, between the node and the vertex if angleOK + gp_XYZ p( NGPOINT_COORDS( mp[isBestAngleN] )); + gp_Vec v2p( pV, p ); v2p.Normalize(); + if ( isBestAngleN && !angleOK ) + p = p1 + gp_Dir( v2p.XYZ() - v2p1.XYZ()).XYZ() * distN1 * 0.95; + else + p = pV + v2p.XYZ() * distFromV; + + if ( !isBestAngleN ) p1 = p, distN1 = distFromV; + + mp[isBestAngleN].SetPoint( netgen::Point<3> (p.X(), p.Y(), p.Z())); + ngMesh.AddPoint ( mp[isBestAngleN], 1, netgen::SURFACEPOINT ); + tri[triInd] = ngMesh.GetNP(); + nodeVec.push_back( helper.AddNode( p.X(), p.Y(), p.Z()) ); + } + } + ngMesh.AddSurfaceElement (tri); + swap( tri[1], tri[2] ); + ngMesh.AddSurfaceElement (tri); + +#ifdef DUMP_TRIANGLES_SCRIPT + py << "n1 = m.AddNode( "<< mpV.X()<<", "<< mpV.Y()<<", "<< mpV.Z()<<") "<< endl + << "n2 = m.AddNode( "<< mp[0].X()<<", "<< mp[0].Y()<<", "<< mp[0].Z()<<") "<< endl + << "n3 = m.AddNode( "<< mp[1].X()<<", "<< mp[1].Y()<<", "<< mp[1].Z()<<" )" << endl + << "m.AddFace([n1,n2,n3])" << endl; +#endif + } // loop on internal vertices of a solid + + } // loop on solids with internal vertices +} + +//================================================================================ +/*! + * \brief Fill SMESH mesh according to contents of netgen mesh + * \param occgeo - container of OCCT geometry to mesh + * \param ngMesh - netgen mesh + * \param initState - bn of entities in netgen mesh before computing + * \param sMesh - SMESH mesh to fill in + * \param nodeVec - vector of nodes in which node index == netgen ID + * \retval int - error + */ +//================================================================================ + +int NETGENPlugin_Mesher::FillSMesh(const netgen::OCCGeometry& occgeo, + netgen::Mesh& ngMesh, + const NETGENPlugin_ngMeshInfo& initState, + SMESH_Mesh& sMesh, + std::vector& nodeVec, + SMESH_Comment& comment) +{ + int nbNod = ngMesh.GetNP(); + int nbSeg = ngMesh.GetNSeg(); + int nbFac = ngMesh.GetNSE(); + int nbVol = ngMesh.GetNE(); + + SMESHDS_Mesh* meshDS = sMesh.GetMeshDS(); + + // ------------------------------------- + // Create and insert nodes into nodeVec + // ------------------------------------- + + nodeVec.resize( nbNod + 1 ); + int i, nbInitNod = initState._nbNodes; + for (i = nbInitNod+1; i <= nbNod; ++i ) + { + const netgen::MeshPoint& ngPoint = ngMesh.Point(i); + SMDS_MeshNode* node = NULL; + TopoDS_Vertex aVert; + // First, netgen creates nodes on vertices in occgeo.vmap, + // so node index corresponds to vertex index + // but (issue 0020776) netgen does not create nodes with equal coordinates + if ( i-nbInitNod <= occgeo.vmap.Extent() ) + { + gp_Pnt p ( NGPOINT_COORDS(ngPoint) ); + for (int iV = i-nbInitNod; aVert.IsNull() && iV <= occgeo.vmap.Extent(); ++iV) + { + aVert = TopoDS::Vertex( occgeo.vmap( iV ) ); + gp_Pnt pV = BRep_Tool::Pnt( aVert ); + if ( p.SquareDistance( pV ) > 1e-20 ) + aVert.Nullify(); + else + node = const_cast( SMESH_Algo::VertexNode( aVert, meshDS )); + } + } + if (!node) // node not found on vertex + { + node = meshDS->AddNode( NGPOINT_COORDS( ngPoint )); + if (!aVert.IsNull()) + meshDS->SetNodeOnVertex(node, aVert); + } + nodeVec[i] = node; + } + + // ------------------------------------------- + // Create mesh segments along geometric edges + // ------------------------------------------- + + int nbInitSeg = initState._nbSegments; + for (i = nbInitSeg+1; i <= nbSeg; ++i ) + { + const netgen::Segment& seg = ngMesh.LineSegment(i); + TopoDS_Edge aEdge; +#ifdef NETGEN_NEW + int pinds[3] = { seg.pnums[0], seg.pnums[1], seg.pnums[2] }; +#else + int pinds[3] = { seg.p1, seg.p2, seg.pmid }; +#endif + int nbp = 0; + double param2 = 0; + for (int j=0; j < 3; ++j) + { + int pind = pinds[j]; + if (pind <= 0 || !nodeVec_ACCESS(pind)) + break; + ++nbp; + double param; + if (j < 2) + { + if (aEdge.IsNull()) + { + int aGeomEdgeInd = seg.epgeominfo[j].edgenr; + if (aGeomEdgeInd > 0 && aGeomEdgeInd <= occgeo.emap.Extent()) + aEdge = TopoDS::Edge(occgeo.emap(aGeomEdgeInd)); + } + param = seg.epgeominfo[j].dist; + param2 += param; + } + else // middle point + { + param = param2 * 0.5; + } + if (!aEdge.IsNull() && nodeVec_ACCESS(pind)->getshapeId() < 1) + { + meshDS->SetNodeOnEdge(nodeVec_ACCESS(pind), aEdge, param); + } + } + if ( nbp > 1 ) + { + SMDS_MeshEdge* edge = 0; + if (nbp == 2) // second order ? + { + if ( meshDS->FindEdge( nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]))) + continue; + edge = meshDS->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1])); + } + else + { + if ( meshDS->FindEdge( nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]), + nodeVec_ACCESS(pinds[2]))) + continue; + edge = meshDS->AddEdge(nodeVec_ACCESS(pinds[0]), nodeVec_ACCESS(pinds[1]), + nodeVec_ACCESS(pinds[2])); + } + if (!edge) + { + if ( comment.empty() ) comment << "Cannot create a mesh edge"; + MESSAGE("Cannot create a mesh edge"); + nbSeg = nbFac = nbVol = 0; + break; + } + if ( !aEdge.IsNull() && edge->getshapeId() < 1 ) + meshDS->SetMeshElementOnShape(edge, aEdge); + } + else if ( comment.empty() ) + { + comment << "Invalid netgen segment #" << i; + } + } + + // ---------------------------------------- + // Create mesh faces along geometric faces + // ---------------------------------------- + + int nbInitFac = initState._nbFaces; + int quadFaceID = ngMesh.GetNFD() + 1; + if ( nbInitFac < nbFac ) + // add a faces descriptor to exclude qudrangle elements generated by NETGEN + // from computation of 3D mesh + ngMesh.AddFaceDescriptor (netgen::FaceDescriptor(quadFaceID, /*solid1=*/0, /*solid2=*/0, 0)); + + for (i = nbInitFac+1; i <= nbFac; ++i ) + { + const netgen::Element2d& elem = ngMesh.SurfaceElement(i); + int aGeomFaceInd = elem.GetIndex(); + TopoDS_Face aFace; + if (aGeomFaceInd > 0 && aGeomFaceInd <= occgeo.fmap.Extent()) + aFace = TopoDS::Face(occgeo.fmap(aGeomFaceInd)); + vector nodes; + for (int j=1; j <= elem.GetNP(); ++j) + { + int pind = elem.PNum(j); + if ( pind < 1 || pind >= nodeVec.size() ) + break; + if ( SMDS_MeshNode* node = nodeVec_ACCESS(pind)) + { + nodes.push_back(node); + if (!aFace.IsNull() && node->getshapeId() < 1) + { + const netgen::PointGeomInfo& pgi = elem.GeomInfoPi(j); + meshDS->SetNodeOnFace(node, aFace, pgi.u, pgi.v); + } + } + } + if ( nodes.size() != elem.GetNP() ) + { + if ( comment.empty() ) + comment << "Invalid netgen 2d element #" << i; + continue; // bad node ids + } + SMDS_MeshFace* face = NULL; + switch (elem.GetType()) + { + case netgen::TRIG: + face = meshDS->AddFace(nodes[0],nodes[1],nodes[2]); + break; + case netgen::QUAD: + face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[3]); + // exclude qudrangle elements from computation of 3D mesh + const_cast< netgen::Element2d& >( elem ).SetIndex( quadFaceID ); + break; + case netgen::TRIG6: + face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[5],nodes[3],nodes[4]); + break; + case netgen::QUAD8: + face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[3], + nodes[4],nodes[7],nodes[5],nodes[6]); + // exclude qudrangle elements from computation of 3D mesh + const_cast< netgen::Element2d& >( elem ).SetIndex( quadFaceID ); + break; + default: + MESSAGE("NETGEN created a face of unexpected type, ignoring"); + continue; + } + if (!face) + { + if ( comment.empty() ) comment << "Cannot create a mesh face"; + MESSAGE("Cannot create a mesh face"); + nbSeg = nbFac = nbVol = 0; + break; + } + if (!aFace.IsNull()) + meshDS->SetMeshElementOnShape(face, aFace); + } + + // ------------------ + // Create tetrahedra + // ------------------ + + for (i = 1; i <= nbVol; ++i) + { + const netgen::Element& elem = ngMesh.VolumeElement(i); + int aSolidInd = elem.GetIndex(); + TopoDS_Solid aSolid; + if (aSolidInd > 0 && aSolidInd <= occgeo.somap.Extent()) + aSolid = TopoDS::Solid(occgeo.somap(aSolidInd)); + vector nodes; + for (int j=1; j <= elem.GetNP(); ++j) + { + int pind = elem.PNum(j); + if ( pind < 1 || pind >= nodeVec.size() ) + break; + if ( SMDS_MeshNode* node = nodeVec_ACCESS(pind) ) + { + nodes.push_back(node); + if ( !aSolid.IsNull() && node->getshapeId() < 1 ) + meshDS->SetNodeInVolume(node, aSolid); + } + } + if ( nodes.size() != elem.GetNP() ) + { + if ( comment.empty() ) + comment << "Invalid netgen 3d element #" << i; + continue; + } + SMDS_MeshVolume* vol = NULL; + switch (elem.GetType()) + { + case netgen::TET: + vol = meshDS->AddVolume(nodes[0],nodes[1],nodes[2],nodes[3]); + break; + case netgen::TET10: + vol = meshDS->AddVolume(nodes[0],nodes[1],nodes[2],nodes[3], + nodes[4],nodes[7],nodes[5],nodes[6],nodes[8],nodes[9]); + break; + default: + MESSAGE("NETGEN created a volume of unexpected type, ignoring"); + continue; + } + if (!vol) + { + if ( comment.empty() ) comment << "Cannot create a mesh volume"; + MESSAGE("Cannot create a mesh volume"); + nbSeg = nbFac = nbVol = 0; + break; + } + if (!aSolid.IsNull()) + meshDS->SetMeshElementOnShape(vol, aSolid); + } + return comment.empty() ? 0 : 1; +} + +namespace +{ + //================================================================================ + /*! + * \brief Restrict size of elements on the given edge + */ + //================================================================================ + + void setLocalSize(const TopoDS_Edge& edge, + double size, + netgen::Mesh& mesh) + { + const int nb = 1000; + Standard_Real u1, u2; + Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, u1, u2); + if ( curve.IsNull() ) + { + TopoDS_Iterator vIt( edge ); + if ( !vIt.More() ) return; + gp_Pnt p = BRep_Tool::Pnt( TopoDS::Vertex( vIt.Value() )); + NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size ); + } + else + { + Standard_Real delta = (u2-u1)/nb; + for(int i=0; iValue(u); + NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), size ); + netgen::Point3d pi(p.X(), p.Y(), p.Z()); + double resultSize = mesh.GetH(pi); + if ( resultSize - size > 0.1*size ) + // netgen does restriction iff oldH/newH > 1.2 (localh.cpp:136) + NETGENPlugin_Mesher::RestrictLocalSize( mesh, p.XYZ(), resultSize/1.201 ); + } + } + } + + //================================================================================ + /*! + * \brief Convert error into text + */ + //================================================================================ + + std::string text(int err) + { + if ( !err ) + return string(""); + return + SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task; + } + + //================================================================================ + /*! + * \brief Convert exception into text + */ + //================================================================================ + + std::string text(Standard_Failure& ex) + { + SMESH_Comment str("Exception in netgen::OCCGenerateMesh()"); + str << " at " << netgen::multithread.task + << ": " << ex.DynamicType()->Name(); + if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) + str << ": " << ex.GetMessageString(); + return str; + } + //================================================================================ + /*! + * \brief Convert exception into text + */ + //================================================================================ + + std::string text(netgen::NgException& ex) + { + SMESH_Comment str("NgException"); + str << " at " << netgen::multithread.task << ": " << ex.What(); + return str; + } +} + //============================================================================= /*! * Here we are going to use the NETGEN mesher */ //============================================================================= + bool NETGENPlugin_Mesher::Compute() { -#ifdef WNT - netgen::MeshingParameters& mparams = netgen::GlobalMeshingParameters(); -#else + NETGENPlugin_NetgenLibWrapper ngLib; + netgen::MeshingParameters& mparams = netgen::mparam; -#endif MESSAGE("Compute with:\n" " max size = " << mparams.maxh << "\n" " segments per edge = " << mparams.segmentsperedge); @@ -513,76 +1822,220 @@ bool NETGENPlugin_Mesher::Compute() " elements per radius = " << mparams.curvaturesafety << "\n" " second order = " << mparams.secondorder << "\n" " quad allowed = " << mparams.quad); + cout << " quad allowed = " << mparams.quad< meshedSM; - PrepareOCCgeometry( occgeo, _shape, *_mesh, &meshedSM ); + list< SMESH_subMesh* > meshedSM[3]; // for 0-2 dimensions + NETGENPlugin_Internals internals( *_mesh, _shape, _isVolume ); + PrepareOCCgeometry( occgeo, _shape, *_mesh, meshedSM, &internals ); // ------------------------- // Generate the mesh // ------------------------- netgen::Mesh *ngMesh = NULL; + NETGENPlugin_ngMeshInfo initState; // it remembers size of ng mesh equal to size of Smesh SMESH_Comment comment; int err = 0; - int nbInitNod = 0; - int nbInitSeg = 0; - int nbInitFac = 0; + // vector of nodes in which node index == netgen ID - vector< SMDS_MeshNode* > nodeVec; - try + vector< const SMDS_MeshNode* > nodeVec; + { // ---------------- // compute 1D mesh // ---------------- - // pass 1D simple parameters to NETGEN - if ( _simpleHyp ) { - if ( int nbSeg = _simpleHyp->GetNumberOfSegments() ) { + if ( _simpleHyp ) + { + // not to RestrictLocalH() according to curvature during MESHCONST_ANALYSE + mparams.uselocalh = false; + mparams.grading = 0.8; // not limitited size growth + + if ( _simpleHyp->GetNumberOfSegments() ) // nb of segments - mparams.segmentsperedge = nbSeg + 0.1; mparams.maxh = occgeo.boundingbox.Diam(); - mparams.grading = 0; - } - else { + else // segment length - mparams.segmentsperedge = 1; mparams.maxh = _simpleHyp->GetLocalLength(); - } } - // let netgen create ngMesh and calculate element size on not meshed shapes + + if ( mparams.maxh == 0.0 ) + mparams.maxh = occgeo.boundingbox.Diam(); + if ( _simpleHyp || ( mparams.minh == 0.0 && _fineness != NETGENPlugin_Hypothesis::UserDefined)) + mparams.minh = GetDefaultMinSize( _shape, mparams.maxh ); + +#ifdef NETGEN_NEW + // Local size on faces + occgeo.face_maxh = mparams.maxh; +#endif + + // Let netgen create ngMesh and calculate element size on not meshed shapes char *optstr = 0; int startWith = netgen::MESHCONST_ANALYSE; int endWith = netgen::MESHCONST_ANALYSE; - err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); - if (err) comment << "Error in netgen::OCCGenerateMesh() at MESHCONST_ANALYSE step"; + try + { + OCC_CATCH_SIGNALS; + err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + comment << text(err); + } + catch (Standard_Failure& ex) + { + comment << text(ex); + } + err = 0; //- MESHCONST_ANALYSE isn't so important step + if ( !ngMesh ) + return false; + ngLib.setMesh(( Ng_Mesh*) ngMesh ); - // fill ngMesh with nodes and elements of computed submeshes - err = ! fillNgMesh(occgeo, *ngMesh, nodeVec, meshedSM); - nbInitNod = ngMesh->GetNP(); - nbInitSeg = ngMesh->GetNSeg(); - nbInitFac = ngMesh->GetNSE(); + ngMesh->ClearFaceDescriptors(); // we make descriptors our-self - // compute mesh + if ( _simpleHyp ) + { + // Pass 1D simple parameters to NETGEN + // -------------------------------- + int nbSeg = _simpleHyp->GetNumberOfSegments(); + double segSize = _simpleHyp->GetLocalLength(); + for ( int iE = 1; iE <= occgeo.emap.Extent(); ++iE ) + { + const TopoDS_Edge& e = TopoDS::Edge( occgeo.emap(iE)); + if ( nbSeg ) + segSize = SMESH_Algo::EdgeLength( e ) / ( nbSeg - 0.4 ); + setLocalSize( e, segSize, *ngMesh ); + } + } + else // if ( ! _simpleHyp ) + { + // Local size on vertices and edges + // -------------------------------- + for(std::map::const_iterator it=EdgeId2LocalSize.begin(); it!=EdgeId2LocalSize.end(); it++) + { + int key = (*it).first; + double hi = (*it).second; + const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key); + const TopoDS_Edge& e = TopoDS::Edge(shape); + setLocalSize( e, hi, *ngMesh ); + } + for(std::map::const_iterator it=VertexId2LocalSize.begin(); it!=VertexId2LocalSize.end(); it++) + { + int key = (*it).first; + double hi = (*it).second; + const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key); + const TopoDS_Vertex& v = TopoDS::Vertex(shape); + gp_Pnt p = BRep_Tool::Pnt(v); + NETGENPlugin_Mesher::RestrictLocalSize( *ngMesh, p.XYZ(), hi ); + } + for(map::const_iterator it=FaceId2LocalSize.begin(); + it!=FaceId2LocalSize.end(); it++) + { + int key = (*it).first; + double val = (*it).second; + const TopoDS_Shape& shape = ShapesWithLocalSize.FindKey(key); + int faceNgID = occgeo.fmap.FindIndex(shape); + occgeo.SetFaceMaxH(faceNgID, val); + for ( TopExp_Explorer edgeExp( shape, TopAbs_EDGE ); edgeExp.More(); edgeExp.Next() ) + setLocalSize( TopoDS::Edge( edgeExp.Current() ), val, *ngMesh ); + } + } + + // Precompute internal edges (issue 0020676) in order to + // add mesh on them correctly (twice) to netgen mesh + if ( !err && internals.hasInternalEdges() ) + { + // load internal shapes into OCCGeometry + netgen::OCCGeometry intOccgeo; + internals.getInternalEdges( intOccgeo.fmap, intOccgeo.emap, intOccgeo.vmap, meshedSM ); + intOccgeo.boundingbox = occgeo.boundingbox; + intOccgeo.shape = occgeo.shape; +#ifdef NETGEN_NEW + intOccgeo.face_maxh.SetSize(intOccgeo.fmap.Extent()); + intOccgeo.face_maxh = netgen::mparam.maxh; +#endif + netgen::Mesh *tmpNgMesh = NULL; + try + { + OCC_CATCH_SIGNALS; + // compute local H on internal shapes in the main mesh + //OCCSetLocalMeshSize(intOccgeo, *ngMesh); it deletes ngMesh->localH + + // let netgen create a temporary mesh + netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + // copy LocalH from the main to temporary mesh + initState.transferLocalH( ngMesh, tmpNgMesh ); + + // compute mesh on internal edges + startWith = endWith = netgen::MESHCONST_MESHEDGES; + err = netgen::OCCGenerateMesh(intOccgeo, tmpNgMesh, startWith, endWith, optstr); + comment << text(err); + } + catch (Standard_Failure& ex) + { + comment << text(ex); + err = 1; + } + initState.restoreLocalH( tmpNgMesh ); + + // fill SMESH by netgen mesh + vector< const SMDS_MeshNode* > tmpNodeVec; + FillSMesh( intOccgeo, *tmpNgMesh, initState, *_mesh, tmpNodeVec, comment ); + err = ( err || !comment.empty() ); + + nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)tmpNgMesh); + } + + // Fill ngMesh with nodes and segments of computed submeshes + if ( !err ) + { + _faceDescriptors.clear(); + err = ! ( fillNgMesh(occgeo, *ngMesh, nodeVec, meshedSM[ MeshDim_0D ]) && + fillNgMesh(occgeo, *ngMesh, nodeVec, meshedSM[ MeshDim_1D ])); + } + initState = NETGENPlugin_ngMeshInfo(ngMesh); + + // Compute 1d mesh if (!err) { startWith = endWith = netgen::MESHCONST_MESHEDGES; - err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); - if (err) comment << "Error in netgen::OCCGenerateMesh() at 1D mesh generation"; + try + { + OCC_CATCH_SIGNALS; + err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + comment << text(err); + } + catch (Standard_Failure& ex) + { + comment << text(ex); + err = 1; + } } + mparams.uselocalh = true; // restore as it is used at surface optimization + // --------------------- // compute surface mesh // --------------------- if (!err) { - // pass 2D simple parameters to NETGEN + // Pass 2D simple parameters to NETGEN if ( _simpleHyp ) { if ( double area = _simpleHyp->GetMaxElementArea() ) { // face area @@ -591,41 +2044,104 @@ bool NETGENPlugin_Mesher::Compute() } else { // length from edges - double length = 0; - for ( TopExp_Explorer exp( _shape, TopAbs_EDGE ); exp.More(); exp.Next() ) - length += SMESH_Algo::EdgeLength( TopoDS::Edge( exp.Current() )); - if ( ngMesh->GetNSeg() ) - mparams.maxh = length / ngMesh->GetNSeg(); - else + if ( ngMesh->GetNSeg() ) { + double edgeLength = 0; + TopTools_MapOfShape visitedEdges; + for ( TopExp_Explorer exp( _shape, TopAbs_EDGE ); exp.More(); exp.Next() ) + if( visitedEdges.Add(exp.Current()) ) + edgeLength += SMESH_Algo::EdgeLength( TopoDS::Edge( exp.Current() )); + // we have to multiply length by 2 since for each TopoDS_Edge there + // are double set of NETGEN edges, in other words, we have to + // divide ngMesh->GetNSeg() by 2. + mparams.maxh = 2*edgeLength / ngMesh->GetNSeg(); + } + else { mparams.maxh = 1000; + } mparams.grading = 0.2; // slow size growth } + mparams.quad = _simpleHyp->GetAllowQuadrangles(); mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 ); ngMesh->SetGlobalH (mparams.maxh); - netgen::Box<3> bb = occgeo.GetBoundingBox(); - bb.Increase (bb.Diam()/20); + netgen::Box<3> bb = occgeo.GetBoundingBox(); + bb.Increase (bb.Diam()/20); ngMesh->SetLocalH (bb.PMin(), bb.PMax(), mparams.grading); } - // let netgen compute 2D mesh + + // Care of vertices internal in faces (issue 0020676) + if ( internals.hasInternalVertexInFace() ) + { + // store computed segments in SMESH in order not to create SMESH + // edges for ng segments added by addIntVerticesInFaces() + FillSMesh( occgeo, *ngMesh, initState, *_mesh, nodeVec, comment ); + // add segments to faces with internal vertices + addIntVerticesInFaces( occgeo, *ngMesh, nodeVec, internals ); + initState = NETGENPlugin_ngMeshInfo(ngMesh); + } + + // Let netgen compute 2D mesh startWith = netgen::MESHCONST_MESHSURFACE; endWith = _optimize ? netgen::MESHCONST_OPTSURFACE : netgen::MESHCONST_MESHSURFACE; - err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); - if (err) comment << "Error in netgen::OCCGenerateMesh() at surface mesh generation"; + try + { + OCC_CATCH_SIGNALS; + err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + comment << text (err); + } + catch (Standard_Failure& ex) + { + comment << text(ex); + //err = 1; -- try to make volumes anyway + } + catch (netgen::NgException exc) + { + comment << text(exc); + //err = 1; -- try to make volumes anyway + } } // --------------------- // generate volume mesh // --------------------- + // Fill ngMesh with nodes and faces of computed 2D submeshes + if ( !err && _isVolume && ( !meshedSM[ MeshDim_2D ].empty() || mparams.quad )) + { + // load SMESH with computed segments and faces + FillSMesh( occgeo, *ngMesh, initState, *_mesh, nodeVec, comment ); + + // compute pyramids on quadrangles + SMESH_ProxyMesh::Ptr proxyMesh; + if ( _mesh->NbQuadrangles() > 0 ) + for ( int iS = 1; iS <= occgeo.somap.Extent(); ++iS ) + { + StdMeshers_QuadToTriaAdaptor* Adaptor = new StdMeshers_QuadToTriaAdaptor; + proxyMesh.reset( Adaptor ); + + int nbPyrams = _mesh->NbPyramids(); + Adaptor->Compute( *_mesh, occgeo.somap(iS) ); + if ( nbPyrams != _mesh->NbPyramids() ) + { + list< SMESH_subMesh* > quadFaceSM; + for (TopExp_Explorer face(occgeo.somap(iS), TopAbs_FACE); face.More(); face.Next()) + if ( Adaptor->GetProxySubMesh( face.Current() )) + { + quadFaceSM.push_back( _mesh->GetSubMesh( face.Current() )); + meshedSM[ MeshDim_2D ].remove( quadFaceSM.back() ); + } + fillNgMesh(occgeo, *ngMesh, nodeVec, quadFaceSM, proxyMesh); + } + } + // fill ngMesh with faces of sub-meshes + err = ! ( fillNgMesh(occgeo, *ngMesh, nodeVec, meshedSM[ MeshDim_2D ])); + initState = NETGENPlugin_ngMeshInfo(ngMesh); + //toPython( ngMesh, "/tmp/ngPython.py"); + } if (!err && _isVolume) { - // add ng face descriptors of meshed faces - std::map< int, std::pair >::iterator fId_soIds = _faceDescriptors.begin(); - for ( ; fId_soIds != _faceDescriptors.end(); ++fId_soIds ) { - int faceID = fId_soIds->first; - int solidID1 = fId_soIds->second.first; - int solidID2 = fId_soIds->second.second; - ngMesh->AddFaceDescriptor (netgen::FaceDescriptor(faceID, solidID1, solidID2, 0)); - } - // pass 3D simple parameters to NETGEN + // Pass 3D simple parameters to NETGEN const NETGENPlugin_SimpleHypothesis_3D* simple3d = dynamic_cast< const NETGENPlugin_SimpleHypothesis_3D* > ( _simpleHyp ); if ( simple3d ) { @@ -638,265 +2154,135 @@ bool NETGENPlugin_Mesher::Compute() // length from faces mparams.maxh = ngMesh->AverageH(); } -// netgen::ARRAY maxhdom; -// maxhdom.SetSize (occgeo.NrSolids()); -// maxhdom = mparams.maxh; -// ngMesh->SetMaxHDomain (maxhdom); ngMesh->SetGlobalH (mparams.maxh); mparams.grading = 0.4; ngMesh->CalcLocalH(); } - // let netgen compute 3D mesh - startWith = netgen::MESHCONST_MESHVOLUME; - endWith = _optimize ? netgen::MESHCONST_OPTVOLUME : netgen::MESHCONST_MESHVOLUME; - err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); - if (err) comment << "Error in netgen::OCCGenerateMesh()"; + // Care of vertices internal in solids and internal faces (issue 0020676) + if ( internals.hasInternalVertexInSolid() || internals.hasInternalFaces() ) + { + // store computed faces in SMESH in order not to create SMESH + // faces for ng faces added here + FillSMesh( occgeo, *ngMesh, initState, *_mesh, nodeVec, comment ); + // add ng faces to solids with internal vertices + addIntVerticesInSolids( occgeo, *ngMesh, nodeVec, internals ); + // duplicate mesh faces on internal faces + fixIntFaces( occgeo, *ngMesh, internals ); + initState = NETGENPlugin_ngMeshInfo(ngMesh); + } + // Let netgen compute 3D mesh + startWith = endWith = netgen::MESHCONST_MESHVOLUME; + try + { + OCC_CATCH_SIGNALS; + err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + if ( comment.empty() ) // do not overwrite a previos error + comment << text(err); + } + catch (Standard_Failure& ex) + { + if ( comment.empty() ) // do not overwrite a previos error + comment << text(ex); + err = 1; + } + catch (netgen::NgException exc) + { + if ( comment.empty() ) // do not overwrite a previos error + comment << text(exc); + err = 1; + } + // Let netgen optimize 3D mesh + if ( !err && _optimize ) + { + startWith = endWith = netgen::MESHCONST_OPTVOLUME; + try + { + OCC_CATCH_SIGNALS; + err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + if ( comment.empty() ) // do not overwrite a previos error + comment << text(err); + } + catch (Standard_Failure& ex) + { + if ( comment.empty() ) // do not overwrite a previos error + comment << text(ex); + } + catch (netgen::NgException exc) + { + if ( comment.empty() ) // do not overwrite a previos error + comment << text(exc); + } + } } if (!err && mparams.secondorder > 0) { - netgen::OCCRefinementSurfaces ref (occgeo); - ref.MakeSecondOrder (*ngMesh); + try + { + OCC_CATCH_SIGNALS; + netgen::OCCRefinementSurfaces ref (occgeo); + ref.MakeSecondOrder (*ngMesh); + } + catch (Standard_Failure& ex) + { + if ( comment.empty() ) // do not overwrite a previos error + comment << "Exception in netgen at passing to 2nd order "; + } + catch (netgen::NgException exc) + { + if ( comment.empty() ) // do not overwrite a previos error + comment << exc.What(); + } } } - catch (netgen::NgException exc) - { - error->myName = err = COMPERR_ALGO_FAILED; - comment << exc.What(); - } - int nbNod = ngMesh->GetNP(); int nbSeg = ngMesh->GetNSeg(); int nbFac = ngMesh->GetNSE(); int nbVol = ngMesh->GetNE(); + bool isOK = ( !err && (_isVolume ? (nbVol > 0) : (nbFac > 0)) ); MESSAGE((err ? "Mesh Generation failure" : "End of Mesh Generation") << - ", nb nodes: " << nbNod << + ", nb nodes: " << nbNod << ", nb segments: " << nbSeg << - ", nb faces: " << nbFac << - ", nb volumes: " << nbVol); + ", nb faces: " << nbFac << + ", nb volumes: " << nbVol); - // ----------------------------------------------------------- // Feed back the SMESHDS with the generated Nodes and Elements - // ----------------------------------------------------------- - - SMESHDS_Mesh* meshDS = _mesh->GetMeshDS(); - bool isOK = ( !err && (_isVolume ? (nbVol > 0) : (nbFac > 0)) ); if ( true /*isOK*/ ) // get whatever built - { - // map of nodes assigned to submeshes - NCollection_Map pindMap; - // create and insert nodes into nodeVec - nodeVec.resize( nbNod + 1 ); - int i; - for (i = nbInitNod+1; i <= nbNod /*&& isOK*/; ++i ) - { - const netgen::MeshPoint& ngPoint = ngMesh->Point(i); - SMDS_MeshNode* node = NULL; - bool newNodeOnVertex = false; - TopoDS_Vertex aVert; - if (i-nbInitNod <= occgeo.vmap.Extent()) - { - // point on vertex - aVert = TopoDS::Vertex(occgeo.vmap(i-nbInitNod)); - SMESHDS_SubMesh * submesh = meshDS->MeshElements(aVert); - if (submesh) - { - SMDS_NodeIteratorPtr it = submesh->GetNodes(); - if (it->more()) - { - node = const_cast (it->next()); - pindMap.Add(i); - } - } - if (!node) - newNodeOnVertex = true; - } - if (!node) - node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z()); - if (!node) - { - MESSAGE("Cannot create a mesh node"); - if ( !comment.size() ) comment << "Cannot create a mesh node"; - nbSeg = nbFac = nbVol = isOK = 0; - break; - } - nodeVec.at(i) = node; - if (newNodeOnVertex) - { - // point on vertex - meshDS->SetNodeOnVertex(node, aVert); - pindMap.Add(i); - } - } + FillSMesh( occgeo, *ngMesh, initState, *_mesh, nodeVec, comment ); //!< - // create mesh segments along geometric edges - NCollection_Map linkMap; - for (i = nbInitSeg+1; i <= nbSeg/* && isOK*/; ++i ) - { - const netgen::Segment& seg = ngMesh->LineSegment(i); - Link link(seg.p1, seg.p2); - if (linkMap.Contains(link)) - continue; - linkMap.Add(link); - TopoDS_Edge aEdge; - int pinds[3] = { seg.p1, seg.p2, seg.pmid }; - int nbp = 0; - double param2 = 0; - for (int j=0; j < 3; ++j) - { - int pind = pinds[j]; - if (pind <= 0) continue; - ++nbp; - double param; - if (j < 2) - { - if (aEdge.IsNull()) - { - int aGeomEdgeInd = seg.epgeominfo[j].edgenr; - if (aGeomEdgeInd > 0 && aGeomEdgeInd <= occgeo.emap.Extent()) - aEdge = TopoDS::Edge(occgeo.emap(aGeomEdgeInd)); - } - param = seg.epgeominfo[j].dist; - param2 += param; - } - else - param = param2 * 0.5; - if (pind <= nbInitNod || pindMap.Contains(pind)) - continue; - if (!aEdge.IsNull()) - { - meshDS->SetNodeOnEdge(nodeVec.at(pind), aEdge, param); - pindMap.Add(pind); - } - } - SMDS_MeshEdge* edge; - if (nbp < 3) // second order ? - edge = meshDS->AddEdge(nodeVec.at(pinds[0]), nodeVec.at(pinds[1])); - else - edge = meshDS->AddEdge(nodeVec.at(pinds[0]), nodeVec.at(pinds[1]), - nodeVec.at(pinds[2])); - if (!edge) - { - if ( !comment.size() ) comment << "Cannot create a mesh edge"; - MESSAGE("Cannot create a mesh edge"); - nbSeg = nbFac = nbVol = isOK = 0; - break; - } - if (!aEdge.IsNull()) - meshDS->SetMeshElementOnShape(edge, aEdge); - } - - // create mesh faces along geometric faces - for (i = nbInitFac+1; i <= nbFac/* && isOK*/; ++i ) - { - const netgen::Element2d& elem = ngMesh->SurfaceElement(i); - int aGeomFaceInd = elem.GetIndex(); - TopoDS_Face aFace; - if (aGeomFaceInd > 0 && aGeomFaceInd <= occgeo.fmap.Extent()) - aFace = TopoDS::Face(occgeo.fmap(aGeomFaceInd)); - vector nodes; - for (int j=1; j <= elem.GetNP(); ++j) - { - int pind = elem.PNum(j); - SMDS_MeshNode* node = nodeVec.at(pind); - nodes.push_back(node); - if (pind <= nbInitNod || pindMap.Contains(pind)) - continue; - if (!aFace.IsNull()) - { - const netgen::PointGeomInfo& pgi = elem.GeomInfoPi(j); - meshDS->SetNodeOnFace(node, aFace, pgi.u, pgi.v); - pindMap.Add(pind); - } - } - SMDS_MeshFace* face = NULL; - switch (elem.GetType()) - { - case netgen::TRIG: - face = meshDS->AddFace(nodes[0],nodes[1],nodes[2]); - break; - case netgen::QUAD: - face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[3]); - break; - case netgen::TRIG6: - face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[5],nodes[3],nodes[4]); - break; - case netgen::QUAD8: - face = meshDS->AddFace(nodes[0],nodes[1],nodes[2],nodes[3], - nodes[4],nodes[7],nodes[5],nodes[6]); - break; - default: - MESSAGE("NETGEN created a face of unexpected type, ignoring"); - continue; - } - if (!face) - { - if ( !comment.size() ) comment << "Cannot create a mesh face"; - MESSAGE("Cannot create a mesh face"); - nbSeg = nbFac = nbVol = isOK = 0; - break; - } - if (!aFace.IsNull()) - meshDS->SetMeshElementOnShape(face, aFace); - } - - // create tetrahedra - for (i = 1; i <= nbVol/* && isOK*/; ++i) - { - const netgen::Element& elem = ngMesh->VolumeElement(i); - int aSolidInd = elem.GetIndex(); - TopoDS_Solid aSolid; - if (aSolidInd > 0 && aSolidInd <= occgeo.somap.Extent()) - aSolid = TopoDS::Solid(occgeo.somap(aSolidInd)); - vector nodes; - for (int j=1; j <= elem.GetNP(); ++j) - { - int pind = elem.PNum(j); - SMDS_MeshNode* node = nodeVec.at(pind); - nodes.push_back(node); - if (pind <= nbInitNod || pindMap.Contains(pind)) - continue; - if (!aSolid.IsNull()) - { - // point in solid - meshDS->SetNodeInVolume(node, aSolid); - pindMap.Add(pind); - } - } - SMDS_MeshVolume* vol = NULL; - switch (elem.GetType()) - { - case netgen::TET: - vol = meshDS->AddVolume(nodes[0],nodes[1],nodes[2],nodes[3]); - break; - case netgen::TET10: - vol = meshDS->AddVolume(nodes[0],nodes[1],nodes[2],nodes[3], - nodes[4],nodes[7],nodes[5],nodes[6],nodes[8],nodes[9]); - break; - default: - MESSAGE("NETGEN created a volume of unexpected type, ignoring"); - continue; - } - if (!vol) - { - if ( !comment.size() ) comment << "Cannot create a mesh volume"; - MESSAGE("Cannot create a mesh volume"); - nbSeg = nbFac = nbVol = isOK = 0; - break; - } - if (!aSolid.IsNull()) - meshDS->SetMeshElementOnShape(vol, aSolid); - } - } + SMESH_ComputeErrorPtr readErr = readErrors(nodeVec); + if ( readErr && !readErr->myBadElements.empty() ) + error = readErr; if ( error->IsOK() && ( !isOK || comment.size() > 0 )) error->myName = COMPERR_ALGO_FAILED; if ( !comment.empty() ) error->myComment = comment; - // set bad compute error to subshapes of all failed subshapes shapes - if ( !error->IsOK() && err ) + // SetIsAlwaysComputed( true ) to empty sub-meshes, which + // appear if the geometry contains coincident sub-shape due + // to bool merge_solids = 1; in netgen/libsrc/occ/occgenmesh.cpp + const int nbMaps = 2; + const TopTools_IndexedMapOfShape* geoMaps[nbMaps] = + { & occgeo.vmap, & occgeo.emap/*, & occgeo.fmap*/ }; + for ( int iMap = 0; iMap < nbMaps; ++iMap ) + for (int i = 1; i <= geoMaps[iMap]->Extent(); i++) + if ( SMESH_subMesh* sm = _mesh->GetSubMeshContaining( geoMaps[iMap]->FindKey(i))) + if ( !sm->IsMeshComputed() ) + sm->SetIsAlwaysComputed( true ); + + // set bad compute error to subshapes of all failed sub-shapes + if ( !error->IsOK() ) { + bool pb2D = false, pb3D = false; for (int i = 1; i <= occgeo.fmap.Extent(); i++) { int status = occgeo.facemeshstatus[i-1]; if (status == 1 ) continue; @@ -904,20 +2290,242 @@ bool NETGENPlugin_Mesher::Compute() SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); if ( !smError || smError->IsOK() ) { if ( status == -1 ) - smError.reset( new SMESH_ComputeError( error->myName, error->myComment )); + smError.reset( new SMESH_ComputeError( *error )); else smError.reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED, "Ignored" )); + if ( SMESH_Algo::GetMeshError( sm ) == SMESH_Algo::MEr_OK ) + smError->myName = COMPERR_WARNING; } + pb2D = pb2D || smError->IsKO(); } } + if ( !pb2D ) // all faces are OK + for (int i = 1; i <= occgeo.somap.Extent(); i++) + if ( SMESH_subMesh* sm = _mesh->GetSubMeshContaining( occgeo.somap( i ))) + { + bool smComputed = nbVol && !sm->IsEmpty(); + if ( smComputed && internals.hasInternalVertexInSolid( sm->GetId() )) + { + int nbIntV = internals.getSolidsWithVertices().find( sm->GetId() )->second.size(); + SMESHDS_SubMesh* smDS = sm->GetSubMeshDS(); + smComputed = ( smDS->NbElements() > 0 || smDS->NbNodes() > nbIntV ); + } + SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); + if ( !smComputed && ( !smError || smError->IsOK() )) + { + smError.reset( new SMESH_ComputeError( *error )); + if ( nbVol && SMESH_Algo::GetMeshError( sm ) == SMESH_Algo::MEr_OK ) + smError->myName = COMPERR_WARNING; + } + pb3D = pb3D || ( smError && smError->IsKO() ); + } + if ( !pb2D && !pb3D ) + err = 0; // no fatal errors, only warnings } - nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh); - nglib::Ng_Exit(); + return !err; +} - RemoveTmpFiles(); +//============================================================================= +/*! + * Evaluate + */ +//============================================================================= +bool NETGENPlugin_Mesher::Evaluate(MapShapeNbElems& aResMap) +{ + netgen::MeshingParameters& mparams = netgen::mparam; - return error->IsOK(); + + // ------------------------- + // Prepare OCC geometry + // ------------------------- + netgen::OCCGeometry occgeo; + PrepareOCCgeometry( occgeo, _shape, *_mesh ); + + bool tooManyElems = false; + const int hugeNb = std::numeric_limits::max() / 100; + + // ---------------- + // evaluate 1D + // ---------------- + // pass 1D simple parameters to NETGEN + if ( _simpleHyp ) { + if ( int nbSeg = _simpleHyp->GetNumberOfSegments() ) { + // nb of segments + mparams.segmentsperedge = nbSeg + 0.1; + mparams.maxh = occgeo.boundingbox.Diam(); + mparams.minh = GetDefaultMinSize( _shape, mparams.maxh ); + mparams.grading = 0.01; + } + else { + // segment length + mparams.segmentsperedge = 1; + mparams.maxh = _simpleHyp->GetLocalLength(); + } + } + // let netgen create ngMesh and calculate element size on not meshed shapes + NETGENPlugin_NetgenLibWrapper ngLib; + netgen::Mesh *ngMesh = NULL; + char *optstr = 0; + int startWith = netgen::MESHCONST_ANALYSE; + int endWith = netgen::MESHCONST_MESHEDGES; + int err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + ngLib.setMesh(( Ng_Mesh*) ngMesh ); + if (err) { + if ( SMESH_subMesh* sm = _mesh->GetSubMeshContaining( _shape )) + sm->GetComputeError().reset( new SMESH_ComputeError( COMPERR_ALGO_FAILED )); + return false; + } + + // calculate total nb of segments and length of edges + double fullLen = 0.0; + int fullNbSeg = 0; + int entity = mparams.secondorder > 0 ? SMDSEntity_Quad_Edge : SMDSEntity_Edge; + TopTools_DataMapOfShapeInteger Edge2NbSeg; + for (TopExp_Explorer exp(_shape, TopAbs_EDGE); exp.More(); exp.Next()) + { + TopoDS_Edge E = TopoDS::Edge( exp.Current() ); + if( !Edge2NbSeg.Bind(E,0) ) + continue; + + double aLen = SMESH_Algo::EdgeLength(E); + fullLen += aLen; + + vector& aVec = aResMap[_mesh->GetSubMesh(E)]; + if ( aVec.empty() ) + aVec.resize( SMDSEntity_Last, 0); + else + fullNbSeg += aVec[ entity ]; + } + + // store nb of segments computed by Netgen + NCollection_Map linkMap; + for (int i = 1; i <= ngMesh->GetNSeg(); ++i ) + { + const netgen::Segment& seg = ngMesh->LineSegment(i); + Link link(seg[0], seg[1]); + if ( !linkMap.Add( link )) continue; + int aGeomEdgeInd = seg.epgeominfo[0].edgenr; + if (aGeomEdgeInd > 0 && aGeomEdgeInd <= occgeo.emap.Extent()) + { + vector& aVec = aResMap[_mesh->GetSubMesh(occgeo.emap(aGeomEdgeInd))]; + aVec[ entity ]++; + } + } + // store nb of nodes on edges computed by Netgen + TopTools_DataMapIteratorOfDataMapOfShapeInteger Edge2NbSegIt(Edge2NbSeg); + for (; Edge2NbSegIt.More(); Edge2NbSegIt.Next()) + { + vector& aVec = aResMap[_mesh->GetSubMesh(Edge2NbSegIt.Key())]; + if ( aVec[ entity ] > 1 && aVec[ SMDSEntity_Node ] == 0 ) + aVec[SMDSEntity_Node] = mparams.secondorder > 0 ? 2*aVec[ entity ]-1 : aVec[ entity ]-1; + + fullNbSeg += aVec[ entity ]; + Edge2NbSeg( Edge2NbSegIt.Key() ) = aVec[ entity ]; + } + + // ---------------- + // evaluate 2D + // ---------------- + if ( _simpleHyp ) { + if ( double area = _simpleHyp->GetMaxElementArea() ) { + // face area + mparams.maxh = sqrt(2. * area/sqrt(3.0)); + mparams.grading = 0.4; // moderate size growth + } + else { + // length from edges + mparams.maxh = fullLen/fullNbSeg; + mparams.grading = 0.2; // slow size growth + } + } + mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 ); + mparams.maxh = min( mparams.maxh, fullLen/fullNbSeg * (1. + mparams.grading)); + + for (TopExp_Explorer exp(_shape, TopAbs_FACE); exp.More(); exp.Next()) + { + TopoDS_Face F = TopoDS::Face( exp.Current() ); + SMESH_subMesh *sm = _mesh->GetSubMesh(F); + GProp_GProps G; + BRepGProp::SurfaceProperties(F,G); + double anArea = G.Mass(); + tooManyElems = tooManyElems || ( anArea/hugeNb > mparams.maxh*mparams.maxh ); + int nb1d = 0; + if ( !tooManyElems ) + { + TopTools_MapOfShape egdes; + for (TopExp_Explorer exp1(F,TopAbs_EDGE); exp1.More(); exp1.Next()) + if ( egdes.Add( exp1.Current() )) + nb1d += Edge2NbSeg.Find(exp1.Current()); + } + int nbFaces = tooManyElems ? hugeNb : int( 4*anArea / (mparams.maxh*mparams.maxh*sqrt(3.))); + int nbNodes = tooManyElems ? hugeNb : (( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 ); + + vector aVec(SMDSEntity_Last, 0); + if( mparams.secondorder > 0 ) { + int nb1d_in = (nbFaces*3 - nb1d) / 2; + aVec[SMDSEntity_Node] = nbNodes + nb1d_in; + aVec[SMDSEntity_Quad_Triangle] = nbFaces; + } + else { + aVec[SMDSEntity_Node] = Max ( nbNodes, 0 ); + aVec[SMDSEntity_Triangle] = nbFaces; + } + aResMap[sm].swap(aVec); + } + + // ---------------- + // evaluate 3D + // ---------------- + if(_isVolume) { + // pass 3D simple parameters to NETGEN + const NETGENPlugin_SimpleHypothesis_3D* simple3d = + dynamic_cast< const NETGENPlugin_SimpleHypothesis_3D* > ( _simpleHyp ); + if ( simple3d ) { + if ( double vol = simple3d->GetMaxElementVolume() ) { + // max volume + mparams.maxh = pow( 72, 1/6. ) * pow( vol, 1/3. ); + mparams.maxh = min( mparams.maxh, occgeo.boundingbox.Diam()/2 ); + } + else { + // using previous length from faces + } + mparams.grading = 0.4; + mparams.maxh = min( mparams.maxh, fullLen/fullNbSeg * (1. + mparams.grading)); + } + GProp_GProps G; + BRepGProp::VolumeProperties(_shape,G); + double aVolume = G.Mass(); + double tetrVol = 0.1179*mparams.maxh*mparams.maxh*mparams.maxh; + tooManyElems = tooManyElems || ( aVolume/hugeNb > tetrVol ); + int nbVols = tooManyElems ? hugeNb : int(aVolume/tetrVol); + int nb1d_in = int(( nbVols*6 - fullNbSeg ) / 6 ); + vector aVec(SMDSEntity_Last, 0 ); + if ( tooManyElems ) // avoid FPE + { + aVec[SMDSEntity_Node] = hugeNb; + aVec[ mparams.secondorder > 0 ? SMDSEntity_Quad_Tetra : SMDSEntity_Tetra] = hugeNb; + } + else + { + if( mparams.secondorder > 0 ) { + aVec[SMDSEntity_Node] = nb1d_in/3 + 1 + nb1d_in; + aVec[SMDSEntity_Quad_Tetra] = nbVols; + } + else { + aVec[SMDSEntity_Node] = nb1d_in/3 + 1; + aVec[SMDSEntity_Tetra] = nbVols; + } + } + SMESH_subMesh *sm = _mesh->GetSubMesh(_shape); + aResMap[sm].swap(aVec); + } + + return true; } //================================================================================ @@ -928,12 +2536,584 @@ bool NETGENPlugin_Mesher::Compute() void NETGENPlugin_Mesher::RemoveTmpFiles() { - TCollection_AsciiString str("test.out"); - OSD_Path path1( str ); - OSD_File file1( path1 ); - file1.Remove(); - str = "problemfaces"; - OSD_Path path2( str ); - OSD_File file2( path2 ); - file2.Remove(); + if ( SMESH_File("test.out").remove() && netgen::testout) + { + delete netgen::testout; + netgen::testout = 0; + } + SMESH_File("problemfaces").remove(); + SMESH_File("occmesh.rep").remove(); +} + +//================================================================================ +/*! + * \brief Read mesh entities preventing successful computation from "test.out" file + */ +//================================================================================ + +SMESH_ComputeErrorPtr +NETGENPlugin_Mesher::readErrors(const vector& nodeVec) +{ + SMESH_ComputeErrorPtr err = SMESH_ComputeError::New + (COMPERR_BAD_INPUT_MESH, "Some edges multiple times in surface mesh"); + SMESH_File file("test.out"); + vector two(2); + const char* badEdgeStr = " multiple times in surface mesh"; + const int badEdgeStrLen = strlen( badEdgeStr ); + while( !file.eof() ) + { + if ( strncmp( file, "Edge ", 5 ) == 0 && + file.getInts( two ) && + strncmp( file, badEdgeStr, badEdgeStrLen ) == 0 && + two[0] < nodeVec.size() && two[1] < nodeVec.size()) + { + err->myBadElements.push_back( new SMDS_LinearEdge( nodeVec[ two[0]], nodeVec[ two[1]] )); + file += badEdgeStrLen; + } + else if ( strncmp( file, "Intersecting: ", 14 ) == 0 ) + { +// Intersecting: +// openelement 18 with open element 126 +// 41 36 38 +// 69 70 72 + vector three1(3), three2(3); + file.getLine(); + const char* pos = file; + bool ok = ( strncmp( file, "openelement ", 12 ) == 0 ); + ok = ok && file.getInts( two ); + ok = ok && file.getInts( three1 ); + ok = ok && file.getInts( three2 ); + for ( int i = 0; ok && i < 3; ++i ) + ok = ( three1[i] < nodeVec.size() && nodeVec[ three1[i]]); + for ( int i = 0; ok && i < 3; ++i ) + ok = ( three2[i] < nodeVec.size() && nodeVec[ three2[i]]); + if ( ok ) + { + err->myBadElements.push_back( new SMDS_FaceOfNodes( nodeVec[ three1[0]], + nodeVec[ three1[1]], + nodeVec[ three1[2]])); + err->myBadElements.push_back( new SMDS_FaceOfNodes( nodeVec[ three2[0]], + nodeVec[ three2[1]], + nodeVec[ three2[2]])); + err->myComment = "Intersecting triangles"; + } + else + { + file.setPos( pos ); + } + } + else + { + ++file; + } + } + return err; +} + +//================================================================================ +/*! + * \brief Write a python script creating an equivalent SALOME mesh. + * This is useful to see what mesh is passed as input for the next step of mesh + * generation (of mesh of higher dimension) + */ +//================================================================================ + +void NETGENPlugin_Mesher::toPython( const netgen::Mesh* ngMesh, + const std::string& pyFile) +{ + ofstream outfile(pyFile.c_str(), ios::out); + if ( !outfile ) return; + + outfile << "import smesh, SMESH" << endl + << "mesh = smesh.Mesh()" << endl << endl; + + using namespace netgen; + PointIndex pi; + for (pi = PointIndex::BASE; + pi < ngMesh->GetNP()+PointIndex::BASE; pi++) + { + outfile << "mesh.AddNode( "; + outfile << (*ngMesh)[pi](0) << ", "; + outfile << (*ngMesh)[pi](1) << ", "; + outfile << (*ngMesh)[pi](2) << ")" << endl; + } + + int nbDom = ngMesh->GetNDomains(); + for ( int i = 0; i < nbDom; ++i ) + outfile<< "grp" << i+1 << " = mesh.CreateEmptyGroup( SMESH.FACE, 'domain"<< i+1 << "')"<< endl; + + SurfaceElementIndex sei; + for (sei = 0; sei < ngMesh->GetNSE(); sei++) + { + outfile << "mesh.AddFace([ "; + Element2d sel = (*ngMesh)[sei]; + for (int j = 0; j < sel.GetNP(); j++) + outfile << sel[j] << ( j+1 < sel.GetNP() ? ", " : " ])"); + outfile << endl; + + if ((*ngMesh)[sei].GetIndex()) + { + if ( int dom1 = ngMesh->GetFaceDescriptor((*ngMesh)[sei].GetIndex ()).DomainIn()) + outfile << "grp"<< dom1 <<".Add([ " << (int)sei+1 << " ])" << endl; + if ( int dom2 = ngMesh->GetFaceDescriptor((*ngMesh)[sei].GetIndex ()).DomainOut()) + outfile << "grp"<< dom2 <<".Add([ " << (int)sei+1 << " ])" << endl; + } + } + + for (ElementIndex ei = 0; ei < ngMesh->GetNE(); ei++) + { + Element el = (*ngMesh)[ei]; + outfile << "mesh.AddVolume([ "; + for (int j = 0; j < el.GetNP(); j++) + outfile << el[j] << ( j+1 < el.GetNP() ? ", " : " ])"); + outfile << endl; + } + + for (int i = 1; i <= ngMesh->GetNSeg(); i++) + { + const Segment & seg = ngMesh->LineSegment (i); + outfile << "mesh.AddEdge([ " + << seg[0] << ", " + << seg[1] << " ])" << endl; + } + cout << "Write " << pyFile << endl; +} + +//================================================================================ +/*! + * \brief Constructor of NETGENPlugin_ngMeshInfo + */ +//================================================================================ + +NETGENPlugin_ngMeshInfo::NETGENPlugin_ngMeshInfo( netgen::Mesh* ngMesh): + _copyOfLocalH(0) +{ + if ( ngMesh ) + { + _nbNodes = ngMesh->GetNP(); + _nbSegments = ngMesh->GetNSeg(); + _nbFaces = ngMesh->GetNSE(); + _nbVolumes = ngMesh->GetNE(); + } + else + { + _nbNodes = _nbSegments = _nbFaces = _nbVolumes = 0; + } +} + +//================================================================================ +/*! + * \brief Copy LocalH member from one netgen mesh to another + */ +//================================================================================ + +void NETGENPlugin_ngMeshInfo::transferLocalH( netgen::Mesh* fromMesh, + netgen::Mesh* toMesh ) +{ + if ( !fromMesh->LocalHFunctionGenerated() ) return; + if ( !toMesh->LocalHFunctionGenerated() ) + toMesh->CalcLocalH(); + + const size_t size = sizeof( netgen::LocalH ); + _copyOfLocalH = new char[ size ]; + memcpy( (void*)_copyOfLocalH, (void*)&toMesh->LocalHFunction(), size ); + memcpy( (void*)&toMesh->LocalHFunction(), (void*)&fromMesh->LocalHFunction(), size ); +} + +//================================================================================ +/*! + * \brief Restore LocalH member of a netgen mesh + */ +//================================================================================ + +void NETGENPlugin_ngMeshInfo::restoreLocalH( netgen::Mesh* toMesh ) +{ + if ( _copyOfLocalH ) + { + const size_t size = sizeof( netgen::LocalH ); + memcpy( (void*)&toMesh->LocalHFunction(), (void*)_copyOfLocalH, size ); + delete [] _copyOfLocalH; + _copyOfLocalH = 0; + } +} + +//================================================================================ +/*! + * \brief Find "internal" sub-shapes + */ +//================================================================================ + +NETGENPlugin_Internals::NETGENPlugin_Internals( SMESH_Mesh& mesh, + const TopoDS_Shape& shape, + bool is3D ) + : _mesh( mesh ), _is3D( is3D ) +{ + SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); + + TopExp_Explorer f,e; + for ( f.Init( shape, TopAbs_FACE ); f.More(); f.Next() ) + { + int faceID = meshDS->ShapeToIndex( f.Current() ); + + // find not computed internal edges + + for ( e.Init( f.Current().Oriented(TopAbs_FORWARD), TopAbs_EDGE ); e.More(); e.Next() ) + if ( e.Current().Orientation() == TopAbs_INTERNAL ) + { + SMESH_subMesh* eSM = mesh.GetSubMesh( e.Current() ); + if ( eSM->IsEmpty() ) + { + _e2face.insert( make_pair( eSM->GetId(), faceID )); + for ( TopoDS_Iterator v(e.Current()); v.More(); v.Next() ) + _e2face.insert( make_pair( meshDS->ShapeToIndex( v.Value() ), faceID )); + } + } + + // find internal vertices in a face + set intVV; // issue 0020850 where same vertex is twice in a face + for ( TopoDS_Iterator fSub( f.Current() ); fSub.More(); fSub.Next()) + if ( fSub.Value().ShapeType() == TopAbs_VERTEX ) + { + int vID = meshDS->ShapeToIndex( fSub.Value() ); + if ( intVV.insert( vID ).second ) + _f2v[ faceID ].push_back( vID ); + } + + if ( is3D ) + { + // find internal faces and their subshapes where nodes are to be doubled + // to make a crack with non-sewed borders + + if ( f.Current().Orientation() == TopAbs_INTERNAL ) + { + _intShapes.insert( meshDS->ShapeToIndex( f.Current() )); + + // egdes + list< TopoDS_Shape > edges; + for ( e.Init( f.Current(), TopAbs_EDGE ); e.More(); e.Next()) + if ( SMESH_MesherHelper::NbAncestors( e.Current(), mesh, TopAbs_FACE ) > 1 ) + { + _intShapes.insert( meshDS->ShapeToIndex( e.Current() )); + edges.push_back( e.Current() ); + // find border faces + PShapeIteratorPtr fIt = + SMESH_MesherHelper::GetAncestors( edges.back(),mesh,TopAbs_FACE ); + while ( const TopoDS_Shape* pFace = fIt->next() ) + if ( !pFace->IsSame( f.Current() )) + _borderFaces.insert( meshDS->ShapeToIndex( *pFace )); + } + // vertices + // we consider vertex internal if it is shared by more than one internal edge + list< TopoDS_Shape >::iterator edge = edges.begin(); + for ( ; edge != edges.end(); ++edge ) + for ( TopoDS_Iterator v( *edge ); v.More(); v.Next() ) + { + set internalEdges; + PShapeIteratorPtr eIt = + SMESH_MesherHelper::GetAncestors( v.Value(),mesh,TopAbs_EDGE ); + while ( const TopoDS_Shape* pEdge = eIt->next() ) + { + int edgeID = meshDS->ShapeToIndex( *pEdge ); + if ( isInternalShape( edgeID )) + internalEdges.insert( edgeID ); + } + if ( internalEdges.size() > 1 ) + _intShapes.insert( meshDS->ShapeToIndex( v.Value() )); + } + } + } + } // loop on geom faces + + // find vertices internal in solids + if ( is3D ) + { + for ( TopExp_Explorer so(shape, TopAbs_SOLID); so.More(); so.Next()) + { + int soID = meshDS->ShapeToIndex( so.Current() ); + for ( TopoDS_Iterator soSub( so.Current() ); soSub.More(); soSub.Next()) + if ( soSub.Value().ShapeType() == TopAbs_VERTEX ) + _s2v[ soID ].push_back( meshDS->ShapeToIndex( soSub.Value() )); + } + } +} + +//================================================================================ +/*! + * \brief Find mesh faces on non-internal geom faces sharing internal edge + * some nodes of which are to be doubled to make the second border of the "crack" + */ +//================================================================================ + +void NETGENPlugin_Internals::findBorderElements( TIDSortedElemSet & borderElems ) +{ + if ( _intShapes.empty() ) return; + + SMESH_Mesh& mesh = const_cast(_mesh); + SMESHDS_Mesh* meshDS = mesh.GetMeshDS(); + + // loop on internal geom edges + set::const_iterator intShapeId = _intShapes.begin(); + for ( ; intShapeId != _intShapes.end(); ++intShapeId ) + { + const TopoDS_Shape& s = meshDS->IndexToShape( *intShapeId ); + if ( s.ShapeType() != TopAbs_EDGE ) continue; + + // get internal and non-internal geom faces sharing the internal edge + int intFace = 0; + set::iterator bordFace = _borderFaces.end(); + PShapeIteratorPtr faces = SMESH_MesherHelper::GetAncestors( s, _mesh, TopAbs_FACE ); + while ( const TopoDS_Shape* pFace = faces->next() ) + { + int faceID = meshDS->ShapeToIndex( *pFace ); + if ( isInternalShape( faceID )) + intFace = faceID; + else + bordFace = _borderFaces.insert( faceID ).first; + } + if ( bordFace == _borderFaces.end() || !intFace ) continue; + + // get all links of mesh faces on internal geom face sharing nodes on edge + set< SMESH_OrientedLink > links; //!< links of faces on internal geom face + list suspectFaces[2]; //!< mesh faces on border geom faces + int nbSuspectFaces = 0; + SMESHDS_SubMesh* intFaceSM = meshDS->MeshElements( intFace ); + if ( !intFaceSM || intFaceSM->NbElements() == 0 ) continue; + SMESH_subMeshIteratorPtr smIt = mesh.GetSubMesh( s )->getDependsOnIterator(true,true); + while ( smIt->more() ) + { + SMESHDS_SubMesh* sm = smIt->next()->GetSubMeshDS(); + if ( !sm ) continue; + SMDS_NodeIteratorPtr nIt = sm->GetNodes(); + while ( nIt->more() ) + { + const SMDS_MeshNode* nOnEdge = nIt->next(); + SMDS_ElemIteratorPtr fIt = nOnEdge->GetInverseElementIterator(SMDSAbs_Face); + while ( fIt->more() ) + { + const SMDS_MeshElement* f = fIt->next(); + int nbNodes = f->NbNodes() / ( f->IsQuadratic() ? 2 : 1 ); + if ( intFaceSM->Contains( f )) + { + for ( int i = 0; i < nbNodes; ++i ) + links.insert( SMESH_OrientedLink( f->GetNode(i), f->GetNode((i+1)%nbNodes))); + } + else + { + int nbDblNodes = 0; + for ( int i = 0; i < nbNodes; ++i ) + nbDblNodes += isInternalShape( f->GetNode(i)->getshapeId() ); + if ( nbDblNodes ) + suspectFaces[ nbDblNodes < 2 ].push_back( f ); + nbSuspectFaces++; + } + } + } + } + // suspectFaces[0] having link with same orientation as mesh faces on + // the internal geom face are . suspectFaces[1] have + // only one node on edge , we decide on them later (at the 2nd loop) + // by links of found at the 1st and 2nd loops + set< SMESH_OrientedLink > borderLinks; + for ( int isPostponed = 0; isPostponed < 2; ++isPostponed ) + { + list::iterator fIt = suspectFaces[isPostponed].begin(); + for ( int nbF = 0; fIt != suspectFaces[isPostponed].end(); ++fIt, ++nbF ) + { + const SMDS_MeshElement* f = *fIt; + bool isBorder = false, linkFound = false, borderLinkFound = false; + list< SMESH_OrientedLink > faceLinks; + int nbNodes = f->NbNodes() / ( f->IsQuadratic() ? 2 : 1 ); + for ( int i = 0; i < nbNodes; ++i ) + { + SMESH_OrientedLink link( f->GetNode(i), f->GetNode((i+1)%nbNodes)); + faceLinks.push_back( link ); + if ( !linkFound ) + { + set< SMESH_OrientedLink >::iterator foundLink = links.find( link ); + if ( foundLink != links.end() ) + { + linkFound= true; + isBorder = ( foundLink->_reversed == link._reversed ); + if ( !isBorder && !isPostponed ) break; + faceLinks.pop_back(); + } + else if ( isPostponed && !borderLinkFound ) + { + foundLink = borderLinks.find( link ); + if ( foundLink != borderLinks.end() ) + { + borderLinkFound = true; + isBorder = ( foundLink->_reversed != link._reversed ); + } + } + } + } + if ( isBorder ) + { + borderElems.insert( f ); + borderLinks.insert( faceLinks.begin(), faceLinks.end() ); + } + else if ( !linkFound && !borderLinkFound ) + { + suspectFaces[1].push_back( f ); + if ( nbF > 2 * nbSuspectFaces ) + break; // dead loop protection + } + } + } + } +} + +//================================================================================ +/*! + * \brief put internal shapes in maps and fill in submeshes to precompute + */ +//================================================================================ + +void NETGENPlugin_Internals::getInternalEdges( TopTools_IndexedMapOfShape& fmap, + TopTools_IndexedMapOfShape& emap, + TopTools_IndexedMapOfShape& vmap, + list< SMESH_subMesh* > smToPrecompute[]) +{ + if ( !hasInternalEdges() ) return; + map::const_iterator ev_face = _e2face.begin(); + for ( ; ev_face != _e2face.end(); ++ev_face ) + { + const TopoDS_Shape& ev = _mesh.GetMeshDS()->IndexToShape( ev_face->first ); + const TopoDS_Shape& face = _mesh.GetMeshDS()->IndexToShape( ev_face->second ); + + ( ev.ShapeType() == TopAbs_EDGE ? emap : vmap ).Add( ev ); + fmap.Add( face ); + //cout<<"INTERNAL EDGE or VERTEX "<first<<" on face "<second<first )); + } +} + +//================================================================================ +/*! + * \brief return shapes and submeshes to be meshed and already meshed boundary submeshes + */ +//================================================================================ + +void NETGENPlugin_Internals::getInternalFaces( TopTools_IndexedMapOfShape& fmap, + TopTools_IndexedMapOfShape& emap, + list< SMESH_subMesh* >& intFaceSM, + list< SMESH_subMesh* >& boundarySM) +{ + if ( !hasInternalFaces() ) return; + + // and are for not yet meshed shapes + // is for submeshes of faces + // is for meshed edges and vertices + + intFaceSM.clear(); + boundarySM.clear(); + + set shapeIDs ( _intShapes ); + if ( !_borderFaces.empty() ) + shapeIDs.insert( _borderFaces.begin(), _borderFaces.end() ); + + set::const_iterator intS = shapeIDs.begin(); + for ( ; intS != shapeIDs.end(); ++intS ) + { + SMESH_subMesh* sm = _mesh.GetSubMeshContaining( *intS ); + + if ( sm->GetSubShape().ShapeType() != TopAbs_FACE ) continue; + + intFaceSM.push_back( sm ); + + // add submeshes of not computed internal faces + if ( !sm->IsEmpty() ) continue; + + SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(true,true); + while ( smIt->more() ) + { + sm = smIt->next(); + const TopoDS_Shape& s = sm->GetSubShape(); + + if ( sm->IsEmpty() ) + { + // not yet meshed + switch ( s.ShapeType() ) { + case TopAbs_FACE: fmap.Add ( s ); break; + case TopAbs_EDGE: emap.Add ( s ); break; + default:; + } + } + else + { + if ( s.ShapeType() != TopAbs_FACE ) + boundarySM.push_back( sm ); + } + } + } +} + +//================================================================================ +/*! + * \brief Return true if given shape is to be precomputed in order to be correctly + * added to netgen mesh + */ +//================================================================================ + +bool NETGENPlugin_Internals::isShapeToPrecompute(const TopoDS_Shape& s) +{ + int shapeID = _mesh.GetMeshDS()->ShapeToIndex( s ); + switch ( s.ShapeType() ) { + case TopAbs_FACE : break; //return isInternalShape( shapeID ) || isBorderFace( shapeID ); + case TopAbs_EDGE : return isInternalEdge( shapeID ); + case TopAbs_VERTEX: break; + default:; + } + return false; +} + +//================================================================================ +/*! + * \brief Return SMESH + */ +//================================================================================ + +SMESH_Mesh& NETGENPlugin_Internals::getMesh() const +{ + return const_cast( _mesh ); +} + +//================================================================================ +/*! + * \brief Initialize netgen library + */ +//================================================================================ + +NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper() +{ + Ng_Init(); + _ngMesh = Ng_NewMesh(); +} + +//================================================================================ +/*! + * \brief Finish using netgen library + */ +//================================================================================ + +NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper() +{ + Ng_DeleteMesh( _ngMesh ); + Ng_Exit(); + NETGENPlugin_Mesher::RemoveTmpFiles(); +} + +//================================================================================ +/*! + * \brief Set netgen mesh to delete at destruction + */ +//================================================================================ + +void NETGENPlugin_NetgenLibWrapper::setMesh( Ng_Mesh* mesh ) +{ + if ( _ngMesh ) + Ng_DeleteMesh( _ngMesh ); + _ngMesh = mesh; } diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx index 4cea643..a525ea7 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx @@ -1,52 +1,82 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_Mesher.hxx // Author : Michael Sazonov (OCN) // Date : 31/03/2006 // Project : SALOME -// $Header$ -//============================================================================= // #ifndef _NETGENPlugin_Mesher_HXX_ #define _NETGENPlugin_Mesher_HXX_ #include "NETGENPlugin_Defs.hxx" -#include "StdMeshers_FaceSide.hxx" + +#include +#include +#include +#include + +namespace nglib { +#include +} + #include +#include +#include class SMESH_Mesh; +class SMESH_Comment; class SMESHDS_Mesh; class TopoDS_Shape; +class TopTools_DataMapOfShapeShape; +class TopTools_IndexedMapOfShape; class NETGENPlugin_Hypothesis; class NETGENPlugin_SimpleHypothesis_2D; +class NETGENPlugin_Internals; namespace netgen { class OCCGeometry; class Mesh; } +//============================================================================= +/*! + * \brief Struct storing nb of entities in netgen mesh + */ +//============================================================================= +struct NETGENPlugin_ngMeshInfo +{ + int _nbNodes, _nbSegments, _nbFaces, _nbVolumes; + char* _copyOfLocalH; + NETGENPlugin_ngMeshInfo( netgen::Mesh* ngMesh=0); + void transferLocalH( netgen::Mesh* fromMesh, netgen::Mesh* toMesh ); + void restoreLocalH ( netgen::Mesh* ngMesh); +}; + +//============================================================================= /*! * \brief This class calls the NETGEN mesher of OCC geometry */ +//============================================================================= class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher { @@ -56,36 +86,155 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher NETGENPlugin_Mesher (SMESH_Mesh* mesh, const TopoDS_Shape& aShape, const bool isVolume); - void SetParameters(const NETGENPlugin_Hypothesis* hyp); + void SetParameters(const NETGENPlugin_Hypothesis* hyp); void SetParameters(const NETGENPlugin_SimpleHypothesis_2D* hyp); bool Compute(); + bool Evaluate(MapShapeNbElems& aResMap); + static void PrepareOCCgeometry(netgen::OCCGeometry& occgeom, const TopoDS_Shape& shape, SMESH_Mesh& mesh, - std::list< SMESH_subMesh* > * meshedSM=0); + std::list< SMESH_subMesh* > * meshedSM=0, + NETGENPlugin_Internals* internalShapes=0); - static void RemoveTmpFiles(); + static double GetDefaultMinSize(const TopoDS_Shape& shape, + const double maxSize); -protected: + static void RestrictLocalSize(netgen::Mesh& ngMesh, const gp_XYZ& p, const double size); + + static int FillSMesh(const netgen::OCCGeometry& occgeom, + netgen::Mesh& ngMesh, + const NETGENPlugin_ngMeshInfo& initState, + SMESH_Mesh& sMesh, + std::vector& nodeVec, + SMESH_Comment& comment); bool fillNgMesh(netgen::OCCGeometry& occgeom, netgen::Mesh& ngMesh, - std::vector& nodeVec, - const std::list< SMESH_subMesh* > & meshedSM); + std::vector& nodeVec, + const std::list< SMESH_subMesh* > & meshedSM, + SMESH_ProxyMesh::Ptr proxyMesh=SMESH_ProxyMesh::Ptr()); + + static void fixIntFaces(const netgen::OCCGeometry& occgeom, + netgen::Mesh& ngMesh, + NETGENPlugin_Internals& internalShapes); + + static void addIntVerticesInFaces(const netgen::OCCGeometry& occgeom, + netgen::Mesh& ngMesh, + std::vector& nodeVec, + NETGENPlugin_Internals& internalShapes); + + static void addIntVerticesInSolids(const netgen::OCCGeometry& occgeom, + netgen::Mesh& ngMesh, + std::vector& nodeVec, + NETGENPlugin_Internals& internalShapes); void defaultParameters(); + static void RemoveTmpFiles(); + + static SMESH_ComputeErrorPtr readErrors(const std::vector< const SMDS_MeshNode* >& nodeVec); + + + static void toPython( const netgen::Mesh* ngMesh, + const std::string& pyFile); // debug private: SMESH_Mesh* _mesh; const TopoDS_Shape& _shape; bool _isVolume; bool _optimize; + int _fineness; const NETGENPlugin_SimpleHypothesis_2D * _simpleHyp; std::map< int, std::pair > _faceDescriptors; }; +//============================================================================= +/*! + * \brief Container of info needed to solve problems with internal shapes. + * + * Issue 0020676. It is made up as a class to be ready to extract from NETGEN + * and put in SMESH as soon as the same solution is needed somewhere else. + * The approach is to precompute internal edges in 2D and internal faces in 3D + * and put their mesh correctly (twice) into netgen mesh. + * In 2D, this class finds internal edges in faces and their vertices. + * In 3D, it additionally finds internal faces, their edges shared with other faces, + * and their vertices shared by several internal edges. Nodes built on the found + * shapes and mesh faces built on the found internal faces are to be doubled in + * netgen mesh to emulate a "crack" + * + * For internal faces a more simple solution is found, which is just to duplicate + * mesh faces on internal geom faces without modeling a "real crack". For this + * reason findBorderElements() is no more used anywhere. + */ +//============================================================================= + +class NETGENPLUGIN_EXPORT NETGENPlugin_Internals +{ + SMESH_Mesh& _mesh; + bool _is3D; + //2D + std::map _e2face;//! > _f2v;//! _intShapes; + std::set _borderFaces; //!< non-internal faces sharing the internal edge + std::map > _s2v;//!& getEdgesAndVerticesWithFaces() const { return _e2face; } + void getInternalEdges( TopTools_IndexedMapOfShape& fmap, + TopTools_IndexedMapOfShape& emap, + TopTools_IndexedMapOfShape& vmap, + std::list< SMESH_subMesh* > smToPrecompute[]); + // vertices + bool hasInternalVertexInFace() const { return !_f2v.empty(); } + const std::map >& getFacesWithVertices() const { return _f2v; } + + // 3D meshing + // faces + bool hasInternalFaces() const { return !_intShapes.empty(); } + bool isInternalShape( int id ) const { return _intShapes.count( id ); } + void findBorderElements( std::set< const SMDS_MeshElement*, TIDCompare > & borderElems ); + bool isBorderFace( int faceID ) const { return _borderFaces.count( faceID ); } + void getInternalFaces( TopTools_IndexedMapOfShape& fmap, + TopTools_IndexedMapOfShape& emap, + std::list< SMESH_subMesh* >& facesSM, + std::list< SMESH_subMesh* >& boundarySM); + // vertices + bool hasInternalVertexInSolid() const { return !_s2v.empty(); } + bool hasInternalVertexInSolid(int soID ) const { return _s2v.count(soID); } + const std::map >& getSolidsWithVertices() const { return _s2v; } + + +}; + +//================================================================================ +/*! + * \brief It correctly initializes netgen library at constructor and + * correctly finishes using netgen library at destructor + */ +//================================================================================ + +struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper +{ + nglib::Ng_Mesh * _ngMesh; + NETGENPlugin_NetgenLibWrapper(); + ~NETGENPlugin_NetgenLibWrapper(); + void setMesh( nglib::Ng_Mesh* mesh ); +}; + #endif diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx index 75bbc53..bf56622 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx @@ -1,30 +1,30 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_NETGEN_2D.cxx // Author : Michael Sazonov (OCN) // Date : 20/03/2006 // Project : SALOME -// $Header$ //============================================================================= // #include "NETGENPlugin_NETGEN_2D.hxx" @@ -40,6 +40,13 @@ #include +#ifdef WITH_SMESH_CANCEL_COMPUTE +namespace nglib { +#include +} +#include +#endif + using namespace std; //============================================================================= @@ -57,7 +64,7 @@ NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D(int hypId, int studyId, _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type _compatibleHypothesis.push_back("NETGEN_Parameters_2D"); _compatibleHypothesis.push_back("NETGEN_SimpleParameters_2D"); - _requireDescretBoundary = false; + _requireDiscreteBoundary = false; _onlyUnaryInput = false; _hypothesis = NULL; _supportSubmeshes = true; @@ -121,11 +128,37 @@ bool NETGENPlugin_NETGEN_2D::CheckHypothesis bool NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) { - //SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); +#ifdef WITH_SMESH_CANCEL_COMPUTE + netgen::multithread.terminate = 0; +#endif NETGENPlugin_Mesher mesher(&aMesh, aShape, false); -// NETGENPlugin_Mesher mesher(meshDS, aShape, false); mesher.SetParameters(dynamic_cast(_hypothesis)); mesher.SetParameters(dynamic_cast(_hypothesis)); return mesher.Compute(); } + +#ifdef WITH_SMESH_CANCEL_COMPUTE +void NETGENPlugin_NETGEN_2D::CancelCompute() +{ + SMESH_Algo::CancelCompute(); + netgen::multithread.terminate = 1; +} +#endif + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool NETGENPlugin_NETGEN_2D::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + + NETGENPlugin_Mesher mesher(&aMesh, aShape, false); + mesher.SetParameters(dynamic_cast(_hypothesis)); + mesher.SetParameters(dynamic_cast(_hypothesis)); + return mesher.Evaluate(aResMap); +} diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.hxx index 57b6ee4..cfb723d 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D.hxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_NETGEN_2D.hxx // Author : Michael Sazonov (OCN) @@ -50,7 +51,14 @@ public: SMESH_Hypothesis::Hypothesis_Status& aStatus); virtual bool Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape); + const TopoDS_Shape& aShape); + +#ifdef WITH_SMESH_CANCEL_COMPUTE + virtual void CancelCompute(); +#endif + + virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap); protected: const SMESHDS_Hypothesis* _hypothesis; diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cxx index 2bad447..5959507 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_NETGEN_2D3D.cxx // Author : Michael Sazonov (OCN) @@ -40,6 +41,13 @@ #include +#ifdef WITH_SMESH_CANCEL_COMPUTE +namespace nglib { +#include +} +#include +#endif + using namespace std; //============================================================================= @@ -57,7 +65,7 @@ NETGENPlugin_NETGEN_2D3D::NETGENPlugin_NETGEN_2D3D(int hypId, int studyId, _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type _compatibleHypothesis.push_back("NETGEN_Parameters"); _compatibleHypothesis.push_back("NETGEN_SimpleParameters_3D"); - _requireDescretBoundary = false; + _requireDiscreteBoundary = false; _onlyUnaryInput = false; _hypothesis = NULL; _supportSubmeshes = true; @@ -124,6 +132,9 @@ bool NETGENPlugin_NETGEN_2D3D::CheckHypothesis bool NETGENPlugin_NETGEN_2D3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) { +#ifdef WITH_SMESH_CANCEL_COMPUTE + netgen::multithread.terminate = 0; +#endif // SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); NETGENPlugin_Mesher mesher(&aMesh, aShape, true); @@ -132,3 +143,27 @@ bool NETGENPlugin_NETGEN_2D3D::Compute(SMESH_Mesh& aMesh, mesher.SetParameters(dynamic_cast(_hypothesis)); return mesher.Compute(); } + +#ifdef WITH_SMESH_CANCEL_COMPUTE +void NETGENPlugin_NETGEN_2D3D::CancelCompute() +{ + SMESH_Algo::CancelCompute(); + netgen::multithread.terminate = 1; +} +#endif + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool NETGENPlugin_NETGEN_2D3D::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + NETGENPlugin_Mesher mesher(&aMesh, aShape, true); + mesher.SetParameters(dynamic_cast(_hypothesis)); + mesher.SetParameters(dynamic_cast(_hypothesis)); + return mesher.Evaluate(aResMap); +} diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.hxx index 2f490d7..7775f8c 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D.hxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_NETGEN_2D3D.hxx // Author : Michael Sazonov (OCN) @@ -50,7 +51,15 @@ public: SMESH_Hypothesis::Hypothesis_Status& aStatus); virtual bool Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape); + const TopoDS_Shape& aShape); + +#ifdef WITH_SMESH_CANCEL_COMPUTE + virtual void CancelCompute(); +#endif + + virtual bool Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap); protected: const SMESHDS_Hypothesis* _hypothesis; diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D_i.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D_i.cxx index c15f825..943bb73 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D_i.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : idl implementation // File : NETGENPlugin_NETGEN_2D3D_i.cxx // Author : Michael Sazonov (OCN) diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D_i.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D_i.hxx index 083deeb..624a0d5 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D3D_i.hxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : idl implementation // File : NETGENPlugin_NETGEN_2D3D_i.hxx // Author : Michael Sazonov (OCN) diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx index fb48a06..acb11d6 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 : NETGENPlugin_NETGEN_2D_ONLY.cxx // Author : Edward AGAPOV (OCC) // Project : SALOME @@ -26,6 +24,7 @@ #include "NETGENPlugin_NETGEN_2D_ONLY.hxx" #include "NETGENPlugin_Mesher.hxx" +#include "NETGENPlugin_Hypothesis_2D.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" @@ -39,6 +38,7 @@ #include "StdMeshers_LengthFromEdges.hxx" #include "StdMeshers_QuadranglePreference.hxx" +#include #include #include @@ -46,6 +46,7 @@ #include #include +#include /* Netgen include files @@ -53,19 +54,23 @@ namespace nglib { #include } +#ifndef OCCGEOMETRY #define OCCGEOMETRY +#endif #include #include //#include namespace netgen { extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*); - /*extern*/ MeshingParameters mparam; + extern MeshingParameters mparam; } using namespace std; using namespace netgen; using namespace nglib; +//#define DUMP_SEGMENTS + //============================================================================= /*! * @@ -78,16 +83,18 @@ NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY(int hypId, int studyId, { MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::NETGENPlugin_NETGEN_2D_ONLY"); _name = "NETGEN_2D_ONLY"; - + _shapeType = (1 << TopAbs_FACE);// 1 bit /shape type _compatibleHypothesis.push_back("MaxElementArea"); _compatibleHypothesis.push_back("LengthFromEdges"); _compatibleHypothesis.push_back("QuadranglePreference"); + _compatibleHypothesis.push_back("NETGEN_Parameters_2D"); _hypMaxElementArea = 0; _hypLengthFromEdges = 0; _hypQuadranglePreference = 0; + _hypParameters = 0; } //============================================================================= @@ -138,21 +145,21 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh, _hypLengthFromEdges = static_cast (hyp); else if ( hypName == "QuadranglePreference" ) _hypQuadranglePreference = static_cast(hyp); + else if ( hypName == "NETGEN_Parameters_2D" ) + _hypParameters = static_cast(hyp); else { aStatus = HYP_INCOMPATIBLE; return false; } } - if ( _hypMaxElementArea && _hypLengthFromEdges ) { + int nbHyps = bool(_hypMaxElementArea) + bool(_hypLengthFromEdges) + bool(_hypParameters ); + if ( nbHyps > 1 ) aStatus = HYP_CONCURENT; - return false; - } - - if ( _hypMaxElementArea || _hypLengthFromEdges ) + else if ( nbHyps == 1) aStatus = HYP_OK; - return aStatus == HYP_OK; + return ( aStatus == HYP_OK ); } //================================================================================ @@ -162,7 +169,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh, */ //================================================================================ -static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, +static TError addSegmentsToMesh(netgen::Mesh& ngMesh, OCCGeometry& geom, const TSideVector& wires, SMESH_MesherHelper& helper, @@ -172,20 +179,27 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, // Check wires and count nodes // ---------------------------- int nbNodes = 0; + double totalLength = 0; for ( int iW = 0; iW < wires.size(); ++iW ) { StdMeshers_FaceSidePtr wire = wires[ iW ]; if ( wire->MissVertexNode() ) - return TError - (new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH, "Missing nodes on vertices")); - + { + // Commented for issue 0020960. It worked for the case, let's wait for case where it doesn't. + // It seems that there is no reason for this limitation +// return TError +// (new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH, "Missing nodes on vertices")); + if (getenv("USER") && string("eap")==getenv("USER")) + cout << "Warning: NETGENPlugin_NETGEN_2D_ONLY : try to work with missing nodes on vertices"<& uvPtVec = wire->GetUVPtStruct(); if ( uvPtVec.size() != wire->NbPoints() ) return TError (new SMESH_ComputeError(COMPERR_BAD_INPUT_MESH, SMESH_Comment("Unexpected nb of points on wire ") << iW << ": " << uvPtVec.size()<<" != "<NbPoints())); - nbNodes += wire->NbSegments(); + nbNodes += wire->NbPoints(); + totalLength += wire->Length(); } nodeVec.reserve( nbNodes ); @@ -197,37 +211,64 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, // bb.Increase (bb.Diam()/10); // ngMesh.SetLocalH (bb.PMin(), bb.PMax(), 0.5); // set grading + // map for nodes on vertices since they can be shared between wires + // ( issue 0020676, face_int_box.brep) + map node2ngID; + const int faceID = 1, solidID = 0; - ngMesh.AddFaceDescriptor (FaceDescriptor(faceID, solidID, solidID, 0)); + if ( ngMesh.GetNFD() < 1 ) + ngMesh.AddFaceDescriptor (FaceDescriptor(faceID, solidID, solidID, 0)); for ( int iW = 0; iW < wires.size(); ++iW ) { StdMeshers_FaceSidePtr wire = wires[ iW ]; const vector& uvPtVec = wire->GetUVPtStruct(); + const int nbSegments = wire->NbPoints() - 1; + + // compute length of every segment + vector segLen( nbSegments ); + for ( int i = 0; i < nbSegments; ++i ) + segLen[i] = SMESH_TNodeXYZ( uvPtVec[ i ].node ).Distance( uvPtVec[ i+1 ].node ); - int firstPointID = ngMesh.GetNP() + 1; int edgeID = 1, posID = -2; - for ( int i = 0; i < wire->NbSegments(); ++i ) // loop on segments + bool isInternalWire = false; + for ( int i = 0; i < nbSegments; ++i ) // loop on segments { // Add the first point of a segment const SMDS_MeshNode * n = uvPtVec[ i ].node; - const int posShapeID = n->GetPosition()->GetShapeId(); + const int posShapeID = n->getshapeId(); + bool onVertex = ( n->GetPosition()->GetTypeOfPosition() == SMDS_TOP_VERTEX ); // skip nodes on degenerated edges if ( helper.IsDegenShape( posShapeID ) && - helper.IsDegenShape( uvPtVec[ i+1 ].node->GetPosition()->GetShapeId() )) + helper.IsDegenShape( uvPtVec[ i+1 ].node->getshapeId() )) continue; - nodeVec.push_back( n ); - - MeshPoint mp( Point<3> (n->X(), n->Y(), n->Z()) ); - ngMesh.AddPoint ( mp, 1, EDGEPOINT ); + int ngID1 = ngMesh.GetNP() + 1, ngID2 = ngID1+1; + if ( onVertex ) + ngID1 = node2ngID.insert( make_pair( n, ngID1 )).first->second; + if ( ngID1 > ngMesh.GetNP() ) + { + MeshPoint mp( Point<3> (n->X(), n->Y(), n->Z()) ); + ngMesh.AddPoint ( mp, 1, EDGEPOINT ); + nodeVec.push_back( n ); + } + else + { + ngID2 = ngMesh.GetNP() + 1; + if ( i > 0 ) // prev segment belongs to same wire + { + Segment& prevSeg = ngMesh.LineSegment( ngMesh.GetNSeg() ); + prevSeg[1] = ngID1; + } + } // Add the segment Segment seg; - seg.p1 = ngMesh.GetNP(); // ng node id - seg.p2 = seg.p1 + 1; // ng node id + seg[0] = ngID1; // ng node id + seg[1] = ngID2; // ng node id + seg.edgenr = ngMesh.GetNSeg() + 1;// segment id seg.si = faceID; // = geom.fmap.FindIndex (face); @@ -240,7 +281,7 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, seg.epgeominfo[ iEnd ].v = pnt.v; // find out edge id and node parameter on edge - bool onVertex = ( pnt.node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_VERTEX ); + onVertex = ( pnt.node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_VERTEX ); if ( onVertex || posShapeID != posID ) { // get edge id @@ -250,29 +291,74 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, const TopoDS_Edge& edge = wire->Edge( wire->EdgeIndex( normParam )); edgeID = geom.emap.FindIndex( edge ); posID = posShapeID; - if ( onVertex ) // param on curve is different on each of two edges - seg.epgeominfo[ iEnd ].dist = helper.GetNodeU( edge, pnt.node ); + isInternalWire = ( edge.Orientation() == TopAbs_INTERNAL ); + // if ( onVertex ) // param on curve is different on each of two edges + // seg.epgeominfo[ iEnd ].dist = helper.GetNodeU( edge, pnt.node ); } seg.epgeominfo[ iEnd ].edgenr = edgeID; // = geom.emap.FindIndex(edge); } ngMesh.AddSegment (seg); + { + // restrict size of elements near the segment + SMESH_TNodeXYZ np1( n ), np2( uvPtVec[ i+1 ].node ); + // get an average size of adjacent segments to avoid sharp change of + // element size (regression on issue 0020452, note 0010898) + int iPrev = SMESH_MesherHelper::WrapIndex( i-1, nbSegments ); + int iNext = SMESH_MesherHelper::WrapIndex( i+1, nbSegments ); + double avgH = ( segLen[ iPrev ] + segLen[ i ] + segLen[ iNext ]) / 3; -// cout << "Segment: " << seg.edgenr << endl -// << "\tp1: " << seg.p1 << endl -// << "\tp2: " << seg.p2 << endl -// << "\tp0 param: " << seg.epgeominfo[ 0 ].dist << endl -// << "\tp0 uv: " << seg.epgeominfo[ 0 ].u <<", "<< seg.epgeominfo[ 0 ].v << endl -// << "\tp0 edge: " << seg.epgeominfo[ 0 ].edgenr << endl -// << "\tp1 param: " << seg.epgeominfo[ 1 ].dist << endl -// << "\tp1 uv: " << seg.epgeominfo[ 1 ].u <<", "<< seg.epgeominfo[ 1 ].v << endl -// << "\tp1 edge: " << seg.epgeominfo[ 1 ].edgenr << endl; + NETGENPlugin_Mesher::RestrictLocalSize( ngMesh, 0.5*(np1+np2), avgH ); + } +#ifdef DUMP_SEGMENTS + cout << "Segment: " << seg.edgenr << endl + << "\tp1: " << seg[0] << endl + << "\tp2: " << seg[1] << endl + << "\tp0 param: " << seg.epgeominfo[ 0 ].dist << endl + << "\tp0 uv: " << seg.epgeominfo[ 0 ].u <<", "<< seg.epgeominfo[ 0 ].v << endl + << "\tp0 edge: " << seg.epgeominfo[ 0 ].edgenr << endl + << "\tp1 param: " << seg.epgeominfo[ 1 ].dist << endl + << "\tp1 uv: " << seg.epgeominfo[ 1 ].u <<", "<< seg.epgeominfo[ 1 ].v << endl + << "\tp1 edge: " << seg.epgeominfo[ 1 ].edgenr << endl; +#endif + if ( isInternalWire ) + { + swap (seg[0], seg[1]); + swap( seg.epgeominfo[0], seg.epgeominfo[1] ); + seg.edgenr = ngMesh.GetNSeg() + 1; // segment id + ngMesh.AddSegment (seg); +#ifdef DUMP_SEGMENTS + cout << "Segment: " << seg.edgenr << endl << "\tis REVRESE of the previous one" << endl; +#endif + } + } // loop on segments on a wire + + // close chain of segments + if ( nbSegments > 0 ) + { + Segment& lastSeg = ngMesh.LineSegment( ngMesh.GetNSeg() - int( isInternalWire)); + const SMDS_MeshNode * lastNode = uvPtVec.back().node; + lastSeg[1] = node2ngID.insert( make_pair( lastNode, lastSeg[1] )).first->second; + if ( lastSeg[1] > ngMesh.GetNP() ) + { + MeshPoint mp( Point<3> (lastNode->X(), lastNode->Y(), lastNode->Z()) ); + ngMesh.AddPoint ( mp, 1, EDGEPOINT ); + nodeVec.push_back( lastNode ); + } + if ( isInternalWire ) + { + Segment& realLastSeg = ngMesh.LineSegment( ngMesh.GetNSeg() ); + realLastSeg[0] = lastSeg[1]; + } } - Segment& seg = ngMesh.LineSegment( ngMesh.GetNSeg() ); - seg.p2 = firstPointID; - } - ngMesh.CalcSurfacesOfNode(); + } // loop on wires of a face + + // add a segment instead of internal vertex + NETGENPlugin_Internals intShapes( *helper.GetMesh(), helper.GetSubShape(), /*is3D=*/false ); + NETGENPlugin_Mesher::addIntVerticesInFaces( geom, ngMesh, nodeVec, intShapes ); + + ngMesh.CalcSurfacesOfNode(); return TError(); } @@ -286,6 +372,9 @@ static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) { +#ifdef WITH_SMESH_CANCEL_COMPUTE + netgen::multithread.terminate = 0; +#endif MESSAGE("NETGENPlugin_NETGEN_2D_ONLY::Compute()"); SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); @@ -311,60 +400,73 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, return error(COMPERR_BAD_INPUT_MESH, SMESH_Comment("Too few segments: ")<NbSegments()); - // ------------------------- - // Make input netgen mesh - // ------------------------- - - Ng_Init(); - netgen::Mesh * ngMesh = new netgen::Mesh (); - - netgen::OCCGeometry occgeo; - NETGENPlugin_Mesher::PrepareOCCgeometry( occgeo, F, aMesh ); - occgeo.fmap.Clear(); // face can be reversed, which is wrong in this case (issue 19978) - occgeo.fmap.Add( F ); - - vector< const SMDS_MeshNode* > nodeVec; - problem = AddSegmentsToMesh( *ngMesh, occgeo, wires, helper, nodeVec ); - if ( problem && !problem->IsOK() ) { - delete ngMesh; Ng_Exit(); - return error( problem ); - } - // -------------------- // compute edge length // -------------------- - double edgeLength = 0; - if (_hypLengthFromEdges || !_hypLengthFromEdges && !_hypMaxElementArea) + NETGENPlugin_Mesher aMesher( &aMesh, aShape, /*isVolume=*/false); + netgen::OCCGeometry occgeo; + aMesher.PrepareOCCgeometry( occgeo, F, aMesh ); + occgeo.fmap.Clear(); // face can be reversed, which is wrong in this case (issue 19978) + occgeo.fmap.Add( F ); + + if ( _hypParameters ) { - int nbSegments = 0; - for ( int iW = 0; iW < nbWires; ++iW ) + aMesher.SetParameters(_hypParameters); + } + else + { + double edgeLength = 0; + if (_hypLengthFromEdges || (!_hypLengthFromEdges && !_hypMaxElementArea)) { - edgeLength += wires[ iW ]->Length(); - nbSegments += wires[ iW ]->NbSegments(); + int nbSegments = 0; + for ( int iW = 0; iW < nbWires; ++iW ) + { + edgeLength += wires[ iW ]->Length(); + nbSegments += wires[ iW ]->NbSegments(); + } + if ( nbSegments ) + edgeLength /= nbSegments; } - if ( nbSegments ) - edgeLength /= nbSegments; - } - if ( _hypMaxElementArea ) - { - double maxArea = _hypMaxElementArea->GetMaxArea(); - edgeLength = sqrt(2. * maxArea/sqrt(3.0)); - } - if ( edgeLength < DBL_MIN ) - edgeLength = occgeo.GetBoundingBox().Diam(); + if ( _hypMaxElementArea ) + { + double maxArea = _hypMaxElementArea->GetMaxArea(); + edgeLength = sqrt(2. * maxArea/sqrt(3.0)); + } + if ( edgeLength < DBL_MIN ) + edgeLength = occgeo.GetBoundingBox().Diam(); - //cout << " edgeLength = " << edgeLength << endl; + netgen::mparam.maxh = edgeLength; + netgen::mparam.minh = aMesher.GetDefaultMinSize( aShape, netgen::mparam.maxh ); + netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0; + netgen::mparam.grading = 0.7; // very coarse mesh by default + } +#ifdef NETGEN_NEW + occgeo.face_maxh = netgen::mparam.maxh; +#endif - netgen::mparam.maxh = edgeLength; - netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0; - //ngMesh->SetGlobalH ( edgeLength ); + // ------------------------- + // Make input netgen mesh + // ------------------------- + + NETGENPlugin_NetgenLibWrapper ngLib; + netgen::Mesh * ngMesh = (netgen::Mesh*) ngLib._ngMesh; + + Box<3> bb = occgeo.GetBoundingBox(); + bb.Increase (bb.Diam()/10); + ngMesh->SetLocalH (bb.PMin(), bb.PMax(), netgen::mparam.grading); + ngMesh->SetGlobalH (netgen::mparam.maxh); + + vector< const SMDS_MeshNode* > nodeVec; + problem = addSegmentsToMesh( *ngMesh, occgeo, wires, helper, nodeVec ); + if ( problem && !problem->IsOK() ) + return error( problem ); // ------------------------- // Generate surface mesh // ------------------------- - char *optstr; + char *optstr = 0; int startWith = MESHCONST_MESHSURFACE; int endWith = MESHCONST_OPTSURFACE; int err = 1; @@ -374,20 +476,26 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, OCC_CATCH_SIGNALS; #endif err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + if ( err ) + error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task); } - catch (Standard_Failure& ex) { - string comment = ex.DynamicType()->Name(); - if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) { - comment += ": "; - comment += ex.GetMessageString(); - } - error(COMPERR_OCC_EXCEPTION, comment); - } - catch (NgException exc) { - error( SMESH_Comment("NgException: ") << exc.What() ); + catch (Standard_Failure& ex) + { + SMESH_Comment str("Exception in netgen::OCCGenerateMesh()"); + str << " at " << netgen::multithread.task + << ": " << ex.DynamicType()->Name(); + if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) + str << ": " << ex.GetMessageString(); + error(str); } catch (...) { - error(COMPERR_EXCEPTION,"Exception in netgen::OCCGenerateMesh()"); + SMESH_Comment str("Exception in netgen::OCCGenerateMesh()"); + str << " at " << netgen::multithread.task; + error(str); } // ---------------------------------------------------- @@ -404,19 +512,26 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, for ( int i = nbInputNodes + 1; i <= nbNodes; ++i ) { const MeshPoint& ngPoint = ngMesh->Point(i); +#ifdef NETGEN_NEW + SMDS_MeshNode * node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2)); +#else SMDS_MeshNode * node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z()); +#endif nodeVec[ i-1 ] = node; } // create faces bool reverse = ( aShape.Orientation() == TopAbs_REVERSED ); - for ( int i = 1; i <= nbFaces ; ++i ) + int i,j; + for ( i = 1; i <= nbFaces ; ++i ) { const Element2d& elem = ngMesh->SurfaceElement(i); vector nodes( elem.GetNP() ); - for (int j=1; j <= elem.GetNP(); ++j) + for (j=1; j <= elem.GetNP(); ++j) { int pind = elem.PNum(j); + if ( pind-1 < 0 ) + break; const SMDS_MeshNode* node = nodeVec.at(pind-1); if ( reverse ) nodes[ nodes.size()-j ] = node; @@ -428,17 +543,108 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, meshDS->SetNodeOnFace((SMDS_MeshNode*)node, faceID, pgi.u, pgi.v); } } - SMDS_MeshFace* face = 0; - if ( elem.GetType() == TRIG ) - face = helper.AddFace(nodes[0],nodes[1],nodes[2]); - else - face = helper.AddFace(nodes[0],nodes[1],nodes[2],nodes[3]); + if ( j > elem.GetNP() ) + { + SMDS_MeshFace* face = 0; + if ( elem.GetType() == TRIG ) + face = helper.AddFace(nodes[0],nodes[1],nodes[2]); + else + face = helper.AddFace(nodes[0],nodes[1],nodes[2],nodes[3]); + } } - Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh); - Ng_Exit(); - - NETGENPlugin_Mesher::RemoveTmpFiles(); - return !err; } + +#ifdef WITH_SMESH_CANCEL_COMPUTE +void NETGENPlugin_NETGEN_2D_ONLY::CancelCompute() +{ + SMESH_Algo::CancelCompute(); + netgen::multithread.terminate = 1; +} +#endif + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool NETGENPlugin_NETGEN_2D_ONLY::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + TopoDS_Face F = TopoDS::Face(aShape); + if(F.IsNull()) + return false; + + // collect info from edges + int nb0d = 0, nb1d = 0; + bool IsQuadratic = false; + bool IsFirst = true; + double fullLen = 0.0; + TopTools_MapOfShape tmpMap; + for (TopExp_Explorer exp(F, 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); + if( anIt==aResMap.end() ) { + SMESH_subMesh *sm = aMesh.GetSubMesh(F); + 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; + nb0d += aVec[SMDSEntity_Node]; + nb1d += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]); + double aLen = SMESH_Algo::EdgeLength(E); + fullLen += aLen; + if(IsFirst) { + IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]); + IsFirst = false; + } + } + tmpMap.Clear(); + + // compute edge length + double ELen = 0; + if (_hypLengthFromEdges || !_hypLengthFromEdges && !_hypMaxElementArea) { + if ( nb1d > 0 ) + ELen = fullLen / nb1d; + } + if ( _hypMaxElementArea ) { + double maxArea = _hypMaxElementArea->GetMaxArea(); + ELen = sqrt(2. * maxArea/sqrt(3.0)); + } + GProp_GProps G; + BRepGProp::SurfaceProperties(F,G); + double anArea = G.Mass(); + + const int hugeNb = numeric_limits::max()/10; + if ( anArea / hugeNb > ELen*ELen ) + { + SMESH_subMesh *sm = aMesh.GetSubMesh(F); + SMESH_ComputeErrorPtr& smError = sm->GetComputeError(); + smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated.\nToo small element length",this)); + return false; + } + int nbFaces = (int) ( anArea / ( ELen*ELen*sqrt(3.) / 4 ) ); + int nbNodes = (int) ( ( nbFaces*3 - (nb1d-1)*2 ) / 6 + 1 ); + std::vector aVec(SMDSEntity_Last); + for(int i=SMDSEntity_Node; i -#include //amv*/ - class StdMeshers_MaxElementArea; class StdMeshers_LengthFromEdges; -class StdMeshers_QuadranglePreference; -//class NETGENPlugin_Hypothesis; - -/*namespace netgen { - class OCCGeometry; -}*/ -/*namespace netgen { - class OCCGeometry; - extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*); - extern MeshingParameters mparam; -}*/ - -//using namespace netgen; +class NETGENPlugin_Hypothesis_2D; /*! * \brief Mesher generating 2D elements on a geometrical face taking @@ -70,17 +52,18 @@ public: virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); - /*static TError AddSegmentsToMesh(netgen::Mesh& ngMesh, - OCCGeometry& geom, - const TSideVector& wires, - SMESH_MesherHelper& helper, - vector< const SMDS_MeshNode* > & nodeVec); //amv*/ +#ifdef WITH_SMESH_CANCEL_COMPUTE + virtual void CancelCompute(); +#endif + + virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap); protected: const StdMeshers_MaxElementArea* _hypMaxElementArea; const StdMeshers_LengthFromEdges* _hypLengthFromEdges; - const StdMeshers_QuadranglePreference* _hypQuadranglePreference; - // const NETGENPlugin_Hypothesis* _hypothesis; + const SMESHDS_Hypothesis* _hypQuadranglePreference; + const NETGENPlugin_Hypothesis_2D* _hypParameters; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY_i.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY_i.cxx index 6dac129..f1f9d94 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY_i.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses // File : NETGENPlugin_NETGEN_2D_ONLY_i.cxx // Author : Edward AGAPOV (OCC) @@ -38,8 +36,8 @@ //============================================================================= NETGENPlugin_NETGEN_2D_ONLY_i::NETGENPlugin_NETGEN_2D_ONLY_i( PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ) + int theStudyId, + ::SMESH_Gen* theGenImpl ) : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ), SMESH_Algo_i( thePOA ), diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY_i.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY_i.hxx index 125a5dc..c34e06c 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY_i.hxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses // File : NETGENPlugin_NETGEN_2D_ONLY_i.cxx // Author : Edward AGAPOV (OCC) diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.cxx index 3a113f6..9e2a944 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : idl implementation // File : NETGENPlugin_NETGEN_2D_i.cxx // Author : Michael Sazonov (OCN) diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.hxx index 984f953..ebbfae9 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.hxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // NETGENPlugin : idl implementation // File : NETGENPlugin_NETGEN_2D_i.hxx // Author : Michael Sazonov (OCN) diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx index 0400de6..e923afb 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx @@ -1,36 +1,36 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 : NETGENPlugin_NETGEN_3D.cxx // Moved here from SMESH_NETGEN_3D.cxx // Created : lundi 27 Janvier 2003 // Author : Nadir BOUHAMOU (CEA) // Project : SALOME -// $Header$ //============================================================================= // #include "NETGENPlugin_NETGEN_3D.hxx" -#include "NETGENPlugin_Mesher.hxx" +#include "NETGENPlugin_Hypothesis.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" @@ -40,11 +40,17 @@ #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_MesherHelper.hxx" +#include "SMESH_MeshEditor.hxx" #include "StdMeshers_QuadToTriaAdaptor.hxx" +#include "StdMeshers_MaxElementVolume.hxx" +#include "StdMeshers_ViscousLayers.hxx" +#include #include +#include #include #include +#include #include #include @@ -60,10 +66,20 @@ Netgen include files */ +#ifndef OCCGEOMETRY +#define OCCGEOMETRY +#endif +#include namespace nglib { #include } +namespace netgen { + extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*); + extern MeshingParameters mparam; + extern volatile multithreadt multithread; +} using namespace nglib; +using namespace std; //============================================================================= /*! @@ -72,17 +88,21 @@ using namespace nglib; //============================================================================= NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D(int hypId, int studyId, - SMESH_Gen* gen) + SMESH_Gen* gen) : SMESH_3D_Algo(hypId, studyId, gen) { MESSAGE("NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D"); _name = "NETGEN_3D"; _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type _compatibleHypothesis.push_back("MaxElementVolume"); + _compatibleHypothesis.push_back("NETGEN_Parameters"); + _compatibleHypothesis.push_back("ViscousLayers"); _maxElementVolume = 0.; _hypMaxElementVolume = NULL; + _hypParameters = NULL; + _viscousLayersHyp = NULL; _requireShape = false; // can work without shape } @@ -104,47 +124,51 @@ NETGENPlugin_NETGEN_3D::~NETGENPlugin_NETGEN_3D() */ //============================================================================= -bool NETGENPlugin_NETGEN_3D::CheckHypothesis - (SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape, - SMESH_Hypothesis::Hypothesis_Status& aStatus) +bool NETGENPlugin_NETGEN_3D::CheckHypothesis (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + Hypothesis_Status& aStatus) { MESSAGE("NETGENPlugin_NETGEN_3D::CheckHypothesis"); _hypMaxElementVolume = NULL; + _hypParameters = NULL; + _viscousLayersHyp = NULL; _maxElementVolume = DBL_MAX; list::const_iterator itl; const SMESHDS_Hypothesis* theHyp; - const list& hyps = GetUsedHypothesis(aMesh, aShape); - int nbHyp = hyps.size(); - if (!nbHyp) + const list& hyps = + GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliary=*/false); + list ::const_iterator h = hyps.begin(); + if ( h == hyps.end()) { aStatus = SMESH_Hypothesis::HYP_OK; - //aStatus = SMESH_Hypothesis::HYP_MISSING; return true; // can work with no hypothesis } - itl = hyps.begin(); - theHyp = (*itl); // use only the first hypothesis - - string hypName = theHyp->GetName(); - - bool isOk = false; - - if (hypName == "MaxElementVolume") + aStatus = HYP_OK; + for ( ; h != hyps.end(); ++h ) { - _hypMaxElementVolume = static_cast (theHyp); - ASSERT(_hypMaxElementVolume); - _maxElementVolume = _hypMaxElementVolume->GetMaxVolume(); - isOk =true; - aStatus = SMESH_Hypothesis::HYP_OK; - } - else - aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE; + if ( !_hypMaxElementVolume ) + _hypMaxElementVolume = dynamic_cast< const StdMeshers_MaxElementVolume*> ( *h ); + if ( !_viscousLayersHyp ) + _viscousLayersHyp = dynamic_cast< const StdMeshers_ViscousLayers*> ( *h ); + if ( ! _hypParameters ) + _hypParameters = dynamic_cast< const NETGENPlugin_Hypothesis*> ( *h ); - return isOk; + if ( *h != _hypMaxElementVolume && + *h != _viscousLayersHyp && + *h != _hypParameters) + aStatus = HYP_INCOMPATIBLE; + } + if ( _hypMaxElementVolume && _hypParameters ) + aStatus = HYP_INCOMPATIBLE; + + if ( _hypMaxElementVolume ) + _maxElementVolume = _hypMaxElementVolume->GetMaxVolume(); + + return aStatus == HYP_OK; } //============================================================================= @@ -156,191 +180,143 @@ bool NETGENPlugin_NETGEN_3D::CheckHypothesis bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) { +#ifdef WITH_SMESH_CANCEL_COMPUTE + netgen::multithread.terminate = 0; +#endif MESSAGE("NETGENPlugin_NETGEN_3D::Compute with maxElmentsize = " << _maxElementVolume); SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); - const int invalid_ID = -1; - - SMESH::Controls::Area areaControl; - SMESH::Controls::TSequenceOfXYZ nodesCoords; - - // ------------------------------------------------------------------- - // get triangles on aShell and make a map of nodes to Netgen node IDs - // ------------------------------------------------------------------- - SMESH_MesherHelper helper(aMesh); - SMESH_MesherHelper* myTool = &helper; - bool _quadraticMesh = myTool->IsQuadraticSubMesh(aShape); + bool _quadraticMesh = helper.IsQuadraticSubMesh(aShape); + helper.SetElementsOnShape( true ); - typedef map< const SMDS_MeshNode*, int> TNodeToIDMap; - TNodeToIDMap nodeToNetgenID; - list< const SMDS_MeshElement* > triangles; - list< bool > isReversed; // orientation of triangles + int Netgen_NbOfNodes = 0; - TopAbs_ShapeEnum mainType = aMesh.GetShapeToMesh().ShapeType(); - bool checkReverse = ( mainType == TopAbs_COMPOUND || mainType == TopAbs_COMPSOLID ); + double Netgen_point[3]; + int Netgen_triangle[3]; - // for the degeneraged edge: ignore all but one node on it; - // map storing ids of degen edges and vertices and their netgen id: - map< int, int* > degenShapeIdToPtrNgId; - map< int, int* >::iterator shId_ngId; - list< int > degenNgIds; + NETGENPlugin_NetgenLibWrapper ngLib; + Ng_Mesh * Netgen_mesh = ngLib._ngMesh; - StdMeshers_QuadToTriaAdaptor Adaptor; - Adaptor.Compute(aMesh,aShape); - - for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next()) + // vector of nodes in which node index == netgen ID + vector< const SMDS_MeshNode* > nodeVec; { - const TopoDS_Shape& aShapeFace = exp.Current(); - const SMESHDS_SubMesh * aSubMeshDSFace = meshDS->MeshElements( aShapeFace ); - if ( aSubMeshDSFace ) + const int invalid_ID = -1; + + SMESH::Controls::Area areaControl; + SMESH::Controls::TSequenceOfXYZ nodesCoords; + + // maps nodes to ng ID + typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap; + typedef TNodeToIDMap::value_type TN2ID; + TNodeToIDMap nodeToNetgenID; + + // find internal shapes + NETGENPlugin_Internals internals( aMesh, aShape, /*is3D=*/true ); + + // --------------------------------- + // Feed the Netgen with surface mesh + // --------------------------------- + + TopAbs_ShapeEnum mainType = aMesh.GetShapeToMesh().ShapeType(); + bool checkReverse = ( mainType == TopAbs_COMPOUND || mainType == TopAbs_COMPSOLID ); + + SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh )); + if ( _viscousLayersHyp ) { + proxyMesh = _viscousLayersHyp->Compute( aMesh, aShape ); + if ( !proxyMesh ) + return false; + } + if ( aMesh.NbQuadrangles() > 0 ) + { + StdMeshers_QuadToTriaAdaptor* Adaptor = new StdMeshers_QuadToTriaAdaptor; + Adaptor->Compute(aMesh,aShape,proxyMesh.get()); + proxyMesh.reset( Adaptor ); + } + + for ( TopExp_Explorer exFa( aShape, TopAbs_FACE ); exFa.More(); exFa.Next()) + { + const TopoDS_Shape& aShapeFace = exFa.Current(); + int faceID = meshDS->ShapeToIndex( aShapeFace ); + bool isInternalFace = internals.isInternalShape( faceID ); bool isRev = false; - if ( checkReverse && helper.NbAncestors(aShapeFace, aMesh, aShape.ShapeType()) > 1 ) + if ( checkReverse && !isInternalFace && + helper.NbAncestors(aShapeFace, aMesh, aShape.ShapeType()) > 1 ) // IsReversedSubMesh() can work wrong on strongly curved faces, // so we use it as less as possible isRev = SMESH_Algo::IsReversedSubMesh( TopoDS::Face(aShapeFace), meshDS ); + const SMESHDS_SubMesh * aSubMeshDSFace = proxyMesh->GetSubMesh( aShapeFace ); + if ( !aSubMeshDSFace ) continue; SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements(); - while ( iteratorElem->more() ) // loop on elements on a face + while ( iteratorElem->more() ) // loop on elements on a geom face { - // check element + // check mesh face const SMDS_MeshElement* elem = iteratorElem->next(); if ( !elem ) return error( COMPERR_BAD_INPUT_MESH, "Null element encounters"); - bool isTraingle = ( elem->NbNodes()==3 || (_quadraticMesh && elem->NbNodes()==6 )); - if ( !isTraingle ) { - //return error( COMPERR_BAD_INPUT_MESH, - // SMESH_Comment("Not triangle element ")<GetID()); - // using adaptor - std::list faces = Adaptor.GetTriangles(elem); - if(faces.size()==0) { - return error( COMPERR_BAD_INPUT_MESH, - SMESH_Comment("Not triangles in adaptor for element ")<GetID()); - } - std::list::iterator itf = faces.begin(); - for(; itf!=faces.end(); itf++ ) { - triangles.push_back( (*itf) ); - isReversed.push_back( isRev ); - // put triange's nodes to nodeToNetgenID map - SMDS_ElemIteratorPtr triangleNodesIt = (*itf)->nodesIterator(); - while ( triangleNodesIt->more() ) { - const SMDS_MeshNode * node = - static_cast(triangleNodesIt->next()); - if(myTool->IsMedium(node)) - continue; - nodeToNetgenID.insert( make_pair( node, invalid_ID )); - } - } - } - else { - // keep a triangle - triangles.push_back( elem ); - isReversed.push_back( isRev ); - // put elem nodes to nodeToNetgenID map - SMDS_ElemIteratorPtr triangleNodesIt = elem->nodesIterator(); - while ( triangleNodesIt->more() ) { - const SMDS_MeshNode * node = - static_cast(triangleNodesIt->next()); - if(myTool->IsMedium(node)) - continue; - nodeToNetgenID.insert( make_pair( node, invalid_ID )); - } - } -#ifdef _DEBUG_ - // check if a trainge is degenerated - areaControl.GetPoints( elem, nodesCoords ); - double area = areaControl.GetValue( nodesCoords ); - if ( area <= DBL_MIN ) { - MESSAGE( "Warning: Degenerated " << elem ); - } -#endif - } - // look for degeneraged edges and vetices - for (TopExp_Explorer expE(aShapeFace,TopAbs_EDGE);expE.More();expE.Next()) - { - TopoDS_Edge aShapeEdge = TopoDS::Edge( expE.Current() ); - if ( BRep_Tool::Degenerated( aShapeEdge )) + if ( elem->NbCornerNodes() != 3 ) + return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters"); + + // Add nodes of triangles and triangles them-selves to netgen mesh + + // add three nodes of triangle + bool hasDegen = false; + for ( int iN = 0; iN < 3; ++iN ) { - degenNgIds.push_back( invalid_ID ); - int* ptrIdOnEdge = & degenNgIds.back(); - // remember edge id - int edgeID = meshDS->ShapeToIndex( aShapeEdge ); - degenShapeIdToPtrNgId.insert( make_pair( edgeID, ptrIdOnEdge )); - // remember vertex id - int vertexID = meshDS->ShapeToIndex( TopExp::FirstVertex( aShapeEdge )); - degenShapeIdToPtrNgId.insert( make_pair( vertexID, ptrIdOnEdge )); + const SMDS_MeshNode* node = elem->GetNode( iN ); + const int shapeID = node->getshapeId(); + if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_EDGE && + helper.IsDegenShape( shapeID )) + { + // ignore all nodes on degeneraged edge and use node on its vertex instead + TopoDS_Shape vertex = TopoDS_Iterator( meshDS->IndexToShape( shapeID )).Value(); + node = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), meshDS ); + hasDegen = true; + } + int& ngID = nodeToNetgenID.insert(TN2ID( node, invalid_ID )).first->second; + if ( ngID == invalid_ID ) + { + ngID = ++Netgen_NbOfNodes; + Netgen_point [ 0 ] = node->X(); + Netgen_point [ 1 ] = node->Y(); + Netgen_point [ 2 ] = node->Z(); + Ng_AddPoint(Netgen_mesh, Netgen_point); + } + Netgen_triangle[ isRev ? 2-iN : iN ] = ngID; } - } - } - } - // --------------------------------- - // Feed the Netgen with surface mesh - // --------------------------------- + // add triangle + if ( hasDegen && (Netgen_triangle[0] == Netgen_triangle[1] || + Netgen_triangle[0] == Netgen_triangle[2] || + Netgen_triangle[2] == Netgen_triangle[1] )) + continue; - int Netgen_NbOfNodes = 0; - int Netgen_param2ndOrder = 0; - double Netgen_paramFine = 1.; - double Netgen_paramSize = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. ); + Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle); - double Netgen_point[3]; - int Netgen_triangle[3]; - int Netgen_tetrahedron[4]; + if ( isInternalFace && !proxyMesh->IsTemporary( elem )) + { + swap( Netgen_triangle[1], Netgen_triangle[2] ); + Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle); + } + } // loop on elements on a face + } // loop on faces of a SOLID or SHELL - Ng_Init(); + // insert old nodes into nodeVec + nodeVec.resize( nodeToNetgenID.size() + 1, 0 ); + TNodeToIDMap::iterator n_id = nodeToNetgenID.begin(); + for ( ; n_id != nodeToNetgenID.end(); ++n_id ) + nodeVec[ n_id->second ] = n_id->first; + nodeToNetgenID.clear(); - Ng_Mesh * Netgen_mesh = Ng_NewMesh(); - - // set nodes and remember thier netgen IDs - bool isDegen = false, hasDegen = !degenShapeIdToPtrNgId.empty(); - TNodeToIDMap::iterator n_id = nodeToNetgenID.begin(); - for ( ; n_id != nodeToNetgenID.end(); ++n_id ) - { - const SMDS_MeshNode* node = n_id->first; - - // ignore nodes on degenerated edge - if ( hasDegen ) { - int shapeId = node->GetPosition()->GetShapeId(); - shId_ngId = degenShapeIdToPtrNgId.find( shapeId ); - isDegen = ( shId_ngId != degenShapeIdToPtrNgId.end() ); - if ( isDegen && *(shId_ngId->second) != invalid_ID ) { - n_id->second = *(shId_ngId->second); - continue; - } - } - Netgen_point [ 0 ] = node->X(); - Netgen_point [ 1 ] = node->Y(); - Netgen_point [ 2 ] = node->Z(); - Ng_AddPoint(Netgen_mesh, Netgen_point); - n_id->second = ++Netgen_NbOfNodes; // set netgen ID - - if ( isDegen ) // all nodes on a degen edge get one netgen ID - *(shId_ngId->second) = n_id->second; - } - - // set triangles - list< const SMDS_MeshElement* >::iterator tria = triangles.begin(); - list< bool >::iterator reverse = isReversed.begin(); - for ( ; tria != triangles.end(); ++tria, ++reverse ) - { - int i = 0; - SMDS_ElemIteratorPtr triangleNodesIt = (*tria)->nodesIterator(); - while ( triangleNodesIt->more() ) { - const SMDS_MeshNode * node = - static_cast(triangleNodesIt->next()); - if(myTool->IsMedium(node)) - continue; - Netgen_triangle[ *reverse ? 2 - i : i ] = nodeToNetgenID[ node ]; - ++i; - } - if ( !hasDegen || - // ignore degenerated triangles, they have 2 or 3 same ids - (Netgen_triangle[0] != Netgen_triangle[1] && - Netgen_triangle[0] != Netgen_triangle[2] && - Netgen_triangle[2] != Netgen_triangle[1] )) + if ( internals.hasInternalVertexInSolid() ) { - Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle); + netgen::OCCGeometry occgeo; + NETGENPlugin_Mesher::addIntVerticesInSolids( occgeo, + (netgen::Mesh&) *Netgen_mesh, + nodeVec, + internals); } } @@ -348,43 +324,95 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, // Generate the volume mesh // ------------------------- - Ng_Meshing_Parameters Netgen_param; + return compute( aMesh, helper, nodeVec, Netgen_mesh); +} - Netgen_param.secondorder = Netgen_param2ndOrder; - Netgen_param.fineness = Netgen_paramFine; - Netgen_param.maxh = Netgen_paramSize; +//================================================================================ +/*! + * \brief set parameters and generate the volume mesh + */ +//================================================================================ - Ng_Result status; +bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh, + SMESH_MesherHelper& helper, + vector< const SMDS_MeshNode* >& nodeVec, + Ng_Mesh * Netgen_mesh) +{ +#ifdef WITH_SMESH_CANCEL_COMPUTE + netgen::multithread.terminate = 0; +#endif + netgen::Mesh* ngMesh = (netgen::Mesh*)Netgen_mesh; + int Netgen_NbOfNodes = Ng_GetNP(Netgen_mesh); - try { + char *optstr = 0; + int startWith = netgen::MESHCONST_MESHVOLUME; + int endWith = netgen::MESHCONST_OPTVOLUME; + int err = 1; + + NETGENPlugin_Mesher aMesher( &aMesh, helper.GetSubShape(), /*isVolume=*/true ); + netgen::OCCGeometry occgeo; + + if ( _hypParameters ) + { + aMesher.SetParameters( _hypParameters ); + if ( !_hypParameters->GetOptimize() ) + endWith = netgen::MESHCONST_MESHVOLUME; + } + else if ( _hypMaxElementVolume ) + { + netgen::mparam.maxh = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. ); + } + else if ( aMesh.HasShapeToMesh() ) + { + aMesher.PrepareOCCgeometry( occgeo, helper.GetSubShape(), aMesh ); + netgen::mparam.maxh = occgeo.GetBoundingBox().Diam()/2; + } + else + { + netgen::Point3d pmin, pmax; + ngMesh->GetBox (pmin, pmax); + netgen::mparam.maxh = Dist(pmin, pmax)/2; + } + + if ( !_hypParameters && aMesh.HasShapeToMesh() ) + { + netgen::mparam.minh = aMesher.GetDefaultMinSize( helper.GetSubShape(), netgen::mparam.maxh ); + } + + try + { #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif - status = Ng_GenerateVolumeMesh(Netgen_mesh, &Netgen_param); + ngMesh->CalcLocalH(); + err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr); +#ifdef WITH_SMESH_CANCEL_COMPUTE + if(netgen::multithread.terminate) + return false; +#endif + if ( err ) + error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task); } - catch (Standard_Failure& exc) { - error(COMPERR_OCC_EXCEPTION, exc.GetMessageString()); - status = NG_VOLUME_FAILURE; + catch (Standard_Failure& ex) + { + SMESH_Comment str("Exception in netgen::OCCGenerateMesh()"); + str << " at " << netgen::multithread.task + << ": " << ex.DynamicType()->Name(); + if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) + str << ": " << ex.GetMessageString(); + error(str); } - catch (...) { - error("Exception in Ng_GenerateVolumeMesh()"); - status = NG_VOLUME_FAILURE; - } - if ( GetComputeError()->IsOK() ) { - switch ( status ) { - case NG_SURFACE_INPUT_ERROR:error( status, "NG_SURFACE_INPUT_ERROR"); - case NG_VOLUME_FAILURE: error( status, "NG_VOLUME_FAILURE"); - case NG_STL_INPUT_ERROR: error( status, "NG_STL_INPUT_ERROR"); - case NG_SURFACE_FAILURE: error( status, "NG_SURFACE_FAILURE"); - case NG_FILE_NOT_FOUND: error( status, "NG_FILE_NOT_FOUND"); - }; + catch (...) + { + SMESH_Comment str("Exception in netgen::OCCGenerateMesh()"); + str << " at " << netgen::multithread.task; + error(str); } int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh); + int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh); - int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh); - - MESSAGE("End of Volume Mesh Generation. status=" << status << + MESSAGE("End of Volume Mesh Generation. err=" << err << ", nb new nodes: " << Netgen_NbOfNodesNew - Netgen_NbOfNodes << ", nb tetra: " << Netgen_NbOfTetra); @@ -392,114 +420,68 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, // Feed back the SMESHDS with the generated Nodes and Volume Elements // ------------------------------------------------------------------- + if ( err ) + { + SMESH_ComputeErrorPtr ce = NETGENPlugin_Mesher::readErrors(nodeVec); + if ( ce && !ce->myBadElements.empty() ) + error( ce ); + } + bool isOK = ( /*status == NG_OK &&*/ Netgen_NbOfTetra > 0 );// get whatever built if ( isOK ) { - // vector of nodes in which node index == netgen ID - vector< const SMDS_MeshNode* > nodeVec ( Netgen_NbOfNodesNew + 1 ); - // insert old nodes into nodeVec - for ( n_id = nodeToNetgenID.begin(); n_id != nodeToNetgenID.end(); ++n_id ) { - nodeVec.at( n_id->second ) = n_id->first; - } + double Netgen_point[3]; + int Netgen_tetrahedron[4]; + // create and insert new nodes into nodeVec + nodeVec.resize( Netgen_NbOfNodesNew + 1, 0 ); int nodeIndex = Netgen_NbOfNodes + 1; - int shapeID = meshDS->ShapeToIndex( aShape ); for ( ; nodeIndex <= Netgen_NbOfNodesNew; ++nodeIndex ) { Ng_GetPoint( Netgen_mesh, nodeIndex, Netgen_point ); - SMDS_MeshNode * node = meshDS->AddNode(Netgen_point[0], - Netgen_point[1], - Netgen_point[2]); - meshDS->SetNodeInVolume(node, shapeID); - nodeVec.at(nodeIndex) = node; + nodeVec.at(nodeIndex) = helper.AddNode(Netgen_point[0], Netgen_point[1], Netgen_point[2]); } // create tetrahedrons for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex ) { Ng_GetVolumeElement(Netgen_mesh, elemIndex, Netgen_tetrahedron); - SMDS_MeshVolume * elt = myTool->AddVolume (nodeVec.at( Netgen_tetrahedron[0] ), - nodeVec.at( Netgen_tetrahedron[1] ), - nodeVec.at( Netgen_tetrahedron[2] ), - nodeVec.at( Netgen_tetrahedron[3] )); - meshDS->SetMeshElementOnShape(elt, shapeID ); + try + { + helper.AddVolume (nodeVec.at( Netgen_tetrahedron[0] ), + nodeVec.at( Netgen_tetrahedron[1] ), + nodeVec.at( Netgen_tetrahedron[2] ), + nodeVec.at( Netgen_tetrahedron[3] )); + } + catch (...) + { + } } } - Ng_DeleteMesh(Netgen_mesh); - Ng_Exit(); - - NETGENPlugin_Mesher::RemoveTmpFiles(); - - return (status == NG_OK); + return !err; } -bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, +//================================================================================ +/*! + * \brief Compute tetrahedral mesh from 2D mesh without geometry + */ +//================================================================================ + +bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, SMESH_MesherHelper* aHelper) { MESSAGE("NETGENPlugin_NETGEN_3D::Compute with maxElmentsize = " << _maxElementVolume); const int invalid_ID = -1; bool _quadraticMesh = false; - typedef map< const SMDS_MeshNode*, int> TNodeToIDMap; - TNodeToIDMap nodeToNetgenID; - list< const SMDS_MeshElement* > triangles; - SMESHDS_Mesh* MeshDS = aHelper->GetMeshDS(); SMESH_MesherHelper::MType MeshType = aHelper->IsQuadraticMesh(); - + if(MeshType == SMESH_MesherHelper::COMP) return error( COMPERR_BAD_INPUT_MESH, SMESH_Comment("Mesh with linear and quadratic elements given.")); else if (MeshType == SMESH_MesherHelper::QUADRATIC) _quadraticMesh = true; - - StdMeshers_QuadToTriaAdaptor Adaptor; - Adaptor.Compute(aMesh); - - SMDS_FaceIteratorPtr iteratorFace = MeshDS->facesIterator(); - while(iteratorFace->more()) { - // check element - const SMDS_MeshElement* elem = iteratorFace->next(); - if ( !elem ) - return error( COMPERR_BAD_INPUT_MESH, "Null element encounters"); - bool isTraingle = ( elem->NbNodes()==3 || (_quadraticMesh && elem->NbNodes()==6 )); - if ( !isTraingle ) { - //return error( COMPERR_BAD_INPUT_MESH, - // SMESH_Comment("Not triangle element ")<GetID()); - // using adaptor - std::list faces = Adaptor.GetTriangles(elem); - if(faces.size()==0) { - return error( COMPERR_BAD_INPUT_MESH, - SMESH_Comment("Not triangles in adaptor for element ")<GetID()); - } - std::list::iterator itf = faces.begin(); - for(; itf!=faces.end(); itf++ ) { - triangles.push_back( (*itf) ); - // put triange's nodes to nodeToNetgenID map - SMDS_ElemIteratorPtr triangleNodesIt = (*itf)->nodesIterator(); - while ( triangleNodesIt->more() ) { - const SMDS_MeshNode * node = - static_cast(triangleNodesIt->next()); - if(aHelper->IsMedium(node)) - continue; - nodeToNetgenID.insert( make_pair( node, invalid_ID )); - } - } - } - else { - // keep a triangle - triangles.push_back( elem ); - // put elem nodes to nodeToNetgenID map - SMDS_ElemIteratorPtr triangleNodesIt = elem->nodesIterator(); - while ( triangleNodesIt->more() ) { - const SMDS_MeshNode * node = - static_cast(triangleNodesIt->next()); - if(aHelper->IsMedium(node)) - continue; - nodeToNetgenID.insert( make_pair( node, invalid_ID )); - } - } - } // --------------------------------- // Feed the Netgen with surface mesh @@ -514,121 +496,160 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, int Netgen_triangle[3]; int Netgen_tetrahedron[4]; - Ng_Init(); + NETGENPlugin_NetgenLibWrapper ngLib; + Ng_Mesh * Netgen_mesh = ngLib._ngMesh; - Ng_Mesh * Netgen_mesh = Ng_NewMesh(); - - // set nodes and remember thier netgen IDs - - TNodeToIDMap::iterator n_id = nodeToNetgenID.begin(); - for ( ; n_id != nodeToNetgenID.end(); ++n_id ) + SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh )); + if ( aMesh.NbQuadrangles() > 0 ) { - const SMDS_MeshNode* node = n_id->first; - - Netgen_point [ 0 ] = node->X(); - Netgen_point [ 1 ] = node->Y(); - Netgen_point [ 2 ] = node->Z(); - Ng_AddPoint(Netgen_mesh, Netgen_point); - n_id->second = ++Netgen_NbOfNodes; // set netgen ID - + StdMeshers_QuadToTriaAdaptor* Adaptor = new StdMeshers_QuadToTriaAdaptor; + Adaptor->Compute(aMesh); + proxyMesh.reset( Adaptor ); } - // set triangles - list< const SMDS_MeshElement* >::iterator tria = triangles.begin(); - for ( ; tria != triangles.end(); ++tria) + // maps nodes to ng ID + typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap; + typedef TNodeToIDMap::value_type TN2ID; + TNodeToIDMap nodeToNetgenID; + + SMDS_ElemIteratorPtr fIt = proxyMesh->GetFaces(); + while( fIt->more()) { - int i = 0; - SMDS_ElemIteratorPtr triangleNodesIt = (*tria)->nodesIterator(); - while ( triangleNodesIt->more() ) { - const SMDS_MeshNode * node = - static_cast(triangleNodesIt->next()); - if(aHelper->IsMedium(node)) - continue; - Netgen_triangle[ i ] = nodeToNetgenID[ node ]; - ++i; + // check element + const SMDS_MeshElement* elem = fIt->next(); + if ( !elem ) + return error( COMPERR_BAD_INPUT_MESH, "Null element encounters"); + if ( elem->NbCornerNodes() != 3 ) + return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters"); + + // add three nodes of triangle + for ( int iN = 0; iN < 3; ++iN ) + { + const SMDS_MeshNode* node = elem->GetNode( iN ); + int& ngID = nodeToNetgenID.insert(TN2ID( node, invalid_ID )).first->second; + if ( ngID == invalid_ID ) + { + ngID = ++Netgen_NbOfNodes; + Netgen_point [ 0 ] = node->X(); + Netgen_point [ 1 ] = node->Y(); + Netgen_point [ 2 ] = node->Z(); + Ng_AddPoint(Netgen_mesh, Netgen_point); + } + Netgen_triangle[ iN ] = ngID; } - Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle); } + proxyMesh.reset(); // delete tmp faces + + // vector of nodes in which node index == netgen ID + vector< const SMDS_MeshNode* > nodeVec ( nodeToNetgenID.size() + 1 ); + // insert old nodes into nodeVec + TNodeToIDMap::iterator n_id = nodeToNetgenID.begin(); + for ( ; n_id != nodeToNetgenID.end(); ++n_id ) + nodeVec.at( n_id->second ) = n_id->first; + nodeToNetgenID.clear(); // ------------------------- // Generate the volume mesh // ------------------------- - Ng_Meshing_Parameters Netgen_param; - - Netgen_param.secondorder = Netgen_param2ndOrder; - Netgen_param.fineness = Netgen_paramFine; - Netgen_param.maxh = Netgen_paramSize; - - Ng_Result status; - - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - status = Ng_GenerateVolumeMesh(Netgen_mesh, &Netgen_param); - } - catch (Standard_Failure& exc) { - error(COMPERR_OCC_EXCEPTION, exc.GetMessageString()); - status = NG_VOLUME_FAILURE; - } - catch (...) { - error("Bad mesh input!!!"); - status = NG_VOLUME_FAILURE; - } - if ( GetComputeError()->IsOK() ) { - error( status, "Bad mesh input!!!"); - } - - int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh); - - int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh); - - MESSAGE("End of Volume Mesh Generation. status=" << status << - ", nb new nodes: " << Netgen_NbOfNodesNew - Netgen_NbOfNodes << - ", nb tetra: " << Netgen_NbOfTetra); - - // ------------------------------------------------------------------- - // Feed back the SMESHDS with the generated Nodes and Volume Elements - // ------------------------------------------------------------------- - - bool isOK = ( Netgen_NbOfTetra > 0 );// get whatever built - if ( isOK ) - { - // vector of nodes in which node index == netgen ID - vector< const SMDS_MeshNode* > nodeVec ( Netgen_NbOfNodesNew + 1 ); - // insert old nodes into nodeVec - for ( n_id = nodeToNetgenID.begin(); n_id != nodeToNetgenID.end(); ++n_id ) { - nodeVec.at( n_id->second ) = n_id->first; - } - // create and insert new nodes into nodeVec - int nodeIndex = Netgen_NbOfNodes + 1; - - for ( ; nodeIndex <= Netgen_NbOfNodesNew; ++nodeIndex ) - { - Ng_GetPoint( Netgen_mesh, nodeIndex, Netgen_point ); - SMDS_MeshNode * node = aHelper->AddNode(Netgen_point[0], - Netgen_point[1], - Netgen_point[2]); - nodeVec.at(nodeIndex) = node; - } - - // create tetrahedrons - for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex ) - { - Ng_GetVolumeElement(Netgen_mesh, elemIndex, Netgen_tetrahedron); - aHelper->AddVolume (nodeVec.at( Netgen_tetrahedron[0] ), - nodeVec.at( Netgen_tetrahedron[1] ), - nodeVec.at( Netgen_tetrahedron[2] ), - nodeVec.at( Netgen_tetrahedron[3] )); - } - } - - Ng_DeleteMesh(Netgen_mesh); - Ng_Exit(); - - NETGENPlugin_Mesher::RemoveTmpFiles(); - - return (status == NG_OK); + return compute( aMesh, *aHelper, nodeVec, Netgen_mesh); } + +#ifdef WITH_SMESH_CANCEL_COMPUTE +void NETGENPlugin_NETGEN_3D::CancelCompute() +{ + SMESH_Algo::CancelCompute(); + netgen::multithread.terminate = 1; +} +#endif + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + int nbtri = 0, nbqua = 0; + double fullArea = 0.0; + for (TopExp_Explorer expF(aShape, TopAbs_FACE); expF.More(); expF.Next()) { + TopoDS_Face F = TopoDS::Face( expF.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 expF(aShape, TopAbs_EDGE); expF.More(); expF.Next()) { + TopoDS_Edge E = TopoDS::Edge(expF.Current()); + if( tmpMap.Contains(E) ) + continue; + tmpMap.Add(E); + SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(expF.Current()); + MapShapeNbElemsItr anIt = aResMap.find(aSubMesh); + if( anIt==aResMap.end() ) { + SMESH_ComputeErrorPtr& smError = aSubMesh->GetComputeError(); + smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED, + "Submesh can not be evaluated",this)); + return false; + } + 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_face = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) ); + double ELen_vol = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. ); + double ELen = Min(ELen_vol,ELen_face*2); + + 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 = (nbVols*6 - nb1d_e - nb1d_f ) / 5; + std::vector aVec(SMDSEntity_Last); + for(int i=SMDSEntity_Node; i& nodeVec, + nglib::Ng_Mesh* ngMesh); + double _maxElementVolume; + const NETGENPlugin_Hypothesis * _hypParameters; const StdMeshers_MaxElementVolume* _hypMaxElementVolume; + const StdMeshers_ViscousLayers* _viscousLayersHyp; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx index 11b3473..c9d64c8 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses // File : NETGENPlugin_NETGEN_3D_i.cxx // Moved here from SMESH_NETGEN_3D_i.cxx @@ -43,8 +44,8 @@ using namespace std; //============================================================================= NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i( PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ) + int theStudyId, + ::SMESH_Gen* theGenImpl ) : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ), SMESH_Algo_i( thePOA ), @@ -52,8 +53,8 @@ NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i( PortableServer::POA_ptr theP { MESSAGE( "NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i" ); myBaseImpl = new ::NETGENPlugin_NETGEN_3D( theGenImpl->GetANewId(), - theStudyId, - theGenImpl ); + theStudyId, + theGenImpl ); } //============================================================================= diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx index cbc660b..97d7609 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses // File : NETGENPlugin_NETGEN_3D_i.hxx // Moved here from SMESH_NETGEN_3D_i.hxx diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cxx index a54d2fb..dd4f81e 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_2D.cxx // Author : Edward AGAPOV @@ -49,7 +47,8 @@ NETGENPlugin_SimpleHypothesis_2D::NETGENPlugin_SimpleHypothesis_2D (int : SMESH_Hypothesis(hypId, studyId, gen), _nbSegments ((int)NETGENPlugin_Hypothesis::GetDefaultNbSegPerEdge()), _segmentLength(0), - _area (0.) + _area (0.), + _allowQuad (false) { _name = "NETGEN_SimpleParameters_2D"; _param_algo_dim = 2; @@ -120,6 +119,30 @@ void NETGENPlugin_SimpleHypothesis_2D::SetMaxElementArea(double area) } } +//======================================================================= +//function : SetAllowQuadrangles +//purpose : Enables/disables generation of quadrangular faces +//======================================================================= + +void NETGENPlugin_SimpleHypothesis_2D::SetAllowQuadrangles(bool toAllow) +{ + if ( _allowQuad != toAllow ) + { + _allowQuad = toAllow; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetAllowQuadrangles +//purpose : Returns true if generation of quadrangular faces is enabled +//======================================================================= + +bool NETGENPlugin_SimpleHypothesis_2D::GetAllowQuadrangles() const +{ + return _allowQuad; +} + //============================================================================= /*! * @@ -127,7 +150,7 @@ void NETGENPlugin_SimpleHypothesis_2D::SetMaxElementArea(double area) //============================================================================= ostream & NETGENPlugin_SimpleHypothesis_2D::SaveTo(ostream & save) { - save << _nbSegments << " " << _segmentLength << " " << _area; + save << _nbSegments << " " << _segmentLength << " " << _area << " " << _allowQuad; return save; } @@ -160,6 +183,8 @@ istream & NETGENPlugin_SimpleHypothesis_2D::LoadFrom(istream & load) else load.clear(ios::badbit | load.rdstate()); + load >> _allowQuad; + return load; } diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.hxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.hxx index 4ed9218..e4406f8 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D.hxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_2D.hxx // Author : Edward AGAPOV @@ -80,6 +78,15 @@ public: */ double GetMaxElementArea() const { return _area; } + /*! + * Enables/disables generation of quadrangular faces + */ + void SetAllowQuadrangles(bool toAllow); + /*! + * Returns true if generation of quadrangular faces is enabled + */ + bool GetAllowQuadrangles() const; + // Persistence virtual ostream & SaveTo(ostream & save); virtual istream & LoadFrom(istream & load); @@ -101,6 +108,7 @@ public: private: int _nbSegments; double _segmentLength, _area; + bool _allowQuad; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx index fac763e..8cc6590 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_2D_i.cxx // Author : Edward AGAPOV @@ -34,6 +32,8 @@ #include #include +#include + using namespace std; //============================================================================= @@ -84,7 +84,7 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb) catch (SALOME_Exception& S_ex) { THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } - SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << nb << " )"; + SMESH::TPythonDump() << _this() << ".SetNumberOfSegments( " << SMESH::TVar(nb) << " )"; } //============================================================================= @@ -115,7 +115,7 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetLocalLength(CORBA::Double segmentLen catch (SALOME_Exception& S_ex) { THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); } - SMESH::TPythonDump() << _this() << ".SetLocalLength( " << segmentLength << " )"; + SMESH::TPythonDump() << _this() << ".SetLocalLength( " << SMESH::TVar(segmentLength) << " )"; } //================================================================================ @@ -154,7 +154,7 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area) MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea"); ASSERT(myBaseImpl); this->GetImpl()->SetMaxElementArea(area); - SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << area << " )"; + SMESH::TPythonDump() << _this() << ".SetMaxElementArea( " << SMESH::TVar(area) << " )"; } @@ -163,18 +163,43 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetMaxElementArea(CORBA::Double area) * NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() */ //============================================================================= + CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() { MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea"); ASSERT(myBaseImpl); return this->GetImpl()->GetMaxElementArea(); } + +//============================================================================= +/*! + * Enables/disables generation of quadrangular faces + */ +//============================================================================= + +void NETGENPlugin_SimpleHypothesis_2D_i::SetAllowQuadrangles(CORBA::Boolean toAllow) +{ + ASSERT(myBaseImpl); + SMESH::TPythonDump() << _this() << ".SetAllowQuadrangles( " << toAllow << " )"; + this->GetImpl()->SetAllowQuadrangles(toAllow); +} + +//============================================================================= +/*! + * Returns true if generation of quadrangular faces is enabled + */ +//============================================================================= + +CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::GetAllowQuadrangles() +{ + return this->GetImpl()->GetAllowQuadrangles(); +} //============================================================================= /*! * NETGENPlugin_SimpleHypothesis_2D_i::GetImpl */ //============================================================================= -::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl() +::NETGENPlugin_SimpleHypothesis_2D* NETGENPlugin_SimpleHypothesis_2D_i::GetImpl() const { MESSAGE("NETGENPlugin_SimpleHypothesis_2D_i::GetImpl"); return (::NETGENPlugin_SimpleHypothesis_2D*)myBaseImpl; @@ -183,9 +208,9 @@ CORBA::Double NETGENPlugin_SimpleHypothesis_2D_i::GetMaxElementArea() //================================================================================ /*! * \brief Verify whether hypothesis supports given entity type - * \param type - dimension (see SMESH::Dimension enumeration) - * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise - * + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ //================================================================================ @@ -193,3 +218,41 @@ CORBA::Boolean NETGENPlugin_SimpleHypothesis_2D_i::IsDimSupported( SMESH::Dimens { return type == SMESH::DIM_2D; } + +//================================================================================ +/*! + * \brief method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook + */ +//================================================================================ + +int NETGENPlugin_SimpleHypothesis_2D_i::getParamIndex(const TCollection_AsciiString& method, + int nbVars) const +{ + if ( method == "SetLocalLength" ) return 0; + if ( method == "SetNumberOfSegments" ) return 0; + if ( method == "SetMaxElementArea" ) return 1; + if ( method == "LengthFromEdges" ) return 10; // just to go to the next state + if ( method == "SetMaxElementVolume" ) return 2; + if ( method == "LengthFromFaces" ) return 10; // just to go to the next state + + return SMESH_Hypothesis_i::getParamIndex( method, nbVars ); // return default value +} + +//================================================================================ +/*! + * \brief Method used to convert variable parameters stored in an old study + * into myMethod2VarParams. It should return a method name for an index of + * variable parameters. Index is countered from zero + */ +//================================================================================ + +std::string NETGENPlugin_SimpleHypothesis_2D_i::getMethodOfParameter(const int paramIndex, + int nbVars) const +{ + switch ( paramIndex ) { + case 0: return GetImpl()->GetNumberOfSegments() ? "SetNumberOfSegments" : "SetLocalLength"; + case 1: return "SetMaxElementArea"; + case 2: return "SetMaxElementVolume"; + } + return ""; +} diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.hxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.hxx index 5426293..5ad350e 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_2D_i.hxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_2D_i.hxx // Author : Edward AGAPOV @@ -64,12 +62,25 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_2D_i: void SetMaxElementArea(CORBA::Double area); CORBA::Double GetMaxElementArea(); + void SetAllowQuadrangles(CORBA::Boolean toAllow); + CORBA::Boolean GetAllowQuadrangles(); // Get implementation - ::NETGENPlugin_SimpleHypothesis_2D* GetImpl(); + ::NETGENPlugin_SimpleHypothesis_2D* GetImpl() const; // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + public: + // method intended to remove explicit treatment of Netgen hypotheses from + // SMESH_NoteBook to assure backward compatibility after implemeneting + // issue 0021308: Remove hard-coded dependency of the external mesh plugins + virtual int getParamIndex(const TCollection_AsciiString& method, int nbVars) const; + + // method used to convert variable parameters stored in an old study + // into myMethod2VarParams. It should return a method name for an index of + // variable parameters. Index is countered from zero + virtual std::string getMethodOfParameter(const int paramIndex, int nbVars) const; }; #endif diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.cxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.cxx index fd799b9..3fb1d3f 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_3D.cxx // Author : Edward AGAPOV diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.hxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.hxx index 7b7de4f..537dd35 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D.hxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_3D.hxx // Author : Edward AGAPOV diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D_i.cxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D_i.cxx index 96b9aa8..5becc61 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D_i.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_3D_i.cxx // Author : Edward AGAPOV @@ -94,7 +92,7 @@ void NETGENPlugin_SimpleHypothesis_3D_i::SetMaxElementVolume(CORBA::Double value MESSAGE("NETGENPlugin_SimpleHypothesis_3D_i::SetMaxElementVolume"); ASSERT(myBaseImpl); this->GetImpl()->SetMaxElementVolume(value); - SMESH::TPythonDump() << _this() << ".SetMaxElementVolume( " << value << " )"; + SMESH::TPythonDump() << _this() << ".SetMaxElementVolume( " << SMESH::TVar(value) << " )"; } diff --git a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D_i.hxx b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D_i.hxx index 6fd6688..e52dbab 100644 --- a/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D_i.hxx +++ b/src/NETGENPlugin/NETGENPlugin_SimpleHypothesis_3D_i.hxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is 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 // + // NETGENPlugin : C++ implementation // File : NETGENPlugin_SimpleHypothesis_3D_i.hxx // Author : Edward AGAPOV diff --git a/src/NETGENPlugin/NETGENPlugin_i.cxx b/src/NETGENPlugin/NETGENPlugin_i.cxx index 78e77c1..acfa7c0 100644 --- a/src/NETGENPlugin/NETGENPlugin_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_i.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is 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 // + // SMESH NETGENPlugin : implementaion of SMESH idl descriptions // File : NETGENPlugin.cxx // Author : Julia DOROVSKIKH @@ -27,12 +28,14 @@ // #include "utilities.h" -#include "NETGENPlugin_NETGEN_3D_i.hxx" -#include "NETGENPlugin_NETGEN_2D_i.hxx" -#include "NETGENPlugin_NETGEN_2D_ONLY_i.hxx" -#include "NETGENPlugin_NETGEN_2D3D_i.hxx" -#include "NETGENPlugin_Hypothesis_i.hxx" +#include "NETGENPlugin_Hypothesis_2D_ONLY_i.hxx" #include "NETGENPlugin_Hypothesis_2D_i.hxx" +#include "NETGENPlugin_Hypothesis_3D_i.hxx" +#include "NETGENPlugin_Hypothesis_i.hxx" +#include "NETGENPlugin_NETGEN_2D3D_i.hxx" +#include "NETGENPlugin_NETGEN_2D_ONLY_i.hxx" +#include "NETGENPlugin_NETGEN_2D_i.hxx" +#include "NETGENPlugin_NETGEN_3D_i.hxx" #include "NETGENPlugin_SimpleHypothesis_2D_i.hxx" #include "NETGENPlugin_SimpleHypothesis_3D_i.hxx" @@ -73,6 +76,10 @@ extern "C" aCreator = new NETGENPlugin_Creator_i; else if (strcmp(aHypName, "NETGEN_Parameters_2D") == 0) aCreator = new NETGENPlugin_Creator_i; + else if (strcmp(aHypName, "NETGEN_Parameters_3D") == 0) + aCreator = new NETGENPlugin_Creator_i; + else if (strcmp(aHypName, "NETGEN_Parameters_2D_ONLY") == 0) + aCreator = new NETGENPlugin_Creator_i; else if (strcmp(aHypName, "NETGEN_SimpleParameters_2D") == 0) aCreator = new NETGENPlugin_Creator_i; else if (strcmp(aHypName, "NETGEN_SimpleParameters_3D") == 0)