netgen/libsrc/csg/triapprox.cpp

60 lines
1.0 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#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 ()
{
2019-08-28 17:00:49 +05:00
NgBitArray used(GetNP());
2019-07-09 13:39:16 +05:00
NgArray<int> map (GetNP());
2009-01-13 04:40:13 +05:00
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);
}
}