DGtal  0.9.2
testDigitalSetToCellularGridConverter.cpp
1 
30 #include <iostream>
32 #include <map>
33 #include "DGtal/base/Common.h"
34 #include "ConfigTest.h"
35 #include "DGtal/helpers/StdDefs.h"
36 // Cellular grid converter
37 #include "DGtal/topology/CubicalComplex.h"
38 // Shape construction
39 #include "DGtal/shapes/GaussDigitizer.h"
40 #include "DGtal/shapes/Shapes.h"
41 #include "DGtal/shapes/EuclideanShapesDecorator.h"
42 #include "DGtal/shapes/parametric/Flower2D.h"
44 
45 using namespace std;
46 using namespace DGtal;
47 using namespace functors;
48 using namespace Z2i;
49 
51 // Functions for testing class digitalSetToCubicalComplexes.
53 class testDigitalSetToCellularGridConverter
54 {
55  typedef Flower2D< Space > MyEuclideanShape;
56  typedef map<Cell, CubicalCellData> Map;
58  typedef GaussDigitizer< Space, MyEuclideanShape > MyGaussDigitizer;
59 private:
60  KSpace K;
61  MyGaussDigitizer digShape;
62 public:
63  testDigitalSetToCellularGridConverter () {}
64  bool extractCells()
65  {
66  MyEuclideanShape shape( RealPoint( 0.0, 0.0 ), 16, 5, 5, M_PI_2/2. );
67  digShape.attach( shape );
68  digShape.init ( shape.getLowerBound(), shape.getUpperBound(), 1.0 );
69  Domain domainShape = digShape.getDomain();
70  K.init ( domainShape.lowerBound(), domainShape.upperBound(), true );
71  DigitalSet aSet ( domainShape );
72  Shapes<Domain>::digitalShaper ( aSet, digShape );
73 
74  CC complex ( K );
75  complex.construct < DigitalSet > ( aSet );
76  return true;
77  }
78 };
80 // Standard services - public :
81 
82 int main( int /* argc */, char** /* argv */ )
83 {
84  bool res = true;
85  testDigitalSetToCellularGridConverter test;
86  trace.beginBlock ( "DigitalSetToCellularGridConverter" );
87  trace.beginBlock ( "Testing extraction of 0D cells" );
88  res &= test.extractCells();
89  trace.endBlock();
90  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
91  trace.endBlock();
92  return res ? 0 : 1;
93 }
94 // //
void beginBlock(const std::string &keyword="")
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
Trace trace
Definition: Common.h:130
KhalimskySpaceND< 2, Integer > KSpace
Definition: StdDefs.h:77
STL namespace.
double endBlock()
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Definition: Flower2D.h:64
std::ostream & emphase()
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
const Point & upperBound() const
DGtal is the top-level namespace which contains all DGtal functions and types.
Space::RealPoint RealPoint
Definition: StdDefs.h:97
const Point & lowerBound() const
Aim: A utility class for constructing different shapes (balls, diamonds, and others).