DGtal  1.5.beta
DGtal::detail::GridPoint< Integer > 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 >:
[legend]

Public Member Functions

 GridPoint ()=default
 
 GridPoint (std::pair< Integer, Integer > const &aDir, int aK)
 
 GridPoint (Integer aX, Integer aY, int aK)
 
std::pair< Integer, Integer > direction () const
 
int 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, Integer > myDir
 
int myK
 

Detailed Description

template<typename Integer = int>
class DGtal::detail::GridPoint< Integer >

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 240 of file PlaneProbingEstimatorHelper.h.

Constructor & Destructor Documentation

◆ GridPoint() [1/3]

template<typename Integer = int>
DGtal::detail::GridPoint< Integer >::GridPoint ( )
default

Default constructor.

Referenced by DGtal::detail::GridPoint< Integer >::getOnSameGrid().

◆ GridPoint() [2/3]

template<typename Integer = int>
DGtal::detail::GridPoint< Integer >::GridPoint ( std::pair< Integer, Integer > const &  aDir,
int  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 258 of file PlaneProbingEstimatorHelper.h.

258 : myDir(aDir), myK(aK) {}
std::pair< Integer, Integer > myDir

◆ GridPoint() [3/3]

template<typename Integer = int>
DGtal::detail::GridPoint< Integer >::GridPoint ( Integer  aX,
Integer  aY,
int  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 268 of file PlaneProbingEstimatorHelper.h.

268 : myDir(std::make_pair(aX,aY)), myK(aK) {}

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

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

◆ direction()

template<typename Integer = int>
std::pair<Integer,Integer> DGtal::detail::GridPoint< Integer >::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 277 of file PlaneProbingEstimatorHelper.h.

277  {
278  return myDir;
279  }

References DGtal::detail::GridPoint< Integer >::myDir.

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

◆ directionVector()

template<typename Integer = int>
template<typename Vector >
Vector DGtal::detail::GridPoint< Integer >::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 299 of file PlaneProbingEstimatorHelper.h.

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

References DGtal::detail::GridPoint< Integer >::myDir, and DGtal::detail::GridPoint< Integer >::myK.

Referenced by DGtal::detail::GridPoint< Integer >::relativePoint().

◆ getOnSameGrid()

template<typename Integer = int>
GridPoint DGtal::detail::GridPoint< Integer >::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 342 of file PlaneProbingEstimatorHelper.h.

342  {
343  return GridPoint(aDir,myK);
344  }

References DGtal::detail::GridPoint< Integer >::GridPoint(), and DGtal::detail::GridPoint< Integer >::myK.

Referenced by DGtal::detail::GridPointOnProbingRay< Integer >::gridPoint(), DGtal::detail::GridPoint< Integer >::operator*(), and DGtal::detail::GridPoint< Integer >::operator+().

◆ isValid()

template<typename Integer = int>
bool DGtal::detail::GridPoint< Integer >::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 378 of file PlaneProbingEstimatorHelper.h.

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

References DGtal::detail::GridPoint< Integer >::myDir, and DGtal::detail::GridPoint< Integer >::myK.

◆ k()

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

Returns the index of the point used as origin.

Returns
the index.

Definition at line 286 of file PlaneProbingEstimatorHelper.h.

286  {
287  return myK;
288  }

References DGtal::detail::GridPoint< Integer >::myK.

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

◆ operator!=()

template<typename Integer = int>
bool DGtal::detail::GridPoint< Integer >::operator!= ( GridPoint< Integer > 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 332 of file PlaneProbingEstimatorHelper.h.

332  {
333  return !(*this == other);
334  }

◆ operator*()

template<typename Integer = int>
GridPoint DGtal::detail::GridPoint< Integer >::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 365 of file PlaneProbingEstimatorHelper.h.

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

References DGtal::detail::GridPoint< Integer >::getOnSameGrid(), and DGtal::detail::GridPoint< Integer >::myDir.

◆ operator+()

template<typename Integer = int>
GridPoint DGtal::detail::GridPoint< Integer >::operator+ ( const GridPoint< Integer > &  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 352 of file PlaneProbingEstimatorHelper.h.

352  {
353  ASSERT(myK == other.myK);
354  std::pair<Integer,Integer> d = std::make_pair(myDir.first+other.myDir.first,
355  myDir.second+other.myDir.second);
356  return getOnSameGrid(d);
357  }

References DGtal::detail::GridPoint< Integer >::getOnSameGrid(), DGtal::detail::GridPoint< Integer >::myDir, and DGtal::detail::GridPoint< Integer >::myK.

◆ operator==()

template<typename Integer = int>
bool DGtal::detail::GridPoint< Integer >::operator== ( GridPoint< Integer > 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 322 of file PlaneProbingEstimatorHelper.h.

322  {
323  return (myDir == other.myDir) && (myK == other.myK);
324  }

References DGtal::detail::GridPoint< Integer >::myDir, and DGtal::detail::GridPoint< Integer >::myK.

◆ relativePoint()

template<typename Integer = int>
template<typename Point >
Point DGtal::detail::GridPoint< Integer >::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 311 of file PlaneProbingEstimatorHelper.h.

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

References DGtal::detail::GridPoint< Integer >::directionVector(), and DGtal::detail::GridPoint< Integer >::myK.

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

Field Documentation

◆ myDir

◆ myK


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