DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
homotopicThinning3D.cpp
Go to the documentation of this file.
1
16
29
30
42
43
45
#include <iostream>
46
#include <queue>
47
#include "DGtal/base/Common.h"
48
#include "DGtal/io/viewers/PolyscopeViewer.h"
49
#include "DGtal/io/Color.h"
50
#include "DGtal/shapes/Shapes.h"
51
#include "DGtal/helpers/StdDefs.h"
52
54
55
using namespace
std
;
56
using namespace
DGtal
;
57
using namespace
Z3i
;
58
60
61
62
63
int
main
()
64
{
65
66
trace
.
beginBlock
(
"Example simple example of 3DViewer"
);
67
68
PolyscopeViewer<>
viewer;
69
70
// Domain cretation from two bounding points.
71
Point
c( 0, 0, 0 );
72
Point
p1( -50, -50, -50 );
73
Point
p2( 50, 50, 50 );
74
Domain
domain
( p1, p2 );
75
76
trace
.
warning
() <<
"Constructing a ring DigitalSet ... "
;
77
DigitalSet
shape_set(
domain
);
78
for
(
Domain::ConstIterator
it =
domain
.begin(); it !=
domain
.end(); ++it )
79
{
80
if
( ((*it - c ).norm() <= 25) && ((*it - c ).norm() >= 18)
81
&& ( (((*it)[0] <= 3)&& ((*it)[0] >= -3))|| (((*it)[1] <= 3)&& ((*it)[1] >= -3)))){
82
shape_set.
insertNew
( *it );
83
}
84
}
85
trace
.
warning
() <<
" [Done]"
<< std::endl;
86
87
trace
.
beginBlock
(
"Thinning"
);
88
Object18_6
shape( dt18_6, shape_set );
89
int
nb_simple=0;
90
DigitalSet::Iterator
it, itE;
91
do
92
{
93
DigitalSet
& S = shape.
pointSet
();
94
std::queue<DigitalSet::Iterator> Q;
95
it = S.
begin
();
96
itE = S.
end
();
97
#ifdef DGTAL_WITH_OPENMP
98
std::vector<DigitalSet::Iterator> v( S.
size
() );
99
std::vector<uint8_t> b( v.size() );
100
for
(
size_t
i = 0; it != itE; ++it, ++i )
101
v[ i ] = it;
102
#pragma omp parallel for schedule(dynamic)
103
for
(
size_t
i = 0; i < v.size(); ++i )
104
b[ i ] = shape.
isSimple
( *(v[ i ]) );
105
106
for
(
size_t
i = 0; i < v.size(); ++i )
107
if
( b[ i ] ) Q.push( v[ i ] );
108
#else
109
for
( ; it != itE; ++it )
110
if
( shape.
isSimple
( *it ) )
111
Q.push( it );
112
#endif
113
nb_simple = 0;
114
while
( ! Q.empty() )
115
{
116
DigitalSet::Iterator
itt = Q.front();
117
Q.pop();
118
if
( shape.
isSimple
( *itt ) )
119
{
120
S.
erase
( *itt );
121
++nb_simple;
122
}
123
}
124
}
125
while
( nb_simple != 0 );
126
DigitalSet
& S = shape.
pointSet
();
127
trace
.
endBlock
();
128
129
// Display by using two different list to manage OpenGL transparency.
130
131
viewer <<
Color
(25,25,255, 255);
132
viewer << S ;
133
134
viewer <<
Color
(250, 0,0, 25);
135
viewer << shape_set;
136
137
138
trace
.
endBlock
();
139
viewer.
show
();
140
return
0;
141
142
}
143
// //
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::DigitalSetByAssociativeContainer::insertNew
void insertNew(const Point &p)
DGtal::DigitalSetByAssociativeContainer::end
ConstIterator end() const
DGtal::DigitalSetByAssociativeContainer::size
Size size() const
DGtal::DigitalSetByAssociativeContainer< Domain, std::unordered_set< typename Domain::Point > >::Iterator
Container::iterator Iterator
Definition
DigitalSetByAssociativeContainer.h:106
DGtal::DigitalSetByAssociativeContainer::begin
ConstIterator begin() const
DGtal::DigitalSetByAssociativeContainer::erase
Size erase(const Point &p)
DGtal::HyperRectDomain< Space >::ConstIterator
Iterator ConstIterator
Definition
HyperRectDomain.h:125
DGtal::Object::pointSet
const DigitalSet & pointSet() const
DGtal::Object::isSimple
bool isSimple(const Point &v) const
DGtal::PolyscopeViewer
Definition
PolyscopeViewer.h:57
DGtal::PolyscopeViewer::show
void show() override
Starts the event loop and display of elements.
Definition
PolyscopeViewer.h:73
DGtal::Point
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::warning
std::ostream & warning()
DGtal::Trace::endBlock
double endBlock()
DGtal::Domain
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal::Z3i::Object18_6
Object< DT18_6, DigitalSet > Object18_6
Definition
StdDefs.h:178
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
DGtal::trace
Trace trace
std
STL namespace.
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
domain
Domain domain
Definition
testProjection.cpp:88
examples
topology
homotopicThinning3D.cpp
Generated on
for DGtal by
1.18.0