DGtal  0.9.3
Functions
testImageSpanIterators.cpp File Reference
#include <cstdio>
#include <cmath>
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
Include dependency graph for testImageSpanIterators.cpp:

Go to the source code of this file.

Functions

bool testSpanIterators ()
 
int main ()
 

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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr )
Date
2010/05/25

This file is part of the DGtal library

Definition in file testImageSpanIterators.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 124 of file testImageSpanIterators.cpp.

References testSpanIterators().

125 {
126 
127  if ( testSpanIterators())
128  return 0;
129  else
130  return 1;
131 }
bool testSpanIterators()

◆ testSpanIterators()

bool testSpanIterators ( )

Definition at line 46 of file testImageSpanIterators.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

47 {
48  typedef SpaceND<3> Space3Type;
49  typedef Space3Type::Point Point;
50  typedef HyperRectDomain<Space3Type> TDomain;
52 
53  const Point::Component t[ ] = { 0, 0, 0};
54  const Point::Component t2[ ] = { 5, 5, 5};
55  const Point::Component t3[ ] = { 0, 0, 0};
56  Point a ( t );
57  Point b ( t2 );
58  Point c( t3 );
59 
60  trace.beginBlock("Test of Concepts");
61  TContainerV myImageV ( TDomain(a,b ));
62 
63  double cpt=0;
64  //Image Construction
65  for ( TContainerV::Iterator it = myImageV.begin();
66  it != myImageV.end();
67  ++it)
68  {
69  (*it) = cpt ;
70  cpt++;
71  }
72 
73 
74  //We process a 1D slice
75  trace.info()<<"Slice dim 0 ";
76  for ( TContainerV::SpanIterator it = myImageV.spanBegin(c,0), itend = myImageV.spanEnd(c,0);
77  it != itend;
78  ++it)
79  trace.info() << (*it)<<" ";
80  trace.info() << endl;
81 
82  //We process a 1D slice
83  trace.info()<<"Slice dim 1 ";
84  for ( TContainerV::SpanIterator it = myImageV.spanBegin(c,1), itend = myImageV.spanEnd(c,1);
85  it != itend;
86  ++it)
87  trace.info() << (*it)<<" ";
88  trace.info() << endl;
89 
90  //We process a 1D slice
91  trace.info()<<"Slice dim 2 ";
92  for ( TContainerV::SpanIterator it = myImageV.spanBegin(c,2), itend = myImageV.spanEnd(c,2);
93  it != itend;
94  ++it)
95  trace.info() << (*it)<<" ";
96  trace.info() << endl;
97 
98 
99  //We process a 1D slice to set a value
100  trace.info()<<"SetValue Slice dim 1 "<<endl;
101  for ( TContainerV::SpanIterator it = myImageV.spanBegin(c,1), itend = myImageV.spanEnd(c,1);
102  it != itend;
103  ++it)
104  myImageV.setValue(it, 12);
105 
106  //We check the a 1D slice
107  trace.info()<<"Check Slice dim 1 ";
108  for ( TContainerV::SpanIterator it = myImageV.spanBegin(c,1), itend = myImageV.spanEnd(c,1);
109  it != itend;
110  ++it)
111  trace.info() << (*it)<<" ";
112  trace.info() << endl;
113 
114 
115 
116  trace.endBlock();
117 
118  return true;
119 
120 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
Aim: SpaceND is a utility class that defines the fundamental structure of a Digital Space in ND...
Definition: SpaceND.h:95
Aim: Parallelepidec region of a digital space, model of a &#39;CDomain&#39;.
double endBlock()
MyPointD Point
Definition: testClone2.cpp:383
std::ostream & info()