DGtal 2.0.0
Loading...
Searching...
No Matches
DGtal::detail::GridPoint< Integer, Index > Class Template Reference

A grid point consists of a couple of nonnegative coordinates \( (x,y) \) and an integer index \( k \) that determines a point used as origin. For a triplet of vectors \( (m_k)_{0 \leq k \leq 2} \) and a point \( q \), a grid point is defined as: \( q - m_{k} + x m_{(k+1)\bmod 3} + y m_{(k+2)\bmod 3} \). \( q - m_{k} \), called base point, is used as origin. More...

#include <DGtal/geometry/helpers/PlaneProbingEstimatorHelper.h>

Inheritance diagram for DGtal::detail::GridPoint< Integer, Index >:
[legend]

Public Member Functions

 GridPoint ()=default
 GridPoint (std::pair< Integer, Integer > const &aDir, Index const &aK)
 GridPoint (Integer const &aX, Integer const &aY, Index const &aK)
std::pair< Integer, Integerdirection () const
Index k () const
template<typename Vector>
Vector directionVector (std::array< Vector, 3 > const &aM) const
template<typename Point>
Point relativePoint (std::array< Point, 3 > const &aM) const
bool operator== (GridPoint const &other) const
bool operator!= (GridPoint const &other) const
GridPoint getOnSameGrid (const std::pair< Integer, Integer > &aDir) const
GridPoint operator+ (const GridPoint &other) const
GridPoint operator* (Integer aValue) const
bool isValid () const

Private Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CInteger< Integer >))

Private Attributes

std::pair< Integer, IntegermyDir
Index myK

Detailed Description

template<typename Integer = int, typename Index = std::size_t>
class DGtal::detail::GridPoint< Integer, Index >

A grid point consists of a couple of nonnegative coordinates \( (x,y) \) and an integer index \( k \) that determines a point used as origin. For a triplet of vectors \( (m_k)_{0 \leq k \leq 2} \) and a point \( q \), a grid point is defined as: \( q - m_{k} + x m_{(k+1)\bmod 3} + y m_{(k+2)\bmod 3} \). \( q - m_{k} \), called base point, is used as origin.

Description of template class 'GridPoint'

This class is used to represent candidate points for the plane-probing L-algorithm. In practice, the point \( q \) is the fixed point and the three vectors \( (m_k)_{0 \leq k \leq 2} \) are the vectors defining the current probing frame.

Template Parameters
Integerthe integer type, model of concepts::CInteger.

Definition at line 238 of file PlaneProbingEstimatorHelper.h.

Constructor & Destructor Documentation

◆ GridPoint() [1/3]

template<typename Integer = int, typename Index = std::size_t>
DGtal::detail::GridPoint< Integer, Index >::GridPoint ( )
default

Default constructor.

Referenced by getOnSameGrid(), operator!=(), operator*(), operator+(), and operator==().

◆ GridPoint() [2/3]

template<typename Integer = int, typename Index = std::size_t>
DGtal::detail::GridPoint< Integer, Index >::GridPoint ( std::pair< Integer, Integer > const & aDir,
Index const & aK )
inline

Constructs a grid point from a couple of coordinates and the index of the point used as origin.

Parameters
aDira pair of nonnegative integers.
aKan index in {0,1,2}.

Definition at line 256 of file PlaneProbingEstimatorHelper.h.

256: myDir(aDir), myK(aK) {}
A grid point consists of a couple of nonnegative coordinates and an integer index that determines a...

References myDir, and myK.

◆ GridPoint() [3/3]

template<typename Integer = int, typename Index = std::size_t>
DGtal::detail::GridPoint< Integer, Index >::GridPoint ( Integer const & aX,
Integer const & aY,
Index const & aK )
inline

Constructs a grid point from a couple of coordinates and the index of the point used as origin.

Parameters
aXfirst coordinate.
aYsecond coordinate.
aKan index in {0,1,2}.

Definition at line 266 of file PlaneProbingEstimatorHelper.h.

References myDir, and myK.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename Integer = int, typename Index = std::size_t>
DGtal::detail::GridPoint< Integer, Index >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< Integer >) )
private

◆ direction()

template<typename Integer = int, typename Index = std::size_t>
std::pair< Integer, Integer > DGtal::detail::GridPoint< Integer, Index >::direction ( ) const
inline

Returns the couple of coordinates, i.e., the direction going from the origin to the grid point.

Returns
the direction.

Definition at line 275 of file PlaneProbingEstimatorHelper.h.

275 {
276 return myDir;
277 }

References myDir.

Referenced by DGtal::detail::operator<<().

◆ directionVector()

template<typename Integer = int, typename Index = std::size_t>
template<typename Vector>
Vector DGtal::detail::GridPoint< Integer, Index >::directionVector ( std::array< Vector, 3 > const & aM) const
inline

Returns the vector going from the base point to the geometric realization of this object.

Parameters
aMan array of three vectors.
Template Parameters
Vectora type for vectors.
Returns
the computed vector.

Definition at line 297 of file PlaneProbingEstimatorHelper.h.

297 {
298 return aM[(myK+1)%3]*myDir.first + aM[(myK+2)%3]*myDir.second;
299 }

References myDir, and myK.

Referenced by relativePoint().

◆ getOnSameGrid()

template<typename Integer = int, typename Index = std::size_t>
GridPoint DGtal::detail::GridPoint< Integer, Index >::getOnSameGrid ( const std::pair< Integer, Integer > & aDir) const
inline

Returns a grid point given a couple of coordinates.

Parameters
aDira couple of coordinates.
Returns
the resulting grid point.

Definition at line 340 of file PlaneProbingEstimatorHelper.h.

340 {
341 return GridPoint(aDir,myK);
342 }

References GridPoint(), and myK.

Referenced by operator*(), and operator+().

◆ isValid()

template<typename Integer = int, typename Index = std::size_t>
bool DGtal::detail::GridPoint< Integer, Index >::isValid ( ) const
inline

Checks whether the representation of the grid point is valid, i.e., the coordinates are nonnegative coordinates, not both equal to zero, and the index is in {0,1,2}.

Returns
'true' if valid, 'false' otherwise.

Definition at line 376 of file PlaneProbingEstimatorHelper.h.

376 {
377 if ( (myDir.first != 0) || (myDir.second != 0) ) { //not both null
378 return ( (myDir.first >= 0) && (myDir.second >= 0)
379 && (myK >= 0) && (myK <= 2)
380 );
381 } else {
382 return false;
383 }
384 }

References myDir, and myK.

◆ k()

template<typename Integer = int, typename Index = std::size_t>
Index DGtal::detail::GridPoint< Integer, Index >::k ( ) const
inline

Returns the index of the point used as origin.

Returns
the index.

Definition at line 284 of file PlaneProbingEstimatorHelper.h.

284 {
285 return myK;
286 }

References myK.

Referenced by DGtal::detail::operator<<().

◆ operator!=()

template<typename Integer = int, typename Index = std::size_t>
bool DGtal::detail::GridPoint< Integer, Index >::operator!= ( GridPoint< Integer, Index > const & other) const
inline

Tells whether this grid point is different from another or not.

Parameters
otheranother grid point.
Returns
'true' if different, i.e., not equal, 'false' otherwise.

Definition at line 330 of file PlaneProbingEstimatorHelper.h.

330 {
331 return !(*this == other);
332 }

References GridPoint().

◆ operator*()

template<typename Integer = int, typename Index = std::size_t>
GridPoint DGtal::detail::GridPoint< Integer, Index >::operator* ( Integer aValue) const
inline

Scales this grid point by a scalar (as if it was vector).

Parameters
aValuea scalar value
Returns
the resulting point.

Definition at line 363 of file PlaneProbingEstimatorHelper.h.

363 {
365 myDir.second*aValue);
366 return getOnSameGrid(d);
367 }
GridPoint getOnSameGrid(const std::pair< Integer, Integer > &aDir) const

References getOnSameGrid(), GridPoint(), and myDir.

◆ operator+()

template<typename Integer = int, typename Index = std::size_t>
GridPoint DGtal::detail::GridPoint< Integer, Index >::operator+ ( const GridPoint< Integer, Index > & other) const
inline

Adds a grid point to this one (as if they were vectors).

Parameters
otheranother grid point.
Returns
the resulting point.

Definition at line 350 of file PlaneProbingEstimatorHelper.h.

350 {
351 ASSERT(myK == other.myK);
353 myDir.second+other.myDir.second);
354 return getOnSameGrid(d);
355 }

References getOnSameGrid(), GridPoint(), myDir, and myK.

◆ operator==()

template<typename Integer = int, typename Index = std::size_t>
bool DGtal::detail::GridPoint< Integer, Index >::operator== ( GridPoint< Integer, Index > const & other) const
inline

Tells whether this grid point is equal to another or not. Two grid points are equal iff their members are equal.

Parameters
otheranother grid point.
Returns
'true' if equal, 'false' otherwise.

Definition at line 320 of file PlaneProbingEstimatorHelper.h.

320 {
321 return (myDir == other.myDir) && (myK == other.myK);
322 }

References GridPoint(), myDir, and myK.

◆ relativePoint()

template<typename Integer = int, typename Index = std::size_t>
template<typename Point>
Point DGtal::detail::GridPoint< Integer, Index >::relativePoint ( std::array< Point, 3 > const & aM) const
inline

Returns the geometric realization of this grid point.

Parameters
aMan array of three points.
Template Parameters
Pointa type for points.
Returns
the computed point.

Definition at line 309 of file PlaneProbingEstimatorHelper.h.

309 {
310 return -aM[myK] + directionVector(aM);
311 }
Vector directionVector(std::array< Vector, 3 > const &aM) const

References directionVector(), and myK.

Referenced by DGtal::detail::GridPointOnProbingRay< Integer, Index >::relativePoint().

Field Documentation

◆ myDir

template<typename Integer = int, typename Index = std::size_t>
std::pair<Integer,Integer> DGtal::detail::GridPoint< Integer, Index >::myDir
private

Couple of coordinates giving a direction

Definition at line 388 of file PlaneProbingEstimatorHelper.h.

Referenced by direction(), directionVector(), GridPoint(), GridPoint(), isValid(), operator*(), operator+(), and operator==().

◆ myK

template<typename Integer = int, typename Index = std::size_t>
Index DGtal::detail::GridPoint< Integer, Index >::myK
private

Index of a point used as origin

Definition at line 389 of file PlaneProbingEstimatorHelper.h.

Referenced by directionVector(), getOnSameGrid(), GridPoint(), GridPoint(), isValid(), k(), operator+(), operator==(), and relativePoint().


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