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"
49 using namespace DGtal;
56 TEST_CASE(
"Simple HyperRectDomain",
"[domain][4D]" )
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,
241 std::vector<Dimension> dimensions(Domain::dimension);
242 std::iota(dimensions.begin(), dimensions.end(),
Dimension(0));
264 trace.
emphase() <<
"Iterator from starting point" << std::endl;
267 trace.
emphase() <<
"Reverse iterator from starting point" << std::endl;
270 trace.
emphase() <<
"Iterator on reversed dimension order: " << std::endl;
271 std::vector<Dimension> dimensions(Point::dimension);
272 std::iota(dimensions.rbegin(), dimensions.rend(),
Dimension(0));
276 trace.
emphase() <<
"Reverse iterator on reversed dimension order: " << std::endl;
279 trace.
emphase() <<
"Iterator on reversed dimension order and from a starting point: " << std::endl;
283 trace.
emphase() <<
"Reverse iterator on reversed dimension order and from a starting point: " << std::endl;
286 trace.
emphase() <<
"Iterator along one dimension: " << std::endl;
288 const std::vector<Dimension> one_dimension({1});
291 trace.
emphase() <<
"Reverse iterator along one dimension: " << std::endl;
296 trace.
emphase() <<
"Iterator along one dimension and from a starting point: " << std::endl;
300 trace.
emphase() <<
"Reverse iterator along one dimension and from a starting point: " << std::endl;
323 Point a({1, 1, 1, 1});
324 Point b({2, 3, 4, 5});
325 Point c({1, 2, 3, 2});
332 #ifdef WITH_BIGINTEGER
338 Point a({1, 1, 1, 1});
339 Point b({2, 3, 4, 5});
340 Point c({1, 2, 3, 2});
362 std::copy ( myHyperRectDomain4D.
begin(),
363 myHyperRectDomain4D.
end(),
364 ostream_iterator<Point4D> (
trace.
info(),
" " ) );
376 const TDomain nonempty_domain( TPoint::diagonal(0), TPoint::diagonal(0) );
377 REQUIRE( !nonempty_domain.isEmpty() );
379 const TDomain default_domain;
380 REQUIRE( default_domain.isEmpty() );
382 const TDomain
domain( TPoint::diagonal(1), TPoint::diagonal(0) );
389 REQUIRE( range.begin() == range.end() );
390 REQUIRE( range.rbegin() == range.rend() );
393 REQUIRE( range.begin() == range.end() );
394 REQUIRE( range.rbegin() == range.rend() );
397 REQUIRE( range.begin() == range.end() );
398 REQUIRE( range.rbegin() == range.rend() );
401 REQUIRE( range.begin() == range.end() );
402 REQUIRE( range.rbegin() == range.rend() );
405 REQUIRE( range.begin() == range.end() );
406 REQUIRE( range.rbegin() == range.rend() );
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
const ConstIterator & end() const
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
Self & partialCopy(const PointVector< dim, OtherComponent, OtherContainer > &pv, const std::vector< Dimension > &dimensions)
Partial copy of a given PointVector.
void beginBlock(const std::string &keyword="")
Point::Coordinate Integer
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))
PointVector< 3, double > RealPoint