1 ///
2 class splinesegment3d
3   {
4   ///
5   Point<3> p1, p2, p3;
6 
7   public:
8   ///
9   splinesegment3d (const Point<3> & ap1, const Point<3> & ap2,
10   	const Point<3> & ap3);
11   ///
12   void Evaluate (double t, Point<3> & p) const;
13   ///
14   void EvaluateTangent (double t, Vec<3> & tang) const;
15   ///
P1() const16   const Point<3> & P1() const { return p1; }
17   ///
P2() const18   const Point<3> & P2() const { return p2; }
19   ///
P3() const20   const Point<3> & P3() const { return p3; }
21   };
22 
23 ///
24 class spline3d
25   {
26   ///
27   ARRAY<splinesegment3d *> segments;
28 
29   public:
30   ///
spline3d()31   spline3d () { };
32   ///
33   void AddSegment (const Point<3> & ap1, const Point<3> & ap2, const Point<3> & ap3);
34   ///
GetNumSegments() const35   int GetNumSegments () const { return segments.Size(); }
36   ///
37   double ProjectToSpline (Point<3> & p) const;
38   ///
39   double ProjectToSpline (Point<3> & p, double t) const;
40   ///
41   void Evaluate (double t, Point<3> & p) const;
42   ///
43   void EvaluateTangent (double t, Vec<3> & tang) const;
44   ///
P1(int i) const45   const Point<3> & P1(int i) const { return segments.Get(i)->P1(); }
46   ///
P2(int i) const47   const Point<3> & P2(int i) const { return segments.Get(i)->P2(); }
48   ///
P3(int i) const49   const Point<3> & P3(int i) const { return segments.Get(i)->P3(); }
50   };
51 
52 ///
53 class splinetube : public Surface
54   {
55   ///
56   const spline3d & middlecurve;
57   ///
58   double r;
59 ///  Vec<3> ex, ey, ez;
60   Vec<2> e2x, e2y;
61   ///
62   Point<3> cp;
63 
64   public:
65   ///
66   splinetube (const spline3d & amiddlecurve, double ar);
67 
68   ///
69   virtual void DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2);
70   ///
71   virtual void ToPlane (const Point<3> & p, Point<2> & pplain, double h, int & zone) const;
72   ///
73   virtual void FromPlane (const Point<2> & pplain, Point<3> & p, double h) const;
74   ///
75   virtual void Project (Point<3> & p) const;
76 
77 //  virtual int RootInBox (const box3d & box) const { return 0; }
78     /// 0 .. no, 1 .. yes, 2 .. maybe
79 
80   virtual int BoxInSolid (const BoxSphere<3> & box) const;
81     /// 0 .. no, 1 .. yes, 2 .. maybe
82 
83   virtual double CalcFunctionValue (const Point<3> & point) const;
84   ///
85   virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
86   ///
HesseNorm() const87   virtual double HesseNorm () const { return 0.5 / r; }
88   ///
89   virtual Point<3> GetSurfacePoint () const;
90   ///
91   virtual void Print (ostream & str) const;
92   };
93