forked from nmwsharp/polyscope
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombo_test.cpp
More file actions
180 lines (137 loc) · 5.21 KB
/
Copy pathcombo_test.cpp
File metadata and controls
180 lines (137 loc) · 5.21 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Copyright 2017-2023, Nicholas Sharp and the Polyscope contributors. https://polyscope.run
#include "polyscope_test.h"
// ============================================================
// =============== Combo test
// ============================================================
// Register a handful of quantities / structures, then call refresh
TEST_F(PolyscopeTest, RefreshMultiTest) {
{ // Surface mesh
auto psMesh = registerTriangleMesh();
std::vector<double> vScalar(psMesh->nVertices(), 7.);
auto q1 = psMesh->addVertexDistanceQuantity("distance", vScalar);
}
{ // Point cloud
auto psPoints = registerPointCloud();
std::vector<double> vScalar(psPoints->nPoints(), 7.);
auto q2 = psPoints->addScalarQuantity("vScalar", vScalar);
q2->setEnabled(true);
}
{ // Curve network
auto psCurve = registerCurveNetwork();
std::vector<glm::vec3> vals(psCurve->nEdges(), {1., 2., 3.});
auto q3 = psCurve->addEdgeVectorQuantity("vals", vals);
q3->setEnabled(true);
}
polyscope::show(3);
polyscope::refresh();
polyscope::show(3);
polyscope::removeAllStructures();
}
// Cycle through the transparency optins
TEST_F(PolyscopeTest, TransparencyTest) {
{ // Surface mesh
auto psMesh = registerTriangleMesh();
std::vector<double> vScalar(psMesh->nVertices(), 7.);
auto q1 = psMesh->addVertexDistanceQuantity("distance", vScalar);
}
{ // Point cloud
auto psPoints = registerPointCloud();
std::vector<double> vScalar(psPoints->nPoints(), 7.);
auto q2 = psPoints->addScalarQuantity("vScalar", vScalar);
q2->setEnabled(true);
}
{ // Curve network
auto psCurve = registerCurveNetwork();
std::vector<glm::vec3> vals(psCurve->nEdges(), {1., 2., 3.});
auto q3 = psCurve->addEdgeVectorQuantity("vals", vals);
q3->setEnabled(true);
}
polyscope::show(3);
polyscope::options::transparencyMode = polyscope::TransparencyMode::Simple;
polyscope::show(3);
polyscope::options::transparencyMode = polyscope::TransparencyMode::Pretty;
polyscope::show(3);
polyscope::removeAllStructures();
}
// Do some slice plane stuff
TEST_F(PolyscopeTest, SlicePlaneTest) {
// Surface mesh
auto psMesh = registerTriangleMesh();
std::vector<double> vScalar(psMesh->nVertices(), 7.);
auto q1 = psMesh->addVertexDistanceQuantity("distance", vScalar);
// Point cloud
auto psPoints = registerPointCloud();
psPoints->setPointRenderMode(polyscope::PointRenderMode::Sphere);
psPoints->setCullWholeElements(true);
std::vector<double> vScalarP(psPoints->nPoints(), 7.);
auto q2 = psPoints->addScalarQuantity("vScalar", vScalarP);
q2->setEnabled(true);
{
// Curve network
auto psCurve = registerCurveNetwork();
std::vector<glm::vec3> vals(psCurve->nEdges(), {1., 2., 3.});
auto q3 = psCurve->addEdgeVectorQuantity("vals", vals);
q3->setEnabled(true);
}
{ // Volume mesh
std::vector<glm::vec3> verts;
std::vector<std::array<int, 8>> cells;
std::tie(verts, cells) = getVolumeMeshData();
polyscope::VolumeMesh* psVol = polyscope::registerVolumeMesh("vol", verts, cells);
polyscope::VolumeMesh* psVol2 = polyscope::registerVolumeMesh("vol cull whole", verts, cells);
psVol2->setCullWholeElements(true);
}
polyscope::show(3);
// render with one slice plane
polyscope::addSceneSlicePlane();
polyscope::show(3);
// try a few variations of point cloud settings
psPoints->setCullWholeElements(false);
polyscope::show(3);
psPoints->setCullWholeElements(true);
psPoints->setPointRenderMode(polyscope::PointRenderMode::Quad);
polyscope::show(3);
psPoints->setCullWholeElements(false);
polyscope::show(3);
polyscope::show(3);
// add another and rotate it
polyscope::SlicePlane* p = polyscope::addSceneSlicePlane();
p->setTransform(glm::translate(p->getTransform(), glm::vec3{-1., 0., 0.}));
polyscope::show(3);
// test removal
polyscope::removeLastSceneSlicePlane();
polyscope::show(3);
// make one structure ignore the plane
psMesh->setIgnoreSlicePlane(polyscope::state::slicePlanes[0]->name, true);
polyscope::show(3);
// remove the last plane so we don't leave it around for future tests
polyscope::removeLastSceneSlicePlane();
polyscope::removeAllStructures();
}
// Register a handful of quantities / structures, then call refresh
TEST_F(PolyscopeTest, OrthoViewTest) {
// Add some stuff
{ // Surface mesh
auto psMesh = registerTriangleMesh();
std::vector<double> vScalar(psMesh->nVertices(), 7.);
auto q1 = psMesh->addVertexDistanceQuantity("distance", vScalar);
}
{ // Point cloud
auto psPoints = registerPointCloud();
std::vector<double> vScalar(psPoints->nPoints(), 7.);
auto q2 = psPoints->addScalarQuantity("vScalar", vScalar);
q2->setEnabled(true);
}
{ // Curve network
auto psCurve = registerCurveNetwork();
std::vector<glm::vec3> vals(psCurve->nEdges(), {1., 2., 3.});
auto q3 = psCurve->addEdgeVectorQuantity("vals", vals);
q3->setEnabled(true);
}
// Enable the orthographic view
polyscope::view::projectionMode = polyscope::ProjectionMode::Orthographic;
polyscope::show(3);
// Go back to default perspective
polyscope::view::projectionMode = polyscope::ProjectionMode::Perspective;
polyscope::removeAllStructures();
}