Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
viewer3D-11-extension.cpp
Go to the documentation of this file.
1
16
29
35
37#include <iostream>
38
39#include "DGtal/base/Common.h"
40#include "DGtal/helpers/StdDefs.h"
41#include "DGtal/io/viewers/PolyscopeViewer.h"
43
44using namespace std;
45using namespace DGtal;
46using namespace Z3i;
47
49// Standard services - public :
50
52struct RandomPointExtension : public PolyscopeViewer<>::Callback {
53 void OnUI() {
54 static int count = 16;
55 // Depending on the viewer, this may change
56 ImGui::SliderInt("Number of points to draw", &count, 0, 32);
57 if (ImGui::Button("Create points")) {
58 for (int i = 0; i < count; ++i) {
59 // Rand values from -10 to 10
60 // Viewer is pointer to the viewer this extension is attached to
61 *viewer << Point(rand() % 21 - 10, rand() % 21 - 10, rand() % 21 - 10);
62 }
63 // Ask viewer to render all data that were added
64 viewer->renderNewData();
65 }
66 }
67};
68
69
70int main( int argc, char ** argv )
71{
72 Point p1( 0, 0, 0 );
73 Point p2( 5, 5, 5 );
74 Point p3( 2, 3, 4 );
75
76 Domain domain( p1, p2 );
77
78 KSpace K;
79 K.init( p1, p2, true );
80
81 PolyscopeViewer viewer(K);
85 viewer << domain;
86 viewer << p1 << p2 << p3;
87
88 viewer.show();
89 return 0;
90}
91// //
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
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
[viewer3D-extension-derivation]
int main()
Definition testBits.cpp:56
KSpace K
Domain domain