31 #include "DGtal/base/Common.h"
32 #include "DGtal/base/CUnaryFunctor.h"
34 #include "DGtal/topology/SCellsFunctors.h"
36 #include "DGtal/topology/KhalimskySpaceND.h"
41 using namespace DGtal;
47 template <
typename TFunctor,
typename TArg,
typename TRes >
48 void checkingConcepts()
58 bool testSCellsFunctors()
60 unsigned int nbok = 0;
70 K3::SCell s = theKSpace.sPointel( K3::Point(3,3,4) );
71 K3::Point aPoint = m( s );
73 nbok += ( aPoint == K3::Point(3,3,4) ) ? 1 : 0;
76 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
82 K3::SCell s(K3::Point(0,0,0),
true);
83 theKSpace.sSetKCoords( s, K3::Point(5,6,8) );
84 K3::Point aPoint = m( s );
86 nbok += ( aPoint == K3::Point(3,3,4) ) ? 1 : 0;
89 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
95 K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
96 K2::Space::RealPoint aPoint = m( s );
98 nbok += ( aPoint == K2::Space::RealPoint(0,0.5) ) ? 1 : 0;
101 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
108 K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
109 std::pair<K2::Point, K2::Vector> aArrow = m( s );
110 trace.
info() << s << aArrow.first << aArrow.second <<std::endl;
113 nbok += ( ((aArrow.first == p) && (aArrow.second == v)) ) ? 1 : 0;
116 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
123 K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
124 K2::Point aPoint = m( s );
126 nbok += ( aPoint == K2::Point(-1,0) ) ? 1 : 0;
129 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
136 K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
137 K2::Point aPoint = m( s );
139 nbok += ( aPoint == K2::Point(0,0) ) ? 1 : 0;
142 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
149 K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
150 std::pair<K2::Point, K2::Point> aPair = m( s );
151 trace.
info() << s << aPair.first << aPair.second <<std::endl;
154 nbok += ( ((aPair.first == p1) && (aPair.second == p2)) ) ? 1 : 0;
157 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
164 K2::SCell s = theKSpace.sCell( K2::Point(0,1) );
167 nbok += ( aCode ==
'3' ) ? 1 : 0;
171 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") " << std::endl;
180 int main(
int argc,
char** argv )
184 for (
int i = 0; i < argc; ++i )
190 checkingConcepts<SCellToPoint<K2>, K2::SCell, K2::Point >();
191 checkingConcepts<SCellToMidPoint<K2>, K2::SCell, K2::Space::RealPoint >();
192 checkingConcepts<SCellToArrow<K2>, K2::SCell, std::pair<K2::Point, K2::Vector> >();
193 checkingConcepts<SCellToInnerPoint<K2>, K2::SCell, K2::Point >();
194 checkingConcepts<SCellToOuterPoint<K2>, K2::SCell, K2::Point >();
195 checkingConcepts<SCellToIncidentPoints<K2>, K2::SCell, std::pair<K2::Point, K2::Point> >();
196 checkingConcepts<SCellToCode<K2>, K2::SCell,
char >();
198 bool res = testSCellsFunctors();
199 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;