8 #ifndef META_OCEAN_CV_SEGMENTATION_TRIANGULATION_H
9 #define META_OCEAN_CV_SEGMENTATION_TRIANGULATION_H
27 namespace Segmentation
56 inline IndexTriangle(
const unsigned int first,
const unsigned int second,
const unsigned int third);
62 inline bool isValid()
const;
69 inline unsigned int operator[](
const unsigned int index)
const;
74 unsigned int indices_[3];
105 template <
typename T>
115 template <
typename T>
116 static inline std::vector<Advanced::PixelTriangleT<T>> triangulation2triangles(
const std::vector<
PixelPositionT<T>>& coordinates,
const IndexTriangles& triangulation);
129 indices_[1] = second;
135 return indices_[0] != indices_[1] && indices_[0] != indices_[2] && indices_[1] != indices_[2];
140 ocean_assert(index < 3u);
141 return indices_[index];
144 template <
typename T>
148 result.reserve(triangulation.size());
150 for (IndexTriangles::const_iterator i = triangulation.begin(); i != triangulation.end(); ++i)
152 ocean_assert((*i)[0] < coordinates.size());
153 ocean_assert((*i)[1] < coordinates.size());
154 ocean_assert((*i)[2] < coordinates.size());
This class implements a 2D triangle with pixel precision.
Definition: PixelTriangle.h:70
This class implements a 2D pixel position with pixel precision.
Definition: PixelPosition.h:65
This class implements a contour with pixel accuracy.
Definition: PixelContour.h:70
This class holds coordinate index of a triangle.
Definition: Triangulation.h:42
unsigned int operator[](const unsigned int index) const
Returns the coordinate indices for the triangle.
Definition: Triangulation.h:138
bool isValid() const
Returns whether this object is valid, which means that all three coordinate indices are different.
Definition: Triangulation.h:133
IndexTriangle()
Creates a new index triangle object with invalid indices.
Definition: Triangulation.h:119
unsigned int indices_[3]
The three coordinate indices of the triangle.
Definition: Triangulation.h:74
This class implements functions allowing for triangulation.
Definition: Triangulation.h:35
static std::vector< Advanced::PixelTriangleT< T > > triangulation2triangles(const std::vector< PixelPositionT< T >> &coordinates, const IndexTriangles &triangulation)
Converts a given set of pixel coordinates and a corresponding triangulation into triangle objects.
Definition: Triangulation.h:145
std::vector< IndexTriangle > IndexTriangles
Definition of a vector holding index triangle objects.
Definition: Triangulation.h:80
std::pair< unsigned int, bool > PixelPositionPair
Definition of a pair combining a pixel position index and a boolean state.
Definition: Triangulation.h:87
static IndexTriangles triangulate(const PixelContourT< T > &pixelContour, const bool forceTriangulation=false, bool *triangulationForced=nullptr)
Triangulates a given (sparse or dense) contour.
std::vector< PixelPositionPair > PixelPositionPairs
Definition of a vector holding pixel position pairs.
Definition: Triangulation.h:92
std::vector< PixelTriangle > PixelTriangles
Definition of a vector holding pixel triangles (with positive coordinate values).
Definition: PixelTriangle.h:53
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15