Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/stlgeom/stlline.hpp
3206 views
1
#ifndef FILE_STLLINE
2
#define FILE_STLLINE
3
4
5
/**************************************************************************/
6
/* File: stlline.hh */
7
/* Author: Joachim Schoeberl */
8
/* Author2: Johannes Gerstmayr */
9
/* Date: 20. Nov. 99 */
10
/**************************************************************************/
11
12
class STLGeometry;
13
class STLTopology;
14
15
class STLEdge
16
{
17
public:
18
int pts[2];
19
int trigs[2]; //left and right trig
20
21
STLEdge (const int * apts) {pts[0] = apts[0]; pts[1] = apts[1];}
22
STLEdge (int v1, int v2) {pts[0] = v1; pts[1] = v2;}
23
STLEdge () {pts[0]=0;pts[1]=0;}
24
int PNum(int i) const {return pts[(i-1)];}
25
26
int LeftTrig() const {return trigs[0];}
27
int RightTrig() const {return trigs[1];}
28
void SetLeftTrig(int i) {trigs[0] = i;}
29
void SetRightTrig(int i) {trigs[1] = i;}
30
};
31
32
enum STL_ED_STATUS { ED_EXCLUDED, ED_CONFIRMED, ED_CANDIDATE, ED_UNDEFINED };
33
34
35
/*
36
37
class STLEdgeData
38
{
39
public:
40
// float angle;
41
int p1;
42
int p2;
43
int lt; //left trig
44
int rt; //right trig
45
// int status;
46
47
STLTopology * top; // pointer to stl topology
48
int topedgenr; // number of corresponding topology edge
49
50
STLEdgeData() {};
51
STLEdgeData(float anglei, int p1i, int p2i, int lti, int rti)
52
{
53
// angle = anglei;
54
p1 = p1i; p2 = p2i;
55
lt = lti; rt = rti;
56
}
57
58
int GetStatus () const;
59
void SetStatus (int stat);
60
61
void SetExcluded() { SetStatus (ED_EXCLUDED); }
62
void SetConfirmed() { SetStatus (ED_CONFIRMED); }
63
void SetCandidate() { SetStatus (ED_CANDIDATE); }
64
void SetUndefined() { SetStatus (ED_UNDEFINED); }
65
66
int Excluded() const {return GetStatus() == ED_EXCLUDED;}
67
int Confirmed() const {return GetStatus() == ED_CONFIRMED;}
68
int Candidate() const {return GetStatus() == ED_CANDIDATE;}
69
int Undefined() const {return GetStatus() == ED_UNDEFINED;}
70
int ConfCand() const {return GetStatus() == ED_CONFIRMED || GetStatus() == ED_CANDIDATE;}
71
72
float CosAngle() const;
73
74
void Write(ofstream& of) const;
75
void Read(ifstream& ifs);
76
};
77
78
class STLEdgeDataList
79
{
80
private:
81
INDEX_2_HASHTABLE<int> hashtab;
82
ARRAY<STLEdgeData> edgedata;
83
TABLE<int> edgesperpoint;
84
85
public:
86
87
STLEdgeDataList():edgedata(),hashtab(1),edgesperpoint() {};
88
const STLEdgeDataList& operator=(const STLEdgeDataList& edl);
89
void SetSize(int size)
90
{
91
edgedata.SetSize(size);
92
hashtab.SetSize(size);
93
edgesperpoint.SetSize(size);
94
}
95
void Clear() {SetSize(0);}
96
int Size() const {return edgedata.Size();}
97
const STLEdgeData& Get(int i) const {return edgedata.Get(i);}
98
STLEdgeData& Elem(int i) {return edgedata.Elem(i);}
99
void Add(const STLEdgeData& ed, int i);
100
101
int GetNEPP(int pn) const
102
{
103
return edgesperpoint.EntrySize(pn);
104
};
105
int GetEdgePP(int pn, int vi) const
106
{
107
return edgesperpoint.Get(pn,vi);
108
};
109
void AddEdgePP(int pn, int vn) {edgesperpoint.Add(pn,vn);};
110
111
void ResetAll();
112
void ResetCandidates();
113
void ConfirmCandidates();
114
int GetEdgeNum(int np1, int np2) const;
115
116
int GetNConfEdges() const;
117
118
void Write(ofstream& of) const;
119
void Read(ifstream& ifs);
120
121
void BuildLineWithEdge(int ep1, int ep2, ARRAY<twoint>& line);
122
123
int GetNEPPStat(int p, int status) const;
124
int GetNConfCandEPP(int p) const;
125
};
126
*/
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//a line defined by several points (polyline)
144
class STLLine
145
{
146
private:
147
const STLGeometry * geometry;
148
ARRAY<int> pts;
149
ARRAY<int> lefttrigs;
150
ARRAY<int> righttrigs;
151
ARRAY<double> dists;
152
int split;
153
154
public:
155
STLLine(const STLGeometry * ageometry);
156
void AddPoint(int i) {pts.Append(i);}
157
int PNum(int i) const {return pts.Get(i);}
158
int NP() const {return pts.Size();}
159
int GetNS() const;
160
void GetSeg(int nr, int& p1, int& p2) const;
161
double GetSegLen(const ARRAY<Point<3> >& ap, int nr) const;
162
int GetLeftTrig(int nr) const;
163
int GetRightTrig(int nr) const;
164
double GetDist(int nr) const { return dists.Get(nr);};
165
void GetBoundingBox (const ARRAY<Point<3> > & ap, Box<3> & box) const;
166
167
void AddLeftTrig(int nr) {lefttrigs.Append(nr);}
168
void AddRightTrig(int nr) {righttrigs.Append(nr);}
169
void AddDist (double dist) {dists.Append(dist); }
170
int StartP() const {return pts.Get(1);}
171
int EndP() const {return pts.Get(pts.Size());}
172
173
double GetLength(const ARRAY<Point<3> >& ap) const;
174
175
//suche punkt in entfernung (in linienkoordinaten) dist
176
//in index ist letzter punkt VOR dist (d.h. max pts.Size()-1)
177
Point<3> GetPointInDist(const ARRAY<Point<3> >& ap, double dist, int& index) const;
178
179
//return a meshed polyline
180
STLLine* Mesh(const ARRAY<Point<3> >& ap,
181
ARRAY<Point3d>& mp, double ghi,
182
class Mesh& mesh) const;
183
184
void DoSplit() {split = 1;}
185
int ShouldSplit() const {return split;}
186
};
187
188
#endif
189
190