Salome HOME
spns #32755 : TopIIVolMesh: move back to master branch
[tools/sat_salome.git] / products / patches / netgen-4.9.13-for-SALOME.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       2011-02-18 11:47:33.000000000 +0300
4 @@ -1,4 +1,5 @@
5  #include <mystdlib.h>
6 +#include <float.h>
7  
8  #include "meshing.hpp"  
9  
10 @@ -650,7 +651,7 @@
11  
12          double det = trans.Det();
13  
14 -        if (det <= 0)
15 +        if (det <= DBL_MIN)
16            err += 1e12;
17          else
18            err += frob * frob / det;
19 @@ -706,7 +707,7 @@
20  
21              double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
22  
23 -            if (det <= 0)
24 +            if (det <= DBL_MIN)
25                {
26                  dd = 0;
27                  return 1e12;
28 @@ -790,7 +791,7 @@
29            = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0)
30            + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0);
31  
32 -        if (det <= 0)
33 +        if (det <= DBL_MIN)
34            err += 1e12;
35          else
36            {
37 @@ -840,7 +841,7 @@
38          frob /= 2;
39  
40          double det = trans.Det();
41 -        if (det <= 0)
42 +        if (det <= DBL_MIN)
43            err += 1e12;
44          else
45            err += frob * frob / det;
46 @@ -1857,7 +1858,7 @@
47        case PYRAMID:
48          {
49            double noz = 1-p(2);
50 -          if (noz == 0.0) noz = 1e-10;
51 +          if (noz <= DBL_MIN) noz = 1e-10;
52  
53            double xi  = p(0) / noz;
54            double eta = p(1) / noz;
55 @@ -2035,7 +2036,7 @@
56  
57          double det = -trans.Det();
58        
59 -        if (det <= 0)
60 +        if (det <= DBL_MIN)
61            err += 1e12;
62          else
63            err += frob * frob * frob / det;
64 @@ -2107,7 +2108,7 @@
65          ddet *= -1;
66  
67        
68 -        if (det <= 0)
69 +        if (det <= DBL_MIN)
70            err += 1e12;
71          else
72            {
73 @@ -2189,7 +2190,7 @@
74        
75          det *= -1;
76        
77 -        if (det <= 0)
78 +        if (det <= DBL_MIN)
79            err += 1e12;
80          else
81            {
82 @@ -2522,10 +2523,10 @@
83  
84    MeshingParameters :: MeshingParameters ()
85    {
86 -    optimize3d = "cmdmustm";
87 +    optimize3d = (char*)"cmdmustm";
88      //optimize3d = "cmdmstm";
89      optsteps3d = 3;
90 -    optimize2d = "smsmsmSmSmSm";
91 +    optimize2d = (char*)"smsmsmSmSmSm";
92      optsteps2d = 3;
93      opterrpow = 2;
94      blockfill = 1;
95 diff -Naur netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp netgen-4.9.13_new/libsrc/meshing/meshtype.hpp
96 --- netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp      2009-11-09 13:50:43.000000000 +0300
97 +++ netgen-4.9.13_new/libsrc/meshing/meshtype.hpp       2011-02-18 11:24:03.000000000 +0300
98 @@ -12,7 +12,7 @@
99      Classes for NETGEN
100  */
101  
102 -
103 +class Mesh;
104  enum ELEMENT_TYPE { 
105    SEGMENT = 1, SEGMENT3 = 2,
106    TRIG = 10, QUAD=11, TRIG6 = 12, QUAD6 = 13, QUAD8 = 14,
107 diff -Naur netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp
108 --- netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp    2009-11-09 13:47:09.000000000 +0300
109 +++ netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp     2011-02-18 16:24:34.000000000 +0300
110 @@ -302,7 +302,8 @@
111      vgrad = 0;
112      badness = 0;
113  
114 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
115 +    //meshthis -> GetNormalVector (surfi, sp1, gi1, n);
116 +    n = normal;
117      pp1 = sp1 + x(0) * t1 + x(1) * t2;
118  
119      //  meshthis -> ProjectPoint (surfi, pp1);
120 @@ -360,7 +361,8 @@
121      vgrad = 0;
122      badness = 0;
123  
124 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
125 +    //meshthis -> GetNormalVector (surfi, sp1, gi1, n);
126 +    n = normal;
127  
128      pp1 = sp1 + x(0) * t1 + x(1) * t2;
129  
130 @@ -514,7 +516,8 @@
131      vgrad = 0;
132      badness = 0;
133  
134 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
135 +    //meshthis -> GetNormalVector (surfi, sp1, gi1, n);
136 +    n = normal;
137  
138      pp1 = sp1 + x(0) * t1 + x(1) * t2;
139  
140 @@ -586,7 +589,8 @@
141      vgrad = 0;
142      badness = 0;
143  
144 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
145 +    //meshthis -> GetNormalVector (surfi, sp1, gi1, n);
146 +    n = normal;
147  
148      // pp1 = sp1;
149      //    pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
150 @@ -973,7 +977,7 @@
151                 {
152                   mesh[pi] = Point<3> (origp);
153                 }
154 -           
155 +             break;
156             }
157         }
158  
159 diff -Naur netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp netgen-4.9.13_new/libsrc/occ/occconstruction.cpp
160 --- netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp   2009-08-24 06:32:47.000000000 +0400
161 +++ netgen-4.9.13_new/libsrc/occ/occconstruction.cpp    2011-02-18 14:04:45.000000000 +0300
162 @@ -28,7 +28,7 @@
163  #include <BRepAlgoAPI_Common.hxx>
164  #include <BRepAlgoAPI_Fuse.hxx>
165  #include <BRepAlgoAPI_Section.hxx>
166 -#include <BRepOffsetAPI_Sewing.hxx>
167 +//#include <BRepOffsetAPI_Sewing.hxx>
168  //#include <BRepAlgo_Sewing.hxx>
169  #include <BRepOffsetAPI_MakeOffsetShape.hxx>
170  #include <ShapeFix_Shape.hxx>
171 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp
172 --- netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp        2010-03-16 09:30:07.000000000 +0300
173 +++ netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp 2011-02-18 17:06:25.000000000 +0300
174 @@ -15,6 +15,7 @@
175  
176  #define DIVIDEEDGESECTIONS 1000
177  #define IGNORECURVELENGTH 1e-4
178 +#define VSMALL 1e-10
179  
180  
181     bool merge_solids = 1;
182 @@ -26,7 +27,7 @@
183        double nq = n*q;
184  
185        Point<3> p = p0 + 0.5*n;
186 -      double lambda = (p-l.p0)*n / nq;
187 +      double lambda = (fabs(nq) > 1e-10 ? (p-l.p0)*n / nq : -1);
188  
189        if (lambda >= 0 && lambda <= 1)
190        {
191 @@ -54,7 +55,7 @@
192  
193  
194  
195 -   double ComputeH (double kappa)
196 +   static double ComputeH (double kappa)
197     {
198        double hret;
199        kappa *= mparam.curvaturesafety;
200 @@ -62,7 +63,7 @@
201        if (mparam.maxh * kappa < 1)
202           hret = mparam.maxh;
203        else
204 -         hret = 1 / kappa;
205 +         hret = 1 / (kappa + VSMALL);
206  
207        if (mparam.maxh < hret)
208           hret = mparam.maxh;
209 @@ -73,7 +74,7 @@
210  
211  
212  
213 -   void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
214 +   static void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
215                             BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
216     {
217        int ls = -1;
218 @@ -168,8 +169,8 @@
219           if(h < 1e-4*maxside)
220              return;
221  
222 -
223 -         if (h > 30) return;
224 +         // commented to restrict H on a large sphere for example
225 +         //if (h > 30) return;
226        }
227  
228        if (h < maxside && depth < 10)
229 @@ -228,7 +229,7 @@
230  
231  
232  
233 -   void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
234 +   static void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
235                      Array<double> & params, Mesh & mesh)
236     {
237        double s0, s1;
238 @@ -247,8 +248,8 @@
239        hvalue[0] = 0;
240        pnt = c->Value(s0);
241  
242 -      double olddist = 0;
243 -      double dist = 0;
244 +      //double olddist = 0;
245 +      //double dist = 0;
246  
247        int tmpVal = (int)(DIVIDEEDGESECTIONS);
248  
249 @@ -256,15 +257,15 @@
250        {
251           oldpnt = pnt;
252           pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
253 -         hvalue[i] = hvalue[i-1] +
254 -            1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
255 -            pnt.Distance(oldpnt);
256 +         hvalue[i] = hvalue[i-1] + min( 1.0,
257 +                                        1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
258 +                                        pnt.Distance(oldpnt));
259  
260           //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
261           //       <<  " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
262  
263 -         olddist = dist;
264 -         dist = pnt.Distance(oldpnt);
265 +         //olddist = dist;
266 +         //dist = pnt.Distance(oldpnt);
267        }
268  
269        //  nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
270 @@ -279,7 +280,10 @@
271        {
272           if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
273           {
274 -            params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
275 +            // For nsubedges comparable to DIVIDEEDGESECTIONS (SALOME issue 0021073)
276 +            //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
277 +            double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
278 +            params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
279              pnt = c->Value(params[i]);
280              ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
281              i++;
282 @@ -323,6 +327,7 @@
283        (*testout) << "nedges = " << nedges << endl;
284  
285        double eps = 1e-6 * geom.GetBoundingBox().Diam();
286 +      const double eps2 = eps * eps;
287  
288        for (int i = 1; i <= nvertices; i++)
289        {
290 @@ -332,7 +337,7 @@
291           bool exists = 0;
292           if (merge_solids)
293              for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
294 -               if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
295 +               if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 )
296                 {
297                    exists = 1;
298                    break;
299 @@ -362,6 +367,7 @@
300           {
301              TopoDS_Face face = TopoDS::Face(exp1.Current());
302              int facenr = geom.fmap.FindIndex(face);
303 +            if ( facenr < 1 ) continue; // support of SALOME sub-meshes
304  
305              if (face2solid[0][facenr-1] == 0)
306                 face2solid[0][facenr-1] = solidnr;
307 @@ -381,6 +387,7 @@
308        int facenr = 0;
309        int edgenr = 0;
310  
311 +      edgenr = mesh.GetNSeg(); // support of SALOME sub-meshes
312  
313        (*testout) << "faces = " << geom.fmap.Extent() << endl;
314        int curr = 0;
315 @@ -442,6 +449,8 @@
316                    //(*testout) << "ignoring degenerated edge" << endl;
317                    continue;
318                 }
319 +               if ( geom.emap.FindIndex(edge) < 1 )
320 +                 continue; // support SALOME sub-meshes
321  
322                 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
323                    geom.vmap.FindIndex(TopExp::LastVertex (edge)))
324 @@ -479,6 +488,8 @@
325                 }
326                 else
327                 {
328 +                  const double tol = std::max( BRep_Tool::Tolerance( TopExp::FirstVertex (edge)),
329 +                                               BRep_Tool::Tolerance( TopExp::LastVertex (edge)));
330                    Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
331                    Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
332  
333 @@ -486,8 +497,8 @@
334                    pnums.Last() = -1;
335                    for (PointIndex pi = 1; pi < first_ep; pi++)
336                    {
337 -                     if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
338 -                     if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
339 +                     if (Dist2 (mesh[pi], fp) < 2*tol*tol) pnums[0] = pi;
340 +                     if (Dist2 (mesh[pi], lp) < 2*tol*tol) pnums.Last() = pi;
341                    }
342                 }
343  
344 @@ -633,7 +644,7 @@
345           }
346  
347           (*testout) << "mesh face " << k << endl;
348 -         multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
349 +         multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
350           geom.facemeshstatus[k-1] = -1;
351  
352  
353 @@ -901,7 +912,7 @@
354           //      if (k != 36) continue;
355  
356           //      (*testout) << "optimize face " << k << endl;
357 -         multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
358 +         multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
359  
360           FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
361  
362 @@ -1229,7 +1240,7 @@
363                    mindist = min (mindist, line.Dist(lines[num]));
364                 }
365  
366 -               mindist *= occparam.resthcloseedgefac;
367 +               mindist /= (occparam.resthcloseedgefac + VSMALL);
368  
369                 if (mindist < 1e-3)
370                 {
371 @@ -1456,3 +1467,4 @@
372  }
373  
374  #endif
375 +
376 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.cpp netgen-4.9.13_new/libsrc/occ/occgeom.cpp
377 --- netgen-4.9.13_orig/libsrc/occ/occgeom.cpp   2010-03-05 16:16:21.000000000 +0300
378 +++ netgen-4.9.13_new/libsrc/occ/occgeom.cpp    2011-02-18 15:34:01.000000000 +0300
379 @@ -7,7 +7,8 @@
380  #include "ShapeAnalysis_ShapeContents.hxx"
381  #include "ShapeAnalysis_CheckSmallFace.hxx"
382  #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
383 -#include "ShapeAnalysis_Surface.hxx"
384 +#include <ShapeAnalysis_Surface.hxx>
385 +#include <BRepTopAdaptor_FClass2d.hxx>
386  #include "BRepAlgoAPI_Fuse.hxx"
387  #include "BRepCheck_Analyzer.hxx"
388  #include "BRepLib.hxx"
389 @@ -15,11 +16,18 @@
390  #include "ShapeFix.hxx"
391  #include "ShapeFix_FixSmallFace.hxx"
392  #include "Partition_Spliter.hxx"
393 -
394 +#include <TopAbs_State.hxx>
395  
396  namespace netgen
397  {
398 -   void OCCGeometry :: PrintNrShapes ()
399 +  OCCGeometry::~OCCGeometry()
400 +  {
401 +    NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
402 +    for (; it.More(); it.Next())
403 +      delete it.Value();
404 +  }
405 +
406 +  void OCCGeometry :: PrintNrShapes ()
407     {
408        TopExp_Explorer e;
409        int count = 0;
410 @@ -952,24 +960,47 @@
411  
412  
413  
414 +   void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
415 +                                  BRepTopAdaptor_FClass2d*& cls) const
416 +   {
417 +     //MSV: organize caching projector in the map
418 +     if (fprjmap.IsBound(surfi))
419 +     {
420 +       proj = fprjmap.Find(surfi);
421 +       cls = fclsmap.Find(surfi);
422 +     }
423 +     else
424 +     {
425 +       const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
426 +       Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
427 +       proj = new ShapeAnalysis_Surface(aSurf);
428 +       fprjmap.Bind(surfi, proj);
429 +       cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
430 +       fclsmap.Bind(surfi, cls);
431 +     }
432 +   }
433  
434 -   void OCCGeometry :: Project (int surfi, Point<3> & p) const
435 +   bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
436     {
437        static int cnt = 0;
438        if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
439  
440        gp_Pnt pnt(p(0), p(1), p(2));
441 -
442 -      double u,v;
443 -      Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
444 -      Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
445 -      gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
446 -      suval.Coord( u, v);
447 -      pnt = thesurf->Value( u, v );
448 -
449 -
450 +  
451 +      Handle(ShapeAnalysis_Surface) proj;
452 +      BRepTopAdaptor_FClass2d *cls;
453 +      GetFaceTools(surfi, proj, cls);
454 +  
455 +      gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
456 +      if (cls->Perform(p2d) == TopAbs_OUT)
457 +      {
458 +        return false;
459 +      }
460 +      pnt = proj->Value(p2d);
461 +      p2d.Coord(u, v);
462 +  
463        p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
464 -
465 +      return true;
466     }
467  
468  
469 @@ -979,54 +1010,20 @@
470     {
471        gp_Pnt p(ap(0), ap(1), ap(2));
472  
473 -      Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
474 -
475 -      gp_Pnt x = surface->Value (u,v);
476 -
477 -      if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
478 -
479 -      gp_Vec du, dv;
480 -
481 -      surface->D1(u,v,x,du,dv);
482 -
483 -      int count = 0;
484 -
485 -      gp_Pnt xold;
486 -      gp_Vec n;
487 -      double det, lambda, mu;
488 -
489 -      do {
490 -         count++;
491 -
492 -         n = du^dv;
493 -
494 -         det = Det3 (n.X(), du.X(), dv.X(),
495 -            n.Y(), du.Y(), dv.Y(),
496 -            n.Z(), du.Z(), dv.Z());
497 -
498 -         if (det < 1e-15) return false;
499 -
500 -         lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
501 -            n.Y(), p.Y()-x.Y(), dv.Y(),
502 -            n.Z(), p.Z()-x.Z(), dv.Z())/det;
503 -
504 -         mu     = Det3 (n.X(), du.X(), p.X()-x.X(),
505 -            n.Y(), du.Y(), p.Y()-x.Y(),
506 -            n.Z(), du.Z(), p.Z()-x.Z())/det;
507 -
508 -         u += lambda;
509 -         v += mu;
510 -
511 -         xold = x;
512 -         surface->D1(u,v,x,du,dv);
513 -
514 -      } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
515 -
516 -      //    (*testout) << "FastProject count: " << count << endl;
517 -
518 -      if (count == 50) return false;
519 -
520 -      ap = Point<3> (x.X(), x.Y(), x.Z());
521 +      Handle(ShapeAnalysis_Surface) proj;
522 +      BRepTopAdaptor_FClass2d *cls;
523 +      GetFaceTools(surfi, proj, cls);
524 +    
525 +      gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
526 +      if (cls->Perform(p2d) == TopAbs_OUT)
527 +      {
528 +        //cout << "Projection fails" << endl;
529 +        return false;
530 +      }
531 +    
532 +      p = proj->Value(p2d);
533 +      p2d.Coord(u, v);
534 +      ap = Point<3> (p.X(), p.Y(), p.Z());
535  
536        return true;
537     }
538 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.hpp netgen-4.9.13_new/libsrc/occ/occgeom.hpp
539 --- netgen-4.9.13_orig/libsrc/occ/occgeom.hpp   2010-01-14 19:56:19.000000000 +0300
540 +++ netgen-4.9.13_new/libsrc/occ/occgeom.hpp    2011-02-18 15:33:10.000000000 +0300
541 @@ -15,8 +15,6 @@
542  #include "Geom_Curve.hxx"
543  #include "Geom2d_Curve.hxx"
544  #include "Geom_Surface.hxx"
545 -#include "GeomAPI_ProjectPointOnSurf.hxx"
546 -#include "GeomAPI_ProjectPointOnCurve.hxx"
547  #include "BRepTools.hxx"
548  #include "TopExp.hxx"
549  #include "BRepBuilderAPI_MakeVertex.hxx"
550 @@ -42,8 +40,6 @@
551  #include "Geom_Curve.hxx"
552  #include "Geom2d_Curve.hxx"
553  #include "Geom_Surface.hxx"
554 -#include "GeomAPI_ProjectPointOnSurf.hxx"
555 -#include "GeomAPI_ProjectPointOnCurve.hxx"
556  #include "TopoDS_Wire.hxx"
557  #include "BRepTools_WireExplorer.hxx"
558  #include "BRepTools.hxx"
559 @@ -68,7 +64,7 @@
560  #include "IGESToBRep_Reader.hxx"
561  #include "Interface_Static.hxx"
562  #include "GeomAPI_ExtremaCurveCurve.hxx"
563 -#include "Standard_ErrorHandler.hxx"
564 +//#include "Standard_ErrorHandler.hxx"
565  #include "Standard_Failure.hxx"
566  #include "ShapeUpgrade_ShellSewing.hxx"
567  #include "ShapeFix_Shape.hxx"
568 @@ -80,6 +76,10 @@
569  #include "ShapeAnalysis.hxx"
570  #include "ShapeBuild_ReShape.hxx"
571  
572 +#include <NCollection_DataMap.hxx>
573 +class Handle_ShapeAnalysis_Surface;
574 +class BRepTopAdaptor_FClass2d;
575 +
576  
577  // Philippose - 29/01/2009
578  // OpenCascade XDE Support
579 @@ -190,6 +190,8 @@
580     class OCCGeometry : public NetgenGeometry
581     {
582        Point<3> center;
583 +      mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
584 +      mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
585  
586     public:
587        TopoDS_Shape shape;
588 @@ -241,6 +243,8 @@
589           vmap.Clear();
590        }
591  
592 +      ~OCCGeometry();
593 +
594        void BuildFMap();
595  
596        Box<3> GetBoundingBox()
597 @@ -260,9 +264,12 @@
598        Point<3> Center()
599        {  return center;}
600  
601 -      void Project (int surfi, Point<3> & p) const;
602 +      bool Project (int surfi, Point<3> & p, double& u, double& v) const;
603        bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
604  
605 +      void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
606 +                        BRepTopAdaptor_FClass2d*& cls) const;
607 +
608        OCCSurface GetSurface (int surfi)
609        {
610           cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
611 diff -Naur netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp
612 --- netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp       2009-08-24 06:32:47.000000000 +0400
613 +++ netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp        2011-02-18 16:27:39.000000000 +0300
614 @@ -6,6 +6,7 @@
615  #include <meshing.hpp>
616  #include <GeomLProp_SLProps.hxx>
617  #include <ShapeAnalysis_Surface.hxx>
618 +#include <GeomAPI_ProjectPointOnCurve.hxx>
619  
620  
621  namespace netgen
622 @@ -434,23 +435,21 @@
623  
624    void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
625    {
626 -    geometry.Project (surfind, p);
627 +    double u, v;
628 +    geometry.Project (surfind, p, u, v);
629    }
630  
631  
632    int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
633    {
634 -    double u = gi.u;
635 -    double v = gi.v;
636 -
637      Point<3> hp = p;
638 -    if (geometry.FastProject (surfind, hp, u, v))
639 -      {
640 -       p = hp;
641 -       return 1;
642 -      }
643 -    ProjectPoint (surfind, p); 
644 -    return CalcPointGeomInfo (surfind, gi, p); 
645 +    bool ok;
646 +    if (gi.trignum > 0)
647 +      ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
648 +    else
649 +      ok = geometry.Project (surfind, hp, gi.u, gi.v);
650 +    p = hp;
651 +    return ok;
652    }
653  
654  
655 @@ -680,7 +679,7 @@
656         if (!geometry.FastProject (surfi, hnewp, u, v))
657           {
658           //  cout << "Fast projection to surface fails! Using OCC projection" << endl;
659 -           geometry.Project (surfi, hnewp);
660 +           geometry.Project (surfi, hnewp, u, v);
661           }
662  
663         newgi.trignum = 1;
664 @@ -708,14 +707,17 @@
665      hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
666      newp = hnewp;
667      newgi = ap1;
668 -  };
669 +  }
670  
671  
672    void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
673    {
674      if (surfi > 0)
675 -      geometry.Project (surfi, p);
676 -  };
677 +    {
678 +      double u, v;
679 +      geometry.Project (surfi, p, u, v);
680 +    }
681 +  }
682  
683    void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
684    {
685 @@ -723,9 +725,10 @@
686        if (!geometry.FastProject (surfi, p, gi.u, gi.v))
687         {
688           cout << "Fast projection to surface fails! Using OCC projection" << endl;
689 -         geometry.Project (surfi, p);
690 +          double u, v;
691 +         geometry.Project (surfi, p, u, v);
692         }
693 -  };
694 +  }
695  
696  
697  
698 diff -Naur netgen-4.9.13_orig/libsrc/occ/utilities.h netgen-4.9.13_new/libsrc/occ/utilities.h
699 --- netgen-4.9.13_orig/libsrc/occ/utilities.h   2009-08-24 06:12:24.000000000 +0400
700 +++ netgen-4.9.13_new/libsrc/occ/utilities.h    2011-02-18 11:24:03.000000000 +0300
701 @@ -33,6 +33,7 @@
702  
703  #include <string>
704  #include <iostream>
705 +#include <iomanip>
706  #include <cstdlib>
707  // #include "SALOME_Log.hxx"
708  
709 diff -Naur netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp
710 --- netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp   2009-08-10 15:40:51.000000000 +0400
711 +++ netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp    2011-02-18 11:24:03.000000000 +0300
712 @@ -1435,7 +1435,7 @@
713  
714           if (!optstring || strlen(optstring) == 0)
715             {
716 -             mparam.optimize2d = "smcm";
717 +             mparam.optimize2d = (char*)"smcm";
718             }
719           else
720             {
721 @@ -1451,7 +1451,7 @@
722                                  mparam.grading);
723               mesh -> LoadLocalMeshSize (mparam.meshsizefilename);            
724               mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac);
725 -             mparam.optimize2d = "cmsmSm";
726 +             mparam.optimize2d = (char*)"cmsmSm";
727               STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
728  #ifdef STAT_STREAM
729               (*statout) << GetTime() << " & ";
730 @@ -1557,7 +1557,7 @@
731  
732           if (!optstring || strlen(optstring) == 0)
733             {
734 -             mparam.optimize3d = "cmdmstm";
735 +             mparam.optimize3d = (char*)"cmdmstm";
736             }
737           else
738             {
739 --- netgen-4.9.13_orig/nglib/nglib.h    2010-05-18 15:20:25.000000000 +0400
740 +++ netgen-4.9.13_new/nglib/nglib.h     2010-05-31 13:02:19.000000000 +0400
741 @@ -24,7 +24,7 @@
742  // Philippose - 14.02.2009
743  // Modifications for creating a DLL in Windows
744  #ifdef WIN32
745 -   #ifdef NGLIB_EXPORTS || nglib_EXPORTS
746 +   #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
747        #define DLL_HEADER   __declspec(dllexport)
748     #else
749        #define DLL_HEADER   __declspec(dllimport)