DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
ctopo-1-3d.cpp
Go to the documentation of this file.
1
16
29
40
41
53
54
56
#include <iostream>
57
#include "DGtal/base/Common.h"
58
#include "DGtal/helpers/StdDefs.h"
59
60
#include "DGtal/io/viewers/PolyscopeViewer.h"
61
63
64
using namespace
std
;
65
using namespace
DGtal
;
66
using namespace
DGtal::Z3i
;
67
69
70
int
main
()
71
{
72
// for 3D display with PolyscopeViewer
73
KSpace
K
;
74
Point
plow(0,0,0);
75
Point
pup(3,3,2);
76
Domain
domain
( plow, pup );
77
K
.
init
( plow, pup,
true
);
78
//
79
typedef
PolyscopeViewer<Space, KSpace>
MyViewer
;
80
81
MyViewer
viewer(
K
);
82
Cell
ptlow =
K
.
uPointel
( plow );
// pointel (0*2,0*2, 0*2)
83
Cell
ptup1 =
K
.
uPointel
( pup );
// pointel (3*2,3*2, 2*2)
84
Cell
ptup2 =
K
.
uTranslation
( ptup1,
Point::diagonal
() );
// pointel (4*2, 4*2, 3*2)
85
86
viewer << ptlow << ptup1 << ptup2;
87
88
// drawing cells of dimension 0
89
Cell
p1=
K
.
uCell
(
Point
(0,0,2));
// pointel (0*2,0*2,2*2)
90
Cell
p2=
K
.
uCell
(
Point
(0,2,2));
// ...
91
Cell
p3=
K
.
uCell
(
Point
(2,2,2));
92
Cell
p4=
K
.
uCell
(
Point
(2,0,2));
93
Cell
p5=
K
.
uCell
(
Point
(0,0,4));
94
Cell
p6=
K
.
uCell
(
Point
(0,2,4));
95
Cell
p7=
K
.
uCell
(
Point
(2,2,4));
96
Cell
p8=
K
.
uCell
(
Point
(2,0,4));
97
viewer << p1 << p2 << p3 << p4 << p5 << p6 << p7 << p8;
98
99
// drawing Cells of dimension 1
100
Cell
linel0 =
K
.
uCell
(
Point
( 1, 0, 2 ) );
// linel (2*1+1, 0, 2*2)
101
Cell
linel1 =
K
.
uCell
(
Point
( 1, 2, 2 ) );
// ...
102
Cell
linel2 =
K
.
uCell
(
Point
( 0, 1, 2 ) );
103
Cell
linel3 =
K
.
uCell
(
Point
( 2, 1, 2 ) );
104
105
Cell
linel4 =
K
.
uCell
(
Point
( 1, 0, 4 ) );
106
Cell
linel5 =
K
.
uCell
(
Point
( 1, 2, 4 ) );
107
Cell
linel6 =
K
.
uCell
(
Point
( 0, 1, 4 ) );
108
Cell
linel7 =
K
.
uCell
(
Point
( 2, 1, 4 ) );
109
110
Cell
linel8 =
K
.
uCell
(
Point
( 0, 0, 3 ) );
111
Cell
linel9 =
K
.
uCell
(
Point
( 0, 2, 3 ) );
112
Cell
linel10 =
K
.
uCell
(
Point
( 2, 0, 3 ) );
113
Cell
linel11 =
K
.
uCell
(
Point
( 2, 2, 3 ) );
114
115
116
Cell
linel12 =
K
.
uCell
(
Point
( 3, 2, 2 ) );
117
118
viewer << linel0<< linel1<< linel2 << linel3 ;
119
viewer << linel4<< linel5<< linel6 << linel7 ;
120
viewer << linel8<< linel9<< linel10 << linel11 << linel12;
121
122
// drawing cells of dimension 2
123
124
Cell
surfelA =
K
.
uCell
(
Point
( 2, 1, 3 ) );
// surfel (2*2,2*1+1,2*3+1)
125
Cell
surfelB =
K
.
uCell
(
Point
( 1, 0, 1 ) );
// surfel (2*1,2*0,2*1+1)
126
Cell
surfelC =
K
.
uCell
(
Point
( 2, 1, 1 ) );
// surfel (2*2,2*1+1,2*1+1)
127
viewer << surfelA << surfelB << surfelC;
128
129
// drawing cells of dimension 3
130
Cell
vox1 =
K
.
uCell
(
Point
( 3, 3, 3 ) );
// voxel (2*3+1,2*3+1,2*3+1)
131
Cell
vox2 =
K
.
uCell
(
Point
( 1, 1, 3 ) );
// voxel (2*1+1,2*1+1,2*3+1)
132
viewer << vox1 << vox2;
133
134
viewer.
show
();
135
return
0;
136
137
}
138
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::uTranslation
Cell uTranslation(const Cell &p, const Vector &vec) const
Add the vector [vec] to [p].
DGtal::KhalimskySpaceND::uPointel
Cell uPointel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding pointel (cell of dimension 0)...
DGtal::KhalimskySpaceND::uCell
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
DGtal::PointVector< dim, Integer >::diagonal
static Self diagonal(Component val=1)
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::Domain
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::Cell
KSpace::Cell Cell
Definition
StdDefs.h:148
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
K
KSpace K
Definition
testCubicalComplex.cpp:62
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
domain
Domain domain
Definition
testProjection.cpp:88
MyViewer
PolyscopeViewer< Space, KSpace > MyViewer
Definition
viewer3D-10-interaction.cpp:64
examples
topology
ctopo-1-3d.cpp
Generated on
for DGtal by
1.18.0