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-12-20 14:50:26.000000000 +0400
6 +#include <float.h> // to get DBL_MIN defined
12 double det = trans.Det();
16 + if (det <= DBL_MIN) // avoid FPE
19 err += frob * frob / det;
22 double det = trans(0,0)*trans(1,1)-trans(1,0)*trans(0,1);
26 + if (det <= DBL_MIN) // avoid FPE
31 = dtrans(0,0) * trans(1,1) - trans(0,1) * dtrans(1,0)
32 + trans(0,0) * dtrans(1,1) - dtrans(0,1) * trans(1,0);
36 + if (det <= DBL_MIN) // avoid FPE
43 double det = trans.Det();
46 + if (det <= DBL_MIN) // avoid FPE
49 err += frob * frob / det;
54 - if (noz == 0.0) noz = 1e-10;
55 + //if (noz == 0.0) noz = 1e-10;
56 + if (noz <= DBL_MIN) noz = 1e-10; // avoid FPE
58 double xi = p(0) / noz;
59 double eta = p(1) / noz;
62 double det = -trans.Det();
66 + if (det <= DBL_MIN) // avoid FPE
69 err += frob * frob * frob / det;
76 + if (det <= DBL_MIN) // avoid FPE
89 @@ -2522,10 +2530,10 @@
91 MeshingParameters :: MeshingParameters ()
93 - optimize3d = "cmdmustm";
94 + optimize3d = (char*)"cmdmustm"; // optimize3d = "cmdmustm";
95 //optimize3d = "cmdmstm";
97 - optimize2d = "smsmsmSmSmSm";
98 + optimize2d = (char*)"smsmsmSmSmSm"; // optimize2d = "smsmsmSmSmSm";
102 diff -Naur netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp netgen-4.9.13_new/libsrc/meshing/meshtype.hpp
103 --- netgen-4.9.13_orig/libsrc/meshing/meshtype.hpp 2009-11-09 13:50:43.000000000 +0300
104 +++ netgen-4.9.13_new/libsrc/meshing/meshtype.hpp 2011-12-20 14:50:26.000000000 +0400
109 +class Mesh; // added due to compilation errors on some platforms
112 SEGMENT = 1, SEGMENT3 = 2,
113 diff -Naur netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp
114 --- netgen-4.9.13_orig/libsrc/meshing/smoothing2.cpp 2009-11-09 13:47:09.000000000 +0300
115 +++ netgen-4.9.13_new/libsrc/meshing/smoothing2.cpp 2011-12-20 14:50:26.000000000 +0400
120 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
121 + //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
123 pp1 = sp1 + x(0) * t1 + x(1) * t2;
125 // meshthis -> ProjectPoint (surfi, pp1);
130 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
131 + //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
134 pp1 = sp1 + x(0) * t1 + x(1) * t2;
140 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
141 + //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
144 pp1 = sp1 + x(0) * t1 + x(1) * t2;
150 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
151 + //normal already computed: meshthis -> GetNormalVector (surfi, sp1, gi1, n);
155 // pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
158 mesh[pi] = Point<3> (origp);
161 + break; // exit as <fact> is not used anymore
165 diff -Naur netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp netgen-4.9.13_new/libsrc/occ/occconstruction.cpp
166 --- netgen-4.9.13_orig/libsrc/occ/occconstruction.cpp 2009-08-24 06:32:47.000000000 +0400
167 +++ netgen-4.9.13_new/libsrc/occ/occconstruction.cpp 2011-12-20 14:50:26.000000000 +0400
169 #include <BRepAlgoAPI_Common.hxx>
170 #include <BRepAlgoAPI_Fuse.hxx>
171 #include <BRepAlgoAPI_Section.hxx>
172 -#include <BRepOffsetAPI_Sewing.hxx>
173 +//#include <BRepOffsetAPI_Sewing.hxx>
174 //#include <BRepAlgo_Sewing.hxx>
175 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
176 #include <ShapeFix_Shape.hxx>
177 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp
178 --- netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp 2010-03-16 09:30:07.000000000 +0300
179 +++ netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp 2011-12-20 14:50:26.000000000 +0400
182 #define DIVIDEEDGESECTIONS 1000
183 #define IGNORECURVELENGTH 1e-4
184 +// a small value used to avoid FPE
185 +#define VSMALL 1e-10
188 bool merge_solids = 1;
192 Point<3> p = p0 + 0.5*n;
193 - double lambda = (p-l.p0)*n / nq;
194 + // double lambda = (p-l.p0)*n / nq; -- avoid FPE
195 + double lambda = (fabs(nq) > 1e-10) ? (p-l.p0)*n / nq : -1;
197 if (lambda >= 0 && lambda <= 1)
204 + static // useless out of this file
205 double ComputeH (double kappa)
209 if (mparam.maxh * kappa < 1)
213 + // hret = 1 / kappa; -- avoid FPE
214 + hret = 1 / (kappa + VSMALL);
216 if (mparam.maxh < hret)
224 + static // useless out of this file
225 void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
226 BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
233 - if (h > 30) return;
234 + // commented to restrict H on a large sphere for example
235 + //if (h > 30) return;
238 if (h < maxside && depth < 10)
243 + static // useless out of this file
244 void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
245 Array<double> & params, Mesh & mesh)
251 - double olddist = 0;
253 + //double olddist = 0; -- useless variables
256 int tmpVal = (int)(DIVIDEEDGESECTIONS);
258 @@ -256,15 +262,19 @@
261 pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
262 + // -- no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
263 hvalue[i] = hvalue[i-1] +
264 - 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
265 - pnt.Distance(oldpnt);
266 + // 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
267 + // pnt.Distance(oldpnt);
269 + 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
270 + pnt.Distance(oldpnt));
272 //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
273 // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
276 - dist = pnt.Distance(oldpnt);
277 + //olddist = dist; -- useless variables
278 + //dist = pnt.Distance(oldpnt);
281 // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
284 if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
286 - params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
287 + // -- for nsubedges comparable to DIVIDEEDGESECTIONS
288 + //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
289 + double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
290 + params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
291 pnt = c->Value(params[i]);
292 ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
295 (*testout) << "nedges = " << nedges << endl;
297 double eps = 1e-6 * geom.GetBoundingBox().Diam();
298 + const double eps2 = eps * eps; // -- small optimization
300 for (int i = 1; i <= nvertices; i++)
305 for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
306 - if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
307 + //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
308 + if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
314 TopoDS_Face face = TopoDS::Face(exp1.Current());
315 int facenr = geom.fmap.FindIndex(face);
316 + if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
318 if (face2solid[0][facenr-1] == 0)
319 face2solid[0][facenr-1] = solidnr;
324 + edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
326 (*testout) << "faces = " << geom.fmap.Extent() << endl;
329 //(*testout) << "ignoring degenerated edge" << endl;
332 + if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
334 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
335 geom.vmap.FindIndex(TopExp::LastVertex (edge)))
336 @@ -479,15 +497,64 @@
340 - Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
341 - Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
342 + TopoDS_Iterator vIt( edge, false );
343 + TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
344 + TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
345 + if ( v1.Orientation() == TopAbs_REVERSED )
346 + std::swap( v1, v2 );
347 + const bool isClosedEdge = v1.IsSame( v2 );
349 + Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
350 + Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
351 + double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
352 + if ( isClosedEdge )
353 + tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
357 for (PointIndex pi = 1; pi < first_ep; pi++)
359 - if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
360 - if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
361 + if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
362 + if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
364 + if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
365 + ( !isClosedEdge && pnums[0] == pnums.Last() ))
366 + pnums[0] = pnums.Last() = -1;
367 + if ( pnums[0] == -1 || pnums.Last() == -1 )
369 + // take into account a possible large gap between a vertex and an edge curve
370 + // end and a large vertex tolerance covering the whole edge
371 + if ( pnums[0] == -1 )
373 + double tol = BRep_Tool::Tolerance( v1 );
374 + for (PointIndex pi = 1; pi < first_ep; pi++)
375 + if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
378 + if ( pnums[0] == -1 )
379 + pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
381 + if ( isClosedEdge )
383 + pnums.Last() = pnums[0];
387 + if ( pnums.Last() == -1 )
389 + double tol = BRep_Tool::Tolerance( v2 );
390 + for (PointIndex pi = 1; pi < first_ep; pi++)
391 + if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
394 + if ( pnums.Last() == -1 )
395 + pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
398 + if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
399 + Dist2( lp, mesh[PointIndex(pnums.Last())]))
400 + std::swap( pnums[0], pnums.Last() );
408 (*testout) << "mesh face " << k << endl;
409 - multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
410 + // multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE
411 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
412 geom.facemeshstatus[k-1] = -1;
416 // if (k != 36) continue;
418 // (*testout) << "optimize face " << k << endl;
419 - multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
420 + //multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE
421 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
423 FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
425 @@ -1456,3 +1525,4 @@
430 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.cpp netgen-4.9.13_new/libsrc/occ/occgeom.cpp
431 --- netgen-4.9.13_orig/libsrc/occ/occgeom.cpp 2010-03-05 16:16:21.000000000 +0300
432 +++ netgen-4.9.13_new/libsrc/occ/occgeom.cpp 2011-12-20 14:50:26.000000000 +0400
434 #include "ShapeAnalysis_CheckSmallFace.hxx"
435 #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
436 #include "ShapeAnalysis_Surface.hxx"
437 +#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
438 +#include <TopAbs_State.hxx>
439 #include "BRepAlgoAPI_Fuse.hxx"
440 #include "BRepCheck_Analyzer.hxx"
441 #include "BRepLib.hxx"
443 #include "ShapeFix_FixSmallFace.hxx"
444 #include "Partition_Spliter.hxx"
449 - void OCCGeometry :: PrintNrShapes ()
450 + // free data used to optimize Project() and FastProject()
451 + OCCGeometry::~OCCGeometry()
453 + NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
454 + for (; it.More(); it.Next())
458 + void OCCGeometry :: PrintNrShapes ()
462 @@ -951,25 +960,58 @@
466 + // returns a projector and a classifier for the given surface
467 + void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
468 + BRepTopAdaptor_FClass2d*& cls) const
470 + //MSV: organize caching projector in the map
471 + if (fprjmap.IsBound(surfi))
473 + proj = fprjmap.Find(surfi);
474 + cls = fclsmap.Find(surfi);
478 + const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
479 + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
480 + proj = new ShapeAnalysis_Surface(aSurf);
481 + fprjmap.Bind(surfi, proj);
482 + cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
483 + fclsmap.Bind(surfi, cls);
488 - void OCCGeometry :: Project (int surfi, Point<3> & p) const
489 + // void OCCGeometry :: Project (int surfi, Point<3> & p) const
490 + bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
493 if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
495 gp_Pnt pnt(p(0), p(1), p(2));
498 - Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
499 - Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
500 - gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
501 - suval.Coord( u, v);
502 - pnt = thesurf->Value( u, v );
505 + // -- Optimization: use cached projector and classifier
507 + // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
508 + // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
509 + // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
510 + // suval.Coord( u, v);
511 + // pnt = thesurf->Value( u, v );
513 + Handle(ShapeAnalysis_Surface) proj;
514 + BRepTopAdaptor_FClass2d *cls;
515 + GetFaceTools(surfi, proj, cls);
517 + gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
518 + if (cls->Perform(p2d) == TopAbs_OUT)
522 + pnt = proj->Value(p2d);
525 p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
531 @@ -979,54 +1021,69 @@
533 gp_Pnt p(ap(0), ap(1), ap(2));
535 - Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
537 - gp_Pnt x = surface->Value (u,v);
539 - if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
543 - surface->D1(u,v,x,du,dv);
549 - double det, lambda, mu;
556 - det = Det3 (n.X(), du.X(), dv.X(),
557 - n.Y(), du.Y(), dv.Y(),
558 - n.Z(), du.Z(), dv.Z());
560 - if (det < 1e-15) return false;
562 - lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
563 - n.Y(), p.Y()-x.Y(), dv.Y(),
564 - n.Z(), p.Z()-x.Z(), dv.Z())/det;
566 - mu = Det3 (n.X(), du.X(), p.X()-x.X(),
567 - n.Y(), du.Y(), p.Y()-x.Y(),
568 - n.Z(), du.Z(), p.Z()-x.Z())/det;
574 - surface->D1(u,v,x,du,dv);
576 - } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
578 - // (*testout) << "FastProject count: " << count << endl;
580 - if (count == 50) return false;
582 - ap = Point<3> (x.X(), x.Y(), x.Z());
583 + // -- Optimization: use cached projector and classifier
584 + // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
586 + // gp_Pnt x = surface->Value (u,v);
588 + // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
592 + // surface->D1(u,v,x,du,dv);
598 + // double det, lambda, mu;
605 + // det = Det3 (n.X(), du.X(), dv.X(),
606 + // n.Y(), du.Y(), dv.Y(),
607 + // n.Z(), du.Z(), dv.Z());
609 + // if (det < 1e-15) return false;
611 + // lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
612 + // n.Y(), p.Y()-x.Y(), dv.Y(),
613 + // n.Z(), p.Z()-x.Z(), dv.Z())/det;
615 + // mu = Det3 (n.X(), du.X(), p.X()-x.X(),
616 + // n.Y(), du.Y(), p.Y()-x.Y(),
617 + // n.Z(), du.Z(), p.Z()-x.Z())/det;
623 + // surface->D1(u,v,x,du,dv);
625 + // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
627 + // // (*testout) << "FastProject count: " << count << endl;
629 + // if (count == 50) return false;
631 + // ap = Point<3> (x.X(), x.Y(), x.Z());
632 + Handle(ShapeAnalysis_Surface) proj;
633 + BRepTopAdaptor_FClass2d *cls;
634 + GetFaceTools(surfi, proj, cls);
636 + gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
637 + if (cls->Perform(p2d) == TopAbs_OUT)
639 + //cout << "Projection fails" << endl;
643 + p = proj->Value(p2d);
645 + ap = Point<3> (p.X(), p.Y(), p.Z());
649 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.hpp netgen-4.9.13_new/libsrc/occ/occgeom.hpp
650 --- netgen-4.9.13_orig/libsrc/occ/occgeom.hpp 2010-01-14 19:56:19.000000000 +0300
651 +++ netgen-4.9.13_new/libsrc/occ/occgeom.hpp 2011-12-20 14:50:26.000000000 +0400
653 #include "Geom_Curve.hxx"
654 #include "Geom2d_Curve.hxx"
655 #include "Geom_Surface.hxx"
656 -#include "GeomAPI_ProjectPointOnSurf.hxx"
657 -#include "GeomAPI_ProjectPointOnCurve.hxx"
658 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
659 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
660 #include "BRepTools.hxx"
661 #include "TopExp.hxx"
662 #include "BRepBuilderAPI_MakeVertex.hxx"
664 #include "Geom_Curve.hxx"
665 #include "Geom2d_Curve.hxx"
666 #include "Geom_Surface.hxx"
667 -#include "GeomAPI_ProjectPointOnSurf.hxx"
668 -#include "GeomAPI_ProjectPointOnCurve.hxx"
669 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
670 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
671 #include "TopoDS_Wire.hxx"
672 #include "BRepTools_WireExplorer.hxx"
673 #include "BRepTools.hxx"
675 #include "IGESToBRep_Reader.hxx"
676 #include "Interface_Static.hxx"
677 #include "GeomAPI_ExtremaCurveCurve.hxx"
678 -#include "Standard_ErrorHandler.hxx"
679 +//#include "Standard_ErrorHandler.hxx"
680 #include "Standard_Failure.hxx"
681 #include "ShapeUpgrade_ShellSewing.hxx"
682 #include "ShapeFix_Shape.hxx"
684 #include "ShapeAnalysis.hxx"
685 #include "ShapeBuild_ReShape.hxx"
687 +// -- Optimization: to use cached projector and classifier
688 +#include <NCollection_DataMap.hxx>
689 +class Handle_ShapeAnalysis_Surface;
690 +class BRepTopAdaptor_FClass2d;
692 // Philippose - 29/01/2009
693 // OpenCascade XDE Support
695 class OCCGeometry : public NetgenGeometry
698 + // -- Optimization: to use cached projector and classifier
699 + mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
700 + mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
708 + ~OCCGeometry(); // -- to free cached projector and classifier
712 Box<3> GetBoundingBox()
717 - void Project (int surfi, Point<3> & p) const;
718 + // void Project (int surfi, Point<3> & p) const; -- optimization
719 + bool Project (int surfi, Point<3> & p, double& u, double& v) const;
720 bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
722 + // -- Optimization: to use cached projector and classifier
723 + void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
724 + BRepTopAdaptor_FClass2d*& cls) const;
726 OCCSurface GetSurface (int surfi)
728 cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
729 diff -Naur netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp
730 --- netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp 2009-08-24 06:32:47.000000000 +0400
731 +++ netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp 2011-12-20 14:50:26.000000000 +0400
733 #include <meshing.hpp>
734 #include <GeomLProp_SLProps.hxx>
735 #include <ShapeAnalysis_Surface.hxx>
736 +#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
740 @@ -434,23 +435,33 @@
742 void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
744 - geometry.Project (surfind, p);
745 + // geometry.Project (surfind, p); -- signature of Project() changed for optimization
747 + geometry.Project (surfind, p, u, v);
751 int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
759 - if (geometry.FastProject (surfind, hp, u, v))
764 - ProjectPoint (surfind, p);
765 - return CalcPointGeomInfo (surfind, gi, p);
766 + // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
767 + // if (geometry.FastProject (surfind, hp, u, v))
772 + // ProjectPoint (surfind, p);
773 + // return CalcPointGeomInfo (surfind, gi, p);
775 + if (gi.trignum > 0)
776 + ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
778 + ok = geometry.Project (surfind, hp, gi.u, gi.v);
785 if (!geometry.FastProject (surfi, hnewp, u, v))
787 // cout << "Fast projection to surface fails! Using OCC projection" << endl;
788 - geometry.Project (surfi, hnewp);
789 + // geometry.Project (surfi, hnewp); -- Project() changed for optimization
790 + geometry.Project (surfi, hnewp, u, v);
799 + }//; -- to compile with -Wall -pedantic
802 void OCCRefinementSurfaces ::
803 @@ -708,14 +720,18 @@
804 hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
811 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
814 - geometry.Project (surfi, p);
816 + // geometry.Project (surfi, p); -- Project() changed for optimization
819 + geometry.Project (surfi, p, u, v);
821 + }//; -- to compile with -Wall -pedantic
823 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
826 if (!geometry.FastProject (surfi, p, gi.u, gi.v))
828 cout << "Fast projection to surface fails! Using OCC projection" << endl;
829 - geometry.Project (surfi, p);
831 + geometry.Project (surfi, p, u, v);
838 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx
839 --- netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx 2009-08-24 06:12:24.000000000 +0400
840 +++ netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx 2011-12-20 14:50:26.000000000 +0400
842 #include <TopOpeBRepTool_OutCurveType.hxx>
843 #include <TopOpeBRep_DSFiller.hxx>
844 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
846 +#include <Standard_Version.hxx>
850 //=======================================================================
852 Standard_Integer i, nbExt = anExtPS.NbExt();
853 Extrema_POnSurf aPOnSurf;
854 for (i = 1; i <= nbExt; ++i )
855 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
856 +// porting to OCCT6.5.1
857 + if (anExtPS.SquareDistance( i ) <= TolE * TolE) {
859 if (anExtPS.Value( i ) <= TolE) {
861 aPOnSurf = anExtPS.Point( i );
864 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx
865 --- netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx 2009-08-24 06:12:24.000000000 +0400
866 +++ netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx 2011-12-20 14:53:39.000000000 +0400
868 #include <BRepAdaptor_Surface.hxx>
869 #include <BRepAlgo_AsDes.hxx>
870 #include <BRepAlgo_FaceRestrictor.hxx>
871 -#include <BRepOffset_DataMapOfShapeReal.hxx>
872 #include <BRepTopAdaptor_FClass2d.hxx>
873 #include <BRep_Builder.hxx>
874 #include <BRep_Tool.hxx>
876 #include <gp_Pnt.hxx>
877 #include <gp_Pnt2d.hxx>
879 +#include <Standard_Version.hxx>
881 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
882 +// porting to OCCT6.5.1
883 +#include <TopTools_DataMapOfShapeReal.hxx>
885 +#include <BRepOffset_DataMapOfShapeReal.hxx>
888 //=======================================================================
889 //function : Partition_Loop2d
892 Cc->D1(uc, PC, CTg1);
893 if (!isForward) CTg1.Reverse();
895 - Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
896 + Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
898 // select an edge whose first derivative is most left of CTg1
899 // ie an angle between Tg1 and CTg1 is least
902 Standard_Real angle = Tg1.Angle(CTg1);
904 - if (PI - Abs(angle) <= tolAng)
905 + if (M_PI - Abs(angle) <= tolAng)
907 // an angle is too close to PI; assure that an angle sign really
908 // reflects an edge position: +PI - an edge is worst,
910 DC.Initialize( DegEdge, F );
912 // avoid intersecting twice the same edge
913 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
914 +// porting to OCCT6.5.1
915 + TopTools_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
917 BRepOffset_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
920 Standard_Real U, f, l;
921 BRep_Tool::Range (DegEdge, f, l);
922 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx
923 --- netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx 2009-08-24 06:12:24.000000000 +0400
924 +++ netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx 2011-12-20 14:53:05.000000000 +0400
929 - Standard_Real anglemax = - PI;
930 + Standard_Real anglemax = - M_PI;
931 TopoDS_Edge SelectedEdge;
932 for ( itl.Initialize(LE); itl.More(); itl.Next()) {
933 const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
934 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx
935 --- netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx 2009-08-24 06:12:24.000000000 +0400
936 +++ netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx 2011-12-20 14:50:26.000000000 +0400
938 #include <GeomAdaptor_Curve.hxx>
939 #include <TopOpeBRepTool_CurveTool.hxx>
941 +#include <Standard_Version.hxx>
946 @@ -1169,7 +1171,12 @@
947 for (; j<=nbj && ok; ++j) {
948 if (Extrema.IsMin(j)) {
949 hasMin = Standard_True;
950 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
951 +// porting to OCCT6.5.1
952 + ok = Extrema.SquareDistance(j) <= tol * tol;
954 ok = Extrema.Value(j) <= tol;
959 diff -Naur netgen-4.9.13_orig/libsrc/occ/utilities.h netgen-4.9.13_new/libsrc/occ/utilities.h
960 --- netgen-4.9.13_orig/libsrc/occ/utilities.h 2009-08-24 06:12:24.000000000 +0400
961 +++ netgen-4.9.13_new/libsrc/occ/utilities.h 2011-12-20 14:50:26.000000000 +0400
968 // #include "SALOME_Log.hxx"
970 diff -Naur netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp
971 --- netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp 2009-08-10 15:40:51.000000000 +0400
972 +++ netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp 2011-12-20 14:50:26.000000000 +0400
973 @@ -1435,7 +1435,8 @@
975 if (!optstring || strlen(optstring) == 0)
977 - mparam.optimize2d = "smcm";
978 + //mparam.optimize2d = (char*)"smcm";
979 + mparam.optimize2d = (char*)"smcm";
983 @@ -1451,7 +1452,8 @@
985 mesh -> LoadLocalMeshSize (mparam.meshsizefilename);
986 mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac);
987 - mparam.optimize2d = "cmsmSm";
988 + //mparam.optimize2d = (char*)"cmsmSm";
989 + mparam.optimize2d = (char*)"cmsmSm";
990 STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
992 (*statout) << GetTime() << " & ";
993 @@ -1557,7 +1559,8 @@
995 if (!optstring || strlen(optstring) == 0)
997 - mparam.optimize3d = "cmdmstm";
998 + //mparam.optimize3d = "cmdmstm";
999 + mparam.optimize3d = (char*)"cmdmstm";
1003 diff -Naur netgen-4.9.13_orig/nglib/nglib.h netgen-4.9.13_new/nglib/nglib.h
1004 --- netgen-4.9.13_orig/nglib/nglib.h 2010-05-18 15:20:25.000000000 +0400
1005 +++ netgen-4.9.13_new/nglib/nglib.h 2011-12-20 14:50:26.000000000 +0400
1007 // Philippose - 14.02.2009
1008 // Modifications for creating a DLL in Windows
1010 - #ifdef NGLIB_EXPORTS || nglib_EXPORTS
1011 + #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
1012 #define DLL_HEADER __declspec(dllexport)
1014 #define DLL_HEADER __declspec(dllimport)
1016 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp /netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp
1017 --- netgen-4.9.13_orig/libsrc/occ/occgenmesh.cpp 2013-12-04 14:39:45.000000000 +0400
1018 +++ netgen-4.9.13_new/libsrc/occ/occgenmesh.cpp 2013-12-04 15:20:24.000000000 +0400
1019 @@ -564,17 +564,20 @@
1022 for (j = first_ep; j <= mesh.GetNP(); j++)
1024 + if (!merge_solids && mesh.Point(j).GetLayer() != geomedgenr ) continue; // to support SALOME fuse edges
1025 if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
1036 - mesh.AddPoint (mp[i-1]);
1037 + mesh.AddPoint (mp[i-1], geomedgenr); // to support SALOME fuse edges
1038 (*testout) << "add meshpoint " << mp[i-1] << endl;
1039 pnums[i] = mesh.GetNP();
1042 // (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si
1043 // << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl;
1045 + for (int j = 1; j <= mesh.GetNP(); j++) // to support SALOME fuse edges: set level to zero
\r
1046 + mesh.Point(j) = MeshPoint( (Point<3>&) mesh.Point(j) );
1048 mesh.CalcSurfacesOfNode();
1049 multithread.task = savetask;