Salome HOME
*** empty log message ***
[tools/install.git] / config_files / patches / netgen-4.5-for-SALOME.patch
1 diff -Naur netgen-4.5.old/libsrc/csg/meshsurf.cpp netgen-4.5.new/libsrc/csg/meshsurf.cpp
2 --- netgen-4.5.old/libsrc/csg/meshsurf.cpp      2006-02-14 11:54:35.000000000 +0300
3 +++ netgen-4.5.new/libsrc/csg/meshsurf.cpp      2008-02-12 14:57:01.000000000 +0300
4 @@ -77,11 +77,12 @@
5  }
6  
7  
8 -void MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const
9 +bool MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const
10  {
11    Point<3> hp = p;
12    geometry.GetSurface(surfind)->Project (hp);
13    p = hp;
14 +  return true;
15  }
16  
17  void MeshOptimize2dSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2, 
18 diff -Naur netgen-4.5.old/libsrc/csg/meshsurf.hpp netgen-4.5.new/libsrc/csg/meshsurf.hpp
19 --- netgen-4.5.old/libsrc/csg/meshsurf.hpp      2004-01-20 14:49:44.000000000 +0300
20 +++ netgen-4.5.new/libsrc/csg/meshsurf.hpp      2008-02-12 14:57:01.000000000 +0300
21 @@ -45,7 +45,7 @@
22      MeshOptimize2dSurfaces (const CSGeometry & ageometry); 
23     
24      ///
25 -    virtual void ProjectPoint (INDEX surfind, Point3d & p) const;
26 +    virtual bool ProjectPoint (INDEX surfind, Point3d & p) const;
27      ///
28      virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const;
29      ///
30 diff -Naur netgen-4.5.old/libsrc/interface/Makefile netgen-4.5.new/libsrc/interface/Makefile
31 --- netgen-4.5.old/libsrc/interface/Makefile    2005-08-09 18:14:59.000000000 +0400
32 +++ netgen-4.5.new/libsrc/interface/Makefile    2008-02-12 14:57:01.000000000 +0300
33 @@ -1,4 +1,5 @@
34 -src = nginterface.cpp writeuser.cpp writediffpack.cpp writeabaqus.cpp writefluent.cpp writepermas.cpp writetochnog.cpp writetecplot.cpp wuchemnitz.cpp writetochnog.cpp writefeap.cpp writeelmer.cpp  writegmsh.cpp writejcm.cpp readuser.cpp importsolution.cpp 
35 +#src = nginterface.cpp writeuser.cpp writediffpack.cpp writeabaqus.cpp writefluent.cpp writepermas.cpp writetochnog.cpp writetecplot.cpp wuchemnitz.cpp writetochnog.cpp writefeap.cpp writeelmer.cpp  writegmsh.cpp writejcm.cpp readuser.cpp importsolution.cpp
36 +src = writeuser.cpp writediffpack.cpp writeabaqus.cpp writefluent.cpp writepermas.cpp writetochnog.cpp writetecplot.cpp wuchemnitz.cpp writetochnog.cpp writefeap.cpp writeelmer.cpp  writegmsh.cpp writejcm.cpp readuser.cpp nglib.cpp ngnewdelete.cpp
37  #
38  lib = nginterface
39  libpath = libsrc/interface
40 diff -Naur netgen-4.5.old/libsrc/interface/nglib.cpp netgen-4.5.new/libsrc/interface/nglib.cpp
41 --- netgen-4.5.old/libsrc/interface/nglib.cpp   2005-10-18 17:53:18.000000000 +0400
42 +++ netgen-4.5.new/libsrc/interface/nglib.cpp   2008-02-12 14:57:01.000000000 +0300
43 @@ -56,7 +56,8 @@
44  
45  void Ng_Exit ()
46  {
47 -  ;
48 +  delete testout;
49 +  testout = NULL;
50  }
51    
52  
53 diff -Naur netgen-4.5.old/libsrc/makefile.inc netgen-4.5.new/libsrc/makefile.inc
54 --- netgen-4.5.old/libsrc/makefile.inc  2005-09-02 17:17:51.000000000 +0400
55 +++ netgen-4.5.new/libsrc/makefile.inc  2008-02-12 14:59:55.000000000 +0300
56 @@ -8,17 +8,14 @@
57  LIBSRC_DIR=$(CPP_DIR)/libsrc
58  LIB_DIR=$(CPP_DIR)/lib/$(MACHINE)
59  
60 -#OCC_DIR=../../occ
61 -#OCCINC_DIR=$(OCC_DIR)/inc
62 -#OCCLIB_DIR=$(OCC_DIR)/lib
63 -# OCC_DIR=/opt/OpenCASCADE5.2/ros
64 -# OCC_DIR=/home/joachim/download/occ/Linux
65 -# OCCINC_DIR=$(OCC_DIR)/inc  -I$(OCC_DIR)/ros/inc
66 -# OCCLIB_DIR=$(OCC_DIR)/Linux/lib
67 +OCC_DIR=$(CASROOT)
68 +OCCINC_DIR=$(OCC_DIR)/inc
69 +OCCLIB_DIR=$(OCC_DIR)/Linux/lib
70  #
71  include $(LIBSRC_DIR)/makefile.mach.$(MACHINE)
72  #
73 -CPLUSPLUSFLAGS1 = -c -I$(LIBSRC_DIR)/include -I$(OCCINC_DIR) 
74 +CPLUSPLUSFLAGS1 = -c -fPIC -I$(LIBSRC_DIR)/include -I$(OCCINC_DIR) \
75 +       -DOCCGEOMETRY -DOCC52 -DHAVE_IOSTREAM -DHAVE_LIMITS_H
76  #
77  ARFLAGS = r
78  #
79 diff -Naur netgen-4.5.old/libsrc/makefile.mach.LINUX netgen-4.5.new/libsrc/makefile.mach.LINUX
80 --- netgen-4.5.old/libsrc/makefile.mach.LINUX   2004-10-11 23:49:26.000000000 +0400
81 +++ netgen-4.5.new/libsrc/makefile.mach.LINUX   2008-02-12 14:57:01.000000000 +0300
82 @@ -16,7 +16,7 @@
83  #
84  CFLAGS2 =
85  
86 -CPLUSPLUSFLAGS2 = -O2 -I/usr/include/GL3.5 -DLINUX -DOPENGL \
87 +CPLUSPLUSFLAGS2 = -O2 -I/usr/include/GL3.5 -DLINUX \
88         -ftemplate-depth-99 -finline-limit=10000 \
89         -Wdisabled-optimization  -funroll-loops  -DnoNGSOLVE
90  
91 diff -Naur netgen-4.5.old/libsrc/meshing/meshtype.cpp netgen-4.5.new/libsrc/meshing/meshtype.cpp
92 --- netgen-4.5.old/libsrc/meshing/meshtype.cpp  2006-02-10 13:11:08.000000000 +0300
93 +++ netgen-4.5.new/libsrc/meshing/meshtype.cpp  2008-03-14 13:19:53.000000000 +0300
94 @@ -1,4 +1,5 @@
95  #include <mystdlib.h>
96 +#include <float.h>
97  
98  #include "meshing.hpp"  
99  
100 @@ -774,7 +775,7 @@
101        frob /= 2;
102  
103        double det = trans.Det();
104 -      if (det <= 0)
105 +      if (det <= DBL_MIN)
106         err += 1e12;
107        else
108         err += frob * frob / det;
109
110
111 diff -Naur netgen-4.5.old/libsrc/meshing/improve2.cpp netgen-4.5.new/libsrc/meshing/improve2.cpp
112 --- netgen-4.5.old/libsrc/meshing/improve2.cpp  2006-01-11 19:08:19.000000000 +0300
113 +++ netgen-4.5.new/libsrc/meshing/improve2.cpp  2008-02-12 14:57:01.000000000 +0300
114 @@ -4,7 +4,7 @@
115  #include <opti.hpp>
116  
117  #ifndef SMALLLIB
118 -#include <visual.hpp>
119 +//#include <visual.hpp>
120  #endif
121  
122  namespace netgen
123 diff -Naur netgen-4.5.old/libsrc/meshing/improve2.hpp netgen-4.5.new/libsrc/meshing/improve2.hpp
124 --- netgen-4.5.old/libsrc/meshing/improve2.hpp  2004-10-12 23:22:55.000000000 +0400
125 +++ netgen-4.5.new/libsrc/meshing/improve2.hpp  2008-02-12 14:57:01.000000000 +0300
126 @@ -32,17 +32,16 @@
127    ///
128    virtual void SelectSurfaceOfPoint (const Point3d & p,
129                                      const PointGeomInfo & gi);
130 -  ///
131 -  virtual void ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { };
132 +
133 +  /// project point on surface, returns true if success
134 +  virtual bool ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { return false; }
135 +  /// fast project point on surface using point geom info of a neighboring point
136 +  /// if gi.trignum != 0,
137 +  /// returns true if success, gi is updated
138 +  virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const
139 +  { gi.trignum = 1; return ProjectPoint (surfind, p); }
140    ///
141    virtual void ProjectPoint2 (INDEX /* surfind */, INDEX /* surfind2 */, Point3d & /* p */) const { };
142 -  /// liefert zu einem 3d-Punkt die geominfo (Dreieck) und liefert 1, wenn erfolgreich, 
143 -  /// 0, wenn nicht (Punkt ausserhalb von chart)
144 -  virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& /*p3*/) const
145 -    { gi.trignum = 1; return 1;};
146 -
147 -  virtual int CalcPointGeomInfo(int /* surfind */, PointGeomInfo& gi, const Point3d& p3) const
148 -    { return CalcPointGeomInfo (gi, p3); }
149  
150    ///
151    virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const;
152 diff -Naur netgen-4.5.old/libsrc/meshing/smoothing2.cpp netgen-4.5.new/libsrc/meshing/smoothing2.cpp
153 --- netgen-4.5.old/libsrc/meshing/smoothing2.cpp        2006-01-11 19:08:20.000000000 +0300
154 +++ netgen-4.5.new/libsrc/meshing/smoothing2.cpp        2008-02-12 14:57:01.000000000 +0300
155 @@ -300,7 +300,7 @@
156    double Opti2SurfaceMinFunction :: 
157    FuncGrad (const Vector & x, Vector & grad) const
158    {
159 -    Vec3d n, vgrad;
160 +    Vec3d vgrad;
161      Point3d pp1;
162      double g1x, g1y;
163      double badness, hbadness;
164 @@ -308,8 +308,6 @@
165      vgrad = 0;
166      badness = 0;
167  
168 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
169 -
170      pp1 = sp1;
171      pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
172  
173 @@ -360,7 +358,7 @@
174    double Opti2SurfaceMinFunction :: 
175    FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const
176    {
177 -    Vec3d n, vgrad;
178 +    Vec3d vgrad;
179      Point3d pp1;
180      double g1x, g1y;
181      double badness, hbadness;
182 @@ -368,8 +366,6 @@
183      vgrad = 0;
184      badness = 0;
185  
186 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
187 -
188      pp1 = sp1;
189      pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
190  
191 @@ -520,7 +516,7 @@
192      // from 2d:
193  
194      int j, k, lpi, gpi;
195 -    Vec3d n, vgrad;
196 +    Vec3d vgrad;
197      Point3d pp1;
198      Vec2d g1, vdir;
199      double badness, hbadness, hbad, hderiv;
200 @@ -528,8 +524,6 @@
201      vgrad = 0;
202      badness = 0;
203  
204 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
205 -
206      pp1 = sp1;
207      pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
208  
209 @@ -593,7 +587,7 @@
210      // from 2d:
211  
212      int j, k, lpi, gpi;
213 -    Vec3d n, vgrad;
214 +    Vec3d vgrad;
215      Point3d pp1;
216      Vec2d g1, vdir;
217      double badness, hbadness, hbad, hderiv;
218 @@ -601,8 +595,6 @@
219      vgrad = 0;
220      badness = 0;
221  
222 -    meshthis -> GetNormalVector (surfi, sp1, gi1, n);
223 -
224      pp1 = sp1;
225      pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
226  
227 @@ -859,19 +851,21 @@
228           locelements.SetSize(0);
229           locrots.SetSize (0);
230           lochs.SetSize (0);
231 +          ngi.trignum = 0;
232         
233           for (j = 0; j < elementsonpoint[pi].Size(); j++)
234             {
235               sei = elementsonpoint[pi][j];
236               const Element2d & bel = mesh[sei];
237               surfi = mesh.GetFaceDescriptor(bel.GetIndex()).SurfNr();
238 -           
239 +
240               locelements.Append (sei);
241             
242               for (k = 1; k <= bel.GetNP(); k++)
243                 if (bel.PNum(k) == pi)
244                   {
245                     locrots.Append (k);
246 +                    ngi = bel.GeomInfoPi(k);
247                     break;
248                   }
249               
250 @@ -942,7 +936,7 @@
251             }
252           
253           //optimizer loop (if not whole distance is not possible, move only a bit!!!!)
254 -         while (loci <= 5 && !moveisok)
255 +          while (loci <= 5 && !moveisok)
256             {
257               loci ++;
258               mesh[pi].X() = origp.X() + (x.Get(1) * t1.X() + x.Get(2) * t2.X())*fact;
259 @@ -951,11 +945,9 @@
260               fact = fact/2.;
261  
262  
263 -             ProjectPoint (surfi, mesh[pi]);
264 +             moveisok = ProjectPoint (surfi, mesh[pi], ngi);
265  
266 -             moveisok = CalcPointGeomInfo(surfi, ngi, mesh[pi]); 
267 -             // point lies on same chart in stlsurface
268 -           
269 +              // point lies on same chart in stlsurface
270               if (moveisok)
271                 {
272                   for (j = 0; j < locelements.Size(); j++)
273 diff -Naur netgen-4.5.old/libsrc/occ/occconstruction.cpp netgen-4.5.new/libsrc/occ/occconstruction.cpp
274 --- netgen-4.5.old/libsrc/occ/occconstruction.cpp       2005-12-06 18:15:53.000000000 +0300
275 +++ netgen-4.5.new/libsrc/occ/occconstruction.cpp       2008-02-12 14:57:01.000000000 +0300
276 @@ -28,8 +28,8 @@
277  #include <BRepAlgoAPI_Common.hxx>
278  #include <BRepAlgoAPI_Fuse.hxx>
279  #include <BRepAlgoAPI_Section.hxx>
280 -#include <BRepOffsetAPI_Sewing.hxx>
281 -#include <BRepAlgo_Sewing.hxx>
282 +//#include <BRepOffsetAPI_Sewing.hxx>
283 +//#include <BRepAlgo_Sewing.hxx>
284  #include <BRepOffsetAPI_MakeOffsetShape.hxx>
285  #include <ShapeFix_Shape.hxx>
286  namespace netgen
287 diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/occgenmesh.cpp
288 --- netgen-4.5.old/libsrc/occ/occgenmesh.cpp    2006-02-07 13:12:48.000000000 +0300
289 +++ netgen-4.5.new/libsrc/occ/occgenmesh.cpp    2008-02-12 14:57:01.000000000 +0300
290 @@ -28,7 +28,7 @@
291      return  Point<3> (p.X(), p.Y(), p.Z());
292    }
293   
294 -  void DivideEdge (TopoDS_Edge & edge,
295 +  static void DivideEdge (TopoDS_Edge & edge,
296                    ARRAY<MeshPoint> & ps,
297                    ARRAY<double> & params,
298                    Mesh & mesh)
299 @@ -49,23 +49,19 @@
300      hvalue[0] = 0;
301      pnt = c->Value(s0);
302  
303 -    double olddist = 0;
304 -    double dist = 0;
305 -
306 -    for (int i = 1; i <= DIVIDEEDGESECTIONS; i++)
307 +    int i;
308 +    for (i = 1; i <= DIVIDEEDGESECTIONS; i++)
309        {
310         oldpnt = pnt;
311         pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
312 +       double dist = pnt.Distance(oldpnt);
313         hvalue[i] = hvalue[i-1] +
314           1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
315 -         pnt.Distance(oldpnt);
316 +         dist;
317  
318         //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) 
319         //         <<  " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
320  
321 -
322 -       olddist = dist;
323 -       dist = pnt.Distance(oldpnt);
324        }
325  
326      //  nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
327 @@ -74,7 +70,7 @@
328      ps.SetSize(nsubedges-1);
329      params.SetSize(nsubedges+1);
330  
331 -    int i = 1;
332 +    i = 1;
333      int i1 = 0;
334      do
335        {
336 @@ -112,7 +108,7 @@
337  
338    static void FindEdges (OCCGeometry & geom, Mesh & mesh)
339    {
340 -    char * savetask = multithread.task;
341 +    const char * savetask = multithread.task;
342      multithread.task = "Edge meshing";
343  
344      (*testout) << "edge meshing" << endl;
345 @@ -124,6 +120,7 @@
346      (*testout) << "nedges = " << nedges << endl;
347  
348      double eps = 1e-6 * geom.GetBoundingBox().Diam();
349 +    double eps2 = eps * eps;
350  
351      for (int i = 1; i <= nvertices; i++)
352        {
353 @@ -133,7 +130,7 @@
354         bool exists = 0;
355         if (merge_solids)
356           for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
357 -           if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
358 +           if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2)
359               {
360                 exists = 1;
361                 break;
362 @@ -163,6 +160,7 @@
363           {
364             TopoDS_Face face = TopoDS::Face(exp1.Current());
365             int facenr = geom.fmap.FindIndex(face);
366 +            if ( facenr < 1 ) continue;
367  
368             if (face2solid[0][facenr-1] == 0)
369               face2solid[0][facenr-1] = solidnr;
370 @@ -184,6 +182,9 @@
371      int facenr = 0;
372      int edgenr = 0;
373      
374 +    // EAP, IMP [SALOME platform 0013410].
375 +    // take into account nb of already meshed edges
376 +    edgenr = mesh.GetNSeg();
377  
378      (*testout) << "faces = " << geom.fmap.Extent() << endl;
379      int curr = 0;
380 @@ -232,6 +233,11 @@
381                     continue;
382                   }
383  
384 +                // EAP, IMP [SALOME platform 0013410].
385 +                // Do not divide already meshed edges
386 +                if ( geom.emap.FindIndex(edge) < 1 )
387 +                  continue;
388 +
389                 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) == 
390                     geom.vmap.FindIndex(TopExp::LastVertex (edge)))
391                   {
392 @@ -276,8 +282,8 @@
393                     pnums.Last() = -1;
394                     for (PointIndex pi = 1; pi < first_ep; pi++)
395                       {
396 -                       if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
397 -                       if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
398 +                       if (Dist2 (mesh[pi], fp) < eps2) pnums[0] = pi;
399 +                       if (Dist2 (mesh[pi], lp) < eps2) pnums.Last() = pi;
400                       }
401                   }
402                 
403 @@ -287,7 +293,7 @@
404                     bool exists = 0;
405                     int j;
406                     for (j = first_ep; j <= mesh.GetNP(); j++)
407 -                     if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps) 
408 +                     if (Dist2(mesh.Point(j), Point<3>(mp[i-1])) < eps2)
409                         {
410                           exists = 1;
411                           break;
412 @@ -394,7 +400,7 @@
413      int i, j, k;
414      int changed;
415  
416 -    char * savetask = multithread.task;
417 +    const char * savetask = multithread.task;
418      multithread.task = "Surface meshing";
419    
420      geom.facemeshstatus = 0;
421 @@ -751,7 +760,7 @@
422      multithread.task = savetask;
423    }
424  
425 -  double ComputeH (double kappa)
426 +  static double ComputeH (double kappa)
427    {
428      double hret;
429      kappa *= mparam.curvaturesafety;
430 @@ -779,7 +788,7 @@
431        double nq = n*q;
432      
433        Point<3> p = p0 + 0.5*n;
434 -      double lambda = (p-l.p0)*n / nq;
435 +      double lambda = (fabs(nq) > 1e-10 ? (p-l.p0)*n / nq : -1);
436  
437        if (lambda >= 0 && lambda <= 1)
438         {
439 @@ -799,55 +808,55 @@
440  
441  
442  
443 -  void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
444 -                         BRepLProp_SLProps * prop, Mesh & mesh, const double maxside, int depth, double h = 0)
445 +  static void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
446 +                         BRepAdaptor_Surface& surf, Mesh & mesh, const double maxside, int depth, double h = 0)
447    {
448 -
449 +    BRepLProp_SLProps prop(surf, 2, 1e-5);
450  
451      gp_Pnt2d parmid;
452  
453      parmid.SetX(0.3*(par0.X()+par1.X()+par2.X()));
454      parmid.SetY(0.3*(par0.Y()+par1.Y()+par2.Y()));
455      
456 -    if (depth == 0)
457 +    //if (depth == 0)
458        {
459         double curvature = 0;
460  
461 -       prop->SetParameters (parmid.X(), parmid.Y());
462 -       if (!prop->IsCurvatureDefined())
463 +       prop.SetParameters (parmid.X(), parmid.Y());
464 +       if (!prop.IsCurvatureDefined())
465           {
466             (*testout) << "curvature not defined!" << endl;
467             return;
468           }
469 -       curvature = max(fabs(prop->MinCurvature()),
470 -                       fabs(prop->MaxCurvature()));
471 +       curvature = max(fabs(prop.MinCurvature()),
472 +                       fabs(prop.MaxCurvature()));
473  
474 -       prop->SetParameters (par0.X(), par0.Y());
475 -       if (!prop->IsCurvatureDefined())
476 +       prop.SetParameters (par0.X(), par0.Y());
477 +       if (!prop.IsCurvatureDefined())
478           {
479             (*testout) << "curvature not defined!" << endl;
480             return;
481           }
482 -       curvature = max(curvature,max(fabs(prop->MinCurvature()),
483 -                                     fabs(prop->MaxCurvature())));
484 +       curvature = max(curvature,max(fabs(prop.MinCurvature()),
485 +                                     fabs(prop.MaxCurvature())));
486  
487 -       prop->SetParameters (par1.X(), par1.Y());
488 -       if (!prop->IsCurvatureDefined())
489 +       prop.SetParameters (par1.X(), par1.Y());
490 +       if (!prop.IsCurvatureDefined())
491           {
492             (*testout) << "curvature not defined!" << endl;
493             return;
494           }
495 -       curvature = max(curvature,max(fabs(prop->MinCurvature()),
496 -                                     fabs(prop->MaxCurvature())));
497 +       curvature = max(curvature,max(fabs(prop.MinCurvature()),
498 +                                     fabs(prop.MaxCurvature())));
499  
500 -       prop->SetParameters (par2.X(), par2.Y());
501 -       if (!prop->IsCurvatureDefined())
502 +       prop.SetParameters (par2.X(), par2.Y());
503 +       if (!prop.IsCurvatureDefined())
504           {
505             (*testout) << "curvature not defined!" << endl;
506             return;
507           }
508 -       curvature = max(curvature,max(fabs(prop->MinCurvature()),
509 -                                     fabs(prop->MaxCurvature())));
510 +       curvature = max(curvature,max(fabs(prop.MinCurvature()),
511 +                                     fabs(prop.MaxCurvature())));
512  
513         //(*testout) << "curvature " << curvature << endl;
514  
515 @@ -886,51 +895,47 @@
516         pm1.SetX(0.5*(par0.X()+par2.X())); pm1.SetY(0.5*(par0.Y()+par2.Y()));
517         pm2.SetX(0.5*(par1.X()+par0.X())); pm2.SetY(0.5*(par1.Y()+par0.Y()));
518  
519 -       RestrictHTriangle (pm0, pm1, pm2, prop, mesh, 0.5*maxside, depth+1, h);
520 -       RestrictHTriangle (par0, pm1, pm2, prop, mesh, 0.5*maxside, depth+1, h);
521 -       RestrictHTriangle (par1, pm0, pm2, prop, mesh, 0.5*maxside, depth+1, h);
522 -       RestrictHTriangle (par2, pm1, pm0, prop, mesh, 0.5*maxside, depth+1, h);
523 +       RestrictHTriangle (pm0, pm1, pm2, surf, mesh, 0.5*maxside, depth+1, h);
524 +       RestrictHTriangle (par0, pm1, pm2, surf, mesh, 0.5*maxside, depth+1, h);
525 +       RestrictHTriangle (par1, pm0, pm2, surf, mesh, 0.5*maxside, depth+1, h);
526 +       RestrictHTriangle (par2, pm1, pm0, surf, mesh, 0.5*maxside, depth+1, h);
527        }
528      else
529        {
530         gp_Pnt pnt;
531         Point3d p3d;
532  
533 -       prop->SetParameters (parmid.X(), parmid.Y());
534 -       pnt = prop->Value();
535 +       surf.D0(parmid.X(), parmid.Y(), pnt);
536         p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
537         mesh.RestrictLocalH (p3d, h);
538  
539         
540 -       prop->SetParameters (par0.X(), par0.Y());
541 -       pnt = prop->Value();
542 +       surf.D0(par0.X(), par0.Y(), pnt);
543         p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
544         mesh.RestrictLocalH (p3d, h);
545  
546 -       prop->SetParameters (par1.X(), par1.Y());
547 -       pnt = prop->Value();
548 +       surf.D0(par1.X(), par1.Y(), pnt);
549         p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
550         mesh.RestrictLocalH (p3d, h);
551  
552 -       prop->SetParameters (par2.X(), par2.Y());
553 -       pnt = prop->Value();
554 +       surf.D0(par2.X(), par2.Y(), pnt);
555         p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
556         mesh.RestrictLocalH (p3d, h);
557  
558 -       (*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl;
559 +       //(*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl;
560         /*
561           (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl;
562  
563 -         prop->SetParameters (par0.X(), par0.Y());
564 -         pnt = prop->Value();
565 +         prop.SetParameters (par0.X(), par0.Y());
566 +         pnt = prop.Value();
567           (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl;
568  
569 -         prop->SetParameters (par1.X(), par1.Y());
570 -         pnt = prop->Value();
571 +         prop.SetParameters (par1.X(), par1.Y());
572 +         pnt = prop.Value();
573           (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl;
574  
575 -         prop->SetParameters (par2.X(), par2.Y());
576 -         pnt = prop->Value();
577 +         prop.SetParameters (par2.X(), par2.Y());
578 +         pnt = prop.Value();
579           (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl;
580         */
581        }
582 @@ -970,7 +975,7 @@
583         if (mparam.uselocalh)
584           {
585  
586 -           char * savetask = multithread.task;
587 +           const char * savetask = multithread.task;
588             multithread.percent = 0;
589  
590             mesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
591 @@ -1075,7 +1080,6 @@
592                 if (triangulation.IsNull()) continue;
593               
594                 BRepAdaptor_Surface sf(face, Standard_True);
595 -               BRepLProp_SLProps prop(sf, 2, 1e-5);
596                 
597                 int ntriangles = triangulation -> NbTriangles();
598                 for (int j = 1; j <= ntriangles; j++)
599 @@ -1096,7 +1100,7 @@
600                     maxside = max (maxside, p[1].Distance(p[2]));
601                     //cout << "\rFace " << i << " pos11 ntriangles " << ntriangles << " maxside " << maxside << flush;
602  
603 -                   RestrictHTriangle (par[0], par[1], par[2], &prop, *mesh, maxside, 0);
604 +                   RestrictHTriangle (par[0], par[1], par[2], sf, *mesh, maxside, 0);
605                     //cout << "\rFace " << i << " pos12 ntriangles " << ntriangles << flush;
606                   }
607               }
608 diff -Naur netgen-4.5.old/libsrc/occ/occgeom.cpp netgen-4.5.new/libsrc/occ/occgeom.cpp
609 --- netgen-4.5.old/libsrc/occ/occgeom.cpp       2006-01-25 16:35:50.000000000 +0300
610 +++ netgen-4.5.new/libsrc/occ/occgeom.cpp       2008-02-12 14:57:01.000000000 +0300
611 @@ -7,6 +7,8 @@
612  #include "ShapeAnalysis_ShapeContents.hxx"
613  #include "ShapeAnalysis_CheckSmallFace.hxx"
614  #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
615 +#include <ShapeAnalysis_Surface.hxx>
616 +#include <BRepTopAdaptor_FClass2d.hxx>
617  #include "BRepAlgoAPI_Fuse.hxx"
618  #include "BRepCheck_Analyzer.hxx"
619  #include "BRepLib.hxx"
620 @@ -16,11 +18,19 @@
621  #include "Partition_Spliter.hxx"
622  //#include "VrmlAPI.hxx"
623  //#include "StlAPI.hxx"
624 +#include <TopAbs_State.hxx>
625  
626  
627  namespace netgen
628  {
629  
630 +  OCCGeometry::~OCCGeometry()
631 +  {
632 +    NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
633 +    for (; it.More(); it.Next())
634 +      delete it.Value();
635 +  }
636 +
637    void OCCGeometry :: PrintNrShapes ()
638    {
639      TopExp_Explorer e;
640 @@ -947,13 +957,13 @@
641  
642    void OCCGeometry :: BuildVisualizationMesh ()
643    {
644 -
645 -    cout << "Preparing visualization (deflection = " << vispar.occdeflection << ") ... " << flush;
646 +    double vispar_occdeflection = 0.01;
647 +    cout << "Preparing visualization (deflection = " << vispar_occdeflection << ") ... " << flush;
648  
649  
650      BRepTools::Clean (shape);
651      //WriteOCC_STL("test.stl");
652 -    BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar.occdeflection, true);
653 +    BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar_occdeflection, true);
654      cout << "done" << endl;
655  
656  
657 @@ -973,8 +983,27 @@
658    
659    }
660  
661 +  void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
662 +                                 BRepTopAdaptor_FClass2d*& cls) const
663 +  {
664 +    //MSV: organize caching projector in the map
665 +    if (fprjmap.IsBound(surfi))
666 +    {
667 +      proj = fprjmap.Find(surfi);
668 +      cls = fclsmap.Find(surfi);
669 +    }
670 +    else
671 +    {
672 +      const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
673 +      Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
674 +      proj = new ShapeAnalysis_Surface(aSurf);
675 +      fprjmap.Bind(surfi, proj);
676 +      cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
677 +      fclsmap.Bind(surfi, cls);
678 +    }
679 +  }
680  
681 -  void OCCGeometry :: Project (int surfi, Point<3> & p) const
682 +  bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
683    {
684      static int cnt = 0;
685      if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
686 @@ -983,18 +1012,22 @@
687  
688      //(*testout) << "before " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl;
689  
690 -    GeomAPI_ProjectPointOnSurf proj(pnt, BRep_Tool::Surface(TopoDS::Face(fmap(surfi))));
691 -    if (proj.NbPoints() == 0)
692 -      {
693 -       cout << "Projection fails" << endl;
694 -      }
695 -    else
696 -      {
697 -       pnt = proj.NearestPoint();
698 -       //(*testout) << "after " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl;
699 +    Handle(ShapeAnalysis_Surface) proj;
700 +    BRepTopAdaptor_FClass2d *cls;
701 +    GetFaceTools(surfi, proj, cls);
702  
703 -       p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
704 -      }
705 +    gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
706 +    if (cls->Perform(p2d) == TopAbs_OUT)
707 +    {
708 +      //cout << "Projection fails" << endl;
709 +      return false;
710 +    }
711 +    pnt = proj->Value(p2d);
712 +    p2d.Coord(u, v);
713 +    //(*testout) << "after " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl;
714 +
715 +    p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
716 +    return true;
717    }
718  
719  
720 @@ -1002,54 +1035,20 @@
721    {
722      gp_Pnt p(ap(0), ap(1), ap(2));
723    
724 -    Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
725 +    Handle(ShapeAnalysis_Surface) proj;
726 +    BRepTopAdaptor_FClass2d *cls;
727 +    GetFaceTools(surfi, proj, cls);
728    
729 -    gp_Pnt x = surface->Value (u,v);
730 -  
731 -    if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
732 -  
733 -    gp_Vec du, dv;
734 -  
735 -    surface->D1(u,v,x,du,dv);
736 -  
737 -    int count = 0;
738 -  
739 -    gp_Pnt xold;
740 -    gp_Vec n;
741 -    double det, lambda, mu;
742 -  
743 -    do {
744 -      count++;
745 -  
746 -      n = du^dv;
747 -  
748 -      det = Det3 (n.X(), du.X(), dv.X(),
749 -                 n.Y(), du.Y(), dv.Y(),
750 -                 n.Z(), du.Z(), dv.Z());
751 -  
752 -      if (det < 1e-15) return false; 
753 -  
754 -      lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
755 -                    n.Y(), p.Y()-x.Y(), dv.Y(),
756 -                    n.Z(), p.Z()-x.Z(), dv.Z())/det;
757 -  
758 -      mu     = Det3 (n.X(), du.X(), p.X()-x.X(),
759 -                    n.Y(), du.Y(), p.Y()-x.Y(),
760 -                    n.Z(), du.Z(), p.Z()-x.Z())/det;
761 -    
762 -      u += lambda;
763 -      v += mu;
764 -  
765 -      xold = x;
766 -      surface->D1(u,v,x,du,dv);
767 -  
768 -    } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
769 -
770 -    //    (*testout) << "FastProject count: " << count << endl;
771 -  
772 -    if (count == 50) return false;
773 +    gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
774 +    if (cls->Perform(p2d) == TopAbs_OUT)
775 +    {
776 +      //cout << "Projection fails" << endl;
777 +      return false;
778 +    }
779    
780 -    ap = Point<3> (x.X(), x.Y(), x.Z());
781 +    p = proj->Value(p2d);
782 +    p2d.Coord(u, v);
783 +    ap = Point<3> (p.X(), p.Y(), p.Z());
784    
785      return true;
786    }
787 diff -Naur netgen-4.5.old/libsrc/occ/occgeom.hpp netgen-4.5.new/libsrc/occ/occgeom.hpp
788 --- netgen-4.5.old/libsrc/occ/occgeom.hpp       2006-01-25 16:35:50.000000000 +0300
789 +++ netgen-4.5.new/libsrc/occ/occgeom.hpp       2008-02-12 14:57:01.000000000 +0300
790 @@ -15,8 +15,6 @@
791  #include "Geom_Curve.hxx"
792  #include "Geom2d_Curve.hxx"
793  #include "Geom_Surface.hxx"
794 -#include "GeomAPI_ProjectPointOnSurf.hxx"
795 -#include "GeomAPI_ProjectPointOnCurve.hxx"
796  #include "BRepTools.hxx"
797  #include "TopExp.hxx"
798  #include "BRepBuilderAPI_MakeVertex.hxx"
799 @@ -41,8 +39,6 @@
800  #include "Geom_Curve.hxx"
801  #include "Geom2d_Curve.hxx"
802  #include "Geom_Surface.hxx"
803 -#include "GeomAPI_ProjectPointOnSurf.hxx"
804 -#include "GeomAPI_ProjectPointOnCurve.hxx"
805  #include "TopoDS_Wire.hxx"
806  #include "BRepTools_WireExplorer.hxx"
807  #include "BRepTools.hxx"
808 @@ -69,7 +65,7 @@
809  #include "IGESToBRep_Reader.hxx"
810  #include "Interface_Static.hxx"
811  #include "GeomAPI_ExtremaCurveCurve.hxx"
812 -#include "Standard_ErrorHandler.hxx"
813 +//#include "Standard_ErrorHandler.hxx"
814  #include "Standard_Failure.hxx"
815  #include "ShapeUpgrade_ShellSewing.hxx"
816  #include "ShapeFix_Shape.hxx"
817 @@ -84,11 +80,15 @@
818  #include "STEPControl_Writer.hxx"
819  #include "StlAPI_Writer.hxx"
820  #include "STEPControl_StepModelType.hxx"
821 +#include <NCollection_DataMap.hxx>
822 +
823 +class Handle_ShapeAnalysis_Surface;
824 +class BRepTopAdaptor_FClass2d;
825  
826  namespace netgen
827  {
828  
829 -#include "../visualization/vispar.hpp"
830 +  //#include "../visualization/vispar.hpp"
831    //  class VisualizationParameters;
832    //  extern VisualizationParameters vispar;
833  
834 @@ -159,6 +159,8 @@
835  class OCCGeometry
836  {
837    Point<3> center;
838 +  mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
839 +  mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
840  
841  public:
842    TopoDS_Shape shape;
843 @@ -189,6 +191,7 @@
844      vmap.Clear();
845    }
846  
847 +  ~OCCGeometry();
848  
849    void BuildFMap();
850  
851 @@ -204,10 +207,12 @@
852    Point<3> Center()
853    { return center; }
854  
855 -  void Project (int surfi, Point<3> & p) const;
856 +  bool Project (int surfi, Point<3> & p, double& u, double& v) const;
857    bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
858  
859
860 +  void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
861 +                    BRepTopAdaptor_FClass2d*& cls) const;
862 +
863    OCCSurface GetSurface (int surfi)
864    {
865      cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
866 diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.cpp netgen-4.5.new/libsrc/occ/occmeshsurf.cpp
867 --- netgen-4.5.old/libsrc/occ/occmeshsurf.cpp   2006-01-25 16:36:26.000000000 +0300
868 +++ netgen-4.5.new/libsrc/occ/occmeshsurf.cpp   2008-02-12 14:57:01.000000000 +0300
869 @@ -5,6 +5,8 @@
870  #include <occgeom.hpp>
871  #include <meshing.hpp>
872  #include <GeomLProp_SLProps.hxx>
873 +#include <GeomAPI_ProjectPointOnSurf.hxx>
874 +#include <GeomAPI_ProjectPointOnCurve.hxx>
875  
876  
877  namespace netgen
878 @@ -411,11 +413,16 @@
879    }
880  
881  
882 -  void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const
883 +  bool MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const
884    {
885      Point<3> hp = p;
886 -    geometry.Project (surfind, hp);
887 +    bool ok;
888 +    if (gi.trignum > 0)
889 +      ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
890 +    else
891 +      ok = geometry.Project (surfind, hp, gi.u, gi.v);
892      p = hp;
893 +    return ok;
894    }
895  
896    void MeshOptimize2dOCCSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2, 
897 @@ -506,38 +513,6 @@
898    }
899  
900  
901 -  int MeshOptimize2dOCCSurfaces :: 
902 -  CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point3d& p) const
903 -  {
904 -    Standard_Real u,v;
905 -
906 -    gp_Pnt pnt(p.X(), p.Y(), p.Z());
907 -
908 -    Handle(Geom_Surface) occface;
909 -    occface = BRep_Tool::Surface(TopoDS::Face(geometry.fmap(surfind)));
910 -
911 -    GeomAPI_ProjectPointOnSurf proj(pnt, occface);
912 -
913 -    if (proj.NbPoints() < 1)
914 -      {
915 -       cout << "ERROR: OCCSurface :: GetNormalVector: GeomAPI_ProjectPointOnSurf failed!"
916 -            << endl;
917 -       cout << p << endl;
918 -       return 0;
919 -      }
920
921 -    proj.LowerDistanceParameters (u, v);  
922 -
923 -    gi.u = u;
924 -    gi.v = v;
925 -    return 1;
926 -  }
927 -
928 -
929 -
930 -
931 -
932 -
933    OCCRefinementSurfaces :: OCCRefinementSurfaces (const OCCGeometry & ageometry)
934      : Refinement(), geometry(ageometry)
935    {
936 @@ -627,10 +602,11 @@
937         if (!geometry.FastProject (surfi, hnewp, u, v))
938           {
939             cout << "Fast projection to surface fails! Using OCC projection" << endl;
940 -           geometry.Project (surfi, hnewp);
941 +            double u, v;
942 +           geometry.Project (surfi, hnewp, u, v);
943           }
944  
945 -       newgi.trignum = 1;
946 +       newgi.trignum = surfi;
947        }
948    
949      newp = hnewp;
950 @@ -653,14 +629,17 @@
951      hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
952      newp = hnewp;
953      newgi = ap1;
954 -  };
955 +  }
956  
957  
958    void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
959    {
960      if (surfi > 0)
961 -      geometry.Project (surfi, p);
962 -  };
963 +    {
964 +      double u, v;
965 +      geometry.Project (surfi, p, u, v);
966 +    }
967 +  }
968  
969    void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
970    {
971 @@ -668,9 +647,10 @@
972        if (!geometry.FastProject (surfi, p, gi.u, gi.v))
973         {
974           cout << "Fast projection to surface fails! Using OCC projection" << endl;
975 -         geometry.Project (surfi, p);
976 +          double u, v;
977 +         geometry.Project (surfi, p, u, v);
978         }
979 -  };
980 +  }
981  
982  
983  
984 diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.hpp netgen-4.5.new/libsrc/occ/occmeshsurf.hpp
985 --- netgen-4.5.old/libsrc/occ/occmeshsurf.hpp   2005-06-09 18:51:10.000000000 +0400
986 +++ netgen-4.5.new/libsrc/occ/occmeshsurf.hpp   2008-02-12 14:57:01.000000000 +0300
987 @@ -151,7 +151,7 @@
988      MeshOptimize2dOCCSurfaces (const OCCGeometry & ageometry); 
989     
990      ///
991 -    virtual void ProjectPoint (INDEX surfind, Point3d & p) const;
992 +    virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const;
993      ///
994      virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const;
995      ///
996 @@ -159,9 +159,6 @@
997      ///
998      virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const;
999  
1000 -    
1001 -  virtual int CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point3d& p3) const;
1002 -
1003  };
1004  
1005  
1006 diff -Naur netgen-4.5.old/libsrc/stlgeom/meshstlsurface.cpp netgen-4.5.new/libsrc/stlgeom/meshstlsurface.cpp
1007 --- netgen-4.5.old/libsrc/stlgeom/meshstlsurface.cpp    2006-01-11 19:08:20.000000000 +0300
1008 +++ netgen-4.5.new/libsrc/stlgeom/meshstlsurface.cpp    2008-02-12 14:57:01.000000000 +0300
1009 @@ -946,20 +946,23 @@
1010  }
1011  
1012  
1013 -void MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point3d & p) const
1014 +bool MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const
1015  {
1016    Point<3> hp = p;
1017 -  if (!geom.Project (hp))
1018 +  if (gi.trignum > 0)
1019 +    ((STLGeometry&)geom).SelectChartOfTriangle (gi.trignum);
1020 +  if (!(gi.trignum = geom.Project (hp)))
1021      {
1022        PrintMessage(7,"project failed");
1023        
1024 -      if (!geom.ProjectOnWholeSurface(hp)) 
1025 +      if (!(gi.trignum = geom.ProjectOnWholeSurface(hp))) 
1026         {
1027           PrintMessage(7, "project on whole surface failed");
1028         }
1029      }
1030    p = hp;
1031    //  geometry.GetSurface(surfind)->Project (p);
1032 +  return gi.trignum > 0;
1033  }
1034  
1035  void MeshOptimizeSTLSurface :: ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const
1036 @@ -970,20 +973,6 @@
1037    */
1038  }
1039  
1040 -int  MeshOptimizeSTLSurface :: CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& p3) const
1041 -{
1042 -  Point<3> hp = p3;
1043 -  gi.trignum = geom.Project (hp);
1044 -
1045 -  if (gi.trignum)
1046 -    {
1047 -      return 1;
1048 -    }
1049 -
1050 -  return 0;
1051 -  
1052 -}
1053 -
1054  void MeshOptimizeSTLSurface :: GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const
1055  {
1056    n = geom.GetChartNormalVector();
1057 diff -Naur netgen-4.5.old/libsrc/stlgeom/meshstlsurface.hpp netgen-4.5.new/libsrc/stlgeom/meshstlsurface.hpp
1058 --- netgen-4.5.old/libsrc/stlgeom/meshstlsurface.hpp    2004-09-30 17:13:56.000000000 +0400
1059 +++ netgen-4.5.new/libsrc/stlgeom/meshstlsurface.hpp    2008-02-12 14:57:01.000000000 +0300
1060 @@ -79,12 +79,10 @@
1061      virtual void SelectSurfaceOfPoint (const Point3d & p,
1062                                        const PointGeomInfo & gi);
1063      ///
1064 -    virtual void ProjectPoint (INDEX surfind, Point3d & p) const;
1065 +    virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const;
1066      ///
1067      virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const;
1068      ///
1069 -    virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& p3) const;
1070 -    ///
1071      virtual void GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const;
1072  };
1073  
1074 diff -Naur netgen-4.5.old/makeForSalome.sh netgen-4.5.new/makeForSalome.sh
1075 --- netgen-4.5.old/makeForSalome.sh     1970-01-01 03:00:00.000000000 +0300
1076 +++ netgen-4.5.new/makeForSalome.sh     2008-02-12 14:57:01.000000000 +0300
1077 @@ -0,0 +1,31 @@
1078 +#! /bin/sh
1079 +cp ngtcltk/ngnewdelete.* libsrc/interface/
1080 +
1081 +MACHINE=LINUX
1082 +export MACHINE
1083 +make -C libsrc/csg
1084 +make -C libsrc/general
1085 +make -C libsrc/geom2d
1086 +make -C libsrc/gprim
1087 +make -C libsrc/interface
1088 +make -C libsrc/linalg
1089 +make -C libsrc/meshing
1090 +make -C libsrc/opti
1091 +make -C libsrc/stlgeom
1092 +make -C libsrc/occ
1093 +
1094 +if [ ! -d install ] ; then
1095 +       mkdir install
1096 +fi
1097 +
1098 +cp -r lib install/
1099 +
1100 +if [ ! -d install/include ] ; then
1101 +       mkdir install/include
1102 +fi
1103 +
1104 +cp libsrc/interface/nglib.h libsrc/general/*.hpp libsrc/csg/*.hpp libsrc/geom2d/*.hpp \
1105 +    libsrc/gprim/*.hpp libsrc/linalg/*.hpp libsrc/meshing/*.hpp \
1106 +    libsrc/occ/*.hpp libsrc/opti/*.hpp libsrc/include/mydefs.hpp \
1107 +    libsrc/stlgeom/*.hpp libsrc/include/mystdlib.h \
1108 +    install/include
1109 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Inter2d.cxx netgen-4.5.new/libsrc/occ/Partition_Inter2d.cxx
1110 --- netgen-4.5.old/libsrc/occ/Partition_Inter2d.cxx     2005-06-09 18:51:10.000000000 +0400
1111 +++ netgen-4.5.new/libsrc/occ/Partition_Inter2d.cxx     2008-02-26 12:34:14.000000000 +0300
1112 @@ -29,10 +29,10 @@
1113  //  $Header$
1114  
1115  //using namespace std;
1116 -#include "Partition_Inter2d.ixx"
1117 -
1118  #include "utilities.h"
1119  
1120 +#include "Partition_Inter2d.ixx"
1121 +
1122  #include <BRepAdaptor_Curve.hxx>
1123  #include <BRepAlgo_AsDes.hxx>
1124  #include <BRepLib_MakeVertex.hxx>
1125 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Inter3d.cxx netgen-4.5.new/libsrc/occ/Partition_Inter3d.cxx
1126 --- netgen-4.5.old/libsrc/occ/Partition_Inter3d.cxx     2005-06-09 18:51:10.000000000 +0400
1127 +++ netgen-4.5.new/libsrc/occ/Partition_Inter3d.cxx     2008-02-26 12:36:27.000000000 +0300
1128 @@ -29,13 +29,17 @@
1129  //  $Header$
1130  
1131  //using namespace std;
1132 +
1133 +#include "utilities.h"
1134 +
1135  #include "Partition_Inter2d.hxx"
1136  #include "Partition_Inter3d.ixx"
1137 -#include "utilities.h"
1138  
1139  #include <BRepAlgo_AsDes.hxx>
1140  #include <BRepAlgo_Image.hxx>
1141  #include <BRepLib.hxx>
1142 +//using namespace std;
1143 +
1144  #include <BRepOffset_Tool.hxx>
1145  #include <BRep_Builder.hxx>
1146  #include <BRep_Tool.hxx>
1147 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop2d.cxx netgen-4.5.new/libsrc/occ/Partition_Loop2d.cxx
1148 --- netgen-4.5.old/libsrc/occ/Partition_Loop2d.cxx      2005-06-09 18:51:10.000000000 +0400
1149 +++ netgen-4.5.new/libsrc/occ/Partition_Loop2d.cxx      2008-02-26 12:37:10.000000000 +0300
1150 @@ -12,9 +12,11 @@
1151  //  $Header$
1152  
1153  //using namespace std;
1154 -#include "Partition_Loop2d.ixx"
1155 +
1156  
1157  #include "utilities.h"
1158 +
1159 +#include "Partition_Loop2d.ixx"
1160  #include <stdio.h>
1161  
1162  #include <BRepAdaptor_Curve2d.hxx>
1163 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop3d.cxx netgen-4.5.new/libsrc/occ/Partition_Loop3d.cxx
1164 --- netgen-4.5.old/libsrc/occ/Partition_Loop3d.cxx      2005-06-09 18:51:10.000000000 +0400
1165 +++ netgen-4.5.new/libsrc/occ/Partition_Loop3d.cxx      2008-02-26 12:39:32.000000000 +0300
1166 @@ -10,6 +10,11 @@
1167  //  Module : GEOM
1168  
1169  //using namespace std;
1170 +
1171 +
1172 +
1173 +#include "utilities.h"
1174 +
1175  #include "Partition_Loop3d.ixx"
1176  
1177  #include <TopExp_Explorer.hxx>
1178 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop.cxx netgen-4.5.new/libsrc/occ/Partition_Loop.cxx
1179 --- netgen-4.5.old/libsrc/occ/Partition_Loop.cxx        2005-06-09 18:51:10.000000000 +0400
1180 +++ netgen-4.5.new/libsrc/occ/Partition_Loop.cxx        2008-02-26 12:40:41.000000000 +0300
1181 @@ -29,12 +29,14 @@
1182  //  $Header$
1183  
1184  //using namespace std;
1185 -#include <stdio.h>
1186  
1187 -#include "Partition_Loop.ixx"
1188  
1189  #include "utilities.h"
1190  
1191 +#include <stdio.h>
1192 +
1193 +#include "Partition_Loop.ixx"
1194 +
1195  #include <BRep_Builder.hxx>
1196  #include <BRepAlgo_FaceRestrictor.hxx>
1197  #include <BRep_Tool.hxx>
1198 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Spliter.cxx netgen-4.5.new/libsrc/occ/Partition_Spliter.cxx
1199 --- netgen-4.5.old/libsrc/occ/Partition_Spliter.cxx     2005-07-11 10:33:27.000000000 +0400
1200 +++ netgen-4.5.new/libsrc/occ/Partition_Spliter.cxx     2008-02-26 12:41:32.000000000 +0300
1201 @@ -29,14 +29,15 @@
1202  //  $Header$
1203  
1204  //using namespace std;
1205 +
1206 +#include "utilities.h"
1207 +
1208  #include "Partition_Inter2d.hxx"
1209  #include "Partition_Inter3d.hxx"
1210  #include "Partition_Loop2d.hxx"
1211  #include "Partition_Loop3d.hxx"
1212  #include "Partition_Spliter.ixx"
1213  
1214 -#include "utilities.h"
1215 -
1216  #include <Precision.hxx>
1217  #include <TopAbs_Orientation.hxx>
1218  #include <TopExp.hxx>
1219 diff -Naur netgen-4.5.old/libsrc/occ/utilities.h netgen-4.5.new/libsrc/occ/utilities.h
1220 --- netgen-4.5.old/libsrc/occ/utilities.h       2005-02-11 14:35:43.000000000 +0300
1221 +++ netgen-4.5.new/libsrc/occ/utilities.h       2008-02-26 12:28:02.000000000 +0300
1222 @@ -33,6 +33,7 @@
1223  
1224  #include <string>
1225  #include <iostream>
1226 +#include <iomanip>
1227  #include <cstdlib>
1228  // #include "SALOME_Log.hxx"
1229
1230 diff -Naur netgen-4.5.old/libsrc/general/profiler.cpp netgen-4.5.new/libsrc/general/profiler.cpp
1231 --- netgen-4.5.old/libsrc/general/profiler.cpp  2006-01-11 13:05:59.000000000 +0300
1232 +++ netgen-4.5.new/libsrc/general/profiler.cpp  2009-05-28 18:47:00.000000000 +0400
1233 @@ -35,7 +35,10 @@
1234      StopTimer (total_timer);
1235
1236      ofstream prof ("netgen.prof");
1237 -    Print (prof);
1238 +
1239 +    ostream& pprof = getenv("NETGEN_PROF") ? prof : std::cout;
1240 +
1241 +    Print (pprof);
1242    }
1243
1244
1245 diff -Naur netgen-4.5.old/libsrc/meshing/meshtype.hpp netgen-4.5.new/libsrc/meshing/meshtype.hpp
1246 --- netgen-4.5.old/libsrc/meshing/meshtype.hpp  2009-05-28 19:22:04.000000000 +0400
1247 +++ netgen-4.5.new/libsrc/meshing/meshtype.hpp  2009-05-28 18:37:18.000000000 +0400
1248 @@ -13,7 +13,7 @@
1249      Classes for NETGEN
1250  */
1251  
1252 -
1253 +class Mesh;
1254  enum ELEMENT_TYPE { 
1255    SEGMENT = 1, SEGMENT3 = 2,
1256    TRIG = 10, QUAD=11, TRIG6 = 12, QUAD6 = 13, QUAD8 = 14,