DGtal  1.2.0
testShortcuts.cpp
Go to the documentation of this file.
1 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/helpers/Shortcuts.h"
34 #include "DGtalCatch.h"
36 
37 using namespace std;
38 using namespace DGtal;
39 
40 
42 // Functions for testing class Shortcuts.
44 
45 SCENARIO( "Shortcuts< K3 > pointel ordering", "[shortcuts][pointel]" )
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 }
84 
85 // //
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Definition: Shortcuts.h:105
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters &params=parametersImplicitShape3D())
Definition: Shortcuts.h:281
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:560
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
Definition: Shortcuts.h:331
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
Definition: Shortcuts.h:522
std::map< Cell, IdxVertex > Cell2Index
Definition: Shortcuts.h:188
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
Definition: Shortcuts.h:1468
static CountedPtr< PolygonalSurface > makePrimalPolygonalSurface(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TContainer > > aSurface)
Definition: Shortcuts.h:2320
static Parameters defaultParameters()
Definition: Shortcuts.h:202
static CountedPtr< LightDigitalSurface > makeLightDigitalSurface(CountedPtr< BinaryImage > bimage, const KSpace &K, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1061
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:437
std::ostream & error()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
Shortcuts< KSpace > SH3
KSpace K
GIVEN("A cubical complex with random 3-cells")
SCENARIO("Shortcuts< K3 > pointel ordering", "[shortcuts][pointel]")
REQUIRE(domain.isInside(aPoint))