41#include "DGtal/base/Common.h"
42#include "DGtal/kernel/SpaceND.h"
43#include "DGtal/kernel/PointVector.h"
44#include "DGtal/kernel/domains/HyperRectDomain.h"
45#include "DGtal/base/CConstBidirectionalRange.h"
47#include "DGtalCatch.h"
56TEST_CASE(
"Simple HyperRectDomain",
"[domain][4D]" )
59 typedef Space4Type::Point
Point;
62 Space4Type::Integer t [] = { 1, 2, 3 , 4};
64 Space4Type::Integer t2[] = { 5, 5, 3 , 4};
66 double td [] = { 1.1, 2.5, 3 , 4};
68 double td2[] = { 4.9, 4.5, 3 , 4};
79 trace.
info() <<
"Empty domain using the default constructor" << std::endl;
82 trace.
info() <<
"Empty domain = " << myEmptyDomain << std::endl;
92 trace.
info() <<
"Domain characterized by points a and b" << std::endl;
95 trace.
info() <<
"Domain = " << myHyperRectDomain << std::endl;
100 trace.
info() <<
"Domain size = " << myHyperRectDomain.
size() << std::endl;
102 REQUIRE( (myHyperRectDomain.
end() - myHyperRectDomain.
begin()) == 20 );
103 REQUIRE( (myHyperRectDomain.
begin() - myHyperRectDomain.
end()) == -20 );
108 trace.
info() <<
"Domain initialized with RealPoint" << std::endl;
110 trace.
info() <<
"Domain = " << myHyperRectDomain_rr << std::endl;
116 trace.
info() <<
"Domain = " << myHyperRectDomain_ir << std::endl;
122 trace.
info() <<
"Domain = " << myHyperRectDomain_ri << std::endl;
132 trace.
info() <<
"Domain = " << myHyperRectDomainBis << std::endl;
133 trace.
info() <<
"Domain size = " << myHyperRectDomainBis.
size() << std::endl;
143 myHyperRectDomainTer = myHyperRectDomain;
144 trace.
info() <<
"Domain = " << myHyperRectDomainTer << std::endl;
145 trace.
info() <<
"Domain size = " << myHyperRectDomainTer.
size() << std::endl;
164 Iterator & it, Iterator
const& it_begin, Iterator
const& it_end,
165 typename std::iterator_traits<Iterator>::difference_type & cnt_begin,
166 Point & pt,
Domain const&
domain, std::vector<Dimension>
const& dimensions, std::size_t
id,
174 REQUIRE( std::distance(it_begin, it) == cnt_begin );
175 REQUIRE( std::distance(it, it_begin) == -cnt_begin );
176 INFO( *(it_begin + cnt_begin) <<
" == " << *it );
177 REQUIRE( it_begin + cnt_begin == it );
178 INFO( *(it - cnt_begin) <<
" == " << *it_begin);
179 REQUIRE( it - cnt_begin == it_begin );
187 const auto d = dimensions[id];
218 Iterator
const& it_begin, Iterator
const& it_end,
222 Iterator it = it_begin;
223 typename std::iterator_traits<Iterator>::difference_type cnt_begin = 0;
226 it, it_begin, it_end, cnt_begin,
238 Iterator
const& it_begin, Iterator
const& it_end,
242 std::vector<Dimension> dimensions(Domain::dimension);
243 std::iota(dimensions.begin(), dimensions.end(),
Dimension(0));
253 using Dimension =
typename Point::Dimension;
266 trace.
emphase() <<
"Iterator from starting point" << std::endl;
269 trace.
emphase() <<
"Reverse iterator from starting point" << std::endl;
272 trace.
emphase() <<
"Iterator on reversed dimension order: " << std::endl;
273 std::vector<Dimension> dimensions(Point::dimension);
274 std::iota(dimensions.rbegin(), dimensions.rend(),
Dimension(0));
278 trace.
emphase() <<
"Reverse iterator on reversed dimension order: " << std::endl;
281 trace.
emphase() <<
"Iterator on reversed dimension order and from a starting point: " << std::endl;
285 trace.
emphase() <<
"Reverse iterator on reversed dimension order and from a starting point: " << std::endl;
288 trace.
emphase() <<
"Iterator along one dimension: " << std::endl;
290 const std::vector<Dimension> one_dimension({1});
293 trace.
emphase() <<
"Reverse iterator along one dimension: " << std::endl;
298 trace.
emphase() <<
"Iterator along one dimension and from a starting point: " << std::endl;
302 trace.
emphase() <<
"Reverse iterator along one dimension and from a starting point: " << std::endl;
325 Point a({1, 1, 1, 1});
326 Point b({2, 3, 4, 5});
327 Point c({1, 2, 3, 2});
334#ifdef WITH_BIGINTEGER
340 Point a({1, 1, 1, 1});
341 Point b({2, 3, 4, 5});
342 Point c({1, 2, 3, 2});
353 typedef TSpace4D::Point Point4D;
354 TSpace4D::Integer t[] = {1, 1, 1, 1};
356 TSpace4D::Integer t2[] = {3, 3, 3, 3};
364 std::copy ( myHyperRectDomain4D.
begin(),
365 myHyperRectDomain4D.
end(),
366 ostream_iterator<Point4D> (
trace.
info(),
" " ) );
375 typedef TSpace::Point TPoint;
378 const TDomain nonempty_domain( TPoint::diagonal(0), TPoint::diagonal(0) );
379 REQUIRE( !nonempty_domain.isEmpty() );
381 const TDomain default_domain;
382 REQUIRE( default_domain.isEmpty() );
384 const TDomain
domain( TPoint::diagonal(1), TPoint::diagonal(0) );
391 REQUIRE( range.begin() == range.end() );
392 REQUIRE( range.rbegin() == range.rend() );
395 REQUIRE( range.begin() == range.end() );
396 REQUIRE( range.rbegin() == range.rend() );
399 REQUIRE( range.begin() == range.end() );
400 REQUIRE( range.rbegin() == range.rend() );
403 REQUIRE( range.begin() == range.end() );
404 REQUIRE( range.rbegin() == range.rend() );
407 REQUIRE( range.begin() == range.end() );
408 REQUIRE( range.rbegin() == range.rend() );
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
const ConstIterator & begin() const
const Point & lowerBound() const
ConstReverseIterator rbegin() const
const Point & upperBound() const
ConstSubRange subRange(const std::vector< Dimension > &permutation) const
ConstReverseIterator rend() const
const ConstIterator & end() const
Space::Dimension Dimension
Aim: Implements basic operations that will be used in Point and Vector classes.
Self & partialCopy(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions)
Partial copy of a given PointVector.
PointVector< dim, Integer > Point
Points in DGtal::SpaceND.
void beginBlock(const std::string &keyword="")
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Aim: Defines the concept describing a bidirectional const range.
Aim: This concept represents a digital domain, i.e. a non mutable subset of points of the given digit...
void testIterator(Point const &a, Point const &b, Point const &c)
void testIteratorHelper(Iterator const &it_begin, Iterator const &it_end, Point pt, Domain const &domain, std::vector< Dimension > const &dimensions, bool forward=true)
TEST_CASE("Simple HyperRectDomain", "[domain][4D]")
void testIteratorHelperImpl(Iterator &it, Iterator const &it_begin, Iterator const &it_end, typename std::iterator_traits< Iterator >::difference_type &cnt_begin, Point &pt, Domain const &domain, std::vector< Dimension > const &dimensions, std::size_t id, bool forward)
Checking iterator given then span domain and dimensions order.
HyperRectDomain< Space > Domain
REQUIRE(domain.isInside(aPoint))