31#if defined(TangencyComputer_RECURSES)
32#error Recursive header files inclusion detected in TangencyComputer.h
35#define TangencyComputer_RECURSES
37#if !defined TangencyComputer_h
39#define TangencyComputer_h
47#include <unordered_set>
48#include "DGtal/base/Common.h"
49#include "DGtal/base/Clone.h"
50#include "DGtal/kernel/domains/HyperRectDomain.h"
51#include "DGtal/topology/CCellularGridSpaceND.h"
52#include "DGtal/kernel/LatticeSetByIntervals.h"
53#include "DGtal/geometry/volumes/CellGeometry.h"
54#include "DGtal/geometry/volumes/DigitalConvexity.h"
72 template <
typename TKSpace >
86 typedef std::vector< Index >
Path;
97 typedef std::tuple< Index, Index, double >
Node;
108 const Node& p2 )
const
110 return std::get<2>( p1 ) > std::get<2>( p2 );
174 const auto nb =
size();
176 myDistance = std::vector< double >( nb, std::numeric_limits<double>::infinity() );
177 myVisited = std::vector< bool > ( nb,
false );
178 myQ = std::priority_queue< Node, std::vector< Node >,
Comparator >();
186 ASSERT( i <
size() );
187 myQ.push( std::make_tuple( i, i, 0.0 ) );
199 template <
typename IndexFwdIterator >
200 void init( IndexFwdIterator it, IndexFwdIterator itE )
202 for ( ; it != itE; ++it )
205 ASSERT( i <
size() );
206 myQ.push( std::make_tuple( i, i, 0.0 ) );
208 const auto elem =
myQ.top();
209 const auto i = std::get<0>( elem );
251 ASSERT( i <
size() );
263 ASSERT( i <
size() );
275 ASSERT( i <
size() );
292 return std::numeric_limits<double>::infinity();
412 template <
typename Po
intIterator >
413 void init( PointIterator itB, PointIterator itE,
414 bool use_lattice_cell_cover =
false );
429 {
return myX.size(); }
432 const std::vector< Point >&
points()
const
462 auto eucl_d = [] (
const Point& p,
const Point& q )
463 {
return ( p - q ).norm(); };
465 for (
auto i = 1; i < path.size(); i++ )
466 l += eucl_d(
point( path[ i-1 ] ),
point( path[ i ] ) );
505 const std::vector< bool > & to_avoid )
const;
559 const std::vector< Index >& targets,
561 bool verbose =
false )
const;
591 bool verbose =
false )
const;
603 std::vector< Vector >
myN;
642 template <
typename TKSpace>
654#include "TangencyComputer.ih"
661#undef TangencyComputer_RECURSES
Aim: This class encapsulates its parameter class to indicate that the given parameter is required to ...
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
static const constexpr Dimension dimension
Aim: A class that computes tangency to a given digital set. It provides services to compute all the c...
KSpace myK
The cellular grid space where computations are done.
const LatticeCellCover & latticeCellCover() const
LatticeCellCover myLatticeCellCover
std::vector< Vector > myN
The vector of all vectors to neighbors (8 in 2D, 26 in 3D, etc).
TangencyComputer(Self &&other)=default
DigitalConvexity< KSpace > myDConv
The digital convexity object used to check full convexity.
const KSpace & space() const
void setUp()
Precomputes some neighborhood tables at construction.
Size index(const Point &a) const
bool arePointsCotangent(const Point &a, const Point &b, const Point &c) const
bool myUseLatticeCellCover
Tells if one must use CellCover or LatticeCellCover for computations.
std::unordered_map< Point, Index > myPt2Index
A map giving for each point its index.
TangencyComputer< TKSpace > Self
const std::vector< Point > & points() const
HyperRectDomain< Space > Domain
std::vector< Index > Path
LatticeSetByIntervals< Space > LatticeCellCover
double length(const Path &path) const
std::vector< Index > getCotangentPoints(const Point &a) const
bool arePointsCotangent(const Point &a, const Point &b) const
std::vector< double > myDN
TangencyComputer(const Self &other)=default
TangencyComputer(Clone< KSpace > aK)
Self & operator=(const Self &other)=default
std::vector< Point > myX
The vector of points defining the digital shape under study.
const Point & point(Index i) const
const CellCover & cellCover() const
ShortestPaths makeShortestPaths(double secure=sqrt(KSpace::dimension)) const
Path shortestPath(Index source, Index target, double secure=sqrt(KSpace::dimension), bool verbose=false) const
CellGeometry< KSpace > CellCover
std::vector< Path > shortestPaths(const std::vector< Index > &sources, const std::vector< Index > &targets, double secure=sqrt(KSpace::dimension), bool verbose=false) const
Self & operator=(Self &&other)=default
BOOST_CONCEPT_ASSERT((concepts::CCellularGridSpaceND< TKSpace >))
std::vector< Index > getCotangentPoints(const Point &a, const std::vector< bool > &to_avoid) const
TangencyComputer()=default
Constructor. The object is invalid.
void init(PointIterator itB, PointIterator itE, bool use_lattice_cell_cover=false)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
bool operator()(const Node &p1, const Node &p2) const
Index ancestor(Index i) const
std::priority_queue< Node, std::vector< Node >, Comparator > myQ
The queue of points being currently processed.
std::vector< Index > getCotangentPoints(Index i) const
const Node & current() const
ShortestPaths(ShortestPaths &&other)=default
std::vector< bool > myVisited
Remembers for each point if it is already visited.
const TangencyComputer * tangencyComputerPtr() const
const std::vector< bool > & visitedPoints() const
std::vector< Index > myAncestor
ShortestPaths(const ShortestPaths &other)=default
const std::vector< Index > & ancestors() const
bool isVisited(Index i) const
ShortestPaths & operator=(const ShortestPaths &other)=default
ShortestPaths(ConstAlias< TangencyComputer > tgcy_computer, double secure=sqrt(KSpace::dimension))
ShortestPaths & operator=(ShortestPaths &&other)=default
void propagate(Index current)
Path pathToSource(Index i) const
double distance(Index i) const
ShortestPaths()
Default constructor. The object is not valid.
void init(IndexFwdIterator it, IndexFwdIterator itE)
std::vector< double > myDistance
Stores for each point its distance to the closest source.
const Point & point(Index i) const
const std::vector< double > & distances() const
const TangencyComputer * myTgcyComputer
A pointer toward the tangency computer.
std::tuple< Index, Index, double > Node
Type used for Dijkstra's algorithm queue (point, ancestor, distance).
Aim: This concept describes a cellular grid space in nD. In these spaces obtained by cartesian produc...