diff --git a/libsrc/csg/csgparser.cpp b/libsrc/csg/csgparser.cpp index 05c1bdcd..1666a2ab 100644 --- a/libsrc/csg/csgparser.cpp +++ b/libsrc/csg/csgparser.cpp @@ -479,7 +479,7 @@ namespace netgen } Primitive * nprim = new Revolution(p0,p1, - *(geom->GetSplineCurve2d(spline))); + geom->GetSplineCurve2d(spline)); geom->AddSurfaces (nprim); return new Solid(nprim); diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index a650a5ae..4328bda4 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -323,13 +323,13 @@ DLL_HEADER void ExportCSG(py::module &m) Solid * sol = new Solid (torus); return make_shared (sol); })); - m.def ("Revolution", FunctionPointer([](Point<3> p1, Point<3> p2, - const SplineGeometry<2> & spline) - { - Revolution * rev = new Revolution (p1, p2, spline); - Solid * sol = new Solid(rev); - return make_shared (sol); - })); + m.def ("Revolution", [](Point<3> p1, Point<3> p2, + shared_ptr> spline) + { + Revolution * rev = new Revolution (p1, p2, spline); + Solid * sol = new Solid(rev); + return make_shared (sol); + }); m.def ("Extrusion", [](shared_ptr> path, shared_ptr> profile, Vec<3> d) diff --git a/libsrc/csg/revolution.cpp b/libsrc/csg/revolution.cpp index 36f7c614..056cdf5e 100644 --- a/libsrc/csg/revolution.cpp +++ b/libsrc/csg/revolution.cpp @@ -640,10 +640,10 @@ namespace netgen Revolution :: Revolution(const Point<3> & p0_in, const Point<3> & p1_in, - const SplineGeometry<2> & spline_in) : - p0(p0_in), p1(p1_in) + shared_ptr> spline_in) : + p0(p0_in), p1(p1_in), splinegeo(spline_in) { - auto nsplines = spline_in.GetNSplines(); + auto nsplines = spline_in->GetNSplines(); surfaceactive.SetSize(0); surfaceids.SetSize(0); @@ -651,39 +651,39 @@ namespace netgen v_axis.Normalize(); - if(spline_in.GetSpline(0).StartPI()(1) <= 0. && - spline_in.GetSpline(nsplines-1).EndPI()(1) <= 0.) + if(spline_in->GetSpline(0).StartPI()(1) <= 0. && + spline_in->GetSpline(nsplines-1).EndPI()(1) <= 0.) type = 2; - else if (Dist(spline_in.GetSpline(0).StartPI(), - spline_in.GetSpline(nsplines-1).EndPI()) < 1e-7) + else if (Dist(spline_in->GetSpline(0).StartPI(), + spline_in->GetSpline(nsplines-1).EndPI()) < 1e-7) type = 1; else cerr << "Surface of revolution cannot be constructed" << endl; - for(int i=0; iGetNSplines(); i++) { - RevolutionFace * face = new RevolutionFace(spline_in.GetSpline(i), - p0,v_axis, - type==2 && i==0, - type==2 && i==spline_in.GetNSplines()-1); - faces.Append(face); - surfaceactive.Append(1); + faces.Append(new RevolutionFace + (spline_in->GetSpline(i), + p0,v_axis, + type==2 && i==0, + type==2 && i==spline_in->GetNSplines()-1)); + surfaceactive.Append(1); surfaceids.Append(0); } // checking if (type == 2) { - auto t0 = spline_in.GetSpline(0).GetTangent(0); + auto t0 = spline_in->GetSpline(0).GetTangent(0); cout << "tstart (must be vertically): " << t0 << endl; - auto tn = spline_in.GetSpline(nsplines-1).GetTangent(1); + auto tn = spline_in->GetSpline(nsplines-1).GetTangent(1); cout << "tend (must be vertically): " << tn << endl; for (int i = 0; i < nsplines-1; i++) { - auto ta = spline_in.GetSpline(i).GetTangent(1); - auto tb = spline_in.GetSpline(i+1).GetTangent(0); + auto ta = spline_in->GetSpline(i).GetTangent(1); + auto tb = spline_in->GetSpline(i+1).GetTangent(0); cout << "sin (must not be 0) = " << abs(ta(0)*tb(1)-ta(1)*tb(0)) / (Abs(ta)*Abs(tb)); } } diff --git a/libsrc/csg/revolution.hpp b/libsrc/csg/revolution.hpp index 67f9d9c9..39ab04ee 100644 --- a/libsrc/csg/revolution.hpp +++ b/libsrc/csg/revolution.hpp @@ -114,14 +114,15 @@ namespace netgen int type; - NgArray faces; + Array faces; + shared_ptr> splinegeo; mutable int intersecting_face; public: Revolution(const Point<3> & p0_in, const Point<3> & p1_in, - const SplineGeometry<2> & spline_in); + shared_ptr> spline_in); // default constructor for archive Revolution() {}