34#include "DGtal/base/Common.h"
35#include "DGtal/helpers/StdDefs.h"
36#include "DGtal/helpers/Shortcuts.h"
37#include "DGtal/geometry/volumes/TangencyComputer.h"
38#include "DGtalCatch.h"
49SCENARIO(
"TangencyComputer::ShortestPaths 3D tests",
"[shortest_paths][3d][tangency]" )
60 typedef std::size_t
Index;
62 SECTION(
"Computing shortest paths on a 3D unit sphere digitized at gridstep 0.25" )
65 const double h = 0.25;
67 params(
"polynomial",
"sphere1" )(
"gridstep", h );
68 params(
"minAABB", -2)(
"maxAABB", 2)(
"offset", 1.0 )(
"closed", 1 );
76 std::vector< Point > lattice_points;
78 for (
auto p : pointels ) lattice_points.push_back(
K.
uCoords( p ) );
79 REQUIRE( pointels.size() == 296 );
81 const Index nb = lattice_points.size();
84 for (
Index i = 1; i < nb; i++ )
86 if ( lattice_points[ i ] < lattice_points[ lowest ] ) lowest = i;
87 if ( lattice_points[ uppest ] < lattice_points[ i ] ) uppest = i;
92 TC.init( lattice_points.cbegin(), lattice_points.cend() );
93 auto SP = TC.makeShortestPaths( sqrt(3.0) );
95 double last_distance = 0.0;
97 double prev_distance = 0.0;
99 unsigned int nb_multiple_pops = 0;
100 unsigned int nb_decreasing_distance = 0;
101 while ( ! SP.finished() )
103 last = std::get<0>( SP.current() );
104 last_distance = std::get<2>( SP.current() );
105 if ( V.count( last ) ) nb_multiple_pops += 1;
108 if ( last_distance < prev_distance ) nb_decreasing_distance += 1;
109 prev_distance = last_distance;
112 REQUIRE( nb_multiple_pops == 0 );
114 REQUIRE( nb_decreasing_distance == 0 );
118 REQUIRE( last_distance*h >= 2.8 );
119 REQUIRE( last_distance*h <= 3.14159265358979323844 );
121 SP = TC.makeShortestPaths( 0 );
123 double last_distance_opt = 0.0;
124 while ( ! SP.finished() )
126 last = std::get<0>( SP.current() );
127 last_distance_opt = std::get<2>( SP.current() );
133 REQUIRE( last_distance_opt*h >= 2.8 );
134 REQUIRE( last_distance_opt*h <= 3.14159265358979323844 );
136 REQUIRE( last_distance_opt*h >= last_distance*h );
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
const Point & lowerBound() const
Return the lower bound for digital points in this space.
const Point & upperBound() const
Return the upper bound for digital points in this space.
Point uCoords(const Cell &c) const
Return its digital coordinates.
Aim: This class is used to simplify shape and surface creation. With it, you can create new shapes an...
static KSpace getKSpace(const Point &low, const Point &up, Parameters params=parametersKSpace())
static CountedPtr< DigitizedImplicitShape3D > makeDigitizedImplicitShape3D(CountedPtr< ImplicitShape3D > shape, Parameters params=parametersDigitizedImplicitShape3D())
static PointelRange getPointelRange(Cell2Index &c2i, CountedPtr< ::DGtal::DigitalSurface< TDigitalSurfaceContainer > > surface)
static CountedPtr< DigitalSurface > makeDigitalSurface(CountedPtr< TPointPredicate > bimage, const KSpace &K, const Parameters ¶ms=parametersDigitalSurface())
static Parameters defaultParameters()
static CountedPtr< BinaryImage > makeBinaryImage(Domain shapeDomain)
static CountedPtr< ImplicitShape3D > makeImplicitShape3D(const Parameters ¶ms=parametersImplicitShape3D())
Aim: A class that computes tangency to a given digital set. It provides services to compute all the c...
DGtal is the top-level namespace which contains all DGtal functions and types.
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
FreemanChain< int >::Vector Vector
SECTION("Testing constant forward iterators")
HyperRectDomain< Space > Domain
REQUIRE(domain.isInside(aPoint))
SCENARIO("UnorderedSetByBlock< PointVector< 2, int > unit tests with 32 bits blocks", "[unorderedsetbyblock][2d]")