DGtal  1.3.beta
HyperRectDomain.h
1 
17 #pragma once
18 
32 #if defined(HyperRectDomain_RECURSES)
33 #error Recursive header files inclusion detected in HyperRectDomain.h
34 #else // defined(HyperRectDomain_RECURSES)
35 
36 #define HyperRectDomain_RECURSES
37 
38 #if !defined HyperRectDomain_h
39 
40 #define HyperRectDomain_h
41 
43 // Inclusions
44 #include <iostream>
45 #include <iterator>
46 
47 #include "DGtal/base/Common.h"
48 #include "DGtal/kernel/CSpace.h"
49 #include "DGtal/kernel/BasicPointPredicates.h"
50 #include "DGtal/kernel/domains/CDomain.h"
51 #include "DGtal/kernel/domains/HyperRectDomain_Iterator.h"
52 #include "DGtal/kernel/NumberTraits.h"
53 #include "DGtal/base/CConstBidirectionalRange.h"
54 
55 namespace DGtal
56 {
58  // class HyperRectDomain
98  template<typename TSpace>
100  {
102 
103  // ----------------------- Standard services ------------------------------
104  public:
105 
107 
108  // typedef TSpace DigitalSpace;
109  // typedef TSpace Space;
110  typedef TSpace Space;
111 
113  typedef typename Space::Point Point;
114  typedef typename Space::Integer Integer;
115  typedef typename Space::Vector Vector;
116  typedef typename Space::Dimension Dimension;
117  typedef typename Space::Size Size;
118  typedef typename Point::Coordinate Coordinate; // TODO REVOIR LES NOMS.... RECUPERER DANS SPACE
119 
121 
127 
129 
133  HyperRectDomain();
134 
139  HyperRectDomain ( const Point &lowerPoint, const Point &upperPoint );
140 
148  HyperRectDomain ( const typename Space::RealPoint &lowerPoint,
149  const typename Space::RealPoint &upperPoint );
150 
155 
161  HyperRectDomain ( const HyperRectDomain & other );
162 
163 
170  HyperRectDomain & operator= ( const HyperRectDomain & other );
171 
176  const ConstIterator& begin() const
177  {
178  return myIteratorBegin;
179  }
180 
188  {
189  ASSERT_MSG(
191  "The point must be inside the domain or be equal to one of his bound."
192  );
193 
195  }
196 
201  const ConstIterator& end() const
202  {
203  return myIteratorEnd;
204  }
205 
211  {
212  return ConstReverseIterator(end());
213  }
214 
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  }
231 
237  {
238  return ConstReverseIterator(begin());
239  }
240 
250  {
253 
263  const std::vector<Dimension> & permutation,
264  const Point & startingPoint)
267  myStartingPoint(startingPoint)
268  {
269  ASSERT_MSG(
270  domain.isInside(startingPoint) || startingPoint == myLowerBound || startingPoint == myUpperBound,
271  "The point must be inside the given domain or be equal to one of his bound."
272  );
273 
274  myPermutation.reserve( permutation.size() );
275  std::copy(permutation.begin(), permutation.end(), std::back_inserter(myPermutation));
278  }
279 
289  std::initializer_list<Dimension> permutation,
290  const Point & startingPoint)
293  myStartingPoint(startingPoint)
294  {
295  ASSERT_MSG(
296  domain.isInside(startingPoint) || startingPoint == myLowerBound || startingPoint == myUpperBound,
297  "The point must be inside the given domain or be equal to one of his bound."
298  );
299 
300  myPermutation.reserve( permutation.size() );
301  for ( const unsigned int *c = permutation.begin(); c != permutation.end(); ++c )
302  {
303  myPermutation.push_back( *c );
304  }
307  }
308 
317  Dimension adim,
318  const Point & startingPoint)
321  myStartingPoint(startingPoint)
322  {
323  ASSERT_MSG(
324  domain.isInside(startingPoint) || startingPoint == myLowerBound || startingPoint == myUpperBound,
325  "The point must be inside the given domain or be equal to one of his bound."
326  );
327 
328  myPermutation.push_back( adim );
331  }
332 
342  Dimension adim1, Dimension adim2,
343  const Point & startingPoint)
346  myStartingPoint(startingPoint)
347  {
348  ASSERT_MSG(
349  domain.isInside(startingPoint) || startingPoint == myLowerBound || startingPoint == myUpperBound,
350  "The point must be inside the given domain or be equal to one of his bound."
351  );
352 
353  myPermutation.push_back( adim1 );
354  myPermutation.push_back( adim2 );
357  }
358 
369  Dimension adim1, Dimension adim2, Dimension adim3,
370  const Point & startingPoint)
373  myStartingPoint(startingPoint)
374  {
375  ASSERT_MSG(
376  domain.isInside(startingPoint) || startingPoint == myLowerBound || startingPoint == myUpperBound,
377  "The point must be inside the given domain or be equal to one of his bound."
378  );
379 
380  myPermutation.push_back( adim1 );
381  myPermutation.push_back( adim2 );
382  myPermutation.push_back( adim3 );
385  }
386 
392  {
394  }
395 
403  {
404  ASSERT(aPoint.partialEqualInv(myLowerBound, myPermutation) );
405  ASSERT_MSG(
407  "The point must be inside the given domain or be equal to one of his bound."
408  );
409 
411  }
412 
418  {
420  ++it;
421  return it;
422  }
423 
429  {
430  return ConstReverseIterator(end());
431  }
432 
440  {
442  ++it;
443  return ConstReverseIterator(it);
444  }
445 
451  {
452  return ConstReverseIterator(begin());
453  }
454 
455  private:
463  std::vector<Dimension> myPermutation;
464  }; // ConstSubRange
465 
472  ConstSubRange subRange(const std::vector<Dimension> & permutation) const
473  {
474  return ConstSubRange(*this, permutation, myLowerBound);
475  }
476 
485  ConstSubRange subRange(const std::vector<Dimension> & permutation,
486  const Point & startingPoint) const
487  {
488  return ConstSubRange(*this, permutation, startingPoint);
489  }
490 
498  ConstSubRange subRange(Dimension adim,
499  const Point & startingPoint) const
500  {
501  return ConstSubRange(*this, adim, startingPoint);
502  }
503 
512  ConstSubRange subRange(Dimension adim1, Dimension adim2,
513  const Point & startingPoint) const
514  {
515  return ConstSubRange(*this, adim1, adim2, startingPoint);
516  }
517 
527  ConstSubRange subRange(Dimension adim1, Dimension adim2, Dimension adim3,
528  const Point & startingPoint) const
529  {
530  return ConstSubRange(*this, adim1, adim2, adim3, startingPoint);
531  }
532 
539  ConstSubRange subRange(std::initializer_list<Dimension> permutation)
540  {
541  return ConstSubRange(*this, permutation, myLowerBound);
542  }
543 
552  ConstSubRange subRange(std::initializer_list<Dimension> permutation,
553  const Point & startingPoint)
554  {
555  return ConstSubRange(*this, permutation, startingPoint);
556  }
557 
558  // ----------------------- Interface --------------------------------------
559  public:
560 
565  Size size() const
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  }
577 
582  const Point &lowerBound() const;
583 
588  const Point &upperBound() const ;
589 
594  bool isInside( const Point & p ) const;
595 
599  bool isEmpty() const;
600 
608  const Predicate & predicate() const;
609 
610  // ------------------------- Private Datas --------------------------------
611  private:
612 
613 
614 
615  // --------------- CDrawableWithBoard2D realization --------------------
616  public:
617 
622  //DrawableWithBoard2D* defaultStyle( std::string mode = "" ) const;
623 
627  std::string className() const;
628 
629 
634  void selfDisplay ( std::ostream & out ) const;
635 
640  bool isValid() const;
641 
642 
643 
644  // ------------------------- Hidden services ------------------------------
645  //private:
650 
651  private:
652 
655 
660  }; // end of class HyperRectDomain
661 
662 
669  template<typename TSpace>
670  std::ostream&
671  operator<< ( std::ostream& out, const HyperRectDomain<TSpace> & object );
672 
673 
674 } // namespace DGtal
675 
676 
678 // Includes inline functions.
679 #include "DGtal/kernel/domains/HyperRectDomain.ih"
680 
681 // //
683 
684 #endif // !defined HyperRectDomain_h
685 
686 #undef HyperRectDomain_RECURSES
687 #endif // else defined(HyperRectDomain_RECURSES)
DGtal::HyperRectDomain::rend
ConstReverseIterator rend() const
Definition: HyperRectDomain.h:236
DGtal::HyperRectDomain::isEmpty
bool isEmpty() const
DGtal::SpaceND::Dimension
DGtal::Dimension Dimension
Copy of the type used for the dimension.
Definition: SpaceND.h:129
DGtal::HyperRectDomain::Dimension
Space::Dimension Dimension
Definition: HyperRectDomain.h:116
DGtal::HyperRectDomain::rbegin
ConstReverseIterator rbegin(const Point &aPoint) const
Definition: HyperRectDomain.h:221
DGtal::HyperRectDomain::Space
TSpace Space
Definition: HyperRectDomain.h:110
DGtal::PointVector::partialCopyInv
Self & partialCopyInv(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions)
Partial copy of a given PointVector.
DGtal::HyperRectDomain::ConstSubRange
Aim: range through some subdomain of all the points in the domain. Defines a constructor taking a dom...
Definition: HyperRectDomain.h:249
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition: HyperRectDomain.h:99
DGtal::concepts::CSpace
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition: CSpace.h:105
DGtal::HyperRectDomain::size
Size size() const
Definition: HyperRectDomain.h:565
DGtal::HyperRectDomain_ReverseIterator
Reverse iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:66
DGtal::HyperRectDomain::isInside
bool isInside(const Point &p) const
DGtal::HyperRectDomain::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
DGtal::HyperRectDomain::ConstReverseIterator
ReverseIterator ConstReverseIterator
Definition: HyperRectDomain.h:126
DGtal::PointVector< dim, Integer >::Coordinate
Component Coordinate
Type for Point elements.
Definition: PointVector.h:617
DGtal::HyperRectDomain::Point
Space::Point Point
Definition: HyperRectDomain.h:113
DGtal::HyperRectDomain::ConstSubRange::end
ConstIterator end() const
Definition: HyperRectDomain.h:417
DGtal::HyperRectDomain::~HyperRectDomain
~HyperRectDomain()
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
DGtal::HyperRectDomain::Self
HyperRectDomain< TSpace > Self
Definition: HyperRectDomain.h:106
aPoint
const Point aPoint(3, 4)
DGtal::SpaceND::Size
UnsignedInteger Size
Type used to represent sizes in the digital space.
Definition: SpaceND.h:107
DGtal::HyperRectDomain::Coordinate
Point::Coordinate Coordinate
Definition: HyperRectDomain.h:118
DGtal::HyperRectDomain::BOOST_STATIC_CONSTANT
BOOST_STATIC_CONSTANT(Dimension, dimension=Space::dimension)
DGtal::HyperRectDomain::className
std::string className() const
DGtal::HyperRectDomain::Domain
HyperRectDomain< Space > Domain
Definition: HyperRectDomain.h:112
DGtal::PointVector< dim, Integer >::diagonal
static Self diagonal(Component val=1)
DGtal::HyperRectDomain::myPredicate
Predicate myPredicate
"IsInside" predicate.
Definition: HyperRectDomain.h:654
DGtal::HyperRectDomain::ConstIterator
Iterator ConstIterator
Definition: HyperRectDomain.h:125
DGtal::HyperRectDomain::ConstSubRange::myUpperBound
Point myUpperBound
Upper bound of the subrange.
Definition: HyperRectDomain.h:459
DGtal::HyperRectDomain::myLowerBound
Point myLowerBound
The lowest point of the space diagonal.
Definition: HyperRectDomain.h:647
DGtal::functors::IsWithinPointPredicate< Point >
DGtal::HyperRectDomain::subRange
ConstSubRange subRange(Dimension adim1, Dimension adim2, const Point &startingPoint) const
Definition: HyperRectDomain.h:512
DGtal::HyperRectDomain::subRange
ConstSubRange subRange(const std::vector< Dimension > &permutation, const Point &startingPoint) const
Definition: HyperRectDomain.h:485
DGtal::HyperRectDomain::ConstSubRange::ConstSubRange
ConstSubRange(const HyperRectDomain< TSpace > &domain, const std::vector< Dimension > &permutation, const Point &startingPoint)
Definition: HyperRectDomain.h:262
DGtal::HyperRectDomain::ConstSubRange::myStartingPoint
Point myStartingPoint
Starting point of the subrange.
Definition: HyperRectDomain.h:461
DGtal::HyperRectDomain_subIterator
Definition: HyperRectDomain_Iterator.h:316
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::HyperRectDomain::Size
Space::Size Size
Definition: HyperRectDomain.h:117
DGtal::HyperRectDomain::ConstSubRange::rbegin
ConstReverseIterator rbegin(const Point &aPoint) const
Definition: HyperRectDomain.h:439
DGtal::HyperRectDomain::myIteratorEnd
ConstIterator myIteratorEnd
End iterator.
Definition: HyperRectDomain.h:659
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::HyperRectDomain::predicate
const Predicate & predicate() const
DGtal::HyperRectDomain::subRange
ConstSubRange subRange(std::initializer_list< Dimension > permutation, const Point &startingPoint)
Definition: HyperRectDomain.h:552
DGtal::HyperRectDomain::ConstSubRange::begin
ConstIterator begin(const Point &aPoint) const
Definition: HyperRectDomain.h:402
DGtal::HyperRectDomain::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::HyperRectDomain::ConstSubRange::rbegin
ConstReverseIterator rbegin() const
Definition: HyperRectDomain.h:428
DGtal::SpaceND::dimension
static const Dimension dimension
static constants to store the dimension.
Definition: SpaceND.h:132
DGtal::PointVector< dim, Integer >::ConstIterator
Container::const_iterator ConstIterator
Constant iterator type.
Definition: PointVector.h:641
DGtal::HyperRectDomain::ConstSubRange::ConstSubRange
ConstSubRange(const HyperRectDomain< TSpace > &domain, Dimension adim1, Dimension adim2, const Point &startingPoint)
Definition: HyperRectDomain.h:341
DGtal::PointVector::end
Iterator end()
DGtal::HyperRectDomain::end
const ConstIterator & end() const
Definition: HyperRectDomain.h:201
DGtal::HyperRectDomain::subRange
ConstSubRange subRange(std::initializer_list< Dimension > permutation)
Definition: HyperRectDomain.h:539
DGtal::HyperRectDomain::HyperRectDomain
HyperRectDomain()
DGtal::PointVector::begin
Iterator begin()
DGtal::HyperRectDomain::ConstSubRange::ConstSubRange
ConstSubRange(const HyperRectDomain< TSpace > &domain, std::initializer_list< Dimension > permutation, const Point &startingPoint)
Definition: HyperRectDomain.h:288
DGtal::HyperRectDomain::subRange
ConstSubRange subRange(Dimension adim, const Point &startingPoint) const
Definition: HyperRectDomain.h:498
DGtal::HyperRectDomain::ConstSubRange::rend
ConstReverseIterator rend() const
Definition: HyperRectDomain.h:450
DGtal::HyperRectDomain::myIteratorBegin
ConstIterator myIteratorBegin
Begin iterator.
Definition: HyperRectDomain.h:657
DGtal::HyperRectDomain::ReverseIterator
HyperRectDomain_ReverseIterator< Iterator > ReverseIterator
Definition: HyperRectDomain.h:124
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:142
DGtal::HyperRectDomain::ConstSubRange::begin
ConstIterator begin() const
Definition: HyperRectDomain.h:391
DGtal::HyperRectDomain::ConstSubRange::ConstSubRange
ConstSubRange(const HyperRectDomain< TSpace > &domain, Dimension adim, const Point &startingPoint)
Definition: HyperRectDomain.h:316
DGtal::HyperRectDomain::Vector
Space::Vector Vector
Definition: HyperRectDomain.h:115
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::HyperRectDomain::ConstSubRange::ConstIterator
HyperRectDomain_subIterator< Point > ConstIterator
Definition: HyperRectDomain.h:251
DGtal::HyperRectDomain::Integer
Space::Integer Integer
Definition: HyperRectDomain.h:114
DGtal::PointVector< dim, Integer >
DGtal::HyperRectDomain::isValid
bool isValid() const
DGtal::HyperRectDomain::Predicate
functors::IsWithinPointPredicate< Point > Predicate
Definition: HyperRectDomain.h:128
DGtal::HyperRectDomain::operator=
HyperRectDomain & operator=(const HyperRectDomain &other)
DGtal::HyperRectDomain::ConstSubRange::ConstSubRange
ConstSubRange(const HyperRectDomain< TSpace > &domain, Dimension adim1, Dimension adim2, Dimension adim3, const Point &startingPoint)
Definition: HyperRectDomain.h:368
DGtal::HyperRectDomain::subRange
ConstSubRange subRange(const std::vector< Dimension > &permutation) const
Definition: HyperRectDomain.h:472
DGtal::HyperRectDomain::ConstSubRange::ConstReverseIterator
HyperRectDomain_ReverseIterator< ConstIterator > ConstReverseIterator
Definition: HyperRectDomain.h:252
DGtal::HyperRectDomain::ConstSubRange::myLowerBound
Point myLowerBound
Lower bound of the subrange.
Definition: HyperRectDomain.h:457
DGtal::HyperRectDomain::begin
const ConstIterator & begin() const
Definition: HyperRectDomain.h:176
DGtal::HyperRectDomain::rbegin
ConstReverseIterator rbegin() const
Definition: HyperRectDomain.h:210
DGtal::PointVector::isLower
bool isLower(const PointVector< dim, OtherComponent, OtherStorage > &p) const
Return true if this point is below a given point.
DGtal::HyperRectDomain::Iterator
HyperRectDomain_Iterator< Point > Iterator
Typedef of domain iterators.
Definition: HyperRectDomain.h:123
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::HyperRectDomain::ConstSubRange::myPermutation
std::vector< Dimension > myPermutation
Permutation on dimensions used in the subrange.
Definition: HyperRectDomain.h:463
DGtal::HyperRectDomain::begin
ConstIterator begin(const Point &aPoint) const
Definition: HyperRectDomain.h:187
DGtal::HyperRectDomain::myUpperBound
Point myUpperBound
The highest point of the space diagonal.
Definition: HyperRectDomain.h:649
DGtal::SpaceND::Integer
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
Definition: SpaceND.h:102
DGtal::HyperRectDomain::subRange
ConstSubRange subRange(Dimension adim1, Dimension adim2, Dimension adim3, const Point &startingPoint) const
Definition: HyperRectDomain.h:527
DGtal::HyperRectDomain::lowerBound
const Point & lowerBound() const