Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/csg/revolution.hpp
3206 views
1
#ifndef _REVOLUTION_HPP
2
#define _REVOLUTION_HPP
3
4
class Revolution;
5
6
class RevolutionFace : public Surface
7
{
8
private:
9
bool isfirst, islast;
10
const SplineSeg<2> * spline;
11
bool deletable;
12
13
Point<3> p0;
14
Vec<3> v_axis;
15
16
int id;
17
18
mutable Vector spline_coefficient;
19
20
21
ARRAY < Vec<2>* > checklines_vec;
22
ARRAY < Point<2>* > checklines_start;
23
ARRAY < Vec<2>* > checklines_normal;
24
25
private:
26
void Init (void);
27
28
public:
29
void CalcProj(const Point<3> & point3d, Point<2> & point2d) const;
30
void CalcProj(const Point<3> & point3d, Point<2> & point2d,
31
const Vec<3> & vector3d, Vec<2> & vector2d) const;
32
void CalcProj0(const Vec<3> & point3d_minus_p0, Point<2> & point2d) const;
33
34
public:
35
RevolutionFace(const SplineSeg<2> & spline_in,
36
const Point<3> & p,
37
const Vec<3> & vec,
38
bool first = false,
39
bool last = false,
40
const int id_in = 0);
41
42
RevolutionFace(const ARRAY<double> & raw_data);
43
44
~RevolutionFace();
45
46
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
47
48
virtual double CalcFunctionValue (const Point<3> & point) const;
49
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
50
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
51
virtual double HesseNorm () const;
52
53
virtual double MaxCurvature () const;
54
//virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
55
// double /* rad */) const;
56
57
virtual void Project (Point<3> & p) const;
58
59
virtual Point<3> GetSurfacePoint () const;
60
virtual void Print (ostream & str) const;
61
62
virtual void GetTriangleApproximation (TriangleApproximation & tas,
63
const Box<3> & boundingbox,
64
double facets) const;
65
66
bool BoxIntersectsFace (const Box<3> & box) const;
67
/*
68
bool BoxIntersectsFace (const BoxSphere<2> & box, bool & uncertain) const;
69
bool BoxIntersectsFace (const BoxSphere<3> & box, bool & uncertain) const;
70
*/
71
72
const SplineSeg<2> & GetSpline(void) const {return *spline;}
73
74
INSOLID_TYPE PointInFace (const Point<3> & p, const double eps) const;
75
76
void GetRawData(ARRAY<double> & data) const;
77
78
};
79
80
81
82
/*
83
84
Primitive of revolution
85
86
*/
87
88
89
class Revolution : public Primitive
90
{
91
private:
92
Point<3> p0,p1;
93
Vec<3> v_axis;
94
const SplineGeometry2d & splinecurve;
95
const int nsplines;
96
97
// 1 ... torus-like
98
// 2 ... sphere-like
99
int type;
100
101
102
ARRAY<RevolutionFace*> faces;
103
104
mutable int intersecting_face;
105
106
public:
107
Revolution(const Point<3> & p0_in,
108
const Point<3> & p1_in,
109
const SplineGeometry2d & spline_in);
110
111
~Revolution();
112
113
114
/*
115
Check, whether box intersects solid defined by surface.
116
117
return values:
118
0 .. box outside solid \\
119
1 .. box in solid \\
120
2 .. can't decide (allowed, iff box is close to solid)
121
*/
122
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
123
virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
124
double eps) const;
125
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
126
const Vec<3> & v,
127
double eps) const;
128
129
// checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
130
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
131
const Vec<3> & v1,
132
const Vec<3> & v2,
133
double eps) const;
134
135
136
virtual int GetNSurfaces() const;
137
virtual Surface & GetSurface (int i = 0);
138
virtual const Surface & GetSurface (int i = 0) const;
139
140
141
virtual void Reduce (const BoxSphere<3> & box);
142
virtual void UnReduce ();
143
144
145
};
146
147
148
149
#endif
150
151