1 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/meshing/meshtype.cpp netgen-5.0.0.patched/libsrc/meshing/meshtype.cpp
2 --- netgen-5.0.0.orig/libsrc/meshing/meshtype.cpp 2012-11-09 19:15:04.000000000 +0400
3 +++ netgen-5.0.0.patched/libsrc/meshing/meshtype.cpp 2013-02-21 17:46:13.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 @@ -2513,10 +2521,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 --exclude=CVS netgen-5.0.0.orig/libsrc/meshing/meshtype.hpp netgen-5.0.0.patched/libsrc/meshing/meshtype.hpp
103 --- netgen-5.0.0.orig/libsrc/meshing/meshtype.hpp 2012-11-09 19:15:04.000000000 +0400
104 +++ netgen-5.0.0.patched/libsrc/meshing/meshtype.hpp 2013-02-21 17:46:13.000000000 +0400
109 +class Mesh; // added due to compilation errors on some platforms
113 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/meshing/smoothing2.cpp netgen-5.0.0.patched/libsrc/meshing/smoothing2.cpp
114 --- netgen-5.0.0.orig/libsrc/meshing/smoothing2.cpp 2012-11-09 19:15:04.000000000 +0400
115 +++ netgen-5.0.0.patched/libsrc/meshing/smoothing2.cpp 2013-02-25 11:20:05.000000000 +0400
120 - ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
121 + //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
123 pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
125 // meshthis -> ProjectPoint (surfi, pp1);
130 - ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
131 + //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
134 pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
140 - ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
141 + //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
144 pp1 = ld.sp1 + x(0) * ld.t1 + x(1) * ld.t2;
150 - ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.gi1, n);
151 + //normal already computed: ld.meshthis -> GetNormalVector (ld.surfi, ld.sp1, ld.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 --exclude=CVS netgen-5.0.0.orig/libsrc/occ/Partition_Inter3d.cxx netgen-5.0.0.patched/libsrc/occ/Partition_Inter3d.cxx
166 --- netgen-5.0.0.orig/libsrc/occ/Partition_Inter3d.cxx 2012-11-09 19:15:02.000000000 +0400
167 +++ netgen-5.0.0.patched/libsrc/occ/Partition_Inter3d.cxx 2013-02-25 13:51:48.000000000 +0400
169 Standard_Integer i, nbExt = anExtPS.NbExt();
170 Extrema_POnSurf aPOnSurf;
171 for (i = 1; i <= nbExt; ++i )
172 - if (anExtPS.Value( i ) <= TolE) // V6.3
173 - // if (anExtPS.SquareDistance( i ) <= TolE) // V6.5
175 + // porting to OCCT6.5.1
176 + //if (anExtPS.Value( i ) <= TolE) // V6.3
177 + // if (anExtPS.SquareDistance( i ) <= TolE) // V6.5
178 + if (anExtPS.SquareDistance( i ) <= TolE * TolE)
180 aPOnSurf = anExtPS.Point( i );
183 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/Partition_Loop2d.cxx netgen-5.0.0.patched/libsrc/occ/Partition_Loop2d.cxx
184 --- netgen-5.0.0.orig/libsrc/occ/Partition_Loop2d.cxx 2012-11-09 19:15:02.000000000 +0400
185 +++ netgen-5.0.0.patched/libsrc/occ/Partition_Loop2d.cxx 2013-02-25 13:48:15.000000000 +0400
187 Cc->D1(uc, PC, CTg1);
188 if (!isForward) CTg1.Reverse();
190 - Standard_Real anglemin = 3 * PI, tolAng = 1.e-8;
191 + Standard_Real anglemin = 3 * M_PI, tolAng = 1.e-8;
193 // select an edge whose first derivative is most left of CTg1
194 // ie an angle between Tg1 and CTg1 is least
197 Standard_Real angle = Tg1.Angle(CTg1);
199 - if (PI - Abs(angle) <= tolAng)
200 + if (M_PI - Abs(angle) <= tolAng)
202 // an angle is too close to PI; assure that an angle sign really
203 // reflects an edge position: +PI - an edge is worst,
204 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/Partition_Spliter.cxx netgen-5.0.0.patched/libsrc/occ/Partition_Spliter.cxx
205 --- netgen-5.0.0.orig/libsrc/occ/Partition_Spliter.cxx 2012-11-09 19:15:02.000000000 +0400
206 +++ netgen-5.0.0.patched/libsrc/occ/Partition_Spliter.cxx 2013-02-25 13:55:10.000000000 +0400
207 @@ -1169,8 +1169,10 @@
208 for (; j<=nbj && ok; ++j) {
209 if (Extrema.IsMin(j)) {
210 hasMin = Standard_True;
211 - ok = Extrema.Value(j) <= tol; // V6.3
212 + // porting to OCCT6.5.1
213 + //ok = Extrema.Value(j) <= tol; // V6.3
214 // ok = Extrema.SquareDistance(j) <= tol; // V6.5
215 + ok = Extrema.SquareDistance(j) <= tol * tol;
219 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occconstruction.cpp netgen-5.0.0.patched/libsrc/occ/occconstruction.cpp
220 --- netgen-5.0.0.orig/libsrc/occ/occconstruction.cpp 2012-11-09 19:15:02.000000000 +0400
221 +++ netgen-5.0.0.patched/libsrc/occ/occconstruction.cpp 2013-02-21 17:46:13.000000000 +0400
223 #include <BRepAlgoAPI_Common.hxx>
224 #include <BRepAlgoAPI_Fuse.hxx>
225 #include <BRepAlgoAPI_Section.hxx>
226 -#include <BRepOffsetAPI_Sewing.hxx>
227 +//#include <BRepOffsetAPI_Sewing.hxx>
228 //#include <BRepAlgo_Sewing.hxx>
229 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
230 #include <ShapeFix_Shape.hxx>
231 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occgenmesh.cpp netgen-5.0.0.patched/libsrc/occ/occgenmesh.cpp
232 --- netgen-5.0.0.orig/libsrc/occ/occgenmesh.cpp 2012-11-09 19:15:02.000000000 +0400
233 +++ netgen-5.0.0.patched/libsrc/occ/occgenmesh.cpp 2013-02-21 17:46:13.000000000 +0400
239 + static // useless out of this file
240 double ComputeH (double kappa)
249 + static // useless out of this file
250 void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
251 BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h = 0)
258 - if (h > 30) return;
259 + // commented to restrict H on a large sphere for example
260 + //if (h > 30) return;
263 if (h < maxside && depth < 10)
268 + static // useless out of this file
269 void DivideEdge (TopoDS_Edge & edge, Array<MeshPoint> & ps,
270 Array<double> & params, Mesh & mesh)
276 - double olddist = 0;
278 + //double olddist = 0; -- useless variables
281 int tmpVal = (int)(DIVIDEEDGESECTIONS);
283 @@ -259,15 +261,19 @@
286 pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
287 + // -- no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
288 hvalue[i] = hvalue[i-1] +
289 - 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
290 - pnt.Distance(oldpnt);
291 + // 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
292 + // pnt.Distance(oldpnt);
294 + 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
295 + pnt.Distance(oldpnt));
297 //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
298 // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
301 - dist = pnt.Distance(oldpnt);
302 + //olddist = dist; -- useless variables
303 + //dist = pnt.Distance(oldpnt);
306 // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
309 if (hvalue[i1]/hvalue[DIVIDEEDGESECTIONS]*nsubedges >= i)
311 - params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
312 + // -- for nsubedges comparable to DIVIDEEDGESECTIONS
313 + //params[i] = s0+(i1/double(DIVIDEEDGESECTIONS))*(s1-s0);
314 + double d1 = i1 - (hvalue[i1] - i*hvalue[DIVIDEEDGESECTIONS]/nsubedges)/(hvalue[i1]-hvalue[i1-1]);
315 + params[i] = s0+(d1/double(DIVIDEEDGESECTIONS))*(s1-s0);
316 pnt = c->Value(params[i]);
317 ps[i-1] = MeshPoint (Point3d(pnt.X(), pnt.Y(), pnt.Z()));
320 (*testout) << "nedges = " << nedges << endl;
322 double eps = 1e-6 * geom.GetBoundingBox().Diam();
323 + const double eps2 = eps * eps; // -- small optimization
325 for (int i = 1; i <= nvertices; i++)
330 for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
331 - if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
332 + //if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
333 + if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2 ) // -- small optimization
339 TopoDS_Face face = TopoDS::Face(exp1.Current());
340 int facenr = geom.fmap.FindIndex(face);
341 + if ( facenr < 1 ) continue; // -- to support SALOME sub-meshes
343 if (face2solid[0][facenr-1] == 0)
344 face2solid[0][facenr-1] = solidnr;
349 + edgenr = mesh.GetNSeg(); // to support SALOME sub-meshes
351 (*testout) << "faces = " << geom.fmap.Extent() << endl;
354 //(*testout) << "ignoring degenerated edge" << endl;
357 + if ( geom.emap.FindIndex(edge) < 1 ) continue; // to support SALOME sub-meshes
359 if (geom.vmap.FindIndex(TopExp::FirstVertex (edge)) ==
360 geom.vmap.FindIndex(TopExp::LastVertex (edge)))
361 @@ -482,15 +496,64 @@
365 - Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
366 - Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
367 + TopoDS_Iterator vIt( edge, false );
368 + TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
369 + TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
370 + if ( v1.Orientation() == TopAbs_REVERSED )
371 + std::swap( v1, v2 );
372 + const bool isClosedEdge = v1.IsSame( v2 );
374 + Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
375 + Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
376 + double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
377 + if ( isClosedEdge )
378 + tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
382 for (PointIndex pi = 1; pi < first_ep; pi++)
384 - if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
385 - if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
386 + if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
387 + if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
389 + if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
390 + ( !isClosedEdge && pnums[0] == pnums.Last() ))
391 + pnums[0] = pnums.Last() = -1;
392 + if ( pnums[0] == -1 || pnums.Last() == -1 )
394 + // take into account a possible large gap between a vertex and an edge curve
395 + // end and a large vertex tolerance covering the whole edge
396 + if ( pnums[0] == -1 )
398 + double tol = BRep_Tool::Tolerance( v1 );
399 + for (PointIndex pi = 1; pi < first_ep; pi++)
400 + if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
403 + if ( pnums[0] == -1 )
404 + pnums[0] = first_ep-1- nvertices + geom.vmap.FindIndex ( v1 );
406 + if ( isClosedEdge )
408 + pnums.Last() = pnums[0];
412 + if ( pnums.Last() == -1 )
414 + double tol = BRep_Tool::Tolerance( v2 );
415 + for (PointIndex pi = 1; pi < first_ep; pi++)
416 + if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
419 + if ( pnums.Last() == -1 )
420 + pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
423 + if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
424 + Dist2( lp, mesh[PointIndex(pnums.Last())]))
425 + std::swap( pnums[0], pnums.Last() );
430 @@ -1458,3 +1521,4 @@
435 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occgeom.cpp netgen-5.0.0.patched/libsrc/occ/occgeom.cpp
436 --- netgen-5.0.0.orig/libsrc/occ/occgeom.cpp 2012-11-09 19:15:02.000000000 +0400
437 +++ netgen-5.0.0.patched/libsrc/occ/occgeom.cpp 2013-02-21 17:46:13.000000000 +0400
439 #include "ShapeAnalysis_CheckSmallFace.hxx"
440 #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
441 #include "ShapeAnalysis_Surface.hxx"
442 +#include <BRepTopAdaptor_FClass2d.hxx> // -- to optimize Project() and FastProject()
443 +#include <TopAbs_State.hxx>
444 #include "BRepAlgoAPI_Fuse.hxx"
445 #include "BRepCheck_Analyzer.hxx"
446 #include "BRepLib.hxx"
448 #include "ShapeFix_FixSmallFace.hxx"
449 #include "Partition_Spliter.hxx"
454 - void OCCGeometry :: PrintNrShapes ()
455 + // free data used to optimize Project() and FastProject()
456 + OCCGeometry::~OCCGeometry()
458 + NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
459 + for (; it.More(); it.Next())
463 + void OCCGeometry :: PrintNrShapes ()
467 @@ -951,25 +960,58 @@
471 + // returns a projector and a classifier for the given surface
472 + void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
473 + BRepTopAdaptor_FClass2d*& cls) const
475 + //MSV: organize caching projector in the map
476 + if (fprjmap.IsBound(surfi))
478 + proj = fprjmap.Find(surfi);
479 + cls = fclsmap.Find(surfi);
483 + const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
484 + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
485 + proj = new ShapeAnalysis_Surface(aSurf);
486 + fprjmap.Bind(surfi, proj);
487 + cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
488 + fclsmap.Bind(surfi, cls);
493 - void OCCGeometry :: Project (int surfi, Point<3> & p) const
494 + // void OCCGeometry :: Project (int surfi, Point<3> & p) const
495 + bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
498 if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
500 gp_Pnt pnt(p(0), p(1), p(2));
503 - Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
504 - Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
505 - gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
506 - suval.Coord( u, v);
507 - pnt = thesurf->Value( u, v );
510 + // -- Optimization: use cached projector and classifier
512 + // Handle( Geom_Surface ) thesurf = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
513 + // Handle( ShapeAnalysis_Surface ) su = new ShapeAnalysis_Surface( thesurf );
514 + // gp_Pnt2d suval = su->ValueOfUV ( pnt, BRep_Tool::Tolerance( TopoDS::Face(fmap(surfi)) ) );
515 + // suval.Coord( u, v);
516 + // pnt = thesurf->Value( u, v );
518 + Handle(ShapeAnalysis_Surface) proj;
519 + BRepTopAdaptor_FClass2d *cls;
520 + GetFaceTools(surfi, proj, cls);
522 + gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
523 + if (cls->Perform(p2d) == TopAbs_OUT)
527 + pnt = proj->Value(p2d);
530 p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
536 @@ -979,54 +1021,69 @@
538 gp_Pnt p(ap(0), ap(1), ap(2));
540 - Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
542 - gp_Pnt x = surface->Value (u,v);
544 - if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
548 - surface->D1(u,v,x,du,dv);
554 - double det, lambda, mu;
561 - det = Det3 (n.X(), du.X(), dv.X(),
562 - n.Y(), du.Y(), dv.Y(),
563 - n.Z(), du.Z(), dv.Z());
565 - if (det < 1e-15) return false;
567 - lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
568 - n.Y(), p.Y()-x.Y(), dv.Y(),
569 - n.Z(), p.Z()-x.Z(), dv.Z())/det;
571 - mu = Det3 (n.X(), du.X(), p.X()-x.X(),
572 - n.Y(), du.Y(), p.Y()-x.Y(),
573 - n.Z(), du.Z(), p.Z()-x.Z())/det;
579 - surface->D1(u,v,x,du,dv);
581 - } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
583 - // (*testout) << "FastProject count: " << count << endl;
585 - if (count == 50) return false;
587 - ap = Point<3> (x.X(), x.Y(), x.Z());
588 + // -- Optimization: use cached projector and classifier
589 + // Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
591 + // gp_Pnt x = surface->Value (u,v);
593 + // if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
597 + // surface->D1(u,v,x,du,dv);
603 + // double det, lambda, mu;
610 + // det = Det3 (n.X(), du.X(), dv.X(),
611 + // n.Y(), du.Y(), dv.Y(),
612 + // n.Z(), du.Z(), dv.Z());
614 + // if (det < 1e-15) return false;
616 + // lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
617 + // n.Y(), p.Y()-x.Y(), dv.Y(),
618 + // n.Z(), p.Z()-x.Z(), dv.Z())/det;
620 + // mu = Det3 (n.X(), du.X(), p.X()-x.X(),
621 + // n.Y(), du.Y(), p.Y()-x.Y(),
622 + // n.Z(), du.Z(), p.Z()-x.Z())/det;
628 + // surface->D1(u,v,x,du,dv);
630 + // } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
632 + // // (*testout) << "FastProject count: " << count << endl;
634 + // if (count == 50) return false;
636 + // ap = Point<3> (x.X(), x.Y(), x.Z());
637 + Handle(ShapeAnalysis_Surface) proj;
638 + BRepTopAdaptor_FClass2d *cls;
639 + GetFaceTools(surfi, proj, cls);
641 + gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
642 + if (cls->Perform(p2d) == TopAbs_OUT)
644 + //cout << "Projection fails" << endl;
648 + p = proj->Value(p2d);
650 + ap = Point<3> (p.X(), p.Y(), p.Z());
654 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occgeom.hpp netgen-5.0.0.patched/libsrc/occ/occgeom.hpp
655 --- netgen-5.0.0.orig/libsrc/occ/occgeom.hpp 2012-11-09 19:15:02.000000000 +0400
656 +++ netgen-5.0.0.patched/libsrc/occ/occgeom.hpp 2013-02-21 17:46:13.000000000 +0400
658 #include "Geom_Curve.hxx"
659 #include "Geom2d_Curve.hxx"
660 #include "Geom_Surface.hxx"
661 -#include "GeomAPI_ProjectPointOnSurf.hxx"
662 -#include "GeomAPI_ProjectPointOnCurve.hxx"
663 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
664 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
665 #include "BRepTools.hxx"
666 #include "TopExp.hxx"
667 #include "BRepBuilderAPI_MakeVertex.hxx"
669 #include "Geom_Curve.hxx"
670 #include "Geom2d_Curve.hxx"
671 #include "Geom_Surface.hxx"
672 -#include "GeomAPI_ProjectPointOnSurf.hxx"
673 -#include "GeomAPI_ProjectPointOnCurve.hxx"
674 +// #include "GeomAPI_ProjectPointOnSurf.hxx"
675 +// #include "GeomAPI_ProjectPointOnCurve.hxx"
676 #include "TopoDS_Wire.hxx"
677 #include "BRepTools_WireExplorer.hxx"
678 #include "BRepTools.hxx"
680 #include "IGESToBRep_Reader.hxx"
681 #include "Interface_Static.hxx"
682 #include "GeomAPI_ExtremaCurveCurve.hxx"
683 -#include "Standard_ErrorHandler.hxx"
684 +//#include "Standard_ErrorHandler.hxx"
685 #include "Standard_Failure.hxx"
686 #include "ShapeUpgrade_ShellSewing.hxx"
687 #include "ShapeFix_Shape.hxx"
689 #include "ShapeAnalysis.hxx"
690 #include "ShapeBuild_ReShape.hxx"
692 +// -- Optimization: to use cached projector and classifier
693 +#include <NCollection_DataMap.hxx>
694 +class Handle_ShapeAnalysis_Surface;
695 +class BRepTopAdaptor_FClass2d;
697 // Philippose - 29/01/2009
698 // OpenCascade XDE Support
700 class OCCGeometry : public NetgenGeometry
703 + // -- Optimization: to use cached projector and classifier
704 + mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
705 + mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
710 virtual void Save (string filename) const;
713 + ~OCCGeometry(); // -- to free cached projector and classifier
717 Box<3> GetBoundingBox()
722 - void Project (int surfi, Point<3> & p) const;
723 + // void Project (int surfi, Point<3> & p) const; -- optimization
724 + bool Project (int surfi, Point<3> & p, double& u, double& v) const;
725 bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
727 + // -- Optimization: to use cached projector and classifier
728 + void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
729 + BRepTopAdaptor_FClass2d*& cls) const;
731 OCCSurface GetSurface (int surfi)
733 cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
734 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/occmeshsurf.cpp netgen-5.0.0.patched/libsrc/occ/occmeshsurf.cpp
735 --- netgen-5.0.0.orig/libsrc/occ/occmeshsurf.cpp 2012-11-09 19:15:02.000000000 +0400
736 +++ netgen-5.0.0.patched/libsrc/occ/occmeshsurf.cpp 2013-02-25 13:27:49.000000000 +0400
738 #include <meshing.hpp>
739 #include <GeomLProp_SLProps.hxx>
740 #include <ShapeAnalysis_Surface.hxx>
741 +#include <GeomAPI_ProjectPointOnCurve.hxx> // -- moved here from occgeom.hpp
745 @@ -434,23 +435,33 @@
747 void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point<3> & p) const
749 - geometry.Project (surfind, p);
750 + // geometry.Project (surfind, p); -- signature of Project() changed for optimization
752 + geometry.Project (surfind, p, u, v);
756 int MeshOptimize2dOCCSurfaces :: ProjectPointGI (INDEX surfind, Point<3> & p, PointGeomInfo & gi) const
764 - if (geometry.FastProject (surfind, hp, u, v))
769 - ProjectPoint (surfind, p);
770 - return CalcPointGeomInfo (surfind, gi, p);
771 + // -- u and v are computed by FastProject() and Project(), no need to call CalcPointGeomInfo()
772 + // if (geometry.FastProject (surfind, hp, u, v))
777 + // ProjectPoint (surfind, p);
778 + // return CalcPointGeomInfo (surfind, gi, p);
780 + if (gi.trignum > 0)
781 + ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
783 + ok = geometry.Project (surfind, hp, gi.u, gi.v);
790 if (!geometry.FastProject (surfi, hnewp, u, v))
792 // cout << "Fast projection to surface fails! Using OCC projection" << endl;
793 - geometry.Project (surfi, hnewp);
794 + // geometry.Project (surfi, hnewp); -- Project() changed for optimization
795 + geometry.Project (surfi, hnewp, u, v);
804 + }//; -- to compile with -Wall -pedantic
807 void OCCRefinementSurfaces ::
808 @@ -708,14 +720,18 @@
809 hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
816 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const
819 - geometry.Project (surfi, p);
821 + // geometry.Project (surfi, p); -- Project() changed for optimization
824 + geometry.Project (surfi, p, u, v);
826 + }//; -- to compile with -Wall -pedantic
828 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const
831 if (!geometry.FastProject (surfi, p, gi.u, gi.v))
833 cout << "Fast projection to surface fails! Using OCC projection" << endl;
834 - geometry.Project (surfi, p);
836 + geometry.Project (surfi, p, u, v);
843 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/occ/utilities.h netgen-5.0.0.patched/libsrc/occ/utilities.h
844 --- netgen-5.0.0.orig/libsrc/occ/utilities.h 2012-11-09 19:15:02.000000000 +0400
845 +++ netgen-5.0.0.patched/libsrc/occ/utilities.h 2013-02-21 17:47:08.000000000 +0400
852 // #include "SALOME_Log.hxx"
854 diff -Naur --exclude=CVS netgen-5.0.0.orig/libsrc/stlgeom/stlgeommesh.cpp netgen-5.0.0.patched/libsrc/stlgeom/stlgeommesh.cpp
855 --- netgen-5.0.0.orig/libsrc/stlgeom/stlgeommesh.cpp 2012-11-09 19:15:04.000000000 +0400
856 +++ netgen-5.0.0.patched/libsrc/stlgeom/stlgeommesh.cpp 2013-02-21 17:52:07.000000000 +0400
857 @@ -1435,7 +1435,8 @@
859 if (!optstring || strlen(optstring) == 0)
861 - mparam.optimize2d = "smcm";
862 + //mparam.optimize2d = (char*)"smcm";
863 + mparam.optimize2d = (char*)"smcm";
867 @@ -1453,7 +1454,7 @@
868 mesh -> LoadLocalMeshSize (mparam.meshsizefilename);
869 mesh -> CalcLocalHFromSurfaceCurvature (mparam.grading,
870 stlparam.resthsurfmeshcurvfac);
871 - mparam.optimize2d = "cmsmSm";
872 + mparam.optimize2d = "(char*)cmsmSm";
873 STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
875 (*statout) << GetTime() << " & ";
876 @@ -1560,7 +1561,8 @@
878 if (!optstring || strlen(optstring) == 0)
880 - mparam.optimize3d = "cmdmstm";
881 + //mparam.optimize3d = "cmdmstm";
882 + mparam.optimize3d = (char*)"cmdmstm";
886 diff -Naur --exclude=CVS netgen-5.0.0.orig/nglib/nglib.h netgen-5.0.0.patched/nglib/nglib.h
887 --- netgen-5.0.0.orig/nglib/nglib.h 2012-11-09 19:15:00.000000000 +0400
888 +++ netgen-5.0.0.patched/nglib/nglib.h 2013-02-21 17:47:08.000000000 +0400
890 // Philippose - 14.02.2009
891 // Modifications for creating a DLL in Windows
893 - #ifdef NGLIB_EXPORTS || nglib_EXPORTS
894 + #if defined NGLIB_EXPORTS || defined nglib_EXPORTS
895 #define DLL_HEADER __declspec(dllexport)
897 #define DLL_HEADER __declspec(dllimport)