DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testDigitalTopology.cpp
1 
30 
31 #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 
48 bool testDigitalTopologyZ2()
49 {
50  unsigned int nbok = 0;
51  unsigned int nb = 0;
52 
53  typedef SpaceND< 2 > Zi2;
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 // //