DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testIndexedDigitalSurface.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include <algorithm>
33
#include "DGtal/base/Common.h"
34
#include "ConfigTest.h"
35
#include "DGtalCatch.h"
36
#include "DGtal/helpers/StdDefs.h"
37
#include "DGtal/kernel/PointVector.h"
38
#include "DGtal/graph/CUndirectedSimpleGraph.h"
39
#include "DGtal/graph/BreadthFirstVisitor.h"
40
#include "DGtal/topology/DigitalSetBoundary.h"
41
#include "DGtal/topology/IndexedDigitalSurface.h"
42
#include "DGtal/shapes/Shapes.h"
44
45
using namespace
std
;
46
using namespace
DGtal
;
47
using namespace
Z3i
;
48
50
// Functions for testing class IndexedDigitalSurface.
52
53
54
SCENARIO
(
"IndexedDigitalSurface< DigitalSetBoundary > build tests"
,
"[idxdsurf][build]"
)
55
{
56
typedef
DigitalSetBoundary< KSpace, DigitalSet >
DigitalSurfaceContainer;
57
typedef
IndexedDigitalSurface< DigitalSurfaceContainer >
DigSurface;
58
Point
p1( -5, -5, -5 );
59
Point
p2( 5, 5, 5 );
60
KSpace
K
;
61
K
.
init
( p1, p2,
true
);
62
DigitalSet
aSet(
Domain
( p1, p2 ) );
63
Shapes<Domain>::addNorm2Ball
( aSet,
Point
( 0, 0, 0 ), 3 );
64
DigSurface dsurf;
65
bool
build_ok = dsurf.build(
new
DigitalSurfaceContainer(
K
, aSet ) );
66
GIVEN
(
"A digital set boundary over a ball of radius 3"
) {
67
THEN(
"Build of underlying half-edge data structure should be ok"
) {
68
REQUIRE
( build_ok ==
true
);
69
}
70
THEN(
"The indexed digital surface has 174 vertices, 348 edges, 176 edges, and Euler=2 as the sphere"
) {
71
REQUIRE
( dsurf.nbVertices() == 174 );
72
REQUIRE
( dsurf.nbEdges() == 348 );
73
REQUIRE
( dsurf.nbFaces() == 176 );
74
REQUIRE
( dsurf.Euler() == 2 );
75
}
76
THEN(
"All vertices have 4 neighbors"
) {
77
REQUIRE
( dsurf.degree( 0 ) == 4 );
78
REQUIRE
( dsurf.degree( 17 ) == 4 );
79
REQUIRE
( dsurf.degree( 54) == 4 );
80
REQUIRE
( dsurf.degree( 102 ) == 4 );
81
}
82
THEN(
"Vertices corresponds to surfels, Arcs to linels, Faces to pointels"
) {
83
REQUIRE
(
K
.
sDim
( dsurf.surfel( 0 ) ) == 2 );
84
REQUIRE
(
K
.
sDim
( dsurf.surfel( 17 ) ) == 2 );
85
REQUIRE
(
K
.
sDim
( dsurf.linel( 0 ) ) == 1 );
86
REQUIRE
(
K
.
sDim
( dsurf.linel( 25 ) ) == 1 );
87
REQUIRE
(
K
.
sDim
( dsurf.pointel( 0 ) ) == 0 );
88
REQUIRE
(
K
.
sDim
( dsurf.pointel( 25 ) ) == 0 );
89
}
90
THEN(
"Linels of opposite arcs are opposite cells"
) {
91
REQUIRE
(
K
.
sOpp
( dsurf.linel( 15 ) ) == dsurf.linel( dsurf.opposite( 15 ) ) );
92
REQUIRE
(
K
.
sOpp
( dsurf.linel( 34 ) ) == dsurf.linel( dsurf.opposite( 34 ) ) );
93
REQUIRE
(
K
.
sOpp
( dsurf.linel( 112 ) ) == dsurf.linel( dsurf.opposite( 112 ) ) );
94
REQUIRE
(
K
.
sOpp
( dsurf.linel( 200 ) ) == dsurf.linel( dsurf.opposite( 200 ) ) );
95
}
96
THEN(
"Breadth-first visiting the digital surface from vertex 0 goes to a distance 13."
) {
97
BreadthFirstVisitor< DigSurface >
visitor( dsurf, 0 );
98
std::vector<int> vertices;
99
std::vector<int> distances;
100
while
( ! visitor.
finished
() )
101
{
102
vertices.push_back( visitor.
current
().first );
103
distances.push_back( visitor.
current
().second );
104
visitor.
expand
();
105
}
106
REQUIRE
( vertices.size() == 174 );
107
REQUIRE
( distances.size() == 174 );
108
REQUIRE
( distances.back() == 13 );
109
}
110
}
111
}
112
113
SCENARIO
(
"IndexedDigitalSurface< RealPoint3 > concept check tests"
,
"[idxdsurf][concepts]"
)
114
{
115
typedef
DigitalSetBoundary< KSpace, DigitalSet >
DigitalSurfaceContainer;
116
typedef
IndexedDigitalSurface< DigitalSurfaceContainer >
DigSurface;
117
BOOST_CONCEPT_ASSERT((
concepts::CUndirectedSimpleGraph< DigSurface >
));
118
}
119
DGtal::BreadthFirstVisitor
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
Definition
BreadthFirstVisitor.h:95
DGtal::BreadthFirstVisitor::current
const Node & current() const
DGtal::BreadthFirstVisitor::finished
bool finished() const
DGtal::BreadthFirstVisitor::expand
void expand()
DGtal::DigitalSetBoundary< KSpace, DigitalSet >
DGtal::HyperRectDomain< Space >::Domain
HyperRectDomain< Space > Domain
Definition
HyperRectDomain.h:112
DGtal::IndexedDigitalSurface
Aim: Represents a digital surface with the topology of its dual surface. Its aim is to mimic the stan...
Definition
IndexedDigitalSurface.h:97
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::KhalimskySpaceND::sOpp
SCell sOpp(const SCell &p) const
Creates the signed cell with the inverse sign of [p].
DGtal::KhalimskySpaceND::sDim
Dimension sDim(const SCell &p) const
Return the dimension of the cell [p].
DGtal::Shapes::addNorm2Ball
static void addNorm2Ball(TDigitalSet &aSet, const Point &aCenter, UnsignedInteger aRadius)
DGtal::Point
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal::Z3i::KSpace
KhalimskySpaceND< 3, Integer > KSpace
Definition
StdDefs.h:146
DGtal::Z3i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:173
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
DGtal::concepts::CUndirectedSimpleGraph
Aim: Represents the concept of local graph: each vertex has neighboring vertices, but we do not neces...
Definition
CUndirectedSimpleGraph.h:105
SCENARIO
SCENARIO("CorrectedNormalCurrentComputer interpolated curvature measures on sphere tests", "[icnc][sphere]")
Definition
testCorrectedNormalCurrentComputer.cpp:50
K
KSpace K
Definition
testCubicalComplex.cpp:62
GIVEN
GIVEN("A cubical complex with random 3-cells")
Definition
testCubicalComplex.cpp:70
REQUIRE
REQUIRE(domain.isInside(aPoint))
tests
topology
testIndexedDigitalSurface.cpp
Generated on
for DGtal by
1.18.0