Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/meshgen2d/src/include/Loop.h
3203 views
1
#if !defined( MESH_LOOP_H )
2
#define MESH_LOOP_H
3
4
#include "GeometryEdge.h"
5
#include <set>
6
#include <vector>
7
#include <algorithm>
8
9
#include "../../config.h"
10
#if defined(_NO_STD_MINMAX) || defined(WIN32)
11
#include "minmaxpatch.h"
12
#endif
13
14
class Loop
15
{
16
public:
17
Loop() { }
18
19
void addEdge( const int dir, GeometryEdge *ed )
20
{
21
direction.push_back( dir );
22
edges.push_back( ed );
23
if( dir == 1 )
24
nodes.push_back( ed->base() );
25
else
26
nodes.push_back( ed->end() );
27
}
28
29
void collectNodes( std::vector< Node * >& chain )
30
{
31
int i;
32
std::vector<Node*> strip;
33
int len = edges.size();
34
for( i = 0; i < len; ++i )
35
{
36
edges[i]->exportNodes(strip, direction[i]);
37
strip.pop_back();
38
}
39
40
std::copy(strip.begin(), strip.end(), std::back_inserter( chain ));
41
}
42
43
void collectNodesAndPairs( std::vector< Node * >& chain, std::set< std::pair< int, int > >& links )
44
{
45
int i;
46
std::vector<Node*> strip;
47
int len = edges.size();
48
for( i = 0; i < len; ++i )
49
{
50
edges[i]->exportNodes(strip, direction[i]);
51
strip.pop_back();
52
}
53
54
len = strip.size();
55
for( i = 0; i < len; ++i )
56
{
57
int t1 = strip[i]->tag;
58
int t2 = strip[(i+1)%len]->tag;
59
const std::pair<int, int> ip = std::make_pair(std::min(t1,t2),std::max(t1,t2));
60
links.insert( ip );
61
}
62
63
std::copy(strip.begin(), strip.end(), std::back_inserter( chain ));
64
}
65
66
void collectGeometryNodes( std::vector< GeometryNode * >& chain )
67
{
68
int i;
69
int len = edges.size();
70
for( i = 0; i < len; ++i )
71
{
72
edges[i]->exportGeometryNodes( chain, direction[i] );
73
chain.pop_back();
74
}
75
}
76
77
void collectBoundaryElements( std::vector< BoundaryElement * >& chain )
78
{
79
int i;
80
int len = edges.size();
81
for( i = 0; i < len; ++i )
82
{
83
if( !edges[i]->isVirtual() )
84
edges[i]->elements(chain, direction[i]);
85
}
86
}
87
88
std::vector< int > direction;
89
std::vector< GeometryNode * > nodes;
90
std::vector< GeometryEdge * > edges;
91
};
92
93
#endif /* MESH_LOOP_H */
94
95