DGtal 1.4.0
Loading...
Searching...
No Matches
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
45using namespace std;
46using namespace DGtal;
47using namespace functors;
48using namespace Z2i;
49
51// Functions for testing class digitalSetToCubicalComplexes.
53class testDigitalSetToCellularGridConverter
54{
55 typedef Flower2D< Space > MyEuclideanShape;
56 typedef map<Cell, CubicalCellData> Map;
58 typedef GaussDigitizer< Space, MyEuclideanShape > MyGaussDigitizer;
59private:
60 KSpace K;
61 MyGaussDigitizer digShape;
62public:
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
82int 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();
90 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
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.
static void digitalShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor)
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
double endBlock()
Space::RealPoint RealPoint
Definition StdDefs.h:97
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
int main()
Definition testBits.cpp:56
KSpace K
std::unordered_map< Cell, CubicalCellData > Map
bool test(const I &itb, const I &ite)