netgen/libsrc/csg/spline3d.hpp

100 lines
2.4 KiB
C++
Raw Normal View History

2009-09-07 17:50:13 +06:00
namespace netgen
{
2009-01-13 04:40:13 +05:00
///
2009-09-07 17:50:13 +06:00
class splinesegment3d
{
///
Point<3> p1, p2, p3;
2009-01-13 04:40:13 +05:00
public:
2009-09-07 17:50:13 +06:00
///
splinesegment3d (const Point<3> & ap1, const Point<3> & ap2,
const Point<3> & ap3);
///
void Evaluate (double t, Point<3> & p) const;
///
void EvaluateTangent (double t, Vec<3> & tang) const;
///
const Point<3> & P1() const { return p1; }
///
const Point<3> & P2() const { return p2; }
///
const Point<3> & P3() const { return p3; }
2009-01-13 04:40:13 +05:00
};
///
2009-09-07 17:50:13 +06:00
class spline3d
{
///
2019-07-09 13:39:16 +05:00
NgArray<splinesegment3d *> segments;
2009-01-13 04:40:13 +05:00
public:
2009-09-07 17:50:13 +06:00
///
spline3d () { };
///
void AddSegment (const Point<3> & ap1, const Point<3> & ap2, const Point<3> & ap3);
///
int GetNumSegments () const { return segments.Size(); }
///
double ProjectToSpline (Point<3> & p) const;
///
double ProjectToSpline (Point<3> & p, double t) const;
///
void Evaluate (double t, Point<3> & p) const;
///
void EvaluateTangent (double t, Vec<3> & tang) const;
///
const Point<3> & P1(int i) const { return segments.Get(i)->P1(); }
///
const Point<3> & P2(int i) const { return segments.Get(i)->P2(); }
///
const Point<3> & P3(int i) const { return segments.Get(i)->P3(); }
2009-01-13 04:40:13 +05:00
};
///
2009-09-07 17:50:13 +06:00
class splinetube : public Surface
{
///
const spline3d & middlecurve;
///
double r;
/// Vec<3> ex, ey, ez;
Vec<2> e2x, e2y;
///
Point<3> cp;
2009-01-13 04:40:13 +05:00
public:
2009-09-07 17:50:13 +06:00
///
splinetube (const spline3d & amiddlecurve, double ar);
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
///
virtual void DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2);
///
virtual void ToPlane (const Point<3> & p, Point<2> & pplain, double h, int & zone) const;
///
virtual void FromPlane (const Point<2> & pplain, Point<3> & p, double h) const;
///
virtual void Project (Point<3> & p) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
// virtual int RootInBox (const box3d & box) const { return 0; }
2009-01-13 04:40:13 +05:00
/// 0 .. no, 1 .. yes, 2 .. maybe
2009-09-07 17:50:13 +06:00
virtual int BoxInSolid (const BoxSphere<3> & box) const;
2009-01-13 04:40:13 +05:00
/// 0 .. no, 1 .. yes, 2 .. maybe
2009-09-07 17:50:13 +06:00
virtual double CalcFunctionValue (const Point<3> & point) const;
///
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
///
virtual double HesseNorm () const { return 0.5 / r; }
///
virtual Point<3> GetSurfacePoint () const;
///
virtual void Print (ostream & str) const;
2009-01-13 04:40:13 +05:00
};
2009-09-07 17:50:13 +06:00
}