Skip to content

Commit 8f871cc

Browse files
committed
optionally dump jacobi volumes
1 parent 3bea673 commit 8f871cc

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

tsd/apps/interactive/demos/animatedVolume/SolverControls.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "SolverControls.h"
55
// tsd_ui_imgui
66
#include <tsd/ui/imgui/Application.h>
7+
#include <tsd/ui/imgui/tsd_ui_imgui.h>
78
// tsd_core
89
#include <tsd/core/Logging.hpp>
910
// std
@@ -70,11 +71,8 @@ void SolverControls::buildUI()
7071
resetSolver();
7172
ImGui::EndDisabled();
7273
ImGui::Checkbox("auto update transfer function", &m_updateTF);
73-
74-
ImGui::Separator();
75-
76-
if (ImGui::Button("export .raw"))
77-
exportRAW();
74+
ImGui::Checkbox("dump volumes timesteps", &m_dumpVolumes);
75+
ImGui::InputText("export root", &m_exportRoot);
7876
}
7977

8078
void SolverControls::setField(tsd::core::SpatialFieldRef f)
@@ -226,6 +224,9 @@ void SolverControls::iterateSolver()
226224
tsd::core::logStatus("[jacobi solver] ...TSD update (%i|%.2fms)",
227225
m_totalIterations,
228226
duration);
227+
228+
if (m_dumpVolumes)
229+
exportRAW();
229230
}
230231

231232
void SolverControls::exportRAW()
@@ -238,7 +239,7 @@ void SolverControls::exportRAW()
238239
filename.resize(100);
239240
filename.resize(std::snprintf(filename.data(),
240241
filename.size(),
241-
"jacobi_%i_%zux%zux%zu_float32.raw",
242+
"jacobi_%04d_%zux%zux%zu_float32.raw",
242243
m_totalIterations,
243244
nx,
244245
ny,
@@ -253,12 +254,13 @@ void SolverControls::exportRAW()
253254
m_dataHost->unmap();
254255
}
255256

256-
auto *fp = std::fopen(filename.c_str(), "wb");
257+
auto location = m_exportRoot + "/" + filename;
258+
auto *fp = std::fopen(location.c_str(), "wb");
257259
std::fwrite(
258260
m_dataHost->dataAs<float>(), sizeof(float), m_dataHost->size(), fp);
259261
std::fclose(fp);
260262

261-
tsd::core::logStatus("[jacobi solver] exported data to %s", filename.c_str());
263+
tsd::core::logStatus("[jacobi solver] exported data to %s", location.c_str());
262264
}
263265

264266
} // namespace tsd::demo

tsd/apps/interactive/demos/animatedVolume/SolverControls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct SolverControls : public tsd::ui::imgui::Window
4141
bool m_playing{false};
4242
bool m_useGPUInterop{false};
4343
bool m_updateTF{true};
44+
bool m_dumpVolumes{false};
45+
std::string m_exportRoot{"./"}; // root filename for .raw exports
4446
};
4547

4648
} // namespace tsd::demo

tsd/apps/interactive/demos/animatedVolume/tsdDemoAnimatedVolume.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ class Application : public TSDApplication
106106
return R"layout(
107107
[Window][MainDockSpace]
108108
Pos=0,26
109-
Size=1920,1105
109+
Size=1920,1054
110110
Collapsed=0
111111
112112
[Window][Viewport]
113113
Pos=549,26
114-
Size=821,429
114+
Size=880,798
115115
Collapsed=0
116116
DockId=0x00000003,0
117117
@@ -122,8 +122,8 @@ Collapsed=0
122122
DockId=0x00000004,0
123123
124124
[Window][Log]
125-
Pos=549,885
126-
Size=821,246
125+
Pos=549,826
126+
Size=880,254
127127
Collapsed=0
128128
DockId=0x0000000E,0
129129
@@ -133,32 +133,32 @@ Size=400,400
133133
Collapsed=0
134134
135135
[Window][Layers]
136-
Pos=0,381
137-
Size=547,205
136+
Pos=0,365
137+
Size=547,195
138138
Collapsed=0
139139
DockId=0x0000000C,0
140140
141141
[Window][Object Editor]
142-
Pos=0,588
143-
Size=547,543
142+
Pos=0,562
143+
Size=547,518
144144
Collapsed=0
145145
DockId=0x0000000D,0
146146
147147
[Window][TF Editor]
148-
Pos=1372,26
149-
Size=548,553
148+
Pos=1431,26
149+
Size=489,527
150150
Collapsed=0
151151
DockId=0x00000005,0
152152
153153
[Window][Isosurface Editor]
154-
Pos=1372,581
155-
Size=548,550
154+
Pos=1431,555
155+
Size=489,525
156156
Collapsed=0
157157
DockId=0x00000006,0
158158
159159
[Window][Solver Controls]
160160
Pos=0,26
161-
Size=547,353
161+
Size=547,337
162162
Collapsed=0
163163
DockId=0x00000008,0
164164
@@ -228,21 +228,24 @@ Column 1 Weight=1.0000
228228
Column 0 Weight=1.0000
229229
Column 1 Weight=1.0000
230230
231+
[Table][0x5EB09CD8,2]
232+
Column 0 Weight=1.0000
233+
Column 1 Weight=1.0000
234+
231235
[Docking][Data]
232-
DockSpace ID=0x782A6D6B Pos=0,22 Size=1920,1057 CentralNode=1 Selected=0x13926F0B
233-
DockSpace ID=0x80F5B4C5 Window=0x079D3A04 Pos=0,26 Size=1920,1105 Split=X
236+
DockSpace ID=0x80F5B4C5 Window=0x079D3A04 Pos=0,26 Size=1920,1054 Split=X
234237
DockNode ID=0x0000000A Parent=0x80F5B4C5 SizeRef=547,1054 Split=Y Selected=0xF64741D0
235238
DockNode ID=0x00000008 Parent=0x0000000A SizeRef=547,337 Selected=0xF64741D0
236239
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=547,715 Split=Y Selected=0xCD8384B1
237240
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=547,195 Selected=0xCD8384B1
238241
DockNode ID=0x0000000D Parent=0x00000009 SizeRef=547,518 Selected=0x82B4C496
239242
DockNode ID=0x0000000B Parent=0x80F5B4C5 SizeRef=1371,1054 Split=X
240-
DockNode ID=0x00000001 Parent=0x0000000B SizeRef=1370,1054 Split=Y Selected=0xC450F867
241-
DockNode ID=0x00000007 Parent=0x00000001 SizeRef=821,806 Split=Y Selected=0xC450F867
243+
DockNode ID=0x00000001 Parent=0x0000000B SizeRef=880,1054 Split=Y Selected=0xC450F867
244+
DockNode ID=0x00000007 Parent=0x00000001 SizeRef=821,798 Split=Y Selected=0xC450F867
242245
DockNode ID=0x00000003 Parent=0x00000007 SizeRef=821,429 CentralNode=1 Selected=0xC450F867
243246
DockNode ID=0x00000004 Parent=0x00000007 SizeRef=821,426 Selected=0xA3219422
244-
DockNode ID=0x0000000E Parent=0x00000001 SizeRef=821,246 Selected=0x139FDA3F
245-
DockNode ID=0x00000002 Parent=0x0000000B SizeRef=548,1054 Split=Y Selected=0x3429FA32
247+
DockNode ID=0x0000000E Parent=0x00000001 SizeRef=821,254 Selected=0x139FDA3F
248+
DockNode ID=0x00000002 Parent=0x0000000B SizeRef=489,1054 Split=Y Selected=0x3429FA32
246249
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=548,527 Selected=0x3429FA32
247250
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=548,525 Selected=0xBCE6538B
248251
)layout";

0 commit comments

Comments
 (0)