Salome HOME
Synchronize adm files
[plugins/netgenplugin.git] / src / NETGEN / netgen49ForSalome.patch
1 diff -Naur netgen-4.9.13_orig/libsrc/meshing/meshtype.cpp netgen-4.9.13_new/libsrc/meshing/meshtype.cpp
2 --- netgen-4.9.13_orig/libsrc/meshing/meshtype.cpp      2009-09-13 14:28:38.000000000 +0400
3 +++ netgen-4.9.13_new/libsrc/meshing/meshtype.cpp       2014-07-22 13:01:28.000000000 +0400
4 @@ -1,4 +1,5 @@
5  #include <mystdlib.h>
6 +#include <float.h> // to get DBL_MIN defined
7  
8  #include "meshing.hpp"  
9  
10 @@ -650,7 +651,8 @@
11  
12          double det = trans.Det();
13  
14 -        if (det <= 0)
15 +        // if (det <= 0)
16 +        if (det <= DBL_MIN) // avoid FPE
17            err += 1e12;
18          else
19            err += frob * frob / det;
20 @@ -706,7 +708,8 @@
21  
22              double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
23  
24 -            if (det <= 0)
25 +            // if (det <= 0)
26 +            if (det <= DBL_MIN)  // avoid FPE
27                {
28                  dd = 0;
29                  return 1e12;
30 @@ -790,7 +793,8 @@
31            = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0)
32            + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0);
33  
34 -        if (det <= 0)
35 +        // if (det <= 0)
36 +        if (det <= DBL_MIN) // avoid FPE
37            err += 1e12;
38          else
39            {
40 @@ -840,7 +844,8 @@
41          frob /= 2;
42  
43          double det = trans.Det();
44 -        if (det <= 0)
45 +        //if (det <= 0)
46 +        if (det <= DBL_MIN) // avoid FPE
47            err += 1e12;
48          else
49            err += frob * frob / det;
50 @@ -1857,7 +1862,8 @@
51        case PYRAMID:
52          {
53            double noz = 1-p(2);
54 -          if (noz == 0.0) noz = 1e-10;
55 +          //if (noz == 0.0) noz = 1e-10;
56 +          if (noz <= DBL_MIN) noz = 1e-10; // avoid FPE
57  
58            double xi  = p(0) / noz;
59            double eta = p(1) / noz;
60 @@ -2035,7 +2041,8 @@
61  
62          double det = -trans.Det();
63        
64 -        if (det <= 0)
65 +        //if (det <= 0)
66 +        if (det <= DBL_MIN) // avoid FPE
67            err += 1e12;
68          else
69            err += frob * frob * frob / det;
70 @@ -2107,7 +2114,8 @@
71          ddet *= -1;
72  
73        
74 -        if (det <= 0)
75 +        //if (det <= 0)
76 +        if (det <= DBL_MIN) // avoid FPE
77            err += 1e12;
78          else
79            {
80 @@ -2189,7 +2197,7 @@
81        
82          det *= -1;
83        
84 -        if (det <= 0)
85 +        if (det <= DBL_MIN)
86            err += 1e12;
87          else
88            {
89 @@ -2522,10 +2530,10 @@
90  
91    MeshingParameters :: MeshingParameters ()
92    {
93 -    optimize3d = "cmdmustm";
94 +    optimize3d = (char*)"cmdmustm"; // optimize3d = "cmdmustm";
95      //optimize3d = "cmdmstm";
96      optsteps3d = 3;
97 -    optimize2d = "smsmsmSmSmSm";
98 +    optimize2d = (char*)"smsmsmSmSmSm"; // optimize2d = "smsmsmSmSmSm";
99      optsteps2d = 3;
100      opterrpow = 2;
101      blockfill = 1;
102 diff -Naur netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp netgen-4.9.13_new/libsrc/meshing/meshtype.hpp
103 --- netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp      2009-11-09 13:50:43.000000000 +0300
104 +++ netgen-4.9.13_new/libsrc/meshing/meshtype.hpp       2014-07-22 13:01:28.000000000 +0400
105 @@ -12,6 +12,7 @@
106      Classes for NETGEN
107  */
108  
109 +class Mesh; // added due to compilation errors on some platforms
110  
111  enum ELEMENT_TYPE { 
112    SEGMENT = 1, SEGMENT3 = 2,
113 diff -Naur netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp
114 --- netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp    2009-11-09 13:47:09.000000000 +0300
115 +++ netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp     2014-07-22 13:01:28.000000000 +0400
116 @@ -302,7 +302,8 @@
117      vgrad = 0;
118      badness = 0;
119  
120 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
121 +    //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
122 +    n = normal;
123      pp1 = sp1 + x(0) * t1 + x(1) * t2;
124  
125      //  meshthis -> ProjectPoint (surfi, pp1);
126 @@ -360,7 +361,8 @@
127      vgrad = 0;
128      badness = 0;
129  
130 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
131 +    //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
132 +    n = normal;
133  
134      pp1 = sp1 + x(0) * t1 + x(1) * t2;
135  
136 @@ -514,7 +516,8 @@
137      vgrad = 0;
138      badness = 0;
139  
140 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
141 +    //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
142 +    n = normal;
143  
144      pp1 = sp1 + x(0) * t1 + x(1) * t2;
145  
146 @@ -586,7 +589,8 @@
147      vgrad = 0;
148      badness = 0;
149  
150 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
151 +    //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
152 +    n = normal;
153  
154      // pp1 = sp1;
155      //    pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
156 @@ -973,7 +977,7 @@
157                 {
158                   mesh[pi] = Point<3> (origp);
159                 }
160 -           
161 +             break; // exit as <fact> is not used anymore
162             }
163         }
164  
165 diff -Naur netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp netgen-4.9.13_new/libsrc/occ/occconstruction.cpp
166 --- netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp   2009-08-24 06:32:47.000000000 +0400
167 +++ netgen-4.9.13_new/libsrc/occ/occconstruction.cpp    2014-07-22 13:01:28.000000000 +0400
168 @@ -28,7 +28,7 @@
169  #include <BRepAlgoAPI_Common.hxx>
170  #include <BRepAlgoAPI_Fuse.hxx>
171  #include <BRepAlgoAPI_Section.hxx>
172 -#include <BRepOffsetAPI_Sewing.hxx>
173 +//#include <BRepOffsetAPI_Sewing.hxx>
174  //#include <BRepAlgo_Sewing.hxx>
175  #include <BRepOffsetAPI_MakeOffsetShape.hxx>
176  #include <ShapeFix_Shape.hxx>
177 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp
178 --- netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp        2010-03-16 09:30:07.000000000 +0300
179 +++ netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp 2014-07-22 13:01:28.000000000 +0400
180 @@ -15,6 +15,8 @@
181  
182  #define DIVIDEEDGESECTIONS 1000
183  #define IGNORECURVELENGTH 1e-4
184 +// a small value used to avoid FPE
185 +#define VSMALL 1e-10
186  
187  
188     bool merge_solids = 1;
189 @@ -26,7 +28,8 @@
190        double nq = n*q;
191  
192        Point<3> p = p0 + 0.5*n;
193 -      double lambda = (p-l.p0)*n / nq;
194 +      // double lambda = (p-l.p0)*n / nq;  -- avoid FPE
195 +      double lambda = (fabs(nq) > 1e-10) ? (p-l.p0)*n / nq : -1;
196  
197        if (lambda >= 0 && lambda <= 1)
198        {
199 @@ -54,6 +57,8 @@
200  
201  
202  
203 +   
204 +   static // useless out of this file
205     double ComputeH (double kappa)
206     {
207        double hret;
208 @@ -62,7 +67,8 @@
209        if (mparam.maxh * kappa < 1)
210           hret = mparam.maxh;
211        else
212 -         hret = 1 / kappa;
213 +        // hret = 1 / kappa; -- avoid FPE
214 +        hret = 1 / (kappa + VSMALL);
215  
216        if (mparam.maxh < hret)
217           hret = mparam.maxh;
218 @@ -71,8 +77,7 @@
219     }
220  
221  
222 -
223 -
224 +   static // useless out of this file
225     void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
226                             BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
227     {
228 @@ -168,8 +173,8 @@
229           if(h < 1e-4*maxside)
230              return;
231  
232 -
233 -         if (h > 30) return;
234 +         // commented to restrict H on a large sphere for example
235 +         //if (h > 30) return;
236        }
237  
238        if (h < maxside && depth < 10)
239 @@ -228,6 +233,7 @@
240  
241  
242  
243 +   static // useless out of this file
244     void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
245                      Array<double> & params, Mesh & mesh)
246     {
247 @@ -247,8 +253,8 @@
248        hvalue[0] = 0;
249        pnt = c->Value(s0);
250  
251 -      double olddist = 0;
252 -      double dist = 0;
253 +      //double olddist = 0; -- useless variables
254 +      //double dist = 0;
255  
256        int tmpVal = (int)(DIVIDEEDGESECTIONS);
257  
258 @@ -256,15 +262,19 @@
259        {
260           oldpnt = pnt;
261           pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
262 +         // -- no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
263           hvalue[i] = hvalue[i-1] +
264 -            1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
265 -            pnt.Distance(oldpnt);
266 +         //   1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
267 +         //   pnt.Distance(oldpnt);
268 +           min( 1.0,
269 +                1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
270 +                pnt.Distance(oldpnt));
271  
272           //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
273           //       <<  " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
274  
275 -         olddist = dist;
276 -         dist = pnt.Distance(oldpnt);
277 +         //olddist = dist; -- useless variables
278 +         //dist = pnt.Distance(oldpnt);
279        }
280  
281        //  nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
282 @@ -279,7 +289,10 @@
283        {
284           if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
285           {
286 -            params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
287 +            // -- for nsubedges comparable to DIVIDEEDGESECTIONS
288 +            //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
289 +            double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
290 +            params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
291              pnt = c->Value(params[i]);
292              ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
293              i++;
294 @@ -323,6 +336,9 @@
295        (*testout) << "nedges = " << nedges << endl;
296  
297        double eps = 1e-6 * geom.GetBoundingBox().Diam();
298 +      const double eps2 = eps * eps; // -- small optimization
299 +
300 +      int first_vp = mesh.GetNP()+1; // -- to support SALOME sub-meshes
301  
302        for (int i = 1; i <= nvertices; i++)
303        {
304 @@ -332,7 +348,8 @@
305           bool exists = 0;
306           if (merge_solids)
307              for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
308 -               if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
309 +               //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)              
310 +               if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
311                 {
312                    exists = 1;
313                    break;
314 @@ -362,6 +379,7 @@
315           {
316              TopoDS_Face face = TopoDS::Face(exp1.Current());
317              int facenr = geom.fmap.FindIndex(face);
318 +            if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
319  
320              if (face2solid[0][facenr-1] == 0)
321                 face2solid[0][facenr-1] = solidnr;
322 @@ -381,6 +399,7 @@
323        int facenr = 0;
324        int edgenr = 0;
325  
326 +      edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
327  
328        (*testout) << "faces = " << geom.fmap.Extent() << endl;
329        int curr = 0;
330 @@ -442,6 +461,7 @@
331                    //(*testout) << "ignoring degenerated edge" << endl;
332                    continue;
333                 }
334 +               if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
335  
336                 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
337                    geom.vmap.FindIndex(TopExp::LastVertex (edge)))
338 @@ -474,20 +494,104 @@
339  
340                 if (!merge_solids)
341                 {
342 -                  pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
343 -                  pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
344 +                 //pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
345 +                 //pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
346 +                 MeshPoint dfltP ( Point<3> ( 0, 0, 0 ) );
347 +                 int *ipp[] = { &pnums[0], &pnums[pnums.Size()-1] };
348 +                 TopoDS_Iterator vIt( edge, false );
349 +                 TopoDS_Vertex v[2];
350 +                 v[0] = TopoDS::Vertex( vIt.Value() ); vIt.Next();
351 +                 v[1] = TopoDS::Vertex( vIt.Value() );
352 +                 if ( v[0].Orientation() == TopAbs_REVERSED )
353 +                   std::swap( v[0], v[1] );
354 +                 for ( int i = 0; i < 2; ++i)
355 +                 {
356 +                   int &ip = *ipp[i];
357 +                   ip = geom.vmap.FindIndex ( v[i] );
358 +                   if ( ip == 0 || ip > nvertices )
359 +                   {
360 +                     int iv = ip;
361 +                     if ( ip == 0 )
362 +                       ip = iv = geom.vmap.Add( v[i] );
363 +                     gp_Pnt pnt = BRep_Tool::Pnt( v[i] );
364 +                     MeshPoint mp( Point<3>(pnt.X(), pnt.Y(), pnt.Z()) );
365 +                     for (PointIndex pi = 1; pi < first_vp; pi++)
366 +                       if ( Dist2 (mesh.Point(pi), Point<3>(mp)) < 1e-100 )
367 +                       {
368 +                         ip = pi;
369 +                         if ( mesh.Point(ip).GetLayer() != dfltP.GetLayer() && mesh.Point(ip).GetLayer() != iv )
370 +                           continue;
371 +                         if ( mesh.Point(ip).GetLayer() == dfltP.GetLayer())
372 +                           mesh.Point(ip) = MeshPoint( mesh.Point(ip), iv );
373 +                         break;
374 +                       }
375 +                   }
376 +                   else
377 +                   {
378 +                     ip += first_vp - 1;
379 +                   }
380 +                 }
381                 }
382                 else
383                 {
384 -                  Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
385 -                  Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
386 +                 TopoDS_Iterator vIt( edge, false );
387 +                 TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
388 +                 TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
389 +                 if ( v1.Orientation() == TopAbs_REVERSED )
390 +                   std::swap( v1, v2 );
391 +                 const bool isClosedEdge = v1.IsSame( v2 );
392 +                 
393 +                  Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
394 +                  Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
395 +                  double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
396 +                  if ( isClosedEdge )
397 +                    tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
398  
399                    pnums[0] = -1;
400                    pnums.Last() = -1;
401                    for (PointIndex pi = 1; pi < first_ep; pi++)
402                    {
403 -                     if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
404 -                     if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
405 +                    if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
406 +                    if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
407 +                  }
408 +                  if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
409 +                      ( !isClosedEdge && pnums[0] == pnums.Last() ))
410 +                    pnums[0] = pnums.Last() = -1;
411 +                  if ( pnums[0] == -1 || pnums.Last() == -1 )
412 +                  {
413 +                    // take into account a possible large gap between a vertex and an edge curve
414 +                    // end and a large vertex tolerance covering the whole edge
415 +                    if ( pnums[0] == -1 )
416 +                    {
417 +                      double tol = BRep_Tool::Tolerance( v1 );
418 +                      for (PointIndex pi = 1; pi < first_ep; pi++)
419 +                        if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
420 +                          pnums[0] = pi;
421 +
422 +                      if ( pnums[0] == -1 )
423 +                        pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
424 +                    }
425 +                    if ( isClosedEdge )
426 +                    {
427 +                      pnums.Last() = pnums[0];
428 +                    }
429 +                    else
430 +                    {
431 +                      if ( pnums.Last() == -1 )
432 +                      {
433 +                        double tol = BRep_Tool::Tolerance( v2 );
434 +                        for (PointIndex pi = 1; pi < first_ep; pi++)
435 +                          if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
436 +                            pnums.Last() = pi;
437 +
438 +                        if ( pnums.Last() == -1 )
439 +                          pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
440 +                      }
441 +
442 +                      if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
443 +                           Dist2( lp, mesh[PointIndex(pnums.Last())]))
444 +                      std::swap( pnums[0], pnums.Last() );
445 +                    }
446                    }
447                 }
448  
449 @@ -497,17 +601,20 @@
450                    bool exists = 0;
451                    int j;
452                    for (j = first_ep; j <= mesh.GetNP(); j++)
453 +                  {
454 +                     if (!merge_solids && mesh.Point(j).GetLayer() != geomedgenr ) continue; // to support SALOME fuse edges
455                       if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
456                       {
457                          exists = 1;
458                          break;
459                       }
460 +                  }
461  
462                       if (exists)
463                          pnums[i] = j;
464                       else
465                       {
466 -                        mesh.AddPoint (mp[i-1]);
467 +                        mesh.AddPoint (mp[i-1], geomedgenr); // to support SALOME fuse edges
468                          (*testout) << "add meshpoint " << mp[i-1] << endl;
469                          pnums[i] = mesh.GetNP();
470                       }
471 @@ -591,6 +698,8 @@
472        //               (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si
473        //                               << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl;
474        //       exit(10);
475 +      for (int j = 1; j <= mesh.GetNP(); j++) // to support SALOME fuse edges: set level to zero\r
476 +        mesh.Point(j) = MeshPoint( (Point<3>&) mesh.Point(j) );
477  
478        mesh.CalcSurfacesOfNode();
479        multithread.task = savetask;
480 @@ -633,7 +742,8 @@
481           }
482  
483           (*testout) << "mesh face " << k << endl;
484 -         multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
485 +         // multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE
486 +         multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
487           geom.facemeshstatus[k-1] = -1;
488  
489  
490 @@ -901,7 +1011,8 @@
491           //      if (k != 36) continue;
492  
493           //      (*testout) << "optimize face " << k << endl;
494 -         multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
495 +         //multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE
496 +         multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
497  
498           FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
499  
500 @@ -1456,3 +1567,4 @@
501  }
502  
503  #endif
504 +
505 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.cpp netgen-4.9.13_new/libsrc/occ/occgeom.cpp
506 --- netgen-4.9.13_orig/libsrc/occ/occgeom.cpp   2010-03-05 16:16:21.000000000 +0300
507 +++ netgen-4.9.13_new/libsrc/occ/occgeom.cpp    2014-07-22 13:01:28.000000000 +0400
508 @@ -8,6 +8,8 @@
509  #include "ShapeAnalysis_CheckSmallFace.hxx"
510  #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
511  #include "ShapeAnalysis_Surface.hxx"
512 +#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
513 +#include <TopAbs_State.hxx>
514  #include "BRepAlgoAPI_Fuse.hxx"
515  #include "BRepCheck_Analyzer.hxx"
516  #include "BRepLib.hxx"
517 @@ -16,10 +18,17 @@
518  #include "ShapeFix_FixSmallFace.hxx"
519  #include "Partition_Spliter.hxx"
520  
521 -
522  namespace netgen
523  {
524 -   void OCCGeometry :: PrintNrShapes ()
525 +  // free data used to optimize Project() and FastProject()
526 +  OCCGeometry::~OCCGeometry()
527 +  {
528 +    NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
529 +    for (; it.More(); it.Next())
530 +      delete it.Value();
531 +  }
532 +
533 +  void OCCGeometry :: PrintNrShapes ()
534     {
535        TopExp_Explorer e;
536        int count = 0;
537 @@ -951,25 +960,58 @@
538     }
539  
540  
541 +   // returns a projector and a classifier for the given surface
542 +   void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
543 +                                  BRepTopAdaptor_FClass2d*& cls) const
544 +   {
545 +     //MSV: organize caching projector in the map
546 +     if (fprjmap.IsBound(surfi))
547 +     {
548 +       proj = fprjmap.Find(surfi);
549 +       cls = fclsmap.Find(surfi);
550 +     }
551 +     else
552 +     {
553 +       const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
554 +       Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
555 +       proj = new ShapeAnalysis_Surface(aSurf);
556 +       fprjmap.Bind(surfi, proj);
557 +       cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
558 +       fclsmap.Bind(surfi, cls);
559 +     }
560 +   }
561  
562 -
563 -   void OCCGeometry :: Project (int surfi, Point<3> & p) const
564 +   // void OCCGeometry :: Project (int surfi, Point<3> & p) const
565 +   bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
566     {
567        static int cnt = 0;
568        if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
569  
570        gp_Pnt pnt(p(0), p(1), p(2));
571  
572 -      double u,v;
573 -      Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
574 -      Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
575 -      gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
576 -      suval.Coord( u, v);
577 -      pnt = thesurf->Value( u, v );
578 -
579 -
580 +      // -- Optimization: use cached projector and classifier
581 +      // double u,v;
582 +      // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
583 +      // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
584 +      // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
585 +      // suval.Coord( u, v);
586 +      // pnt = thesurf->Value( u, v );  
587 +
588 +      Handle(ShapeAnalysis_Surface) proj;
589 +      BRepTopAdaptor_FClass2d *cls;
590 +      GetFaceTools(surfi, proj, cls);
591 +  
592 +      gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
593 +      if (cls->Perform(p2d) == TopAbs_OUT)
594 +      {
595 +        return false;
596 +      }
597 +      pnt = proj->Value(p2d);
598 +      p2d.Coord(u, v);
599 +  
600        p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
601  
602 +      return true;
603     }
604  
605  
606 @@ -979,54 +1021,69 @@
607     {
608        gp_Pnt p(ap(0), ap(1), ap(2));
609  
610 -      Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
611 -
612 -      gp_Pnt x = surface->Value (u,v);
613 -
614 -      if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
615 -
616 -      gp_Vec du, dv;
617 -
618 -      surface->D1(u,v,x,du,dv);
619 -
620 -      int count = 0;
621 -
622 -      gp_Pnt xold;
623 -      gp_Vec n;
624 -      double det, lambda, mu;
625 -
626 -      do {
627 -         count++;
628 -
629 -         n = du^dv;
630 -
631 -         det = Det3 (n.X(), du.X(), dv.X(),
632 -            n.Y(), du.Y(), dv.Y(),
633 -            n.Z(), du.Z(), dv.Z());
634 -
635 -         if (det < 1e-15) return false;
636 -
637 -         lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
638 -            n.Y(), p.Y()-x.Y(), dv.Y(),
639 -            n.Z(), p.Z()-x.Z(), dv.Z())/det;
640 -
641 -         mu     = Det3 (n.X(), du.X(), p.X()-x.X(),
642 -            n.Y(), du.Y(), p.Y()-x.Y(),
643 -            n.Z(), du.Z(), p.Z()-x.Z())/det;
644 -
645 -         u += lambda;
646 -         v += mu;
647 -
648 -         xold = x;
649 -         surface->D1(u,v,x,du,dv);
650 -
651 -      } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
652 -
653 -      //    (*testout) << "FastProject count: " << count << endl;
654 -
655 -      if (count == 50) return false;
656 -
657 -      ap = Point<3> (x.X(), x.Y(), x.Z());
658 +      // -- Optimization: use cached projector and classifier
659 +      // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
660 +      // 
661 +      // gp_Pnt x = surface->Value (u,v);
662 +      // 
663 +      // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
664 +      // 
665 +      // gp_Vec du, dv;
666 +      // 
667 +      // surface->D1(u,v,x,du,dv);
668 +      // 
669 +      // int count = 0;
670 +      // 
671 +      // gp_Pnt xold;
672 +      // gp_Vec n;
673 +      // double det, lambda, mu;
674 +      // 
675 +      // do {
676 +      //    count++;
677 +      // 
678 +      //    n = du^dv;
679 +      // 
680 +      //    det = Det3 (n.X(), du.X(), dv.X(),
681 +      //       n.Y(), du.Y(), dv.Y(),
682 +      //       n.Z(), du.Z(), dv.Z());
683 +      // 
684 +      //    if (det < 1e-15) return false;
685 +      // 
686 +      //    lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
687 +      //       n.Y(), p.Y()-x.Y(), dv.Y(),
688 +      //       n.Z(), p.Z()-x.Z(), dv.Z())/det;
689 +      // 
690 +      //    mu     = Det3 (n.X(), du.X(), p.X()-x.X(),
691 +      //       n.Y(), du.Y(), p.Y()-x.Y(),
692 +      //       n.Z(), du.Z(), p.Z()-x.Z())/det;
693 +      // 
694 +      //    u += lambda;
695 +      //    v += mu;
696 +      // 
697 +      //    xold = x;
698 +      //    surface->D1(u,v,x,du,dv);
699 +      // 
700 +      // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
701 +      // 
702 +      // //    (*testout) << "FastProject count: " << count << endl;
703 +      // 
704 +      // if (count == 50) return false;
705 +      // 
706 +      // ap = Point<3> (x.X(), x.Y(), x.Z());
707 +      Handle(ShapeAnalysis_Surface) proj;
708 +      BRepTopAdaptor_FClass2d *cls;
709 +      GetFaceTools(surfi, proj, cls);
710 +    
711 +      gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
712 +      if (cls->Perform(p2d) == TopAbs_OUT)
713 +      {
714 +        //cout << "Projection fails" << endl;
715 +        return false;
716 +      }
717 +    
718 +      p = proj->Value(p2d);
719 +      p2d.Coord(u, v);
720 +      ap = Point<3> (p.X(), p.Y(), p.Z());
721  
722        return true;
723     }
724 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.hpp netgen-4.9.13_new/libsrc/occ/occgeom.hpp
725 --- netgen-4.9.13_orig/libsrc/occ/occgeom.hpp   2010-01-14 19:56:19.000000000 +0300
726 +++ netgen-4.9.13_new/libsrc/occ/occgeom.hpp    2014-07-22 13:09:03.000000000 +0400
727 @@ -15,8 +15,8 @@
728  #include "Geom_Curve.hxx"
729  #include "Geom2d_Curve.hxx"
730  #include "Geom_Surface.hxx"
731 -#include "GeomAPI_ProjectPointOnSurf.hxx"
732 -#include "GeomAPI_ProjectPointOnCurve.hxx"
733 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
734 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
735  #include "BRepTools.hxx"
736  #include "TopExp.hxx"
737  #include "BRepBuilderAPI_MakeVertex.hxx"
738 @@ -42,8 +42,8 @@
739  #include "Geom_Curve.hxx"
740  #include "Geom2d_Curve.hxx"
741  #include "Geom_Surface.hxx"
742 -#include "GeomAPI_ProjectPointOnSurf.hxx"
743 -#include "GeomAPI_ProjectPointOnCurve.hxx"
744 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
745 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
746  #include "TopoDS_Wire.hxx"
747  #include "BRepTools_WireExplorer.hxx"
748  #include "BRepTools.hxx"
749 @@ -68,18 +68,26 @@
750  #include "IGESToBRep_Reader.hxx"
751  #include "Interface_Static.hxx"
752  #include "GeomAPI_ExtremaCurveCurve.hxx"
753 -#include "Standard_ErrorHandler.hxx"
754 +//#include "Standard_ErrorHandler.hxx"
755  #include "Standard_Failure.hxx"
756  #include "ShapeUpgrade_ShellSewing.hxx"
757  #include "ShapeFix_Shape.hxx"
758  #include "ShapeFix_Wireframe.hxx"
759 +#include <Standard_Version.hxx>
760 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) <= 0x060702
761 +// porting to OCCT6.7.3
762  #include "BRepMesh.hxx"
763 +#endif
764  #include "BRepMesh_IncrementalMesh.hxx"
765  #include "BRepBndLib.hxx"
766  #include "Bnd_Box.hxx"
767  #include "ShapeAnalysis.hxx"
768  #include "ShapeBuild_ReShape.hxx"
769  
770 +// -- Optimization: to use cached projector and classifier
771 +#include <NCollection_DataMap.hxx>
772 +class Handle_ShapeAnalysis_Surface;
773 +class BRepTopAdaptor_FClass2d;
774  
775  // Philippose - 29/01/2009
776  // OpenCascade XDE Support
777 @@ -190,6 +198,9 @@
778     class OCCGeometry : public NetgenGeometry
779     {
780        Point<3> center;
781 +      // -- Optimization: to use cached projector and classifier
782 +      mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
783 +      mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
784  
785     public:
786        TopoDS_Shape shape;
787 @@ -241,6 +252,8 @@
788           vmap.Clear();
789        }
790  
791 +      ~OCCGeometry();      // -- to free cached projector and classifier
792 +
793        void BuildFMap();
794  
795        Box<3> GetBoundingBox()
796 @@ -260,9 +273,14 @@
797        Point<3> Center()
798        {  return center;}
799  
800 -      void Project (int surfi, Point<3> & p) const;
801 +      // void Project (int surfi, Point<3> & p) const; -- optimization
802 +      bool Project (int surfi, Point<3> & p, double& u, double& v) const;
803        bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
804  
805 +      // -- Optimization: to use cached projector and classifier
806 +      void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
807 +                        BRepTopAdaptor_FClass2d*& cls) const;
808 +
809        OCCSurface GetSurface (int surfi)
810        {
811           cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
812 diff -Naur netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp
813 --- netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp       2009-08-24 06:32:47.000000000 +0400
814 +++ netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp        2014-07-22 13:01:28.000000000 +0400
815 @@ -6,6 +6,7 @@
816  #include <meshing.hpp>
817  #include <GeomLProp_SLProps.hxx>
818  #include <ShapeAnalysis_Surface.hxx>
819 +#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
820  
821  
822  namespace netgen
823 @@ -434,23 +435,33 @@
824  
825    void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
826    {
827 -    geometry.Project (surfind, p);
828 +    // geometry.Project (surfind, p); -- signature of Project() changed for optimization
829 +    double u, v;
830 +    geometry.Project (surfind, p, u, v);
831    }
832  
833  
834    int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
835    {
836 -    double u = gi.u;
837 -    double v = gi.v;
838 +    //double u = gi.u;
839 +    //double v = gi.v;
840  
841      Point<3> hp = p;
842 -    if (geometry.FastProject (surfind, hp, u, v))
843 -      {
844 -       p = hp;
845 -       return 1;
846 -      }
847 -    ProjectPoint (surfind, p); 
848 -    return CalcPointGeomInfo (surfind, gi, p); 
849 +    // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
850 +    // if (geometry.FastProject (surfind, hp, u, v))
851 +    //   {
852 +    //    p = hp;
853 +    //    return 1;
854 +    //   }
855 +    // ProjectPoint (surfind, p); 
856 +    // return CalcPointGeomInfo (surfind, gi, p); 
857 +    bool ok;
858 +    if (gi.trignum > 0)
859 +      ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
860 +    else
861 +      ok = geometry.Project (surfind, hp, gi.u, gi.v);
862 +    p = hp;
863 +    return ok;
864    }
865  
866  
867 @@ -680,7 +691,8 @@
868         if (!geometry.FastProject (surfi, hnewp, u, v))
869           {
870           //  cout << "Fast projection to surface fails! Using OCC projection" << endl;
871 -           geometry.Project (surfi, hnewp);
872 +           // geometry.Project (surfi, hnewp); -- Project() changed for optimization
873 +           geometry.Project (surfi, hnewp, u, v);
874           }
875  
876         newgi.trignum = 1;
877 @@ -689,7 +701,7 @@
878        }
879    
880      newp = hnewp;
881 -  }
882 +  }//; -- to compile with -Wall -pedantic
883  
884  
885    void OCCRefinementSurfaces :: 
886 @@ -708,14 +720,18 @@
887      hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
888      newp = hnewp;
889      newgi = ap1;
890 -  };
891 +  }
892  
893  
894    void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
895    {
896      if (surfi > 0)
897 -      geometry.Project (surfi, p);
898 -  };
899 +      // geometry.Project (surfi, p); -- Project() changed for optimization
900 +    {
901 +      double u, v;
902 +      geometry.Project (surfi, p, u, v);
903 +    }
904 +  }//; -- to compile with -Wall -pedantic
905  
906    void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
907    {
908 @@ -723,9 +739,10 @@
909        if (!geometry.FastProject (surfi, p, gi.u, gi.v))
910         {
911           cout << "Fast projection to surface fails! Using OCC projection" << endl;
912 -         geometry.Project (surfi, p);
913 +          double u, v;
914 +         geometry.Project (surfi, p, u, v);
915         }
916 -  };
917 +  }
918  
919  
920  
921 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx
922 --- netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx 2009-08-24 06:12:24.000000000 +0400
923 +++ netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx  2014-07-22 13:01:28.000000000 +0400
924 @@ -86,6 +86,9 @@
925  #include <TopOpeBRepTool_OutCurveType.hxx>
926  #include <TopOpeBRep_DSFiller.hxx>
927  #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
928 +
929 +#include <Standard_Version.hxx>
930 +
931  #include <stdio.h>
932  
933  //=======================================================================
934 @@ -243,7 +246,12 @@
935        Standard_Integer i, nbExt = anExtPS.NbExt();
936        Extrema_POnSurf aPOnSurf;
937        for (i = 1; i <= nbExt; ++i )
938 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
939 +// porting to OCCT6.5.1
940 +        if (anExtPS.SquareDistance( i ) <= TolE * TolE) {
941 +#else
942          if (anExtPS.Value( i ) <= TolE) {
943 +#endif
944            aPOnSurf = anExtPS.Point( i );
945            break;
946          }
947 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx
948 --- netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx  2009-08-24 06:12:24.000000000 +0400
949 +++ netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx   2014-07-22 13:01:28.000000000 +0400
950 @@ -22,7 +22,6 @@
951  #include <BRepAdaptor_Surface.hxx>
952  #include <BRepAlgo_AsDes.hxx>
953  #include <BRepAlgo_FaceRestrictor.hxx>
954 -#include <BRepOffset_DataMapOfShapeReal.hxx>
955  #include <BRepTopAdaptor_FClass2d.hxx>
956  #include <BRep_Builder.hxx>
957  #include <BRep_Tool.hxx>
958 @@ -51,6 +50,15 @@
959  #include <gp_Pnt.hxx>
960  #include <gp_Pnt2d.hxx>
961  
962 +#include <Standard_Version.hxx>
963 +
964 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
965 +// porting to OCCT6.5.1
966 +#include <TopTools_DataMapOfShapeReal.hxx>
967 +#else
968 +#include <BRepOffset_DataMapOfShapeReal.hxx>
969 +#endif
970 +
971  //=======================================================================
972  //function : Partition_Loop2d
973  //purpose  :
974 @@ -209,7 +217,7 @@
975      Cc->D1(uc, PC, CTg1);
976      if (!isForward) CTg1.Reverse();
977  
978 -    Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
979 +    Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
980  
981      // select an edge whose first derivative is most left of CTg1
982      // ie an angle between Tg1 and CTg1 is least
983 @@ -233,7 +241,7 @@
984        // -PI < angle < PI
985        Standard_Real angle = Tg1.Angle(CTg1);
986  
987 -      if (PI - Abs(angle) <= tolAng)
988 +      if (M_PI - Abs(angle) <= tolAng)
989        {
990          // an angle is too close to PI; assure that an angle sign really
991          // reflects an edge position: +PI - an edge is worst,
992 @@ -519,7 +527,12 @@
993      DC.Initialize( DegEdge, F );
994  
995    // avoid intersecting twice the same edge
996 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
997 +// porting to OCCT6.5.1
998 +  TopTools_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
999 +#else
1000    BRepOffset_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
1001 +#endif
1002  
1003    Standard_Real U, f, l;
1004    BRep_Tool::Range (DegEdge, f, l);
1005 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx
1006 --- netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx    2009-08-24 06:12:24.000000000 +0400
1007 +++ netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx     2014-07-22 13:01:28.000000000 +0400
1008 @@ -178,7 +178,7 @@
1009        }
1010      }
1011  
1012 -    Standard_Real anglemax = - PI;
1013 +    Standard_Real anglemax = - M_PI;
1014      TopoDS_Edge   SelectedEdge;        
1015      for ( itl.Initialize(LE); itl.More(); itl.Next()) {
1016        const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
1017 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx
1018 --- netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx 2009-08-24 06:12:24.000000000 +0400
1019 +++ netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx  2014-07-22 13:01:28.000000000 +0400
1020 @@ -79,6 +79,8 @@
1021  #include <GeomAdaptor_Curve.hxx>
1022  #include <TopOpeBRepTool_CurveTool.hxx>
1023  
1024 +#include <Standard_Version.hxx>
1025 +
1026  #ifdef DEB
1027  //# define PART_PERF
1028  #endif
1029 @@ -1169,7 +1171,12 @@
1030            for (; j<=nbj && ok; ++j) {
1031              if (Extrema.IsMin(j)) {
1032               hasMin = Standard_True;
1033 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
1034 +// porting to OCCT6.5.1
1035 +              ok = Extrema.SquareDistance(j) <= tol * tol;
1036 +#else
1037                ok = Extrema.Value(j) <= tol;
1038 +#endif
1039             }
1040            }
1041          }
1042 diff -Naur netgen-4.9.13_orig/libsrc/occ/utilities.h netgen-4.9.13_new/libsrc/occ/utilities.h
1043 --- netgen-4.9.13_orig/libsrc/occ/utilities.h   2009-08-24 06:12:24.000000000 +0400
1044 +++ netgen-4.9.13_new/libsrc/occ/utilities.h    2014-07-22 13:01:28.000000000 +0400
1045 @@ -33,6 +33,7 @@
1046  
1047  #include <string>
1048  #include <iostream>
1049 +#include <iomanip>
1050  #include <cstdlib>
1051  // #include "SALOME_Log.hxx"
1052  
1053 diff -Naur netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp
1054 --- netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp   2009-08-10 15:40:51.000000000 +0400
1055 +++ netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp    2014-07-22 13:01:28.000000000 +0400
1056 @@ -1435,7 +1435,8 @@
1057  
1058           if (!optstring || strlen(optstring) == 0)
1059             {
1060 -             mparam.optimize2d = "smcm";
1061 +             //mparam.optimize2d = (char*)"smcm";
1062 +              mparam.optimize2d = (char*)"smcm";
1063             }
1064           else
1065             {
1066 @@ -1451,7 +1452,8 @@
1067                                  mparam.grading);
1068               mesh -> LoadLocalMeshSize (mparam.meshsizefilename);            
1069               mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac);
1070 -             mparam.optimize2d = "cmsmSm";
1071 +             //mparam.optimize2d = (char*)"cmsmSm";
1072 +              mparam.optimize2d = (char*)"cmsmSm";
1073               STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
1074  #ifdef STAT_STREAM
1075               (*statout) << GetTime() << " & ";
1076 @@ -1557,7 +1559,8 @@
1077  
1078           if (!optstring || strlen(optstring) == 0)
1079             {
1080 -             mparam.optimize3d = "cmdmstm";
1081 +              //mparam.optimize3d = "cmdmstm";
1082 +             mparam.optimize3d = (char*)"cmdmstm";
1083             }
1084           else
1085             {
1086 diff -Naur netgen-4.9.13_orig/nglib/nglib.h netgen-4.9.13_new/nglib/nglib.h
1087 --- netgen-4.9.13_orig/nglib/nglib.h    2010-05-18 15:20:25.000000000 +0400
1088 +++ netgen-4.9.13_new/nglib/nglib.h     2014-07-22 13:01:28.000000000 +0400
1089 @@ -24,7 +24,7 @@
1090  // Philippose - 14.02.2009
1091  // Modifications for creating a DLL in Windows
1092  #ifdef WIN32
1093 -   #ifdef NGLIB_EXPORTS || nglib_EXPORTS
1094 +   #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
1095        #define DLL_HEADER   __declspec(dllexport)
1096     #else
1097        #define DLL_HEADER   __declspec(dllimport)