10 #include <boost/filesystem.hpp> 24 boost::shared_array<T>
reduceData(boost::shared_array<T> data,
27 unsigned int reductionFactor,
28 size_t* reducedDataCount)
30 *reducedDataCount = dataCount / reductionFactor + 1;
32 boost::shared_array<T> reducedData =
33 boost::shared_array<T>(
new T[(*reducedDataCount) * dataWidth]);
35 size_t reducedDataIdx = 0;
36 for (
size_t i = 0; i < dataCount; i++)
38 if (i % reductionFactor == 0)
40 std::copy(data.get() + i * dataWidth,
41 data.get() + (i + 1) * dataWidth,
42 reducedData.get() + reducedDataIdx * dataWidth);
54 boost::filesystem::path inputDir(options.
getInputDir());
55 boost::filesystem::path outputDir(options.
getOutputDir());
57 boost::filesystem::path outputPath(outputDir / options.
getOutputFile());
66 if (!boost::filesystem::exists(inputDir))
74 if (!boost::filesystem::exists(outputDir))
77 if (!boost::filesystem::create_directory(outputDir))
89 if (boost::filesystem::exists(outputPath))
91 std::cout <<
timestamp <<
"File already exists. Expanding File..." << std::endl;
94 hdf.
open(outputPath.string());
100 hdf.
open(outputPath.string());
106 std::cout <<
timestamp <<
"Reading ScanProject from directory" << std::endl;
110 std::cout <<
timestamp <<
"Writing ScanProject to HDF5" << std::endl;
115 existingScanProject->positions.push_back(scanPosPtr);
117 hdf.
save(existingScanProject);
121 hdf.
save(scanProject);
126 for (
int i = 0; i < scanProject->positions.size(); i++)
129 sprintf(buffer,
"%08d", i);
130 string nr_str(buffer);
131 std::string previewGroupName =
"/preview/" + nr_str;
133 std::cout <<
timestamp <<
"Generating preview for position " << nr_str << std::endl;
137 ScanPtr scanPtr = scanPositionPtr->scans[0];
138 floatArr points = scanPtr->points->getPointArray();
144 scanPtr->points->numPoints(),
149 std::vector<size_t> previewDim = {numPreview, 3};
150 hdf.
save<
float>(previewGroupName,
"points", previewDim, previewData);
155 std::cout <<
timestamp <<
"Program finished" << std::endl;
virtual void save(std::string filename)
Save the loaded elements to the given file.
const kaboom::Options * options
ScanProjectPtr loadScanProject()
static Timestamp timestamp
A global time stamp object for program runtime measurement.
typename add_features_with_deps< F... >::type AddFeatures
std::shared_ptr< Scan > ScanPtr
Shared pointer to scans.
int main(int argc, char **argv)
Manager Class for all Hdf5IO components located in hdf5 directory.
boost::shared_array< float > floatArr
std::shared_ptr< ScanProject > ScanProjectPtr
int m_previewReductionFactor
bool loadScanProject(const boost::filesystem::path &root, ScanProject &scanProj)
bool open(std::string filename, int open_flag)
boost::shared_array< T > reduceData(boost::shared_array< T > data, size_t dataCount, size_t dataWidth, unsigned int reductionFactor, size_t *reducedDataCount)
std::shared_ptr< ScanPosition > ScanPositionPtr