DGtal  1.3.beta
Data Structures | Public Types | Public Member Functions | Data Fields | Private Member Functions | Private Attributes
DGtal::HyperRectDomain< TSpace > Class Template Reference

Aim: Parallelepidec region of a digital space, model of a 'CDomain'. More...

#include <DGtal/kernel/domains/HyperRectDomain.h>

Inheritance diagram for DGtal::HyperRectDomain< TSpace >:
[legend]

Data Structures

struct  ConstSubRange
 Aim: range through some subdomain of all the points in the domain. Defines a constructor taking a domain in parameter plus some additional parameters to specify the subdomain, begin and end methods returning ConstIterator, and rbegin and rend methods returning ConstReverseIterator. More...
 

Public Types

typedef HyperRectDomain< TSpace > Self
 
typedef TSpace Space
 
typedef HyperRectDomain< SpaceDomain
 
typedef Space::Point Point
 
typedef Space::Integer Integer
 
typedef Space::Vector Vector
 
typedef Space::Dimension Dimension
 
typedef Space::Size Size
 
typedef Point::Coordinate Coordinate
 
typedef HyperRectDomain_Iterator< PointIterator
 Typedef of domain iterators. More...
 
typedef HyperRectDomain_ReverseIterator< IteratorReverseIterator
 
typedef Iterator ConstIterator
 
typedef ReverseIterator ConstReverseIterator
 
typedef functors::IsWithinPointPredicate< PointPredicate
 

Public Member Functions

 BOOST_STATIC_CONSTANT (Dimension, dimension=Space::dimension)
 
 HyperRectDomain ()
 
 HyperRectDomain (const Point &lowerPoint, const Point &upperPoint)
 
 HyperRectDomain (const typename Space::RealPoint &lowerPoint, const typename Space::RealPoint &upperPoint)
 
 ~HyperRectDomain ()
 
 HyperRectDomain (const HyperRectDomain &other)
 
HyperRectDomainoperator= (const HyperRectDomain &other)
 
const ConstIteratorbegin () const
 
ConstIterator begin (const Point &aPoint) const
 
const ConstIteratorend () const
 
ConstReverseIterator rbegin () const
 
ConstReverseIterator rbegin (const Point &aPoint) const
 
ConstReverseIterator rend () const
 
ConstSubRange subRange (const std::vector< Dimension > &permutation) const
 
ConstSubRange subRange (const std::vector< Dimension > &permutation, const Point &startingPoint) const
 
ConstSubRange subRange (Dimension adim, const Point &startingPoint) const
 
ConstSubRange subRange (Dimension adim1, Dimension adim2, const Point &startingPoint) const
 
ConstSubRange subRange (Dimension adim1, Dimension adim2, Dimension adim3, const Point &startingPoint) const
 
ConstSubRange subRange (std::initializer_list< Dimension > permutation)
 
ConstSubRange subRange (std::initializer_list< Dimension > permutation, const Point &startingPoint)
 
Size size () const
 
const PointlowerBound () const
 
const PointupperBound () const
 
bool isInside (const Point &p) const
 
bool isEmpty () const
 
const Predicatepredicate () const
 
std::string className () const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Data Fields

Point myLowerBound
 The lowest point of the space diagonal. More...
 
Point myUpperBound
 The highest point of the space diagonal. More...
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >))
 

Private Attributes

Predicate myPredicate
 "IsInside" predicate. More...
 
ConstIterator myIteratorBegin
 Begin iterator. More...
 
ConstIterator myIteratorEnd
 End iterator. More...
 

Detailed Description

template<typename TSpace>
class DGtal::HyperRectDomain< TSpace >

Aim: Parallelepidec region of a digital space, model of a 'CDomain'.

Description of class 'HyperRectDomain'

The following code snippet demonstrates how to use HyperRectDomain

#include <DGtal/kernel/Space.h>
#include <DGtal/kernel/domains/HyperRectDomain.h>
...
//We create a digital Space based on 'int' integers and in dimension 4
typedef DGtal::Space<4> Space4D;
typedef Space4D::TPoint Point4D;
const int rawA[ ] = { 1, 2, 3 ,4};
const int rawB[ ] = { 5, 5, 3 ,4};
Point4D A ( rawA );
Point4D B ( rawB );
//Domain construction from two points
//We iterate on the Domain points and print out the point coordinates.
std::copy ( myDomain.begin(),
myDomain.end(),
std::ostream_iterator<Point4D> ( std::cout, " " ) );

More informations can be found in the module page about Digital Spaces, Points, Vectors and Domains .

Note
Since DGtal 1.1, HyperRectDomain provides random-access iterators. It can be use to easily split the domain, for example for parallelization purpose. See the dedicated section Scanning an HyperRectDomain in parallel and the example file (and benchmark) exampleHyperRectDomainParallelScan.cpp .
See also
testHyperRectDomain.cpp
Examples
doc-examples/demo-kernel-1.cpp, doc-examples/kernelDomain.cpp, doc-examples/range.cpp, geometry/tools/determinant/exampleInHalfPlane.cpp, io/viewers/demo-kernel-2.cpp, and topology/3dBorderExtraction.cpp.

Definition at line 99 of file HyperRectDomain.h.

Member Typedef Documentation

◆ ConstIterator

template<typename TSpace >
typedef Iterator DGtal::HyperRectDomain< TSpace >::ConstIterator

Definition at line 125 of file HyperRectDomain.h.

◆ ConstReverseIterator

template<typename TSpace >
typedef ReverseIterator DGtal::HyperRectDomain< TSpace >::ConstReverseIterator

Definition at line 126 of file HyperRectDomain.h.

◆ Coordinate

template<typename TSpace >
typedef Point::Coordinate DGtal::HyperRectDomain< TSpace >::Coordinate

Definition at line 118 of file HyperRectDomain.h.

◆ Dimension

template<typename TSpace >
typedef Space::Dimension DGtal::HyperRectDomain< TSpace >::Dimension

Definition at line 116 of file HyperRectDomain.h.

◆ Domain

template<typename TSpace >
typedef HyperRectDomain<Space> DGtal::HyperRectDomain< TSpace >::Domain

Definition at line 112 of file HyperRectDomain.h.

◆ Integer

template<typename TSpace >
typedef Space::Integer DGtal::HyperRectDomain< TSpace >::Integer

Definition at line 114 of file HyperRectDomain.h.

◆ Iterator

template<typename TSpace >
typedef HyperRectDomain_Iterator<Point> DGtal::HyperRectDomain< TSpace >::Iterator

Typedef of domain iterators.

Definition at line 123 of file HyperRectDomain.h.

◆ Point

template<typename TSpace >
typedef Space::Point DGtal::HyperRectDomain< TSpace >::Point

Definition at line 113 of file HyperRectDomain.h.

◆ Predicate

template<typename TSpace >
typedef functors::IsWithinPointPredicate<Point> DGtal::HyperRectDomain< TSpace >::Predicate

Definition at line 128 of file HyperRectDomain.h.

◆ ReverseIterator

template<typename TSpace >
typedef HyperRectDomain_ReverseIterator<Iterator> DGtal::HyperRectDomain< TSpace >::ReverseIterator

Definition at line 124 of file HyperRectDomain.h.

◆ Self

template<typename TSpace >
typedef HyperRectDomain<TSpace> DGtal::HyperRectDomain< TSpace >::Self

Definition at line 106 of file HyperRectDomain.h.

◆ Size

template<typename TSpace >
typedef Space::Size DGtal::HyperRectDomain< TSpace >::Size

Definition at line 117 of file HyperRectDomain.h.

◆ Space

template<typename TSpace >
typedef TSpace DGtal::HyperRectDomain< TSpace >::Space

Definition at line 110 of file HyperRectDomain.h.

◆ Vector

template<typename TSpace >
typedef Space::Vector DGtal::HyperRectDomain< TSpace >::Vector

Definition at line 115 of file HyperRectDomain.h.

Constructor & Destructor Documentation

◆ HyperRectDomain() [1/4]

template<typename TSpace >
DGtal::HyperRectDomain< TSpace >::HyperRectDomain ( )

Default Constructor.

◆ HyperRectDomain() [2/4]

template<typename TSpace >
DGtal::HyperRectDomain< TSpace >::HyperRectDomain ( const Point lowerPoint,
const Point upperPoint 
)

Constructor from two points

Parameters
lowerPointand
upperPointdefining the space diagonal.

◆ HyperRectDomain() [3/4]

template<typename TSpace >
DGtal::HyperRectDomain< TSpace >::HyperRectDomain ( const typename Space::RealPoint lowerPoint,
const typename Space::RealPoint upperPoint 
)

Constructor from two points

Parameters
lowerPointand
upperPointwith real coordinates and that define the space diagonal.

The domain actualy defined is the smallest domain with integer bounds that contains the two given points.

◆ ~HyperRectDomain()

template<typename TSpace >
DGtal::HyperRectDomain< TSpace >::~HyperRectDomain ( )

Destructor.

◆ HyperRectDomain() [4/4]

template<typename TSpace >
DGtal::HyperRectDomain< TSpace >::HyperRectDomain ( const HyperRectDomain< TSpace > &  other)

Copy constructor.

Parameters
otherthe object to clone. Forbidden by default.

Member Function Documentation

◆ begin() [1/2]

template<typename TSpace >
const ConstIterator& DGtal::HyperRectDomain< TSpace >::begin ( ) const
inline

◆ begin() [2/2]

template<typename TSpace >
ConstIterator DGtal::HyperRectDomain< TSpace >::begin ( const Point aPoint) const
inline

begin method from a given point.

Parameters
aPointthe initial point.
Returns
a ConstIterator initialized to aPoint.
Precondition
aPoint must belong to the range.

Definition at line 187 of file HyperRectDomain.h.

188  {
189  ASSERT_MSG(
191  "The point must be inside the domain or be equal to one of his bound."
192  );
193 
195  }

◆ BOOST_CONCEPT_ASSERT()

template<typename TSpace >
DGtal::HyperRectDomain< TSpace >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >)  )
private

◆ BOOST_STATIC_CONSTANT()

template<typename TSpace >
DGtal::HyperRectDomain< TSpace >::BOOST_STATIC_CONSTANT ( Dimension  ,
dimension  = Space::dimension 
)

◆ className()

template<typename TSpace >
std::string DGtal::HyperRectDomain< TSpace >::className ( ) const

◆ end()

template<typename TSpace >
const ConstIterator& DGtal::HyperRectDomain< TSpace >::end ( ) const
inline

◆ isEmpty()

template<typename TSpace >
bool DGtal::HyperRectDomain< TSpace >::isEmpty ( ) const
Returns
true if the domain is empty.

Referenced by TEST_CASE().

◆ isInside()

template<typename TSpace >
bool DGtal::HyperRectDomain< TSpace >::isInside ( const Point p) const
Parameters
pany point.
Returns
'true' if point [p] is inside this domain.

Referenced by DGtal::HyperRectDomain< Space >::begin(), main(), and DGtal::HyperRectDomain< Space >::rbegin().

◆ isValid()

template<typename TSpace >
bool DGtal::HyperRectDomain< TSpace >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Referenced by TEST_CASE().

◆ lowerBound()

template<typename TSpace >
const Point& DGtal::HyperRectDomain< TSpace >::lowerBound ( ) const

◆ operator=()

template<typename TSpace >
HyperRectDomain& DGtal::HyperRectDomain< TSpace >::operator= ( const HyperRectDomain< TSpace > &  other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'. Forbidden by default.

◆ predicate()

template<typename TSpace >
const Predicate& DGtal::HyperRectDomain< TSpace >::predicate ( ) const
Returns
a const reference to the "IsInside" predicate.

NB: Could have used template class DomainPredicate but, for performance reason, directly used the IsWithinPointPredicate which fits perfectly.

Referenced by example(), and main().

◆ rbegin() [1/2]

template<typename TSpace >
ConstReverseIterator DGtal::HyperRectDomain< TSpace >::rbegin ( ) const
inline

reverse begin method.

Returns
ConstIterator on the beginning of the reverse range.

Definition at line 210 of file HyperRectDomain.h.

211  {
212  return ConstReverseIterator(end());
213  }

Referenced by SECTION(), TEST_CASE(), TEST_CASE_METHOD(), and testIterator().

◆ rbegin() [2/2]

template<typename TSpace >
ConstReverseIterator DGtal::HyperRectDomain< TSpace >::rbegin ( const Point aPoint) const
inline

reverse begin method from a given point.

Parameters
aPointthe initial point.
Returns
a ConstIterator initialized to aPoint.
Precondition
aPoint must belong to the range.

Definition at line 221 of file HyperRectDomain.h.

222  {
223  ASSERT_MSG(
225  "The point must be inside the domain or be equal to one of his bound."
226  );
227 
228  ConstIterator it(begin(aPoint)); ++it;
229  return ConstReverseIterator(it);
230  }

◆ rend()

template<typename TSpace >
ConstReverseIterator DGtal::HyperRectDomain< TSpace >::rend ( ) const
inline

reverse end method.

Returns
ConstIterator on the end of the reverse range.

Definition at line 236 of file HyperRectDomain.h.

237  {
238  return ConstReverseIterator(begin());
239  }

Referenced by SECTION(), TEST_CASE(), TEST_CASE_METHOD(), and testIterator().

◆ selfDisplay()

template<typename TSpace >
void DGtal::HyperRectDomain< TSpace >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ size()

template<typename TSpace >
Size DGtal::HyperRectDomain< TSpace >::size ( ) const
inline
Returns
the size (number of points) of the HyperRectDomain

Definition at line 565 of file HyperRectDomain.h.

566  {
567  Size res = 1;
568  Point p = Point::diagonal(1);
569  Vector e = (myUpperBound - myLowerBound) + p;
570  typename Vector::ConstIterator it, itEnd;
571  for ( it = e.begin(), itEnd = e.end(); it != itEnd; ++it)
572  {
573  res *= *it;
574  }
575  return res;
576  }

Referenced by ArrayImageAdapter_example(), main(), moduleImages_example(), SCENARIO(), SECTION(), TEST_CASE(), TEST_CASE_METHOD(), test_image(), test_range_constRange(), testSetFromImage(), and testVoronoiCovarianceMeasure().

◆ subRange() [1/7]

template<typename TSpace >
ConstSubRange DGtal::HyperRectDomain< TSpace >::subRange ( const std::vector< Dimension > &  permutation) const
inline

get a subRange.

Parameters
permutationa vector containing the dimensions used for the subrange. Dimensions are iterated in the given order.
Returns
a sub-range of the domain for the given permutation.

Definition at line 472 of file HyperRectDomain.h.

473  {
474  return ConstSubRange(*this, permutation, myLowerBound);
475  }

Referenced by DGtal::ImageFactoryFromHDF5< TImageContainer >::flushImage(), main(), TEST_CASE(), TEST_CASE_METHOD(), and testIterator().

◆ subRange() [2/7]

template<typename TSpace >
ConstSubRange DGtal::HyperRectDomain< TSpace >::subRange ( const std::vector< Dimension > &  permutation,
const Point startingPoint 
) const
inline

get a subRange from an initial point.

Parameters
permutationa vector containing the dimensions used for the subrange. Dimensions are iterated in the given order.
startingPointthe initial point.
Returns
a sub-range of the domain for the given permutation.
Precondition
startingPoint must belong to the range.

Definition at line 485 of file HyperRectDomain.h.

487  {
488  return ConstSubRange(*this, permutation, startingPoint);
489  }

◆ subRange() [3/7]

template<typename TSpace >
ConstSubRange DGtal::HyperRectDomain< TSpace >::subRange ( Dimension  adim,
const Point startingPoint 
) const
inline

get a subRange of one dimension.

Parameters
adimthe dimension of the subrange.
startingPointthe initial point.
Returns
a sub-range of the domain for the given dimension.
Precondition
startingPoint must belong to the range.

Definition at line 498 of file HyperRectDomain.h.

500  {
501  return ConstSubRange(*this, adim, startingPoint);
502  }

◆ subRange() [4/7]

template<typename TSpace >
ConstSubRange DGtal::HyperRectDomain< TSpace >::subRange ( Dimension  adim1,
Dimension  adim2,
const Point startingPoint 
) const
inline

get a subRange of two dimensions.

Parameters
adim1the first dimension of the subrange.
adim2the second dimension of the subrange.
startingPointthe initial point.
Returns
a sub-range of the domain for the given two dimensions.
Precondition
startingPoint must belong to the range.

Definition at line 512 of file HyperRectDomain.h.

514  {
515  return ConstSubRange(*this, adim1, adim2, startingPoint);
516  }

◆ subRange() [5/7]

template<typename TSpace >
ConstSubRange DGtal::HyperRectDomain< TSpace >::subRange ( Dimension  adim1,
Dimension  adim2,
Dimension  adim3,
const Point startingPoint 
) const
inline

get a subRange of three dimensions.

Parameters
adim1the first dimension of the subrange.
adim2the second dimension of the subrange.
adim3the third dimension of the subrange.
startingPointthe initial point.
Returns
a sub-range of the domain for the given three dimensions.
Precondition
startingPoint must belong to the range.

Definition at line 527 of file HyperRectDomain.h.

529  {
530  return ConstSubRange(*this, adim1, adim2, adim3, startingPoint);
531  }

◆ subRange() [6/7]

template<typename TSpace >
ConstSubRange DGtal::HyperRectDomain< TSpace >::subRange ( std::initializer_list< Dimension permutation)
inline

get a subRange.

Parameters
permutationan initializer_list containing the dimensions used for the subrange. Dimensions are iterated in the given order.
Returns
a sub-range of the domain for the given permutation.

Definition at line 539 of file HyperRectDomain.h.

540  {
541  return ConstSubRange(*this, permutation, myLowerBound);
542  }

◆ subRange() [7/7]

template<typename TSpace >
ConstSubRange DGtal::HyperRectDomain< TSpace >::subRange ( std::initializer_list< Dimension permutation,
const Point startingPoint 
)
inline

get a subRange from an initial point.

Parameters
permutationan initializer_list containing the dimensions used for the subrange. Dimensions are iterated in the given order.
startingPointthe initial point.
Returns
a sub-range of the domain for the given permutation.
Precondition
startingPoint must belong to the range.

Definition at line 552 of file HyperRectDomain.h.

554  {
555  return ConstSubRange(*this, permutation, startingPoint);
556  }

◆ upperBound()

template<typename TSpace >
const Point& DGtal::HyperRectDomain< TSpace >::upperBound ( ) const

Field Documentation

◆ myIteratorBegin

template<typename TSpace >
ConstIterator DGtal::HyperRectDomain< TSpace >::myIteratorBegin
private

Begin iterator.

Definition at line 657 of file HyperRectDomain.h.

Referenced by DGtal::HyperRectDomain< Space >::begin().

◆ myIteratorEnd

template<typename TSpace >
ConstIterator DGtal::HyperRectDomain< TSpace >::myIteratorEnd
private

End iterator.

Definition at line 659 of file HyperRectDomain.h.

Referenced by DGtal::HyperRectDomain< Space >::end().

◆ myLowerBound

template<typename TSpace >
Point DGtal::HyperRectDomain< TSpace >::myLowerBound

◆ myPredicate

template<typename TSpace >
Predicate DGtal::HyperRectDomain< TSpace >::myPredicate
private

"IsInside" predicate.

Definition at line 654 of file HyperRectDomain.h.

◆ myUpperBound

template<typename TSpace >
Point DGtal::HyperRectDomain< TSpace >::myUpperBound

The highest point of the space diagonal.

Definition at line 649 of file HyperRectDomain.h.

Referenced by DGtal::HyperRectDomain< Space >::begin(), DGtal::HyperRectDomain< Space >::rbegin(), and DGtal::HyperRectDomain< Space >::size().


The documentation for this class was generated from the following file:
ConstIterator
MyDigitalSurface::ConstIterator ConstIterator
Definition: greedy-plane-segmentation-ex2.cpp:93
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition: HyperRectDomain.h:99
DGtal::HyperRectDomain::isInside
bool isInside(const Point &p) const
DGtal::HyperRectDomain::ConstReverseIterator
ReverseIterator ConstReverseIterator
Definition: HyperRectDomain.h:126
aPoint
const Point aPoint(3, 4)
DGtal::PointVector< dim, Integer >::diagonal
static Self diagonal(Component val=1)
DGtal::HyperRectDomain::ConstIterator
Iterator ConstIterator
Definition: HyperRectDomain.h:125
DGtal::HyperRectDomain::myLowerBound
Point myLowerBound
The lowest point of the space diagonal.
Definition: HyperRectDomain.h:647
Size
HalfEdgeDataStructure::Size Size
Definition: testHalfEdgeDataStructure.cpp:50
DGtal::HyperRectDomain::myIteratorEnd
ConstIterator myIteratorEnd
End iterator.
Definition: HyperRectDomain.h:659
DGtal::PointVector< dim, Integer >::ConstIterator
Container::const_iterator ConstIterator
Constant iterator type.
Definition: PointVector.h:641
DGtal::HyperRectDomain::end
const ConstIterator & end() const
Definition: HyperRectDomain.h:201
Vector
FreemanChain< int >::Vector Vector
Definition: testCombinDSS.cpp:60
DGtal::HyperRectDomain::myIteratorBegin
ConstIterator myIteratorBegin
Begin iterator.
Definition: HyperRectDomain.h:657
DGtal::HyperRectDomain::begin
const ConstIterator & begin() const
Definition: HyperRectDomain.h:176
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::HyperRectDomain::myUpperBound
Point myUpperBound
The highest point of the space diagonal.
Definition: HyperRectDomain.h:649