DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testParDirCollapse.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "ConfigTest.h"
34
#include "DGtalCatch.h"
35
#include "DGtal/helpers/StdDefs.h"
36
// Cellular grid
37
#include "DGtal/topology/CubicalComplex.h"
38
#include "DGtal/topology/ParDirCollapse.h"
39
// Shape construction
40
#include "DGtal/shapes/GaussDigitizer.h"
41
#include "DGtal/shapes/Shapes.h"
42
#include "DGtal/shapes/EuclideanShapesDecorator.h"
43
#include "DGtal/shapes/parametric/Flower2D.h"
45
46
using namespace
std
;
47
using namespace
DGtal
;
48
using namespace
Z2i
;
49
51
// Functions for testing class ParDirCollapse.
53
54
template
<
typename
CC,
typename
KSpace>
55
void
getComplex
(
CC
& complex,
KSpace
&
K
)
56
{
57
typedef
Flower2D< Space >
MyEuclideanShape;
58
MyEuclideanShape shape(
RealPoint
( 0.0, 0.0 ), 16, 5, 5, M_PI_2/2. );
59
60
typedef
GaussDigitizer< Space, MyEuclideanShape >
MyGaussDigitizer;
61
MyGaussDigitizer digShape;
62
digShape.
attach
( shape );
63
digShape.init ( shape.getLowerBound(), shape.getUpperBound(), 1.0 );
64
Domain
domainShape = digShape.getDomain();
65
DigitalSet
aSet( domainShape );
66
Shapes<Domain>::digitalShaper
( aSet, digShape );
67
68
K
.
init
( domainShape.lowerBound(), domainShape.upperBound(),
true
);
69
complex.clear();
70
complex.construct ( aSet );
71
}
72
73
TEST_CASE
(
"Testing ParDirCollapse"
)
74
{
75
typedef
map<Cell, CubicalCellData>
Map
;
76
typedef
CubicalComplex< KSpace, Map >
CC
;
77
KSpace
K
;
78
CC
complex (
K
);
79
ParDirCollapse < CC > thinning (
K
);
80
81
SECTION
(
"Testing the basic algorithm of ParDirCollapse"
)
82
{
83
getComplex< CC, KSpace >
( complex,
K
);
84
int
eulerBefore = complex.euler();
85
thinning.
attach
( &complex );
86
REQUIRE
( ( thinning.
eval
( 2 ) != 0 ) );
87
REQUIRE
( (eulerBefore == complex.euler()) );
88
}
89
90
SECTION
(
"Testing ParDirCollapse::collapseSurface"
)
91
{
92
getComplex< CC, KSpace >
( complex,
K
);
93
int
eulerBefore = complex.euler();
94
thinning.
attach
( &complex );
95
thinning.
collapseSurface
();
96
REQUIRE
( (eulerBefore == complex.euler()) );
97
}
98
SECTION
(
"Testing ParDirCollapse::collapseIsthmus"
)
99
{
100
getComplex< CC, KSpace >
( complex,
K
);
101
int
eulerBefore = complex.euler();
102
thinning.
attach
( &complex );
103
thinning.
collapseIsthmus
();
104
REQUIRE
( (eulerBefore == complex.euler()) );
105
}
106
}
107
DGtal::CubicalComplex< KSpace, Map >
DGtal::Flower2D< Space >
DGtal::GaussDigitizer< Space, MyEuclideanShape >
DGtal::GaussDigitizer::attach
void attach(ConstAlias< EuclideanShape > shape)
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::ParDirCollapse::collapseSurface
void collapseSurface()
DGtal::ParDirCollapse::attach
void attach(Alias< CC > pComplex)
DGtal::ParDirCollapse::collapseIsthmus
void collapseIsthmus()
DGtal::ParDirCollapse::eval
unsigned int eval(unsigned int iterations)
DGtal::Shapes::digitalShaper
static void digitalShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor)
DGtal::Domain
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal::Z2i::KSpace
KhalimskySpaceND< 2, Integer > KSpace
Definition
StdDefs.h:77
DGtal::Z2i::RealPoint
Space::RealPoint RealPoint
Definition
StdDefs.h:97
DGtal::Z2i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:100
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
TEST_CASE
TEST_CASE("int container traits", "[int][traits]")
Definition
testContainerTraits.cpp:53
K
KSpace K
Definition
testCubicalComplex.cpp:62
Map
std::unordered_map< Cell, CubicalCellData > Map
Definition
testCubicalComplex.cpp:57
CC
CubicalComplex< KSpace, Map > CC
Definition
testCubicalComplex.cpp:58
getComplex
void getComplex(CC &complex, KSpace &K)
Definition
testParDirCollapse.cpp:55
SECTION
SECTION("Testing constant forward iterators")
Definition
testSimpleRandomAccessRangeFromPoint.cpp:66
REQUIRE
REQUIRE(domain.isInside(aPoint))
tests
topology
testParDirCollapse.cpp
Generated on
for DGtal by
1.18.0