DGtal  0.9.3
testDigitalTopology.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/kernel/SpaceND.h"
34 #include "DGtal/topology/MetricAdjacency.h"
35 #include "DGtal/topology/DigitalTopology.h"
37 
38 using namespace std;
39 using namespace DGtal;
40 
42 // Functions for testing class DigitalTopology.
44 
49 {
50  unsigned int nbok = 0;
51  unsigned int nb = 0;
52 
53  typedef SpaceND< 2 > Zi2;
54  typedef MetricAdjacency< Zi2, 1 > Adj4;
55  typedef MetricAdjacency< Zi2, 2 > Adj8;
56  Adj4 adj4;
57  Adj8 adj8;
58 
59  trace.beginBlock ( "Testing Digital topology (4,8) in Z2." );
60  typedef DigitalTopology< Adj4, Adj8 > DT48;
61  DT48 dt( adj4, adj8, JORDAN_DT );
62  nbok += true ? 1 : 0;
63  nb++;
64  trace.info() << "(" << nbok << "/" << nb << ") "
65  << dt << std::endl;
66  typedef DT48::ReverseTopology DT84;
67  DT84 opp_dt = dt.reverseTopology();
68  nbok += true ? 1 : 0;
69  nb++;
70  trace.info() << "(" << nbok << "/" << nb << ") "
71  << opp_dt << std::endl;
72  trace.endBlock();
73 
74  // should not compile
75  // typedef DigitalTopology< Adj4, bool > DTimpossible;
76  // DTimpossible dti( adj4, true );
77 
78  return nbok == nb;
79 }
80 
82 // Standard services - public :
83 
84 int main( int argc, char** argv )
85 {
86  trace.beginBlock ( "Testing class DigitalTopology" );
87  trace.info() << "Args:";
88  for ( int i = 0; i < argc; ++i )
89  trace.info() << " " << argv[ i ];
90  trace.info() << endl;
91 
92  bool res = testDigitalTopologyZ2(); // && ... other tests
93  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
94  trace.endBlock();
95  return res ? 0 : 1;
96 }
97 // //
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
int main(int argc, char **argv)
STL namespace.
double endBlock()
Aim: Describes digital adjacencies in digital spaces that are defined with the 1-norm and the infinit...
Aim: Represents a digital topology as a couple of adjacency relations.
std::ostream & emphase()
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & info()
bool testDigitalTopologyZ2()