diff --git a/libsrc/csg/algprim.cpp b/libsrc/csg/algprim.cpp index e43b0022..8aa9be73 100644 --- a/libsrc/csg/algprim.cpp +++ b/libsrc/csg/algprim.cpp @@ -642,6 +642,32 @@ namespace netgen cz = v(2); } + void Ellipsoid :: GetPrimitiveData (const char *& classname, NgArray & coeffs) const + { + classname = "ellipsoid"; + coeffs.SetSize (12); + for(auto i : Range(3)) + { + coeffs[i] = a(i); + coeffs[3+i] = v1(i); + coeffs[6+i] = v2(i); + coeffs[9+i] = v3(i); + } + } + + void Ellipsoid :: SetPrimitiveData (NgArray & coeffs) + { + for(auto i : Range(3)) + { + a(i) = coeffs[i]; + v1(i) = coeffs[3+i]; + v2(i) = coeffs[6+i]; + v3(i) = coeffs[9+i]; + } + + CalcData(); + } + INSOLID_TYPE Ellipsoid :: BoxInSolid (const BoxSphere<3> & box) const { diff --git a/libsrc/csg/algprim.hpp b/libsrc/csg/algprim.hpp index fde47dc4..e32b0eee 100644 --- a/libsrc/csg/algprim.hpp +++ b/libsrc/csg/algprim.hpp @@ -339,23 +339,26 @@ namespace netgen // default constructor for archive Ellipsoid() {} - virtual void DoArchive(Archive& ar) + void DoArchive(Archive& ar) override { QuadraticSurface::DoArchive(ar); ar & a & v1 & v2 & v3 & rmin; } /// - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const override; /// - virtual double HesseNorm () const; + double HesseNorm () const override; /// - virtual double MaxCurvature () const; + double MaxCurvature () const override; /// - virtual Point<3> GetSurfacePoint () const; + Point<3> GetSurfacePoint () const override; - virtual void GetTriangleApproximation (TriangleApproximation & tas, + void GetTriangleApproximation (TriangleApproximation & tas, const Box<3> & bbox, - double facets) const; + double facets) const override; + + void GetPrimitiveData (const char *& classname, NgArray & coeffs) const override; + void SetPrimitiveData (NgArray & coeffs) override; private: void CalcData(); diff --git a/libsrc/csg/csgeom.cpp b/libsrc/csg/csgeom.cpp index fa4c78f7..4874f0a9 100644 --- a/libsrc/csg/csgeom.cpp +++ b/libsrc/csg/csgeom.cpp @@ -562,6 +562,15 @@ namespace netgen delete_them.Append(cone); } + else if(classname == "ellipsoid") + { + Ellipsoid * ellipsoid = new Ellipsoid(dummypoint,dummyvec,dummyvec,dummyvec); + ellipsoid->SetPrimitiveData(coeffs); + + AddSurface(ellipsoid); + delete_them.Append(ellipsoid); + } + else if(classname == "ellipticcone") { EllipticCone * ellipticcone = new EllipticCone(dummypoint,dummyvec,dummyvec,dummydouble,dummydouble);