File: triapprox.cpp

package info (click to toggle)
netgen 6.2.2601%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,076 kB
  • sloc: cpp: 166,627; tcl: 6,310; python: 2,868; sh: 528; makefile: 90
file content (59 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#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 ()
  {
    NgBitArray 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);
  }
}