mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-12 00:59:16 +05:00
60 lines
1.0 KiB
C++
60 lines
1.0 KiB
C++
#include <mystdlib.h>
|
|
#include <myadt.hpp>
|
|
|
|
#include <linalg.hpp>
|
|
#include <csg.hpp>
|
|
|
|
|
|
namespace netgen
|
|
{
|
|
|
|
TriangleApproximation :: TriangleApproximation ()
|
|
{
|
|
;
|
|
}
|
|
|
|
int TriangleApproximation ::
|
|
AddTriangle (const TATriangle & tri, bool invert)
|
|
{
|
|
trigs.Append (tri);
|
|
if (invert)
|
|
{
|
|
trigs.Last()[1] = tri[2];
|
|
trigs.Last()[2] = tri[1];
|
|
}
|
|
return trigs.Size()-1;
|
|
}
|
|
|
|
|
|
void TriangleApproximation :: RemoveUnusedPoints ()
|
|
{
|
|
BitArray used(GetNP());
|
|
NgArray<int> map (GetNP());
|
|
int i, j;
|
|
int cnt = 0;
|
|
|
|
used.Clear();
|
|
for (i = 0; i < GetNT(); i++)
|
|
for (j = 0; j < 3; j++)
|
|
used.Set (GetTriangle (i)[j]);
|
|
|
|
for (i = 0; i < GetNP(); i++)
|
|
if (used.Test(i))
|
|
map[i] = cnt++;
|
|
|
|
for (i = 0; i < GetNT(); i++)
|
|
for (j = 0; j < 3; j++)
|
|
trigs[i][j] = map[trigs[i][j]];
|
|
|
|
for (i = 0; i < GetNP(); i++)
|
|
if (used.Test(i))
|
|
{
|
|
points[map[i]] = points[i];
|
|
normals[map[i]] = normals[i];
|
|
}
|
|
|
|
points.SetSize (cnt);
|
|
normals.SetSize (cnt);
|
|
}
|
|
}
|