From b8ab3a47a7a7b7e6582b97a9abc39b94d781b4b7 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 8 Jun 2021 14:35:58 +0200 Subject: [PATCH] Give bcname and maxh to revolution by adding it to spline --- libsrc/csg/python_csg.cpp | 21 +++++++++++---------- libsrc/csg/revolution.cpp | 2 ++ libsrc/gprim/spline.cpp | 12 ++++++++---- libsrc/gprim/spline.hpp | 23 +++++++++++++++++------ 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 4328bda4..9bb9d65d 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -7,6 +7,7 @@ using namespace netgen; +using namespace pybind11::literals; namespace netgen { @@ -179,16 +180,16 @@ DLL_HEADER void ExportCSG(py::module &m) self.geompoints.Append (GeomPoint<2> (Point<2> (x,y))); return self.geompoints.Size()-1; })) - .def ("AddSegment", FunctionPointer - ([] (SplineGeometry<2> & self, int i1, int i2) - { - self.splines.Append (new LineSeg<2> (self.geompoints[i1], self.geompoints[i2])); - })) - .def ("AddSegment", FunctionPointer - ([] (SplineGeometry<2> & self, int i1, int i2, int i3) - { - self.splines.Append (new SplineSeg3<2> (self.geompoints[i1], self.geompoints[i2], self.geompoints[i3])); - })) + .def ("AddSegment", [] (SplineGeometry<2> & self, int i1, int i2, + string bcname, double maxh) + { + self.splines.Append (new LineSeg<2> (self.geompoints[i1], self.geompoints[i2], maxh, bcname)); + }, "p1"_a, "p2"_a, "bcname"_a="default", "maxh"_a=1e99) + .def ("AddSegment", [] (SplineGeometry<2> & self, int i1, int i2, + int i3, string bcname, double maxh) + { + self.splines.Append (new SplineSeg3<2> (self.geompoints[i1], self.geompoints[i2], self.geompoints[i3], bcname, maxh)); + }, "p1"_a, "p2"_a, "p3"_a, "bcname"_a="default", "maxh"_a=1e99) ; py::class_,shared_ptr>> (m,"SplineCurve3d") diff --git a/libsrc/csg/revolution.cpp b/libsrc/csg/revolution.cpp index 056cdf5e..e284a4f2 100644 --- a/libsrc/csg/revolution.cpp +++ b/libsrc/csg/revolution.cpp @@ -48,6 +48,8 @@ namespace netgen isfirst(first), islast(last), spline(&spline_in), p0(p), v_axis(vec), id(id_in) { deletable = false; + maxh = spline_in.GetMaxh(); + bcname = spline_in.GetBCName(); Init(); } diff --git a/libsrc/gprim/spline.cpp b/libsrc/gprim/spline.cpp index 4a17da71..4a945fbc 100644 --- a/libsrc/gprim/spline.cpp +++ b/libsrc/gprim/spline.cpp @@ -89,8 +89,10 @@ namespace netgen template SplineSeg3 :: SplineSeg3 (const GeomPoint & ap1, const GeomPoint & ap2, - const GeomPoint & ap3) - : p1(ap1), p2(ap2), p3(ap3) + const GeomPoint & ap3, + string bcname, + double maxh) + : SplineSeg(maxh, bcname), p1(ap1), p2(ap2), p3(ap3) { weight = Dist (p1, p3) / sqrt (0.5 * (Dist2 (p1, p2) + Dist2 (p2, p3))); // weight = sqrt(2); @@ -102,8 +104,10 @@ namespace netgen SplineSeg3 :: SplineSeg3 (const GeomPoint & ap1, const GeomPoint & ap2, const GeomPoint & ap3, - double aweight) - : p1(ap1), p2(ap2), p3(ap3), weight(aweight) + double aweight, + string bcname, + double maxh) + : SplineSeg(maxh, bcname), p1(ap1), p2(ap2), p3(ap3) { proj_latest_t = 0.5; } diff --git a/libsrc/gprim/spline.hpp b/libsrc/gprim/spline.hpp index 94a96f60..21acd1d2 100644 --- a/libsrc/gprim/spline.hpp +++ b/libsrc/gprim/spline.hpp @@ -50,8 +50,11 @@ namespace netgen template < int D > class SplineSeg { + double maxh; + string bcname; public: - SplineSeg () { ; } + SplineSeg (double amaxh = 1e99, string abcname = "default") + : maxh(amaxh), bcname(abcname) { ; } /// virtual ~SplineSeg() { ; } /// calculates length of curve @@ -116,6 +119,8 @@ namespace netgen virtual void GetRawData (NgArray & data) const { cerr << "GetRawData not implemented for spline base-class" << endl;} + double GetMaxh() const { return maxh; } + string GetBCName() const { return bcname; } }; @@ -127,7 +132,8 @@ namespace netgen GeomPoint p1, p2; public: /// - LineSeg (const GeomPoint & ap1, const GeomPoint & ap2); + LineSeg (const GeomPoint & ap1, const GeomPoint & ap2, + double maxh=1e99, string bcname="default"); /// // default constructor for archive LineSeg() {} @@ -184,11 +190,15 @@ namespace netgen /// SplineSeg3 (const GeomPoint & ap1, const GeomPoint & ap2, - const GeomPoint & ap3); + const GeomPoint & ap3, + string bcname="default", + double maxh=1e99); SplineSeg3 (const GeomPoint & ap1, const GeomPoint & ap2, const GeomPoint & ap3, - double aweight); + double aweight, + string bcname="default", + double maxh=1e99); // default constructor for archive SplineSeg3() {} /// @@ -384,8 +394,9 @@ namespace netgen template LineSeg :: LineSeg (const GeomPoint & ap1, - const GeomPoint & ap2) - : p1(ap1), p2(ap2) + const GeomPoint & ap2, + double maxh, string bcname) + : SplineSeg(maxh, bcname), p1(ap1), p2(ap2) { ; }