1 
2 
3 
4 
5 das File sollte nicht mehr verwendet werden ---> spline.hpp
6 
7 
8 
9 
10 
11 
12 
13 #ifndef FILE_SPLINE2D
14 #define FILE_SPLINE2D
15 
16 /**************************************************************************/
17 /* File:   spline2d.hh                                                    */
18 /* Author: Joachim Schoeberl                                              */
19 /* Date:   24. Jul. 96                                                    */
20 /**************************************************************************/
21 
22 
23 /*
24   Spline curves for 2D mesh generation
25   */
26 
27 #include "spline.hpp"
28 
29 
30 //#define OLDSPLINEVERSION
31 #ifdef OLDSPLINEVERSION
32 
33 /// Geometry point
34 class GeomPoint2d : public Point<2>
35 {
36 public:
37   /// refinement to point
38   double refatpoint;
39   bool hpref;
40 
GeomPoint2d()41   GeomPoint2d ()
42   { ; }
43 
44   ///
GeomPoint2d(double ax,double ay,double aref=1)45   GeomPoint2d (double ax, double ay, double aref = 1)
46     : Point<2> (ax, ay), refatpoint(aref) { ; }
47 };
48 
49 
50 
51 /// base class for 2d - segment
52 class SplineSegment
53 {
54 public:
55   /// left domain
56   int leftdom;
57   /// right domain
58   int rightdom;
59   /// refinement at line
60   double reffak;
61   /// boundary condition number
62   int bc;
63   /// copy spline mesh from other spline (-1.. do not copy)
64   int copyfrom;
65   /// perform anisotropic refinement (hp-refinement) to edge
66   bool hpref_left;
67   bool hpref_right;
68   /// calculates length of curve
69   virtual double Length () const;
70   /// returns point at curve, 0 <= t <= 1
71   virtual Point<2> GetPoint (double t) const = 0;
72   /// partitionizes curve
73   void Partition (double h, double elto0,
74 		  Mesh & mesh, Point3dTree & searchtree, int segnr) const;
75   /// returns initial point on curve
76   virtual const GeomPoint2d & StartPI () const = 0;
77   /// returns terminal point on curve
78   virtual const GeomPoint2d & EndPI () const = 0;
79   /** writes curve description for fepp:
80     for implicitly given quadratic curves, the 6 coefficients of
81     the polynomial
82     $$ a x^2 + b y^2 + c x y + d x + e y + f = 0 $$
83     are written to ost */
84   void PrintCoeff (ostream & ost) const;
85 
86   virtual void GetCoeff (Vector & coeffs) const = 0;
87 
88   virtual void GetPoints (int n, NgArray<Point<2> > & points);
89 
90   /** calculates lineintersections:
91       for lines $$ a x + b y + c = 0 $$ the interecting points are calculated
92       and stored in points */
LineIntersections(const double a,const double b,const double c,NgArray<Point<2>> & points,const double eps) const93   virtual void LineIntersections (const double a, const double b, const double c,
94 				  NgArray < Point<2> > & points, const double eps) const
95   {points.SetSize(0);}
96 
97   virtual double MaxCurvature(void) const = 0;
98 
GetType(void) const99   virtual string GetType(void) const {return "splinebase";}
100 };
101 
102 
103 /// Straight line form p1 to p2
104 class LineSegment : public SplineSegment
105 {
106   ///
107   const GeomPoint2d &p1, &p2;
108 public:
109   ///
110   LineSegment (const GeomPoint2d & ap1, const GeomPoint2d & ap2);
111   ///
112   virtual double Length () const;
113   ///
114   virtual Point<2> GetPoint (double t) const;
115   ///
StartPI() const116   virtual const GeomPoint2d & StartPI () const { return p1; };
117   ///
EndPI() const118   virtual const GeomPoint2d & EndPI () const { return p2; }
119   ///
120   //virtual void PrintCoeff (ostream & ost) const;
121   virtual void GetCoeff (Vector & coeffs) const;
122 
GetType(void) const123   virtual string GetType(void) const {return "line";}
124 
125   virtual void LineIntersections (const double a, const double b, const double c,
126 				  NgArray < Point<2> > & points, const double eps) const;
127 
MaxCurvature(void) const128   virtual double MaxCurvature(void) const {return 0;}
129 };
130 
131 
132 /// curve given by a rational, quadratic spline (including ellipses)
133 class SplineSegment3 : public SplineSegment
134 {
135   ///
136   const GeomPoint2d &p1, &p2, &p3;
137 public:
138   ///
139   SplineSegment3 (const GeomPoint2d & ap1,
140 		  const GeomPoint2d & ap2,
141 		  const GeomPoint2d & ap3);
142   ///
143   virtual Point<2> GetPoint (double t) const;
144   ///
StartPI() const145   virtual const GeomPoint2d & StartPI () const { return p1; };
146   ///
EndPI() const147   virtual const GeomPoint2d & EndPI () const { return p3; }
148   ///
149   //virtual void PrintCoeff (ostream & ost) const;
150   virtual void GetCoeff (Vector & coeffs) const;
151 
GetType(void) const152   virtual string GetType(void) const {return "spline3";}
153 
TangentPoint(void) const154   const GeomPoint2d & TangentPoint (void) const { return p2; }
155 
156   virtual void LineIntersections (const double a, const double b, const double c,
157 				  NgArray < Point<2> > & points, const double eps) const;
158 
159   virtual double MaxCurvature(void) const;
160 };
161 
162 
163 // Gundolf Haase  8/26/97
164 /// A circle
165 class CircleSegment : public SplineSegment
166 {
167   ///
168 private:
169   const GeomPoint2d	&p1, &p2, &p3;
170   Point<2>		pm;
171   double		radius, w1,w3;
172 public:
173   ///
174   CircleSegment (const GeomPoint2d & ap1,
175 		 const GeomPoint2d & ap2,
176 		 const GeomPoint2d & ap3);
177   ///
178   virtual Point<2> GetPoint (double t) const;
179   ///
StartPI() const180   virtual const GeomPoint2d & StartPI () const { return p1; }
181   ///
EndPI() const182   virtual const GeomPoint2d & EndPI () const { return p3; }
183   ///
184   //virtual void PrintCoeff (ostream & ost) const;
185   virtual void GetCoeff (Vector & coeffs) const;
186   ///
Radius() const187   double Radius() const { return radius; }
188   ///
StartAngle() const189   double StartAngle() const { return w1; }
190   ///
EndAngle() const191   double EndAngle() const { return w3; }
192   ///
MidPoint(void) const193   const Point<2> & MidPoint(void) const {return pm; }
194 
GetType(void) const195   virtual string GetType(void) const {return "circle";}
196 
197   virtual void LineIntersections (const double a, const double b, const double c,
198 				  NgArray < Point<2> > & points, const double eps) const;
199 
MaxCurvature(void) const200   virtual double MaxCurvature(void) const {return 1./radius;}
201 };
202 
203 
204 
205 
206 
207 
208 ///
209 class DiscretePointsSegment : public SplineSegment
210 {
211   NgArray<Point<2> > pts;
212   GeomPoint2d p1, p2;
213 public:
214   ///
215   DiscretePointsSegment (const NgArray<Point<2> > & apts);
216   ///
217   virtual ~DiscretePointsSegment ();
218   ///
219   virtual Point<2> GetPoint (double t) const;
220   ///
StartPI() const221   virtual const GeomPoint2d & StartPI () const { return p1; };
222   ///
EndPI() const223   virtual const GeomPoint2d & EndPI () const { return p2; }
224   ///
225   //virtual void PrintCoeff (ostream & /* ost */) const { ; }
GetCoeff(Vector & coeffs) const226   virtual void GetCoeff (Vector & coeffs) const {;}
227 
MaxCurvature(void) const228   virtual double MaxCurvature(void) const {return 1;}
229 };
230 
231 
232 #endif
233 
234 #endif
235