Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/geom2d/spline2d.hpp
3206 views
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
41
GeomPoint2d ()
42
{ ; }
43
44
///
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
/// perfrom 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, ARRAY<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 */
93
virtual void LineIntersections (const double a, const double b, const double c,
94
ARRAY < Point<2> > & points, const double eps) const
95
{points.SetSize(0);}
96
97
virtual double MaxCurvature(void) const = 0;
98
99
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
///
116
virtual const GeomPoint2d & StartPI () const { return p1; };
117
///
118
virtual const GeomPoint2d & EndPI () const { return p2; }
119
///
120
//virtual void PrintCoeff (ostream & ost) const;
121
virtual void GetCoeff (Vector & coeffs) const;
122
123
virtual string GetType(void) const {return "line";}
124
125
virtual void LineIntersections (const double a, const double b, const double c,
126
ARRAY < Point<2> > & points, const double eps) const;
127
128
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
///
145
virtual const GeomPoint2d & StartPI () const { return p1; };
146
///
147
virtual const GeomPoint2d & EndPI () const { return p3; }
148
///
149
//virtual void PrintCoeff (ostream & ost) const;
150
virtual void GetCoeff (Vector & coeffs) const;
151
152
virtual string GetType(void) const {return "spline3";}
153
154
const GeomPoint2d & TangentPoint (void) const { return p2; }
155
156
virtual void LineIntersections (const double a, const double b, const double c,
157
ARRAY < 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
///
180
virtual const GeomPoint2d & StartPI () const { return p1; }
181
///
182
virtual const GeomPoint2d & EndPI () const { return p3; }
183
///
184
//virtual void PrintCoeff (ostream & ost) const;
185
virtual void GetCoeff (Vector & coeffs) const;
186
///
187
double Radius() const { return radius; }
188
///
189
double StartAngle() const { return w1; }
190
///
191
double EndAngle() const { return w3; }
192
///
193
const Point<2> & MidPoint(void) const {return pm; }
194
195
virtual string GetType(void) const {return "circle";}
196
197
virtual void LineIntersections (const double a, const double b, const double c,
198
ARRAY < Point<2> > & points, const double eps) const;
199
200
virtual double MaxCurvature(void) const {return 1./radius;}
201
};
202
203
204
205
206
207
208
///
209
class DiscretePointsSegment : public SplineSegment
210
{
211
ARRAY<Point<2> > pts;
212
GeomPoint2d p1, p2;
213
public:
214
///
215
DiscretePointsSegment (const ARRAY<Point<2> > & apts);
216
///
217
virtual ~DiscretePointsSegment ();
218
///
219
virtual Point<2> GetPoint (double t) const;
220
///
221
virtual const GeomPoint2d & StartPI () const { return p1; };
222
///
223
virtual const GeomPoint2d & EndPI () const { return p2; }
224
///
225
//virtual void PrintCoeff (ostream & /* ost */) const { ; }
226
virtual void GetCoeff (Vector & coeffs) const {;}
227
228
virtual double MaxCurvature(void) const {return 1;}
229
};
230
231
232
#endif
233
234
#endif
235
236