DGtal  1.3.beta
testIntegralInvariantShortcuts.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include <vector>
33 
34 #include "DGtal/base/Common.h"
35 #include "ConfigTest.h"
36 #include "DGtalCatch.h"
37 #include "DGtal/helpers/StdDefs.h"
38 #include "DGtal/helpers/Shortcuts.h"
39 #include "DGtal/helpers/ShortcutsGeometry.h"
40 
42 
43 using namespace std;
44 using namespace DGtal;
45 
48 
50 // Functions for testing class IntegralInvariantShortcuts.
52 
53 TEST_CASE( "Testing IntegralInvariant Shortcuts API" )
54 {
55  auto params = SH3::defaultParameters() | SHG3::defaultParameters() | SHG3::parametersGeometryEstimation();
56  params( "polynomial", "goursat" )( "gridstep", 1. );
57  auto implicit_shape = SH3::makeImplicitShape3D ( params );
58  auto digitized_shape = SH3::makeDigitizedImplicitShape3D( implicit_shape, params );
59  auto binary_image = SH3::makeBinaryImage( digitized_shape, params );
60  auto K = SH3::getKSpace( params );
61  auto embedder = SH3::getCellEmbedder( K );
62  auto surface = SH3::makeLightDigitalSurface( binary_image, K, params );
63  auto surfels = SH3::getSurfelRange( surface, params );
64 
65  trace.info() << "Nb surfels= " << surfels.size() << std::endl;
66 
67  //Computing some differential quantities
68  params("r-radius", 3.0);
69 
70  //We compute the curvature tensor, the mean and the Gaussian curvature
71  auto Tcurv = SHG3::getIIPrincipalCurvaturesAndDirections(binary_image, surfels, params);
72  auto Kcurv = SHG3::getIIGaussianCurvatures( binary_image, surfels, params);
73 
74  std::vector<double> k1,k2,G;
75  for(auto &result: Tcurv)
76  {
77  k1.push_back( std::get<0>(result) );
78  k2.push_back( std::get<1>(result) );
79  G.push_back( ( std::get<0>(result) * std::get<1>(result)) );
80  }
81 
82  SECTION("Testing that mean/Gaussian/tensor curvature shortucut values match")
83  {
84  for(std::size_t i = 0; i < G.size(); ++i)
85  REQUIRE( Kcurv[i] == Approx( G[i] ) );
86  }
87 }
88 
DGtal::Shortcuts::getCellEmbedder
static CanonicCellEmbedder< KSpace > getCellEmbedder(const KSpace &K)
Definition: Shortcuts.h:438
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
DGtal::Trace::info
std::ostream & info()
SHG3
ShortcutsGeometry< Z3i::KSpace > SHG3
Definition: testIntegralInvariantShortcuts.cpp:47
SH3
Shortcuts< Z3i::KSpace > SH3
Definition: testIntegralInvariantShortcuts.cpp:46
DGtal::Shortcuts::defaultParameters
static Parameters defaultParameters()
Definition: Shortcuts.h:203
TEST_CASE
TEST_CASE("Testing IntegralInvariant Shortcuts API")
Definition: testIntegralInvariantShortcuts.cpp:53
DGtal::Shortcuts::makeImplicitShape3D
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters &params=parametersImplicitShape3D())
Definition: Shortcuts.h:282
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::ShortcutsGeometry
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
Definition: ShortcutsGeometry.h:76
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
SECTION
SECTION("Testing constant forward iterators")
Definition: testSimpleRandomAccessRangeFromPoint.cpp:66
DGtal::Shortcuts::getSurfelRange
static SurfelRange getSurfelRange(CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface, const Parameters &params=parametersDigitalSurface())
Definition: Shortcuts.h:1547
DGtal::Shortcuts::makeBinaryImage
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
Definition: Shortcuts.h:561