-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathvolume_mesh_vector_quantity.cpp
More file actions
99 lines (71 loc) · 3.08 KB
/
volume_mesh_vector_quantity.cpp
File metadata and controls
99 lines (71 loc) · 3.08 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
// Copyright 2017-2023, Nicholas Sharp and the Polyscope contributors. https://polyscope.run
#include "polyscope/volume_mesh_vector_quantity.h"
#include "polyscope/polyscope.h"
#include "polyscope/render/engine.h"
#include "imgui.h"
#include <fstream>
#include <iostream>
namespace polyscope {
VolumeMeshVectorQuantity::VolumeMeshVectorQuantity(std::string name, VolumeMesh& mesh_, VolumeMeshElement definedOn_)
: VolumeMeshQuantity(name, mesh_), definedOn(definedOn_) {}
// ========================================================
// ========== Vertex Vector ==========
// ========================================================
VolumeMeshVertexVectorQuantity::VolumeMeshVertexVectorQuantity(std::string name, std::vector<glm::vec3> vectors_,
VolumeMesh& mesh_, VectorType vectorType_)
: VolumeMeshVectorQuantity(name, mesh_, VolumeMeshElement::VERTEX),
VectorQuantity<VolumeMeshVertexVectorQuantity>(*this, vectors_, parent.vertexPositions, vectorType_) {}
void VolumeMeshVertexVectorQuantity::refresh() {
refreshVectors();
Quantity::refresh();
}
void VolumeMeshVertexVectorQuantity::draw() {
if (!isEnabled()) return;
drawVectors();
}
void VolumeMeshVertexVectorQuantity::buildCustomUI() { buildVectorUI(); }
void VolumeMeshVertexVectorQuantity::buildVertexInfoGUI(size_t iV) {
ImGui::TextUnformatted(name.c_str());
ImGui::NextColumn();
glm::vec3 vec = vectors.getValue(iV);
std::stringstream buffer;
buffer << vec;
ImGui::TextUnformatted(buffer.str().c_str());
ImGui::NextColumn();
ImGui::NextColumn();
ImGui::Text("magnitude: %g", glm::length(vec));
ImGui::NextColumn();
}
std::string VolumeMeshVertexVectorQuantity::niceName() { return name + " (vertex vector)"; }
// ========================================================
// ========== Cell Vector ==========
// ========================================================
VolumeMeshCellVectorQuantity::VolumeMeshCellVectorQuantity(std::string name, std::vector<glm::vec3> vectors_,
VolumeMesh& mesh_, VectorType vectorType_)
: VolumeMeshVectorQuantity(name, mesh_, VolumeMeshElement::CELL),
VectorQuantity<VolumeMeshCellVectorQuantity>(*this, vectors_, parent.cellCenters, vectorType_) {
refresh();
}
void VolumeMeshCellVectorQuantity::refresh() {
refreshVectors();
Quantity::refresh();
}
void VolumeMeshCellVectorQuantity::draw() {
if (!isEnabled()) return;
drawVectors();
}
void VolumeMeshCellVectorQuantity::buildCustomUI() { buildVectorUI(); }
void VolumeMeshCellVectorQuantity::buildCellInfoGUI(size_t iC) {
ImGui::TextUnformatted(name.c_str());
ImGui::NextColumn();
glm::vec3 vec = vectors.getValue(iC);
std::stringstream buffer;
buffer << vec;
ImGui::TextUnformatted(buffer.str().c_str());
ImGui::NextColumn();
ImGui::NextColumn();
ImGui::Text("magnitude: %g", glm::length(vec));
ImGui::NextColumn();
}
std::string VolumeMeshCellVectorQuantity::niceName() { return name + " (cell vector)"; }
} // namespace polyscope