Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/meshgen2d/src/include/SSSFVertex.h
3203 views
1
#if !defined( MESH_SSSFVERTEX_H )
2
#define MESH_SSSFVERTEX_H
3
4
#include "VSVertex.h"
5
6
class SSSFVertex : public VSVertex
7
{
8
public:
9
SSSFVertex() : VSVertex() { }
10
SSSFVertex( Node* n1, Node* n2, Node* n3 ) : VSVertex(n1, n2, n3) { }
11
12
bool testIfActive( pq& actives, pq& crystals )
13
{
14
SSSFVertex *v1 = static_cast<SSSFVertex *>( vertices[0] );
15
SSSFVertex *v2 = static_cast<SSSFVertex *>( vertices[1] );
16
SSSFVertex *v3 = static_cast<SSSFVertex *>( vertices[2] );
17
18
if( v1->isAccepted() || v2->isAccepted() || v3->isAccepted() )
19
{
20
makeActive();
21
if( isActive() )
22
actives.insert( this );
23
else if( isCrystal() )
24
crystals.insert( this );
25
return true;
26
}
27
return false;
28
}
29
30
void radiate( pq& actives, pq& crystals )
31
{
32
SSSFVertex *v1 = static_cast<SSSFVertex *>( vertices[0] );
33
SSSFVertex *v2 = static_cast<SSSFVertex *>( vertices[1] );
34
SSSFVertex *v3 = static_cast<SSSFVertex *>( vertices[2] );
35
36
if( !v1->isExternal() && v1->isWaiting() )
37
{
38
v1->makeActive();
39
if( v1->isActive() )
40
actives.insert( v1 );
41
else if( v1->isCrystal() )
42
crystals.insert( v1 );
43
}
44
if( !v2->isExternal() && v2->isWaiting() )
45
{
46
v2->makeActive();
47
if( v2->isActive() )
48
actives.insert( v2 );
49
else if( v2->isCrystal() )
50
crystals.insert( v2 );
51
}
52
if( !v3->isExternal() && v3->isWaiting() )
53
{
54
v3->makeActive();
55
if( v3->isActive() )
56
actives.insert( v3 );
57
else if( v3->isCrystal() )
58
crystals.insert( v3 );
59
}
60
}
61
62
void makeAccepted()
63
{
64
MeshNode *n1 = static_cast<MeshNode *>( nodes[0] );
65
MeshNode *n2 = static_cast<MeshNode *>( nodes[1] );
66
MeshNode *n3 = static_cast<MeshNode *>( nodes[2] );
67
68
type = ACCEPTED;
69
n1->putOnCrysralIfNotFixed();
70
n2->putOnCrysralIfNotFixed();
71
n3->putOnCrysralIfNotFixed();
72
}
73
74
void makeActive()
75
{
76
MeshNode *n1 = static_cast<MeshNode *>( nodes[0] );
77
MeshNode *n2 = static_cast<MeshNode *>( nodes[1] );
78
MeshNode *n3 = static_cast<MeshNode *>( nodes[2] );
79
80
if( n1->isCrystal() && n2->isCrystal() && n3->isCrystal() )
81
{
82
// type = CRYSTAL;
83
// return;
84
85
SSSFVertex *v1 = static_cast<SSSFVertex *>( vertices[0] );
86
SSSFVertex *v2 = static_cast<SSSFVertex *>( vertices[1] );
87
SSSFVertex *v3 = static_cast<SSSFVertex *>( vertices[2] );
88
89
int counter = 0;
90
if(v1 != (SSSFVertex *)0) if(v1->isAccepted()) ++counter;
91
if(v2 != (SSSFVertex *)0) if(v2->isAccepted()) ++counter;
92
if(v3 != (SSSFVertex *)0) if(v3->isAccepted()) ++counter;
93
if(counter >= 2)
94
{
95
type = CRYSTAL;
96
return;
97
}
98
}
99
type = ACTIVE;
100
}
101
102
bool isCrystal() { return type == CRYSTAL; }
103
bool wasCrystal()
104
{
105
MeshNode *n1 = static_cast<MeshNode *>( nodes[0] );
106
MeshNode *n2 = static_cast<MeshNode *>( nodes[1] );
107
MeshNode *n3 = static_cast<MeshNode *>( nodes[2] );
108
109
if( n1->isCrystal() && n2->isCrystal() && n3->isCrystal() )
110
return true;
111
return false;
112
}
113
};
114
115
#endif /* MESH_SSSFVERTEX_H */
116
117
118
119