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 2014-07-22 13:01:28.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 2014-07-22 13:01:28.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 2014-07-22 13:01:28.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 2014-07-22 13:01:28.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 2014-07-22 13:01:28.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 + int first_vp = mesh.GetNP()+1; // -- to support SALOME sub-meshes
302 for (int i = 1; i <= nvertices; i++)
307 for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
308 - if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
309 + //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
310 + if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
316 TopoDS_Face face = TopoDS::Face(exp1.Current());
317 int facenr = geom.fmap.FindIndex(face);
318 + if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
320 if (face2solid[0][facenr-1] == 0)
321 face2solid[0][facenr-1] = solidnr;
326 + edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
328 (*testout) << "faces = " << geom.fmap.Extent() << endl;
331 //(*testout) << "ignoring degenerated edge" << endl;
334 + if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
336 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
337 geom.vmap.FindIndex(TopExp::LastVertex (edge)))
338 @@ -474,20 +494,104 @@
342 - pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
343 - pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
344 + //pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge));
345 + //pnums[pnums.Size()-1] = geom.vmap.FindIndex (TopExp::LastVertex (edge));
346 + MeshPoint dfltP ( Point<3> ( 0, 0, 0 ) );
347 + int *ipp[] = { &pnums[0], &pnums[pnums.Size()-1] };
348 + TopoDS_Iterator vIt( edge, false );
349 + TopoDS_Vertex v[2];
350 + v[0] = TopoDS::Vertex( vIt.Value() ); vIt.Next();
351 + v[1] = TopoDS::Vertex( vIt.Value() );
352 + if ( v[0].Orientation() == TopAbs_REVERSED )
353 + std::swap( v[0], v[1] );
354 + for ( int i = 0; i < 2; ++i)
357 + ip = geom.vmap.FindIndex ( v[i] );
358 + if ( ip == 0 || ip > nvertices )
362 + ip = iv = geom.vmap.Add( v[i] );
363 + gp_Pnt pnt = BRep_Tool::Pnt( v[i] );
364 + MeshPoint mp( Point<3>(pnt.X(), pnt.Y(), pnt.Z()) );
365 + for (PointIndex pi = 1; pi < first_vp; pi++)
366 + if ( Dist2 (mesh.Point(pi), Point<3>(mp)) < 1e-100 )
369 + if ( mesh.Point(ip).GetLayer() != dfltP.GetLayer() && mesh.Point(ip).GetLayer() != iv )
371 + if ( mesh.Point(ip).GetLayer() == dfltP.GetLayer())
372 + mesh.Point(ip) = MeshPoint( mesh.Point(ip), iv );
378 + ip += first_vp - 1;
384 - Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
385 - Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
386 + TopoDS_Iterator vIt( edge, false );
387 + TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
388 + TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
389 + if ( v1.Orientation() == TopAbs_REVERSED )
390 + std::swap( v1, v2 );
391 + const bool isClosedEdge = v1.IsSame( v2 );
393 + Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
394 + Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
395 + double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
396 + if ( isClosedEdge )
397 + tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
401 for (PointIndex pi = 1; pi < first_ep; pi++)
403 - if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
404 - if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
405 + if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
406 + if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
408 + if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
409 + ( !isClosedEdge && pnums[0] == pnums.Last() ))
410 + pnums[0] = pnums.Last() = -1;
411 + if ( pnums[0] == -1 || pnums.Last() == -1 )
413 + // take into account a possible large gap between a vertex and an edge curve
414 + // end and a large vertex tolerance covering the whole edge
415 + if ( pnums[0] == -1 )
417 + double tol = BRep_Tool::Tolerance( v1 );
418 + for (PointIndex pi = 1; pi < first_ep; pi++)
419 + if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
422 + if ( pnums[0] == -1 )
423 + pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
425 + if ( isClosedEdge )
427 + pnums.Last() = pnums[0];
431 + if ( pnums.Last() == -1 )
433 + double tol = BRep_Tool::Tolerance( v2 );
434 + for (PointIndex pi = 1; pi < first_ep; pi++)
435 + if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
438 + if ( pnums.Last() == -1 )
439 + pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
442 + if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
443 + Dist2( lp, mesh[PointIndex(pnums.Last())]))
444 + std::swap( pnums[0], pnums.Last() );
449 @@ -497,17 +601,20 @@
452 for (j = first_ep; j <= mesh.GetNP(); j++)
454 + if (!merge_solids && mesh.Point(j).GetLayer() != geomedgenr ) continue; // to support SALOME fuse edges
455 if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
466 - mesh.AddPoint (mp[i-1]);
467 + mesh.AddPoint (mp[i-1], geomedgenr); // to support SALOME fuse edges
468 (*testout) << "add meshpoint " << mp[i-1] << endl;
469 pnums[i] = mesh.GetNP();
472 // (*testout) << "edge " << mesh.LineSegment(i).edgenr << " face " << mesh.LineSegment(i).si
473 // << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl;
475 + for (int j = 1; j <= mesh.GetNP(); j++) // to support SALOME fuse edges: set level to zero
\r
476 + mesh.Point(j) = MeshPoint( (Point<3>&) mesh.Point(j) );
478 mesh.CalcSurfacesOfNode();
479 multithread.task = savetask;
483 (*testout) << "mesh face " << k << endl;
484 - multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
485 + // multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE
486 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
487 geom.facemeshstatus[k-1] = -1;
491 // if (k != 36) continue;
493 // (*testout) << "optimize face " << k << endl;
494 - multithread.percent = 100 * k / (mesh.GetNFD()+1e-10);
495 + //multithread.percent = 100 * k / (mesh.GetNFD()+1e-10); -- avoid FPE
496 + multithread.percent = 100 * k / (mesh.GetNFD() + VSMALL);
498 FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
500 @@ -1456,3 +1567,4 @@
505 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.cpp netgen-4.9.13_new/libsrc/occ/occgeom.cpp
506 --- netgen-4.9.13_orig/libsrc/occ/occgeom.cpp 2010-03-05 16:16:21.000000000 +0300
507 +++ netgen-4.9.13_new/libsrc/occ/occgeom.cpp 2014-07-22 13:01:28.000000000 +0400
509 #include "ShapeAnalysis_CheckSmallFace.hxx"
510 #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
511 #include "ShapeAnalysis_Surface.hxx"
512 +#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
513 +#include <TopAbs_State.hxx>
514 #include "BRepAlgoAPI_Fuse.hxx"
515 #include "BRepCheck_Analyzer.hxx"
516 #include "BRepLib.hxx"
518 #include "ShapeFix_FixSmallFace.hxx"
519 #include "Partition_Spliter.hxx"
524 - void OCCGeometry :: PrintNrShapes ()
525 + // free data used to optimize Project() and FastProject()
526 + OCCGeometry::~OCCGeometry()
528 + NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
529 + for (; it.More(); it.Next())
533 + void OCCGeometry :: PrintNrShapes ()
537 @@ -951,25 +960,58 @@
541 + // returns a projector and a classifier for the given surface
542 + void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
543 + BRepTopAdaptor_FClass2d*& cls) const
545 + //MSV: organize caching projector in the map
546 + if (fprjmap.IsBound(surfi))
548 + proj = fprjmap.Find(surfi);
549 + cls = fclsmap.Find(surfi);
553 + const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
554 + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
555 + proj = new ShapeAnalysis_Surface(aSurf);
556 + fprjmap.Bind(surfi, proj);
557 + cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
558 + fclsmap.Bind(surfi, cls);
563 - void OCCGeometry :: Project (int surfi, Point<3> & p) const
564 + // void OCCGeometry :: Project (int surfi, Point<3> & p) const
565 + bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
568 if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
570 gp_Pnt pnt(p(0), p(1), p(2));
573 - Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
574 - Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
575 - gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
576 - suval.Coord( u, v);
577 - pnt = thesurf->Value( u, v );
580 + // -- Optimization: use cached projector and classifier
582 + // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
583 + // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
584 + // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
585 + // suval.Coord( u, v);
586 + // pnt = thesurf->Value( u, v );
588 + Handle(ShapeAnalysis_Surface) proj;
589 + BRepTopAdaptor_FClass2d *cls;
590 + GetFaceTools(surfi, proj, cls);
592 + gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
593 + if (cls->Perform(p2d) == TopAbs_OUT)
597 + pnt = proj->Value(p2d);
600 p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
606 @@ -979,54 +1021,69 @@
608 gp_Pnt p(ap(0), ap(1), ap(2));
610 - Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
612 - gp_Pnt x = surface->Value (u,v);
614 - if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
618 - surface->D1(u,v,x,du,dv);
624 - double det, lambda, mu;
631 - det = Det3 (n.X(), du.X(), dv.X(),
632 - n.Y(), du.Y(), dv.Y(),
633 - n.Z(), du.Z(), dv.Z());
635 - if (det < 1e-15) return false;
637 - lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
638 - n.Y(), p.Y()-x.Y(), dv.Y(),
639 - n.Z(), p.Z()-x.Z(), dv.Z())/det;
641 - mu = Det3 (n.X(), du.X(), p.X()-x.X(),
642 - n.Y(), du.Y(), p.Y()-x.Y(),
643 - n.Z(), du.Z(), p.Z()-x.Z())/det;
649 - surface->D1(u,v,x,du,dv);
651 - } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
653 - // (*testout) << "FastProject count: " << count << endl;
655 - if (count == 50) return false;
657 - ap = Point<3> (x.X(), x.Y(), x.Z());
658 + // -- Optimization: use cached projector and classifier
659 + // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
661 + // gp_Pnt x = surface->Value (u,v);
663 + // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
667 + // surface->D1(u,v,x,du,dv);
673 + // double det, lambda, mu;
680 + // det = Det3 (n.X(), du.X(), dv.X(),
681 + // n.Y(), du.Y(), dv.Y(),
682 + // n.Z(), du.Z(), dv.Z());
684 + // if (det < 1e-15) return false;
686 + // lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
687 + // n.Y(), p.Y()-x.Y(), dv.Y(),
688 + // n.Z(), p.Z()-x.Z(), dv.Z())/det;
690 + // mu = Det3 (n.X(), du.X(), p.X()-x.X(),
691 + // n.Y(), du.Y(), p.Y()-x.Y(),
692 + // n.Z(), du.Z(), p.Z()-x.Z())/det;
698 + // surface->D1(u,v,x,du,dv);
700 + // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
702 + // // (*testout) << "FastProject count: " << count << endl;
704 + // if (count == 50) return false;
706 + // ap = Point<3> (x.X(), x.Y(), x.Z());
707 + Handle(ShapeAnalysis_Surface) proj;
708 + BRepTopAdaptor_FClass2d *cls;
709 + GetFaceTools(surfi, proj, cls);
711 + gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
712 + if (cls->Perform(p2d) == TopAbs_OUT)
714 + //cout << "Projection fails" << endl;
718 + p = proj->Value(p2d);
720 + ap = Point<3> (p.X(), p.Y(), p.Z());
724 diff -Naur netgen-4.9.13_orig/libsrc/occ/occgeom.hpp netgen-4.9.13_new/libsrc/occ/occgeom.hpp
725 --- netgen-4.9.13_orig/libsrc/occ/occgeom.hpp 2010-01-14 19:56:19.000000000 +0300
726 +++ netgen-4.9.13_new/libsrc/occ/occgeom.hpp 2014-07-22 13:09:03.000000000 +0400
728 #include "Geom_Curve.hxx"
729 #include "Geom2d_Curve.hxx"
730 #include "Geom_Surface.hxx"
731 -#include "GeomAPI_ProjectPointOnSurf.hxx"
732 -#include "GeomAPI_ProjectPointOnCurve.hxx"
733 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
734 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
735 #include "BRepTools.hxx"
736 #include "TopExp.hxx"
737 #include "BRepBuilderAPI_MakeVertex.hxx"
739 #include "Geom_Curve.hxx"
740 #include "Geom2d_Curve.hxx"
741 #include "Geom_Surface.hxx"
742 -#include "GeomAPI_ProjectPointOnSurf.hxx"
743 -#include "GeomAPI_ProjectPointOnCurve.hxx"
744 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
745 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
746 #include "TopoDS_Wire.hxx"
747 #include "BRepTools_WireExplorer.hxx"
748 #include "BRepTools.hxx"
750 #include "IGESToBRep_Reader.hxx"
751 #include "Interface_Static.hxx"
752 #include "GeomAPI_ExtremaCurveCurve.hxx"
753 -#include "Standard_ErrorHandler.hxx"
754 +//#include "Standard_ErrorHandler.hxx"
755 #include "Standard_Failure.hxx"
756 #include "ShapeUpgrade_ShellSewing.hxx"
757 #include "ShapeFix_Shape.hxx"
758 #include "ShapeFix_Wireframe.hxx"
759 +#include <Standard_Version.hxx>
760 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) <= 0x060702
761 +// porting to OCCT6.7.3
762 #include "BRepMesh.hxx"
764 #include "BRepMesh_IncrementalMesh.hxx"
765 #include "BRepBndLib.hxx"
766 #include "Bnd_Box.hxx"
767 #include "ShapeAnalysis.hxx"
768 #include "ShapeBuild_ReShape.hxx"
770 +// -- Optimization: to use cached projector and classifier
771 +#include <NCollection_DataMap.hxx>
772 +class Handle_ShapeAnalysis_Surface;
773 +class BRepTopAdaptor_FClass2d;
775 // Philippose - 29/01/2009
776 // OpenCascade XDE Support
778 class OCCGeometry : public NetgenGeometry
781 + // -- Optimization: to use cached projector and classifier
782 + mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
783 + mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
791 + ~OCCGeometry(); // -- to free cached projector and classifier
795 Box<3> GetBoundingBox()
800 - void Project (int surfi, Point<3> & p) const;
801 + // void Project (int surfi, Point<3> & p) const; -- optimization
802 + bool Project (int surfi, Point<3> & p, double& u, double& v) const;
803 bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
805 + // -- Optimization: to use cached projector and classifier
806 + void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
807 + BRepTopAdaptor_FClass2d*& cls) const;
809 OCCSurface GetSurface (int surfi)
811 cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
812 diff -Naur netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp
813 --- netgen-4.9.13_orig/libsrc/occ/occmeshsurf.cpp 2009-08-24 06:32:47.000000000 +0400
814 +++ netgen-4.9.13_new/libsrc/occ/occmeshsurf.cpp 2014-07-22 13:01:28.000000000 +0400
816 #include <meshing.hpp>
817 #include <GeomLProp_SLProps.hxx>
818 #include <ShapeAnalysis_Surface.hxx>
819 +#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
823 @@ -434,23 +435,33 @@
825 void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
827 - geometry.Project (surfind, p);
828 + // geometry.Project (surfind, p); -- signature of Project() changed for optimization
830 + geometry.Project (surfind, p, u, v);
834 int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
842 - if (geometry.FastProject (surfind, hp, u, v))
847 - ProjectPoint (surfind, p);
848 - return CalcPointGeomInfo (surfind, gi, p);
849 + // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
850 + // if (geometry.FastProject (surfind, hp, u, v))
855 + // ProjectPoint (surfind, p);
856 + // return CalcPointGeomInfo (surfind, gi, p);
858 + if (gi.trignum > 0)
859 + ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
861 + ok = geometry.Project (surfind, hp, gi.u, gi.v);
868 if (!geometry.FastProject (surfi, hnewp, u, v))
870 // cout << "Fast projection to surface fails! Using OCC projection" << endl;
871 - geometry.Project (surfi, hnewp);
872 + // geometry.Project (surfi, hnewp); -- Project() changed for optimization
873 + geometry.Project (surfi, hnewp, u, v);
882 + }//; -- to compile with -Wall -pedantic
885 void OCCRefinementSurfaces ::
886 @@ -708,14 +720,18 @@
887 hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
894 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
897 - geometry.Project (surfi, p);
899 + // geometry.Project (surfi, p); -- Project() changed for optimization
902 + geometry.Project (surfi, p, u, v);
904 + }//; -- to compile with -Wall -pedantic
906 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
909 if (!geometry.FastProject (surfi, p, gi.u, gi.v))
911 cout << "Fast projection to surface fails! Using OCC projection" << endl;
912 - geometry.Project (surfi, p);
914 + geometry.Project (surfi, p, u, v);
921 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx
922 --- netgen-4.9.13_orig/libsrc/occ/Partition_Inter3d.cxx 2009-08-24 06:12:24.000000000 +0400
923 +++ netgen-4.9.13_new/libsrc/occ/Partition_Inter3d.cxx 2014-07-22 13:01:28.000000000 +0400
925 #include <TopOpeBRepTool_OutCurveType.hxx>
926 #include <TopOpeBRep_DSFiller.hxx>
927 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
929 +#include <Standard_Version.hxx>
933 //=======================================================================
935 Standard_Integer i, nbExt = anExtPS.NbExt();
936 Extrema_POnSurf aPOnSurf;
937 for (i = 1; i <= nbExt; ++i )
938 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
939 +// porting to OCCT6.5.1
940 + if (anExtPS.SquareDistance( i ) <= TolE * TolE) {
942 if (anExtPS.Value( i ) <= TolE) {
944 aPOnSurf = anExtPS.Point( i );
947 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx
948 --- netgen-4.9.13_orig/libsrc/occ/Partition_Loop2d.cxx 2009-08-24 06:12:24.000000000 +0400
949 +++ netgen-4.9.13_new/libsrc/occ/Partition_Loop2d.cxx 2014-07-22 13:01:28.000000000 +0400
951 #include <BRepAdaptor_Surface.hxx>
952 #include <BRepAlgo_AsDes.hxx>
953 #include <BRepAlgo_FaceRestrictor.hxx>
954 -#include <BRepOffset_DataMapOfShapeReal.hxx>
955 #include <BRepTopAdaptor_FClass2d.hxx>
956 #include <BRep_Builder.hxx>
957 #include <BRep_Tool.hxx>
959 #include <gp_Pnt.hxx>
960 #include <gp_Pnt2d.hxx>
962 +#include <Standard_Version.hxx>
964 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
965 +// porting to OCCT6.5.1
966 +#include <TopTools_DataMapOfShapeReal.hxx>
968 +#include <BRepOffset_DataMapOfShapeReal.hxx>
971 //=======================================================================
972 //function : Partition_Loop2d
975 Cc->D1(uc, PC, CTg1);
976 if (!isForward) CTg1.Reverse();
978 - Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
979 + Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
981 // select an edge whose first derivative is most left of CTg1
982 // ie an angle between Tg1 and CTg1 is least
985 Standard_Real angle = Tg1.Angle(CTg1);
987 - if (PI - Abs(angle) <= tolAng)
988 + if (M_PI - Abs(angle) <= tolAng)
990 // an angle is too close to PI; assure that an angle sign really
991 // reflects an edge position: +PI - an edge is worst,
993 DC.Initialize( DegEdge, F );
995 // avoid intersecting twice the same edge
996 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
997 +// porting to OCCT6.5.1
998 + TopTools_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
1000 BRepOffset_DataMapOfShapeReal EUMap ( EdgesList.Extent() );
1003 Standard_Real U, f, l;
1004 BRep_Tool::Range (DegEdge, f, l);
1005 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx
1006 --- netgen-4.9.13_orig/libsrc/occ/Partition_Loop.cxx 2009-08-24 06:12:24.000000000 +0400
1007 +++ netgen-4.9.13_new/libsrc/occ/Partition_Loop.cxx 2014-07-22 13:01:28.000000000 +0400
1012 - Standard_Real anglemax = - PI;
1013 + Standard_Real anglemax = - M_PI;
1014 TopoDS_Edge SelectedEdge;
1015 for ( itl.Initialize(LE); itl.More(); itl.Next()) {
1016 const TopoDS_Edge& E = TopoDS::Edge(itl.Value());
1017 diff -Naur netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx
1018 --- netgen-4.9.13_orig/libsrc/occ/Partition_Spliter.cxx 2009-08-24 06:12:24.000000000 +0400
1019 +++ netgen-4.9.13_new/libsrc/occ/Partition_Spliter.cxx 2014-07-22 13:01:28.000000000 +0400
1021 #include <GeomAdaptor_Curve.hxx>
1022 #include <TopOpeBRepTool_CurveTool.hxx>
1024 +#include <Standard_Version.hxx>
1027 //# define PART_PERF
1029 @@ -1169,7 +1171,12 @@
1030 for (; j<=nbj && ok; ++j) {
1031 if (Extrema.IsMin(j)) {
1032 hasMin = Standard_True;
1033 +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060400
1034 +// porting to OCCT6.5.1
1035 + ok = Extrema.SquareDistance(j) <= tol * tol;
1037 ok = Extrema.Value(j) <= tol;
1042 diff -Naur netgen-4.9.13_orig/libsrc/occ/utilities.h netgen-4.9.13_new/libsrc/occ/utilities.h
1043 --- netgen-4.9.13_orig/libsrc/occ/utilities.h 2009-08-24 06:12:24.000000000 +0400
1044 +++ netgen-4.9.13_new/libsrc/occ/utilities.h 2014-07-22 13:01:28.000000000 +0400
1051 // #include "SALOME_Log.hxx"
1053 diff -Naur netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp
1054 --- netgen-4.9.13_orig/libsrc/stlgeom/stlgeommesh.cpp 2009-08-10 15:40:51.000000000 +0400
1055 +++ netgen-4.9.13_new/libsrc/stlgeom/stlgeommesh.cpp 2014-07-22 13:01:28.000000000 +0400
1056 @@ -1435,7 +1435,8 @@
1058 if (!optstring || strlen(optstring) == 0)
1060 - mparam.optimize2d = "smcm";
1061 + //mparam.optimize2d = (char*)"smcm";
1062 + mparam.optimize2d = (char*)"smcm";
1066 @@ -1451,7 +1452,8 @@
1068 mesh -> LoadLocalMeshSize (mparam.meshsizefilename);
1069 mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac);
1070 - mparam.optimize2d = "cmsmSm";
1071 + //mparam.optimize2d = (char*)"cmsmSm";
1072 + mparam.optimize2d = (char*)"cmsmSm";
1073 STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
1075 (*statout) << GetTime() << " & ";
1076 @@ -1557,7 +1559,8 @@
1078 if (!optstring || strlen(optstring) == 0)
1080 - mparam.optimize3d = "cmdmstm";
1081 + //mparam.optimize3d = "cmdmstm";
1082 + mparam.optimize3d = (char*)"cmdmstm";
1086 diff -Naur netgen-4.9.13_orig/nglib/nglib.h netgen-4.9.13_new/nglib/nglib.h
1087 --- netgen-4.9.13_orig/nglib/nglib.h 2010-05-18 15:20:25.000000000 +0400
1088 +++ netgen-4.9.13_new/nglib/nglib.h 2014-07-22 13:01:28.000000000 +0400
1090 // Philippose - 14.02.2009
1091 // Modifications for creating a DLL in Windows
1093 - #ifdef NGLIB_EXPORTS || nglib_EXPORTS
1094 + #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
1095 #define DLL_HEADER __declspec(dllexport)
1097 #define DLL_HEADER __declspec(dllimport)