8fe3486
diff -rupN netgen-5.1/libsrc/meshing/meshtype.cpp netgen-5.1-new/libsrc/meshing/meshtype.cpp
8fe3486
--- netgen-5.1/libsrc/meshing/meshtype.cpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/meshing/meshtype.cpp	2014-06-13 19:54:42.968358572 +0200
8fe3486
@@ -1,4 +1,5 @@
8fe3486
 #include <mystdlib.h>
8fe3486
+#include <float.h> // to get DBL_MIN defined
8fe3486
 
8fe3486
 #include "meshing.hpp"  
8fe3486
 
8fe3486
@@ -666,7 +667,8 @@ namespace netgen
8fe3486
 
8fe3486
         double det = trans.Det();
8fe3486
 
8fe3486
-        if (det <= 0)
8fe3486
+        // if (det <= 0)
8fe3486
+        if (det <= DBL_MIN) // avoid FPE
8fe3486
           err += 1e12;
8fe3486
         else
8fe3486
           err += frob * frob / det;
8fe3486
@@ -722,7 +724,8 @@ namespace netgen
8fe3486
 
8fe3486
             double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
8fe3486
 
8fe3486
-            if (det <= 0)
8fe3486
+            // if (det <= 0)
8fe3486
+            if (det <= DBL_MIN)  // avoid FPE
8fe3486
               {
8fe3486
                 dd = 0;
8fe3486
                 return 1e12;
8fe3486
@@ -806,7 +809,8 @@ namespace netgen
8fe3486
           = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0)
8fe3486
           + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0);
8fe3486
 
8fe3486
-        if (det <= 0)
8fe3486
+        // if (det <= 0)
8fe3486
+        if (det <= DBL_MIN) // avoid FPE
8fe3486
           err += 1e12;
8fe3486
         else
8fe3486
           {
8fe3486
@@ -856,7 +860,8 @@ namespace netgen
8fe3486
         frob /= 2;
8fe3486
 
8fe3486
         double det = trans.Det();
8fe3486
-        if (det <= 0)
8fe3486
+        //if (det <= 0)
8fe3486
+        if (det <= DBL_MIN) // avoid FPE
8fe3486
           err += 1e12;
8fe3486
         else
8fe3486
           err += frob * frob / det;
8fe3486
@@ -1864,7 +1869,8 @@ namespace netgen
8fe3486
       case PYRAMID:
8fe3486
         {
8fe3486
           double noz = 1-p(2);
8fe3486
-          if (noz == 0.0) noz = 1e-10;
8fe3486
+          //if (noz == 0.0) noz = 1e-10;
8fe3486
+          if (noz <= DBL_MIN) noz = 1e-10; // avoid FPE
8fe3486
 
8fe3486
           double xi  = p(0) / noz;
8fe3486
           double eta = p(1) / noz;
8fe3486
@@ -2030,7 +2036,8 @@ namespace netgen
8fe3486
 
8fe3486
         double det = -trans.Det();
8fe3486
       
8fe3486
-        if (det <= 0)
8fe3486
+        //if (det <= 0)
8fe3486
+        if (det <= DBL_MIN) // avoid FPE
8fe3486
           err += 1e12;
8fe3486
         else
8fe3486
           err += frob * frob * frob / det;
8fe3486
@@ -2102,7 +2109,8 @@ namespace netgen
8fe3486
         ddet *= -1;
8fe3486
 
8fe3486
       
8fe3486
-        if (det <= 0)
8fe3486
+        //if (det <= 0)
8fe3486
+        if (det <= DBL_MIN) // avoid FPE
8fe3486
           err += 1e12;
8fe3486
         else
8fe3486
           {
8fe3486
@@ -2184,7 +2192,7 @@ namespace netgen
8fe3486
       
8fe3486
         det *= -1;
8fe3486
       
8fe3486
-        if (det <= 0)
8fe3486
+        if (det <= DBL_MIN)
8fe3486
           err += 1e12;
8fe3486
         else
8fe3486
           {
8fe3486
@@ -2513,10 +2521,10 @@ namespace netgen
8fe3486
 
8fe3486
   MeshingParameters :: MeshingParameters ()
8fe3486
   {
8fe3486
-    optimize3d = "cmdmustm";
8fe3486
+    optimize3d = (char*)"cmdmustm"; // optimize3d = "cmdmustm";
8fe3486
     //optimize3d = "cmdmstm";
8fe3486
     optsteps3d = 3;
8fe3486
-    optimize2d = "smsmsmSmSmSm";
8fe3486
+    optimize2d = (char*)"smsmsmSmSmSm"; // optimize2d = "smsmsmSmSmSm";
8fe3486
     optsteps2d = 3;
8fe3486
     opterrpow = 2;
8fe3486
     blockfill = 1;
8fe3486
diff -rupN netgen-5.1/libsrc/meshing/meshtype.hpp netgen-5.1-new/libsrc/meshing/meshtype.hpp
8fe3486
--- netgen-5.1/libsrc/meshing/meshtype.hpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/meshing/meshtype.hpp	2014-06-13 19:54:42.969358572 +0200
8fe3486
@@ -15,6 +15,7 @@ namespace netgen
8fe3486
     Classes for NETGEN
8fe3486
   */
8fe3486
 
8fe3486
+class Mesh; // added due to compilation errors on some platforms
8fe3486
 
8fe3486
 
8fe3486
   enum ELEMENT_TYPE { 
8fe3486
diff -rupN netgen-5.1/libsrc/meshing/smoothing2.cpp netgen-5.1-new/libsrc/meshing/smoothing2.cpp
8fe3486
--- netgen-5.1/libsrc/meshing/smoothing2.cpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/meshing/smoothing2.cpp	2014-06-13 19:54:42.969358572 +0200
8fe3486
@@ -361,7 +361,8 @@ namespace netgen
8fe3486
     vgrad = 0;
8fe3486
     double badness = 0;
8fe3486
 
8fe3486
-    ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
8fe3486
+    //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
8fe3486
+    n = ld.normal;
8fe3486
     pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
8fe3486
 
8fe3486
     //  meshthis -> ProjectPoint (surfi, pp1);
8fe3486
@@ -577,7 +578,8 @@ namespace netgen
8fe3486
     vgrad = 0;
8fe3486
     badness = 0;
8fe3486
 
8fe3486
-    ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
8fe3486
+    //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
8fe3486
+    n = ld.normal;
8fe3486
 
8fe3486
     pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
8fe3486
 
8fe3486
@@ -649,7 +651,8 @@ namespace netgen
8fe3486
     vgrad = 0;
8fe3486
     badness = 0;
8fe3486
 
8fe3486
-    ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
8fe3486
+    //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
8fe3486
+    n = ld.normal;
8fe3486
 
8fe3486
     // pp1 = sp1;
8fe3486
     //    pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
8fe3486
@@ -1079,7 +1082,7 @@ namespace netgen
8fe3486
 		{
8fe3486
 		  mesh[pi] = Point<3> (origp);
8fe3486
 		}
8fe3486
-	    
8fe3486
+	      break; // exit as <fact> is not used anymore
8fe3486
 	    }
8fe3486
 	}
8fe3486
       }
8fe3486
diff -rupN netgen-5.1/libsrc/occ/occconstruction.cpp netgen-5.1-new/libsrc/occ/occconstruction.cpp
8fe3486
--- netgen-5.1/libsrc/occ/occconstruction.cpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/occconstruction.cpp	2014-06-13 19:54:42.970358572 +0200
8fe3486
@@ -28,7 +28,7 @@
8fe3486
 #include <BRepAlgoAPI_Common.hxx>
8fe3486
 #include <BRepAlgoAPI_Fuse.hxx>
8fe3486
 #include <BRepAlgoAPI_Section.hxx>
8fe3486
-#include <BRepOffsetAPI_Sewing.hxx>
8fe3486
+//#include <BRepOffsetAPI_Sewing.hxx>
8fe3486
 //#include <BRepAlgo_Sewing.hxx>
8fe3486
 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
8fe3486
 #include <ShapeFix_Shape.hxx>
8fe3486
diff -rupN netgen-5.1/libsrc/occ/occgenmesh.cpp netgen-5.1-new/libsrc/occ/occgenmesh.cpp
8fe3486
--- netgen-5.1/libsrc/occ/occgenmesh.cpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/occgenmesh.cpp	2014-06-13 19:54:42.971358572 +0200
8fe3486
@@ -57,6 +57,8 @@ namespace netgen
8fe3486
 
8fe3486
 
8fe3486
 
8fe3486
+   
8fe3486
+   static // useless out of this file
8fe3486
    double ComputeH (double kappa)
8fe3486
    {
8fe3486
       double hret;
8fe3486
@@ -74,8 +76,7 @@ namespace netgen
8fe3486
    }
8fe3486
 
8fe3486
 
8fe3486
-
8fe3486
-
8fe3486
+   static // useless out of this file
8fe3486
    void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
8fe3486
                            BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
8fe3486
    {
8fe3486
@@ -171,8 +172,8 @@ namespace netgen
8fe3486
          if(h < 1e-4*maxside)
8fe3486
             return;
8fe3486
 
8fe3486
-
8fe3486
-         if (h > 30) return;
8fe3486
+         // commented to restrict H on a large sphere for example
8fe3486
+         //if (h > 30) return;
8fe3486
       }
8fe3486
 
8fe3486
       if (h < maxside && depth < 10)
8fe3486
@@ -231,6 +232,7 @@ namespace netgen
8fe3486
 
8fe3486
 
8fe3486
 
8fe3486
+   static // useless out of this file
8fe3486
    void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
8fe3486
                     Array<double> & params, Mesh & mesh)
8fe3486
    {
8fe3486
@@ -250,8 +252,8 @@ namespace netgen
8fe3486
       hvalue[0] = 0;
8fe3486
       pnt = c->Value(s0);
8fe3486
 
8fe3486
-      double olddist = 0;
8fe3486
-      double dist = 0;
8fe3486
+      //double olddist = 0; -- useless variables
8fe3486
+      //double dist = 0;
8fe3486
 
8fe3486
       int tmpVal = (int)(DIVIDEEDGESECTIONS);
8fe3486
 
8fe3486
@@ -259,15 +261,19 @@ namespace netgen
8fe3486
       {
8fe3486
          oldpnt = pnt;
8fe3486
          pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
8fe3486
+         // -- no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
8fe3486
          hvalue[i] = hvalue[i-1] +
8fe3486
-            1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
8fe3486
-            pnt.Distance(oldpnt);
8fe3486
+         //   1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
8fe3486
+         //   pnt.Distance(oldpnt);
8fe3486
+           min( 1.0,
8fe3486
+                1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
8fe3486
+                pnt.Distance(oldpnt));
8fe3486
 
8fe3486
          //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
8fe3486
          //	   <<  " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
8fe3486
 
8fe3486
-         olddist = dist;
8fe3486
-         dist = pnt.Distance(oldpnt);
8fe3486
+         //olddist = dist; -- useless variables
8fe3486
+         //dist = pnt.Distance(oldpnt);
8fe3486
       }
8fe3486
 
8fe3486
       //  nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
8fe3486
@@ -282,7 +288,10 @@ namespace netgen
8fe3486
       {
8fe3486
          if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
8fe3486
          {
8fe3486
-            params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
8fe3486
+            // -- for nsubedges comparable to DIVIDEEDGESECTIONS
8fe3486
+            //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
8fe3486
+            double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
8fe3486
+            params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
8fe3486
             pnt = c->Value(params[i]);
8fe3486
             ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
8fe3486
             i++;
8fe3486
@@ -326,6 +335,7 @@ namespace netgen
8fe3486
       (*testout) << "nedges = " << nedges << endl;
8fe3486
 
8fe3486
       double eps = 1e-6 * geom.GetBoundingBox().Diam();
8fe3486
+      const double eps2 = eps * eps; // -- small optimization
8fe3486
 
8fe3486
       for (int i = 1; i <= nvertices; i++)
8fe3486
       {
8fe3486
@@ -335,7 +345,8 @@ namespace netgen
8fe3486
          bool exists = 0;
8fe3486
          if (merge_solids)
8fe3486
             for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
8fe3486
-               if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
8fe3486
+               //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)              
8fe3486
+               if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
8fe3486
                {
8fe3486
                   exists = 1;
8fe3486
                   break;
8fe3486
@@ -365,6 +376,7 @@ namespace netgen
8fe3486
          {
8fe3486
             TopoDS_Face face = TopoDS::Face(exp1.Current());
8fe3486
             int facenr = geom.fmap.FindIndex(face);
8fe3486
+            if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
8fe3486
 
8fe3486
             if (face2solid[0][facenr-1] == 0)
8fe3486
                face2solid[0][facenr-1] = solidnr;
8fe3486
@@ -384,6 +396,7 @@ namespace netgen
8fe3486
       int facenr = 0;
8fe3486
       int edgenr = 0;
8fe3486
 
8fe3486
+      edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
8fe3486
 
8fe3486
       (*testout) << "faces = " << geom.fmap.Extent() << endl;
8fe3486
       int curr = 0;
8fe3486
@@ -445,6 +458,7 @@ namespace netgen
8fe3486
                   //(*testout) << "ignoring degenerated edge" << endl;
8fe3486
                   continue;
8fe3486
                }
8fe3486
+               if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
8fe3486
 
8fe3486
                if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
8fe3486
                   geom.vmap.FindIndex(TopExp::LastVertex (edge)))
8fe3486
@@ -482,15 +496,64 @@ namespace netgen
8fe3486
                }
8fe3486
                else
8fe3486
                {
8fe3486
-                  Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
8fe3486
-                  Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
8fe3486
+                 TopoDS_Iterator vIt( edge, false );
8fe3486
+                 TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
8fe3486
+                 TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
8fe3486
+                 if ( v1.Orientation() == TopAbs_REVERSED )
8fe3486
+                   std::swap( v1, v2 );
8fe3486
+                 const bool isClosedEdge = v1.IsSame( v2 );
8fe3486
+                 
8fe3486
+                  Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
8fe3486
+                  Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
8fe3486
+                  double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
8fe3486
+                  if ( isClosedEdge )
8fe3486
+                    tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
8fe3486
 
8fe3486
                   pnums[0] = -1;
8fe3486
                   pnums.Last() = -1;
8fe3486
                   for (PointIndex pi = 1; pi < first_ep; pi++)
8fe3486
                   {
8fe3486
-                     if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
8fe3486
-                     if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
8fe3486
+                    if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
8fe3486
+                    if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
8fe3486
+                  }
8fe3486
+                  if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
8fe3486
+                      ( !isClosedEdge && pnums[0] == pnums.Last() ))
8fe3486
+                    pnums[0] = pnums.Last() = -1;
8fe3486
+                  if ( pnums[0] == -1 || pnums.Last() == -1 )
8fe3486
+                  {
8fe3486
+                    // take into account a possible large gap between a vertex and an edge curve
8fe3486
+                    // end and a large vertex tolerance covering the whole edge
8fe3486
+                    if ( pnums[0] == -1 )
8fe3486
+                    {
8fe3486
+                      double tol = BRep_Tool::Tolerance( v1 );
8fe3486
+                      for (PointIndex pi = 1; pi < first_ep; pi++)
8fe3486
+                        if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
8fe3486
+                          pnums[0] = pi;
8fe3486
+
8fe3486
+                      if ( pnums[0] == -1 )
8fe3486
+                        pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
8fe3486
+                    }
8fe3486
+                    if ( isClosedEdge )
8fe3486
+                    {
8fe3486
+                      pnums.Last() = pnums[0];
8fe3486
+                    }
8fe3486
+                    else
8fe3486
+                    {
8fe3486
+                      if ( pnums.Last() == -1 )
8fe3486
+                      {
8fe3486
+                        double tol = BRep_Tool::Tolerance( v2 );
8fe3486
+                        for (PointIndex pi = 1; pi < first_ep; pi++)
8fe3486
+                          if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
8fe3486
+                            pnums.Last() = pi;
8fe3486
+
8fe3486
+                        if ( pnums.Last() == -1 )
8fe3486
+                          pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
8fe3486
+                      }
8fe3486
+
8fe3486
+                      if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
8fe3486
+                           Dist2( lp, mesh[PointIndex(pnums.Last())]))
8fe3486
+                      std::swap( pnums[0], pnums.Last() );
8fe3486
+                    }
8fe3486
                   }
8fe3486
                }
8fe3486
 
8fe3486
@@ -1458,3 +1521,4 @@ namespace netgen
8fe3486
 }
8fe3486
 
8fe3486
 #endif
8fe3486
+
8fe3486
diff -rupN netgen-5.1/libsrc/occ/occgeom.cpp netgen-5.1-new/libsrc/occ/occgeom.cpp
8fe3486
--- netgen-5.1/libsrc/occ/occgeom.cpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/occgeom.cpp	2014-06-13 19:54:42.971358572 +0200
8fe3486
@@ -8,6 +8,8 @@
8fe3486
 #include "ShapeAnalysis_CheckSmallFace.hxx"
8fe3486
 #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
8fe3486
 #include "ShapeAnalysis_Surface.hxx"
8fe3486
+#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
8fe3486
+#include <TopAbs_State.hxx>
8fe3486
 #include "BRepAlgoAPI_Fuse.hxx"
8fe3486
 #include "BRepCheck_Analyzer.hxx"
8fe3486
 #include "BRepLib.hxx"
8fe3486
@@ -16,10 +18,17 @@
8fe3486
 #include "ShapeFix_FixSmallFace.hxx"
8fe3486
 #include "Partition_Spliter.hxx"
8fe3486
 
8fe3486
-
8fe3486
 namespace netgen
8fe3486
 {
8fe3486
-   void OCCGeometry :: PrintNrShapes ()
8fe3486
+  // free data used to optimize Project() and FastProject()
8fe3486
+  OCCGeometry::~OCCGeometry()
8fe3486
+  {
8fe3486
+    NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
8fe3486
+    for (; it.More(); it.Next())
8fe3486
+      delete it.Value();
8fe3486
+  }
8fe3486
+
8fe3486
+  void OCCGeometry :: PrintNrShapes ()
8fe3486
    {
8fe3486
       TopExp_Explorer e;
8fe3486
       int count = 0;
8fe3486
@@ -951,25 +960,58 @@ namespace netgen
8fe3486
    }
8fe3486
 
8fe3486
 
8fe3486
+   // returns a projector and a classifier for the given surface
8fe3486
+   void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
8fe3486
+                                  BRepTopAdaptor_FClass2d*& cls) const
8fe3486
+   {
8fe3486
+     //MSV: organize caching projector in the map
8fe3486
+     if (fprjmap.IsBound(surfi))
8fe3486
+     {
8fe3486
+       proj = fprjmap.Find(surfi);
8fe3486
+       cls = fclsmap.Find(surfi);
8fe3486
+     }
8fe3486
+     else
8fe3486
+     {
8fe3486
+       const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
8fe3486
+       Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
8fe3486
+       proj = new ShapeAnalysis_Surface(aSurf);
8fe3486
+       fprjmap.Bind(surfi, proj);
8fe3486
+       cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
8fe3486
+       fclsmap.Bind(surfi, cls);
8fe3486
+     }
8fe3486
+   }
8fe3486
 
8fe3486
-
8fe3486
-   void OCCGeometry :: Project (int surfi, Point<3> & p) const
8fe3486
+   // void OCCGeometry :: Project (int surfi, Point<3> & p) const
8fe3486
+   bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
8fe3486
    {
8fe3486
       static int cnt = 0;
8fe3486
       if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
8fe3486
 
8fe3486
       gp_Pnt pnt(p(0), p(1), p(2));
8fe3486
 
8fe3486
-      double u,v;
8fe3486
-      Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
8fe3486
-      Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
8fe3486
-      gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
8fe3486
-      suval.Coord( u, v);
8fe3486
-      pnt = thesurf->Value( u, v );
8fe3486
-
8fe3486
-
8fe3486
+      // -- Optimization: use cached projector and classifier
8fe3486
+      // double u,v;
8fe3486
+      // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
8fe3486
+      // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
8fe3486
+      // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
8fe3486
+      // suval.Coord( u, v);
8fe3486
+      // pnt = thesurf->Value( u, v );  
8fe3486
+
8fe3486
+      Handle(ShapeAnalysis_Surface) proj;
8fe3486
+      BRepTopAdaptor_FClass2d *cls;
8fe3486
+      GetFaceTools(surfi, proj, cls);
8fe3486
+  
8fe3486
+      gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
8fe3486
+      if (cls->Perform(p2d) == TopAbs_OUT)
8fe3486
+      {
8fe3486
+        return false;
8fe3486
+      }
8fe3486
+      pnt = proj->Value(p2d);
8fe3486
+      p2d.Coord(u, v);
8fe3486
+  
8fe3486
       p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
8fe3486
 
8fe3486
+      return true;
8fe3486
    }
8fe3486
 
8fe3486
 
8fe3486
@@ -979,54 +1021,69 @@ namespace netgen
8fe3486
    {
8fe3486
       gp_Pnt p(ap(0), ap(1), ap(2));
8fe3486
 
8fe3486
-      Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
8fe3486
-
8fe3486
-      gp_Pnt x = surface->Value (u,v);
8fe3486
-
8fe3486
-      if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
8fe3486
-
8fe3486
-      gp_Vec du, dv;
8fe3486
-
8fe3486
-      surface->D1(u,v,x,du,dv);
8fe3486
-
8fe3486
-      int count = 0;
8fe3486
-
8fe3486
-      gp_Pnt xold;
8fe3486
-      gp_Vec n;
8fe3486
-      double det, lambda, mu;
8fe3486
-
8fe3486
-      do {
8fe3486
-         count++;
8fe3486
-
8fe3486
-         n = du^dv;
8fe3486
-
8fe3486
-         det = Det3 (n.X(), du.X(), dv.X(),
8fe3486
-            n.Y(), du.Y(), dv.Y(),
8fe3486
-            n.Z(), du.Z(), dv.Z());
8fe3486
-
8fe3486
-         if (det < 1e-15) return false;
8fe3486
-
8fe3486
-         lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
8fe3486
-            n.Y(), p.Y()-x.Y(), dv.Y(),
8fe3486
-            n.Z(), p.Z()-x.Z(), dv.Z())/det;
8fe3486
-
8fe3486
-         mu     = Det3 (n.X(), du.X(), p.X()-x.X(),
8fe3486
-            n.Y(), du.Y(), p.Y()-x.Y(),
8fe3486
-            n.Z(), du.Z(), p.Z()-x.Z())/det;
8fe3486
-
8fe3486
-         u += lambda;
8fe3486
-         v += mu;
8fe3486
-
8fe3486
-         xold = x;
8fe3486
-         surface->D1(u,v,x,du,dv);
8fe3486
-
8fe3486
-      } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
8fe3486
-
8fe3486
-      //    (*testout) << "FastProject count: " << count << endl;
8fe3486
-
8fe3486
-      if (count == 50) return false;
8fe3486
-
8fe3486
-      ap = Point<3> (x.X(), x.Y(), x.Z());
8fe3486
+      // -- Optimization: use cached projector and classifier
8fe3486
+      // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
8fe3486
+      // 
8fe3486
+      // gp_Pnt x = surface->Value (u,v);
8fe3486
+      // 
8fe3486
+      // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
8fe3486
+      // 
8fe3486
+      // gp_Vec du, dv;
8fe3486
+      // 
8fe3486
+      // surface->D1(u,v,x,du,dv);
8fe3486
+      // 
8fe3486
+      // int count = 0;
8fe3486
+      // 
8fe3486
+      // gp_Pnt xold;
8fe3486
+      // gp_Vec n;
8fe3486
+      // double det, lambda, mu;
8fe3486
+      // 
8fe3486
+      // do {
8fe3486
+      //    count++;
8fe3486
+      // 
8fe3486
+      //    n = du^dv;
8fe3486
+      // 
8fe3486
+      //    det = Det3 (n.X(), du.X(), dv.X(),
8fe3486
+      //       n.Y(), du.Y(), dv.Y(),
8fe3486
+      //       n.Z(), du.Z(), dv.Z());
8fe3486
+      // 
8fe3486
+      //    if (det < 1e-15) return false;
8fe3486
+      // 
8fe3486
+      //    lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
8fe3486
+      //       n.Y(), p.Y()-x.Y(), dv.Y(),
8fe3486
+      //       n.Z(), p.Z()-x.Z(), dv.Z())/det;
8fe3486
+      // 
8fe3486
+      //    mu     = Det3 (n.X(), du.X(), p.X()-x.X(),
8fe3486
+      //       n.Y(), du.Y(), p.Y()-x.Y(),
8fe3486
+      //       n.Z(), du.Z(), p.Z()-x.Z())/det;
8fe3486
+      // 
8fe3486
+      //    u += lambda;
8fe3486
+      //    v += mu;
8fe3486
+      // 
8fe3486
+      //    xold = x;
8fe3486
+      //    surface->D1(u,v,x,du,dv);
8fe3486
+      // 
8fe3486
+      // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
8fe3486
+      // 
8fe3486
+      // //    (*testout) << "FastProject count: " << count << endl;
8fe3486
+      // 
8fe3486
+      // if (count == 50) return false;
8fe3486
+      // 
8fe3486
+      // ap = Point<3> (x.X(), x.Y(), x.Z());
8fe3486
+      Handle(ShapeAnalysis_Surface) proj;
8fe3486
+      BRepTopAdaptor_FClass2d *cls;
8fe3486
+      GetFaceTools(surfi, proj, cls);
8fe3486
+    
8fe3486
+      gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
8fe3486
+      if (cls->Perform(p2d) == TopAbs_OUT)
8fe3486
+      {
8fe3486
+        //cout << "Projection fails" << endl;
8fe3486
+        return false;
8fe3486
+      }
8fe3486
+    
8fe3486
+      p = proj->Value(p2d);
8fe3486
+      p2d.Coord(u, v);
8fe3486
+      ap = Point<3> (p.X(), p.Y(), p.Z());
8fe3486
 
8fe3486
       return true;
8fe3486
    }
8fe3486
diff -rupN netgen-5.1/libsrc/occ/occgeom.hpp netgen-5.1-new/libsrc/occ/occgeom.hpp
8fe3486
--- netgen-5.1/libsrc/occ/occgeom.hpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/occgeom.hpp	2014-06-13 19:54:42.972358572 +0200
8fe3486
@@ -15,8 +15,8 @@
8fe3486
 #include "Geom_Curve.hxx"
8fe3486
 #include "Geom2d_Curve.hxx"
8fe3486
 #include "Geom_Surface.hxx"
8fe3486
-#include "GeomAPI_ProjectPointOnSurf.hxx"
8fe3486
-#include "GeomAPI_ProjectPointOnCurve.hxx"
8fe3486
+// #include "GeomAPI_ProjectPointOnSurf.hxx"
8fe3486
+// #include "GeomAPI_ProjectPointOnCurve.hxx"
8fe3486
 #include "BRepTools.hxx"
8fe3486
 #include "TopExp.hxx"
8fe3486
 #include "BRepBuilderAPI_MakeVertex.hxx"
8fe3486
@@ -42,8 +42,8 @@
8fe3486
 #include "Geom_Curve.hxx"
8fe3486
 #include "Geom2d_Curve.hxx"
8fe3486
 #include "Geom_Surface.hxx"
8fe3486
-#include "GeomAPI_ProjectPointOnSurf.hxx"
8fe3486
-#include "GeomAPI_ProjectPointOnCurve.hxx"
8fe3486
+// #include "GeomAPI_ProjectPointOnSurf.hxx"
8fe3486
+// #include "GeomAPI_ProjectPointOnCurve.hxx"
8fe3486
 #include "TopoDS_Wire.hxx"
8fe3486
 #include "BRepTools_WireExplorer.hxx"
8fe3486
 #include "BRepTools.hxx"
8fe3486
@@ -68,7 +68,7 @@
8fe3486
 #include "IGESToBRep_Reader.hxx"
8fe3486
 #include "Interface_Static.hxx"
8fe3486
 #include "GeomAPI_ExtremaCurveCurve.hxx"
8fe3486
-#include "Standard_ErrorHandler.hxx"
8fe3486
+//#include "Standard_ErrorHandler.hxx"
8fe3486
 #include "Standard_Failure.hxx"
8fe3486
 #include "ShapeUpgrade_ShellSewing.hxx"
8fe3486
 #include "ShapeFix_Shape.hxx"
8fe3486
@@ -80,6 +80,10 @@
8fe3486
 #include "ShapeAnalysis.hxx"
8fe3486
 #include "ShapeBuild_ReShape.hxx"
8fe3486
 
8fe3486
+// -- Optimization: to use cached projector and classifier
8fe3486
+#include <NCollection_DataMap.hxx>
8fe3486
+class Handle_ShapeAnalysis_Surface;
8fe3486
+class BRepTopAdaptor_FClass2d;
8fe3486
 
8fe3486
 // Philippose - 29/01/2009
8fe3486
 // OpenCascade XDE Support
8fe3486
@@ -192,6 +196,9 @@ namespace netgen
8fe3486
    class OCCGeometry : public NetgenGeometry
8fe3486
    {
8fe3486
       Point<3> center;
8fe3486
+      // -- Optimization: to use cached projector and classifier
8fe3486
+      mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
8fe3486
+      mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
8fe3486
 
8fe3486
    public:
8fe3486
       TopoDS_Shape shape;
8fe3486
@@ -247,6 +254,8 @@ namespace netgen
8fe3486
      virtual void Save (string filename) const;
8fe3486
 
8fe3486
 
8fe3486
+      ~OCCGeometry();      // -- to free cached projector and classifier
8fe3486
+
8fe3486
       void BuildFMap();
8fe3486
 
8fe3486
       Box<3> GetBoundingBox()
8fe3486
@@ -266,9 +275,14 @@ namespace netgen
8fe3486
       Point<3> Center()
8fe3486
       {  return center;}
8fe3486
 
8fe3486
-      void Project (int surfi, Point<3> & p) const;
8fe3486
+      // void Project (int surfi, Point<3> & p) const; -- optimization
8fe3486
+      bool Project (int surfi, Point<3> & p, double& u, double& v) const;
8fe3486
       bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
8fe3486
 
8fe3486
+      // -- Optimization: to use cached projector and classifier
8fe3486
+      void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
8fe3486
+                        BRepTopAdaptor_FClass2d*& cls) const;
8fe3486
+
8fe3486
       OCCSurface GetSurface (int surfi)
8fe3486
       {
8fe3486
          cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
8fe3486
diff -rupN netgen-5.1/libsrc/occ/occmeshsurf.cpp netgen-5.1-new/libsrc/occ/occmeshsurf.cpp
8fe3486
--- netgen-5.1/libsrc/occ/occmeshsurf.cpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/occmeshsurf.cpp	2014-06-13 19:54:42.972358572 +0200
8fe3486
@@ -6,6 +6,7 @@
8fe3486
 #include <meshing.hpp>
8fe3486
 #include <GeomLProp_SLProps.hxx>
8fe3486
 #include <ShapeAnalysis_Surface.hxx>
8fe3486
+#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
8fe3486
 
8fe3486
 
8fe3486
 namespace netgen
8fe3486
@@ -434,23 +435,33 @@ namespace netgen
8fe3486
 
8fe3486
   void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
8fe3486
   {
8fe3486
-    geometry.Project (surfind, p);
8fe3486
+    // geometry.Project (surfind, p); -- signature of Project() changed for optimization
8fe3486
+    double u, v;
8fe3486
+    geometry.Project (surfind, p, u, v);
8fe3486
   }
8fe3486
 
8fe3486
 
8fe3486
   int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
8fe3486
   {
8fe3486
-    double u = gi.u;
8fe3486
-    double v = gi.v;
8fe3486
+    //double u = gi.u;
8fe3486
+    //double v = gi.v;
8fe3486
 
8fe3486
     Point<3> hp = p;
8fe3486
-    if (geometry.FastProject (surfind, hp, u, v))
8fe3486
-      {
8fe3486
-	p = hp;
8fe3486
-	return 1;
8fe3486
-      }
8fe3486
-    ProjectPoint (surfind, p); 
8fe3486
-    return CalcPointGeomInfo (surfind, gi, p); 
8fe3486
+    // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
8fe3486
+    // if (geometry.FastProject (surfind, hp, u, v))
8fe3486
+    //   {
8fe3486
+    //    p = hp;
8fe3486
+    //    return 1;
8fe3486
+    //   }
8fe3486
+    // ProjectPoint (surfind, p); 
8fe3486
+    // return CalcPointGeomInfo (surfind, gi, p); 
8fe3486
+    bool ok;
8fe3486
+    if (gi.trignum > 0)
8fe3486
+      ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
8fe3486
+    else
8fe3486
+      ok = geometry.Project (surfind, hp, gi.u, gi.v);
8fe3486
+    p = hp;
8fe3486
+    return ok;
8fe3486
   }
8fe3486
 
8fe3486
 
8fe3486
@@ -680,7 +691,8 @@ namespace netgen
8fe3486
 	if (!geometry.FastProject (surfi, hnewp, u, v))
8fe3486
 	  {
8fe3486
 	  //  cout << "Fast projection to surface fails! Using OCC projection" << endl;
8fe3486
-	    geometry.Project (surfi, hnewp);
8fe3486
+	    // geometry.Project (surfi, hnewp); -- Project() changed for optimization
8fe3486
+	    geometry.Project (surfi, hnewp, u, v);
8fe3486
 	  }
8fe3486
 
8fe3486
 	newgi.trignum = 1;
8fe3486
@@ -689,7 +701,7 @@ namespace netgen
8fe3486
       }
8fe3486
   
8fe3486
     newp = hnewp;
8fe3486
-  }
8fe3486
+  }//; -- to compile with -Wall -pedantic
8fe3486
 
8fe3486
 
8fe3486
   void OCCRefinementSurfaces :: 
8fe3486
@@ -708,14 +720,18 @@ namespace netgen
8fe3486
     hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
8fe3486
     newp = hnewp;
8fe3486
     newgi = ap1;
8fe3486
-  };
8fe3486
+  }
8fe3486
 
8fe3486
 
8fe3486
   void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const
8fe3486
   {
8fe3486
     if (surfi > 0)
8fe3486
-      geometry.Project (surfi, p);
8fe3486
-  };
8fe3486
+    // geometry.Project (surfi, p); -- Project() changed for optimization
8fe3486
+    {
8fe3486
+      double u, v;
8fe3486
+      geometry.Project (surfi, p, u, v);
8fe3486
+    }
8fe3486
+  }//; -- to compile with -Wall -pedantic
8fe3486
 
8fe3486
   void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const
8fe3486
   {
8fe3486
@@ -723,9 +739,10 @@ namespace netgen
8fe3486
       if (!geometry.FastProject (surfi, p, gi.u, gi.v))
8fe3486
 	{
8fe3486
 	  cout << "Fast projection to surface fails! Using OCC projection" << endl;
8fe3486
-	  geometry.Project (surfi, p);
8fe3486
+          double u, v;
8fe3486
+	  geometry.Project (surfi, p, u, v);
8fe3486
 	}
8fe3486
-  };
8fe3486
+  }
8fe3486
 
8fe3486
 
8fe3486
 
8fe3486
diff -rupN netgen-5.1/libsrc/occ/Partition_Inter3d.cxx netgen-5.1-new/libsrc/occ/Partition_Inter3d.cxx
8fe3486
--- netgen-5.1/libsrc/occ/Partition_Inter3d.cxx	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/Partition_Inter3d.cxx	2014-06-13 19:54:42.969358572 +0200
8fe3486
@@ -243,9 +243,11 @@ static void PutInBounds (const TopoDS_Fa
8fe3486
       Standard_Integer i, nbExt = anExtPS.NbExt();
8fe3486
       Extrema_POnSurf aPOnSurf;
8fe3486
       for (i = 1; i <= nbExt; ++i )
8fe3486
-	if (anExtPS.Value( i ) <= TolE)               // V6.3
8fe3486
-	  // if (anExtPS.SquareDistance( i ) <= TolE)   // V6.5
8fe3486
-	  {
8fe3486
+        // porting to OCCT6.5.1
8fe3486
+	//if (anExtPS.Value( i ) <= TolE)               // V6.3
8fe3486
+	// if (anExtPS.SquareDistance( i ) <= TolE)   // V6.5
8fe3486
+        if (anExtPS.SquareDistance( i ) <= TolE * TolE)
8fe3486
+	{
8fe3486
           aPOnSurf = anExtPS.Point( i );
8fe3486
           break;
8fe3486
         }
8fe3486
diff -rupN netgen-5.1/libsrc/occ/Partition_Loop2d.cxx netgen-5.1-new/libsrc/occ/Partition_Loop2d.cxx
8fe3486
--- netgen-5.1/libsrc/occ/Partition_Loop2d.cxx	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/Partition_Loop2d.cxx	2014-06-13 19:54:42.970358572 +0200
8fe3486
@@ -210,7 +210,7 @@ static Standard_Boolean  SelectEdge(cons
8fe3486
     Cc->D1(uc, PC, CTg1);
8fe3486
     if (!isForward) CTg1.Reverse();
8fe3486
 
8fe3486
-    Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
8fe3486
+    Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
8fe3486
 
8fe3486
     // select an edge whose first derivative is most left of CTg1
8fe3486
     // ie an angle between Tg1 and CTg1 is least
8fe3486
@@ -234,7 +234,7 @@ static Standard_Boolean  SelectEdge(cons
8fe3486
       // -PI < angle < PI
8fe3486
       Standard_Real angle = Tg1.Angle(CTg1);
8fe3486
 
8fe3486
-      if (PI - Abs(angle) <= tolAng)
8fe3486
+      if (M_PI - Abs(angle) <= tolAng)
8fe3486
       {
8fe3486
         // an angle is too close to PI; assure that an angle sign really
8fe3486
         // reflects an edge position: +PI - an edge is worst,
8fe3486
diff -rupN netgen-5.1/libsrc/occ/Partition_Spliter.cxx netgen-5.1-new/libsrc/occ/Partition_Spliter.cxx
8fe3486
--- netgen-5.1/libsrc/occ/Partition_Spliter.cxx	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/Partition_Spliter.cxx	2014-06-13 19:54:42.970358572 +0200
8fe3486
@@ -1169,8 +1169,10 @@ static void findEqual (const TopTools_Li
8fe3486
           for (; j<=nbj && ok; ++j) {
8fe3486
             if (Extrema.IsMin(j)) {
8fe3486
 	      hasMin = Standard_True;
8fe3486
-	      ok = Extrema.Value(j) <= tol;  // V6.3
8fe3486
+	      // porting to OCCT6.5.1
8fe3486
+	      //ok = Extrema.Value(j) <= tol;  // V6.3
8fe3486
 	      // ok = Extrema.SquareDistance(j) <= tol;  // V6.5
8fe3486
+	      ok = Extrema.SquareDistance(j) <= tol * tol;
8fe3486
 	    }
8fe3486
           }
8fe3486
         }
8fe3486
diff -rupN netgen-5.1/libsrc/occ/utilities.h netgen-5.1-new/libsrc/occ/utilities.h
8fe3486
--- netgen-5.1/libsrc/occ/utilities.h	2013-08-14 16:09:45.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/occ/utilities.h	2014-06-13 19:54:42.972358572 +0200
8fe3486
@@ -33,6 +33,7 @@
8fe3486
 
8fe3486
 #include <string>
8fe3486
 #include <iostream>
8fe3486
+#include <iomanip>
8fe3486
 #include <cstdlib>
8fe3486
 // #include "SALOME_Log.hxx"
8fe3486
 
8fe3486
diff -rupN netgen-5.1/libsrc/stlgeom/stlgeommesh.cpp netgen-5.1-new/libsrc/stlgeom/stlgeommesh.cpp
8fe3486
--- netgen-5.1/libsrc/stlgeom/stlgeommesh.cpp	2013-06-25 13:28:59.000000000 +0200
8fe3486
+++ netgen-5.1-new/libsrc/stlgeom/stlgeommesh.cpp	2014-06-13 19:54:42.972358572 +0200
8fe3486
@@ -1435,7 +1435,8 @@ int STLMeshingDummy (STLGeometry* stlgeo
8fe3486
 	  /*
8fe3486
 	  if (!optstring || strlen(optstring) == 0)
8fe3486
 	    {
8fe3486
-	      mparam.optimize2d = "smcm";
8fe3486
+	      //mparam.optimize2d = (char*)"smcm";
8fe3486
+              mparam.optimize2d = (char*)"smcm";
8fe3486
 	    }
8fe3486
 	  else
8fe3486
 	    {
8fe3486
@@ -1453,7 +1454,7 @@ int STLMeshingDummy (STLGeometry* stlgeo
8fe3486
 	      mesh -> LoadLocalMeshSize (mparam.meshsizefilename);	      
8fe3486
 	      mesh -> CalcLocalHFromSurfaceCurvature (mparam.grading, 
8fe3486
 						      stlparam.resthsurfmeshcurvfac);
8fe3486
-	      mparam.optimize2d = "cmsmSm";
8fe3486
+	      mparam.optimize2d = "(char*)cmsmSm";
8fe3486
 	      STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
8fe3486
 #ifdef STAT_STREAM
8fe3486
 	      (*statout) << GetTime() << " & ";
8fe3486
@@ -1560,7 +1561,8 @@ int STLMeshingDummy (STLGeometry* stlgeo
8fe3486
 	  /*
8fe3486
 	  if (!optstring || strlen(optstring) == 0)
8fe3486
 	    {
8fe3486
-	      mparam.optimize3d = "cmdmstm";
8fe3486
+              //mparam.optimize3d = "cmdmstm";
8fe3486
+	      mparam.optimize3d = (char*)"cmdmstm";
8fe3486
 	    }
8fe3486
 	  else
8fe3486
 	    {
8fe3486
diff -rupN netgen-5.1/nglib/nglib.h netgen-5.1-new/nglib/nglib.h
8fe3486
--- netgen-5.1/nglib/nglib.h	2013-06-25 13:28:56.000000000 +0200
8fe3486
+++ netgen-5.1-new/nglib/nglib.h	2014-06-13 19:54:42.973358572 +0200
8fe3486
@@ -24,7 +24,7 @@
8fe3486
 // Philippose - 14.02.2009
8fe3486
 // Modifications for creating a DLL in Windows
8fe3486
 #ifdef WIN32
8fe3486
-   #ifdef NGLIB_EXPORTS || nglib_EXPORTS
8fe3486
+   #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
8fe3486
       #define DLL_HEADER   __declspec(dllexport)
8fe3486
    #else
8fe3486
       #define DLL_HEADER   __declspec(dllimport)