OGS
GeoLib::Triangle Class Referencefinal

Detailed Description

Class Triangle consists of a reference to a point vector and a vector that stores the indices in the point vector. A surface is composed by triangles. The class Surface stores the position of pointers to the points of triangles in the _pnt_ids vector.

Definition at line 26 of file Triangle.h.

#include <Triangle.h>

Public Member Functions

 Triangle (std::vector< Point * > const &pnt_vec, std::size_t pnt_a, std::size_t pnt_b, std::size_t pnt_c)
 
const std::size_t & operator[] (std::size_t i) const
 const access operator to access the index of the i-th triangle point
 
const PointgetPoint (std::size_t i) const
 const access operator to access the i-th triangle Point
 
bool containsPoint (MathLib::Point3d const &q, double eps=std::numeric_limits< float >::epsilon()) const
 

Private Attributes

std::vector< Point * > const & _pnts
 a vector of pointers to points the triangle is based on
 
std::array< std::size_t, 3 > _pnt_ids
 position of pointers to the geometric points
 

Constructor & Destructor Documentation

◆ Triangle()

GeoLib::Triangle::Triangle ( std::vector< Point * > const & pnt_vec,
std::size_t pnt_a,
std::size_t pnt_b,
std::size_t pnt_c )

construction of object, initialization of reference to point vector, saves the three indices describing a triangle

Definition at line 20 of file Triangle.cpp.

22 : _pnts(pnt_vec), _pnt_ids({{pnt_a, pnt_b, pnt_c}})
23{
24 assert(!_pnts.empty());
25 assert(pnt_a < _pnts.size() && pnt_b < _pnts.size() &&
26 pnt_c < _pnts.size());
27}
std::array< std::size_t, 3 > _pnt_ids
position of pointers to the geometric points
Definition Triangle.h:71
std::vector< Point * > const & _pnts
a vector of pointers to points the triangle is based on
Definition Triangle.h:69

Member Function Documentation

◆ containsPoint()

bool GeoLib::Triangle::containsPoint ( MathLib::Point3d const & q,
double eps = std::numeric_limits<float>::epsilon() ) const

Checks if point q is within the triangle, uses GeoLib::isPointInTriangle().

Parameters
qThe input point.
epsChecks the 'epsilon'-neighbourhood
Returns
true, if point is in triangle, else false

Definition at line 29 of file Triangle.cpp.

30{
31 GeoLib::Point const& a(*(_pnts[_pnt_ids[0]]));
32 GeoLib::Point const& b(*(_pnts[_pnt_ids[1]]));
33 GeoLib::Point const& c(*(_pnts[_pnt_ids[2]]));
34 return MathLib::isPointInTriangle(q, a, b, c, eps);
35}
bool isPointInTriangle(MathLib::Point3d const &p, MathLib::Point3d const &a, MathLib::Point3d const &b, MathLib::Point3d const &c, double eps_pnt_out_of_plane, double eps_pnt_out_of_tri, MathLib::TriangleTest algorithm)

References _pnt_ids, _pnts, and MathLib::isPointInTriangle().

◆ getPoint()

const Point * GeoLib::Triangle::getPoint ( std::size_t i) const
inline

const access operator to access the i-th triangle Point

Definition at line 50 of file Triangle.h.

51 {
52 assert(i < 3);
53 return _pnts[_pnt_ids[i]];
54 }

References _pnt_ids, and _pnts.

Referenced by GeoLib::DuplicateGeometry::copySurfacesVector(), GeoLib::SurfaceGrid::sortTriangleInGridCells(), and GeoLib::IO::TINInterface::writeSurfaceAsTIN().

◆ operator[]()

const std::size_t & GeoLib::Triangle::operator[] ( std::size_t i) const
inline

const access operator to access the index of the i-th triangle point

Definition at line 41 of file Triangle.h.

42 {
43 assert(i < 3);
44 return _pnt_ids[i];
45 }

References _pnt_ids.

Member Data Documentation

◆ _pnt_ids

std::array<std::size_t, 3> GeoLib::Triangle::_pnt_ids
private

position of pointers to the geometric points

Definition at line 71 of file Triangle.h.

Referenced by containsPoint(), getPoint(), and operator[]().

◆ _pnts

std::vector<Point*> const& GeoLib::Triangle::_pnts
private

a vector of pointers to points the triangle is based on

Definition at line 69 of file Triangle.h.

Referenced by containsPoint(), and getPoint().


The documentation for this class was generated from the following files: