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]));
272 if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
274 - params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
275 + // For nsubedges comparable to DIVIDEEDGESECTIONS (SALOME issue 0021073)
276 + //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
277 + double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
278 + params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
279 pnt = c->Value(params[i]);
280 ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
283 (*testout) << "nedges = " << nedges << endl;
285 double eps = 1e-6 * geom.GetBoundingBox().Diam();
286 + const double eps2 = eps * eps;
288 for (int i = 1; i <= nvertices; i++)
293 for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
294 - if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
295 + if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 )
301 TopoDS_Face face = TopoDS::Face(exp1.Current());
302 int facenr = geom.fmap.FindIndex(face);
303 + if ( facenr < 1 ) continue; // support of SALOME sub-meshes
305 if (face2solid[0][facenr-1] == 0)
306 face2solid[0][facenr-1] = solidnr;
311 + edgenr = mesh.GetNSeg(); // support of SALOME sub-meshes
313 (*testout) << "faces = " << geom.fmap.Extent() << endl;
316 //(*testout) << "ignoring degenerated edge" << endl;
319 + if ( geom.emap.FindIndex(edge) < 1 )
320 + continue; // support SALOME sub-meshes
322 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
323 geom.vmap.FindIndex(TopExp::LastVertex (edge)))
328 + const double tol = std::max( BRep_Tool::Tolerance( TopExp::FirstVertex (edge)),
329 + BRep_Tool::Tolerance( TopExp::LastVertex (edge)));
330 Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
331 Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
335 for (PointIndex pi = 1; pi < first_ep; pi++)
337 - if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
338 - if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
339 + if (Dist2 (mesh[pi], fp) < 2*tol*tol) pnums[0] = pi;
340 + if (Dist2 (mesh[pi], lp) < 2*tol*tol) pnums.Last() = pi;
347 (*testout) << "mesh face " << k << endl;
348 - multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
349 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
350 geom.facemeshstatus[k-1] = -1;
354 // if (k != 36) continue;
356 // (*testout) << "optimize face " << k << endl;
357 - multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
358 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
360 FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
362 @@ -1229,7 +1240,7 @@
363 mindist = min (mindist, line.Dist(lines[num]));
366 - mindist *= occparam.resthcloseedgefac;
367 + mindist /= (occparam.resthcloseedgefac + VSMALL);
371 @@ -1456,3 +1467,4 @@
376 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.cpp netgen-4.9.13_new/libsrc/occ/occgeom.cpp
377 --- netgen-4.9.13_orig/libsrc/occ/occgeom.cpp 2010-03-05 16:16:21.000000000 +0300
378 +++ netgen-4.9.13_new/libsrc/occ/occgeom.cpp 2011-02-18 15:34:01.000000000 +0300
380 #include "ShapeAnalysis_ShapeContents.hxx"
381 #include "ShapeAnalysis_CheckSmallFace.hxx"
382 #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
383 -#include "ShapeAnalysis_Surface.hxx"
384 +#include <ShapeAnalysis_Surface.hxx>
385 +#include <BRepTopAdaptor_FClass2d.hxx>
386 #include "BRepAlgoAPI_Fuse.hxx"
387 #include "BRepCheck_Analyzer.hxx"
388 #include "BRepLib.hxx"
390 #include "ShapeFix.hxx"
391 #include "ShapeFix_FixSmallFace.hxx"
392 #include "Partition_Spliter.hxx"
394 +#include <TopAbs_State.hxx>
398 - void OCCGeometry :: PrintNrShapes ()
399 + OCCGeometry::~OCCGeometry()
401 + NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
402 + for (; it.More(); it.Next())
406 + void OCCGeometry :: PrintNrShapes ()
410 @@ -952,24 +960,47 @@
414 + void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
415 + BRepTopAdaptor_FClass2d*& cls) const
417 + //MSV: organize caching projector in the map
418 + if (fprjmap.IsBound(surfi))
420 + proj = fprjmap.Find(surfi);
421 + cls = fclsmap.Find(surfi);
425 + const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
426 + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
427 + proj = new ShapeAnalysis_Surface(aSurf);
428 + fprjmap.Bind(surfi, proj);
429 + cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
430 + fclsmap.Bind(surfi, cls);
434 - void OCCGeometry :: Project (int surfi, Point<3> & p) const
435 + bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
438 if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
440 gp_Pnt pnt(p(0), p(1), p(2));
443 - Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
444 - Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
445 - gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
446 - suval.Coord( u, v);
447 - pnt = thesurf->Value( u, v );
451 + Handle(ShapeAnalysis_Surface) proj;
452 + BRepTopAdaptor_FClass2d *cls;
453 + GetFaceTools(surfi, proj, cls);
455 + gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
456 + if (cls->Perform(p2d) == TopAbs_OUT)
460 + pnt = proj->Value(p2d);
463 p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
469 @@ -979,54 +1010,20 @@
471 gp_Pnt p(ap(0), ap(1), ap(2));
473 - Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
475 - gp_Pnt x = surface->Value (u,v);
477 - if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
481 - surface->D1(u,v,x,du,dv);
487 - double det, lambda, mu;
494 - det = Det3 (n.X(), du.X(), dv.X(),
495 - n.Y(), du.Y(), dv.Y(),
496 - n.Z(), du.Z(), dv.Z());
498 - if (det < 1e-15) return false;
500 - lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
501 - n.Y(), p.Y()-x.Y(), dv.Y(),
502 - n.Z(), p.Z()-x.Z(), dv.Z())/det;
504 - mu = Det3 (n.X(), du.X(), p.X()-x.X(),
505 - n.Y(), du.Y(), p.Y()-x.Y(),
506 - n.Z(), du.Z(), p.Z()-x.Z())/det;
512 - surface->D1(u,v,x,du,dv);
514 - } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
516 - // (*testout) << "FastProject count: " << count << endl;
518 - if (count == 50) return false;
520 - ap = Point<3> (x.X(), x.Y(), x.Z());
521 + Handle(ShapeAnalysis_Surface) proj;
522 + BRepTopAdaptor_FClass2d *cls;
523 + GetFaceTools(surfi, proj, cls);
525 + gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
526 + if (cls->Perform(p2d) == TopAbs_OUT)
528 + //cout << "Projection fails" << endl;
532 + p = proj->Value(p2d);
534 + ap = Point<3> (p.X(), p.Y(), p.Z());
538 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.hpp netgen-4.9.13_new/libsrc/occ/occgeom.hpp
539 --- netgen-4.9.13_orig/libsrc/occ/occgeom.hpp 2010-01-14 19:56:19.000000000 +0300
540 +++ netgen-4.9.13_new/libsrc/occ/occgeom.hpp 2011-02-18 15:33:10.000000000 +0300
542 #include "Geom_Curve.hxx"
543 #include "Geom2d_Curve.hxx"
544 #include "Geom_Surface.hxx"
545 -#include "GeomAPI_ProjectPointOnSurf.hxx"
546 -#include "GeomAPI_ProjectPointOnCurve.hxx"
547 #include "BRepTools.hxx"
548 #include "TopExp.hxx"
549 #include "BRepBuilderAPI_MakeVertex.hxx"
551 #include "Geom_Curve.hxx"
552 #include "Geom2d_Curve.hxx"
553 #include "Geom_Surface.hxx"
554 -#include "GeomAPI_ProjectPointOnSurf.hxx"
555 -#include "GeomAPI_ProjectPointOnCurve.hxx"
556 #include "TopoDS_Wire.hxx"
557 #include "BRepTools_WireExplorer.hxx"
558 #include "BRepTools.hxx"
560 #include "IGESToBRep_Reader.hxx"
561 #include "Interface_Static.hxx"
562 #include "GeomAPI_ExtremaCurveCurve.hxx"
563 -#include "Standard_ErrorHandler.hxx"
564 +//#include "Standard_ErrorHandler.hxx"
565 #include "Standard_Failure.hxx"
566 #include "ShapeUpgrade_ShellSewing.hxx"
567 #include "ShapeFix_Shape.hxx"
569 #include "ShapeAnalysis.hxx"
570 #include "ShapeBuild_ReShape.hxx"
572 +#include <NCollection_DataMap.hxx>
573 +class Handle_ShapeAnalysis_Surface;
574 +class BRepTopAdaptor_FClass2d;
577 // Philippose - 29/01/2009
578 // OpenCascade XDE Support
580 class OCCGeometry : public NetgenGeometry
583 + mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
584 + mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
596 Box<3> GetBoundingBox()
601 - void Project (int surfi, Point<3> & p) const;
602 + bool Project (int surfi, Point<3> & p, double& u, double& v) const;
603 bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
605 + void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
606 + BRepTopAdaptor_FClass2d*& cls) const;
608 OCCSurface GetSurface (int surfi)
610 cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
611 diff -Naur netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp
612 --- netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp 2009-08-24 06:32:47.000000000 +0400
613 +++ netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp 2011-02-18 16:27:39.000000000 +0300
615 #include <meshing.hpp>
616 #include <GeomLProp_SLProps.hxx>
617 #include <ShapeAnalysis_Surface.hxx>
618 +#include <GeomAPI_ProjectPointOnCurve.hxx>
622 @@ -434,23 +435,21 @@
624 void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
626 - geometry.Project (surfind, p);
628 + geometry.Project (surfind, p, u, v);
632 int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
638 - if (geometry.FastProject (surfind, hp, u, v))
643 - ProjectPoint (surfind, p);
644 - return CalcPointGeomInfo (surfind, gi, p);
646 + if (gi.trignum > 0)
647 + ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
649 + ok = geometry.Project (surfind, hp, gi.u, gi.v);
656 if (!geometry.FastProject (surfi, hnewp, u, v))
658 // cout << "Fast projection to surface fails! Using OCC projection" << endl;
659 - geometry.Project (surfi, hnewp);
660 + geometry.Project (surfi, hnewp, u, v);
664 @@ -708,14 +707,17 @@
665 hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
672 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
675 - geometry.Project (surfi, p);
679 + geometry.Project (surfi, p, u, v);
683 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
686 if (!geometry.FastProject (surfi, p, gi.u, gi.v))
688 cout << "Fast projection to surface fails! Using OCC projection" << endl;
689 - geometry.Project (surfi, p);
691 + geometry.Project (surfi, p, u, v);
698 diff -Naur netgen-4.9.13_orig/libsrc/occ/utilities.h netgen-4.9.13_new/libsrc/occ/utilities.h
699 --- netgen-4.9.13_orig/libsrc/occ/utilities.h 2009-08-24 06:12:24.000000000 +0400
700 +++ netgen-4.9.13_new/libsrc/occ/utilities.h 2011-02-18 11:24:03.000000000 +0300
707 // #include "SALOME_Log.hxx"
709 diff -Naur netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp
710 --- netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp 2009-08-10 15:40:51.000000000 +0400
711 +++ netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp 2011-02-18 11:24:03.000000000 +0300
712 @@ -1435,7 +1435,7 @@
714 if (!optstring || strlen(optstring) == 0)
716 - mparam.optimize2d = "smcm";
717 + mparam.optimize2d = (char*)"smcm";
721 @@ -1451,7 +1451,7 @@
723 mesh -> LoadLocalMeshSize (mparam.meshsizefilename);
724 mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac);
725 - mparam.optimize2d = "cmsmSm";
726 + mparam.optimize2d = (char*)"cmsmSm";
727 STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
729 (*statout) << GetTime() << " & ";
730 @@ -1557,7 +1557,7 @@
732 if (!optstring || strlen(optstring) == 0)
734 - mparam.optimize3d = "cmdmstm";
735 + mparam.optimize3d = (char*)"cmdmstm";
739 --- netgen-4.9.13_orig/nglib/nglib.h 2010-05-18 15:20:25.000000000 +0400
740 +++ netgen-4.9.13_new/nglib/nglib.h 2010-05-31 13:02:19.000000000 +0400
742 // Philippose - 14.02.2009
743 // Modifications for creating a DLL in Windows
745 - #ifdef NGLIB_EXPORTS || nglib_EXPORTS
746 + #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
747 #define DLL_HEADER __declspec(dllexport)
749 #define DLL_HEADER __declspec(dllimport)