DGtal  1.3.beta
Functions
testShortcuts.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/Shortcuts.h"
#include "DGtalCatch.h"
Include dependency graph for testShortcuts.cpp:

Go to the source code of this file.

Functions

 SCENARIO ("Shortcuts< K3 > pointel ordering", "[shortcuts][pointel]")
 

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
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2015/08/28

Functions for testing class Shortcuts.

This file is part of the DGtal library.

Definition in file testShortcuts.cpp.

Function Documentation

◆ SCENARIO()

SCENARIO ( "Shortcuts< K3 > pointel ordering"  ,
""  [shortcuts][pointel] 
)

Definition at line 45 of file testShortcuts.cpp.

46 {
48  typedef Shortcuts< KSpace > SH3;
49 
50  auto params = SH3::defaultParameters();
51  const double h = 0.25;
52  params( "polynomial", "goursat" )( "gridstep", h );
53  auto implicit_shape = SH3::makeImplicitShape3D ( params );
54  auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
55  auto binary_image = SH3::makeBinaryImage ( digitized_shape, params );
56  auto K = SH3::getKSpace( params );
57  auto embedder = SH3::getCellEmbedder( K );
58  auto surface = SH3::makeLightDigitalSurface( binary_image, K, params );
59 
60  GIVEN( "A digital surface, its associated polygonal surface, and its pointel range" ) {
61  SH3::Cell2Index c2i;
62  auto polySurf = SH3::makePrimalPolygonalSurface( c2i, surface );
63  auto pointels = SH3::getPointelRange( surface );
64  THEN( "The polygonal surface and the pointel range have the same number of pointels" ) {
65  REQUIRE( pointels.size() == polySurf->nbVertices() );
66  }
67  THEN( "The vertices of the polygonal surface are in the same order as the pointel range" ) {
68  unsigned int nb_ok = 0, nb_ko = 0;
69  for ( auto i = 0; i < polySurf->nbVertices(); i++ )
70  {
71  auto p = pointels[ i ];
72  auto idx = c2i[ p ];
73  if ( i != idx )
74  {
75  DGtal::trace.error() << "Pointel " << p << " of primal polygonal surface has not the same index in the polygonal surface (" << idx << ") and in the pointel range (" << i << ")." << std::endl;
76  nb_ko += 1;
77  }
78  else nb_ok += 1;
79  }
80  REQUIRE( nb_ko == 0 );
81  }
82  }
83 }

References DGtal::Shortcuts< TKSpace >::defaultParameters(), DGtal::Trace::error(), DGtal::Shortcuts< TKSpace >::getCellEmbedder(), DGtal::Shortcuts< TKSpace >::getKSpace(), DGtal::Shortcuts< TKSpace >::getPointelRange(), GIVEN(), K, DGtal::Shortcuts< TKSpace >::makeBinaryImage(), DGtal::Shortcuts< TKSpace >::makeDigitizedImplicitShape3D(), DGtal::Shortcuts< TKSpace >::makeImplicitShape3D(), DGtal::Shortcuts< TKSpace >::makeLightDigitalSurface(), DGtal::Shortcuts< TKSpace >::makePrimalPolygonalSurface(), REQUIRE(), and DGtal::trace.

DGtal::Shortcuts::makePrimalPolygonalSurface
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2321
DGtal::Shortcuts::Cell2Index
std::map< Cell, IdxVertex > Cell2Index
Definition: Shortcuts.h:189
DGtal::Shortcuts::getCellEmbedder
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:438
SH3
Shortcuts< KSpace > SH3
Definition: testArithmeticalDSSComputerOnSurfels.cpp:49
DGtal::Trace::error
std::ostream & error()
DGtal::trace
Trace trace
Definition: Common.h:154
K
KSpace K
Definition: testCubicalComplex.cpp:62
REQUIRE
REQUIRE(domain.isInside(aPoint))
DGtal::Shortcuts
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Definition: Shortcuts.h:104
KSpace
Z3i::KSpace KSpace
Definition: testArithmeticalDSSComputerOnSurfels.cpp:48
DGtal::Shortcuts::defaultParameters
static Parameters defaultParameters()
Definition: Shortcuts.h:203
DGtal::Shortcuts::makeImplicitShape3D
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters &params=parametersImplicitShape3D())
Definition: Shortcuts.h:282
DGtal::Shortcuts::makeDigitizedImplicitShape3D
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
Definition: Shortcuts.h:523
DGtal::Shortcuts::makeLightDigitalSurface
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1062
DGtal::Shortcuts::getKSpace
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition: Shortcuts.h:332
DGtal::Shortcuts::getPointelRange
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:1469
GIVEN
GIVEN("A cubical complex with random 3-cells")
Definition: testCubicalComplex.cpp:70
DGtal::Shortcuts::makeBinaryImage
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:561
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64