diff --git a/libsrc/csg/algprim.cpp b/libsrc/csg/algprim.cpp index c324e460..0f870d98 100644 --- a/libsrc/csg/algprim.cpp +++ b/libsrc/csg/algprim.cpp @@ -1236,7 +1236,15 @@ namespace netgen return max2(bb/(aa*aa),aa/(bb*bb)); } + int EllipticCylinder :: IsIdentic(const Surface& s2, int& inv, double eps) const + { + const EllipticCylinder* ps2 = dynamic_cast(&s2); + if (!ps2) return 0; + if((vl - ps2->vl).Length() > eps || (vs - ps2->vs).Length() > eps || (a-ps2->a).Length() > eps) + return 0; + return 1; + } Point<3> EllipticCylinder :: GetSurfacePoint () const { diff --git a/libsrc/csg/algprim.hpp b/libsrc/csg/algprim.hpp index ab496cc7..6daf643b 100644 --- a/libsrc/csg/algprim.hpp +++ b/libsrc/csg/algprim.hpp @@ -303,7 +303,8 @@ namespace netgen const Box<3> & bbox, double facets) const; - + virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; + virtual double MaxCurvature () const; virtual double MaxCurvatureLoc (const Point<3> & /* c */ , diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index 74067f23..0db96e6d 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -235,13 +235,17 @@ DLL_HEADER void ExportCSG(py::module &m) return self.GetNP()-1; }), py::arg("x"),py::arg("y"),py::arg("z"),py::arg("hpref")=false) - .def("AddSegment", FunctionPointer - ([] (SplineSurface & self, int i1, int i2, string bcname, double maxh) + .def("AddSegment", [] (SplineSurface & self, int i1, int i2, string bcname, double maxh) { auto seg = make_shared>(self.GetPoint(i1),self.GetPoint(i2)); self.AppendSegment(seg,bcname,maxh); - }), + }, py::arg("pnt1"),py::arg("pnt2"),py::arg("bcname")="default", py::arg("maxh")=-1.) + .def("AddSegment", [] (SplineSurface& self, int i1, int i2, int i3, string bcname, double maxh) + { + auto seg = make_shared>(self.GetPoint(i1), self.GetPoint(i2), self.GetPoint(i3)); + self.AppendSegment(seg, bcname, maxh); + }, py::arg("pnt1"),py::arg("pnt2"), py::arg("pnt3"),py::arg("bcname")="default", py::arg("maxh")=-1.) ; py::class_> (m, "Solid") @@ -455,7 +459,12 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails! self.GetTopLevelObject(tlonr) -> SetBCProp(surf->GetBase()->GetBCProperty()); self.GetTopLevelObject(tlonr) -> SetBCName(surf->GetBase()->GetBCName()); self.GetTopLevelObject(tlonr) -> SetMaxH(surf->GetBase()->GetMaxH()); - for(auto p : surf->GetPoints()) + Array> non_midpoints; + for(auto spline : surf->GetSplines()) + { + non_midpoints.Append(spline->GetPoint(0)); + } + for(auto p : non_midpoints) self.AddUserPoint(p); self.AddSplineSurface(surf); }), diff --git a/libsrc/csg/splinesurface.cpp b/libsrc/csg/splinesurface.cpp index 986d616e..6134b1f4 100644 --- a/libsrc/csg/splinesurface.cpp +++ b/libsrc/csg/splinesurface.cpp @@ -62,7 +62,30 @@ void SplineSurface :: AppendPoint(const Point<3> & p, const double reffac, const cuttings->Append(plane); } else - throw NgException("Spline type not implemented for SplineSurface!"); + { + auto spline3 = dynamic_cast*>(spline.get()); + if(spline3) + { + auto p1 = Point<3>(spline3->StartPI()); + Project(p1); + auto p2 = Point<3>(spline3->TangentPoint()); + Project(p2); + auto p3 = Point<3>(spline3->EndPI()); + Project(p3); + Vec<3> v1 = p2-p1; + Vec<3> v2 = p2-p3; + Point<3> mid = p1 - v2; + cout << "mid point = " << mid << endl; + cout << "v1 = " << v1 << endl; + cout << "v2 = " << v2 << endl; + auto cyl = make_shared(mid, v1, v2); + if(maxh[i] > 0) + cyl->SetMaxH(maxh[i]); + cuttings->Append(cyl); + } + else + throw NgException("Spline type not implemented for SplineSurface!"); + } } all_cuts = cuttings; return cuttings; diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index 1ba68b20..a16c13f7 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -17,7 +17,8 @@ DLL_HEADER void ExportGeom2d(py::module &m) { py::class_> (m, "SplineGeometry", - "a 2d boundary representation geometry model by lines and splines") + "a 2d boundary representation geometry model by lines and splines", + py::multiple_inheritance()) .def(py::init<>()) .def(py::init([](const string& filename) {