From: mkr Date: Mon, 24 Mar 2008 11:48:15 +0000 (+0000) Subject: Merge from BR_Dev_For_4_0. X-Git-Tag: V5_0_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=045264aff07029417a58f120d17e3f084f0c9178;p=plugins%2Fnetgenplugin.git Merge from BR_Dev_For_4_0. --- diff --git a/build_configure b/build_configure index 4c67778..c97ecba 100755 --- a/build_configure +++ b/build_configure @@ -13,6 +13,7 @@ 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 @@ -28,12 +29,26 @@ fi # echo "failed : KERNEL_SRC variable is not correct !" # exit #fi +for option +do + case $option in + -with-ihm | --with-ihm) + NETGENPLUGIN_WITH_GUI="yes" + break;; + -without-ihm | --without-ihm | -with-ihm=no | --with-ihm=no) + NETGENPLUGIN_WITH_GUI="no" + break;; + esac +done + ######################################################################## # Test if the GUI_ROOT_DIR is set correctly -if test ! -d "${GUI_ROOT_DIR}"; then - echo "failed : GUI_ROOT_DIR variable is not correct !" - exit +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 ######################################################################## @@ -63,24 +78,29 @@ fi 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/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 +#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 +#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 # ____________________________________________________________________ @@ -92,7 +112,20 @@ for deprecated in ac_cc_warnings.m4 ac_cxx_partial_specialization.m4 \ # autom4te.cache (directory) echo "====================================================== aclocal" -aclocal -I adm_local/unix/config_files -I salome_adm/unix/config_files || exit 1 +if test ${NETGENPLUGIN_WITH_GUI} = yes; 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 \ + -I ${MED_ROOT_DIR}/adm_local/unix/config_files \ + -I ${GEOM_ROOT_DIR}/adm_local/unix/config_files \ + -I ${SMESH_ROOT_DIR}/adm_local/unix/config_files || exit 1 +else + aclocal -I adm_local/unix/config_files \ + -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \ + -I ${MED_ROOT_DIR}/adm_local/unix/config_files \ + -I ${GEOM_ROOT_DIR}/adm_local/unix/config_files \ + -I ${SMESH_ROOT_DIR}/adm_local/unix/config_files || exit 1 +fi # ____________________________________________________________________ # libtoolize creates some configuration files (ltmain.sh, diff --git a/configure.ac b/configure.ac index 0059e1f..5c19daf 100644 --- a/configure.ac +++ b/configure.ac @@ -17,18 +17,13 @@ # Created from configure.in.base # -AC_INIT([Salome2 Project NETGENPLUGIN module], [4.0.0], [gboulant@CS], [salome]) +AC_INIT([Salome2 Project NETGENPLUGIN module], [4.1.1], [webmaster.salome@opencascade.com], [salome]) AC_CONFIG_AUX_DIR(salome_adm/unix/config_files) AC_CANONICAL_HOST AC_CANONICAL_TARGET AM_INIT_AUTOMAKE -PACKAGE=salome -AC_SUBST(PACKAGE) - -VERSION=4.0.0 -XVERSION=0x040000 -AC_SUBST(VERSION) +XVERSION=`echo $VERSION | awk -F. '{printf("0x%02x%02x%02x",$1,$2,$3)}'` AC_SUBST(XVERSION) # set up MODULE_NAME variable for dynamic construction of directories (resources, etc.) @@ -228,37 +223,63 @@ AC_SUBST_FILE(CORBA) corba=make_$ORB CORBA=adm_local/unix/$corba -echo -echo --------------------------------------------- -echo testing openGL -echo --------------------------------------------- -echo +NETGENPLUGIN_WITH_GUI=no -CHECK_OPENGL +AM_CONDITIONAL(NETGENPLUGIN_ENABLE_GUI, [test "${NETGENPLUGIN_WITH_GUI}" = "yes"]) -echo -echo --------------------------------------------- -echo testing QT -echo --------------------------------------------- -echo +if test "${NETGENPLUGIN_WITH_GUI}" = "yes"; then + echo + echo --------------------------------------------- + echo testing MSG2QM + echo --------------------------------------------- + echo -CHECK_QT + CHECK_MSG2QM -echo -echo --------------------------------------------- -echo testing MSG2QM -echo --------------------------------------------- -echo + echo + echo --------------------------------------------- + echo testing openGL + echo --------------------------------------------- + echo -CHECK_MSG2QM + CHECK_OPENGL -echo -echo --------------------------------------------- -echo testing VTK -echo --------------------------------------------- -echo + echo + echo --------------------------------------------- + echo testing QT + echo --------------------------------------------- + echo + + CHECK_QT + + echo + echo --------------------------------------------- + echo testing VTK + echo --------------------------------------------- + echo + + CHECK_VTK -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 --------------------------------------------- @@ -284,26 +305,6 @@ echo CHECK_HTML_GENERATORS -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 - echo echo --------------------------------------------- echo Testing Kernel @@ -353,7 +354,12 @@ echo #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" +fi for var in $variables do diff --git a/idl/NETGENPlugin_Algorithm.idl b/idl/NETGENPlugin_Algorithm.idl index ffee6c4..687419c 100644 --- a/idl/NETGENPlugin_Algorithm.idl +++ b/idl/NETGENPlugin_Algorithm.idl @@ -41,19 +41,28 @@ module NETGENPlugin }; /*! - * NETGENPlugin_NETGEN_2D: interface of "1D-2D (Netgen)" algorithm + * NETGENPlugin_NETGEN_2D: interface of "Netgen 1D-2D" algorithm */ interface NETGENPlugin_NETGEN_2D : SMESH::SMESH_2D_Algo { }; /*! - * NETGENPlugin_NETGEN_2D3D: interface of "1D-2D-3D (Netgen)" algorithm + * NETGENPlugin_NETGEN_2D3D: interface of "Netgen 1D-2D-3D" algorithm */ interface NETGENPlugin_NETGEN_2D3D : SMESH::SMESH_3D_Algo { }; + /*! + * NETGENPlugin_NETGEN_2D_ONLY: interface of "Netgen 2D" algorithm, + * generating 2D elements on a geometrical face taking + * into account pre-existing nodes on face boundaries + */ + interface NETGENPlugin_NETGEN_2D_ONLY : SMESH::SMESH_2D_Algo + { + }; + /*! * NETGENPlugin_Hypothesis: interface of "NETGEN parameters" hypothesis */ diff --git a/resources/NETGENPlugin.xml b/resources/NETGENPlugin.xml index 1a32055..6135daa 100644 --- a/resources/NETGENPlugin.xml +++ b/resources/NETGENPlugin.xml @@ -24,6 +24,7 @@ label-id="Tetrahedron (Netgen)" icon-id="mesh_algo_tetra.png" hypos="MaxElementVolume" + need-geom="false" input="TRIA" dim="3"/> + diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx index 5da2f11..6f81cf2 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx @@ -122,16 +122,18 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() myGrowthRate->setMinValue( 0.1 ); myGrowthRate->setMaxValue( 10 ); myGrowthRate->setLineStep( 0.1 ); - + + const double VALUE_MAX = 1.0e+6; + new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), GroupC1 ); myNbSegPerEdge = new QtxDblSpinBox( GroupC1 ); myNbSegPerEdge->setMinValue( 0.2 ); - myNbSegPerEdge->setMaxValue( 5.0 ); + myNbSegPerEdge->setMaxValue( VALUE_MAX ); // (PAL14890) max value in native netgen gui is 5 new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), GroupC1 ); myNbSegPerRadius = new QtxDblSpinBox( GroupC1 ); myNbSegPerRadius->setMinValue( 0.2 ); - myNbSegPerRadius->setMaxValue( 5.0 ); + myNbSegPerRadius->setMaxValue( VALUE_MAX ); // (PAL14890) max value in native netgen gui is 5 if ( hypType()=="NETGEN_Parameters_2D" ) { diff --git a/src/Makefile.am b/src/Makefile.am index 20b4341..f4af73a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,4 +27,10 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am -SUBDIRS = NETGEN NETGENPlugin GUI +#SUBDIRS = NETGEN NETGENPlugin GUI + +SUBDIRS = NETGEN NETGENPlugin + +if NETGENPLUGIN_ENABLE_GUI + SUBDIRS += GUI +endif diff --git a/src/NETGEN/netgen45ForSalome.patch b/src/NETGEN/netgen45ForSalome.patch index e819950..1560303 100644 --- a/src/NETGEN/netgen45ForSalome.patch +++ b/src/NETGEN/netgen45ForSalome.patch @@ -1,1058 +1,1058 @@ -diff -Nru netgen-4.5_orig/libsrc/csg/meshsurf.cpp netgen-4.5_patch/libsrc/csg/meshsurf.cpp ---- netgen-4.5_orig/libsrc/csg/meshsurf.cpp 2006-02-14 10:54:35.000000000 +0300 -+++ netgen-4.5_patch/libsrc/csg/meshsurf.cpp 2006-10-25 16:05:59.000000000 +0400 -@@ -77,11 +77,12 @@ - } - - --void MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const -+bool MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const - { - Point<3> hp = p; - geometry.GetSurface(surfind)->Project (hp); - p = hp; -+ return true; - } - - void MeshOptimize2dSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2, -diff -Nru netgen-4.5_orig/libsrc/csg/meshsurf.hpp netgen-4.5_patch/libsrc/csg/meshsurf.hpp ---- netgen-4.5_orig/libsrc/csg/meshsurf.hpp 2004-01-20 13:49:44.000000000 +0300 -+++ netgen-4.5_patch/libsrc/csg/meshsurf.hpp 2006-10-25 16:08:05.000000000 +0400 -@@ -45,7 +45,7 @@ - MeshOptimize2dSurfaces (const CSGeometry & ageometry); - - /// -- virtual void ProjectPoint (INDEX surfind, Point3d & p) const; -+ virtual bool ProjectPoint (INDEX surfind, Point3d & p) const; - /// - virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const; - /// -diff -Nru netgen-4.5_orig/libsrc/interface/Makefile netgen-4.5_patch/libsrc/interface/Makefile ---- netgen-4.5_orig/libsrc/interface/Makefile 2005-08-09 18:14:59.000000000 +0400 -+++ netgen-4.5_patch/libsrc/interface/Makefile 2006-04-27 13:12:54.000000000 +0400 -@@ -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 -+src = 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 nglib.cpp ngnewdelete.cpp - # - lib = nginterface - libpath = libsrc/interface -diff -Nru netgen-4.5_orig/libsrc/interface/nglib.cpp netgen-4.5_patch/libsrc/interface/nglib.cpp ---- netgen-4.5_orig/libsrc/interface/nglib.cpp 2005-10-18 17:53:18.000000000 +0400 -+++ netgen-4.5_patch/libsrc/interface/nglib.cpp 2006-04-27 13:12:54.000000000 +0400 -@@ -56,7 +56,8 @@ - - void Ng_Exit () - { -- ; -+ delete testout; -+ testout = NULL; - } - - -diff -Nru netgen-4.5_orig/libsrc/makefile.inc netgen-4.5_patch/libsrc/makefile.inc ---- netgen-4.5_orig/libsrc/makefile.inc 2005-09-02 17:17:51.000000000 +0400 -+++ netgen-4.5_patch/libsrc/makefile.inc 2006-10-26 09:33:58.000000000 +0400 -@@ -8,17 +8,14 @@ - LIBSRC_DIR=$(CPP_DIR)/libsrc - LIB_DIR=$(CPP_DIR)/lib/$(MACHINE) - --#OCC_DIR=../../occ --#OCCINC_DIR=$(OCC_DIR)/inc --#OCCLIB_DIR=$(OCC_DIR)/lib --# OCC_DIR=/opt/OpenCASCADE5.2/ros --# OCC_DIR=/home/joachim/download/occ/Linux --# OCCINC_DIR=$(OCC_DIR)/inc -I$(OCC_DIR)/ros/inc --# OCCLIB_DIR=$(OCC_DIR)/Linux/lib -+OCC_DIR=$(CASROOT) -+OCCINC_DIR=$(OCC_DIR)/inc -+OCCLIB_DIR=$(OCC_DIR)/Linux/lib - # - include $(LIBSRC_DIR)/makefile.mach.$(MACHINE) - # --CPLUSPLUSFLAGS1 = -c -I$(LIBSRC_DIR)/include -I$(OCCINC_DIR) -+CPLUSPLUSFLAGS1 = -c -I$(LIBSRC_DIR)/include -I$(OCCINC_DIR) \ -+ -DOCCGEOMETRY -DOCC52 -DHAVE_IOSTREAM -DHAVE_LIMITS_H - # - ARFLAGS = r - # -diff -Nru netgen-4.5_orig/libsrc/makefile.mach.LINUX netgen-4.5_patch/libsrc/makefile.mach.LINUX ---- netgen-4.5_orig/libsrc/makefile.mach.LINUX 2004-10-11 23:49:26.000000000 +0400 -+++ netgen-4.5_patch/libsrc/makefile.mach.LINUX 2006-04-27 13:12:54.000000000 +0400 -@@ -16,7 +16,7 @@ - # - CFLAGS2 = - --CPLUSPLUSFLAGS2 = -O2 -I/usr/include/GL3.5 -DLINUX -DOPENGL \ -+CPLUSPLUSFLAGS2 = -O2 -I/usr/include/GL3.5 -DLINUX \ - -ftemplate-depth-99 -finline-limit=10000 \ - -Wdisabled-optimization -funroll-loops -DnoNGSOLVE - -diff -Nru netgen-4.5_orig/libsrc/meshing/improve2.cpp netgen-4.5_patch/libsrc/meshing/improve2.cpp ---- netgen-4.5_orig/libsrc/meshing/improve2.cpp 2006-01-11 18:08:19.000000000 +0300 -+++ netgen-4.5_patch/libsrc/meshing/improve2.cpp 2006-04-27 13:12:54.000000000 +0400 -@@ -4,7 +4,7 @@ - #include - - #ifndef SMALLLIB --#include -+//#include - #endif - - namespace netgen -diff -Nru netgen-4.5_orig/libsrc/meshing/improve2.hpp netgen-4.5_patch/libsrc/meshing/improve2.hpp ---- netgen-4.5_orig/libsrc/meshing/improve2.hpp 2004-10-12 23:22:55.000000000 +0400 -+++ netgen-4.5_patch/libsrc/meshing/improve2.hpp 2006-10-25 16:09:37.000000000 +0400 -@@ -32,17 +32,16 @@ - /// - virtual void SelectSurfaceOfPoint (const Point3d & p, - const PointGeomInfo & gi); -- /// -- virtual void ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { }; -+ -+ /// project point on surface, returns true if success -+ virtual bool ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { return false; } -+ /// fast project point on surface using point geom info of a neighboring point -+ /// if gi.trignum != 0, -+ /// returns true if success, gi is updated -+ virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const -+ { gi.trignum = 1; return ProjectPoint (surfind, p); } - /// - virtual void ProjectPoint2 (INDEX /* surfind */, INDEX /* surfind2 */, Point3d & /* p */) const { }; -- /// liefert zu einem 3d-Punkt die geominfo (Dreieck) und liefert 1, wenn erfolgreich, -- /// 0, wenn nicht (Punkt ausserhalb von chart) -- virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& /*p3*/) const -- { gi.trignum = 1; return 1;}; -- -- virtual int CalcPointGeomInfo(int /* surfind */, PointGeomInfo& gi, const Point3d& p3) const -- { return CalcPointGeomInfo (gi, p3); } - - /// - virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const; -diff -Nru netgen-4.5_orig/libsrc/meshing/smoothing2.cpp netgen-4.5_patch/libsrc/meshing/smoothing2.cpp ---- netgen-4.5_orig/libsrc/meshing/smoothing2.cpp 2006-01-11 18:08:20.000000000 +0300 -+++ netgen-4.5_patch/libsrc/meshing/smoothing2.cpp 2006-10-25 16:10:46.000000000 +0400 -@@ -300,7 +300,7 @@ - double Opti2SurfaceMinFunction :: - FuncGrad (const Vector & x, Vector & grad) const - { -- Vec3d n, vgrad; -+ Vec3d vgrad; - Point3d pp1; - double g1x, g1y; - double badness, hbadness; -@@ -308,8 +308,6 @@ - vgrad = 0; - badness = 0; - -- meshthis -> GetNormalVector (surfi, sp1, gi1, n); -- - pp1 = sp1; - pp1.Add2 (x.Get(1), t1, x.Get(2), t2); - -@@ -360,7 +358,7 @@ - double Opti2SurfaceMinFunction :: - FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const - { -- Vec3d n, vgrad; -+ Vec3d vgrad; - Point3d pp1; - double g1x, g1y; - double badness, hbadness; -@@ -368,8 +366,6 @@ - vgrad = 0; - badness = 0; - -- meshthis -> GetNormalVector (surfi, sp1, gi1, n); -- - pp1 = sp1; - pp1.Add2 (x.Get(1), t1, x.Get(2), t2); - -@@ -520,7 +516,7 @@ - // from 2d: - - int j, k, lpi, gpi; -- Vec3d n, vgrad; -+ Vec3d vgrad; - Point3d pp1; - Vec2d g1, vdir; - double badness, hbadness, hbad, hderiv; -@@ -528,8 +524,6 @@ - vgrad = 0; - badness = 0; - -- meshthis -> GetNormalVector (surfi, sp1, gi1, n); -- - pp1 = sp1; - pp1.Add2 (x.Get(1), t1, x.Get(2), t2); - -@@ -593,7 +587,7 @@ - // from 2d: - - int j, k, lpi, gpi; -- Vec3d n, vgrad; -+ Vec3d vgrad; - Point3d pp1; - Vec2d g1, vdir; - double badness, hbadness, hbad, hderiv; -@@ -601,8 +595,6 @@ - vgrad = 0; - badness = 0; - -- meshthis -> GetNormalVector (surfi, sp1, gi1, n); -- - pp1 = sp1; - pp1.Add2 (x.Get(1), t1, x.Get(2), t2); - -@@ -859,19 +851,21 @@ - locelements.SetSize(0); - locrots.SetSize (0); - lochs.SetSize (0); -+ ngi.trignum = 0; - - for (j = 0; j < elementsonpoint[pi].Size(); j++) - { - sei = elementsonpoint[pi][j]; - const Element2d & bel = mesh[sei]; - surfi = mesh.GetFaceDescriptor(bel.GetIndex()).SurfNr(); -- -+ - locelements.Append (sei); - - for (k = 1; k <= bel.GetNP(); k++) - if (bel.PNum(k) == pi) - { - locrots.Append (k); -+ ngi = bel.GeomInfoPi(k); - break; - } - -@@ -942,7 +936,7 @@ - } - - //optimizer loop (if not whole distance is not possible, move only a bit!!!!) -- while (loci <= 5 && !moveisok) -+ while (loci <= 5 && !moveisok) - { - loci ++; - mesh[pi].X() = origp.X() + (x.Get(1) * t1.X() + x.Get(2) * t2.X())*fact; -@@ -951,11 +945,9 @@ - fact = fact/2.; - - -- ProjectPoint (surfi, mesh[pi]); -+ moveisok = ProjectPoint (surfi, mesh[pi], ngi); - -- moveisok = CalcPointGeomInfo(surfi, ngi, mesh[pi]); -- // point lies on same chart in stlsurface -- -+ // point lies on same chart in stlsurface - if (moveisok) - { - for (j = 0; j < locelements.Size(); j++) -diff -Nru netgen-4.5_orig/libsrc/occ/occconstruction.cpp netgen-4.5_patch/libsrc/occ/occconstruction.cpp ---- netgen-4.5_orig/libsrc/occ/occconstruction.cpp 2005-12-06 17:15:53.000000000 +0300 -+++ netgen-4.5_patch/libsrc/occ/occconstruction.cpp 2006-04-27 13:12:54.000000000 +0400 -@@ -28,8 +28,8 @@ - #include - #include - #include --#include --#include -+//#include -+//#include - #include - #include - namespace netgen -diff -Nru netgen-4.5_orig/libsrc/occ/occgenmesh.cpp netgen-4.5_patch/libsrc/occ/occgenmesh.cpp ---- netgen-4.5_orig/libsrc/occ/occgenmesh.cpp 2006-02-07 12:12:48.000000000 +0300 -+++ netgen-4.5_patch/libsrc/occ/occgenmesh.cpp 2006-10-25 16:14:48.000000000 +0400 -@@ -28,7 +28,7 @@ - return Point<3> (p.X(), p.Y(), p.Z()); - } - -- void DivideEdge (TopoDS_Edge & edge, -+ static void DivideEdge (TopoDS_Edge & edge, - ARRAY & ps, - ARRAY & params, - Mesh & mesh) -@@ -49,23 +49,19 @@ - hvalue[0] = 0; - pnt = c->Value(s0); - -- double olddist = 0; -- double dist = 0; -- -- for (int i = 1; i <= DIVIDEEDGESECTIONS; i++) -+ int i; -+ for (i = 1; i <= DIVIDEEDGESECTIONS; i++) - { - 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()))* -- pnt.Distance(oldpnt); -+ 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; - -- -- olddist = dist; -- dist = pnt.Distance(oldpnt); - } - - // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS])); -@@ -74,7 +70,7 @@ - ps.SetSize(nsubedges-1); - params.SetSize(nsubedges+1); - -- int i = 1; -+ i = 1; - int i1 = 0; - do - { -@@ -112,7 +108,7 @@ - - static void FindEdges (OCCGeometry & geom, Mesh & mesh) - { -- char * savetask = multithread.task; -+ const char * savetask = multithread.task; - multithread.task = "Edge meshing"; - - (*testout) << "edge meshing" << endl; -@@ -124,6 +120,7 @@ - (*testout) << "nedges = " << nedges << endl; - - double eps = 1e-6 * geom.GetBoundingBox().Diam(); -+ double eps2 = eps * eps; - - for (int i = 1; i <= nvertices; i++) - { -@@ -133,7 +130,7 @@ - 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)) < eps2) - { - exists = 1; - break; -@@ -276,8 +273,8 @@ - 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) < eps2) pnums[0] = pi; -+ if (Dist2 (mesh[pi], lp) < eps2) pnums.Last() = pi; - } - } - -@@ -287,7 +284,7 @@ - bool exists = 0; - int j; - for (j = first_ep; j <= mesh.GetNP(); j++) -- if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps) -+ if (Dist2(mesh.Point(j), Point<3>(mp[i-1])) < eps2) - { - exists = 1; - break; -@@ -394,7 +391,7 @@ - int i, j, k; - int changed; - -- char * savetask = multithread.task; -+ const char * savetask = multithread.task; - multithread.task = "Surface meshing"; - - geom.facemeshstatus = 0; -@@ -751,7 +748,7 @@ - multithread.task = savetask; - } - -- double ComputeH (double kappa) -+ static double ComputeH (double kappa) - { - double hret; - kappa *= mparam.curvaturesafety; -@@ -779,7 +776,7 @@ - double nq = n*q; - - Point<3> p = p0 + 0.5*n; -- double lambda = (p-l.p0)*n / nq; -+ double lambda = (fabs(nq) > 1e-10 ? (p-l.p0)*n / nq : -1); - - if (lambda >= 0 && lambda <= 1) - { -@@ -799,55 +796,55 @@ - - - -- void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2, -- BRepLProp_SLProps * prop, Mesh & mesh, const double maxside, int depth, double h = 0) -+ static void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2, -+ BRepAdaptor_Surface& surf, Mesh & mesh, const double maxside, int depth, double h = 0) - { -- -+ BRepLProp_SLProps prop(surf, 2, 1e-5); - - gp_Pnt2d parmid; - - parmid.SetX(0.3*(par0.X()+par1.X()+par2.X())); - parmid.SetY(0.3*(par0.Y()+par1.Y()+par2.Y())); - -- if (depth == 0) -+ //if (depth == 0) - { - double curvature = 0; - -- prop->SetParameters (parmid.X(), parmid.Y()); -- if (!prop->IsCurvatureDefined()) -+ prop.SetParameters (parmid.X(), parmid.Y()); -+ if (!prop.IsCurvatureDefined()) - { - (*testout) << "curvature not defined!" << endl; - return; - } -- curvature = max(fabs(prop->MinCurvature()), -- fabs(prop->MaxCurvature())); -+ curvature = max(fabs(prop.MinCurvature()), -+ fabs(prop.MaxCurvature())); - -- prop->SetParameters (par0.X(), par0.Y()); -- if (!prop->IsCurvatureDefined()) -+ prop.SetParameters (par0.X(), par0.Y()); -+ if (!prop.IsCurvatureDefined()) - { - (*testout) << "curvature not defined!" << endl; - return; - } -- curvature = max(curvature,max(fabs(prop->MinCurvature()), -- fabs(prop->MaxCurvature()))); -+ curvature = max(curvature,max(fabs(prop.MinCurvature()), -+ fabs(prop.MaxCurvature()))); - -- prop->SetParameters (par1.X(), par1.Y()); -- if (!prop->IsCurvatureDefined()) -+ prop.SetParameters (par1.X(), par1.Y()); -+ if (!prop.IsCurvatureDefined()) - { - (*testout) << "curvature not defined!" << endl; - return; - } -- curvature = max(curvature,max(fabs(prop->MinCurvature()), -- fabs(prop->MaxCurvature()))); -+ curvature = max(curvature,max(fabs(prop.MinCurvature()), -+ fabs(prop.MaxCurvature()))); - -- prop->SetParameters (par2.X(), par2.Y()); -- if (!prop->IsCurvatureDefined()) -+ prop.SetParameters (par2.X(), par2.Y()); -+ if (!prop.IsCurvatureDefined()) - { - (*testout) << "curvature not defined!" << endl; - return; - } -- curvature = max(curvature,max(fabs(prop->MinCurvature()), -- fabs(prop->MaxCurvature()))); -+ curvature = max(curvature,max(fabs(prop.MinCurvature()), -+ fabs(prop.MaxCurvature()))); - - //(*testout) << "curvature " << curvature << endl; - -@@ -886,51 +883,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())); - -- RestrictHTriangle (pm0, pm1, pm2, prop, mesh, 0.5*maxside, depth+1, h); -- RestrictHTriangle (par0, pm1, pm2, prop, mesh, 0.5*maxside, depth+1, h); -- RestrictHTriangle (par1, pm0, pm2, prop, mesh, 0.5*maxside, depth+1, h); -- RestrictHTriangle (par2, pm1, pm0, prop, mesh, 0.5*maxside, depth+1, h); -+ RestrictHTriangle (pm0, pm1, pm2, surf, mesh, 0.5*maxside, depth+1, h); -+ RestrictHTriangle (par0, pm1, pm2, surf, mesh, 0.5*maxside, depth+1, h); -+ RestrictHTriangle (par1, pm0, pm2, surf, mesh, 0.5*maxside, depth+1, h); -+ RestrictHTriangle (par2, pm1, pm0, surf, mesh, 0.5*maxside, depth+1, h); - } - else - { - gp_Pnt pnt; - Point3d p3d; - -- prop->SetParameters (parmid.X(), parmid.Y()); -- pnt = prop->Value(); -+ surf.D0(parmid.X(), parmid.Y(), pnt); - p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z()); - mesh.RestrictLocalH (p3d, h); - - -- prop->SetParameters (par0.X(), par0.Y()); -- pnt = prop->Value(); -+ surf.D0(par0.X(), par0.Y(), pnt); - p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z()); - mesh.RestrictLocalH (p3d, h); - -- prop->SetParameters (par1.X(), par1.Y()); -- pnt = prop->Value(); -+ surf.D0(par1.X(), par1.Y(), pnt); - p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z()); - mesh.RestrictLocalH (p3d, h); - -- prop->SetParameters (par2.X(), par2.Y()); -- pnt = prop->Value(); -+ surf.D0(par2.X(), par2.Y(), pnt); - p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z()); - mesh.RestrictLocalH (p3d, h); - -- (*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl; -+ //(*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl; - /* - (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; - -- prop->SetParameters (par0.X(), par0.Y()); -- pnt = prop->Value(); -+ prop.SetParameters (par0.X(), par0.Y()); -+ pnt = prop.Value(); - (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; - -- prop->SetParameters (par1.X(), par1.Y()); -- pnt = prop->Value(); -+ prop.SetParameters (par1.X(), par1.Y()); -+ pnt = prop.Value(); - (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; - -- prop->SetParameters (par2.X(), par2.Y()); -- pnt = prop->Value(); -+ prop.SetParameters (par2.X(), par2.Y()); -+ pnt = prop.Value(); - (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; - */ - } -@@ -970,7 +963,7 @@ - if (mparam.uselocalh) - { - -- char * savetask = multithread.task; -+ const char * savetask = multithread.task; - multithread.percent = 0; - - mesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading); -@@ -1075,7 +1068,6 @@ - if (triangulation.IsNull()) continue; - - BRepAdaptor_Surface sf(face, Standard_True); -- BRepLProp_SLProps prop(sf, 2, 1e-5); - - int ntriangles = triangulation -> NbTriangles(); - for (int j = 1; j <= ntriangles; j++) -@@ -1096,7 +1088,7 @@ - maxside = max (maxside, p[1].Distance(p[2])); - //cout << "\rFace " << i << " pos11 ntriangles " << ntriangles << " maxside " << maxside << flush; - -- RestrictHTriangle (par[0], par[1], par[2], &prop, *mesh, maxside, 0); -+ RestrictHTriangle (par[0], par[1], par[2], sf, *mesh, maxside, 0); - //cout << "\rFace " << i << " pos12 ntriangles " << ntriangles << flush; - } - } -diff -Nru netgen-4.5_orig/libsrc/occ/occgeom.cpp netgen-4.5_patch/libsrc/occ/occgeom.cpp ---- netgen-4.5_orig/libsrc/occ/occgeom.cpp 2006-01-25 15:35:50.000000000 +0300 -+++ netgen-4.5_patch/libsrc/occ/occgeom.cpp 2006-10-25 16:15:24.000000000 +0400 -@@ -7,6 +7,8 @@ - #include "ShapeAnalysis_ShapeContents.hxx" - #include "ShapeAnalysis_CheckSmallFace.hxx" - #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx" -+#include -+#include - #include "BRepAlgoAPI_Fuse.hxx" - #include "BRepCheck_Analyzer.hxx" - #include "BRepLib.hxx" -@@ -16,11 +18,19 @@ - #include "Partition_Spliter.hxx" - //#include "VrmlAPI.hxx" - //#include "StlAPI.hxx" -+#include - - - namespace netgen - { - -+ OCCGeometry::~OCCGeometry() -+ { -+ NCollection_DataMap::Iterator it(fclsmap); -+ for (; it.More(); it.Next()) -+ delete it.Value(); -+ } -+ - void OCCGeometry :: PrintNrShapes () - { - TopExp_Explorer e; -@@ -947,13 +957,13 @@ - - void OCCGeometry :: BuildVisualizationMesh () - { -- -- cout << "Preparing visualization (deflection = " << vispar.occdeflection << ") ... " << flush; -+ double vispar_occdeflection = 0.01; -+ cout << "Preparing visualization (deflection = " << vispar_occdeflection << ") ... " << flush; - - - BRepTools::Clean (shape); - //WriteOCC_STL("test.stl"); -- BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar.occdeflection, true); -+ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar_occdeflection, true); - cout << "done" << endl; - - -@@ -973,8 +983,27 @@ - - } - -+ 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 -+ 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; -@@ -983,18 +1012,22 @@ - - //(*testout) << "before " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl; - -- GeomAPI_ProjectPointOnSurf proj(pnt, BRep_Tool::Surface(TopoDS::Face(fmap(surfi)))); -- if (proj.NbPoints() == 0) -- { -- cout << "Projection fails" << endl; -- } -- else -- { -- pnt = proj.NearestPoint(); -- //(*testout) << "after " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl; -+ Handle(ShapeAnalysis_Surface) proj; -+ BRepTopAdaptor_FClass2d *cls; -+ GetFaceTools(surfi, proj, cls); - -- p = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); -- } -+ gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion()); -+ if (cls->Perform(p2d) == TopAbs_OUT) -+ { -+ //cout << "Projection fails" << endl; -+ return false; -+ } -+ pnt = proj->Value(p2d); -+ p2d.Coord(u, v); -+ //(*testout) << "after " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl; -+ -+ p = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); -+ return true; - } - - -@@ -1002,54 +1035,20 @@ - { - gp_Pnt p(ap(0), ap(1), ap(2)); - -- Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); -+ Handle(ShapeAnalysis_Surface) proj; -+ BRepTopAdaptor_FClass2d *cls; -+ GetFaceTools(surfi, proj, cls); - -- 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; -+ gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion()); -+ if (cls->Perform(p2d) == TopAbs_OUT) -+ { -+ //cout << "Projection fails" << endl; -+ return false; -+ } - -- ap = Point<3> (x.X(), x.Y(), x.Z()); -+ p = proj->Value(p2d); -+ p2d.Coord(u, v); -+ ap = Point<3> (p.X(), p.Y(), p.Z()); - - return true; - } -diff -Nru netgen-4.5_orig/libsrc/occ/occgeom.hpp netgen-4.5_patch/libsrc/occ/occgeom.hpp ---- netgen-4.5_orig/libsrc/occ/occgeom.hpp 2006-01-25 15:35:50.000000000 +0300 -+++ netgen-4.5_patch/libsrc/occ/occgeom.hpp 2006-10-25 16:16:01.000000000 +0400 -@@ -15,8 +15,6 @@ - #include "Geom_Curve.hxx" - #include "Geom2d_Curve.hxx" - #include "Geom_Surface.hxx" --#include "GeomAPI_ProjectPointOnSurf.hxx" --#include "GeomAPI_ProjectPointOnCurve.hxx" - #include "BRepTools.hxx" - #include "TopExp.hxx" - #include "BRepBuilderAPI_MakeVertex.hxx" -@@ -41,8 +39,6 @@ - #include "Geom_Curve.hxx" - #include "Geom2d_Curve.hxx" - #include "Geom_Surface.hxx" --#include "GeomAPI_ProjectPointOnSurf.hxx" --#include "GeomAPI_ProjectPointOnCurve.hxx" - #include "TopoDS_Wire.hxx" - #include "BRepTools_WireExplorer.hxx" - #include "BRepTools.hxx" -@@ -69,7 +65,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" -@@ -84,11 +80,15 @@ - #include "STEPControl_Writer.hxx" - #include "StlAPI_Writer.hxx" - #include "STEPControl_StepModelType.hxx" -+#include -+ -+class Handle_ShapeAnalysis_Surface; -+class BRepTopAdaptor_FClass2d; - - namespace netgen - { - --#include "../visualization/vispar.hpp" -+ //#include "../visualization/vispar.hpp" - // class VisualizationParameters; - // extern VisualizationParameters vispar; - -@@ -159,6 +159,8 @@ - class OCCGeometry - { - Point<3> center; -+ mutable NCollection_DataMap fprjmap; -+ mutable NCollection_DataMap fclsmap; - - public: - TopoDS_Shape shape; -@@ -189,6 +191,7 @@ - vmap.Clear(); - } - -+ ~OCCGeometry(); - - void BuildFMap(); - -@@ -204,10 +207,12 @@ - Point<3> Center() - { return center; } - -- void Project (int surfi, Point<3> & p) const; -+ bool Project (int surfi, Point<3> & p, double& u, double& v) const; - bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const; - -- -+ void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj, -+ BRepTopAdaptor_FClass2d*& cls) const; -+ - OCCSurface GetSurface (int surfi) - { - cout << "OCCGeometry::GetSurface using PLANESPACE" << endl; -diff -Nru netgen-4.5_orig/libsrc/occ/occmeshsurf.cpp netgen-4.5_patch/libsrc/occ/occmeshsurf.cpp ---- netgen-4.5_orig/libsrc/occ/occmeshsurf.cpp 2006-01-25 15:36:26.000000000 +0300 -+++ netgen-4.5_patch/libsrc/occ/occmeshsurf.cpp 2006-10-25 16:16:26.000000000 +0400 -@@ -5,6 +5,8 @@ - #include - #include - #include -+#include -+#include - - - namespace netgen -@@ -411,11 +413,16 @@ - } - - -- void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const -+ bool MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const - { - Point<3> hp = p; -- geometry.Project (surfind, hp); -+ 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; - } - - void MeshOptimize2dOCCSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2, -@@ -506,38 +513,6 @@ - } - - -- int MeshOptimize2dOCCSurfaces :: -- CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point3d& p) const -- { -- Standard_Real u,v; -- -- gp_Pnt pnt(p.X(), p.Y(), p.Z()); -- -- Handle(Geom_Surface) occface; -- occface = BRep_Tool::Surface(TopoDS::Face(geometry.fmap(surfind))); -- -- GeomAPI_ProjectPointOnSurf proj(pnt, occface); -- -- if (proj.NbPoints() < 1) -- { -- cout << "ERROR: OCCSurface :: GetNormalVector: GeomAPI_ProjectPointOnSurf failed!" -- << endl; -- cout << p << endl; -- return 0; -- } -- -- proj.LowerDistanceParameters (u, v); -- -- gi.u = u; -- gi.v = v; -- return 1; -- } -- -- -- -- -- -- - OCCRefinementSurfaces :: OCCRefinementSurfaces (const OCCGeometry & ageometry) - : Refinement(), geometry(ageometry) - { -@@ -627,10 +602,11 @@ - if (!geometry.FastProject (surfi, hnewp, u, v)) - { - cout << "Fast projection to surface fails! Using OCC projection" << endl; -- geometry.Project (surfi, hnewp); -+ double u, v; -+ geometry.Project (surfi, hnewp, u, v); - } - -- newgi.trignum = 1; -+ newgi.trignum = surfi; - } - - newp = hnewp; -@@ -653,14 +629,17 @@ - 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); -- }; -+ { -+ double u, v; -+ geometry.Project (surfi, p, u, v); -+ } -+ } - - void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) - { -@@ -668,9 +647,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 -Nru netgen-4.5_orig/libsrc/occ/occmeshsurf.hpp netgen-4.5_patch/libsrc/occ/occmeshsurf.hpp ---- netgen-4.5_orig/libsrc/occ/occmeshsurf.hpp 2005-06-09 18:51:10.000000000 +0400 -+++ netgen-4.5_patch/libsrc/occ/occmeshsurf.hpp 2006-10-25 16:17:22.000000000 +0400 -@@ -151,7 +151,7 @@ - MeshOptimize2dOCCSurfaces (const OCCGeometry & ageometry); - - /// -- virtual void ProjectPoint (INDEX surfind, Point3d & p) const; -+ virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const; - /// - virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const; - /// -@@ -159,9 +159,6 @@ - /// - virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const; - -- -- virtual int CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point3d& p3) const; -- - }; - - -diff -Nru netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.cpp netgen-4.5_patch/libsrc/stlgeom/meshstlsurface.cpp ---- netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.cpp 2006-01-11 18:08:20.000000000 +0300 -+++ netgen-4.5_patch/libsrc/stlgeom/meshstlsurface.cpp 2006-10-25 16:17:47.000000000 +0400 -@@ -946,20 +946,23 @@ - } - - --void MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point3d & p) const -+bool MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const - { - Point<3> hp = p; -- if (!geom.Project (hp)) -+ if (gi.trignum > 0) -+ ((STLGeometry&)geom).SelectChartOfTriangle (gi.trignum); -+ if (!(gi.trignum = geom.Project (hp))) - { - PrintMessage(7,"project failed"); - -- if (!geom.ProjectOnWholeSurface(hp)) -+ if (!(gi.trignum = geom.ProjectOnWholeSurface(hp))) - { - PrintMessage(7, "project on whole surface failed"); - } - } - p = hp; - // geometry.GetSurface(surfind)->Project (p); -+ return gi.trignum > 0; - } - - void MeshOptimizeSTLSurface :: ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const -@@ -970,20 +973,6 @@ - */ - } - --int MeshOptimizeSTLSurface :: CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& p3) const --{ -- Point<3> hp = p3; -- gi.trignum = geom.Project (hp); -- -- if (gi.trignum) -- { -- return 1; -- } -- -- return 0; -- --} -- - void MeshOptimizeSTLSurface :: GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const - { - n = geom.GetChartNormalVector(); -diff -Nru netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.hpp netgen-4.5_patch/libsrc/stlgeom/meshstlsurface.hpp ---- netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.hpp 2004-09-30 17:13:56.000000000 +0400 -+++ netgen-4.5_patch/libsrc/stlgeom/meshstlsurface.hpp 2006-10-25 16:17:59.000000000 +0400 -@@ -79,12 +79,10 @@ - virtual void SelectSurfaceOfPoint (const Point3d & p, - const PointGeomInfo & gi); - /// -- virtual void ProjectPoint (INDEX surfind, Point3d & p) const; -+ virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const; - /// - virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const; - /// -- virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& p3) const; -- /// - virtual void GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const; - }; - -diff -Nru netgen-4.5_orig/makeForSalome.sh netgen-4.5_patch/makeForSalome.sh ---- netgen-4.5_orig/makeForSalome.sh 1970-01-01 03:00:00.000000000 +0300 -+++ netgen-4.5_patch/makeForSalome.sh 2006-04-27 13:12:54.000000000 +0400 -@@ -0,0 +1,31 @@ -+#! /bin/sh -+cp ngtcltk/ngnewdelete.* libsrc/interface/ -+ -+MACHINE=LINUX -+export MACHINE -+make -C libsrc/csg -+make -C libsrc/general -+make -C libsrc/geom2d -+make -C libsrc/gprim -+make -C libsrc/interface -+make -C libsrc/linalg -+make -C libsrc/meshing -+make -C libsrc/opti -+make -C libsrc/stlgeom -+make -C libsrc/occ -+ -+if [ ! -d install ] ; then -+ mkdir install -+fi -+ -+cp -r lib install/ -+ -+if [ ! -d install/include ] ; then -+ mkdir install/include -+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 -Nru netgen-4.5_orig/libsrc/csg/meshsurf.cpp netgen-4.5_patch/libsrc/csg/meshsurf.cpp +--- netgen-4.5_orig/libsrc/csg/meshsurf.cpp 2006-02-14 10:54:35.000000000 +0300 ++++ netgen-4.5_patch/libsrc/csg/meshsurf.cpp 2006-10-25 16:05:59.000000000 +0400 +@@ -77,11 +77,12 @@ + } + + +-void MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const ++bool MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const + { + Point<3> hp = p; + geometry.GetSurface(surfind)->Project (hp); + p = hp; ++ return true; + } + + void MeshOptimize2dSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2, +diff -Nru netgen-4.5_orig/libsrc/csg/meshsurf.hpp netgen-4.5_patch/libsrc/csg/meshsurf.hpp +--- netgen-4.5_orig/libsrc/csg/meshsurf.hpp 2004-01-20 13:49:44.000000000 +0300 ++++ netgen-4.5_patch/libsrc/csg/meshsurf.hpp 2006-10-25 16:08:05.000000000 +0400 +@@ -45,7 +45,7 @@ + MeshOptimize2dSurfaces (const CSGeometry & ageometry); + + /// +- virtual void ProjectPoint (INDEX surfind, Point3d & p) const; ++ virtual bool ProjectPoint (INDEX surfind, Point3d & p) const; + /// + virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const; + /// +diff -Nru netgen-4.5_orig/libsrc/interface/Makefile netgen-4.5_patch/libsrc/interface/Makefile +--- netgen-4.5_orig/libsrc/interface/Makefile 2005-08-09 18:14:59.000000000 +0400 ++++ netgen-4.5_patch/libsrc/interface/Makefile 2006-04-27 13:12:54.000000000 +0400 +@@ -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 ++src = 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 nglib.cpp ngnewdelete.cpp + # + lib = nginterface + libpath = libsrc/interface +diff -Nru netgen-4.5_orig/libsrc/interface/nglib.cpp netgen-4.5_patch/libsrc/interface/nglib.cpp +--- netgen-4.5_orig/libsrc/interface/nglib.cpp 2005-10-18 17:53:18.000000000 +0400 ++++ netgen-4.5_patch/libsrc/interface/nglib.cpp 2006-04-27 13:12:54.000000000 +0400 +@@ -56,7 +56,8 @@ + + void Ng_Exit () + { +- ; ++ delete testout; ++ testout = NULL; + } + + +diff -Nru netgen-4.5_orig/libsrc/makefile.inc netgen-4.5_patch/libsrc/makefile.inc +--- netgen-4.5_orig/libsrc/makefile.inc 2005-09-02 17:17:51.000000000 +0400 ++++ netgen-4.5_patch/libsrc/makefile.inc 2006-10-26 09:33:58.000000000 +0400 +@@ -8,17 +8,14 @@ + LIBSRC_DIR=$(CPP_DIR)/libsrc + LIB_DIR=$(CPP_DIR)/lib/$(MACHINE) + +-#OCC_DIR=../../occ +-#OCCINC_DIR=$(OCC_DIR)/inc +-#OCCLIB_DIR=$(OCC_DIR)/lib +-# OCC_DIR=/opt/OpenCASCADE5.2/ros +-# OCC_DIR=/home/joachim/download/occ/Linux +-# OCCINC_DIR=$(OCC_DIR)/inc -I$(OCC_DIR)/ros/inc +-# OCCLIB_DIR=$(OCC_DIR)/Linux/lib ++OCC_DIR=$(CASROOT) ++OCCINC_DIR=$(OCC_DIR)/inc ++OCCLIB_DIR=$(OCC_DIR)/Linux/lib + # + include $(LIBSRC_DIR)/makefile.mach.$(MACHINE) + # +-CPLUSPLUSFLAGS1 = -c -I$(LIBSRC_DIR)/include -I$(OCCINC_DIR) ++CPLUSPLUSFLAGS1 = -c -I$(LIBSRC_DIR)/include -I$(OCCINC_DIR) \ ++ -DOCCGEOMETRY -DOCC52 -DHAVE_IOSTREAM -DHAVE_LIMITS_H + # + ARFLAGS = r + # +diff -Nru netgen-4.5_orig/libsrc/makefile.mach.LINUX netgen-4.5_patch/libsrc/makefile.mach.LINUX +--- netgen-4.5_orig/libsrc/makefile.mach.LINUX 2004-10-11 23:49:26.000000000 +0400 ++++ netgen-4.5_patch/libsrc/makefile.mach.LINUX 2006-04-27 13:12:54.000000000 +0400 +@@ -16,7 +16,7 @@ + # + CFLAGS2 = + +-CPLUSPLUSFLAGS2 = -O2 -I/usr/include/GL3.5 -DLINUX -DOPENGL \ ++CPLUSPLUSFLAGS2 = -O2 -I/usr/include/GL3.5 -DLINUX \ + -ftemplate-depth-99 -finline-limit=10000 \ + -Wdisabled-optimization -funroll-loops -DnoNGSOLVE + +diff -Nru netgen-4.5_orig/libsrc/meshing/improve2.cpp netgen-4.5_patch/libsrc/meshing/improve2.cpp +--- netgen-4.5_orig/libsrc/meshing/improve2.cpp 2006-01-11 18:08:19.000000000 +0300 ++++ netgen-4.5_patch/libsrc/meshing/improve2.cpp 2006-04-27 13:12:54.000000000 +0400 +@@ -4,7 +4,7 @@ + #include + + #ifndef SMALLLIB +-#include ++//#include + #endif + + namespace netgen +diff -Nru netgen-4.5_orig/libsrc/meshing/improve2.hpp netgen-4.5_patch/libsrc/meshing/improve2.hpp +--- netgen-4.5_orig/libsrc/meshing/improve2.hpp 2004-10-12 23:22:55.000000000 +0400 ++++ netgen-4.5_patch/libsrc/meshing/improve2.hpp 2006-10-25 16:09:37.000000000 +0400 +@@ -32,17 +32,16 @@ + /// + virtual void SelectSurfaceOfPoint (const Point3d & p, + const PointGeomInfo & gi); +- /// +- virtual void ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { }; ++ ++ /// project point on surface, returns true if success ++ virtual bool ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { return false; } ++ /// fast project point on surface using point geom info of a neighboring point ++ /// if gi.trignum != 0, ++ /// returns true if success, gi is updated ++ virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const ++ { gi.trignum = 1; return ProjectPoint (surfind, p); } + /// + virtual void ProjectPoint2 (INDEX /* surfind */, INDEX /* surfind2 */, Point3d & /* p */) const { }; +- /// liefert zu einem 3d-Punkt die geominfo (Dreieck) und liefert 1, wenn erfolgreich, +- /// 0, wenn nicht (Punkt ausserhalb von chart) +- virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& /*p3*/) const +- { gi.trignum = 1; return 1;}; +- +- virtual int CalcPointGeomInfo(int /* surfind */, PointGeomInfo& gi, const Point3d& p3) const +- { return CalcPointGeomInfo (gi, p3); } + + /// + virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const; +diff -Nru netgen-4.5_orig/libsrc/meshing/smoothing2.cpp netgen-4.5_patch/libsrc/meshing/smoothing2.cpp +--- netgen-4.5_orig/libsrc/meshing/smoothing2.cpp 2006-01-11 18:08:20.000000000 +0300 ++++ netgen-4.5_patch/libsrc/meshing/smoothing2.cpp 2006-10-25 16:10:46.000000000 +0400 +@@ -300,7 +300,7 @@ + double Opti2SurfaceMinFunction :: + FuncGrad (const Vector & x, Vector & grad) const + { +- Vec3d n, vgrad; ++ Vec3d vgrad; + Point3d pp1; + double g1x, g1y; + double badness, hbadness; +@@ -308,8 +308,6 @@ + vgrad = 0; + badness = 0; + +- meshthis -> GetNormalVector (surfi, sp1, gi1, n); +- + pp1 = sp1; + pp1.Add2 (x.Get(1), t1, x.Get(2), t2); + +@@ -360,7 +358,7 @@ + double Opti2SurfaceMinFunction :: + FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const + { +- Vec3d n, vgrad; ++ Vec3d vgrad; + Point3d pp1; + double g1x, g1y; + double badness, hbadness; +@@ -368,8 +366,6 @@ + vgrad = 0; + badness = 0; + +- meshthis -> GetNormalVector (surfi, sp1, gi1, n); +- + pp1 = sp1; + pp1.Add2 (x.Get(1), t1, x.Get(2), t2); + +@@ -520,7 +516,7 @@ + // from 2d: + + int j, k, lpi, gpi; +- Vec3d n, vgrad; ++ Vec3d vgrad; + Point3d pp1; + Vec2d g1, vdir; + double badness, hbadness, hbad, hderiv; +@@ -528,8 +524,6 @@ + vgrad = 0; + badness = 0; + +- meshthis -> GetNormalVector (surfi, sp1, gi1, n); +- + pp1 = sp1; + pp1.Add2 (x.Get(1), t1, x.Get(2), t2); + +@@ -593,7 +587,7 @@ + // from 2d: + + int j, k, lpi, gpi; +- Vec3d n, vgrad; ++ Vec3d vgrad; + Point3d pp1; + Vec2d g1, vdir; + double badness, hbadness, hbad, hderiv; +@@ -601,8 +595,6 @@ + vgrad = 0; + badness = 0; + +- meshthis -> GetNormalVector (surfi, sp1, gi1, n); +- + pp1 = sp1; + pp1.Add2 (x.Get(1), t1, x.Get(2), t2); + +@@ -859,19 +851,21 @@ + locelements.SetSize(0); + locrots.SetSize (0); + lochs.SetSize (0); ++ ngi.trignum = 0; + + for (j = 0; j < elementsonpoint[pi].Size(); j++) + { + sei = elementsonpoint[pi][j]; + const Element2d & bel = mesh[sei]; + surfi = mesh.GetFaceDescriptor(bel.GetIndex()).SurfNr(); +- ++ + locelements.Append (sei); + + for (k = 1; k <= bel.GetNP(); k++) + if (bel.PNum(k) == pi) + { + locrots.Append (k); ++ ngi = bel.GeomInfoPi(k); + break; + } + +@@ -942,7 +936,7 @@ + } + + //optimizer loop (if not whole distance is not possible, move only a bit!!!!) +- while (loci <= 5 && !moveisok) ++ while (loci <= 5 && !moveisok) + { + loci ++; + mesh[pi].X() = origp.X() + (x.Get(1) * t1.X() + x.Get(2) * t2.X())*fact; +@@ -951,11 +945,9 @@ + fact = fact/2.; + + +- ProjectPoint (surfi, mesh[pi]); ++ moveisok = ProjectPoint (surfi, mesh[pi], ngi); + +- moveisok = CalcPointGeomInfo(surfi, ngi, mesh[pi]); +- // point lies on same chart in stlsurface +- ++ // point lies on same chart in stlsurface + if (moveisok) + { + for (j = 0; j < locelements.Size(); j++) +diff -Nru netgen-4.5_orig/libsrc/occ/occconstruction.cpp netgen-4.5_patch/libsrc/occ/occconstruction.cpp +--- netgen-4.5_orig/libsrc/occ/occconstruction.cpp 2005-12-06 17:15:53.000000000 +0300 ++++ netgen-4.5_patch/libsrc/occ/occconstruction.cpp 2006-04-27 13:12:54.000000000 +0400 +@@ -28,8 +28,8 @@ + #include + #include + #include +-#include +-#include ++//#include ++//#include + #include + #include + namespace netgen +diff -Nru netgen-4.5_orig/libsrc/occ/occgenmesh.cpp netgen-4.5_patch/libsrc/occ/occgenmesh.cpp +--- netgen-4.5_orig/libsrc/occ/occgenmesh.cpp 2006-02-07 12:12:48.000000000 +0300 ++++ netgen-4.5_patch/libsrc/occ/occgenmesh.cpp 2006-10-25 16:14:48.000000000 +0400 +@@ -28,7 +28,7 @@ + return Point<3> (p.X(), p.Y(), p.Z()); + } + +- void DivideEdge (TopoDS_Edge & edge, ++ static void DivideEdge (TopoDS_Edge & edge, + ARRAY & ps, + ARRAY & params, + Mesh & mesh) +@@ -49,23 +49,19 @@ + hvalue[0] = 0; + pnt = c->Value(s0); + +- double olddist = 0; +- double dist = 0; +- +- for (int i = 1; i <= DIVIDEEDGESECTIONS; i++) ++ int i; ++ for (i = 1; i <= DIVIDEEDGESECTIONS; i++) + { + 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()))* +- pnt.Distance(oldpnt); ++ 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; + +- +- olddist = dist; +- dist = pnt.Distance(oldpnt); + } + + // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS])); +@@ -74,7 +70,7 @@ + ps.SetSize(nsubedges-1); + params.SetSize(nsubedges+1); + +- int i = 1; ++ i = 1; + int i1 = 0; + do + { +@@ -112,7 +108,7 @@ + + static void FindEdges (OCCGeometry & geom, Mesh & mesh) + { +- char * savetask = multithread.task; ++ const char * savetask = multithread.task; + multithread.task = "Edge meshing"; + + (*testout) << "edge meshing" << endl; +@@ -124,6 +120,7 @@ + (*testout) << "nedges = " << nedges << endl; + + double eps = 1e-6 * geom.GetBoundingBox().Diam(); ++ double eps2 = eps * eps; + + for (int i = 1; i <= nvertices; i++) + { +@@ -133,7 +130,7 @@ + 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)) < eps2) + { + exists = 1; + break; +@@ -276,8 +273,8 @@ + 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) < eps2) pnums[0] = pi; ++ if (Dist2 (mesh[pi], lp) < eps2) pnums.Last() = pi; + } + } + +@@ -287,7 +284,7 @@ + bool exists = 0; + int j; + for (j = first_ep; j <= mesh.GetNP(); j++) +- if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps) ++ if (Dist2(mesh.Point(j), Point<3>(mp[i-1])) < eps2) + { + exists = 1; + break; +@@ -394,7 +391,7 @@ + int i, j, k; + int changed; + +- char * savetask = multithread.task; ++ const char * savetask = multithread.task; + multithread.task = "Surface meshing"; + + geom.facemeshstatus = 0; +@@ -751,7 +748,7 @@ + multithread.task = savetask; + } + +- double ComputeH (double kappa) ++ static double ComputeH (double kappa) + { + double hret; + kappa *= mparam.curvaturesafety; +@@ -779,7 +776,7 @@ + double nq = n*q; + + Point<3> p = p0 + 0.5*n; +- double lambda = (p-l.p0)*n / nq; ++ double lambda = (fabs(nq) > 1e-10 ? (p-l.p0)*n / nq : -1); + + if (lambda >= 0 && lambda <= 1) + { +@@ -799,55 +796,55 @@ + + + +- void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2, +- BRepLProp_SLProps * prop, Mesh & mesh, const double maxside, int depth, double h = 0) ++ static void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2, ++ BRepAdaptor_Surface& surf, Mesh & mesh, const double maxside, int depth, double h = 0) + { +- ++ BRepLProp_SLProps prop(surf, 2, 1e-5); + + gp_Pnt2d parmid; + + parmid.SetX(0.3*(par0.X()+par1.X()+par2.X())); + parmid.SetY(0.3*(par0.Y()+par1.Y()+par2.Y())); + +- if (depth == 0) ++ //if (depth == 0) + { + double curvature = 0; + +- prop->SetParameters (parmid.X(), parmid.Y()); +- if (!prop->IsCurvatureDefined()) ++ prop.SetParameters (parmid.X(), parmid.Y()); ++ if (!prop.IsCurvatureDefined()) + { + (*testout) << "curvature not defined!" << endl; + return; + } +- curvature = max(fabs(prop->MinCurvature()), +- fabs(prop->MaxCurvature())); ++ curvature = max(fabs(prop.MinCurvature()), ++ fabs(prop.MaxCurvature())); + +- prop->SetParameters (par0.X(), par0.Y()); +- if (!prop->IsCurvatureDefined()) ++ prop.SetParameters (par0.X(), par0.Y()); ++ if (!prop.IsCurvatureDefined()) + { + (*testout) << "curvature not defined!" << endl; + return; + } +- curvature = max(curvature,max(fabs(prop->MinCurvature()), +- fabs(prop->MaxCurvature()))); ++ curvature = max(curvature,max(fabs(prop.MinCurvature()), ++ fabs(prop.MaxCurvature()))); + +- prop->SetParameters (par1.X(), par1.Y()); +- if (!prop->IsCurvatureDefined()) ++ prop.SetParameters (par1.X(), par1.Y()); ++ if (!prop.IsCurvatureDefined()) + { + (*testout) << "curvature not defined!" << endl; + return; + } +- curvature = max(curvature,max(fabs(prop->MinCurvature()), +- fabs(prop->MaxCurvature()))); ++ curvature = max(curvature,max(fabs(prop.MinCurvature()), ++ fabs(prop.MaxCurvature()))); + +- prop->SetParameters (par2.X(), par2.Y()); +- if (!prop->IsCurvatureDefined()) ++ prop.SetParameters (par2.X(), par2.Y()); ++ if (!prop.IsCurvatureDefined()) + { + (*testout) << "curvature not defined!" << endl; + return; + } +- curvature = max(curvature,max(fabs(prop->MinCurvature()), +- fabs(prop->MaxCurvature()))); ++ curvature = max(curvature,max(fabs(prop.MinCurvature()), ++ fabs(prop.MaxCurvature()))); + + //(*testout) << "curvature " << curvature << endl; + +@@ -886,51 +883,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())); + +- RestrictHTriangle (pm0, pm1, pm2, prop, mesh, 0.5*maxside, depth+1, h); +- RestrictHTriangle (par0, pm1, pm2, prop, mesh, 0.5*maxside, depth+1, h); +- RestrictHTriangle (par1, pm0, pm2, prop, mesh, 0.5*maxside, depth+1, h); +- RestrictHTriangle (par2, pm1, pm0, prop, mesh, 0.5*maxside, depth+1, h); ++ RestrictHTriangle (pm0, pm1, pm2, surf, mesh, 0.5*maxside, depth+1, h); ++ RestrictHTriangle (par0, pm1, pm2, surf, mesh, 0.5*maxside, depth+1, h); ++ RestrictHTriangle (par1, pm0, pm2, surf, mesh, 0.5*maxside, depth+1, h); ++ RestrictHTriangle (par2, pm1, pm0, surf, mesh, 0.5*maxside, depth+1, h); + } + else + { + gp_Pnt pnt; + Point3d p3d; + +- prop->SetParameters (parmid.X(), parmid.Y()); +- pnt = prop->Value(); ++ surf.D0(parmid.X(), parmid.Y(), pnt); + p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z()); + mesh.RestrictLocalH (p3d, h); + + +- prop->SetParameters (par0.X(), par0.Y()); +- pnt = prop->Value(); ++ surf.D0(par0.X(), par0.Y(), pnt); + p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z()); + mesh.RestrictLocalH (p3d, h); + +- prop->SetParameters (par1.X(), par1.Y()); +- pnt = prop->Value(); ++ surf.D0(par1.X(), par1.Y(), pnt); + p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z()); + mesh.RestrictLocalH (p3d, h); + +- prop->SetParameters (par2.X(), par2.Y()); +- pnt = prop->Value(); ++ surf.D0(par2.X(), par2.Y(), pnt); + p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z()); + mesh.RestrictLocalH (p3d, h); + +- (*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl; ++ //(*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl; + /* + (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; + +- prop->SetParameters (par0.X(), par0.Y()); +- pnt = prop->Value(); ++ prop.SetParameters (par0.X(), par0.Y()); ++ pnt = prop.Value(); + (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; + +- prop->SetParameters (par1.X(), par1.Y()); +- pnt = prop->Value(); ++ prop.SetParameters (par1.X(), par1.Y()); ++ pnt = prop.Value(); + (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; + +- prop->SetParameters (par2.X(), par2.Y()); +- pnt = prop->Value(); ++ prop.SetParameters (par2.X(), par2.Y()); ++ pnt = prop.Value(); + (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl; + */ + } +@@ -970,7 +963,7 @@ + if (mparam.uselocalh) + { + +- char * savetask = multithread.task; ++ const char * savetask = multithread.task; + multithread.percent = 0; + + mesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading); +@@ -1075,7 +1068,6 @@ + if (triangulation.IsNull()) continue; + + BRepAdaptor_Surface sf(face, Standard_True); +- BRepLProp_SLProps prop(sf, 2, 1e-5); + + int ntriangles = triangulation -> NbTriangles(); + for (int j = 1; j <= ntriangles; j++) +@@ -1096,7 +1088,7 @@ + maxside = max (maxside, p[1].Distance(p[2])); + //cout << "\rFace " << i << " pos11 ntriangles " << ntriangles << " maxside " << maxside << flush; + +- RestrictHTriangle (par[0], par[1], par[2], &prop, *mesh, maxside, 0); ++ RestrictHTriangle (par[0], par[1], par[2], sf, *mesh, maxside, 0); + //cout << "\rFace " << i << " pos12 ntriangles " << ntriangles << flush; + } + } +diff -Nru netgen-4.5_orig/libsrc/occ/occgeom.cpp netgen-4.5_patch/libsrc/occ/occgeom.cpp +--- netgen-4.5_orig/libsrc/occ/occgeom.cpp 2006-01-25 15:35:50.000000000 +0300 ++++ netgen-4.5_patch/libsrc/occ/occgeom.cpp 2006-10-25 16:15:24.000000000 +0400 +@@ -7,6 +7,8 @@ + #include "ShapeAnalysis_ShapeContents.hxx" + #include "ShapeAnalysis_CheckSmallFace.hxx" + #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx" ++#include ++#include + #include "BRepAlgoAPI_Fuse.hxx" + #include "BRepCheck_Analyzer.hxx" + #include "BRepLib.hxx" +@@ -16,11 +18,19 @@ + #include "Partition_Spliter.hxx" + //#include "VrmlAPI.hxx" + //#include "StlAPI.hxx" ++#include + + + namespace netgen + { + ++ OCCGeometry::~OCCGeometry() ++ { ++ NCollection_DataMap::Iterator it(fclsmap); ++ for (; it.More(); it.Next()) ++ delete it.Value(); ++ } ++ + void OCCGeometry :: PrintNrShapes () + { + TopExp_Explorer e; +@@ -947,13 +957,13 @@ + + void OCCGeometry :: BuildVisualizationMesh () + { +- +- cout << "Preparing visualization (deflection = " << vispar.occdeflection << ") ... " << flush; ++ double vispar_occdeflection = 0.01; ++ cout << "Preparing visualization (deflection = " << vispar_occdeflection << ") ... " << flush; + + + BRepTools::Clean (shape); + //WriteOCC_STL("test.stl"); +- BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar.occdeflection, true); ++ BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar_occdeflection, true); + cout << "done" << endl; + + +@@ -973,8 +983,27 @@ + + } + ++ 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 ++ 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; +@@ -983,18 +1012,22 @@ + + //(*testout) << "before " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl; + +- GeomAPI_ProjectPointOnSurf proj(pnt, BRep_Tool::Surface(TopoDS::Face(fmap(surfi)))); +- if (proj.NbPoints() == 0) +- { +- cout << "Projection fails" << endl; +- } +- else +- { +- pnt = proj.NearestPoint(); +- //(*testout) << "after " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl; ++ Handle(ShapeAnalysis_Surface) proj; ++ BRepTopAdaptor_FClass2d *cls; ++ GetFaceTools(surfi, proj, cls); + +- p = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); +- } ++ gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion()); ++ if (cls->Perform(p2d) == TopAbs_OUT) ++ { ++ //cout << "Projection fails" << endl; ++ return false; ++ } ++ pnt = proj->Value(p2d); ++ p2d.Coord(u, v); ++ //(*testout) << "after " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl; ++ ++ p = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); ++ return true; + } + + +@@ -1002,54 +1035,20 @@ + { + gp_Pnt p(ap(0), ap(1), ap(2)); + +- Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); ++ Handle(ShapeAnalysis_Surface) proj; ++ BRepTopAdaptor_FClass2d *cls; ++ GetFaceTools(surfi, proj, cls); + +- 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; ++ gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion()); ++ if (cls->Perform(p2d) == TopAbs_OUT) ++ { ++ //cout << "Projection fails" << endl; ++ return false; ++ } + +- ap = Point<3> (x.X(), x.Y(), x.Z()); ++ p = proj->Value(p2d); ++ p2d.Coord(u, v); ++ ap = Point<3> (p.X(), p.Y(), p.Z()); + + return true; + } +diff -Nru netgen-4.5_orig/libsrc/occ/occgeom.hpp netgen-4.5_patch/libsrc/occ/occgeom.hpp +--- netgen-4.5_orig/libsrc/occ/occgeom.hpp 2006-01-25 15:35:50.000000000 +0300 ++++ netgen-4.5_patch/libsrc/occ/occgeom.hpp 2006-10-25 16:16:01.000000000 +0400 +@@ -15,8 +15,6 @@ + #include "Geom_Curve.hxx" + #include "Geom2d_Curve.hxx" + #include "Geom_Surface.hxx" +-#include "GeomAPI_ProjectPointOnSurf.hxx" +-#include "GeomAPI_ProjectPointOnCurve.hxx" + #include "BRepTools.hxx" + #include "TopExp.hxx" + #include "BRepBuilderAPI_MakeVertex.hxx" +@@ -41,8 +39,6 @@ + #include "Geom_Curve.hxx" + #include "Geom2d_Curve.hxx" + #include "Geom_Surface.hxx" +-#include "GeomAPI_ProjectPointOnSurf.hxx" +-#include "GeomAPI_ProjectPointOnCurve.hxx" + #include "TopoDS_Wire.hxx" + #include "BRepTools_WireExplorer.hxx" + #include "BRepTools.hxx" +@@ -69,7 +65,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" +@@ -84,11 +80,15 @@ + #include "STEPControl_Writer.hxx" + #include "StlAPI_Writer.hxx" + #include "STEPControl_StepModelType.hxx" ++#include ++ ++class Handle_ShapeAnalysis_Surface; ++class BRepTopAdaptor_FClass2d; + + namespace netgen + { + +-#include "../visualization/vispar.hpp" ++ //#include "../visualization/vispar.hpp" + // class VisualizationParameters; + // extern VisualizationParameters vispar; + +@@ -159,6 +159,8 @@ + class OCCGeometry + { + Point<3> center; ++ mutable NCollection_DataMap fprjmap; ++ mutable NCollection_DataMap fclsmap; + + public: + TopoDS_Shape shape; +@@ -189,6 +191,7 @@ + vmap.Clear(); + } + ++ ~OCCGeometry(); + + void BuildFMap(); + +@@ -204,10 +207,12 @@ + Point<3> Center() + { return center; } + +- void Project (int surfi, Point<3> & p) const; ++ bool Project (int surfi, Point<3> & p, double& u, double& v) const; + bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const; + +- ++ void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj, ++ BRepTopAdaptor_FClass2d*& cls) const; ++ + OCCSurface GetSurface (int surfi) + { + cout << "OCCGeometry::GetSurface using PLANESPACE" << endl; +diff -Nru netgen-4.5_orig/libsrc/occ/occmeshsurf.cpp netgen-4.5_patch/libsrc/occ/occmeshsurf.cpp +--- netgen-4.5_orig/libsrc/occ/occmeshsurf.cpp 2006-01-25 15:36:26.000000000 +0300 ++++ netgen-4.5_patch/libsrc/occ/occmeshsurf.cpp 2006-10-25 16:16:26.000000000 +0400 +@@ -5,6 +5,8 @@ + #include + #include + #include ++#include ++#include + + + namespace netgen +@@ -411,11 +413,16 @@ + } + + +- void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const ++ bool MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const + { + Point<3> hp = p; +- geometry.Project (surfind, hp); ++ 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; + } + + void MeshOptimize2dOCCSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2, +@@ -506,38 +513,6 @@ + } + + +- int MeshOptimize2dOCCSurfaces :: +- CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point3d& p) const +- { +- Standard_Real u,v; +- +- gp_Pnt pnt(p.X(), p.Y(), p.Z()); +- +- Handle(Geom_Surface) occface; +- occface = BRep_Tool::Surface(TopoDS::Face(geometry.fmap(surfind))); +- +- GeomAPI_ProjectPointOnSurf proj(pnt, occface); +- +- if (proj.NbPoints() < 1) +- { +- cout << "ERROR: OCCSurface :: GetNormalVector: GeomAPI_ProjectPointOnSurf failed!" +- << endl; +- cout << p << endl; +- return 0; +- } +- +- proj.LowerDistanceParameters (u, v); +- +- gi.u = u; +- gi.v = v; +- return 1; +- } +- +- +- +- +- +- + OCCRefinementSurfaces :: OCCRefinementSurfaces (const OCCGeometry & ageometry) + : Refinement(), geometry(ageometry) + { +@@ -627,10 +602,11 @@ + if (!geometry.FastProject (surfi, hnewp, u, v)) + { + cout << "Fast projection to surface fails! Using OCC projection" << endl; +- geometry.Project (surfi, hnewp); ++ double u, v; ++ geometry.Project (surfi, hnewp, u, v); + } + +- newgi.trignum = 1; ++ newgi.trignum = surfi; + } + + newp = hnewp; +@@ -653,14 +629,17 @@ + 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); +- }; ++ { ++ double u, v; ++ geometry.Project (surfi, p, u, v); ++ } ++ } + + void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) + { +@@ -668,9 +647,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 -Nru netgen-4.5_orig/libsrc/occ/occmeshsurf.hpp netgen-4.5_patch/libsrc/occ/occmeshsurf.hpp +--- netgen-4.5_orig/libsrc/occ/occmeshsurf.hpp 2005-06-09 18:51:10.000000000 +0400 ++++ netgen-4.5_patch/libsrc/occ/occmeshsurf.hpp 2006-10-25 16:17:22.000000000 +0400 +@@ -151,7 +151,7 @@ + MeshOptimize2dOCCSurfaces (const OCCGeometry & ageometry); + + /// +- virtual void ProjectPoint (INDEX surfind, Point3d & p) const; ++ virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const; + /// + virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const; + /// +@@ -159,9 +159,6 @@ + /// + virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const; + +- +- virtual int CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point3d& p3) const; +- + }; + + +diff -Nru netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.cpp netgen-4.5_patch/libsrc/stlgeom/meshstlsurface.cpp +--- netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.cpp 2006-01-11 18:08:20.000000000 +0300 ++++ netgen-4.5_patch/libsrc/stlgeom/meshstlsurface.cpp 2006-10-25 16:17:47.000000000 +0400 +@@ -946,20 +946,23 @@ + } + + +-void MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point3d & p) const ++bool MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const + { + Point<3> hp = p; +- if (!geom.Project (hp)) ++ if (gi.trignum > 0) ++ ((STLGeometry&)geom).SelectChartOfTriangle (gi.trignum); ++ if (!(gi.trignum = geom.Project (hp))) + { + PrintMessage(7,"project failed"); + +- if (!geom.ProjectOnWholeSurface(hp)) ++ if (!(gi.trignum = geom.ProjectOnWholeSurface(hp))) + { + PrintMessage(7, "project on whole surface failed"); + } + } + p = hp; + // geometry.GetSurface(surfind)->Project (p); ++ return gi.trignum > 0; + } + + void MeshOptimizeSTLSurface :: ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const +@@ -970,20 +973,6 @@ + */ + } + +-int MeshOptimizeSTLSurface :: CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& p3) const +-{ +- Point<3> hp = p3; +- gi.trignum = geom.Project (hp); +- +- if (gi.trignum) +- { +- return 1; +- } +- +- return 0; +- +-} +- + void MeshOptimizeSTLSurface :: GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const + { + n = geom.GetChartNormalVector(); +diff -Nru netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.hpp netgen-4.5_patch/libsrc/stlgeom/meshstlsurface.hpp +--- netgen-4.5_orig/libsrc/stlgeom/meshstlsurface.hpp 2004-09-30 17:13:56.000000000 +0400 ++++ netgen-4.5_patch/libsrc/stlgeom/meshstlsurface.hpp 2006-10-25 16:17:59.000000000 +0400 +@@ -79,12 +79,10 @@ + virtual void SelectSurfaceOfPoint (const Point3d & p, + const PointGeomInfo & gi); + /// +- virtual void ProjectPoint (INDEX surfind, Point3d & p) const; ++ virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const; + /// + virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const; + /// +- virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& p3) const; +- /// + virtual void GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const; + }; + +diff -Nru netgen-4.5_orig/makeForSalome.sh netgen-4.5_patch/makeForSalome.sh +--- netgen-4.5_orig/makeForSalome.sh 1970-01-01 03:00:00.000000000 +0300 ++++ netgen-4.5_patch/makeForSalome.sh 2006-04-27 13:12:54.000000000 +0400 +@@ -0,0 +1,31 @@ ++#! /bin/sh ++cp ngtcltk/ngnewdelete.* libsrc/interface/ ++ ++MACHINE=LINUX ++export MACHINE ++make -C libsrc/csg ++make -C libsrc/general ++make -C libsrc/geom2d ++make -C libsrc/gprim ++make -C libsrc/interface ++make -C libsrc/linalg ++make -C libsrc/meshing ++make -C libsrc/opti ++make -C libsrc/stlgeom ++make -C libsrc/occ ++ ++if [ ! -d install ] ; then ++ mkdir install ++fi ++ ++cp -r lib install/ ++ ++if [ ! -d install/include ] ; then ++ mkdir install/include ++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 --git a/src/NETGENPlugin/Makefile.am b/src/NETGENPlugin/Makefile.am index cb8063c..7a10e1e 100644 --- a/src/NETGENPlugin/Makefile.am +++ b/src/NETGENPlugin/Makefile.am @@ -41,6 +41,8 @@ dist_libNETGENEngine_la_SOURCES = \ NETGENPlugin_NETGEN_2D_i.cxx \ NETGENPlugin_NETGEN_2D3D.cxx \ NETGENPlugin_NETGEN_2D3D_i.cxx \ + NETGENPlugin_NETGEN_2D_ONLY.cxx \ + NETGENPlugin_NETGEN_2D_ONLY_i.cxx \ NETGENPlugin_Hypothesis.cxx \ NETGENPlugin_Hypothesis_i.cxx \ NETGENPlugin_Hypothesis_2D.cxx \ diff --git a/src/NETGENPlugin/NETGENPlugin_Defs.hxx b/src/NETGENPlugin/NETGENPlugin_Defs.hxx index 03bdc4e..5ed43a2 100755 --- a/src/NETGENPlugin/NETGENPlugin_Defs.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Defs.hxx @@ -34,4 +34,4 @@ #define NETGENPLUGIN_EXPORT #endif -#endif \ No newline at end of file +#endif diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index 3678e3b..b1be861 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -25,11 +25,13 @@ // Project : SALOME // $Header$ //============================================================================= + #include "NETGENPlugin_Mesher.hxx" #include "NETGENPlugin_Hypothesis_2D.hxx" #include #include +#include #include #include #include @@ -43,6 +45,9 @@ #include #include #include +#include +#include +#include // Netgen include files namespace nglib { @@ -153,6 +158,33 @@ Standard_Boolean IsEqual(const Link& aLink1, const Link& aLink2) aLink1.n1 == aLink2.n2 && aLink1.n2 == aLink2.n1); } +//================================================================================ +/*! + * \brief Initialize netgen::OCCGeometry with OCCT shape + */ +//================================================================================ + +void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry& occgeo, + const TopoDS_Shape& shape) +{ + occgeo.shape = shape; + occgeo.changed = 1; + occgeo.BuildFMap(); + + BRepTools::Clean (shape); + BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, 0.01, true); + Bnd_Box bb; + BRepBndLib::Add (shape, bb); + double x1,y1,z1,x2,y2,z2; + bb.Get (x1,y1,z1,x2,y2,z2); + MESSAGE("shape bounding box:\n" << + "(" << x1 << " " << y1 << " " << z1 << ") " << + "(" << x2 << " " << y2 << " " << z2 << ")"); + netgen::Point<3> p1 = netgen::Point<3> (x1,y1,z1); + netgen::Point<3> p2 = netgen::Point<3> (x2,y2,z2); + occgeo.boundingbox = netgen::Box<3> (p1,p2); +} + //============================================================================= /*! * Here we are going to use the NETGEN mesher @@ -182,21 +214,7 @@ bool NETGENPlugin_Mesher::Compute() // ------------------------- netgen::OCCGeometry occgeo; - occgeo.shape = _shape; - occgeo.changed = 1; - occgeo.BuildFMap(); - BRepTools::Clean (_shape); - BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (_shape, 0.01, true); - Bnd_Box bb; - BRepBndLib::Add (_shape, bb); - double x1,y1,z1,x2,y2,z2; - bb.Get (x1,y1,z1,x2,y2,z2); - MESSAGE("shape bounding box:\n" << - "(" << x1 << " " << y1 << " " << z1 << ") " << - "(" << x2 << " " << y2 << " " << z2 << ")"); - netgen::Point<3> p1 = netgen::Point<3> (x1,y1,z1); - netgen::Point<3> p2 = netgen::Point<3> (x2,y2,z2); - occgeo.boundingbox = netgen::Box<3> (p1,p2); + PrepareOCCgeometry( occgeo, _shape ); // ------------------------- // Generate the mesh @@ -416,7 +434,7 @@ bool NETGENPlugin_Mesher::Compute() // create tetrahedra for (i = 1; i <= nbVol/* && isOK*/; ++i) { - const netgen::Element& elem = ngMesh->VolumeElement(i); + const netgen::Element& elem = ngMesh->VolumeElement(i); int aSolidInd = elem.GetIndex(); TopoDS_Solid aSolid; if (aSolidInd > 0 && aSolidInd <= occgeo.somap.Extent()) @@ -488,5 +506,25 @@ bool NETGENPlugin_Mesher::Compute() nglib::Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh); nglib::Ng_Exit(); + RemoveTmpFiles(); + return error->IsOK(); } + +//================================================================================ +/*! + * \brief Remove "test.out" and "problemfaces" files in current directory + */ +//================================================================================ + +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(); +} diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx index 18ee455..7795e6b 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx @@ -30,13 +30,15 @@ #define _NETGENPlugin_Mesher_HXX_ #include "NETGENPlugin_Defs.hxx" - -#include "SMESH_ComputeError.hxx" +#include "StdMeshers_FaceSide.hxx" class SMESH_Mesh; class SMESHDS_Mesh; class TopoDS_Shape; class NETGENPlugin_Hypothesis; +namespace netgen { + class OCCGeometry; +} /*! * \brief This class calls the NETGEN mesher of OCC geometry @@ -54,6 +56,11 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher bool Compute(); + static void PrepareOCCgeometry(netgen::OCCGeometry& occgeom, + const TopoDS_Shape& shape); + + static void RemoveTmpFiles(); + private: SMESH_Mesh* _mesh; const TopoDS_Shape& _shape; diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx index f481c10..66e3b95 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx @@ -28,6 +28,8 @@ //============================================================================= #include "NETGENPlugin_NETGEN_3D.hxx" +#include "NETGENPlugin_Mesher.hxx" + #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" #include "SMESHDS_Mesh.hxx" @@ -42,6 +44,9 @@ #include #include +#include +#include + #include "utilities.h" #include @@ -312,11 +317,17 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, 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 (...) { - MESSAGE("An exception has been caught during the Volume Mesh Generation ..."); - error(dfltErr(), "Exception in Ng_GenerateVolumeMesh()"); + error("Exception in Ng_GenerateVolumeMesh()"); status = NG_VOLUME_FAILURE; } if ( GetComputeError()->IsOK() ) { @@ -378,5 +389,185 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, Ng_DeleteMesh(Netgen_mesh); Ng_Exit(); + NETGENPlugin_Mesher::RemoveTmpFiles(); + + return (status == NG_OK); +} + +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; + + 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()); + + // 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 + // --------------------------------- + + int Netgen_NbOfNodes = 0; + int Netgen_param2ndOrder = 0; + double Netgen_paramFine = 1.; + double Netgen_paramSize = _maxElementVolume; + + double Netgen_point[3]; + int Netgen_triangle[3]; + int Netgen_tetrahedron[4]; + + Ng_Init(); + + 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 ) + { + 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 + + } + + // set triangles + list< const SMDS_MeshElement* >::iterator tria = triangles.begin(); + for ( ; tria != triangles.end(); ++tria) + { + 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; + } + + Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle); + } + + // ------------------------- + // 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); } diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx index 4edec42..1824689 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx @@ -49,6 +49,9 @@ public: virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); + virtual bool Compute(SMESH_Mesh& aMesh, + SMESH_MesherHelper* aHelper); + protected: double _maxElementVolume; diff --git a/src/NETGENPlugin/NETGENPlugin_i.cxx b/src/NETGENPlugin/NETGENPlugin_i.cxx index 0f01ec2..2b27c98 100644 --- a/src/NETGENPlugin/NETGENPlugin_i.cxx +++ b/src/NETGENPlugin/NETGENPlugin_i.cxx @@ -30,6 +30,7 @@ #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_i.hxx" @@ -62,6 +63,8 @@ extern "C" aCreator = new NETGENPlugin_Creator_i; else if (strcmp(aHypName, "NETGEN_2D") == 0) aCreator = new NETGENPlugin_Creator_i; + else if (strcmp(aHypName, "NETGEN_2D_ONLY") == 0) + aCreator = new NETGENPlugin_Creator_i; else if (strcmp(aHypName, "NETGEN_2D3D") == 0) aCreator = new NETGENPlugin_Creator_i; // Hypotheses