Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/meshgen2d/src/BGTriangleMesh.cpp
3196 views
1
#include "BGMesh.h"
2
#include "BGVertex.h"
3
#ifdef WIN32
4
#include <direct.h>
5
#else
6
#include <unistd.h>
7
#endif
8
#include <stdio.h>
9
10
void BGTriangleMesh::
11
initialize(std::vector< GeometryNode* >& nds, std::vector< GeometryEdge* >& eds)
12
{
13
initialized = true;
14
15
nodes = nds;
16
17
int i;
18
int len = nodes.size();
19
20
for( i = 0; i < len; ++i )
21
{
22
border.push_back( nodes[i] );
23
}
24
25
makeWorld();
26
27
len = border.size();
28
int *indirect = new int[len];
29
for( i = 0; i < len; ++i)
30
{
31
indirect[i] = i;
32
}
33
std::random_shuffle(indirect, indirect + len);
34
35
for( i = 0; i < len; ++i)
36
{
37
int ind = indirect[i];
38
Vertex *vtx = root->firstAcceptableFound( border[ind]->x, border[ind]->y);
39
addSite( vtx, border[ind], true );
40
GeometryNode *nd = static_cast<GeometryNode *>( border[ind] );
41
recycle();
42
}
43
44
delete [] indirect;
45
46
// We have to set deltas for the BGVertices and compute the interpolation parameters
47
std::list< Vertex* >::iterator vxIt;
48
for( vxIt = allVertices.begin(); vxIt != allVertices.end(); ++vxIt )
49
{
50
BGVertex *vtx = static_cast< BGVertex * >(*vxIt);
51
if( !(vtx->isDeleted()) )
52
{
53
vtx->initInterpolation( );
54
}
55
}
56
dump();
57
}
58
59
void BGTriangleMesh::
60
getVertices( std::vector< Vertex * >& v, const int count )
61
{
62
int i;
63
for( i = 0; i < count; ++i )
64
{
65
if( vertexStore.empty() ) break;
66
v.push_back( vertexStore.back() );
67
vertexStore.pop_back();
68
}
69
for( ; i < count; ++i )
70
{
71
BGVertex *vtx = new BGVertex;
72
v.push_back( vtx );
73
allVertices.push_back( vtx );
74
}
75
}
76
77
double BGTriangleMesh::
78
interpolate( const double ix, const double iy )
79
{
80
BGVertex *vtx = static_cast< BGVertex * >( root );
81
return vtx->interpolate( ix, iy );
82
}
83
84
void blm_error(const char* msg, const char *opt = "");
85
86
void BGTriangleMesh::
87
dump()
88
{
89
}
90
91