DGtal 1.4.0
Loading...
Searching...
No Matches
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)
36#define HyperRectDomain_RECURSES
37
38#if !defined HyperRectDomain_h
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
55namespace 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;
119
121
127
129
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
162
163
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
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
499 const Point & startingPoint) const
500 {
501 return ConstSubRange(*this, adim, startingPoint);
502 }
503
513 const Point & startingPoint) const
514 {
515 return ConstSubRange(*this, adim1, adim2, startingPoint);
516 }
517
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 for(Dimension i=0; i < Space::dimension; ++i)
570 return res;
571 }
572
577 const Point &lowerBound() const;
578
583 const Point &upperBound() const ;
584
589 bool isInside( const Point & p ) const;
590
594 bool isEmpty() const;
595
603 const Predicate & predicate() const;
604
605 // ------------------------- Private Datas --------------------------------
606 private:
607
608
609
610 // --------------- CDrawableWithBoard2D realization --------------------
611 public:
612
617 //DrawableWithBoard2D* defaultStyle( std::string mode = "" ) const;
618
622 std::string className() const;
623
624
629 void selfDisplay ( std::ostream & out ) const;
630
635 bool isValid() const;
636
637
638
639 // ------------------------- Hidden services ------------------------------
640 //private:
645
646 private:
647
650
655 }; // end of class HyperRectDomain
656
657
664 template<typename TSpace>
665 std::ostream&
666 operator<< ( std::ostream& out, const HyperRectDomain<TSpace> & object );
667
668
669} // namespace DGtal
670
671
673// Includes inline functions.
674#include "DGtal/kernel/domains/HyperRectDomain.ih"
675
676// //
678
679#endif // !defined HyperRectDomain_h
680
681#undef HyperRectDomain_RECURSES
682#endif // else defined(HyperRectDomain_RECURSES)
Reverse iterator for HyperRectDomain.
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Point myUpperBound
The highest point of the space diagonal.
Point myLowerBound
The lowest point of the space diagonal.
HyperRectDomain(const typename Space::RealPoint &lowerPoint, const typename Space::RealPoint &upperPoint)
HyperRectDomain< Space > Domain
BOOST_STATIC_CONSTANT(Dimension, dimension=Space::dimension)
ConstSubRange subRange(Dimension adim1, Dimension adim2, Dimension adim3, const Point &startingPoint) const
bool isInside(const Point &p) const
ConstSubRange subRange(const std::vector< Dimension > &permutation, const Point &startingPoint) const
functors::IsWithinPointPredicate< Point > Predicate
const ConstIterator & begin() const
const Point & lowerBound() const
ReverseIterator ConstReverseIterator
ConstSubRange subRange(std::initializer_list< Dimension > permutation)
ConstReverseIterator rbegin() const
const Predicate & predicate() const
HyperRectDomain & operator=(const HyperRectDomain &other)
ConstIterator myIteratorBegin
Begin iterator.
const Point & upperBound() const
ConstSubRange subRange(Dimension adim, const Point &startingPoint) const
HyperRectDomain(const Point &lowerPoint, const Point &upperPoint)
ConstSubRange subRange(const std::vector< Dimension > &permutation) const
HyperRectDomain_ReverseIterator< Iterator > ReverseIterator
void selfDisplay(std::ostream &out) const
ConstIterator begin(const Point &aPoint) const
ConstReverseIterator rend() const
Predicate myPredicate
"IsInside" predicate.
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
std::string className() const
HyperRectDomain_Iterator< Point > Iterator
Typedef of domain iterators.
HyperRectDomain(const HyperRectDomain &other)
Point::Coordinate Coordinate
ConstSubRange subRange(std::initializer_list< Dimension > permutation, const Point &startingPoint)
const ConstIterator & end() const
Space::Dimension Dimension
ConstReverseIterator rbegin(const Point &aPoint) const
HyperRectDomain< TSpace > Self
ConstSubRange subRange(Dimension adim1, Dimension adim2, const Point &startingPoint) const
ConstIterator myIteratorEnd
End iterator.
bool isLower(const PointVector< dim, OtherComponent, OtherStorage > &p) const
Return true if this point is below a given point.
Self & partialCopyInv(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions)
Partial copy of a given PointVector.
TInteger Integer
Arithmetic ring induced by (+,-,*) and Integer numbers.
Definition SpaceND.h:102
size_t Size
Type used to represent sizes in the digital space.
Definition SpaceND.h:107
static const Dimension dimension
static constants to store the dimension.
Definition SpaceND.h:132
DGtal::Dimension Dimension
Copy of the type used for the dimension.
Definition SpaceND.h:129
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: range through some subdomain of all the points in the domain. Defines a constructor taking a dom...
Point myStartingPoint
Starting point of the subrange.
ConstSubRange(const HyperRectDomain< TSpace > &domain, Dimension adim, const Point &startingPoint)
ConstSubRange(const HyperRectDomain< TSpace > &domain, const std::vector< Dimension > &permutation, const Point &startingPoint)
Point myUpperBound
Upper bound of the subrange.
ConstIterator begin(const Point &aPoint) const
HyperRectDomain_subIterator< Point > ConstIterator
ConstReverseIterator rbegin() const
ConstReverseIterator rbegin(const Point &aPoint) const
ConstSubRange(const HyperRectDomain< TSpace > &domain, Dimension adim1, Dimension adim2, const Point &startingPoint)
ConstSubRange(const HyperRectDomain< TSpace > &domain, std::initializer_list< Dimension > permutation, const Point &startingPoint)
ConstReverseIterator rend() const
ConstSubRange(const HyperRectDomain< TSpace > &domain, Dimension adim1, Dimension adim2, Dimension adim3, const Point &startingPoint)
HyperRectDomain_ReverseIterator< ConstIterator > ConstReverseIterator
Point myLowerBound
Lower bound of the subrange.
std::vector< Dimension > myPermutation
Permutation on dimensions used in the subrange.
Aim: The traits class for all models of Cinteger.
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
Definition CSpace.h:106
Aim: The predicate returns true when the point is within the given bounds.
Domain domain
const Point aPoint(3, 4)