36 #include "DGtal/base/Common.h" 37 #include "DGtal/base/CUnaryFunctor.h" 38 #include "DGtal/kernel/PointVector.h" 39 #include "DGtal/kernel/SpaceND.h" 40 #include "DGtal/kernel/BasicPointFunctors.h" 41 #include "DGtal/kernel/domains/HyperRectDomain.h" 43 using namespace DGtal;
46 template <
typename TFunctor,
typename TArg,
typename TRes >
54 unsigned int nbok = 0;
64 std::vector<Dimension> v1, v2;
65 v1.push_back(0); v1.push_back(2);
66 v2.push_back(2); v2.push_back(1);
67 Projector2D proj1, proj2, proj3;
68 proj1.
init(v1.begin(), v1.end());
69 proj2.init(v2.begin(), v2.end());
73 trace.
info() <<
"p " << p <<
" => " << proj1(p) <<
" == " << res1 << std::endl;
74 nbok += ( proj1(p) == res1 ) ? 1 : 0;
78 trace.
info() <<
"p " << p <<
" => " << proj2(p) <<
" == " << res2 << std::endl;
79 nbok += ( proj2(p) == res2 ) ? 1 : 0;
83 trace.
info() <<
"p " << p <<
" => " << proj3(p) <<
" == " << res3 << std::endl;
84 nbok += ( proj3(p) == res3 ) ? 1 : 0;
96 std::vector<Dimension> v1, v2, v4;
97 v1.push_back(0); v1.push_back(2); v1.push_back(1);
98 v2.push_back(1); v2.push_back(0);
100 Projector3D proj1, proj2, proj3;
101 proj1.init(v1.begin(), v1.end());
102 proj2.init(v2.begin(), v2.end());
103 Projector3D proj4(-1);
104 proj4.init(v4.begin(), v4.end());
118 trace.
info() <<
"pt " << pt <<
" => " << sliceRot(pt) <<
" == " << ptR << std::endl;
119 nbok += ( sliceRot(pt) == ptR ) ? 1 : 0;
122 trace.
info() <<
"pt " << pt_2 <<
" => " << sliceRot2(pt_2) <<
" == " << ptR2 << std::endl;
123 nbok += ( sliceRot2(pt_2) == ptR2 ) ? 1 : 0;
166 trace.
info() <<
"p " << p <<
" => " << proj1(p) <<
" == " << res1 << std::endl;
167 nbok += ( proj1(p) == res1 ) ? 1 : 0;
171 trace.
info() <<
"p " << p <<
" => " << proj2(p) <<
" == " << res2 << std::endl;
172 nbok += ( proj2(p) == res2 ) ? 1 : 0;
176 trace.
info() <<
"p " << p <<
" => " << proj3(p) <<
" == " << res3 << std::endl;
177 nbok += ( proj3(p) == res3 ) ? 1 : 0;
181 trace.
info() <<
"p " << p <<
" => " << proj4(p) <<
" == " << res4
182 <<
"(-1 as default value)" << std::endl;
183 nbok += ( proj4(p) == res4 ) ? 1 : 0;
193 std::vector< SpaceND<2, int>::Size > aGridSize;
194 aGridSize.push_back(5);
195 aGridSize.push_back(5);
198 aGridSize, shiftVector);
199 trace.
info()<<
"Subsampling functor on 2D domain " << domainSource <<
" with grid size " 200 << aGridSize[0] <<
" " << aGridSize[1] <<
" and shift vector "<< shiftVector <<std::endl ;
203 trace.
info() <<
"Sampling point of coordinate "<< pointTest <<
", => coordinates in source domain:" 210 std::vector< SpaceND<3, int>::Size > aGridSize3D;
211 aGridSize3D.push_back(5);
212 aGridSize3D.push_back(3);
213 aGridSize3D.push_back(1);
216 aGridSize3D, shiftVector3D);
217 trace.
info()<<
"Subsampling functor on 3D domain " << domainSource3D <<
" with grid size " 218 << aGridSize3D[0] <<
" " << aGridSize3D[1]<<
" " << aGridSize3D[2] <<
" and shift vector "<< shiftVector3D <<std::endl ;
223 trace.
info() <<
"Sampling point of coordinate "<< pointTest3D <<
", => coordinates in source domain:" 225 trace.
info() <<
"Sampling point of coordinate "<< pointTest3D2 <<
", => coordinates in source domain:" 232 std::vector<unsigned int> vectFlip;
233 vectFlip.push_back(1);
234 vectFlip.push_back(2);
236 trace.
info() <<
"Flip point of coordinate "<< pointTest3D <<
", => fliped coordinates with axis 1 and 2:" 237 << flipFunctorAxis12(pointTest3D) <<
" == " <<
PointVector<3,int>(0, 9, 8) << std::endl;
244 std::vector< double > aGridSizeReSample;
245 aGridSizeReSample.push_back(0.25);
246 aGridSizeReSample.push_back(0.5);
249 aGridSizeReSample, shiftVector);
251 trace.
info()<<
"Resampling functor on 2D domain " << domainSource <<
" with grid size " 252 << aGridSizeReSample[0] <<
" " << aGridSizeReSample[1] <<
" and shift vector "<< shiftVector <<std::endl ;
255 trace.
info() <<
"Sampling point of coordinate "<< pointTestRS <<
", => coordinates in source domain:" 269 int main(
int argc,
char** argv )
273 for (
int i = 0; i < argc; ++i )
285 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
void beginBlock(const std::string &keyword="")
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an ...
Aim: Functor that subsamples an initial domain by given a grid size and a shift vector....
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Defines a unary functor, which associates arguments to results.
Aim: Functor that embeds a 2D point into a 3D space from two axis vectors and an origin point given i...
Aim: Functor that flips the domain coordinate system from some selected axis. For instance,...
DGtal is the top-level namespace which contains all DGtal functions and types.
void init(const TIterator &itb, const TIterator &ite)
int main(int argc, char **argv)
boost::int32_t int32_t
signed 32-bit integer.
Special Point Functor that adds one dimension to a 2D point and apply on it a rotation of angle alpha...