netgen/libsrc/csg/triapprox.hpp

64 lines
1.7 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef FILE_TRIAPPROX
#define FILE_TRIAPPROX
/**************************************************************************/
/* File: triapprox.hh */
/* Author: Joachim Schoeberl */
/* Date: 2. Mar. 98 */
/**************************************************************************/
2009-09-07 17:50:13 +06:00
namespace netgen
2009-01-13 04:40:13 +05:00
{
2009-09-07 17:50:13 +06:00
/**
Triangulated approxiamtion to true surface
*/
class TATriangle
{
int pi[3];
int surfind;
public:
TATriangle () { ; }
TATriangle (int si, int pi1, int pi2, int pi3)
2009-01-13 04:40:13 +05:00
{ surfind = si; pi[0] = pi1; pi[1] = pi2; pi[2] = pi3; }
2009-09-07 17:50:13 +06:00
int SurfaceIndex() const { return surfind; }
int & SurfaceIndex() { return surfind; }
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
int & operator[] (int i) { return pi[i]; }
const int & operator[] (int i) const { return pi[i]; }
};
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
class TriangleApproximation
{
Array<Point<3> > points;
Array<Vec<3> > normals;
Array<TATriangle> trigs;
public:
TriangleApproximation();
int GetNP () const { return points.Size(); }
int GetNT () const { return trigs.Size(); }
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
int AddPoint (const Point<3> & p) { points.Append (p); return points.Size()-1; }
int AddNormal (const Vec<3> & n) { normals.Append (n); return normals.Size()-1; }
int AddTriangle (const TATriangle & tri, bool invert = 0);
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
const Point<3> & GetPoint (int i) const { return points[i]; }
const TATriangle & GetTriangle (int i) const { return trigs[i]; }
const Vec<3> & GetNormal (int i) const { return normals[i]; }
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
void RemoveUnusedPoints ();
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
friend class CSGeometry;
};
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
}
2009-01-13 04:40:13 +05:00
#endif