DGtal 1.4.0
|
Transform a point-dependent (and possibly domain-dependent) functor into a constant image. More...
#include <DGtal/images/ConstImageFunctorHolder.h>
Data Structures | |
class | ConstRange |
Constant range on a ConstImageFunctorHolder. More... | |
Public Types | |
using | Self = ConstImageFunctorHolder<TDomain, TValue, TFunctor> |
using | Domain = TDomain |
using | Point = typename Domain::Point |
using | Vector = typename Domain::Vector |
using | Integer = typename Domain::Integer |
using | Size = typename Domain::Size |
using | Dimension = typename Domain::Dimension |
using | Vertex = Point |
using | Value = TValue |
using | Functor = TFunctor |
using | ConstIterator = boost::transform_iterator< std::reference_wrapper<const Self>, typename Domain::ConstIterator > |
using | ConstReverseIterator = std::reverse_iterator< ConstIterator > |
Public Member Functions | |
BOOST_STATIC_CONSTANT (Dimension, dimension=Domain::Space::dimension) | |
template<class TGivenFunctor > | |
ConstImageFunctorHolder (Domain const &aDomain, TGivenFunctor &&aFunctor) | |
Constructor. | |
Domain const & | domain () const |
Returns the associated domain. | |
template<typename TPoint > | |
auto | operator() (TPoint const &aPoint) const -> decltype(myFunctor(aPoint)) |
Evaluates the functor at the given point. | |
template<typename TPoint > | |
auto | operator() (TPoint const &aPoint) const -> decltype(myFunctor(aPoint, myDomain)) |
ConstRange | constRange () const |
Returns a constant range over this image. | |
void | selfDisplay (std::ostream &out) const |
Writes/Displays the object on an output stream. | |
constexpr bool | isValid () const |
Checks the validity/consistency of the object. | |
Private Member Functions | |
BOOST_CONCEPT_ASSERT ((DGtal::concepts::CDomain< TDomain >)) | |
Private Attributes | |
Domain | myDomain |
The image domain. | |
Functor | myFunctor |
The functor that generates the image. | |
Transform a point-dependent (and possibly domain-dependent) functor into a constant image.
TDomain | Domain type. |
TValue | Value type returned by the functor. |
TFunctor | Type of the functor. |
The functor must accept a point, and eventually a domain, and return a value whose type is Value.
A typical usage would be:
resulting in:
In you want to use a function instead of a functor or lambda, consider wrapping it into a lambda to avoid a performance penalty due to the fact that a pointer to a function cannot be inlined:
This example is illustrated in Constant image from a function, functor or lambda and you can find more informations about how to use this class appropriately in the module about Using functions, functors and lambdas in DGtal .
Definition at line 103 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstIterator = boost::transform_iterator< std::reference_wrapper<const Self>, typename Domain::ConstIterator > |
Definition at line 122 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstReverseIterator = std::reverse_iterator< ConstIterator > |
Definition at line 123 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Dimension = typename Domain::Dimension |
Definition at line 117 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Domain = TDomain |
Definition at line 112 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Functor = TFunctor |
Definition at line 120 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Integer = typename Domain::Integer |
Definition at line 115 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Point = typename Domain::Point |
Definition at line 113 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Self = ConstImageFunctorHolder<TDomain, TValue, TFunctor> |
Definition at line 111 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Size = typename Domain::Size |
Definition at line 116 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Value = TValue |
Definition at line 119 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Vector = typename Domain::Vector |
Definition at line 114 of file ConstImageFunctorHolder.h.
using DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::Vertex = Point |
Definition at line 118 of file ConstImageFunctorHolder.h.
|
inlineexplicit |
Constructor.
aDomain | The domain of the image. |
aFunctor | The functor taking point as parameter. |
Definition at line 143 of file ConstImageFunctorHolder.h.
|
private |
DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::BOOST_STATIC_CONSTANT | ( | Dimension | , |
dimension | = Domain::Space::dimension ) |
|
inline |
Returns a constant range over this image.
Definition at line 197 of file ConstImageFunctorHolder.h.
|
inline |
Returns the associated domain.
Definition at line 154 of file ConstImageFunctorHolder.h.
References DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::myDomain.
|
inlineconstexpr |
Checks the validity/consistency of the object.
Definition at line 215 of file ConstImageFunctorHolder.h.
|
inline |
Evaluates the functor at the given point.
TPoint | point type (auto-deduced). |
aPoint | the point. |
Definition at line 170 of file ConstImageFunctorHolder.h.
References aPoint(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::myDomain, and DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::myFunctor.
|
inline |
Definition at line 182 of file ConstImageFunctorHolder.h.
References aPoint(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::myDomain, and DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::myFunctor.
|
inline |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 206 of file ConstImageFunctorHolder.h.
References DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::myDomain, and DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::myFunctor.
|
private |
The image domain.
Definition at line 132 of file ConstImageFunctorHolder.h.
Referenced by DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstRange::begin(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstRange::begin(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::domain(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstRange::end(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::operator()(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::operator()(), and DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::selfDisplay().
|
private |
The functor that generates the image.
Definition at line 133 of file ConstImageFunctorHolder.h.
Referenced by DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::operator()(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::operator()(), and DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::selfDisplay().