Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/meshgen2d/src/include/VSVertex.h
3203 views
1
#if !defined( MESH_VSVERTEX_H )
2
#define MESH_VSVERTEX_H
3
4
#include "PQ.h"
5
#include "Vertex.h"
6
#include "BGMesh.h"
7
8
enum vertexType { ACCEPTED=0, ACTIVE, WAITING, CRYSTAL };
9
class VSVertex : public Vertex
10
{
11
public:
12
VSVertex() : Vertex() { type = WAITING; }
13
VSVertex( Node* n1, Node* n2, Node* n3 ) : Vertex(n1, n2, n3) { type = WAITING; }
14
void reset( Node* n1, Node* n2, Node* n3 )
15
{
16
Vertex::reset(n1,n2,n3);
17
type = WAITING;
18
}
19
20
virtual double orderingValue() { return radius; }
21
double ratioValue() { return ratio; }
22
bool isWaiting() { return type == WAITING; }
23
bool isAccepted() { return type == ACCEPTED; }
24
bool isActive() { return type == ACTIVE; }
25
26
void makeWaiting() { type = WAITING; }
27
void makeAccepted() { type = ACCEPTED; }
28
void makeActive() { type = ACTIVE; }
29
30
bool testIfActive( pq& actives )
31
{
32
VSVertex *v1 = static_cast<VSVertex *>( vertices[0] );
33
VSVertex *v2 = static_cast<VSVertex *>( vertices[1] );
34
VSVertex *v3 = static_cast<VSVertex *>( vertices[2] );
35
36
if( v1->isExternal() || v2->isExternal() ||
37
v3->isExternal() ||
38
v1->isAccepted() || v2->isAccepted() ||
39
v3->isAccepted() )
40
{
41
type = ACTIVE;
42
actives.insert( this );
43
return true;
44
}
45
return false;
46
}
47
48
void radiate( pq& actives )
49
{
50
VSVertex *v1 = static_cast<VSVertex *>( vertices[0] );
51
VSVertex *v2 = static_cast<VSVertex *>( vertices[1] );
52
VSVertex *v3 = static_cast<VSVertex *>( vertices[2] );
53
54
if( !v1->isExternal() && v1->isWaiting() )
55
{
56
v1->makeActive();
57
actives.insert( v1 );
58
}
59
if( !v2->isExternal() && v2->isWaiting() )
60
{
61
v2->makeActive();
62
actives.insert( v2 );
63
}
64
if( !v3->isExternal() && v3->isWaiting() )
65
{
66
v3->makeActive();
67
actives.insert( v3 );
68
}
69
}
70
71
bool borderTest()
72
{
73
VSVertex *v1 = static_cast<VSVertex *>( vertices[0] );
74
VSVertex *v2 = static_cast<VSVertex *>( vertices[1] );
75
VSVertex *v3 = static_cast<VSVertex *>( vertices[2] );
76
77
if( (v1->isAccepted() || v1->isExternal()) &&
78
(v2->isAccepted() || v2->isExternal()) &&
79
(v3->isAccepted() || v3->isExternal()))
80
{
81
makeAccepted();
82
return true;
83
}
84
return false;
85
}
86
87
int computeNewCoordinates( BGMesh& bg, double& nx, double& ny );
88
89
protected:
90
vertexType type;
91
};
92
#endif /* MESH_VSVERTEX_H */
93
94