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
12 double det = trans.Det();
18 err += frob * frob / det;
21 double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
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);
40 double det = trans.Det();
45 err += frob * frob / det;
50 - if (noz == 0.0) noz = 1e-10;
51 + if (noz <= DBL_MIN) noz = 1e-10;
53 double xi = p(0) / noz;
54 double eta = p(1) / noz;
57 double det = -trans.Det();
63 err += frob * frob * frob / det;
82 @@ -2522,10 +2523,10 @@
84 MeshingParameters :: MeshingParameters ()
86 - optimize3d = "cmdmustm";
87 + optimize3d = (char*)"cmdmustm";
88 //optimize3d = "cmdmstm";
90 - optimize2d = "smsmsmSmSmSm";
91 + optimize2d = (char*)"smsmsmSmSmSm";
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
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
114 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
115 + //meshthis -> GetNormalVector (surfi, sp1, gi1, n);
117 pp1 = sp1 + x(0) * t1 + x(1) * t2;
119 // meshthis -> ProjectPoint (surfi, pp1);
124 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
125 + //meshthis -> GetNormalVector (surfi, sp1, gi1, n);
128 pp1 = sp1 + x(0) * t1 + x(1) * t2;
134 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
135 + //meshthis -> GetNormalVector (surfi, sp1, gi1, n);
138 pp1 = sp1 + x(0) * t1 + x(1) * t2;
144 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
145 + //meshthis -> GetNormalVector (surfi, sp1, gi1, n);
149 // pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
152 mesh[pi] = Point<3> (origp);
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
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
176 #define DIVIDEEDGESECTIONS 1000
177 #define IGNORECURVELENGTH 1e-4
178 +#define VSMALL 1e-10
181 bool merge_solids = 1;
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);
189 if (lambda >= 0 && lambda <= 1)
195 - double ComputeH (double kappa)
196 + static double ComputeH (double kappa)
199 kappa *= mparam.curvaturesafety;
201 if (mparam.maxh * kappa < 1)
205 + hret = 1 / (kappa + VSMALL);
207 if (mparam.maxh < hret)
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)
223 - if (h > 30) return;
224 + // commented to restrict H on a large sphere for example
225 + //if (h > 30) return;
228 if (h < maxside && depth < 10)
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)
242 - double olddist = 0;
244 + //double olddist = 0;
247 int tmpVal = (int)(DIVIDEEDGESECTIONS);
249 @@ -256,15 +257,15 @@
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));
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;
264 - dist = pnt.Distance(oldpnt);
266 + //dist = pnt.Distance(oldpnt);
269 // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
271 (*testout) << "nedges = " << nedges << endl;
273 double eps = 1e-6 * geom.GetBoundingBox().Diam();
274 + const double eps2 = eps * eps;
276 for (int i = 1; i <= nvertices; i++)
281 for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
282 - if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
283 + if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 )
289 TopoDS_Face face = TopoDS::Face(exp1.Current());
290 int facenr = geom.fmap.FindIndex(face);
291 + if ( facenr < 1 ) continue; // support of sub-meshes
293 if (face2solid[0][facenr-1] == 0)
294 face2solid[0][facenr-1] = solidnr;
299 + edgenr = mesh.GetNSeg(); // support of sub-meshes
301 (*testout) << "faces = " << geom.fmap.Extent() << endl;
304 //(*testout) << "ignoring degenerated edge" << endl;
307 + if ( geom.emap.FindIndex(edge) < 1 )
308 + continue; // support sub-meshes
310 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
311 geom.vmap.FindIndex(TopExp::LastVertex (edge)))
314 for (PointIndex pi = 1; pi < first_ep; pi++)
316 - if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
317 - if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
318 + if (Dist2 (mesh[pi], fp) < eps2) pnums[0] = pi;
319 + if (Dist2 (mesh[pi], lp) < eps2) pnums.Last() = pi;
326 for (j = first_ep; j <= mesh.GetNP(); j++)
327 - if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
328 + if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps2)
335 (*testout) << "mesh face " << k << endl;
336 - multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
337 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
338 geom.facemeshstatus[k-1] = -1;
342 // if (k != 36) continue;
344 // (*testout) << "optimize face " << k << endl;
345 - multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
346 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
348 FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
350 @@ -1229,7 +1235,7 @@
351 mindist = min (mindist, line.Dist(lines[num]));
354 - mindist *= occparam.resthcloseedgefac;
355 + mindist /= (occparam.resthcloseedgefac + VSMALL);
359 @@ -1456,3 +1462,4 @@
364 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.cpp netgen-4.9.13_new/libsrc/occ/occgeom.cpp
365 --- netgen-4.9.13_orig/libsrc/occ/occgeom.cpp 2010-03-05 16:16:21.000000000 +0300
366 +++ netgen-4.9.13_new/libsrc/occ/occgeom.cpp 2011-02-18 15:34:01.000000000 +0300
368 #include "ShapeAnalysis_ShapeContents.hxx"
369 #include "ShapeAnalysis_CheckSmallFace.hxx"
370 #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
371 -#include "ShapeAnalysis_Surface.hxx"
372 +#include <ShapeAnalysis_Surface.hxx>
373 +#include <BRepTopAdaptor_FClass2d.hxx>
374 #include "BRepAlgoAPI_Fuse.hxx"
375 #include "BRepCheck_Analyzer.hxx"
376 #include "BRepLib.hxx"
378 #include "ShapeFix.hxx"
379 #include "ShapeFix_FixSmallFace.hxx"
380 #include "Partition_Spliter.hxx"
382 +#include <TopAbs_State.hxx>
386 - void OCCGeometry :: PrintNrShapes ()
387 + OCCGeometry::~OCCGeometry()
389 + NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
390 + for (; it.More(); it.Next())
394 + void OCCGeometry :: PrintNrShapes ()
398 @@ -952,24 +960,47 @@
402 + void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
403 + BRepTopAdaptor_FClass2d*& cls) const
405 + //MSV: organize caching projector in the map
406 + if (fprjmap.IsBound(surfi))
408 + proj = fprjmap.Find(surfi);
409 + cls = fclsmap.Find(surfi);
413 + const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
414 + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
415 + proj = new ShapeAnalysis_Surface(aSurf);
416 + fprjmap.Bind(surfi, proj);
417 + cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
418 + fclsmap.Bind(surfi, cls);
422 - void OCCGeometry :: Project (int surfi, Point<3> & p) const
423 + bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
426 if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
428 gp_Pnt pnt(p(0), p(1), p(2));
431 - Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
432 - Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
433 - gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
434 - suval.Coord( u, v);
435 - pnt = thesurf->Value( u, v );
439 + Handle(ShapeAnalysis_Surface) proj;
440 + BRepTopAdaptor_FClass2d *cls;
441 + GetFaceTools(surfi, proj, cls);
443 + gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
444 + if (cls->Perform(p2d) == TopAbs_OUT)
448 + pnt = proj->Value(p2d);
451 p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
457 @@ -979,54 +1010,20 @@
459 gp_Pnt p(ap(0), ap(1), ap(2));
461 - Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
463 - gp_Pnt x = surface->Value (u,v);
465 - if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
469 - surface->D1(u,v,x,du,dv);
475 - double det, lambda, mu;
482 - det = Det3 (n.X(), du.X(), dv.X(),
483 - n.Y(), du.Y(), dv.Y(),
484 - n.Z(), du.Z(), dv.Z());
486 - if (det < 1e-15) return false;
488 - lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
489 - n.Y(), p.Y()-x.Y(), dv.Y(),
490 - n.Z(), p.Z()-x.Z(), dv.Z())/det;
492 - mu = Det3 (n.X(), du.X(), p.X()-x.X(),
493 - n.Y(), du.Y(), p.Y()-x.Y(),
494 - n.Z(), du.Z(), p.Z()-x.Z())/det;
500 - surface->D1(u,v,x,du,dv);
502 - } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
504 - // (*testout) << "FastProject count: " << count << endl;
506 - if (count == 50) return false;
508 - ap = Point<3> (x.X(), x.Y(), x.Z());
509 + Handle(ShapeAnalysis_Surface) proj;
510 + BRepTopAdaptor_FClass2d *cls;
511 + GetFaceTools(surfi, proj, cls);
513 + gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
514 + if (cls->Perform(p2d) == TopAbs_OUT)
516 + //cout << "Projection fails" << endl;
520 + p = proj->Value(p2d);
522 + ap = Point<3> (p.X(), p.Y(), p.Z());
526 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.hpp netgen-4.9.13_new/libsrc/occ/occgeom.hpp
527 --- netgen-4.9.13_orig/libsrc/occ/occgeom.hpp 2010-01-14 19:56:19.000000000 +0300
528 +++ netgen-4.9.13_new/libsrc/occ/occgeom.hpp 2011-02-18 15:33:10.000000000 +0300
530 #include "Geom_Curve.hxx"
531 #include "Geom2d_Curve.hxx"
532 #include "Geom_Surface.hxx"
533 -#include "GeomAPI_ProjectPointOnSurf.hxx"
534 -#include "GeomAPI_ProjectPointOnCurve.hxx"
535 #include "BRepTools.hxx"
536 #include "TopExp.hxx"
537 #include "BRepBuilderAPI_MakeVertex.hxx"
539 #include "Geom_Curve.hxx"
540 #include "Geom2d_Curve.hxx"
541 #include "Geom_Surface.hxx"
542 -#include "GeomAPI_ProjectPointOnSurf.hxx"
543 -#include "GeomAPI_ProjectPointOnCurve.hxx"
544 #include "TopoDS_Wire.hxx"
545 #include "BRepTools_WireExplorer.hxx"
546 #include "BRepTools.hxx"
548 #include "IGESToBRep_Reader.hxx"
549 #include "Interface_Static.hxx"
550 #include "GeomAPI_ExtremaCurveCurve.hxx"
551 -#include "Standard_ErrorHandler.hxx"
552 +//#include "Standard_ErrorHandler.hxx"
553 #include "Standard_Failure.hxx"
554 #include "ShapeUpgrade_ShellSewing.hxx"
555 #include "ShapeFix_Shape.hxx"
557 #include "ShapeAnalysis.hxx"
558 #include "ShapeBuild_ReShape.hxx"
560 +#include <NCollection_DataMap.hxx>
561 +class Handle_ShapeAnalysis_Surface;
562 +class BRepTopAdaptor_FClass2d;
565 // Philippose - 29/01/2009
566 // OpenCascade XDE Support
568 class OCCGeometry : public NetgenGeometry
571 + mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
572 + mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
584 Box<3> GetBoundingBox()
589 - void Project (int surfi, Point<3> & p) const;
590 + bool Project (int surfi, Point<3> & p, double& u, double& v) const;
591 bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
593 + void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
594 + BRepTopAdaptor_FClass2d*& cls) const;
596 OCCSurface GetSurface (int surfi)
598 cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
599 diff -Naur netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp
600 --- netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp 2009-08-24 06:32:47.000000000 +0400
601 +++ netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp 2011-02-18 16:27:39.000000000 +0300
603 #include <meshing.hpp>
604 #include <GeomLProp_SLProps.hxx>
605 #include <ShapeAnalysis_Surface.hxx>
606 +#include <GeomAPI_ProjectPointOnCurve.hxx>
610 @@ -434,23 +435,21 @@
612 void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
614 - geometry.Project (surfind, p);
616 + geometry.Project (surfind, p, u, v);
620 int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
626 - if (geometry.FastProject (surfind, hp, u, v))
631 - ProjectPoint (surfind, p);
632 - return CalcPointGeomInfo (surfind, gi, p);
634 + if (gi.trignum > 0)
635 + ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
637 + ok = geometry.Project (surfind, hp, gi.u, gi.v);
644 if (!geometry.FastProject (surfi, hnewp, u, v))
646 // cout << "Fast projection to surface fails! Using OCC projection" << endl;
647 - geometry.Project (surfi, hnewp);
648 + geometry.Project (surfi, hnewp, u, v);
652 @@ -708,14 +707,17 @@
653 hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
660 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
663 - geometry.Project (surfi, p);
667 + geometry.Project (surfi, p, u, v);
671 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
674 if (!geometry.FastProject (surfi, p, gi.u, gi.v))
676 cout << "Fast projection to surface fails! Using OCC projection" << endl;
677 - geometry.Project (surfi, p);
679 + geometry.Project (surfi, p, u, v);
686 diff -Naur netgen-4.9.13_orig/libsrc/occ/utilities.h netgen-4.9.13_new/libsrc/occ/utilities.h
687 --- netgen-4.9.13_orig/libsrc/occ/utilities.h 2009-08-24 06:12:24.000000000 +0400
688 +++ netgen-4.9.13_new/libsrc/occ/utilities.h 2011-02-18 11:24:03.000000000 +0300
695 // #include "SALOME_Log.hxx"
697 diff -Naur netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp
698 --- netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp 2009-08-10 15:40:51.000000000 +0400
699 +++ netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp 2011-02-18 11:24:03.000000000 +0300
700 @@ -1435,7 +1435,7 @@
702 if (!optstring || strlen(optstring) == 0)
704 - mparam.optimize2d = "smcm";
705 + mparam.optimize2d = (char*)"smcm";
709 @@ -1451,7 +1451,7 @@
711 mesh -> LoadLocalMeshSize (mparam.meshsizefilename);
712 mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac);
713 - mparam.optimize2d = "cmsmSm";
714 + mparam.optimize2d = (char*)"cmsmSm";
715 STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
717 (*statout) << GetTime() << " & ";
718 @@ -1557,7 +1557,7 @@
720 if (!optstring || strlen(optstring) == 0)
722 - mparam.optimize3d = "cmdmstm";
723 + mparam.optimize3d = (char*)"cmdmstm";
727 --- netgen-4.9.13_orig/nglib/nglib.h 2010-05-18 15:20:25.000000000 +0400
728 +++ netgen-4.9.13_new/nglib/nglib.h 2010-05-31 13:02:19.000000000 +0400
730 // Philippose - 14.02.2009
731 // Modifications for creating a DLL in Windows
733 - #ifdef NGLIB_EXPORTS || nglib_EXPORTS
734 + #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
735 #define DLL_HEADER __declspec(dllexport)
737 #define DLL_HEADER __declspec(dllimport)