DGtal  1.5.beta
testSimpleRandomAccessRangeFromPoint.cpp File Reference
#include "DGtalCatch.h"
#include <DGtal/kernel/SpaceND.h>
#include <DGtal/kernel/domains/HyperRectDomain.h>
#include <DGtal/kernel/domains/Linearizer.h>
#include <DGtal/images/ImageContainerBySTLVector.h>
#include <algorithm>
#include <cstddef>
Include dependency graph for testSimpleRandomAccessRangeFromPoint.cpp:

Go to the source code of this file.

Typedefs

typedef double Value
 
typedef SpaceND< 2 > Space
 
typedef Space::Point Point
 
typedef HyperRectDomain< SpaceDomain
 
typedef ImageContainerBySTLVector< Domain, ValueImage
 
typedef Image::Range Range
 
typedef Image::ConstRange ConstRange
 
typedef Linearizer< Domain, ColMajorStorageLinearizer
 

Functions

const Domain domain (Point(1, 2), Point(6, 5))
 
const Point aPoint (3, 4)
 
 REQUIRE (domain.isInside(aPoint))
 
Image image (domain)
 
Image refImage (domain)
 
 for (Domain::ConstIterator it=domain.begin(), it_end=domain.end();it !=it_end;++it,++cnt)
 
 SECTION ("Testing constant forward iterators")
 
 SECTION ("Testing constant forward iterators from a point")
 
 SECTION ("Testing mutable forward iterators")
 
 SECTION ("Testing mutable forward iterators from a point")
 
 SECTION ("Testing constant reverse iterators")
 
 SECTION ("Testing constant reverse iterators from a point")
 
 SECTION ("Testing mutable reverse iterators")
 
 SECTION ("Testing mutable reverse iterators from a point")
 
 SECTION ("Testing forward output iterators")
 
 SECTION ("Testing forward output iterators from a point")
 
 SECTION ("Testing reverse output iterators")
 
 SECTION ("Testing reverse output iterators from a point")
 
 SECTION ("Testing constant forward circulators")
 
 SECTION ("Testing constant reverse circulators")
 
 SECTION ("Testing mutable circulators in forward way")
 
 SECTION ("Testing mutable circulators in backward way")
 
 SECTION ("Testing mutable reverse circulators in forward way")
 
 SECTION ("Testing mutable reverse circulators in backward way")
 

Variables

const double hour = 4.29
 
std::size_t cnt = 0
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Roland Denis (rolan.nosp@m.d.de.nosp@m.nis@u.nosp@m.niv-.nosp@m.smb.f.nosp@m.r )
Date
2015/10/21

This file is part of the DGtal library

Definition in file testSimpleRandomAccessRangeFromPoint.cpp.

Typedef Documentation

◆ ConstRange

◆ Domain

◆ Image

◆ Linearizer

◆ Point

Definition at line 43 of file testSimpleRandomAccessRangeFromPoint.cpp.

◆ Range

◆ Space

◆ Value

Function Documentation

◆ aPoint()

const Point aPoint ( ,
 
)

Referenced by DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::begin(), DGtal::TiledImageBidirectionalRangeFromPoint< TTiledImage >::begin(), DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::begin(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::begin(), DGtal::TiledImageBidirectionalConstRangeFromPoint< TTiledImage >::begin(), DGtal::DefaultConstImageRange< TImage >::begin(), DGtal::DefaultImageRange< TImage >::begin(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::begin(), DGtal::HyperRectDomain< TSpace >::begin(), DGtal::HyperRectDomain< TSpace >::ConstSubRange::begin(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstRange::begin(), calcPointModuloDomain(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::findBlockCoordsFromPoint(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::findSubDomain(), DGtal::ReverseDistanceTransformation< TWeightImage, TPSeparableMetric, TImageContainer >::getPowerVector(), DGtal::ArrayImageAdapter< TArrayIterator, HyperRectDomain< TSpace > >::getValue(), DGtal::DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::getVoronoiSite(), DGtal::DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::operator()(), DGtal::PowerMap< TWeightImage, TPowerSeparableMetric, TImageContainer >::operator()(), DGtal::ReverseDistanceTransformation< TWeightImage, TPSeparableMetric, TImageContainer >::operator()(), DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::operator()(), DGtal::VoronoiMapComplete< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::operator()(), DGtal::ConstImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV >::operator()(), DGtal::Image< TImageContainer >::operator()(), DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::operator()(), DGtal::DistanceFunctorFromPoint< TImage >::operator()(), DGtal::ImageToConstantFunctor< Image, PointPredicate, TValue >::operator()(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::operator()(), DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::operator()(), DGtal::functors::FlipDomainAxis< TDomain >::operator()(), DGtal::ParametricShapeCurvatureFunctor< TParametricShape >::operator()(), DGtal::ParametricShapeTangentFunctor< TParametricShape >::operator()(), DGtal::ImplicitBall< TSpace >::operator()(), DGtal::ImplicitHyperCube< TSpace >::operator()(), DGtal::ImplicitNorm1Ball< TSpace >::operator()(), DGtal::ImplicitRoundedHyperCube< TSpace >::operator()(), DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::operator()(), DGtal::functors::SliceRotator2D< TDomain3D, TInteger >::operator()(), DGtal::functors::IntervalForegroundPredicate< Image >::operator()(), DGtal::functors::SimpleThresholdForegroundPredicate< Image >::operator()(), DGtal::ArrayImageAdapter< TArrayIterator, HyperRectDomain< TSpace > >::operator()(), DGtal::IteratorCompletionTraits< ArrayImageAdapter< TArrayIterator, TDomain > >::DistanceFunctor::operator()(), DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::operator()(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::operator()(), DGtal::DigitalSetInserter< TDigitalSet >::operator=(), DGtal::WindingNumbersShape< TSpace >::orientation(), DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::outputIterator(), DGtal::TiledImageBidirectionalRangeFromPoint< TTiledImage >::outputIterator(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::outputIterator(), DGtal::DefaultImageRange< TImage >::outputIterator(), DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::rbegin(), DGtal::TiledImageBidirectionalRangeFromPoint< TTiledImage >::rbegin(), DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rbegin(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::rbegin(), DGtal::TiledImageBidirectionalConstRangeFromPoint< TTiledImage >::rbegin(), DGtal::DefaultConstImageRange< TImage >::rbegin(), DGtal::DefaultImageRange< TImage >::rbegin(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::rbegin(), DGtal::HyperRectDomain< TSpace >::rbegin(), DGtal::HyperRectDomain< TSpace >::ConstSubRange::rbegin(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstRange::rbegin(), DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::routputIterator(), DGtal::TiledImageBidirectionalRangeFromPoint< TTiledImage >::routputIterator(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::routputIterator(), DGtal::DefaultImageRange< TImage >::routputIterator(), SECTION(), DGtal::Image< TImageContainer >::setValue(), DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::setValue(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::setValue(), DGtal::ArrayImageAdapter< TArrayIterator, HyperRectDomain< TSpace > >::setValue(), DGtal::ImageContainerBySTLVector< TDomain, TValue >::spanBegin(), DGtal::ImageContainerBySTLVector< TDomain, TValue >::spanEnd(), TEST_CASE(), testDirectIncidence(), testFaces(), testIncidence(), testNeighborhood(), testSCellsFunctors(), and DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::TiledIterator::TiledIterator().

◆ domain()

const Domain domain ( Point(1, 2)  ,
Point(6, 5)   
)

Referenced by SECTION().

◆ for()

for ( Domain::ConstIterator  it = domain.begin(),
it_end  = domain.end(); it != it_end; ++it,
++  cnt 
)

Definition at line 60 of file testSimpleRandomAccessRangeFromPoint.cpp.

61  {
62  image.setValue(*it, cnt*hour);
63  refImage.setValue(*it, cnt*hour);
64  }
void setValue(const Point &aPoint, const Value &aValue)
Definition: Image.h:247
Image refImage(domain)

References cnt, hour, refImage(), and DGtal::Image< TImageContainer >::setValue().

◆ image()

◆ refImage()

Image refImage ( domain  )

Referenced by for(), SECTION(), and testWriteAndRead().

◆ REQUIRE()

◆ SECTION() [1/18]

SECTION ( "Testing constant forward circulators"  )

Definition at line 259 of file testSimpleRandomAccessRangeFromPoint.cpp.

260  {
261  // Reference sum
262  Value refSum = 0;
263  for ( Image::ConstIterator it = refImage.begin(), it_end = refImage.end(); it != it_end; ++it )
264  {
265  refSum += 2 * (*it);
266  }
267 
268  // Sum in forward way
269  const Range range = image.range();
270  Value sum = 0;
271  cnt = 1;
272  for ( Range::ConstCirculator it = range.c(); cnt <= 2*domain.size(); ++it )
273  {
274  sum += *it;
275  ++cnt;
276  }
277  REQUIRE( sum == Approx(refSum) );
278  REQUIRE( std::equal( refImage.begin(), refImage.end(), range.c() ) );
279 
280  // Sum in backward way
281  sum = 0;
282  cnt = 1;
283  for ( Range::ConstCirculator it = range.c(); cnt <= 2*domain.size(); --it )
284  {
285  sum += *it;
286  ++cnt;
287  }
288  REQUIRE( sum == Approx(refSum) );
289 
290  // Sum in forward way
291  ConstRange crange = image.constRange();
292  sum = 0;
293  cnt = 1;
294  for ( Range::ConstCirculator it = crange.c(); cnt <= 2*domain.size(); ++it )
295  {
296  sum += *it;
297  ++cnt;
298  }
299  REQUIRE( sum == Approx(refSum) );
300  REQUIRE( std::equal( refImage.begin(), refImage.end(), crange.c() ) );
301 
302  // Sum in backward way
303  sum = 0;
304  cnt = 1;
305  for ( Range::ConstCirculator it = crange.c(); cnt <= 2*domain.size(); --it )
306  {
307  sum += *it;
308  ++cnt;
309  }
310  REQUIRE( sum == Approx(refSum) );
311  }
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition: Circulator.h:86
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
const Domain domain(Point(1, 2), Point(6, 5))
REQUIRE(domain.isInside(aPoint))

References DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::c(), cnt, domain(), refImage(), REQUIRE(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [2/18]

SECTION ( "Testing constant forward iterators from a point"  )

Definition at line 77 of file testSimpleRandomAccessRangeFromPoint.cpp.

78  {
79  const Range range = image.range();
80  REQUIRE( static_cast<Domain::Size>(range.end() - range.begin(aPoint)) == domain.size() - Linearizer::getIndex(aPoint, domain) );
81  REQUIRE( std::equal( range.begin(aPoint), range.end(), refImage.begin() + Linearizer::getIndex(aPoint, domain) ) );
82 
83  ConstRange crange = image.constRange();
84  REQUIRE( static_cast<Domain::Size>(crange.end() - crange.begin(aPoint)) == domain.size() - Linearizer::getIndex(aPoint, domain) );
85  REQUIRE( std::equal( crange.begin(aPoint), crange.end(), refImage.begin() + Linearizer::getIndex(aPoint, domain) ) );
86  }
const Point aPoint(3, 4)

References aPoint(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::begin(), domain(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::end(), refImage(), REQUIRE(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [3/18]

SECTION ( "Testing constant forward iterators"  )
Examples
doc-examples/exampleCatch.cpp.

Definition at line 66 of file testSimpleRandomAccessRangeFromPoint.cpp.

67  {
68  const Range range = image.range();
69  REQUIRE( static_cast<Domain::Size>(range.end() - range.begin()) == domain.size() );
70  REQUIRE( std::equal(range.begin(), range.end(), refImage.begin()) );
71 
72  ConstRange crange = image.constRange();
73  REQUIRE( static_cast<Domain::Size>(crange.end() - crange.begin()) == domain.size() );
74  REQUIRE( std::equal(crange.begin(), crange.end(), refImage.begin()) );
75  }

References DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::begin(), domain(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::end(), refImage(), REQUIRE(), and DGtal::HyperRectDomain< TSpace >::size().

Referenced by SCENARIO(), TEMPLATE_TEST_CASE(), TEST_CASE(), and TEST_CASE_METHOD().

◆ SECTION() [4/18]

SECTION ( "Testing constant reverse circulators"  )

Definition at line 313 of file testSimpleRandomAccessRangeFromPoint.cpp.

314  {
315  // Reference sum
316  Value refSum = 0;
317  for ( Image::ConstIterator it = refImage.begin(), it_end = refImage.end(); it != it_end; ++it )
318  {
319  refSum += 2 * (*it);
320  }
321 
322  // Sum in forward way
323  const Range range = image.range();
324  Value sum = 0;
325  cnt = 1;
326  for ( Range::ConstReverseCirculator it = range.rc(); cnt <= 2*domain.size(); ++it )
327  {
328  sum += *it;
329  ++cnt;
330  }
331  REQUIRE( sum == Approx(refSum) );
332  REQUIRE( std::equal( refImage.rbegin(), refImage.rend(), range.rc() ) );
333 
334  // Sum in backward way
335  sum = 0;
336  cnt = 1;
337  for ( Range::ConstReverseCirculator it = range.rc(); cnt <= 2*domain.size(); --it )
338  {
339  sum += *it;
340  ++cnt;
341  }
342  REQUIRE( sum == Approx(refSum) );
343 
344  // Sum in forward way
345  ConstRange crange = image.constRange();
346  sum = 0;
347  cnt = 1;
348  for ( Range::ConstReverseCirculator it = crange.rc(); cnt <= 2*domain.size(); ++it )
349  {
350  sum += *it;
351  ++cnt;
352  }
353  REQUIRE( sum == Approx(refSum) );
354  REQUIRE( std::equal( refImage.rbegin(), refImage.rend(), crange.rc() ) );
355 
356  // Sum in backward way
357  sum = 0;
358  cnt = 1;
359  for ( Range::ConstReverseCirculator it = crange.rc(); cnt <= 2*domain.size(); --it )
360  {
361  sum += *it;
362  ++cnt;
363  }
364  REQUIRE( sum == Approx(refSum) );
365  }
std::reverse_iterator< ConstCirculator > ConstReverseCirculator

References cnt, domain(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::rc(), refImage(), REQUIRE(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [5/18]

SECTION ( "Testing constant reverse iterators from a point"  )

Definition at line 141 of file testSimpleRandomAccessRangeFromPoint.cpp.

142  {
143  const Range range = image.range();
144  REQUIRE( static_cast<Domain::Size>(range.rend() - range.rbegin(aPoint)) == Linearizer::getIndex(aPoint, domain) + 1 );
145  REQUIRE( std::equal( range.rbegin(aPoint), range.rend(), refImage.rbegin() + (domain.size() - Linearizer::getIndex(aPoint, domain) - 1) ) );
146 
147  ConstRange crange = image.constRange();
148  REQUIRE( static_cast<Domain::Size>(crange.rend() - crange.rbegin(aPoint)) == Linearizer::getIndex(aPoint, domain) + 1 );
149  REQUIRE( std::equal( crange.rbegin(aPoint), crange.rend(), refImage.rbegin() + (domain.size() - Linearizer::getIndex(aPoint, domain) - 1) ) );
150  }

References aPoint(), domain(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::rbegin(), refImage(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::rend(), REQUIRE(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [6/18]

SECTION ( "Testing constant reverse iterators"  )

Definition at line 130 of file testSimpleRandomAccessRangeFromPoint.cpp.

131  {
132  const Range range = image.range();
133  REQUIRE( static_cast<Domain::Size>(range.rend() - range.rbegin()) == domain.size() );
134  REQUIRE( std::equal(range.rbegin(), range.rend(), refImage.rbegin()) );
135 
136  ConstRange crange = image.constRange();
137  REQUIRE( static_cast<Domain::Size>(crange.rend() - crange.rbegin()) == domain.size() );
138  REQUIRE( std::equal(crange.rbegin(), crange.rend(), refImage.rbegin()) );
139  }

References domain(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::rbegin(), refImage(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::rend(), REQUIRE(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [7/18]

SECTION ( "Testing forward output iterators from a point"  )

Definition at line 211 of file testSimpleRandomAccessRangeFromPoint.cpp.

212  {
213  Range range = image.range();
214 
215  cnt = 1;
216  for ( Domain::ConstIterator it = domain.begin(aPoint), it_end = domain.end(); it != it_end; ++it )
217  {
218  refImage.setValue( *it, refImage(*it)+cnt );
219  ++cnt;
220  }
221 
222  std::copy( refImage.begin() + Linearizer::getIndex(aPoint, domain), refImage.end(), range.outputIterator(aPoint) );
223 
224  REQUIRE( std::equal(range.begin(), range.end(), refImage.begin()) );
225  }
Iterator for HyperRectDomain.
const ConstIterator & end() const
const ConstIterator & begin() const

References aPoint(), DGtal::HyperRectDomain< TSpace >::begin(), cnt, domain(), DGtal::HyperRectDomain< TSpace >::end(), refImage(), REQUIRE(), and DGtal::Image< TImageContainer >::setValue().

◆ SECTION() [8/18]

SECTION ( "Testing forward output iterators"  )

Definition at line 195 of file testSimpleRandomAccessRangeFromPoint.cpp.

196  {
197  Range range = image.range();
198 
199  cnt = 1;
200  for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end; ++it )
201  {
202  refImage.setValue( *it, refImage(*it)+cnt );
203  ++cnt;
204  }
205 
206  std::copy( refImage.begin(), refImage.end(), range.outputIterator() );
207 
208  REQUIRE( std::equal(range.begin(), range.end(), refImage.begin()) );
209  }

References DGtal::HyperRectDomain< TSpace >::begin(), cnt, domain(), DGtal::HyperRectDomain< TSpace >::end(), refImage(), REQUIRE(), and DGtal::Image< TImageContainer >::setValue().

◆ SECTION() [9/18]

SECTION ( "Testing mutable circulators in backward way"  )

Definition at line 387 of file testSimpleRandomAccessRangeFromPoint.cpp.

388  {
389  Range range = image.range();
390 
391  cnt = 1;
392  for ( Range::Circulator it = --range.c(); cnt <= 2*domain.size(); --it )
393  {
394  *it += cnt++;
395  }
396 
397  cnt = 1;
398  for ( Domain::ConstReverseIterator it = domain.rbegin(), it_end = domain.rend(); it != it_end; ++it )
399  {
400  refImage.setValue( *it, refImage(*it) + 2*cnt + domain.size());
401  ++cnt;
402  }
403 
404  REQUIRE( std::equal( range.begin(), range.end(), refImage.begin() ) );
405  }
Reverse iterator for HyperRectDomain.
ConstReverseIterator rbegin() const
ConstReverseIterator rend() const

References cnt, domain(), DGtal::HyperRectDomain< TSpace >::rbegin(), refImage(), DGtal::HyperRectDomain< TSpace >::rend(), REQUIRE(), DGtal::Image< TImageContainer >::setValue(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [10/18]

SECTION ( "Testing mutable circulators in forward way"  )

Definition at line 367 of file testSimpleRandomAccessRangeFromPoint.cpp.

368  {
369  Range range = image.range();
370 
371  cnt = 1;
372  for ( Range::Circulator it = range.c(); cnt <= 2*domain.size(); ++it )
373  {
374  *it += cnt++;
375  }
376 
377  cnt = 1;
378  for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end; ++it )
379  {
380  refImage.setValue( *it, refImage(*it) + 2*cnt + domain.size());
381  ++cnt;
382  }
383 
384  REQUIRE( std::equal( range.begin(), range.end(), refImage.begin() ) );
385  }

References DGtal::HyperRectDomain< TSpace >::begin(), cnt, domain(), DGtal::HyperRectDomain< TSpace >::end(), refImage(), REQUIRE(), DGtal::Image< TImageContainer >::setValue(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [11/18]

SECTION ( "Testing mutable forward iterators from a point"  )

Definition at line 109 of file testSimpleRandomAccessRangeFromPoint.cpp.

110  {
111  Range range = image.range();
112  REQUIRE( static_cast<Domain::Size>(range.end() - range.begin(aPoint)) == domain.size() - Linearizer::getIndex(aPoint, domain) );
113 
114  cnt = 1;
115  for ( Range::Iterator it = range.begin(aPoint), it_end = range.end(); it != it_end; ++it )
116  {
117  *it += cnt++;
118  }
119 
120  cnt = 1;
121  for ( Domain::ConstIterator it = domain.begin(aPoint), it_end = domain.end(); it != it_end; ++it )
122  {
123  refImage.setValue( *it, refImage(*it)+cnt );
124  ++cnt;
125  }
126 
127  REQUIRE( std::equal(range.begin(), range.end(), refImage.begin()) );
128  }

References aPoint(), DGtal::HyperRectDomain< TSpace >::begin(), cnt, domain(), DGtal::HyperRectDomain< TSpace >::end(), refImage(), REQUIRE(), DGtal::Image< TImageContainer >::setValue(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [12/18]

SECTION ( "Testing mutable forward iterators"  )

Definition at line 88 of file testSimpleRandomAccessRangeFromPoint.cpp.

89  {
90  Range range = image.range();
91  REQUIRE( static_cast<Domain::Size>(range.end() - range.begin()) == domain.size() );
92 
93  cnt = 1;
94  for ( Range::Iterator it = range.begin(), it_end = range.end(); it != it_end; ++it )
95  {
96  *it += cnt++;
97  }
98 
99  cnt = 1;
100  for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end; ++it )
101  {
102  refImage.setValue( *it, refImage(*it)+cnt );
103  ++cnt;
104  }
105 
106  REQUIRE( std::equal(range.begin(), range.end(), refImage.begin()) );
107  }

References DGtal::HyperRectDomain< TSpace >::begin(), cnt, domain(), DGtal::HyperRectDomain< TSpace >::end(), refImage(), REQUIRE(), DGtal::Image< TImageContainer >::setValue(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [13/18]

SECTION ( "Testing mutable reverse circulators in backward way"  )

Definition at line 427 of file testSimpleRandomAccessRangeFromPoint.cpp.

428  {
429  Range range = image.range();
430 
431  cnt = 1;
432  for ( Range::ReverseCirculator it = --range.rc(); cnt <= 2*domain.size(); --it )
433  {
434  *it += cnt++;
435  }
436 
437  cnt = 1;
438  for ( Domain::ConstIterator it = domain.begin(), it_end = domain.end(); it != it_end; ++it )
439  {
440  refImage.setValue( *it, refImage(*it) + 2*cnt + domain.size());
441  ++cnt;
442  }
443 
444  REQUIRE( std::equal( range.begin(), range.end(), refImage.begin() ) );
445  }
std::reverse_iterator< Circulator > ReverseCirculator

References DGtal::HyperRectDomain< TSpace >::begin(), cnt, domain(), DGtal::HyperRectDomain< TSpace >::end(), refImage(), REQUIRE(), DGtal::Image< TImageContainer >::setValue(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [14/18]

SECTION ( "Testing mutable reverse circulators in forward way"  )

Definition at line 407 of file testSimpleRandomAccessRangeFromPoint.cpp.

408  {
409  Range range = image.range();
410 
411  cnt = 1;
412  for ( Range::ReverseCirculator it = range.rc(); cnt <= 2*domain.size(); ++it )
413  {
414  *it += cnt++;
415  }
416 
417  cnt = 1;
418  for ( Domain::ConstReverseIterator it = domain.rbegin(), it_end = domain.rend(); it != it_end; ++it )
419  {
420  refImage.setValue( *it, refImage(*it) + 2*cnt + domain.size());
421  ++cnt;
422  }
423 
424  REQUIRE( std::equal( range.begin(), range.end(), refImage.begin() ) );
425  }

References cnt, domain(), DGtal::HyperRectDomain< TSpace >::rbegin(), refImage(), DGtal::HyperRectDomain< TSpace >::rend(), REQUIRE(), DGtal::Image< TImageContainer >::setValue(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [15/18]

SECTION ( "Testing mutable reverse iterators from a point"  )

Definition at line 173 of file testSimpleRandomAccessRangeFromPoint.cpp.

174  {
175  Range range = image.range();
176  REQUIRE( static_cast<Domain::Size>(range.rend() - range.rbegin(aPoint)) == Linearizer::getIndex(aPoint, domain) + 1 );
177 
178  cnt = 1;
179  for ( Range::ReverseIterator it = range.rbegin(aPoint), it_end = range.rend(); it != it_end; ++it )
180  {
181  *it += cnt++;
182  }
183 
184 
185  cnt = 1;
186  for ( Domain::ConstReverseIterator it = domain.rbegin(aPoint), it_end = domain.rend(); it != it_end; ++it )
187  {
188  refImage.setValue( *it, refImage(*it)+cnt );
189  ++cnt;
190  }
191 
192  REQUIRE( std::equal(range.rbegin(), range.rend(), refImage.rbegin()) );
193  }

References aPoint(), cnt, domain(), DGtal::HyperRectDomain< TSpace >::rbegin(), refImage(), DGtal::HyperRectDomain< TSpace >::rend(), REQUIRE(), and DGtal::Image< TImageContainer >::setValue().

◆ SECTION() [16/18]

SECTION ( "Testing mutable reverse iterators"  )

Definition at line 152 of file testSimpleRandomAccessRangeFromPoint.cpp.

153  {
154  Range range = image.range();
155  REQUIRE( static_cast<Domain::Size>(range.rend() - range.rbegin()) == domain.size() );
156 
157  cnt = 1;
158  for ( Range::ReverseIterator it = range.rbegin(), it_end = range.rend(); it != it_end; ++it )
159  {
160  *it += cnt++;
161  }
162 
163  cnt = 1;
164  for ( Domain::ConstReverseIterator it = domain.rbegin(), it_end = domain.rend(); it != it_end; ++it )
165  {
166  refImage.setValue( *it, refImage(*it)+cnt );
167  ++cnt;
168  }
169 
170  REQUIRE( std::equal(range.rbegin(), range.rend(), refImage.rbegin()) );
171  }

References cnt, domain(), DGtal::HyperRectDomain< TSpace >::rbegin(), refImage(), DGtal::HyperRectDomain< TSpace >::rend(), REQUIRE(), DGtal::Image< TImageContainer >::setValue(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [17/18]

SECTION ( "Testing reverse output iterators from a point"  )

Definition at line 243 of file testSimpleRandomAccessRangeFromPoint.cpp.

244  {
245  Range range = image.range();
246 
247  cnt = 1;
248  for ( Domain::ConstReverseIterator it = domain.rbegin(aPoint), it_end = domain.rend(); it != it_end; ++it )
249  {
250  refImage.setValue( *it, refImage(*it)+cnt );
251  ++cnt;
252  }
253 
254  std::copy( refImage.rbegin() + (domain.size() - Linearizer::getIndex(aPoint, domain) - 1), refImage.rend(), range.routputIterator(aPoint) );
255 
256  REQUIRE( std::equal(range.rbegin(), range.rend(), refImage.rbegin()) );
257  }

References aPoint(), cnt, domain(), DGtal::HyperRectDomain< TSpace >::rbegin(), refImage(), DGtal::HyperRectDomain< TSpace >::rend(), REQUIRE(), DGtal::Image< TImageContainer >::setValue(), and DGtal::HyperRectDomain< TSpace >::size().

◆ SECTION() [18/18]

SECTION ( "Testing reverse output iterators"  )

Definition at line 227 of file testSimpleRandomAccessRangeFromPoint.cpp.

228  {
229  Range range = image.range();
230 
231  cnt = 1;
232  for ( Domain::ConstReverseIterator it = domain.rbegin(), it_end = domain.rend(); it != it_end; ++it )
233  {
234  refImage.setValue( *it, refImage(*it)+cnt );
235  ++cnt;
236  }
237 
238  std::copy( refImage.rbegin(), refImage.rend(), range.routputIterator() );
239 
240  REQUIRE( std::equal(range.rbegin(), range.rend(), refImage.rbegin()) );
241  }

References cnt, domain(), DGtal::HyperRectDomain< TSpace >::rbegin(), refImage(), DGtal::HyperRectDomain< TSpace >::rend(), REQUIRE(), and DGtal::Image< TImageContainer >::setValue().

Variable Documentation

◆ cnt

std::size_t cnt = 0

◆ hour

const double hour = 4.29

Definition at line 58 of file testSimpleRandomAccessRangeFromPoint.cpp.

Referenced by for().