Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/netgen/libsrc/csg/triapprox.cpp
3206 views
1
#include <mystdlib.h>
2
#include <myadt.hpp>
3
4
#include <linalg.hpp>
5
#include <csg.hpp>
6
7
8
namespace netgen
9
{
10
11
TriangleApproximation :: TriangleApproximation ()
12
{
13
;
14
}
15
16
int TriangleApproximation ::
17
AddTriangle (const TATriangle & tri, bool invert)
18
{
19
trigs.Append (tri);
20
if (invert)
21
{
22
trigs.Last()[1] = tri[2];
23
trigs.Last()[2] = tri[1];
24
}
25
return trigs.Size()-1;
26
}
27
28
29
void TriangleApproximation :: RemoveUnusedPoints ()
30
{
31
BitArray used(GetNP());
32
ARRAY<int> map (GetNP());
33
int i, j;
34
int cnt = 0;
35
36
used.Clear();
37
for (i = 0; i < GetNT(); i++)
38
for (j = 0; j < 3; j++)
39
used.Set (GetTriangle (i)[j]);
40
41
for (i = 0; i < GetNP(); i++)
42
if (used.Test(i))
43
map[i] = cnt++;
44
45
for (i = 0; i < GetNT(); i++)
46
for (j = 0; j < 3; j++)
47
trigs[i][j] = map[trigs[i][j]];
48
49
for (i = 0; i < GetNP(); i++)
50
if (used.Test(i))
51
{
52
points[map[i]] = points[i];
53
normals[map[i]] = normals[i];
54
}
55
56
points.SetSize (cnt);
57
normals.SetSize (cnt);
58
}
59
}
60
61