Salome HOME
Update netgen-5.3.1 patch.
[plugins/netgenplugin.git] / src / NETGEN / netgen53ForSalome.patch
1 diff -NaurwB netgen-5.3.1_orig/Makefile.am netgen-5.3.1_new/Makefile.am
2 --- netgen-5.3.1_orig/Makefile.am       2016-10-21 17:32:01.000000000 +0300
3 +++ netgen-5.3.1_new/Makefile.am        2016-10-21 17:31:54.000000000 +0300
4 @@ -2,7 +2,7 @@
5  
6  METASOURCES = AUTO
7  
8 -SUBDIRS = libsrc ng tutorials doc windows nglib
9 +SUBDIRS = libsrc nglib #tutorials doc windows nglib
10  
11  # TESTS = ng/netgen -batchmode
12  
13 diff -NaurwB netgen-5.3.1_orig/Makefile.in netgen-5.3.1_new/Makefile.in
14 --- netgen-5.3.1_orig/Makefile.in       2014-10-06 15:04:37.000000000 +0400
15 +++ netgen-5.3.1_new/Makefile.in        2016-10-03 16:17:10.164707368 +0300
16 @@ -280,7 +280,7 @@
17  top_srcdir = @top_srcdir@
18  ACLOCAL_AMFLAGS = -I m4
19  METASOURCES = AUTO
20 -SUBDIRS = libsrc ng tutorials doc windows nglib
21 +SUBDIRS = libsrc nglib #tutorials doc windows nglib
22  all: config.h
23         $(MAKE) $(AM_MAKEFLAGS) all-recursive
24  
25 diff -NaurwB netgen-5.3.1_orig/configure.ac netgen-5.3.1_new/configure.ac
26 --- netgen-5.3.1_orig/configure.ac      2014-10-06 15:00:17.000000000 +0400
27 +++ netgen-5.3.1_new/configure.ac       2016-09-29 14:34:11.957389447 +0300
28 @@ -20,7 +20,7 @@
29  CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
30  # LDFLAGS="$LDFLAGS $OPENMP_CXXFLAGS"
31  
32 -AM_PROG_AR
33 +m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
34  AC_PROG_LIBTOOL
35  LT_INIT
36  
37 @@ -42,8 +42,8 @@
38  
39  if test a$occon = atrue ; then
40  
41 -       AC_SUBST([OCCFLAGS], ["-DOCCGEOMETRY -I$occdir/inc -I/usr/include/opencascade"])
42 -       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"])
43 +       AC_SUBST([OCCFLAGS], ["-DOCCGEOMETRY -I$occdir/include/opencascade"])
44 +       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"])
45  
46  #  -lTKDCAF
47  
48 diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/findip.hpp netgen-5.3.1_new/libsrc/meshing/findip.hpp
49 --- netgen-5.3.1_orig/libsrc/meshing/findip.hpp 2014-08-29 13:54:05.000000000 +0400
50 +++ netgen-5.3.1_new/libsrc/meshing/findip.hpp  2016-09-30 20:38:56.662234111 +0300
51 @@ -75,6 +75,9 @@
52    static int timer = NgProfiler::CreateTimer ("FindInnerPoint");
53    NgProfiler::RegionTimer reg (timer);
54  
55 +  if ( points.Size() < 3 )
56 +    return 0;
57 +
58    Array<Vec3d> a;
59    Array<double> c;
60    Mat<3> m, inv;
61 diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/improve3.cpp netgen-5.3.1_new/libsrc/meshing/improve3.cpp
62 --- netgen-5.3.1_orig/libsrc/meshing/improve3.cpp       2014-08-29 13:54:05.000000000 +0400
63 +++ netgen-5.3.1_new/libsrc/meshing/improve3.cpp        2016-10-03 16:16:57.636639300 +0300
64 @@ -1219,6 +1219,7 @@
65  
66               tetused = 0;
67               tetused[0] = 1;
68 +              int nbtetused = 0;
69  
70               for (int l = 2; l < nsuround; l++)
71                 {
72 @@ -1239,10 +1240,12 @@
73                               
74                               tetused[k] = 1; 
75                               suroundpts[l] = newpi;
76 +                              ++nbtetused;
77                             }                   
78                       }
79                 }
80 -
81 +              if ( nbtetused < nsuround )
82 +                continue;
83               
84               bad1 = 0;
85               for (int k = 0; k < nsuround; k++)
86 diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp netgen-5.3.1_new/libsrc/meshing/meshtype.cpp
87 --- netgen-5.3.1_orig/libsrc/meshing/meshtype.cpp       2014-08-29 13:54:05.000000000 +0400
88 +++ netgen-5.3.1_new/libsrc/meshing/meshtype.cpp        2016-09-29 14:04:51.500148293 +0300
89 @@ -1,4 +1,5 @@
90  #include <mystdlib.h>
91 +#include <float.h> // to get DBL_MIN defined
92  
93  #include "meshing.hpp"  
94  
95 @@ -666,7 +667,8 @@
96  
97          double det = trans.Det();
98  
99 -        if (det <= 0)
100 +        // if (det <= 0)
101 +        if (det <= DBL_MIN) // avoid FPE
102            err += 1e12;
103          else
104            err += frob * frob / det;
105 @@ -722,7 +724,8 @@
106  
107              double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
108  
109 -            if (det <= 0)
110 +            // if (det <= 0)
111 +            if (det <= DBL_MIN)  // avoid FPE
112                {
113                  dd = 0;
114                  return 1e12;
115 @@ -806,7 +809,8 @@
116            = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0)
117            + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0);
118  
119 -        if (det <= 0)
120 +        // if (det <= 0)
121 +        if (det <= DBL_MIN) // avoid FPE
122            err += 1e12;
123          else
124            {
125 @@ -856,7 +860,8 @@
126          frob /= 2;
127  
128          double det = trans.Det();
129 -        if (det <= 0)
130 +        //if (det <= 0)
131 +        if (det <= DBL_MIN) // avoid FPE
132            err += 1e12;
133          else
134            err += frob * frob / det;
135 @@ -1864,7 +1869,8 @@
136        case PYRAMID:
137          {
138            double noz = 1-p(2);
139 -          if (noz == 0.0) noz = 1e-10;
140 +          //if (noz == 0.0) noz = 1e-10;
141 +          if (noz <= DBL_MIN) noz = 1e-10; // avoid FPE
142  
143            double xi  = p(0) / noz;
144            double eta = p(1) / noz;
145 @@ -2030,7 +2036,8 @@
146  
147          double det = -trans.Det();
148        
149 -        if (det <= 0)
150 +        //if (det <= 0)
151 +        if (det <= DBL_MIN) // avoid FPE
152            err += 1e12;
153          else
154            err += frob * frob * frob / det;
155 @@ -2102,7 +2109,8 @@
156          ddet *= -1;
157  
158        
159 -        if (det <= 0)
160 +        //if (det <= 0)
161 +        if (det <= DBL_MIN) // avoid FPE
162            err += 1e12;
163          else
164            {
165 @@ -2184,7 +2192,7 @@
166        
167          det *= -1;
168        
169 -        if (det <= 0)
170 +        if (det <= DBL_MIN)
171            err += 1e12;
172          else
173            {
174 diff -NaurwB netgen-5.3.1_orig/libsrc/meshing/meshtype.hpp netgen-5.3.1_new/libsrc/meshing/meshtype.hpp
175 --- netgen-5.3.1_orig/libsrc/meshing/meshtype.hpp       2014-08-29 13:54:05.000000000 +0400
176 +++ netgen-5.3.1_new/libsrc/meshing/meshtype.hpp        2016-09-30 14:28:09.147575801 +0300
177 @@ -15,6 +15,7 @@
178      Classes for NETGEN
179    */
180  
181 +class Mesh; // added due to compilation errors on some platforms
182  
183  
184    enum ELEMENT_TYPE { 
185 @@ -360,7 +361,7 @@
186          {
187  #ifdef DEBUG
188            if (typ != QUAD && typ != QUAD6 && typ != QUAD8)
189 -            PrintSysError ("element2d::GetNV not implemented for typ", typ)
190 +            PrintSysError ("element2d::GetNV not implemented for typ", typ);
191  #endif
192            return 4;
193          }
194 @@ -618,7 +619,7 @@
195           return 8;
196         default:
197  #ifdef DEBUG
198 -         PrintSysError ("Element3d::GetNV not implemented for typ ", typ)
199 +         PrintSysError ("Element3d::GetNV not implemented for typ ", typ);
200  #endif
201             ;
202         }
203 @@ -682,7 +683,7 @@
204         case PRISM12: return 5;
205         default:
206  #ifdef DEBUG
207 -         PrintSysError ("element3d::GetNFaces not implemented for typ", typ)
208 +         PrintSysError ("element3d::GetNFaces not implemented for typ", typ);
209  #endif
210             ;
211         }
212 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.cxx
213 --- netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.cxx  2014-08-29 13:54:03.000000000 +0400
214 +++ netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.cxx   2016-09-29 14:44:01.996464598 +0300
215 @@ -47,9 +47,7 @@
216  #include <TopOpeBRep_EdgesIntersector.hxx>
217  #include <TopOpeBRep_Point2d.hxx>
218  #include <TopTools_ListIteratorOfListOfShape.hxx>
219 -#include <TopTools_ListOfShape.hxx>
220  #include <TopTools_MapIteratorOfMapOfShape.hxx>
221 -#include <TopTools_MapOfShape.hxx>
222  #include <TopoDS.hxx>
223  #include <TopoDS_Edge.hxx>
224  #include <TopoDS_Vertex.hxx>
225 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.hxx
226 --- netgen-5.3.1_orig/libsrc/occ/Partition_Inter2d.hxx  2014-08-29 13:54:03.000000000 +0400
227 +++ netgen-5.3.1_new/libsrc/occ/Partition_Inter2d.hxx   2016-09-29 14:44:01.996464598 +0300
228 @@ -27,7 +27,9 @@
229  #ifndef _Partition_Inter2d_HeaderFile
230  #define _Partition_Inter2d_HeaderFile
231  
232 -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
233 +#include <Standard_Version.hxx>
234 +
235 +#if OCC_VERSION_MAJOR < 7
236  #include <Handle_BRepAlgo_AsDes.hxx>
237  #endif
238  #ifndef _Standard_Real_HeaderFile
239 @@ -36,11 +38,13 @@
240  #ifndef _Standard_Boolean_HeaderFile
241  #include <Standard_Boolean.hxx>
242  #endif
243 +
244 +#include <TopTools_MapOfShape.hxx>
245 +#include <TopTools_ListOfShape.hxx>
246 +
247  class BRepAlgo_AsDes;
248  class TopoDS_Face;
249 -class TopTools_MapOfShape;
250  class TopoDS_Vertex;
251 -class TopTools_ListOfShape;
252  class TopoDS_Edge;
253  
254  
255 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.cxx
256 --- netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.cxx  2014-08-29 13:54:03.000000000 +0400
257 +++ netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.cxx   2016-09-29 14:44:02.000464619 +0300
258 @@ -48,7 +48,6 @@
259  #include <TopOpeBRepTool_BoxSort.hxx>
260  #include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
261  #include <TopTools_ListIteratorOfListOfShape.hxx>
262 -#include <TopTools_ListOfShape.hxx>
263  #include <TopoDS.hxx>
264  #include <TopoDS_Compound.hxx>
265  #include <TopoDS_Edge.hxx>
266 @@ -206,7 +205,7 @@
267    Handle (Geom_Surface) S   = BRep_Tool::Surface(F,L);
268  
269    if (S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
270 -    S = (*(Handle_Geom_RectangularTrimmedSurface*)&S)->BasisSurface();
271 +    S = Handle(Geom_RectangularTrimmedSurface)::DownCast (S)->BasisSurface();
272    }
273    if (!S->IsUPeriodic() && !S->IsVPeriodic())
274      return;
275 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.hxx
276 --- netgen-5.3.1_orig/libsrc/occ/Partition_Inter3d.hxx  2014-08-29 13:54:03.000000000 +0400
277 +++ netgen-5.3.1_new/libsrc/occ/Partition_Inter3d.hxx   2016-09-29 14:44:02.000464619 +0300
278 @@ -27,7 +27,9 @@
279  #ifndef _Partition_Inter3d_HeaderFile
280  #define _Partition_Inter3d_HeaderFile
281  
282 -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
283 +#include <Standard_Version.hxx>
284 +
285 +#if OCC_VERSION_MAJOR < 7
286  #include <Handle_BRepAlgo_AsDes.hxx>
287  #endif
288  #ifndef _TopTools_DataMapOfShapeListOfShape_HeaderFile
289 @@ -36,6 +38,9 @@
290  #ifndef _TopTools_MapOfShape_HeaderFile
291  #include <TopTools_MapOfShape.hxx>
292  #endif
293 +#ifndef _TopTools_ListOfShape_HeaderFile
294 +#include <TopTools_ListOfShape.hxx>
295 +#endif
296  #ifndef _TopTools_DataMapOfShapeShape_HeaderFile
297  #include <TopTools_DataMapOfShapeShape.hxx>
298  #endif
299 @@ -43,10 +48,7 @@
300  #include <Standard_Boolean.hxx>
301  #endif
302  class BRepAlgo_AsDes;
303 -class TopTools_ListOfShape;
304 -class TopTools_DataMapOfShapeShape;
305  class TopoDS_Face;
306 -class TopTools_MapOfShape;
307  class TopoDS_Shape;
308  class TopoDS_Vertex;
309  class TopoDS_Edge;
310 @@ -83,13 +85,13 @@
311     void FacesPartition(const TopoDS_Face& F1,const TopoDS_Face& F2) ;
312     Standard_Boolean IsDone(const TopoDS_Face& F1,const TopoDS_Face& F2) const;
313     TopTools_MapOfShape& TouchedFaces() ;
314 -   Handle_BRepAlgo_AsDes AsDes() const;
315 +   Handle(BRepAlgo_AsDes) AsDes() const;
316     TopTools_MapOfShape& NewEdges() ;
317     Standard_Boolean HasSameDomainF(const TopoDS_Shape& F) const;
318     Standard_Boolean IsSameDomainF(const TopoDS_Shape& F1,const TopoDS_Shape& F2) const;
319     const TopTools_ListOfShape& SameDomain(const TopoDS_Face& F) const;
320     TopoDS_Vertex ReplaceSameDomainV(const TopoDS_Vertex& V,const TopoDS_Edge& E) const;
321 -   Handle_BRepAlgo_AsDes SectionEdgesAD() const;
322 +   Handle(BRepAlgo_AsDes) SectionEdgesAD() const;
323     Standard_Boolean IsSectionEdge(const TopoDS_Edge& E) const;
324     Standard_Boolean HasSectionEdge(const TopoDS_Face& F) const;
325     Standard_Boolean IsSplitOn(const TopoDS_Edge& NewE,const TopoDS_Edge& OldE,const TopoDS_Face& F) const;
326 @@ -121,11 +123,11 @@
327  
328     // Fields PRIVATE
329     //
330 -   Handle_BRepAlgo_AsDes myAsDes;
331 +   Handle(BRepAlgo_AsDes) myAsDes;
332     TopTools_DataMapOfShapeListOfShape myDone;
333     TopTools_MapOfShape myTouched;
334     TopTools_MapOfShape myNewEdges;
335 -   Handle_BRepAlgo_AsDes mySectionEdgesAD;
336 +   Handle(BRepAlgo_AsDes) mySectionEdgesAD;
337     TopTools_DataMapOfShapeListOfShape mySameDomainFM;
338     TopTools_DataMapOfShapeShape mySameDomainVM;
339  
340 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop.hxx
341 --- netgen-5.3.1_orig/libsrc/occ/Partition_Loop.hxx     2014-08-29 13:54:03.000000000 +0400
342 +++ netgen-5.3.1_new/libsrc/occ/Partition_Loop.hxx      2016-09-29 14:44:02.000464619 +0300
343 @@ -38,8 +38,6 @@
344  #endif
345  class TopoDS_Face;
346  class TopoDS_Edge;
347 -class TopTools_ListOfShape;
348 -
349  
350  #ifndef _Standard_HeaderFile
351  #include <Standard.hxx>
352 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.cxx netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.cxx
353 --- netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.cxx   2014-08-29 13:54:03.000000000 +0400
354 +++ netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.cxx    2016-09-29 14:04:51.504148314 +0300
355 @@ -210,7 +210,7 @@
356      Cc->D1(uc, PC, CTg1);
357      if (!isForward) CTg1.Reverse();
358  
359 -    Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
360 +    Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
361  
362      // select an edge whose first derivative is most left of CTg1
363      // ie an angle between Tg1 and CTg1 is least
364 @@ -234,7 +234,7 @@
365        // -PI < angle < PI
366        Standard_Real angle = Tg1.Angle(CTg1);
367  
368 -      if (PI - Abs(angle) <= tolAng)
369 +      if (M_PI - Abs(angle) <= tolAng)
370        {
371          // an angle is too close to PI; assure that an angle sign really
372          // reflects an edge position: +PI - an edge is worst,
373 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.hxx
374 --- netgen-5.3.1_orig/libsrc/occ/Partition_Loop2d.hxx   2014-08-29 13:54:03.000000000 +0400
375 +++ netgen-5.3.1_new/libsrc/occ/Partition_Loop2d.hxx    2016-09-29 14:44:02.000464619 +0300
376 @@ -24,7 +24,6 @@
377  #endif
378  class TopoDS_Face;
379  class TopoDS_Edge;
380 -class TopTools_ListOfShape;
381  class BRepAlgo_Image;
382  
383  
384 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Loop3d.hxx netgen-5.3.1_new/libsrc/occ/Partition_Loop3d.hxx
385 --- netgen-5.3.1_orig/libsrc/occ/Partition_Loop3d.hxx   2014-08-29 13:54:03.000000000 +0400
386 +++ netgen-5.3.1_new/libsrc/occ/Partition_Loop3d.hxx    2016-09-29 14:44:02.000464619 +0300
387 @@ -13,6 +13,9 @@
388  #ifndef _TopTools_ListOfShape_HeaderFile
389  #include <TopTools_ListOfShape.hxx>
390  #endif
391 +#ifndef _TopTools_MapOfOrientedShape_HeaderFile
392 +#include <TopTools_MapOfOrientedShape.hxx>
393 +#endif
394  #ifndef _TopTools_IndexedDataMapOfShapeListOfShape_HeaderFile
395  #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
396  #endif
397 @@ -23,8 +26,6 @@
398  #include <Standard_Real.hxx>
399  #endif
400  class TopoDS_Shape;
401 -class TopTools_ListOfShape;
402 -class TopTools_MapOfOrientedShape;
403  class TopoDS_Edge;
404  class TopoDS_Face;
405  class gp_Vec;
406 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.cxx netgen-5.3.1_new/libsrc/occ/Partition_Spliter.cxx
407 --- netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.cxx  2014-08-29 13:54:03.000000000 +0400
408 +++ netgen-5.3.1_new/libsrc/occ/Partition_Spliter.cxx   2016-09-29 14:44:02.000464619 +0300
409 @@ -48,7 +48,6 @@
410  #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
411  #include <TopTools_IndexedMapOfShape.hxx>
412  #include <TopTools_ListIteratorOfListOfShape.hxx>
413 -#include <TopTools_ListOfShape.hxx>
414  #include <TopTools_MapIteratorOfMapOfShape.hxx>
415  #include <TopTools_SequenceOfShape.hxx>
416  
417 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.hxx netgen-5.3.1_new/libsrc/occ/Partition_Spliter.hxx
418 --- netgen-5.3.1_orig/libsrc/occ/Partition_Spliter.hxx  2014-08-29 13:54:03.000000000 +0400
419 +++ netgen-5.3.1_new/libsrc/occ/Partition_Spliter.hxx   2016-09-29 14:44:02.004464639 +0300
420 @@ -28,9 +28,6 @@
421  #ifndef _TopTools_DataMapOfShapeShape_HeaderFile
422  #include <TopTools_DataMapOfShapeShape.hxx>
423  #endif
424 -#ifndef _Handle_BRepAlgo_AsDes_HeaderFile
425 -#include <Handle_BRepAlgo_AsDes.hxx>
426 -#endif
427  #ifndef _BRepAlgo_Image_HeaderFile
428  #include <BRepAlgo_Image.hxx>
429  #endif
430 @@ -45,7 +42,6 @@
431  #endif
432  class BRepAlgo_AsDes;
433  class TopoDS_Shape;
434 -class TopTools_ListOfShape;
435  class TopoDS_Edge;
436  
437  
438 @@ -129,7 +125,7 @@
439     TopTools_DataMapOfShapeShape myFaceShapeMap;
440     TopTools_DataMapOfShapeShape myInternalFaces;
441     TopTools_DataMapOfShapeShape myIntNotClFaces;
442 -   Handle_BRepAlgo_AsDes myAsDes;
443 +   Handle(BRepAlgo_AsDes) myAsDes;
444     BRepAlgo_Image myImagesFaces;
445     BRepAlgo_Image myImagesEdges;
446     BRepAlgo_Image myImageShape;
447 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp netgen-5.3.1_new/libsrc/occ/occconstruction.cpp
448 --- netgen-5.3.1_orig/libsrc/occ/occconstruction.cpp    2014-08-29 13:54:03.000000000 +0400
449 +++ netgen-5.3.1_new/libsrc/occ/occconstruction.cpp     2016-09-29 14:04:51.500148293 +0300
450 @@ -28,7 +28,7 @@
451  #include <BRepAlgoAPI_Common.hxx>
452  #include <BRepAlgoAPI_Fuse.hxx>
453  #include <BRepAlgoAPI_Section.hxx>
454 -#include <BRepOffsetAPI_Sewing.hxx>
455 +//#include <BRepOffsetAPI_Sewing.hxx>
456  //#include <BRepAlgo_Sewing.hxx>
457  #include <BRepOffsetAPI_MakeOffsetShape.hxx>
458  #include <ShapeFix_Shape.hxx>
459 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp netgen-5.3.1_new/libsrc/occ/occgenmesh.cpp
460 --- netgen-5.3.1_orig/libsrc/occ/occgenmesh.cpp 2014-08-29 13:54:03.000000000 +0400
461 +++ netgen-5.3.1_new/libsrc/occ/occgenmesh.cpp  2016-09-29 14:04:51.500148293 +0300
462 @@ -171,8 +171,8 @@
463           if(h < 1e-4*maxside)\r
464              return;\r
465  \r
466 -\r
467 -         if (h > 30) return;\r
468 +         // commented to restrict H on a large sphere for example
469 +         //if (h > 30) return;
470        }\r
471  \r
472        if (h < maxside && depth < 10)\r
473 @@ -250,8 +250,8 @@
474        hvalue[0] = 0;\r
475        pnt = c->Value(s0);\r
476  \r
477 -      double olddist = 0;\r
478 -      double dist = 0;\r
479 +      //double olddist = 0; -- useless variables
480 +      //double dist = 0;
481  \r
482        int tmpVal = (int)(DIVIDEEDGESECTIONS);\r
483  \r
484 @@ -259,15 +259,19 @@
485        {\r
486           oldpnt = pnt;\r
487           pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));\r
488 +         // -- no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
489           hvalue[i] = hvalue[i-1] +\r
490 +         //   1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
491 +         //   pnt.Distance(oldpnt);
492 +           min( 1.0,
493              1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*\r
494 -            pnt.Distance(oldpnt);\r
495 +                pnt.Distance(oldpnt));
496  \r
497           //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))\r
498           //       <<  " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;\r
499  \r
500 -         olddist = dist;\r
501 -         dist = pnt.Distance(oldpnt);\r
502 +         //olddist = dist; -- useless variables
503 +         //dist = pnt.Distance(oldpnt);
504        }\r
505  \r
506        //  nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));\r
507 @@ -282,7 +286,10 @@
508        {\r
509           if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)\r
510           {\r
511 -            params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);\r
512 +            // -- for nsubedges comparable to DIVIDEEDGESECTIONS
513 +            //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
514 +            double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
515 +            params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
516              pnt = c->Value(params[i]);\r
517              ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));\r
518              i++;\r
519 @@ -326,6 +333,9 @@
520        (*testout) << "nedges = " << nedges << endl;\r
521  \r
522        double eps = 1e-6 * geom.GetBoundingBox().Diam();\r
523 +      const double eps2 = eps * eps; // -- small optimization
524 +
525 +      int first_vp = mesh.GetNP()+1; // -- to support SALOME sub-meshes
526  \r
527        for (int i = 1; i <= nvertices; i++)\r
528        {\r
529 @@ -335,7 +345,8 @@
530           bool exists = 0;\r
531           if (merge_solids)\r
532              for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)\r
533 -               if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)\r
534 +               //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)              
535 +               if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
536                 {\r
537                    exists = 1;\r
538                    break;\r
539 @@ -365,6 +376,7 @@
540           {\r
541              TopoDS_Face face = TopoDS::Face(exp1.Current());\r
542              int facenr = geom.fmap.FindIndex(face);\r
543 +            if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
544  \r
545              if (face2solid[0][facenr-1] == 0)\r
546                 face2solid[0][facenr-1] = solidnr;\r
547 @@ -384,6 +396,7 @@
548        int facenr = 0;\r
549        int edgenr = 0;\r
550  \r
551 +      edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
552  \r
553        (*testout) << "faces = " << geom.fmap.Extent() << endl;\r
554        int curr = 0;\r
555 @@ -445,6 +458,7 @@
556                    //(*testout) << "ignoring degenerated edge" << endl;\r
557                    continue;\r
558                 }\r
559 +               if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
560  \r
561                 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==\r
562                    geom.vmap.FindIndex(TopExp::LastVertex (edge)))\r
563 @@ -477,20 +491,104 @@
564  \r
565                 if (!merge_solids)\r
566                 {\r
567 -                  pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));\r
568 -                  pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));\r
569 +                 //pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
570 +                 //pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
571 +                 MeshPoint dfltP ( Point<3> ( 0, 0, 0 ) );
572 +                 int *ipp[] = { &pnums[0], &pnums[pnums.Size()-1] };
573 +                 TopoDS_Iterator vIt( edge, false );
574 +                 TopoDS_Vertex v[2];
575 +                 v[0] = TopoDS::Vertex( vIt.Value() ); vIt.Next();
576 +                 v[1] = TopoDS::Vertex( vIt.Value() );
577 +                 if ( v[0].Orientation() == TopAbs_REVERSED )
578 +                   std::swap( v[0], v[1] );
579 +                 for ( int i = 0; i < 2; ++i)
580 +                 {
581 +                   int &ip = *ipp[i];
582 +                   ip = geom.vmap.FindIndex ( v[i] );
583 +                   if ( ip == 0 || ip > nvertices )
584 +                   {
585 +                     int iv = ip;
586 +                     if ( ip == 0 )
587 +                       ip = iv = geom.vmap.Add( v[i] );
588 +                     gp_Pnt pnt = BRep_Tool::Pnt( v[i] );
589 +                     MeshPoint mp( Point<3>(pnt.X(), pnt.Y(), pnt.Z()) );
590 +                     for (PointIndex pi = 1; pi < first_vp; pi++)
591 +                       if ( Dist2 (mesh.Point(pi), Point<3>(mp)) < 1e-100 )
592 +                       {
593 +                         ip = pi;
594 +                         if ( mesh.Point(ip).GetLayer() != dfltP.GetLayer() && mesh.Point(ip).GetLayer() != iv )
595 +                           continue;
596 +                         if ( mesh.Point(ip).GetLayer() == dfltP.GetLayer())
597 +                           mesh.Point(ip) = MeshPoint( mesh.Point(ip), iv );
598 +                         break;
599 +                       }
600                 }\r
601                 else\r
602                 {\r
603 -                  Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));\r
604 -                  Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));\r
605 +                     ip += first_vp - 1;
606 +                   }
607 +                 }
608 +               }
609 +               else
610 +               {
611 +                 TopoDS_Iterator vIt( edge, false );
612 +                 TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
613 +                 TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
614 +                 if ( v1.Orientation() == TopAbs_REVERSED )
615 +                   std::swap( v1, v2 );
616 +                 const bool isClosedEdge = v1.IsSame( v2 );
617 +                 
618 +                  Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
619 +                  Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
620 +                  double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
621 +                  if ( isClosedEdge )
622 +                    tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
623  \r
624                    pnums[0] = -1;\r
625                    pnums.Last() = -1;\r
626                    for (PointIndex pi = 1; pi < first_ep; pi++)\r
627                    {\r
628 -                     if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;\r
629 -                     if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;\r
630 +                    if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
631 +                    if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
632 +                  }
633 +                  if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
634 +                      ( !isClosedEdge && pnums[0] == pnums.Last() ))
635 +                    pnums[0] = pnums.Last() = -1;
636 +                  if ( pnums[0] == -1 || pnums.Last() == -1 )
637 +                  {
638 +                    // take into account a possible large gap between a vertex and an edge curve
639 +                    // end and a large vertex tolerance covering the whole edge
640 +                    if ( pnums[0] == -1 )
641 +                    {
642 +                      double tol = BRep_Tool::Tolerance( v1 );
643 +                      for (PointIndex pi = 1; pi < first_ep; pi++)
644 +                        if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
645 +                          pnums[0] = pi;
646 +
647 +                      if ( pnums[0] == -1 )
648 +                        pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
649 +                    }
650 +                    if ( isClosedEdge )
651 +                    {
652 +                      pnums.Last() = pnums[0];
653 +                    }
654 +                    else
655 +                    {
656 +                      if ( pnums.Last() == -1 )
657 +                      {
658 +                        double tol = BRep_Tool::Tolerance( v2 );
659 +                        for (PointIndex pi = 1; pi < first_ep; pi++)
660 +                          if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
661 +                            pnums.Last() = pi;
662 +
663 +                        if ( pnums.Last() == -1 )
664 +                          pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
665 +                      }
666 +
667 +                      if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
668 +                           Dist2( lp, mesh[PointIndex(pnums.Last())]))
669 +                      std::swap( pnums[0], pnums.Last() );
670 +                    }
671                    }\r
672                 }\r
673  \r
674 @@ -500,17 +598,20 @@
675                    bool exists = 0;\r
676                    int j;\r
677                    for (j = first_ep; j <= mesh.GetNP(); j++)\r
678 +                  {
679 +                     if (!merge_solids && mesh.Point(j).GetLayer() != geomedgenr ) continue; // to support SALOME fuse edges
680                       if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)\r
681                       {\r
682                          exists = 1;\r
683                          break;\r
684                       }\r
685 +                  }
686  \r
687                       if (exists)\r
688                          pnums[i] = j;\r
689                       else\r
690                       {\r
691 -                        mesh.AddPoint (mp[i-1]);\r
692 +                        mesh.AddPoint (mp[i-1], geomedgenr); // to support SALOME fuse edges
693                          (*testout) << "add meshpoint " << mp[i-1] << endl;\r
694                          pnums[i] = mesh.GetNP();\r
695                       }\r
696 @@ -594,6 +695,8 @@
697        //               (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si\r
698        //                               << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl;\r
699        //       exit(10);\r
700 +      for (int j = 1; j <= mesh.GetNP(); j++) // to support SALOME fuse edges: set level to zero
701 +        mesh.Point(j) = MeshPoint( (Point<3>&) mesh.Point(j) );
702  \r
703        mesh.CalcSurfacesOfNode();\r
704        multithread.task = savetask;\r
705 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgeom.cpp netgen-5.3.1_new/libsrc/occ/occgeom.cpp
706 --- netgen-5.3.1_orig/libsrc/occ/occgeom.cpp    2014-08-29 13:54:03.000000000 +0400
707 +++ netgen-5.3.1_new/libsrc/occ/occgeom.cpp     2016-09-29 16:22:31.636328123 +0300
708 @@ -8,6 +8,8 @@
709  #include "ShapeAnalysis_CheckSmallFace.hxx"\r
710  #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"\r
711  #include "ShapeAnalysis_Surface.hxx"\r
712 +#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
713 +#include <TopAbs_State.hxx>
714  #include "BRepAlgoAPI_Fuse.hxx"\r
715  #include "BRepCheck_Analyzer.hxx"\r
716  #include "BRepLib.hxx"\r
717 @@ -16,9 +18,16 @@
718  #include "ShapeFix_FixSmallFace.hxx"\r
719  #include "Partition_Spliter.hxx"\r
720  \r
721 -\r
722  namespace netgen\r
723  {\r
724 +  // free data used to optimize Project() and FastProject()
725 +  OCCGeometry::~OCCGeometry()
726 +  {
727 +    NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
728 +    for (; it.More(); it.Next())
729 +      delete it.Value();
730 +  }
731 +
732     void OCCGeometry :: PrintNrShapes ()\r
733     {\r
734        TopExp_Explorer e;\r
735 @@ -112,7 +121,7 @@
736        double surfacecont = 0;\r
737  \r
738        {\r
739 -         Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
740 +         Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
741           rebuild->Apply(shape);\r
742           for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
743           {\r
744 @@ -143,7 +152,7 @@
745           cout << endl << "- repairing faces" << endl;\r
746  \r
747           Handle(ShapeFix_Face) sff;\r
748 -         Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
749 +         Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
750           rebuild->Apply(shape);\r
751  \r
752  \r
753 @@ -200,7 +209,7 @@
754  \r
755  \r
756        {\r
757 -         Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
758 +         Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
759           rebuild->Apply(shape);\r
760           for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
761           {\r
762 @@ -217,7 +226,7 @@
763           cout << endl << "- fixing small edges" << endl;\r
764  \r
765           Handle(ShapeFix_Wire) sfw;\r
766 -         Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
767 +         Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
768           rebuild->Apply(shape);\r
769  \r
770  \r
771 @@ -284,7 +293,7 @@
772  \r
773           {\r
774              BuildFMap();\r
775 -            Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
776 +            Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
777              rebuild->Apply(shape);\r
778  \r
779              for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
780 @@ -312,7 +321,7 @@
781  \r
782  \r
783           {\r
784 -            Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
785 +            Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
786              rebuild->Apply(shape);\r
787              for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
788              {\r
789 @@ -438,7 +447,7 @@
790  \r
791  \r
792        {\r
793 -         Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
794 +         Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
795           rebuild->Apply(shape);\r
796           for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next())\r
797           {\r
798 @@ -483,7 +492,7 @@
799                    TopoDS_Solid solid = TopoDS::Solid(exp0.Current());\r
800                    TopoDS_Solid newsolid = solid;\r
801                    BRepLib::OrientClosedSolid (newsolid);\r
802 -                  Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
803 +                  Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
804                    //             rebuild->Apply(shape);\r
805                    rebuild->Replace(solid, newsolid, Standard_False);\r
806                    TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID);//, 1);\r
807 @@ -906,7 +915,7 @@
808              TopoDS_Solid solid = TopoDS::Solid(exp0.Current());\r
809              TopoDS_Solid newsolid = solid;\r
810              BRepLib::OrientClosedSolid (newsolid);\r
811 -            Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;\r
812 +            Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape;
813              rebuild->Replace(solid, newsolid, Standard_False);\r
814  \r
815              TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_SHAPE, 1);\r
816 @@ -951,25 +960,58 @@
817     }\r
818  \r
819  \r
820 +   // returns a projector and a classifier for the given surface
821 +   void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
822 +                                  BRepTopAdaptor_FClass2d*& cls) const
823 +   {
824 +     //MSV: organize caching projector in the map
825 +     if (fprjmap.IsBound(surfi))
826 +     {
827 +       proj = fprjmap.Find(surfi);
828 +       cls = fclsmap.Find(surfi);
829 +     }
830 +     else
831 +     {
832 +       const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
833 +       Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
834 +       proj = new ShapeAnalysis_Surface(aSurf);
835 +       fprjmap.Bind(surfi, proj);
836 +       cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
837 +       fclsmap.Bind(surfi, cls);
838 +     }
839 +   }
840  \r
841 -\r
842 -   void OCCGeometry :: Project (int surfi, Point<3> & p) const\r
843 +   // void OCCGeometry :: Project (int surfi, Point<3> & p) const
844 +   bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
845     {\r
846        static int cnt = 0;\r
847        if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;\r
848  \r
849        gp_Pnt pnt(p(0), p(1), p(2));\r
850  \r
851 -      double u,v;\r
852 -      Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));\r
853 -      Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );\r
854 -      gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );\r
855 -      suval.Coord( u, v);\r
856 -      pnt = thesurf->Value( u, v );\r
857 +      // -- Optimization: use cached projector and classifier
858 +      // double u,v;
859 +      // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
860 +      // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
861 +      // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
862 +      // suval.Coord( u, v);
863 +      // pnt = thesurf->Value( u, v );  
864 +
865 +      Handle(ShapeAnalysis_Surface) proj;
866 +      BRepTopAdaptor_FClass2d *cls;
867 +      GetFaceTools(surfi, proj, cls);
868  \r
869 +      gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
870 +      if (cls->Perform(p2d) == TopAbs_OUT)
871 +      {
872 +        return false;
873 +      }
874 +      pnt = proj->Value(p2d);
875 +      p2d.Coord(u, v);
876  \r
877        p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());\r
878  \r
879 +      return true;
880     }\r
881  \r
882  \r
883 @@ -979,54 +1021,69 @@
884     {\r
885        gp_Pnt p(ap(0), ap(1), ap(2));\r
886  \r
887 -      Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));\r
888 -\r
889 -      gp_Pnt x = surface->Value (u,v);\r
890 -\r
891 -      if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;\r
892 -\r
893 -      gp_Vec du, dv;\r
894 +      // -- Optimization: use cached projector and classifier
895 +      // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
896 +      // 
897 +      // gp_Pnt x = surface->Value (u,v);
898 +      // 
899 +      // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
900 +      // 
901 +      // gp_Vec du, dv;
902 +      // 
903 +      // surface->D1(u,v,x,du,dv);
904 +      // 
905 +      // int count = 0;
906 +      // 
907 +      // gp_Pnt xold;
908 +      // gp_Vec n;
909 +      // double det, lambda, mu;
910 +      // 
911 +      // do {
912 +      //    count++;
913 +      // 
914 +      //    n = du^dv;
915 +      // 
916 +      //    det = Det3 (n.X(), du.X(), dv.X(),
917 +      //       n.Y(), du.Y(), dv.Y(),
918 +      //       n.Z(), du.Z(), dv.Z());
919 +      // 
920 +      //    if (det < 1e-15) return false;
921 +      // 
922 +      //    lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
923 +      //       n.Y(), p.Y()-x.Y(), dv.Y(),
924 +      //       n.Z(), p.Z()-x.Z(), dv.Z())/det;
925 +      // 
926 +      //    mu     = Det3 (n.X(), du.X(), p.X()-x.X(),
927 +      //       n.Y(), du.Y(), p.Y()-x.Y(),
928 +      //       n.Z(), du.Z(), p.Z()-x.Z())/det;
929 +      // 
930 +      //    u += lambda;
931 +      //    v += mu;
932 +      // 
933 +      //    xold = x;
934 +      //    surface->D1(u,v,x,du,dv);
935 +      // 
936 +      // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
937 +      // 
938 +      // //    (*testout) << "FastProject count: " << count << endl;
939 +      // 
940 +      // if (count == 50) return false;
941 +      // 
942 +      // ap = Point<3> (x.X(), x.Y(), x.Z());
943 +      Handle(ShapeAnalysis_Surface) proj;
944 +      BRepTopAdaptor_FClass2d *cls;
945 +      GetFaceTools(surfi, proj, cls);
946  \r
947 -      surface->D1(u,v,x,du,dv);\r
948 -\r
949 -      int count = 0;\r
950 -\r
951 -      gp_Pnt xold;\r
952 -      gp_Vec n;\r
953 -      double det, lambda, mu;\r
954 -\r
955 -      do {\r
956 -         count++;\r
957 -\r
958 -         n = du^dv;\r
959 -\r
960 -         det = Det3 (n.X(), du.X(), dv.X(),\r
961 -            n.Y(), du.Y(), dv.Y(),\r
962 -            n.Z(), du.Z(), dv.Z());\r
963 -\r
964 -         if (det < 1e-15) return false;\r
965 -\r
966 -         lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),\r
967 -            n.Y(), p.Y()-x.Y(), dv.Y(),\r
968 -            n.Z(), p.Z()-x.Z(), dv.Z())/det;\r
969 -\r
970 -         mu     = Det3 (n.X(), du.X(), p.X()-x.X(),\r
971 -            n.Y(), du.Y(), p.Y()-x.Y(),\r
972 -            n.Z(), du.Z(), p.Z()-x.Z())/det;\r
973 -\r
974 -         u += lambda;\r
975 -         v += mu;\r
976 -\r
977 -         xold = x;\r
978 -         surface->D1(u,v,x,du,dv);\r
979 -\r
980 -      } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);\r
981 -\r
982 -      //    (*testout) << "FastProject count: " << count << endl;\r
983 -\r
984 -      if (count == 50) return false;\r
985 +      gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
986 +      if (cls->Perform(p2d) == TopAbs_OUT)
987 +      {
988 +        //cout << "Projection fails" << endl;
989 +        return false;
990 +      }
991  \r
992 -      ap = Point<3> (x.X(), x.Y(), x.Z());\r
993 +      p = proj->Value(p2d);
994 +      p2d.Coord(u, v);
995 +      ap = Point<3> (p.X(), p.Y(), p.Z());
996  \r
997        return true;\r
998     }\r
999 @@ -1038,9 +1095,9 @@
1000     {\r
1001        cout << "writing stl..."; cout.flush();\r
1002        StlAPI_Writer writer;\r
1003 -      writer.RelativeMode() = Standard_False;\r
1004 +      //writer.RelativeMode() = Standard_False;
1005  \r
1006 -      writer.SetDeflection(0.02);\r
1007 +      //writer.SetDeflection(0.02);
1008        writer.Write(shape,filename);\r
1009  \r
1010        cout << "done" << endl;\r
1011 @@ -1059,10 +1116,10 @@
1012        occgeo = new OCCGeometry;\r
1013  \r
1014        // Initiate a dummy XCAF Application to handle the IGES XCAF Document\r
1015 -      static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication();\r
1016 +      static Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
1017  \r
1018        // Create an XCAF Document to contain the IGES file itself\r
1019 -      Handle_TDocStd_Document iges_doc;\r
1020 +      Handle(TDocStd_Document) iges_doc;
1021  \r
1022        // Check if a IGES File is already open under this handle, if so, close it to prevent\r
1023        // Segmentation Faults when trying to create a new document\r
1024 @@ -1089,8 +1146,8 @@
1025        reader.Transfer(iges_doc);\r
1026  \r
1027        // Read in the shape(s) and the colours present in the IGES File\r
1028 -      Handle_XCAFDoc_ShapeTool iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main());\r
1029 -      Handle_XCAFDoc_ColorTool iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main());\r
1030 +      Handle(XCAFDoc_ShapeTool) iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main());
1031 +      Handle(XCAFDoc_ColorTool) iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main());
1032  \r
1033        TDF_LabelSequence iges_shapes;\r
1034        iges_shape_contents->GetShapes(iges_shapes);\r
1035 @@ -1137,10 +1194,10 @@
1036        occgeo = new OCCGeometry;\r
1037  \r
1038        // Initiate a dummy XCAF Application to handle the STEP XCAF Document\r
1039 -      static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication();\r
1040 +      static Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
1041  \r
1042        // Create an XCAF Document to contain the STEP file itself\r
1043 -      Handle_TDocStd_Document step_doc;\r
1044 +      Handle(TDocStd_Document) step_doc;
1045  \r
1046        // Check if a STEP File is already open under this handle, if so, close it to prevent\r
1047        // Segmentation Faults when trying to create a new document\r
1048 @@ -1167,8 +1224,8 @@
1049        reader.Transfer(step_doc);\r
1050  \r
1051        // Read in the shape(s) and the colours present in the STEP File\r
1052 -      Handle_XCAFDoc_ShapeTool step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main());\r
1053 -      Handle_XCAFDoc_ColorTool step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main());\r
1054 +      Handle(XCAFDoc_ShapeTool) step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main());
1055 +      Handle(XCAFDoc_ColorTool) step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main());
1056  \r
1057        TDF_LabelSequence step_shapes;\r
1058        step_shape_contents->GetShapes(step_shapes);\r
1059 @@ -1221,7 +1278,7 @@
1060        // Fixed a bug in the OpenCascade XDE Colour handling when \r
1061        // opening BREP Files, since BREP Files have no colour data.\r
1062        // Hence, the face_colours Handle needs to be created as a NULL handle.\r
1063 -      occgeo->face_colours = Handle_XCAFDoc_ColorTool();\r
1064 +      occgeo->face_colours = Handle(XCAFDoc_ColorTool)();
1065        occgeo->face_colours.Nullify();\r
1066        occgeo->changed = 1;\r
1067        occgeo->BuildFMap();\r
1068 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occgeom.hpp netgen-5.3.1_new/libsrc/occ/occgeom.hpp
1069 --- netgen-5.3.1_orig/libsrc/occ/occgeom.hpp    2014-08-29 13:54:03.000000000 +0400
1070 +++ netgen-5.3.1_new/libsrc/occ/occgeom.hpp     2016-09-29 14:44:01.996464598 +0300
1071 @@ -15,8 +15,8 @@
1072  #include "Geom_Curve.hxx"\r
1073  #include "Geom2d_Curve.hxx"\r
1074  #include "Geom_Surface.hxx"\r
1075 -#include "GeomAPI_ProjectPointOnSurf.hxx"\r
1076 -#include "GeomAPI_ProjectPointOnCurve.hxx"\r
1077 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
1078 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
1079  #include "BRepTools.hxx"\r
1080  #include "TopExp.hxx"\r
1081  #include "BRepBuilderAPI_MakeVertex.hxx"\r
1082 @@ -42,8 +42,8 @@
1083  #include "Geom_Curve.hxx"\r
1084  #include "Geom2d_Curve.hxx"\r
1085  #include "Geom_Surface.hxx"\r
1086 -#include "GeomAPI_ProjectPointOnSurf.hxx"\r
1087 -#include "GeomAPI_ProjectPointOnCurve.hxx"\r
1088 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
1089 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
1090  #include "TopoDS_Wire.hxx"\r
1091  #include "BRepTools_WireExplorer.hxx"\r
1092  #include "BRepTools.hxx"\r
1093 @@ -68,18 +68,26 @@
1094  #include "IGESToBRep_Reader.hxx"\r
1095  #include "Interface_Static.hxx"\r
1096  #include "GeomAPI_ExtremaCurveCurve.hxx"\r
1097 -#include "Standard_ErrorHandler.hxx"\r
1098 +//#include "Standard_ErrorHandler.hxx"
1099  #include "Standard_Failure.hxx"\r
1100  #include "ShapeUpgrade_ShellSewing.hxx"\r
1101  #include "ShapeFix_Shape.hxx"\r
1102  #include "ShapeFix_Wireframe.hxx"\r
1103 +#include <Standard_Version.hxx>
1104 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) <= 0x060702
1105 +// porting to OCCT6.7.3
1106  #include "BRepMesh.hxx"\r
1107 +#endif
1108  #include "BRepMesh_IncrementalMesh.hxx"\r
1109  #include "BRepBndLib.hxx"\r
1110  #include "Bnd_Box.hxx"\r
1111  #include "ShapeAnalysis.hxx"\r
1112  #include "ShapeBuild_ReShape.hxx"\r
1113  \r
1114 +// -- Optimization: to use cached projector and classifier
1115 +#include <NCollection_DataMap.hxx>
1116 +class ShapeAnalysis_Surface;
1117 +class BRepTopAdaptor_FClass2d;
1118  \r
1119  // Philippose - 29/01/2009\r
1120  // OpenCascade XDE Support\r
1121 @@ -192,6 +200,9 @@
1122     class OCCGeometry : public NetgenGeometry\r
1123     {\r
1124        Point<3> center;\r
1125 +      // -- Optimization: to use cached projector and classifier
1126 +      mutable NCollection_DataMap<int,Handle(ShapeAnalysis_Surface)> fprjmap;
1127 +      mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
1128  \r
1129     public:\r
1130        TopoDS_Shape shape;\r
1131 @@ -203,7 +214,7 @@
1132        // OpenCascade XDE Support\r
1133        // XCAF Handle to make the face colours available to the rest of\r
1134        // the system\r
1135 -      Handle_XCAFDoc_ColorTool face_colours;\r
1136 +      Handle(XCAFDoc_ColorTool) face_colours;
1137  \r
1138       mutable int changed;\r
1139        Array<int> facemeshstatus;\r
1140 @@ -247,6 +258,8 @@
1141       virtual void Save (string filename) const;\r
1142  \r
1143  \r
1144 +      ~OCCGeometry();      // -- to free cached projector and classifier
1145 +
1146        void BuildFMap();\r
1147  \r
1148        Box<3> GetBoundingBox()\r
1149 @@ -266,9 +279,14 @@
1150        Point<3> Center()\r
1151        {  return center;}\r
1152  \r
1153 -      void Project (int surfi, Point<3> & p) const;\r
1154 +      // void Project (int surfi, Point<3> & p) const; -- optimization
1155 +      bool Project (int surfi, Point<3> & p, double& u, double& v) const;
1156        bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;\r
1157  \r
1158 +      // -- Optimization: to use cached projector and classifier
1159 +      void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
1160 +                        BRepTopAdaptor_FClass2d*& cls) const;
1161 +
1162        OCCSurface GetSurface (int surfi)\r
1163        {\r
1164           cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;\r
1165 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp netgen-5.3.1_new/libsrc/occ/occmeshsurf.cpp
1166 --- netgen-5.3.1_orig/libsrc/occ/occmeshsurf.cpp        2014-08-29 13:54:03.000000000 +0400
1167 +++ netgen-5.3.1_new/libsrc/occ/occmeshsurf.cpp 2016-09-29 14:08:00.045144560 +0300
1168 @@ -6,6 +6,7 @@
1169  #include <meshing.hpp>
1170  #include <GeomLProp_SLProps.hxx>
1171  #include <ShapeAnalysis_Surface.hxx>
1172 +#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
1173  
1174  
1175  namespace netgen
1176 @@ -96,13 +97,16 @@
1177  
1178         n.Normalize();
1179        }
1180 -    else
1181 +    else if ( lprop.IsNormalDefined() )
1182        {
1183         n(0)=lprop.Normal().X();
1184         n(1)=lprop.Normal().Y();
1185         n(2)=lprop.Normal().Z();
1186        }
1187 -
1188 +    else
1189 +      {
1190 +        n = 0;
1191 +      }
1192      if(glob_testout)
1193        {
1194         (*testout) << "u " << geominfo.u << " v " << geominfo.v 
1195 @@ -434,23 +435,33 @@
1196  
1197    void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
1198    {
1199 -    geometry.Project (surfind, p);
1200 +    // geometry.Project (surfind, p); -- signature of Project() changed for optimization
1201 +    double u, v;
1202 +    geometry.Project (surfind, p, u, v);
1203    }
1204  
1205  
1206    int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
1207    {
1208 -    double u = gi.u;
1209 -    double v = gi.v;
1210 +    //double u = gi.u;
1211 +    //double v = gi.v;
1212  
1213      Point<3> hp = p;
1214 -    if (geometry.FastProject (surfind, hp, u, v))
1215 -      {
1216 +    // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
1217 +    // if (geometry.FastProject (surfind, hp, u, v))
1218 +    //   {
1219 +    //    p = hp;
1220 +    //    return 1;
1221 +    //   }
1222 +    // ProjectPoint (surfind, p); 
1223 +    // return CalcPointGeomInfo (surfind, gi, p); 
1224 +    bool ok;
1225 +    if (gi.trignum > 0)
1226 +      ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
1227 +    else
1228 +      ok = geometry.Project (surfind, hp, gi.u, gi.v);
1229         p = hp;
1230 -       return 1;
1231 -      }
1232 -    ProjectPoint (surfind, p); 
1233 -    return CalcPointGeomInfo (surfind, gi, p); 
1234 +    return ok;
1235    }
1236  
1237  
1238 @@ -680,7 +691,8 @@
1239         if (!geometry.FastProject (surfi, hnewp, u, v))
1240           {
1241           //  cout << "Fast projection to surface fails! Using OCC projection" << endl;
1242 -           geometry.Project (surfi, hnewp);
1243 +           // geometry.Project (surfi, hnewp); -- Project() changed for optimization
1244 +           geometry.Project (surfi, hnewp, u, v);
1245           }
1246  
1247         newgi.trignum = 1;
1248 @@ -689,7 +701,7 @@
1249        }
1250    
1251      newp = hnewp;
1252 -  }
1253 +  }//; -- to compile with -Wall -pedantic
1254  
1255  
1256    void OCCRefinementSurfaces :: 
1257 @@ -708,14 +720,18 @@
1258      hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
1259      newp = hnewp;
1260      newgi = ap1;
1261 -  };
1262 +  }//; -- to compile with -Wall -pedantic
1263  
1264  
1265    void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const
1266    {
1267      if (surfi > 0)
1268 -      geometry.Project (surfi, p);
1269 -  };
1270 +      //geometry.Project (surfi, p);
1271 +    {
1272 +      double u, v;
1273 +      geometry.Project (surfi, p, u, v);
1274 +    }
1275 +  }//; -- to compile with -Wall -pedantic
1276  
1277    void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const
1278    {
1279 @@ -723,9 +739,10 @@
1280        if (!geometry.FastProject (surfi, p, gi.u, gi.v))
1281         {
1282           cout << "Fast projection to surface fails! Using OCC projection" << endl;
1283 -         geometry.Project (surfi, p);
1284 +          double u, v;
1285 +         geometry.Project (surfi, p, u, v);
1286 +       }
1287         }
1288 -  };
1289  
1290  
1291  
1292 diff -NaurwB netgen-5.3.1_orig/libsrc/occ/utilities.h netgen-5.3.1_new/libsrc/occ/utilities.h
1293 --- netgen-5.3.1_orig/libsrc/occ/utilities.h    2014-08-29 13:54:03.000000000 +0400
1294 +++ netgen-5.3.1_new/libsrc/occ/utilities.h     2016-09-29 14:04:51.504148314 +0300
1295 @@ -33,6 +33,7 @@
1296  
1297  #include <string>
1298  #include <iostream>
1299 +#include <iomanip>
1300  #include <cstdlib>
1301  // #include "SALOME_Log.hxx"
1302  
1303 diff -NaurwB netgen-5.3.1_orig/nglib/nglib.h netgen-5.3.1_new/nglib/nglib.h
1304 --- netgen-5.3.1_orig/nglib/nglib.h     2014-08-29 13:54:00.000000000 +0400
1305 +++ netgen-5.3.1_new/nglib/nglib.h      2016-09-29 14:04:51.504148314 +0300
1306 @@ -24,7 +24,7 @@
1307  // Philippose - 14.02.2009\r
1308  // Modifications for creating a DLL in Windows\r
1309  #ifdef WIN32\r
1310 -   #ifdef NGLIB_EXPORTS || nglib_EXPORTS\r
1311 +   #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
1312        #define DLL_HEADER   __declspec(dllexport)\r
1313     #else\r
1314        #define DLL_HEADER   __declspec(dllimport)\r
1315 diff -Naur netgen-5.3.1_orig/libsrc/csg/Makefile.am netgen-5.3.1_new/libsrc/csg/Makefile.am
1316 --- netgen-5.3.1_orig/libsrc/csg/Makefile.am    2014-08-29 13:54:06.000000000 +0400
1317 +++ netgen-5.3.1_new/libsrc/csg/Makefile.am     2016-11-08 17:48:02.000000000 +0300
1318 @@ -8,7 +8,7 @@
1319  AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include  $(TCL_INCLUDES)
1320  METASOURCES = AUTO
1321  
1322 -lib_LTLIBRARIES = libcsg.la
1323 +noinst_LTLIBRARIES = libcsg.la
1324  
1325  
1326  libcsg_la_SOURCES = algprim.cpp brick.cpp   \
1327 @@ -17,12 +17,9 @@
1328  manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp \
1329  solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp
1330  
1331 -libcsg_la_LIBADD =  $(top_builddir)/libsrc/meshing/libmesh.la
1332 -
1333 -
1334  
1335  if NGGUI
1336 -lib_LTLIBRARIES += libcsgvis.la 
1337 +lib_LTLIBRARIES = libcsgvis.la 
1338  
1339  libcsgvis_la_SOURCES = vscsg.cpp csgpkg.cpp
1340  libcsgvis_la_LIBADD = libcsg.la
1341 diff -Naur netgen-5.3.1_orig/libsrc/geom2d/Makefile.am netgen-5.3.1_new/libsrc/geom2d/Makefile.am
1342 --- netgen-5.3.1_orig/libsrc/geom2d/Makefile.am 2014-08-29 13:54:06.000000000 +0400
1343 +++ netgen-5.3.1_new/libsrc/geom2d/Makefile.am  2016-11-08 17:49:13.000000000 +0300
1344 @@ -4,16 +4,15 @@
1345  
1346  METASOURCES = AUTO
1347  
1348 -lib_LTLIBRARIES = libgeom2d.la 
1349 +noinst_LTLIBRARIES = libgeom2d.la 
1350  
1351  if NGGUI
1352 -lib_LTLIBRARIES += libgeom2dvis.la 
1353 +lib_LTLIBRARIES = libgeom2dvis.la 
1354  endif
1355  
1356  
1357  
1358  libgeom2d_la_SOURCES = genmesh2d.cpp geom2dmesh.cpp geometry2d.cpp
1359 -libgeom2d_la_LIBADD =  $(top_builddir)/libsrc/meshing/libmesh.la
1360  
1361  libgeom2dvis_la_SOURCES = geom2dpkg.cpp vsgeom2d.cpp
1362  libgeom2dvis_la_LIBADD = libgeom2d.la
1363 diff -Naur netgen-5.3.1_orig/libsrc/interface/Makefile.am netgen-5.3.1_new/libsrc/interface/Makefile.am
1364 --- netgen-5.3.1_orig/libsrc/interface/Makefile.am      2014-08-29 13:54:02.000000000 +0400
1365 +++ netgen-5.3.1_new/libsrc/interface/Makefile.am       2016-11-08 17:49:26.000000000 +0300
1366 @@ -2,14 +2,11 @@
1367  
1368  AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface  $(MPI_INCLUDES) $(TCL_INCLUDES) -DOPENGL
1369  METASOURCES = AUTO
1370 -lib_LTLIBRARIES = libinterface.la
1371 +noinst_LTLIBRARIES = libinterface.la
1372  libinterface_la_SOURCES = nginterface.cpp nginterface_v2.cpp \
1373         read_fnf_mesh.cpp readtetmesh.cpp readuser.cpp writeabaqus.cpp writediffpack.cpp \
1374         writedolfin.cpp writeelmer.cpp writefeap.cpp writefluent.cpp writegmsh.cpp writejcm.cpp \
1375         writepermas.cpp writetecplot.cpp writetet.cpp writetochnog.cpp writeuser.cpp \
1376         wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp 
1377  
1378 -
1379 -libinterface_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
1380 -
1381  # libinterface_la_LDFLAGS = -rdynamic
1382 diff -Naur netgen-5.3.1_orig/libsrc/meshing/Makefile.am netgen-5.3.1_new/libsrc/meshing/Makefile.am
1383 --- netgen-5.3.1_orig/libsrc/meshing/Makefile.am        2014-08-29 13:54:05.000000000 +0400
1384 +++ netgen-5.3.1_new/libsrc/meshing/Makefile.am 2016-11-08 17:48:44.000000000 +0300
1385 @@ -15,7 +15,7 @@
1386  
1387  METASOURCES = AUTO
1388  
1389 -lib_LTLIBRARIES = libmesh.la
1390 +noinst_LTLIBRARIES = libmesh.la
1391  
1392  libmesh_la_SOURCES = adfront2.cpp adfront3.cpp bisect.cpp boundarylayer.cpp \
1393         clusters.cpp curvedelems.cpp delaunay.cpp delaunay2d.cpp            \
1394 @@ -30,8 +30,5 @@
1395         topology.cpp triarls.cpp validate.cpp zrefine.cpp bcfunctions.cpp   \
1396         parallelmesh.cpp  paralleltop.cpp  paralleltop.hpp basegeom.cpp 
1397  
1398 -libmesh_la_LIBADD =  $(top_builddir)/libsrc/linalg/libla.la \
1399 -       $(top_builddir)/libsrc/gprim/libgprim.la \
1400 -       $(top_builddir)/libsrc/general/libgen.la \
1401 -       -lz
1402 +libmesh_la_LIBADD = -lz
1403  
1404 diff -Naur netgen-5.3.1_orig/libsrc/occ/Makefile.am netgen-5.3.1_new/libsrc/occ/Makefile.am
1405 --- netgen-5.3.1_orig/libsrc/occ/Makefile.am    2014-08-29 13:54:03.000000000 +0400
1406 +++ netgen-5.3.1_new/libsrc/occ/Makefile.am     2016-11-08 17:30:53.000000000 +0300
1407 @@ -14,10 +14,10 @@
1408  
1409  METASOURCES = AUTO
1410  
1411 -lib_LTLIBRARIES = libocc.la
1412 +noinst_LTLIBRARIES = libocc.la
1413  
1414  if NGGUI
1415 -lib_LTLIBRARIES += liboccvis.la 
1416 +lib_LTLIBRARIES = liboccvis.la 
1417  endif
1418  
1419  
1420 diff -Naur netgen-5.3.1_orig/libsrc/stlgeom/Makefile.am netgen-5.3.1_new/libsrc/stlgeom/Makefile.am
1421 --- netgen-5.3.1_orig/libsrc/stlgeom/Makefile.am        2014-08-29 13:54:05.000000000 +0400
1422 +++ netgen-5.3.1_new/libsrc/stlgeom/Makefile.am 2016-11-08 18:28:09.000000000 +0300
1423 @@ -4,10 +4,10 @@
1424  AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(TCL_INCLUDES)
1425  METASOURCES = AUTO
1426  
1427 -lib_LTLIBRARIES = libstl.la 
1428 +noinst_LTLIBRARIES = libstl.la 
1429  
1430  if NGGUI
1431 -lib_LTLIBRARIES += libstlvis.la 
1432 +lib_LTLIBRARIES = libstlvis.la 
1433  endif
1434  
1435  libstl_la_SOURCES = meshstlsurface.cpp stlgeom.cpp stlgeomchart.cpp \
1436 @@ -16,6 +16,5 @@
1437  
1438  libstlvis_la_SOURCES = stlpkg.cpp vsstl.cpp
1439  libstlvis_la_LIBADD = libstl.la
1440 -libstl_la_LIBADD =  $(top_builddir)/libsrc/meshing/libmesh.la
1441  # libstlvis_la_LIBADD = libstl.la $(top_builddir)/libsrc/linalg/libla.la 
1442  
1443 diff -Naur netgen-5.3.1_orig/nglib/Makefile.am netgen-5.3.1_new/nglib/Makefile.am
1444 --- netgen-5.3.1_orig/nglib/Makefile.am 2014-08-29 13:54:00.000000000 +0400
1445 +++ netgen-5.3.1_new/nglib/Makefile.am  2016-11-08 19:01:17.000000000 +0300
1446 @@ -14,6 +14,9 @@
1447         $(top_builddir)/libsrc/stlgeom/libstl.la \
1448         $(top_builddir)/libsrc/occ/libocc.la \
1449         $(top_builddir)/libsrc/meshing/libmesh.la \
1450 +       $(top_builddir)/libsrc/general/libgen.la \
1451 +       $(top_builddir)/libsrc/gprim/libgprim.la \
1452 +       $(top_builddir)/libsrc/linalg/libla.la
1453         $(OCCLIBS) $(MPI_LIBS)
1454  
1455  libnglib_la_LDFLAGS = -avoid-version