DGtal  1.5.beta
testDigitalSetToCellularGridConverter.cpp
Go to the documentation of this file.
1 
31 #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 // //
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Definition: Flower2D.h:65
const Point & lowerBound() const
const Point & upperBound() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
KSpace K
std::unordered_map< Cell, CubicalCellData > Map
CubicalComplex< KSpace, Map > CC
int main(int, char **)
bool test(const I &itb, const I &ite)
PointVector< 3, double > RealPoint