OGS
Triangle.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <vector>
7
8#include "MathLib/Point3d.h"
9
10namespace GeoLib
11{
12
13class Point;
14
20class Triangle final
21{
22public:
27 Triangle(std::vector<Point*> const& pnt_vec,
28 std::size_t pnt_a,
29 std::size_t pnt_b,
30 std::size_t pnt_c);
31
35 const std::size_t& operator[](std::size_t i) const
36 {
37 assert(i < 3);
38 return _pnt_ids[i];
39 }
40
44 const Point* getPoint(std::size_t i) const
45 {
46 assert(i < 3);
47 return _pnts[_pnt_ids[i]];
48 }
49
57 bool containsPoint(
58 MathLib::Point3d const& q,
59 double eps = std::numeric_limits<float>::epsilon()) const;
60
61private:
63 std::vector<Point*> const& _pnts;
65 std::array<std::size_t, 3> _pnt_ids;
66};
67} // namespace GeoLib
const Point * getPoint(std::size_t i) const
const access operator to access the i-th triangle Point
Definition Triangle.h:44
bool containsPoint(MathLib::Point3d const &q, double eps=std::numeric_limits< float >::epsilon()) const
Definition Triangle.cpp:23
Triangle(std::vector< Point * > const &pnt_vec, std::size_t pnt_a, std::size_t pnt_b, std::size_t pnt_c)
Definition Triangle.cpp:14
const std::size_t & operator[](std::size_t i) const
const access operator to access the index of the i-th triangle point
Definition Triangle.h:35
std::array< std::size_t, 3 > _pnt_ids
position of pointers to the geometric points
Definition Triangle.h:65
std::vector< Point * > const & _pnts
a vector of pointers to points the triangle is based on
Definition Triangle.h:63