1 diff -Naur netgen-4.5.old/libsrc/csg/meshsurf.cpp netgen-4.5.new/libsrc/csg/meshsurf.cpp
2 --- netgen-4.5.old/libsrc/csg/meshsurf.cpp 2006-02-14 11:54:35.000000000 +0300
3 +++ netgen-4.5.new/libsrc/csg/meshsurf.cpp 2008-02-12 14:57:01.000000000 +0300
8 -void MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const
9 +bool MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const
12 geometry.GetSurface(surfind)->Project (hp);
17 void MeshOptimize2dSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2,
18 diff -Naur netgen-4.5.old/libsrc/csg/meshsurf.hpp netgen-4.5.new/libsrc/csg/meshsurf.hpp
19 --- netgen-4.5.old/libsrc/csg/meshsurf.hpp 2004-01-20 14:49:44.000000000 +0300
20 +++ netgen-4.5.new/libsrc/csg/meshsurf.hpp 2008-02-12 14:57:01.000000000 +0300
22 MeshOptimize2dSurfaces (const CSGeometry & ageometry);
25 - virtual void ProjectPoint (INDEX surfind, Point3d & p) const;
26 + virtual bool ProjectPoint (INDEX surfind, Point3d & p) const;
28 virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const;
30 diff -Naur netgen-4.5.old/libsrc/interface/Makefile netgen-4.5.new/libsrc/interface/Makefile
31 --- netgen-4.5.old/libsrc/interface/Makefile 2005-08-09 18:14:59.000000000 +0400
32 +++ netgen-4.5.new/libsrc/interface/Makefile 2008-02-12 14:57:01.000000000 +0300
34 -src = nginterface.cpp writeuser.cpp writediffpack.cpp writeabaqus.cpp writefluent.cpp writepermas.cpp writetochnog.cpp writetecplot.cpp wuchemnitz.cpp writetochnog.cpp writefeap.cpp writeelmer.cpp writegmsh.cpp writejcm.cpp readuser.cpp importsolution.cpp
35 +#src = nginterface.cpp writeuser.cpp writediffpack.cpp writeabaqus.cpp writefluent.cpp writepermas.cpp writetochnog.cpp writetecplot.cpp wuchemnitz.cpp writetochnog.cpp writefeap.cpp writeelmer.cpp writegmsh.cpp writejcm.cpp readuser.cpp importsolution.cpp
36 +src = writeuser.cpp writediffpack.cpp writeabaqus.cpp writefluent.cpp writepermas.cpp writetochnog.cpp writetecplot.cpp wuchemnitz.cpp writetochnog.cpp writefeap.cpp writeelmer.cpp writegmsh.cpp writejcm.cpp readuser.cpp nglib.cpp ngnewdelete.cpp
39 libpath = libsrc/interface
40 diff -Naur netgen-4.5.old/libsrc/interface/nglib.cpp netgen-4.5.new/libsrc/interface/nglib.cpp
41 --- netgen-4.5.old/libsrc/interface/nglib.cpp 2005-10-18 17:53:18.000000000 +0400
42 +++ netgen-4.5.new/libsrc/interface/nglib.cpp 2008-02-12 14:57:01.000000000 +0300
53 diff -Naur netgen-4.5.old/libsrc/makefile.inc netgen-4.5.new/libsrc/makefile.inc
54 --- netgen-4.5.old/libsrc/makefile.inc 2005-09-02 17:17:51.000000000 +0400
55 +++ netgen-4.5.new/libsrc/makefile.inc 2008-02-12 14:59:55.000000000 +0300
57 LIBSRC_DIR=$(CPP_DIR)/libsrc
58 LIB_DIR=$(CPP_DIR)/lib/$(MACHINE)
61 -#OCCINC_DIR=$(OCC_DIR)/inc
62 -#OCCLIB_DIR=$(OCC_DIR)/lib
63 -# OCC_DIR=/opt/OpenCASCADE5.2/ros
64 -# OCC_DIR=/home/joachim/download/occ/Linux
65 -# OCCINC_DIR=$(OCC_DIR)/inc -I$(OCC_DIR)/ros/inc
66 -# OCCLIB_DIR=$(OCC_DIR)/Linux/lib
68 +OCCINC_DIR=$(OCC_DIR)/inc
69 +OCCLIB_DIR=$(OCC_DIR)/Linux/lib
71 include $(LIBSRC_DIR)/makefile.mach.$(MACHINE)
73 -CPLUSPLUSFLAGS1 = -c -I$(LIBSRC_DIR)/include -I$(OCCINC_DIR)
74 +CPLUSPLUSFLAGS1 = -c -fPIC -I$(LIBSRC_DIR)/include -I$(OCCINC_DIR) \
75 + -DOCCGEOMETRY -DOCC52 -DHAVE_IOSTREAM -DHAVE_LIMITS_H
79 diff -Naur netgen-4.5.old/libsrc/makefile.mach.LINUX netgen-4.5.new/libsrc/makefile.mach.LINUX
80 --- netgen-4.5.old/libsrc/makefile.mach.LINUX 2004-10-11 23:49:26.000000000 +0400
81 +++ netgen-4.5.new/libsrc/makefile.mach.LINUX 2008-02-12 14:57:01.000000000 +0300
86 -CPLUSPLUSFLAGS2 = -O2 -I/usr/include/GL3.5 -DLINUX -DOPENGL \
87 +CPLUSPLUSFLAGS2 = -O2 -I/usr/include/GL3.5 -DLINUX \
88 -ftemplate-depth-99 -finline-limit=10000 \
89 -Wdisabled-optimization -funroll-loops -DnoNGSOLVE
91 diff -Naur netgen-4.5.old/libsrc/meshing/improve2.cpp netgen-4.5.new/libsrc/meshing/improve2.cpp
92 --- netgen-4.5.old/libsrc/meshing/improve2.cpp 2006-01-11 19:08:19.000000000 +0300
93 +++ netgen-4.5.new/libsrc/meshing/improve2.cpp 2008-02-12 14:57:01.000000000 +0300
98 -#include <visual.hpp>
99 +//#include <visual.hpp>
103 diff -Naur netgen-4.5.old/libsrc/meshing/improve2.hpp netgen-4.5.new/libsrc/meshing/improve2.hpp
104 --- netgen-4.5.old/libsrc/meshing/improve2.hpp 2004-10-12 23:22:55.000000000 +0400
105 +++ netgen-4.5.new/libsrc/meshing/improve2.hpp 2008-02-12 14:57:01.000000000 +0300
108 virtual void SelectSurfaceOfPoint (const Point3d & p,
109 const PointGeomInfo & gi);
111 - virtual void ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { };
113 + /// project point on surface, returns true if success
114 + virtual bool ProjectPoint (INDEX /* surfind */, Point3d & /* p */) const { return false; }
115 + /// fast project point on surface using point geom info of a neighboring point
116 + /// if gi.trignum != 0,
117 + /// returns true if success, gi is updated
118 + virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const
119 + { gi.trignum = 1; return ProjectPoint (surfind, p); }
121 virtual void ProjectPoint2 (INDEX /* surfind */, INDEX /* surfind2 */, Point3d & /* p */) const { };
122 - /// liefert zu einem 3d-Punkt die geominfo (Dreieck) und liefert 1, wenn erfolgreich,
123 - /// 0, wenn nicht (Punkt ausserhalb von chart)
124 - virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& /*p3*/) const
125 - { gi.trignum = 1; return 1;};
127 - virtual int CalcPointGeomInfo(int /* surfind */, PointGeomInfo& gi, const Point3d& p3) const
128 - { return CalcPointGeomInfo (gi, p3); }
131 virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const;
132 diff -Naur netgen-4.5.old/libsrc/meshing/smoothing2.cpp netgen-4.5.new/libsrc/meshing/smoothing2.cpp
133 --- netgen-4.5.old/libsrc/meshing/smoothing2.cpp 2006-01-11 19:08:20.000000000 +0300
134 +++ netgen-4.5.new/libsrc/meshing/smoothing2.cpp 2008-02-12 14:57:01.000000000 +0300
136 double Opti2SurfaceMinFunction ::
137 FuncGrad (const Vector & x, Vector & grad) const
143 double badness, hbadness;
148 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
151 pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
154 double Opti2SurfaceMinFunction ::
155 FuncDeriv (const Vector & x, const Vector & dir, double & deriv) const
161 double badness, hbadness;
166 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
169 pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
179 double badness, hbadness, hbad, hderiv;
184 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
187 pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
197 double badness, hbadness, hbad, hderiv;
202 - meshthis -> GetNormalVector (surfi, sp1, gi1, n);
205 pp1.Add2 (x.Get(1), t1, x.Get(2), t2);
207 @@ -859,19 +851,21 @@
208 locelements.SetSize(0);
213 for (j = 0; j < elementsonpoint[pi].Size(); j++)
215 sei = elementsonpoint[pi][j];
216 const Element2d & bel = mesh[sei];
217 surfi = mesh.GetFaceDescriptor(bel.GetIndex()).SurfNr();
220 locelements.Append (sei);
222 for (k = 1; k <= bel.GetNP(); k++)
223 if (bel.PNum(k) == pi)
226 + ngi = bel.GeomInfoPi(k);
233 //optimizer loop (if not whole distance is not possible, move only a bit!!!!)
234 - while (loci <= 5 && !moveisok)
235 + while (loci <= 5 && !moveisok)
238 mesh[pi].X() = origp.X() + (x.Get(1) * t1.X() + x.Get(2) * t2.X())*fact;
243 - ProjectPoint (surfi, mesh[pi]);
244 + moveisok = ProjectPoint (surfi, mesh[pi], ngi);
246 - moveisok = CalcPointGeomInfo(surfi, ngi, mesh[pi]);
247 - // point lies on same chart in stlsurface
249 + // point lies on same chart in stlsurface
252 for (j = 0; j < locelements.Size(); j++)
253 diff -Naur netgen-4.5.old/libsrc/occ/occconstruction.cpp netgen-4.5.new/libsrc/occ/occconstruction.cpp
254 --- netgen-4.5.old/libsrc/occ/occconstruction.cpp 2005-12-06 18:15:53.000000000 +0300
255 +++ netgen-4.5.new/libsrc/occ/occconstruction.cpp 2008-02-12 14:57:01.000000000 +0300
257 #include <BRepAlgoAPI_Common.hxx>
258 #include <BRepAlgoAPI_Fuse.hxx>
259 #include <BRepAlgoAPI_Section.hxx>
260 -#include <BRepOffsetAPI_Sewing.hxx>
261 -#include <BRepAlgo_Sewing.hxx>
262 +//#include <BRepOffsetAPI_Sewing.hxx>
263 +//#include <BRepAlgo_Sewing.hxx>
264 #include <BRepOffsetAPI_MakeOffsetShape.hxx>
265 #include <ShapeFix_Shape.hxx>
267 diff -Naur netgen-4.5.old/libsrc/occ/occgenmesh.cpp netgen-4.5.new/libsrc/occ/occgenmesh.cpp
268 --- netgen-4.5.old/libsrc/occ/occgenmesh.cpp 2006-02-07 13:12:48.000000000 +0300
269 +++ netgen-4.5.new/libsrc/occ/occgenmesh.cpp 2008-02-12 14:57:01.000000000 +0300
271 return Point<3> (p.X(), p.Y(), p.Z());
274 - void DivideEdge (TopoDS_Edge & edge,
275 + static void DivideEdge (TopoDS_Edge & edge,
276 ARRAY<MeshPoint> & ps,
277 ARRAY<double> & params,
283 - double olddist = 0;
286 - for (int i = 1; i <= DIVIDEEDGESECTIONS; i++)
288 + for (i = 1; i <= DIVIDEEDGESECTIONS; i++)
291 pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
292 + double dist = pnt.Distance(oldpnt);
293 hvalue[i] = hvalue[i-1] +
294 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
295 - pnt.Distance(oldpnt);
298 //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
299 // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
303 - dist = pnt.Distance(oldpnt);
306 // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS]));
308 ps.SetSize(nsubedges-1);
309 params.SetSize(nsubedges+1);
318 static void FindEdges (OCCGeometry & geom, Mesh & mesh)
320 - char * savetask = multithread.task;
321 + const char * savetask = multithread.task;
322 multithread.task = "Edge meshing";
324 (*testout) << "edge meshing" << endl;
326 (*testout) << "nedges = " << nedges << endl;
328 double eps = 1e-6 * geom.GetBoundingBox().Diam();
329 + double eps2 = eps * eps;
331 for (int i = 1; i <= nvertices; i++)
336 for (PointIndex pi = 1; pi <= mesh.GetNP(); pi++)
337 - if ( Dist2 (mesh[pi], Point<3>(mp)) < eps*eps)
338 + if ( Dist2 (mesh[pi], Point<3>(mp)) < eps2)
344 for (PointIndex pi = 1; pi < first_ep; pi++)
346 - if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
347 - if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
348 + if (Dist2 (mesh[pi], fp) < eps2) pnums[0] = pi;
349 + if (Dist2 (mesh[pi], lp) < eps2) pnums.Last() = pi;
356 for (j = first_ep; j <= mesh.GetNP(); j++)
357 - if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
358 + if (Dist2(mesh.Point(j), Point<3>(mp[i-1])) < eps2)
366 - char * savetask = multithread.task;
367 + const char * savetask = multithread.task;
368 multithread.task = "Surface meshing";
370 geom.facemeshstatus = 0;
372 multithread.task = savetask;
375 - double ComputeH (double kappa)
376 + static double ComputeH (double kappa)
379 kappa *= mparam.curvaturesafety;
383 Point<3> p = p0 + 0.5*n;
384 - double lambda = (p-l.p0)*n / nq;
385 + double lambda = (fabs(nq) > 1e-10 ? (p-l.p0)*n / nq : -1);
387 if (lambda >= 0 && lambda <= 1)
389 @@ -799,55 +796,55 @@
393 - void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
394 - BRepLProp_SLProps * prop, Mesh & mesh, const double maxside, int depth, double h = 0)
395 + static void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
396 + BRepAdaptor_Surface& surf, Mesh & mesh, const double maxside, int depth, double h = 0)
399 + BRepLProp_SLProps prop(surf, 2, 1e-5);
403 parmid.SetX(0.3*(par0.X()+par1.X()+par2.X()));
404 parmid.SetY(0.3*(par0.Y()+par1.Y()+par2.Y()));
409 double curvature = 0;
411 - prop->SetParameters (parmid.X(), parmid.Y());
412 - if (!prop->IsCurvatureDefined())
413 + prop.SetParameters (parmid.X(), parmid.Y());
414 + if (!prop.IsCurvatureDefined())
416 (*testout) << "curvature not defined!" << endl;
419 - curvature = max(fabs(prop->MinCurvature()),
420 - fabs(prop->MaxCurvature()));
421 + curvature = max(fabs(prop.MinCurvature()),
422 + fabs(prop.MaxCurvature()));
424 - prop->SetParameters (par0.X(), par0.Y());
425 - if (!prop->IsCurvatureDefined())
426 + prop.SetParameters (par0.X(), par0.Y());
427 + if (!prop.IsCurvatureDefined())
429 (*testout) << "curvature not defined!" << endl;
432 - curvature = max(curvature,max(fabs(prop->MinCurvature()),
433 - fabs(prop->MaxCurvature())));
434 + curvature = max(curvature,max(fabs(prop.MinCurvature()),
435 + fabs(prop.MaxCurvature())));
437 - prop->SetParameters (par1.X(), par1.Y());
438 - if (!prop->IsCurvatureDefined())
439 + prop.SetParameters (par1.X(), par1.Y());
440 + if (!prop.IsCurvatureDefined())
442 (*testout) << "curvature not defined!" << endl;
445 - curvature = max(curvature,max(fabs(prop->MinCurvature()),
446 - fabs(prop->MaxCurvature())));
447 + curvature = max(curvature,max(fabs(prop.MinCurvature()),
448 + fabs(prop.MaxCurvature())));
450 - prop->SetParameters (par2.X(), par2.Y());
451 - if (!prop->IsCurvatureDefined())
452 + prop.SetParameters (par2.X(), par2.Y());
453 + if (!prop.IsCurvatureDefined())
455 (*testout) << "curvature not defined!" << endl;
458 - curvature = max(curvature,max(fabs(prop->MinCurvature()),
459 - fabs(prop->MaxCurvature())));
460 + curvature = max(curvature,max(fabs(prop.MinCurvature()),
461 + fabs(prop.MaxCurvature())));
463 //(*testout) << "curvature " << curvature << endl;
465 @@ -886,51 +883,47 @@
466 pm1.SetX(0.5*(par0.X()+par2.X())); pm1.SetY(0.5*(par0.Y()+par2.Y()));
467 pm2.SetX(0.5*(par1.X()+par0.X())); pm2.SetY(0.5*(par1.Y()+par0.Y()));
469 - RestrictHTriangle (pm0, pm1, pm2, prop, mesh, 0.5*maxside, depth+1, h);
470 - RestrictHTriangle (par0, pm1, pm2, prop, mesh, 0.5*maxside, depth+1, h);
471 - RestrictHTriangle (par1, pm0, pm2, prop, mesh, 0.5*maxside, depth+1, h);
472 - RestrictHTriangle (par2, pm1, pm0, prop, mesh, 0.5*maxside, depth+1, h);
473 + RestrictHTriangle (pm0, pm1, pm2, surf, mesh, 0.5*maxside, depth+1, h);
474 + RestrictHTriangle (par0, pm1, pm2, surf, mesh, 0.5*maxside, depth+1, h);
475 + RestrictHTriangle (par1, pm0, pm2, surf, mesh, 0.5*maxside, depth+1, h);
476 + RestrictHTriangle (par2, pm1, pm0, surf, mesh, 0.5*maxside, depth+1, h);
483 - prop->SetParameters (parmid.X(), parmid.Y());
484 - pnt = prop->Value();
485 + surf.D0(parmid.X(), parmid.Y(), pnt);
486 p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
487 mesh.RestrictLocalH (p3d, h);
490 - prop->SetParameters (par0.X(), par0.Y());
491 - pnt = prop->Value();
492 + surf.D0(par0.X(), par0.Y(), pnt);
493 p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
494 mesh.RestrictLocalH (p3d, h);
496 - prop->SetParameters (par1.X(), par1.Y());
497 - pnt = prop->Value();
498 + surf.D0(par1.X(), par1.Y(), pnt);
499 p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
500 mesh.RestrictLocalH (p3d, h);
502 - prop->SetParameters (par2.X(), par2.Y());
503 - pnt = prop->Value();
504 + surf.D0(par2.X(), par2.Y(), pnt);
505 p3d = Point3d(pnt.X(), pnt.Y(), pnt.Z());
506 mesh.RestrictLocalH (p3d, h);
508 - (*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl;
509 + //(*testout) << "p = " << p3d << ", h = " << h << ", maxside = " << maxside << endl;
511 (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl;
513 - prop->SetParameters (par0.X(), par0.Y());
514 - pnt = prop->Value();
515 + prop.SetParameters (par0.X(), par0.Y());
516 + pnt = prop.Value();
517 (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl;
519 - prop->SetParameters (par1.X(), par1.Y());
520 - pnt = prop->Value();
521 + prop.SetParameters (par1.X(), par1.Y());
522 + pnt = prop.Value();
523 (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl;
525 - prop->SetParameters (par2.X(), par2.Y());
526 - pnt = prop->Value();
527 + prop.SetParameters (par2.X(), par2.Y());
528 + pnt = prop.Value();
529 (*testout) << pnt.X() << " " << pnt.Y() << " " << pnt.Z() << endl;
533 if (mparam.uselocalh)
536 - char * savetask = multithread.task;
537 + const char * savetask = multithread.task;
538 multithread.percent = 0;
540 mesh->SetLocalH (bb.PMin(), bb.PMax(), mparam.grading);
541 @@ -1075,7 +1068,6 @@
542 if (triangulation.IsNull()) continue;
544 BRepAdaptor_Surface sf(face, Standard_True);
545 - BRepLProp_SLProps prop(sf, 2, 1e-5);
547 int ntriangles = triangulation -> NbTriangles();
548 for (int j = 1; j <= ntriangles; j++)
549 @@ -1096,7 +1088,7 @@
550 maxside = max (maxside, p[1].Distance(p[2]));
551 //cout << "\rFace " << i << " pos11 ntriangles " << ntriangles << " maxside " << maxside << flush;
553 - RestrictHTriangle (par[0], par[1], par[2], &prop, *mesh, maxside, 0);
554 + RestrictHTriangle (par[0], par[1], par[2], sf, *mesh, maxside, 0);
555 //cout << "\rFace " << i << " pos12 ntriangles " << ntriangles << flush;
558 diff -Naur netgen-4.5.old/libsrc/occ/occgeom.cpp netgen-4.5.new/libsrc/occ/occgeom.cpp
559 --- netgen-4.5.old/libsrc/occ/occgeom.cpp 2006-01-25 16:35:50.000000000 +0300
560 +++ netgen-4.5.new/libsrc/occ/occgeom.cpp 2008-02-12 14:57:01.000000000 +0300
562 #include "ShapeAnalysis_ShapeContents.hxx"
563 #include "ShapeAnalysis_CheckSmallFace.hxx"
564 #include "ShapeAnalysis_DataMapOfShapeListOfReal.hxx"
565 +#include <ShapeAnalysis_Surface.hxx>
566 +#include <BRepTopAdaptor_FClass2d.hxx>
567 #include "BRepAlgoAPI_Fuse.hxx"
568 #include "BRepCheck_Analyzer.hxx"
569 #include "BRepLib.hxx"
571 #include "Partition_Spliter.hxx"
572 //#include "VrmlAPI.hxx"
573 //#include "StlAPI.hxx"
574 +#include <TopAbs_State.hxx>
580 + OCCGeometry::~OCCGeometry()
582 + NCollection_DataMap<int,BRepTopAdaptor_FClass2d*>::Iterator it(fclsmap);
583 + for (; it.More(); it.Next())
587 void OCCGeometry :: PrintNrShapes ()
590 @@ -947,13 +957,13 @@
592 void OCCGeometry :: BuildVisualizationMesh ()
595 - cout << "Preparing visualization (deflection = " << vispar.occdeflection << ") ... " << flush;
596 + double vispar_occdeflection = 0.01;
597 + cout << "Preparing visualization (deflection = " << vispar_occdeflection << ") ... " << flush;
600 BRepTools::Clean (shape);
601 //WriteOCC_STL("test.stl");
602 - BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar.occdeflection, true);
603 + BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh (shape, vispar_occdeflection, true);
604 cout << "done" << endl;
611 + void OCCGeometry::GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
612 + BRepTopAdaptor_FClass2d*& cls) const
614 + //MSV: organize caching projector in the map
615 + if (fprjmap.IsBound(surfi))
617 + proj = fprjmap.Find(surfi);
618 + cls = fclsmap.Find(surfi);
622 + const TopoDS_Face& aFace = TopoDS::Face(fmap(surfi));
623 + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
624 + proj = new ShapeAnalysis_Surface(aSurf);
625 + fprjmap.Bind(surfi, proj);
626 + cls = new BRepTopAdaptor_FClass2d(aFace,Precision::Confusion());
627 + fclsmap.Bind(surfi, cls);
631 - void OCCGeometry :: Project (int surfi, Point<3> & p) const
632 + bool OCCGeometry :: Project (int surfi, Point<3> & p, double& u, double& v) const
635 if (++cnt % 1000 == 0) cout << "Project cnt = " << cnt << endl;
636 @@ -983,18 +1012,22 @@
638 //(*testout) << "before " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl;
640 - GeomAPI_ProjectPointOnSurf proj(pnt, BRep_Tool::Surface(TopoDS::Face(fmap(surfi))));
641 - if (proj.NbPoints() == 0)
643 - cout << "Projection fails" << endl;
647 - pnt = proj.NearestPoint();
648 - //(*testout) << "after " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl;
649 + Handle(ShapeAnalysis_Surface) proj;
650 + BRepTopAdaptor_FClass2d *cls;
651 + GetFaceTools(surfi, proj, cls);
653 - p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
655 + gp_Pnt2d p2d = proj->ValueOfUV(pnt, Precision::Confusion());
656 + if (cls->Perform(p2d) == TopAbs_OUT)
658 + //cout << "Projection fails" << endl;
661 + pnt = proj->Value(p2d);
663 + //(*testout) << "after " << pnt.X() << " "<< pnt.Y() << " "<< pnt.Z() << " " << endl;
665 + p = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
670 @@ -1002,54 +1035,20 @@
672 gp_Pnt p(ap(0), ap(1), ap(2));
674 - Handle(Geom_Surface) surface = BRep_Tool::Surface(TopoDS::Face(fmap(surfi)));
675 + Handle(ShapeAnalysis_Surface) proj;
676 + BRepTopAdaptor_FClass2d *cls;
677 + GetFaceTools(surfi, proj, cls);
679 - gp_Pnt x = surface->Value (u,v);
681 - if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return true;
685 - surface->D1(u,v,x,du,dv);
691 - double det, lambda, mu;
698 - det = Det3 (n.X(), du.X(), dv.X(),
699 - n.Y(), du.Y(), dv.Y(),
700 - n.Z(), du.Z(), dv.Z());
702 - if (det < 1e-15) return false;
704 - lambda = Det3 (n.X(), p.X()-x.X(), dv.X(),
705 - n.Y(), p.Y()-x.Y(), dv.Y(),
706 - n.Z(), p.Z()-x.Z(), dv.Z())/det;
708 - mu = Det3 (n.X(), du.X(), p.X()-x.X(),
709 - n.Y(), du.Y(), p.Y()-x.Y(),
710 - n.Z(), du.Z(), p.Z()-x.Z())/det;
716 - surface->D1(u,v,x,du,dv);
718 - } while (xold.SquareDistance(x) > sqr(PROJECTION_TOLERANCE) && count < 50);
720 - // (*testout) << "FastProject count: " << count << endl;
722 - if (count == 50) return false;
723 + gp_Pnt2d p2d = proj->NextValueOfUV(gp_Pnt2d(u,v), p, Precision::Confusion());
724 + if (cls->Perform(p2d) == TopAbs_OUT)
726 + //cout << "Projection fails" << endl;
730 - ap = Point<3> (x.X(), x.Y(), x.Z());
731 + p = proj->Value(p2d);
733 + ap = Point<3> (p.X(), p.Y(), p.Z());
737 diff -Naur netgen-4.5.old/libsrc/occ/occgeom.hpp netgen-4.5.new/libsrc/occ/occgeom.hpp
738 --- netgen-4.5.old/libsrc/occ/occgeom.hpp 2006-01-25 16:35:50.000000000 +0300
739 +++ netgen-4.5.new/libsrc/occ/occgeom.hpp 2008-02-12 14:57:01.000000000 +0300
741 #include "Geom_Curve.hxx"
742 #include "Geom2d_Curve.hxx"
743 #include "Geom_Surface.hxx"
744 -#include "GeomAPI_ProjectPointOnSurf.hxx"
745 -#include "GeomAPI_ProjectPointOnCurve.hxx"
746 #include "BRepTools.hxx"
747 #include "TopExp.hxx"
748 #include "BRepBuilderAPI_MakeVertex.hxx"
750 #include "Geom_Curve.hxx"
751 #include "Geom2d_Curve.hxx"
752 #include "Geom_Surface.hxx"
753 -#include "GeomAPI_ProjectPointOnSurf.hxx"
754 -#include "GeomAPI_ProjectPointOnCurve.hxx"
755 #include "TopoDS_Wire.hxx"
756 #include "BRepTools_WireExplorer.hxx"
757 #include "BRepTools.hxx"
759 #include "IGESToBRep_Reader.hxx"
760 #include "Interface_Static.hxx"
761 #include "GeomAPI_ExtremaCurveCurve.hxx"
762 -#include "Standard_ErrorHandler.hxx"
763 +//#include "Standard_ErrorHandler.hxx"
764 #include "Standard_Failure.hxx"
765 #include "ShapeUpgrade_ShellSewing.hxx"
766 #include "ShapeFix_Shape.hxx"
768 #include "STEPControl_Writer.hxx"
769 #include "StlAPI_Writer.hxx"
770 #include "STEPControl_StepModelType.hxx"
771 +#include <NCollection_DataMap.hxx>
773 +class Handle_ShapeAnalysis_Surface;
774 +class BRepTopAdaptor_FClass2d;
779 -#include "../visualization/vispar.hpp"
780 + //#include "../visualization/vispar.hpp"
781 // class VisualizationParameters;
782 // extern VisualizationParameters vispar;
788 + mutable NCollection_DataMap<int,Handle_ShapeAnalysis_Surface> fprjmap;
789 + mutable NCollection_DataMap<int,BRepTopAdaptor_FClass2d*> fclsmap;
801 @@ -204,10 +207,12 @@
805 - void Project (int surfi, Point<3> & p) const;
806 + bool Project (int surfi, Point<3> & p, double& u, double& v) const;
807 bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const;
810 + void GetFaceTools(int surfi, Handle(ShapeAnalysis_Surface)& proj,
811 + BRepTopAdaptor_FClass2d*& cls) const;
813 OCCSurface GetSurface (int surfi)
815 cout << "OCCGeometry::GetSurface using PLANESPACE" << endl;
816 diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.cpp netgen-4.5.new/libsrc/occ/occmeshsurf.cpp
817 --- netgen-4.5.old/libsrc/occ/occmeshsurf.cpp 2006-01-25 16:36:26.000000000 +0300
818 +++ netgen-4.5.new/libsrc/occ/occmeshsurf.cpp 2008-02-12 14:57:01.000000000 +0300
820 #include <occgeom.hpp>
821 #include <meshing.hpp>
822 #include <GeomLProp_SLProps.hxx>
823 +#include <GeomAPI_ProjectPointOnSurf.hxx>
824 +#include <GeomAPI_ProjectPointOnCurve.hxx>
828 @@ -411,11 +413,16 @@
832 - void MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const
833 + bool MeshOptimize2dOCCSurfaces :: ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const
836 - geometry.Project (surfind, hp);
838 + if (gi.trignum > 0)
839 + ok = geometry.FastProject (surfind, hp, gi.u, gi.v);
841 + ok = geometry.Project (surfind, hp, gi.u, gi.v);
846 void MeshOptimize2dOCCSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2,
851 - int MeshOptimize2dOCCSurfaces ::
852 - CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point3d& p) const
856 - gp_Pnt pnt(p.X(), p.Y(), p.Z());
858 - Handle(Geom_Surface) occface;
859 - occface = BRep_Tool::Surface(TopoDS::Face(geometry.fmap(surfind)));
861 - GeomAPI_ProjectPointOnSurf proj(pnt, occface);
863 - if (proj.NbPoints() < 1)
865 - cout << "ERROR: OCCSurface :: GetNormalVector: GeomAPI_ProjectPointOnSurf failed!"
871 - proj.LowerDistanceParameters (u, v);
883 OCCRefinementSurfaces :: OCCRefinementSurfaces (const OCCGeometry & ageometry)
884 : Refinement(), geometry(ageometry)
886 @@ -627,10 +602,11 @@
887 if (!geometry.FastProject (surfi, hnewp, u, v))
889 cout << "Fast projection to surface fails! Using OCC projection" << endl;
890 - geometry.Project (surfi, hnewp);
892 + geometry.Project (surfi, hnewp, u, v);
896 + newgi.trignum = surfi;
900 @@ -653,14 +629,17 @@
901 hnewp = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
908 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi)
911 - geometry.Project (surfi, p);
915 + geometry.Project (surfi, p, u, v);
919 void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi)
922 if (!geometry.FastProject (surfi, p, gi.u, gi.v))
924 cout << "Fast projection to surface fails! Using OCC projection" << endl;
925 - geometry.Project (surfi, p);
927 + geometry.Project (surfi, p, u, v);
934 diff -Naur netgen-4.5.old/libsrc/occ/occmeshsurf.hpp netgen-4.5.new/libsrc/occ/occmeshsurf.hpp
935 --- netgen-4.5.old/libsrc/occ/occmeshsurf.hpp 2005-06-09 18:51:10.000000000 +0400
936 +++ netgen-4.5.new/libsrc/occ/occmeshsurf.hpp 2008-02-12 14:57:01.000000000 +0300
938 MeshOptimize2dOCCSurfaces (const OCCGeometry & ageometry);
941 - virtual void ProjectPoint (INDEX surfind, Point3d & p) const;
942 + virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const;
944 virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const;
948 virtual void GetNormalVector(INDEX surfind, const Point3d & p, PointGeomInfo & gi, Vec3d & n) const;
951 - virtual int CalcPointGeomInfo(int surfind, PointGeomInfo& gi, const Point3d& p3) const;
956 diff -Naur netgen-4.5.old/libsrc/stlgeom/meshstlsurface.cpp netgen-4.5.new/libsrc/stlgeom/meshstlsurface.cpp
957 --- netgen-4.5.old/libsrc/stlgeom/meshstlsurface.cpp 2006-01-11 19:08:20.000000000 +0300
958 +++ netgen-4.5.new/libsrc/stlgeom/meshstlsurface.cpp 2008-02-12 14:57:01.000000000 +0300
959 @@ -946,20 +946,23 @@
963 -void MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point3d & p) const
964 +bool MeshOptimizeSTLSurface :: ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const
967 - if (!geom.Project (hp))
968 + if (gi.trignum > 0)
969 + ((STLGeometry&)geom).SelectChartOfTriangle (gi.trignum);
970 + if (!(gi.trignum = geom.Project (hp)))
972 PrintMessage(7,"project failed");
974 - if (!geom.ProjectOnWholeSurface(hp))
975 + if (!(gi.trignum = geom.ProjectOnWholeSurface(hp)))
977 PrintMessage(7, "project on whole surface failed");
981 // geometry.GetSurface(surfind)->Project (p);
982 + return gi.trignum > 0;
985 void MeshOptimizeSTLSurface :: ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const
990 -int MeshOptimizeSTLSurface :: CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& p3) const
993 - gi.trignum = geom.Project (hp);
1004 void MeshOptimizeSTLSurface :: GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const
1006 n = geom.GetChartNormalVector();
1007 diff -Naur netgen-4.5.old/libsrc/stlgeom/meshstlsurface.hpp netgen-4.5.new/libsrc/stlgeom/meshstlsurface.hpp
1008 --- netgen-4.5.old/libsrc/stlgeom/meshstlsurface.hpp 2004-09-30 17:13:56.000000000 +0400
1009 +++ netgen-4.5.new/libsrc/stlgeom/meshstlsurface.hpp 2008-02-12 14:57:01.000000000 +0300
1011 virtual void SelectSurfaceOfPoint (const Point3d & p,
1012 const PointGeomInfo & gi);
1014 - virtual void ProjectPoint (INDEX surfind, Point3d & p) const;
1015 + virtual bool ProjectPoint (INDEX surfind, Point3d & p, PointGeomInfo& gi) const;
1017 virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const;
1019 - virtual int CalcPointGeomInfo(PointGeomInfo& gi, const Point3d& p3) const;
1021 virtual void GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const;
1024 diff -Naur netgen-4.5.old/makeForSalome.sh netgen-4.5.new/makeForSalome.sh
1025 --- netgen-4.5.old/makeForSalome.sh 1970-01-01 03:00:00.000000000 +0300
1026 +++ netgen-4.5.new/makeForSalome.sh 2008-02-12 14:57:01.000000000 +0300
1029 +cp ngtcltk/ngnewdelete.* libsrc/interface/
1034 +make -C libsrc/general
1035 +make -C libsrc/geom2d
1036 +make -C libsrc/gprim
1037 +make -C libsrc/interface
1038 +make -C libsrc/linalg
1039 +make -C libsrc/meshing
1040 +make -C libsrc/opti
1041 +make -C libsrc/stlgeom
1044 +if [ ! -d install ] ; then
1050 +if [ ! -d install/include ] ; then
1051 + mkdir install/include
1054 +cp libsrc/interface/nglib.h libsrc/general/*.hpp libsrc/csg/*.hpp libsrc/geom2d/*.hpp \
1055 + libsrc/gprim/*.hpp libsrc/linalg/*.hpp libsrc/meshing/*.hpp \
1056 + libsrc/occ/*.hpp libsrc/opti/*.hpp libsrc/include/mydefs.hpp \
1057 + libsrc/stlgeom/*.hpp libsrc/include/mystdlib.h \
1059 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Inter2d.cxx netgen-4.5.new/libsrc/occ/Partition_Inter2d.cxx
1060 --- netgen-4.5.old/libsrc/occ/Partition_Inter2d.cxx 2005-06-09 18:51:10.000000000 +0400
1061 +++ netgen-4.5.new/libsrc/occ/Partition_Inter2d.cxx 2008-02-26 12:34:14.000000000 +0300
1065 //using namespace std;
1066 -#include "Partition_Inter2d.ixx"
1068 #include "utilities.h"
1070 +#include "Partition_Inter2d.ixx"
1072 #include <BRepAdaptor_Curve.hxx>
1073 #include <BRepAlgo_AsDes.hxx>
1074 #include <BRepLib_MakeVertex.hxx>
1075 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Inter3d.cxx netgen-4.5.new/libsrc/occ/Partition_Inter3d.cxx
1076 --- netgen-4.5.old/libsrc/occ/Partition_Inter3d.cxx 2005-06-09 18:51:10.000000000 +0400
1077 +++ netgen-4.5.new/libsrc/occ/Partition_Inter3d.cxx 2008-02-26 12:36:27.000000000 +0300
1081 //using namespace std;
1083 +#include "utilities.h"
1085 #include "Partition_Inter2d.hxx"
1086 #include "Partition_Inter3d.ixx"
1087 -#include "utilities.h"
1089 #include <BRepAlgo_AsDes.hxx>
1090 #include <BRepAlgo_Image.hxx>
1091 #include <BRepLib.hxx>
1092 +//using namespace std;
1094 #include <BRepOffset_Tool.hxx>
1095 #include <BRep_Builder.hxx>
1096 #include <BRep_Tool.hxx>
1097 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop2d.cxx netgen-4.5.new/libsrc/occ/Partition_Loop2d.cxx
1098 --- netgen-4.5.old/libsrc/occ/Partition_Loop2d.cxx 2005-06-09 18:51:10.000000000 +0400
1099 +++ netgen-4.5.new/libsrc/occ/Partition_Loop2d.cxx 2008-02-26 12:37:10.000000000 +0300
1103 //using namespace std;
1104 -#include "Partition_Loop2d.ixx"
1107 #include "utilities.h"
1109 +#include "Partition_Loop2d.ixx"
1112 #include <BRepAdaptor_Curve2d.hxx>
1113 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop3d.cxx netgen-4.5.new/libsrc/occ/Partition_Loop3d.cxx
1114 --- netgen-4.5.old/libsrc/occ/Partition_Loop3d.cxx 2005-06-09 18:51:10.000000000 +0400
1115 +++ netgen-4.5.new/libsrc/occ/Partition_Loop3d.cxx 2008-02-26 12:39:32.000000000 +0300
1119 //using namespace std;
1123 +#include "utilities.h"
1125 #include "Partition_Loop3d.ixx"
1127 #include <TopExp_Explorer.hxx>
1128 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Loop.cxx netgen-4.5.new/libsrc/occ/Partition_Loop.cxx
1129 --- netgen-4.5.old/libsrc/occ/Partition_Loop.cxx 2005-06-09 18:51:10.000000000 +0400
1130 +++ netgen-4.5.new/libsrc/occ/Partition_Loop.cxx 2008-02-26 12:40:41.000000000 +0300
1134 //using namespace std;
1137 -#include "Partition_Loop.ixx"
1139 #include "utilities.h"
1143 +#include "Partition_Loop.ixx"
1145 #include <BRep_Builder.hxx>
1146 #include <BRepAlgo_FaceRestrictor.hxx>
1147 #include <BRep_Tool.hxx>
1148 diff -Naur netgen-4.5.old/libsrc/occ/Partition_Spliter.cxx netgen-4.5.new/libsrc/occ/Partition_Spliter.cxx
1149 --- netgen-4.5.old/libsrc/occ/Partition_Spliter.cxx 2005-07-11 10:33:27.000000000 +0400
1150 +++ netgen-4.5.new/libsrc/occ/Partition_Spliter.cxx 2008-02-26 12:41:32.000000000 +0300
1154 //using namespace std;
1156 +#include "utilities.h"
1158 #include "Partition_Inter2d.hxx"
1159 #include "Partition_Inter3d.hxx"
1160 #include "Partition_Loop2d.hxx"
1161 #include "Partition_Loop3d.hxx"
1162 #include "Partition_Spliter.ixx"
1164 -#include "utilities.h"
1166 #include <Precision.hxx>
1167 #include <TopAbs_Orientation.hxx>
1168 #include <TopExp.hxx>
1169 diff -Naur netgen-4.5.old/libsrc/occ/utilities.h netgen-4.5.new/libsrc/occ/utilities.h
1170 --- netgen-4.5.old/libsrc/occ/utilities.h 2005-02-11 14:35:43.000000000 +0300
1171 +++ netgen-4.5.new/libsrc/occ/utilities.h 2008-02-26 12:28:02.000000000 +0300
1178 // #include "SALOME_Log.hxx"