Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
viewer3D-10-interaction.cpp
Go to the documentation of this file.
1
16
32
50
51
53#include <iostream>
54
55#include "DGtal/base/Common.h"
56#include "DGtal/helpers/StdDefs.h"
57#include "DGtal/io/viewers/PolyscopeViewer.h"
59
60using namespace std;
61using namespace DGtal;
62using namespace Z3i;
63
66typedef KSpace::SCell SCell;
67
69// Standard services - public :
70//
71struct MyCallback : public Callback {
72 void OnClick(
73 const std::string& name, size_t index,
75 void* polyscopeStructure
76 ) {
77 std::cout << "Item name: " << name << std::endl;
78 }
79};
80
81int main( int argc, char** argv )
82{
83 Point p1( 0, 0, 0 );
84 Point p2( 5, 5 ,5 );
85 Point p3( 2, 3, 4 );
86
87 KSpace K;
88 K.init( p1, p2, true );
89
90 Point v1 = Z3i::Point(10, 10,10);
91 Point v2 = Z3i::Point(9, 9, 9);
92 Point v3 = Z3i::Point(11, 11,11);
93
94 MyViewer viewer( K );
95 viewer.setCallback(new MyCallback);
96 Z3i::SCell surfel1 = K.sCell( Point( 1, 1, 2 ), KSpace::POS );
97 Z3i::SCell surfel2 = K.sCell( Point( 3, 3, 4 ), KSpace::NEG );
98 Z3i::SCell surfel3 = K.sCell( Point( 5, 6, 5 ), KSpace::POS );
99
100 viewer.draw(surfel1, "Surfel 1");
101 viewer.draw(surfel2, "Surfel 2");
102 viewer << Point(0, 0, 1) << Point(1, 1, 2);
103
104 viewer.show();
105 return 0;
106}
107// //
std::string draw(const Point &p, const std::string &uname="Point_{i}")
SignedKhalimskyCell< dim, Integer > SCell
void setCallback(typename Display3D< Space, KSpace >::Callback *callback) override
void show() override
Starts the event loop and display of elements.
Z3i this namespace gathers the standard of types for 3D imagery.
KhalimskySpaceND< 3, Integer > KSpace
Definition StdDefs.h:146
Space::Point Point
Definition StdDefs.h:168
KSpace::SCell SCell
Definition StdDefs.h:149
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
A general callback for the viewer to give control to the user.
Definition Display3D.h:402
Data required to display an object.
Definition Display3D.h:247
void OnClick(const std::string &name, size_t index, const DisplayData< MyViewer::RealPoint > &data, void *polyscopeStructure)
unsigned int index(DGtal::uint32_t n, unsigned int b)
Definition testBits.cpp:44
int main()
Definition testBits.cpp:56
KSpace K
MyViewer::Callback Callback
PolyscopeViewer< Space, KSpace > MyViewer