DGtal  1.3.beta
Typedefs | Functions | Variables
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

Definition at line 47 of file testSimpleRandomAccessRangeFromPoint.cpp.

◆ Domain

◆ Image

◆ Linearizer

Definition at line 48 of file testSimpleRandomAccessRangeFromPoint.cpp.

◆ Point

Definition at line 43 of file testSimpleRandomAccessRangeFromPoint.cpp.

◆ Range

◆ Space

typedef SpaceND<2> Space

◆ Value

typedef double Value

Function Documentation

◆ aPoint()

const Point aPoint ( ,
 
)

Referenced by DGtal::DefaultConstImageRange< TImage >::begin(), DGtal::DefaultImageRange< TImage >::begin(), DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::begin(), DGtal::TiledImageBidirectionalConstRangeFromPoint< TTiledImage >::begin(), DGtal::HyperRectDomain< Space >::begin(), DGtal::TiledImageBidirectionalRangeFromPoint< TTiledImage >::begin(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::begin(), DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::begin(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstRange::begin(), DGtal::HyperRectDomain< TSpace >::ConstSubRange::begin(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::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 >::getVoronoiVector(), DGtal::DistanceFunctorFromPoint< TImage >::operator()(), DGtal::functors::SimpleThresholdForegroundPredicate< Image >::operator()(), DGtal::functors::IntervalForegroundPredicate< Image >::operator()(), DGtal::ImplicitBall< TSpace >::operator()(), DGtal::ImplicitHyperCube< TSpace >::operator()(), DGtal::ImplicitNorm1Ball< TSpace >::operator()(), DGtal::ImplicitRoundedHyperCube< TSpace >::operator()(), DGtal::ParametricShapeTangentFunctor< TParametricShape >::operator()(), DGtal::ParametricShapeCurvatureFunctor< TParametricShape >::operator()(), DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::operator()(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::operator()(), DGtal::ReverseDistanceTransformation< TWeightImage, TPSeparableMetric, TImageContainer >::operator()(), DGtal::DistanceTransformation< 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::PowerMap< TWeightImage, TPSeparableMetric, ImageContainerBySTLVector< HyperRectDomain< typename TWeightImage::Domain::Space >, typename TWeightImage::Domain::Space::Vector > >::operator()(), DGtal::ArrayImageAdapter< TArrayIterator, HyperRectDomain< TSpace > >::operator()(), DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, ImageContainerBySTLVector< HyperRectDomain< TSpace >, typename TSpace::Vector > >::operator()(), DGtal::functors::SliceRotator2D< TDomain3D, TInteger >::operator()(), DGtal::ImageToConstantFunctor< Image, PointPredicate, TValue >::operator()(), DGtal::IteratorCompletionTraits< ArrayImageAdapter< TArrayIterator, TDomain > >::DistanceFunctor::operator()(), DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::operator()(), DGtal::functors::BasicDomainSubSampler< TDomain, TInteger, TValue >::operator()(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::operator()(), DGtal::functors::FlipDomainAxis< TDomain >::operator()(), DGtal::DigitalSetInserter< TDigitalSet >::operator=(), DGtal::DefaultImageRange< TImage >::outputIterator(), DGtal::TiledImageBidirectionalRangeFromPoint< TTiledImage >::outputIterator(), DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::outputIterator(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::outputIterator(), DGtal::DefaultConstImageRange< TImage >::rbegin(), DGtal::DefaultImageRange< TImage >::rbegin(), DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rbegin(), DGtal::TiledImageBidirectionalConstRangeFromPoint< TTiledImage >::rbegin(), DGtal::HyperRectDomain< Space >::rbegin(), DGtal::SimpleRandomAccessConstRangeFromPoint< TConstIterator, DistanceFunctor >::rbegin(), DGtal::functors::ConstImageFunctorHolder< TDomain, TValue, TFunctor >::ConstRange::rbegin(), DGtal::TiledImageBidirectionalRangeFromPoint< TTiledImage >::rbegin(), DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::rbegin(), DGtal::HyperRectDomain< TSpace >::ConstSubRange::rbegin(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::rbegin(), DGtal::DefaultImageRange< TImage >::routputIterator(), DGtal::TiledImageBidirectionalRangeFromPoint< TTiledImage >::routputIterator(), DGtal::SimpleRandomAccessRangeFromPoint< TConstIterator, TIterator, DistanceFunctor >::routputIterator(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::routputIterator(), SECTION(), DGtal::ArrayImageAdapter< TArrayIterator, HyperRectDomain< TSpace > >::setValue(), DGtal::Image< TImageContainer >::setValue(), DGtal::ImageAdapter< TImageContainer, TNewDomain, TFunctorD, TNewValue, TFunctorV, TFunctorVm1 >::setValue(), DGtal::TiledImage< TImageContainer, TImageFactory, TImageCacheReadPolicy, TImageCacheWritePolicy >::setValue(), DGtal::ImageContainerBySTLVector< Domain, Storage * >::spanBegin(), DGtal::ImageContainerBySTLVector< Domain, Storage * >::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  }

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

◆ image()

Image image ( domain  )

◆ refImage()

Image refImage ( domain  )

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

◆ REQUIRE()

REQUIRE ( domain.  isInsideaPoint)

◆ 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  }

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  }

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  }

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  }

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  }

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  }

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().

DGtal::HyperRectDomain::rend
ConstReverseIterator rend() const
Definition: HyperRectDomain.h:236
DGtal::Image::setValue
void setValue(const Point &aPoint, const Value &aValue)
Definition: Image.h:247
DGtal::Circulator
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition: Circulator.h:85
DGtal::HyperRectDomain::size
Size size() const
Definition: HyperRectDomain.h:565
DGtal::SimpleRandomAccessConstRangeFromPoint
Aim: model of CConstBidirectionalRangeFromPoint that adapts any range of elements bounded by two iter...
Definition: SimpleRandomAccessConstRangeFromPoint.h:73
DGtal::SimpleRandomAccessRangeFromPoint::ReverseCirculator
std::reverse_iterator< Circulator > ReverseCirculator
Definition: SimpleRandomAccessRangeFromPoint.h:96
DGtal::HyperRectDomain_ReverseIterator
Reverse iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:66
DGtal::SimpleRandomAccessConstRangeFromPoint::rend
ConstReverseIterator rend() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:240
DGtal::SimpleRandomAccessRangeFromPoint::Iterator
TIterator Iterator
Definition: SimpleRandomAccessRangeFromPoint.h:86
aPoint
const Point aPoint(3, 4)
DGtal::ImageContainerBySTLVector< Domain, Value >::ConstIterator
std::vector< Value >::const_iterator ConstIterator
Definition: ImageContainerBySTLVector.h:265
DGtal::SimpleRandomAccessConstRangeFromPoint::begin
ConstIterator begin() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:191
REQUIRE
REQUIRE(domain.isInside(aPoint))
DGtal::HyperRectDomain< Space >::Size
Space::Size Size
Definition: HyperRectDomain.h:117
DGtal::SimpleRandomAccessRangeFromPoint::ReverseIterator
std::reverse_iterator< Iterator > ReverseIterator
Definition: SimpleRandomAccessRangeFromPoint.h:89
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::SimpleRandomAccessRangeFromPoint
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
Definition: SimpleRandomAccessRangeFromPoint.h:73
DGtal::SimpleRandomAccessConstRangeFromPoint::rbegin
ConstReverseIterator rbegin() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:220
DGtal::HyperRectDomain::end
const ConstIterator & end() const
Definition: HyperRectDomain.h:201
hour
const double hour
Definition: testSimpleRandomAccessRangeFromPoint.cpp:58
DGtal::SimpleRandomAccessConstRangeFromPoint::c
ConstCirculator c() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:249
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:142
cnt
std::size_t cnt
Definition: testSimpleRandomAccessRangeFromPoint.cpp:59
DGtal::SimpleRandomAccessConstRangeFromPoint::rc
ConstReverseCirculator rc() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:258
refImage
Image refImage(domain)
domain
const Domain domain(Point(1, 2), Point(6, 5))
DGtal::HyperRectDomain::begin
const ConstIterator & begin() const
Definition: HyperRectDomain.h:176
DGtal::HyperRectDomain::rbegin
ConstReverseIterator rbegin() const
Definition: HyperRectDomain.h:210
DGtal::SimpleRandomAccessConstRangeFromPoint::end
ConstIterator end() const
Definition: SimpleRandomAccessConstRangeFromPoint.h:211
Value
double Value
Definition: testSimpleRandomAccessRangeFromPoint.cpp:38
DGtal::SimpleRandomAccessRangeFromPoint::ConstReverseCirculator
std::reverse_iterator< ConstCirculator > ConstReverseCirculator
Definition: SimpleRandomAccessRangeFromPoint.h:99