This example shows how to save and restore the reconstruction volume.
Boost is only used to generate examples and is not necessary for working with this SDK.
#include <boost/test/unit_test.hpp>
#include <stdio.h>
#include <conio.h>
BOOST_AUTO_TEST_SUITE(example_reconstructmesdk)
BOOST_AUTO_TEST_CASE(volume)
{
puts("Key mapping");
puts("x: quit scanning");
puts("r: reset volume to empty state");
puts("s: save volume to disk");
puts("l: load volume from disk and resume");
puts("All keys need to be pressed with the command line in the foreground");
int num_slices;
const void *bytes;
int length;
void *load_buffer = 0;
int load_buffer_length = 0;
bool continue_scanning = true;
if (_kbhit()) {
char k = _getch();
switch(k) {
case 'r': {
break;
}
case 's' : {
FILE *f = fopen("volume.bin", "wb");
for (int i = 0; i < num_slices; i++)
{
fwrite(&length, sizeof(int), 1, f);
fwrite(bytes, 1, length, f);
}
fclose(f);
break;
}
case 'l': {
FILE *f = fopen("volume.bin", "rb");
for (int i = 0; i < num_slices; i++)
{
fread(&length, sizeof(int), 1, f);
if (load_buffer_length != length) {
if (load_buffer != 0)
free(load_buffer);
load_buffer = malloc(length);
load_buffer_length = length;
}
fread(load_buffer, 1, length, f);
}
fclose(f);
if (load_buffer != 0) {
free(load_buffer);
load_buffer = 0;
load_buffer_length = 0;
}
break;
}
case 'x': {
continue_scanning = false;
break;
}
}
}
}
}
}
BOOST_AUTO_TEST_SUITE_END()