DGtal  1.4.beta
testParDirCollapse.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/CubicalComplex.h"
#include "DGtal/topology/ParDirCollapse.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/shapes/EuclideanShapesDecorator.h"
#include "DGtal/shapes/parametric/Flower2D.h"
Include dependency graph for testParDirCollapse.cpp:

Go to the source code of this file.

Functions

template<typename CC , typename KSpace >
void getComplex (CC &complex, KSpace &K)
 
 TEST_CASE ("Testing ParDirCollapse")
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Kacper Pluta (kacpe.nosp@m.r.pl.nosp@m.uta@e.nosp@m.siee.nosp@m..fr ) Laboratoire d'Informatique Gaspard-Monge - LIGM, France
Date
2016/01/16

Functions for testing class ParDirCollapse.

This file is part of the DGtal library.

Definition in file testParDirCollapse.cpp.

Function Documentation

◆ getComplex()

template<typename CC , typename KSpace >
void getComplex ( CC complex,
KSpace K 
)

Definition at line 55 of file testParDirCollapse.cpp.

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 }
void construct(const TDigitalSet &set)
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
void attach(ConstAlias< EuclideanShape > shape)
const Point & lowerBound() const
const Point & upperBound() const
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).
KSpace K
PointVector< 3, double > RealPoint

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), DGtal::CubicalComplex< TKSpace, TCellContainer >::clear(), DGtal::CubicalComplex< TKSpace, TCellContainer >::construct(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), and DGtal::HyperRectDomain< TSpace >::upperBound().

◆ TEST_CASE()

TEST_CASE ( "Testing ParDirCollapse )

Definition at line 73 of file testParDirCollapse.cpp.

74 {
75  typedef map<Cell, CubicalCellData> Map;
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 }
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Aim: Implements thinning algorithms in cubical complexes. The implementation supports any model of cu...
std::unordered_map< Cell, CubicalCellData > Map
CubicalComplex< KSpace, Map > CC
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))

References DGtal::ParDirCollapse< CC >::attach(), DGtal::ParDirCollapse< CC >::collapseIsthmus(), DGtal::ParDirCollapse< CC >::collapseSurface(), DGtal::CubicalComplex< TKSpace, TCellContainer >::euler(), DGtal::ParDirCollapse< CC >::eval(), K, REQUIRE(), and SECTION().