Store Ellipsoid csg surface in mesh files

This commit is contained in:
Matthias Hochsteger 2020-01-15 15:13:08 +01:00
parent 3ece315bd0
commit 4810b4f1b2
3 changed files with 45 additions and 7 deletions

View File

@ -642,6 +642,32 @@ namespace netgen
cz = v(2); cz = v(2);
} }
void Ellipsoid :: GetPrimitiveData (const char *& classname, NgArray<double> & 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<double> & 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 INSOLID_TYPE Ellipsoid :: BoxInSolid (const BoxSphere<3> & box) const
{ {

View File

@ -339,23 +339,26 @@ namespace netgen
// default constructor for archive // default constructor for archive
Ellipsoid() {} Ellipsoid() {}
virtual void DoArchive(Archive& ar) void DoArchive(Archive& ar) override
{ {
QuadraticSurface::DoArchive(ar); QuadraticSurface::DoArchive(ar);
ar & a & v1 & v2 & v3 & rmin; 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, const Box<3> & bbox,
double facets) const; double facets) const override;
void GetPrimitiveData (const char *& classname, NgArray<double> & coeffs) const override;
void SetPrimitiveData (NgArray<double> & coeffs) override;
private: private:
void CalcData(); void CalcData();

View File

@ -562,6 +562,15 @@ namespace netgen
delete_them.Append(cone); 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") else if(classname == "ellipticcone")
{ {
EllipticCone * ellipticcone = new EllipticCone(dummypoint,dummyvec,dummyvec,dummydouble,dummydouble); EllipticCone * ellipticcone = new EllipticCone(dummypoint,dummyvec,dummyvec,dummydouble,dummydouble);