From: eap Date: Fri, 7 Oct 2016 13:52:00 +0000 (+0300) Subject: 23104: EDF SMESH: Pre-study for Netgen 5x X-Git-Tag: V8_2_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7d8f8a32b54f9da2f0261ce8fdd2c3ba38525ba8;p=plugins%2Fnetgenplugin.git 23104: EDF SMESH: Pre-study for Netgen 5x --- diff --git a/src/NETGEN/netgen53ForSalome.patch b/src/NETGEN/netgen53ForSalome.patch index 3934014..7db2830 100644 --- a/src/NETGEN/netgen53ForSalome.patch +++ b/src/NETGEN/netgen53ForSalome.patch @@ -1,13 +1,75 @@ -diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc/meshing/meshtype.cpp ---- netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp 2009-09-13 14:28:38.000000000 +0400 -+++ netgen-5.3.1_new/libsrc/meshing/meshtype.cpp 2014-07-22 13:01:28.000000000 +0400 +diff -NaurwB netgen-5.3.1_orig/Makefile.in netgen-5.3.1_new/Makefile.in +--- netgen-5.3.1_orig/Makefile.in 2014-10-06 15:04:37.000000000 +0400 ++++ netgen-5.3.1_new/Makefile.in 2016-10-03 16:17:10.164707368 +0300 +@@ -280,7 +280,7 @@ + top_srcdir = @top_srcdir@ + ACLOCAL_AMFLAGS = -I m4 + METASOURCES = AUTO +-SUBDIRS = libsrc ng tutorials doc windows nglib ++SUBDIRS = libsrc nglib #tutorials doc windows nglib + all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +diff -NaurwB netgen-5.3.1_orig/configure.ac netgen-5.3.1_new/configure.ac +--- netgen-5.3.1_orig/configure.ac 2014-10-06 15:00:17.000000000 +0400 ++++ netgen-5.3.1_new/configure.ac 2016-09-29 14:34:11.957389447 +0300 +@@ -42,7 +42,7 @@ + + if test a$occon = atrue ; then + +- AC_SUBST([OCCFLAGS], ["-DOCCGEOMETRY -I$occdir/inc -I/usr/include/opencascade"]) ++ AC_SUBST([OCCFLAGS], ["-DOCCGEOMETRY -I$occdir/include/opencascade"]) + AC_SUBST([OCCLIBS], ["-L$occdir/lib -lTKernel -lTKGeomBase -lTKMath -lTKG2d -lTKG3d -lTKXSBase -lTKOffset -lTKFillet -lTKShHealing -lTKMesh -lTKMeshVS -lTKTopAlgo -lTKGeomAlgo -lTKBool -lTKPrim -lTKBO -lTKIGES -lTKBRep -lTKSTEPBase -lTKSTEP -lTKSTL -lTKSTEPAttr -lTKSTEP209 -lTKXDESTEP -lTKXDEIGES -lTKXCAF -lTKLCAF -lFWOSPlugin"]) + + # -lTKDCAF +diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/findip.hpp netgen-5.3.1_new/libsrc/meshing/findip.hpp +--- netgen-5.3.1_orig/libsrc/meshing/findip.hpp 2014-08-29 13:54:05.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/meshing/findip.hpp 2016-09-30 20:38:56.662234111 +0300 +@@ -75,6 +75,9 @@ + static int timer = NgProfiler::CreateTimer ("FindInnerPoint"); + NgProfiler::RegionTimer reg (timer); + ++ if ( points.Size() < 3 ) ++ return 0; ++ + Array a; + Array c; + Mat<3> m, inv; +diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/improve3.cpp netgen-5.3.1_new/libsrc/meshing/improve3.cpp +--- netgen-5.3.1_orig/libsrc/meshing/improve3.cpp 2014-08-29 13:54:05.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/meshing/improve3.cpp 2016-10-03 16:16:57.636639300 +0300 +@@ -1219,6 +1219,7 @@ + + tetused = 0; + tetused[0] = 1; ++ int nbtetused = 0; + + for (int l = 2; l < nsuround; l++) + { +@@ -1239,10 +1240,12 @@ + + tetused[k] = 1; + suroundpts[l] = newpi; ++ ++nbtetused; + } + } + } +- ++ if ( nbtetused < nsuround ) ++ continue; + + bad1 = 0; + for (int k = 0; k < nsuround; k++) +diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc/meshing/meshtype.cpp +--- netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp 2014-08-29 13:54:05.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/meshing/meshtype.cpp 2016-09-29 14:04:51.500148293 +0300 @@ -1,4 +1,5 @@ #include +#include // to get DBL_MIN defined #include "meshing.hpp" -@@ -650,7 +651,8 @@ +@@ -666,7 +667,8 @@ double det = trans.Det(); @@ -17,7 +79,7 @@ diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc err += 1e12; else err += frob * frob / det; -@@ -706,7 +708,8 @@ +@@ -722,7 +724,8 @@ double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1); @@ -27,7 +89,7 @@ diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc { dd = 0; return 1e12; -@@ -790,7 +793,8 @@ +@@ -806,7 +809,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); @@ -37,7 +99,7 @@ diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc err += 1e12; else { -@@ -840,7 +844,8 @@ +@@ -856,7 +860,8 @@ frob /= 2; double det = trans.Det(); @@ -47,7 +109,7 @@ diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc err += 1e12; else err += frob * frob / det; -@@ -1857,7 +1862,8 @@ +@@ -1864,7 +1869,8 @@ case PYRAMID: { double noz = 1-p(2); @@ -57,7 +119,7 @@ diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc double xi = p(0) / noz; double eta = p(1) / noz; -@@ -2035,7 +2041,8 @@ +@@ -2030,7 +2036,8 @@ double det = -trans.Det(); @@ -67,7 +129,7 @@ diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc err += 1e12; else err += frob * frob * frob / det; -@@ -2107,7 +2114,8 @@ +@@ -2102,7 +2109,8 @@ ddet *= -1; @@ -77,7 +139,7 @@ diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc err += 1e12; else { -@@ -2189,7 +2197,7 @@ +@@ -2184,7 +2192,7 @@ det *= -1; @@ -86,21 +148,282 @@ diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc err += 1e12; else { -diff -Naur netgen-5.3.1_orig/libsrc/meshing/meshtype.hpp netgen-5.3.1_new/libsrc/meshing/meshtype.hpp ---- netgen-5.3.1_orig/libsrc/meshing/meshtype.hpp 2009-11-09 13:50:43.000000000 +0300 -+++ netgen-5.3.1_new/libsrc/meshing/meshtype.hpp 2014-07-22 13:01:28.000000000 +0400 -@@ -12,6 +12,7 @@ +diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/meshtype.hpp netgen-5.3.1_new/libsrc/meshing/meshtype.hpp +--- netgen-5.3.1_orig/libsrc/meshing/meshtype.hpp 2014-08-29 13:54:05.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/meshing/meshtype.hpp 2016-09-30 14:28:09.147575801 +0300 +@@ -15,6 +15,7 @@ Classes for NETGEN - */ + */ +class Mesh; // added due to compilation errors on some platforms - enum ELEMENT_TYPE { - SEGMENT = 1, SEGMENT3 = 2, -diff -Naur netgen-5.3.1_orig/libsrc/meshing/smoothing2.cpp netgen-5.3.1_new/libsrc/meshing/smoothing2.cpp -diff -Naur netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp netgen-5.3.1_new/libsrc/occ/occconstruction.cpp ---- netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp 2009-08-24 06:32:47.000000000 +0400 -+++ netgen-5.3.1_new/libsrc/occ/occconstruction.cpp 2014-07-22 13:01:28.000000000 +0400 + + enum ELEMENT_TYPE { +@@ -360,7 +361,7 @@ + { + #ifdef DEBUG + if (typ != QUAD && typ != QUAD6 && typ != QUAD8) +- PrintSysError ("element2d::GetNV not implemented for typ", typ) ++ PrintSysError ("element2d::GetNV not implemented for typ", typ); + #endif + return 4; + } +@@ -618,7 +619,7 @@ + return 8; + default: + #ifdef DEBUG +- PrintSysError ("Element3d::GetNV not implemented for typ ", typ) ++ PrintSysError ("Element3d::GetNV not implemented for typ ", typ); + #endif + ; + } +@@ -682,7 +683,7 @@ + case PRISM12: return 5; + default: + #ifdef DEBUG +- PrintSysError ("element3d::GetNFaces not implemented for typ", typ) ++ PrintSysError ("element3d::GetNFaces not implemented for typ", typ); + #endif + ; + } +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.cxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.cxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.cxx 2016-09-29 14:44:01.996464598 +0300 +@@ -47,9 +47,7 @@ + #include + #include + #include +-#include + #include +-#include + #include + #include + #include +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.hxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.hxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.hxx 2016-09-29 14:44:01.996464598 +0300 +@@ -27,7 +27,9 @@ + #ifndef _Partition_Inter2d_HeaderFile + #define _Partition_Inter2d_HeaderFile + +-#ifndef _Handle_BRepAlgo_AsDes_HeaderFile ++#include ++ ++#if OCC_VERSION_MAJOR < 7 + #include + #endif + #ifndef _Standard_Real_HeaderFile +@@ -36,11 +38,13 @@ + #ifndef _Standard_Boolean_HeaderFile + #include + #endif ++ ++#include ++#include ++ + class BRepAlgo_AsDes; + class TopoDS_Face; +-class TopTools_MapOfShape; + class TopoDS_Vertex; +-class TopTools_ListOfShape; + class TopoDS_Edge; + + +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.cxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.cxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.cxx 2016-09-29 14:44:02.000464619 +0300 +@@ -48,7 +48,6 @@ + #include + #include + #include +-#include + #include + #include + #include +@@ -206,7 +205,7 @@ + Handle (Geom_Surface) S = BRep_Tool::Surface(F,L); + + if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { +- S = (*(Handle_Geom_RectangularTrimmedSurface*)&S)->BasisSurface(); ++ S = Handle(Geom_RectangularTrimmedSurface)::DownCast (S)->BasisSurface(); + } + if (!S->IsUPeriodic() && !S->IsVPeriodic()) + return; +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.hxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.hxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.hxx 2016-09-29 14:44:02.000464619 +0300 +@@ -27,7 +27,9 @@ + #ifndef _Partition_Inter3d_HeaderFile + #define _Partition_Inter3d_HeaderFile + +-#ifndef _Handle_BRepAlgo_AsDes_HeaderFile ++#include ++ ++#if OCC_VERSION_MAJOR < 7 + #include + #endif + #ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile +@@ -36,6 +38,9 @@ + #ifndef _TopTools_MapOfShape_HeaderFile + #include + #endif ++#ifndef _TopTools_ListOfShape_HeaderFile ++#include ++#endif + #ifndef _TopTools_DataMapOfShapeShape_HeaderFile + #include + #endif +@@ -43,10 +48,7 @@ + #include + #endif + class BRepAlgo_AsDes; +-class TopTools_ListOfShape; +-class TopTools_DataMapOfShapeShape; + class TopoDS_Face; +-class TopTools_MapOfShape; + class TopoDS_Shape; + class TopoDS_Vertex; + class TopoDS_Edge; +@@ -83,13 +85,13 @@ + void FacesPartition(const TopoDS_Face& F1,const TopoDS_Face& F2) ; + Standard_Boolean IsDone(const TopoDS_Face& F1,const TopoDS_Face& F2) const; + TopTools_MapOfShape& TouchedFaces() ; +- Handle_BRepAlgo_AsDes AsDes() const; ++ Handle(BRepAlgo_AsDes) AsDes() const; + TopTools_MapOfShape& NewEdges() ; + Standard_Boolean HasSameDomainF(const TopoDS_Shape& F) const; + Standard_Boolean IsSameDomainF(const TopoDS_Shape& F1,const TopoDS_Shape& F2) const; + const TopTools_ListOfShape& SameDomain(const TopoDS_Face& F) const; + TopoDS_Vertex ReplaceSameDomainV(const TopoDS_Vertex& V,const TopoDS_Edge& E) const; +- Handle_BRepAlgo_AsDes SectionEdgesAD() const; ++ Handle(BRepAlgo_AsDes) SectionEdgesAD() const; + Standard_Boolean IsSectionEdge(const TopoDS_Edge& E) const; + Standard_Boolean HasSectionEdge(const TopoDS_Face& F) const; + Standard_Boolean IsSplitOn(const TopoDS_Edge& NewE,const TopoDS_Edge& OldE,const TopoDS_Face& F) const; +@@ -121,11 +123,11 @@ + + // Fields PRIVATE + // +- Handle_BRepAlgo_AsDes myAsDes; ++ Handle(BRepAlgo_AsDes) myAsDes; + TopTools_DataMapOfShapeListOfShape myDone; + TopTools_MapOfShape myTouched; + TopTools_MapOfShape myNewEdges; +- Handle_BRepAlgo_AsDes mySectionEdgesAD; ++ Handle(BRepAlgo_AsDes) mySectionEdgesAD; + TopTools_DataMapOfShapeListOfShape mySameDomainFM; + TopTools_DataMapOfShapeShape mySameDomainVM; + +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop.hxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Loop.hxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Loop.hxx 2016-09-29 14:44:02.000464619 +0300 +@@ -38,8 +38,6 @@ + #endif + class TopoDS_Face; + class TopoDS_Edge; +-class TopTools_ListOfShape; +- + + #ifndef _Standard_HeaderFile + #include +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.cxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.cxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.cxx 2016-09-29 14:04:51.504148314 +0300 +@@ -210,7 +210,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 +@@ -234,7 +234,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, +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.hxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.hxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.hxx 2016-09-29 14:44:02.000464619 +0300 +@@ -24,7 +24,6 @@ + #endif + class TopoDS_Face; + class TopoDS_Edge; +-class TopTools_ListOfShape; + class BRepAlgo_Image; + + +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop3d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop3d.hxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Loop3d.hxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Loop3d.hxx 2016-09-29 14:44:02.000464619 +0300 +@@ -13,6 +13,9 @@ + #ifndef _TopTools_ListOfShape_HeaderFile + #include + #endif ++#ifndef _TopTools_MapOfOrientedShape_HeaderFile ++#include ++#endif + #ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile + #include + #endif +@@ -23,8 +26,6 @@ + #include + #endif + class TopoDS_Shape; +-class TopTools_ListOfShape; +-class TopTools_MapOfOrientedShape; + class TopoDS_Edge; + class TopoDS_Face; + class gp_Vec; +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.cxx netgen-5.3.1_new/libsrc/occ/Partition_Spliter.cxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.cxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Spliter.cxx 2016-09-29 14:44:02.000464619 +0300 +@@ -48,7 +48,6 @@ + #include + #include + #include +-#include + #include + #include + +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.hxx netgen-5.3.1_new/libsrc/occ/Partition_Spliter.hxx +--- netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.hxx 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/Partition_Spliter.hxx 2016-09-29 14:44:02.004464639 +0300 +@@ -28,9 +28,6 @@ + #ifndef _TopTools_DataMapOfShapeShape_HeaderFile + #include + #endif +-#ifndef _Handle_BRepAlgo_AsDes_HeaderFile +-#include +-#endif + #ifndef _BRepAlgo_Image_HeaderFile + #include + #endif +@@ -45,7 +42,6 @@ + #endif + class BRepAlgo_AsDes; + class TopoDS_Shape; +-class TopTools_ListOfShape; + class TopoDS_Edge; + + +@@ -129,7 +125,7 @@ + TopTools_DataMapOfShapeShape myFaceShapeMap; + TopTools_DataMapOfShapeShape myInternalFaces; + TopTools_DataMapOfShapeShape myIntNotClFaces; +- Handle_BRepAlgo_AsDes myAsDes; ++ Handle(BRepAlgo_AsDes) myAsDes; + BRepAlgo_Image myImagesFaces; + BRepAlgo_Image myImagesEdges; + BRepAlgo_Image myImageShape; +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp netgen-5.3.1_new/libsrc/occ/occconstruction.cpp +--- netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/occconstruction.cpp 2016-09-29 14:04:51.500148293 +0300 @@ -28,7 +28,7 @@ #include #include @@ -110,117 +433,116 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp netgen-5.3.1_new/lib //#include #include #include -diff -Naur netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp netgen-5.3.1_new/libsrc/occ/occgenmesh.cpp ---- netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp 2010-03-16 09:30:07.000000000 +0300 -+++ netgen-5.3.1_new/libsrc/occ/occgenmesh.cpp 2014-07-22 13:01:28.000000000 +0400 -@@ -168,8 +173,8 @@ - if(h < 1e-4*maxside) - return; - -- -- if (h > 30) return; +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp netgen-5.3.1_new/libsrc/occ/occgenmesh.cpp +--- netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/occgenmesh.cpp 2016-09-29 14:04:51.500148293 +0300 +@@ -171,8 +171,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) -@@ -247,8 +253,8 @@ - hvalue[0] = 0; - pnt = c->Value(s0); - -- double olddist = 0; -- double dist = 0; + } + + if (h < maxside && depth < 10) +@@ -250,8 +250,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)); + + int tmpVal = (int)(DIVIDEEDGESECTIONS); + +@@ -259,15 +259,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); + hvalue[i] = hvalue[i-1] + + // 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()))* + 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))* +- pnt.Distance(oldpnt); + 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); + + //(*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); + } + + // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS])); +@@ -282,7 +286,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,9 @@ - (*testout) << "nedges = " << nedges << endl; - - double eps = 1e-6 * geom.GetBoundingBox().Diam(); + pnt = c->Value(params[i]); + ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z())); + i++; +@@ -326,6 +333,9 @@ + (*testout) << "nedges = " << nedges << endl; + + double eps = 1e-6 * geom.GetBoundingBox().Diam(); + const double eps2 = eps * eps; // -- small optimization + + int first_vp = mesh.GetNP()+1; // -- to support SALOME sub-meshes - - for (int i = 1; i <= nvertices; i++) - { -@@ -332,7 +348,8 @@ - bool exists = 0; - if (merge_solids) - for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++) -- if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps) + + for (int i = 1; i <= nvertices; i++) + { +@@ -335,7 +345,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 +379,7 @@ - { - TopoDS_Face face = TopoDS::Face(exp1.Current()); - int facenr = geom.fmap.FindIndex(face); + { + exists = 1; + break; +@@ -365,6 +376,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 +399,7 @@ - int facenr = 0; - int edgenr = 0; - + + if (face2solid[0][facenr-1] == 0) + face2solid[0][facenr-1] = solidnr; +@@ -384,6 +396,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 +461,7 @@ - //(*testout) << "ignoring degenerated edge" << endl; - continue; - } + + (*testout) << "faces = " << geom.fmap.Extent() << endl; + int curr = 0; +@@ -445,6 +458,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))) -@@ -474,20 +494,104 @@ - - if (!merge_solids) - { -- pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge)); -- pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge)); + + if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) == + geom.vmap.FindIndex(TopExp::LastVertex (edge))) +@@ -477,20 +491,104 @@ + + if (!merge_solids) + { +- pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge)); +- pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge)); + //pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge)); + //pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge)); + MeshPoint dfltP ( Point<3> ( 0, 0, 0 ) ); @@ -252,17 +574,17 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp netgen-5.3.1_new/libsrc/o + mesh.Point(ip) = MeshPoint( mesh.Point(ip), iv ); + break; + } -+ } -+ else -+ { + } + else + { +- Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge))); +- Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge))); + ip += first_vp - 1; + } + } - } - else - { -- Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge))); -- Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge))); ++ } ++ else ++ { + TopoDS_Iterator vIt( edge, false ); + TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next(); + TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() ); @@ -275,13 +597,13 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp netgen-5.3.1_new/libsrc/o + 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; + + 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; + } @@ -323,60 +645,59 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp netgen-5.3.1_new/libsrc/o + Dist2( lp, mesh[PointIndex(pnums.Last())])) + std::swap( pnums[0], pnums.Last() ); + } - } - } - -@@ -497,17 +601,20 @@ - bool exists = 0; - int j; - for (j = first_ep; j <= mesh.GetNP(); j++) + } + } + +@@ -500,17 +598,20 @@ + bool exists = 0; + int j; + for (j = first_ep; j <= mesh.GetNP(); j++) + { + if (!merge_solids && mesh.Point(j).GetLayer() != geomedgenr ) continue; // to support SALOME fuse edges - if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps) - { - exists = 1; - break; - } + if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps) + { + exists = 1; + break; + } + } - - if (exists) - pnums[i] = j; - else - { -- mesh.AddPoint (mp[i-1]); + + if (exists) + pnums[i] = j; + else + { +- mesh.AddPoint (mp[i-1]); + mesh.AddPoint (mp[i-1], geomedgenr); // to support SALOME fuse edges - (*testout) << "add meshpoint " << mp[i-1] << endl; - pnums[i] = mesh.GetNP(); - } -@@ -591,6 +698,8 @@ - // (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si - // << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl; - // exit(10); + (*testout) << "add meshpoint " << mp[i-1] << endl; + pnums[i] = mesh.GetNP(); + } +@@ -594,6 +695,8 @@ + // (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si + // << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl; + // exit(10); + for (int j = 1; j <= mesh.GetNP(); j++) // to support SALOME fuse edges: set level to zero + mesh.Point(j) = MeshPoint( (Point<3>&) mesh.Point(j) ); - - mesh.CalcSurfacesOfNode(); - multithread.task = savetask; -diff -Naur netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/occgeom.cpp ---- netgen-5.3.1_orig/libsrc/occ/occgeom.cpp 2010-03-05 16:16:21.000000000 +0300 -+++ netgen-5.3.1_new/libsrc/occ/occgeom.cpp 2014-07-22 13:01:28.000000000 +0400 + + mesh.CalcSurfacesOfNode(); + multithread.task = savetask; +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/occgeom.cpp +--- netgen-5.3.1_orig/libsrc/occ/occgeom.cpp 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/occgeom.cpp 2016-09-29 16:22:31.636328123 +0300 @@ -8,6 +8,8 @@ - #include "ShapeAnalysis_CheckSmallFace.hxx" - #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx" - #include "ShapeAnalysis_Surface.hxx" + #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 () + #include "BRepAlgoAPI_Fuse.hxx" + #include "BRepCheck_Analyzer.hxx" + #include "BRepLib.hxx" +@@ -16,9 +18,16 @@ + #include "ShapeFix_FixSmallFace.hxx" + #include "Partition_Spliter.hxx" + +- + namespace netgen + { + // free data used to optimize Project() and FastProject() + OCCGeometry::~OCCGeometry() + { @@ -385,14 +706,94 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/ + delete it.Value(); + } + -+ void OCCGeometry :: PrintNrShapes () - { - TopExp_Explorer e; - int count = 0; + void OCCGeometry :: PrintNrShapes () + { + TopExp_Explorer e; +@@ -112,7 +121,7 @@ + double surfacecont = 0; + + { +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + rebuild->Apply(shape); + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) + { +@@ -143,7 +152,7 @@ + cout << endl << "- repairing faces" << endl; + + Handle(ShapeFix_Face) sff; +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + rebuild->Apply(shape); + + +@@ -200,7 +209,7 @@ + + + { +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + rebuild->Apply(shape); + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) + { +@@ -217,7 +226,7 @@ + cout << endl << "- fixing small edges" << endl; + + Handle(ShapeFix_Wire) sfw; +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + rebuild->Apply(shape); + + +@@ -284,7 +293,7 @@ + + { + BuildFMap(); +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + rebuild->Apply(shape); + + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) +@@ -312,7 +321,7 @@ + + + { +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + rebuild->Apply(shape); + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) + { +@@ -438,7 +447,7 @@ + + + { +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + rebuild->Apply(shape); + for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) + { +@@ -483,7 +492,7 @@ + TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); + TopoDS_Solid newsolid = solid; + BRepLib::OrientClosedSolid (newsolid); +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + // rebuild->Apply(shape); + rebuild->Replace(solid, newsolid, Standard_False); + TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID);//, 1); +@@ -906,7 +915,7 @@ + TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); + TopoDS_Solid newsolid = solid; + BRepLib::OrientClosedSolid (newsolid); +- Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; ++ Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; + rebuild->Replace(solid, newsolid, Standard_False); + + TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_SHAPE, 1); @@ -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 @@ -413,25 +814,23 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/ + fclsmap.Bind(surfi, cls); + } + } - -- -- void OCCGeometry :: Project (int surfi, Point<3> & p) const + +- +- 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 ); -- -- + { + 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))); @@ -443,7 +842,7 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/ + 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) + { @@ -451,65 +850,24 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/ + } + pnt = proj->Value(p2d); + p2d.Coord(u, v); -+ - p = Point<3> (pnt.X(), pnt.Y(), pnt.Z()); - + + 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()); + { + 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; + // -- Optimization: use cached projector and classifier + // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi))); + // @@ -562,111 +920,228 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/ + Handle(ShapeAnalysis_Surface) proj; + BRepTopAdaptor_FClass2d *cls; + GetFaceTools(surfi, proj, cls); -+ + +- 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 -Naur netgen-5.3.1_orig/libsrc/occ/occgeom.hpp netgen-5.3.1_new/libsrc/occ/occgeom.hpp ---- netgen-5.3.1_orig/libsrc/occ/occgeom.hpp 2010-01-14 19:56:19.000000000 +0300 -+++ netgen-5.3.1_new/libsrc/occ/occgeom.hpp 2014-07-22 13:09:03.000000000 +0400 + + return true; + } +@@ -1038,9 +1095,9 @@ + { + cout << "writing stl..."; cout.flush(); + StlAPI_Writer writer; +- writer.RelativeMode() = Standard_False; ++ //writer.RelativeMode() = Standard_False; + +- writer.SetDeflection(0.02); ++ //writer.SetDeflection(0.02); + writer.Write(shape,filename); + + cout << "done" << endl; +@@ -1059,10 +1116,10 @@ + occgeo = new OCCGeometry; + + // Initiate a dummy XCAF Application to handle the IGES XCAF Document +- static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication(); ++ static Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication(); + + // Create an XCAF Document to contain the IGES file itself +- Handle_TDocStd_Document iges_doc; ++ Handle(TDocStd_Document) iges_doc; + + // Check if a IGES File is already open under this handle, if so, close it to prevent + // Segmentation Faults when trying to create a new document +@@ -1089,8 +1146,8 @@ + reader.Transfer(iges_doc); + + // Read in the shape(s) and the colours present in the IGES File +- Handle_XCAFDoc_ShapeTool iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main()); +- Handle_XCAFDoc_ColorTool iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main()); ++ Handle(XCAFDoc_ShapeTool) iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main()); ++ Handle(XCAFDoc_ColorTool) iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main()); + + TDF_LabelSequence iges_shapes; + iges_shape_contents->GetShapes(iges_shapes); +@@ -1137,10 +1194,10 @@ + occgeo = new OCCGeometry; + + // Initiate a dummy XCAF Application to handle the STEP XCAF Document +- static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication(); ++ static Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication(); + + // Create an XCAF Document to contain the STEP file itself +- Handle_TDocStd_Document step_doc; ++ Handle(TDocStd_Document) step_doc; + + // Check if a STEP File is already open under this handle, if so, close it to prevent + // Segmentation Faults when trying to create a new document +@@ -1167,8 +1224,8 @@ + reader.Transfer(step_doc); + + // Read in the shape(s) and the colours present in the STEP File +- Handle_XCAFDoc_ShapeTool step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main()); +- Handle_XCAFDoc_ColorTool step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main()); ++ Handle(XCAFDoc_ShapeTool) step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main()); ++ Handle(XCAFDoc_ColorTool) step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main()); + + TDF_LabelSequence step_shapes; + step_shape_contents->GetShapes(step_shapes); +@@ -1221,7 +1278,7 @@ + // Fixed a bug in the OpenCascade XDE Colour handling when + // opening BREP Files, since BREP Files have no colour data. + // Hence, the face_colours Handle needs to be created as a NULL handle. +- occgeo->face_colours = Handle_XCAFDoc_ColorTool(); ++ occgeo->face_colours = Handle(XCAFDoc_ColorTool)(); + occgeo->face_colours.Nullify(); + occgeo->changed = 1; + occgeo->BuildFMap(); +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgeom.hpp netgen-5.3.1_new/libsrc/occ/occgeom.hpp +--- netgen-5.3.1_orig/libsrc/occ/occgeom.hpp 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/occgeom.hpp 2016-09-29 14:44:01.996464598 +0300 @@ -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 "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" + #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 "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" + #include "TopoDS_Wire.hxx" + #include "BRepTools_WireExplorer.hxx" + #include "BRepTools.hxx" @@ -68,18 +68,26 @@ - #include "IGESToBRep_Reader.hxx" - #include "Interface_Static.hxx" - #include "GeomAPI_ExtremaCurveCurve.hxx" --#include "Standard_ErrorHandler.hxx" + #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" - #include "ShapeFix_Wireframe.hxx" + #include "Standard_Failure.hxx" + #include "ShapeUpgrade_ShellSewing.hxx" + #include "ShapeFix_Shape.hxx" + #include "ShapeFix_Wireframe.hxx" +#include +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) <= 0x060702 +// porting to OCCT6.7.3 - #include "BRepMesh.hxx" + #include "BRepMesh.hxx" +#endif - #include "BRepMesh_IncrementalMesh.hxx" - #include "BRepBndLib.hxx" - #include "Bnd_Box.hxx" - #include "ShapeAnalysis.hxx" - #include "ShapeBuild_ReShape.hxx" - + #include "BRepMesh_IncrementalMesh.hxx" + #include "BRepBndLib.hxx" + #include "Bnd_Box.hxx" + #include "ShapeAnalysis.hxx" + #include "ShapeBuild_ReShape.hxx" + +// -- Optimization: to use cached projector and classifier +#include -+class Handle_ShapeAnalysis_Surface; ++class ShapeAnalysis_Surface; +class BRepTopAdaptor_FClass2d; - - // Philippose - 29/01/2009 - // OpenCascade XDE Support -@@ -190,6 +198,9 @@ - class OCCGeometry : public NetgenGeometry - { - Point<3> center; + + // Philippose - 29/01/2009 + // OpenCascade XDE Support +@@ -192,6 +200,9 @@ + class OCCGeometry : public NetgenGeometry + { + Point<3> center; + // -- Optimization: to use cached projector and classifier -+ mutable NCollection_DataMap fprjmap; ++ mutable NCollection_DataMap fprjmap; + mutable NCollection_DataMap fclsmap; - - public: - TopoDS_Shape shape; -@@ -241,6 +252,8 @@ - vmap.Clear(); - } - + + public: + TopoDS_Shape shape; +@@ -203,7 +214,7 @@ + // OpenCascade XDE Support + // XCAF Handle to make the face colours available to the rest of + // the system +- Handle_XCAFDoc_ColorTool face_colours; ++ Handle(XCAFDoc_ColorTool) face_colours; + + mutable int changed; + Array facemeshstatus; +@@ -247,6 +258,8 @@ + virtual void Save (string filename) const; + + + ~OCCGeometry(); // -- to free cached projector and classifier + - void BuildFMap(); - - Box<3> GetBoundingBox() -@@ -260,9 +273,14 @@ - Point<3> Center() - { return center;} - -- void Project (int surfi, Point<3> & p) const; + void BuildFMap(); + + Box<3> GetBoundingBox() +@@ -266,9 +279,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; - + 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-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/occ/occmeshsurf.cpp ---- netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp 2009-08-24 06:32:47.000000000 +0400 -+++ netgen-5.3.1_new/libsrc/occ/occmeshsurf.cpp 2014-07-22 13:01:28.000000000 +0400 + OCCSurface GetSurface (int surfi) + { + cout << "OCCGeometry::GetSurface using PLANESPACE" << endl; +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/occ/occmeshsurf.cpp +--- netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/occmeshsurf.cpp 2016-09-29 14:08:00.045144560 +0300 @@ -6,6 +6,7 @@ #include #include @@ -675,6 +1150,25 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/ namespace netgen +@@ -96,13 +97,16 @@ + + n.Normalize(); + } +- else ++ else if ( lprop.IsNormalDefined() ) + { + n(0)=lprop.Normal().X(); + n(1)=lprop.Normal().Y(); + n(2)=lprop.Normal().Z(); + } +- ++ else ++ { ++ n = 0; ++ } + if(glob_testout) + { + (*testout) << "u " << geominfo.u << " v " << geominfo.v @@ -434,23 +435,33 @@ void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const @@ -696,11 +1190,6 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/ 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)) + // { @@ -714,7 +1203,11 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/ + ok = geometry.FastProject (surfind, hp, gi.u, gi.v); + else + ok = geometry.Project (surfind, hp, gi.u, gi.v); -+ p = hp; + p = hp; +- return 1; +- } +- ProjectPoint (surfind, p); +- return CalcPointGeomInfo (surfind, gi, p); + return ok; } @@ -743,22 +1236,22 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/ newp = hnewp; newgi = ap1; - }; -+ } ++ }//; -- to compile with -Wall -pedantic - void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) + void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const { if (surfi > 0) - geometry.Project (surfi, p); - }; -+ // geometry.Project (surfi, p); -- Project() changed for optimization ++ //geometry.Project (surfi, p); + { + double u, v; + geometry.Project (surfi, p, u, v); + } + }//; -- to compile with -Wall -pedantic - void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) + void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const { @@ -723,9 +739,10 @@ if (!geometry.FastProject (surfi, p, gi.u, gi.v)) @@ -767,36 +1260,15 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/ - geometry.Project (surfi, p); + double u, v; + geometry.Project (surfi, p, u, v); ++ } } - }; -+ } -diff -Naur netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.cxx ---- netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.cxx 2009-08-24 06:12:24.000000000 +0400 -+++ netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.cxx 2014-07-22 13:01:28.000000000 +0400 -@@ -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, -diff -Naur netgen-5.3.1_orig/libsrc/occ/utilities.h netgen-5.3.1_new/libsrc/occ/utilities.h ---- netgen-5.3.1_orig/libsrc/occ/utilities.h 2009-08-24 06:12:24.000000000 +0400 -+++ netgen-5.3.1_new/libsrc/occ/utilities.h 2014-07-22 13:01:28.000000000 +0400 +diff -NaurwB netgen-5.3.1_orig/libsrc/occ/utilities.h netgen-5.3.1_new/libsrc/occ/utilities.h +--- netgen-5.3.1_orig/libsrc/occ/utilities.h 2014-08-29 13:54:03.000000000 +0400 ++++ netgen-5.3.1_new/libsrc/occ/utilities.h 2016-09-29 14:04:51.504148314 +0300 @@ -33,6 +33,7 @@ #include @@ -805,15 +1277,15 @@ diff -Naur netgen-5.3.1_orig/libsrc/occ/utilities.h netgen-5.3.1_new/libsrc/occ/ #include // #include "SALOME_Log.hxx" -diff -Naur netgen-5.3.1_orig/nglib/nglib.h netgen-5.3.1_new/nglib/nglib.h ---- netgen-5.3.1_orig/nglib/nglib.h 2010-05-18 15:20:25.000000000 +0400 -+++ netgen-5.3.1_new/nglib/nglib.h 2014-07-22 13:01:28.000000000 +0400 +diff -NaurwB netgen-5.3.1_orig/nglib/nglib.h netgen-5.3.1_new/nglib/nglib.h +--- netgen-5.3.1_orig/nglib/nglib.h 2014-08-29 13:54:00.000000000 +0400 ++++ netgen-5.3.1_new/nglib/nglib.h 2016-09-29 14:04:51.504148314 +0300 @@ -24,7 +24,7 @@ - // Philippose - 14.02.2009 - // Modifications for creating a DLL in Windows - #ifdef WIN32 -- #ifdef NGLIB_EXPORTS || nglib_EXPORTS + // 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) + #define DLL_HEADER __declspec(dllexport) + #else + #define DLL_HEADER __declspec(dllimport)