forked from nmwsharp/polyscope
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
106 lines (78 loc) · 2.68 KB
/
Copy pathtest.cpp
File metadata and controls
106 lines (78 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "polyscope/point_cloud.h"
static int num_points_inc = 100;
// int main()
// {
// // Initialize polyscope
// polyscope::init();
// std::vector<glm::vec3> points;
// // generate points
// for (size_t i = 0; i < 3000; i++) {
// points.push_back(
// glm::vec3{polyscope::randomUnit() - .5,
// polyscope::randomUnit() - .5,
// polyscope::randomUnit() - .5});
// }
// // visualize!
// polyscope::PointCloud* psCloud = polyscope::registerPointCloud("really great points", points);
// // set some options
// psCloud->setPointRadius(0.02);
// psCloud->setPointRenderMode(polyscope::PointRenderMode::Quad);
// // show
// polyscope::show();
// psCloud->updatePointPositions(points);
// polyscope::show();
// return 0;
// }
#include "polyscope/polyscope.h"
#include "polyscope/point_cloud.h"
// Parameters which we will set in the callback UI.
int nPts = 2000;
float anotherParam = 3.14;
void mySubroutine(int num_points) {
// do something useful...
// Register a structure
std::vector<glm::vec3> points;
for (int i = 0; i < num_points; i++) {
points.push_back(
glm::vec3{ i / 100.f,//polyscope::randomUnit(),
i / 100.f,//polyscope::randomUnit(),
i / 100.f//polyscope::randomUnit()
});
}
polyscope::registerPointCloud("my point cloud", points);
}
// Your callback functions
void myCallback() {
// Since options::openImGuiWindowForUserCallback == true by default,
// we can immediately start using ImGui commands to build a UI
ImGui::PushItemWidth(100); // Make ui elements 100 pixels wide,
// instead of full width. Must have
// matching PopItemWidth() below.
ImGui::InputInt("num points", &nPts); // set a int variable
ImGui::InputFloat("param value", &anotherParam); // set a float variable
// if (ImGui::Button("run subroutine")) {
// // executes when button is pressed
mySubroutine(num_points_inc++);
// }
ImGui::SameLine();
if (ImGui::Button("hi")) {
polyscope::warning("hi");
}
ImGui::PopItemWidth();
}
int main(int argc, char** argv) {
/*
...your program setup...
*/
// Initialize polyscope
polyscope::init();
polyscope::options::automaticallyComputeSceneExtents = false;
polyscope::state::lengthScale = 1.;
polyscope::state::boundingBox =
std::tuple<glm::vec3, glm::vec3>{ {-1., -1., -1.}, {1., 1., 1.} };
// Specify the callback
polyscope::state::userCallback = myCallback;
// Give control to the polyscope gui
polyscope::show();
return EXIT_SUCCESS;
}