Skip to content
Snippets Groups Projects
Commit 00477374 authored by cgrabosch's avatar cgrabosch
Browse files

add processing of pli data

parent f16ac6cf
No related branches found
No related tags found
No related merge requests found
#ifndef LIBRARY_PHX_LINE_SEGMENTS_HPP_
#define LIBRARY_PHX_LINE_SEGMENTS_HPP_
#include <vector>
#include <glm/glm.hpp>
namespace phx {
struct line_segments
{
std::vector<glm::vec3> vertices;
std::vector<glm::u8vec4> colors;
std::vector<std::uint32_t> indices;
float radius = 1.0f;
};
}
#endif
\ No newline at end of file
......@@ -18,8 +18,8 @@ SUPPRESS_WARNINGS_END
namespace phx {
std::unique_ptr<phx::Resource> PLILoader::Load(
const ResourceDeclaration& declaration) {
std::unique_ptr<phx::Resource> PLILoader::Load(const ResourceDeclaration& declaration)
{
//check for all important information
if (declaration.find("file_name") == declaration.end() ||
......@@ -138,9 +138,11 @@ namespace phx {
glm::vec3(0)
);
tbb::parallel_for (std::size_t(0), size_vec[2], std::size_t(1), [&](std::size_t x) {
tbb::parallel_for (std::size_t(0), size_vec[3], std::size_t(1), [&](std::size_t y) {
tbb::parallel_for (std::size_t(0), size_vec[0], std::size_t(1), [&](std::size_t z) {
//collapse nested loops for (hopefully) better performance
tbb::parallel_for(tbb::blocked_range3d<int>(std::size_t(0), size_vec[2], std::size_t(0), size_vec[3], std::size_t(0), size_vec[0]), [&](const tbb::blocked_range3d<int> &r) {
for (int x = r.pages().begin(), x_end = r.pages().end(); x < x_end; x++) {
for (int y = r.rows().begin(), y_end = r.rows().end(); y < y_end; y++) {
for (int z = r.cols().begin(), z_end = r.cols().end(); z < z_end; z++) {
const size_t padded_coord =
(x + zero_pad_) + (size_vec[2] + 2 * zero_pad_) *
......@@ -152,8 +154,9 @@ namespace phx {
glm::vec3(orientation_data[z][0][x][y],
orientation_data[z][1][x][y],
orientation_data[z][2][x][y]);
});
});
}
}
}
});
//free memory
......@@ -166,6 +169,7 @@ namespace phx {
resource->SetRetardation(retardation_result);
resource->SetTransmittance(transmittance_result);
//free memory
orientation_result.resize(0);
transmittance_result.resize(0);
retardation_result.resize(0);
......
#include "phx/pli_processor.hpp"
#include "phx/pli_loader.hpp"
#include "phx/pli_region.hpp"
#include "phx/resource_declaration.hpp"
#include "phx/resource_manager.hpp"
#include "phx/line_segments.hpp"
#include "phx/resource_utils.hpp"
#include <string>
namespace phx {
line_segments make_hedgehog(Resource* resource, const float length = 1.0f, const float radius = 1.0f)
{
auto pli_region = dynamic_cast<PLIRegion *>(resource);
auto size = pli_region->GetSize();
//create return value
line_segments segments;
segments.radius = radius;
for (auto z = 0; z < size[0]; z++)
{
for (auto x = 0; x < size[1]; x++)
{
for (auto y = 0; y < size[2]; y++)
{
const auto center = glm::vec3(x, y, z);
const auto direction = glm::normalize(glm::vec3(pli_region->GetOrientation[z][0][x][y], pli_region->GetOrientation[z][1][x][y], pli_region->GetOrientation[z][2][x][y]));
segments.vertices.push_back(center + length / 2.0f * direction);
segments.vertices.push_back(center - length / 2.0f * direction);
segments.colors.push_back(glm::u8vec4(glm::abs(direction) * 255.0f, 255));
segments.colors.push_back(glm::u8vec4(glm::abs(direction) * 255.0f, 255));
segments.indices.push_back(static_cast<std::uint32_t>(segments.vertices.size() - 2));
segments.indices.push_back(static_cast<std::uint32_t>(segments.vertices.size() - 1));
}
}
}
return segments;
}
void pli_prepare_data() {
//TODO: find out how ResourceDeclaration/ nlohmann-json works
//TODO: find out why Load doesn't work
std::string addr("O:/Documents/MSA0309_s0536-0695.h5");
ResourceDeclaration& declaration(
(ResourceDeclaration)addr, { { "from",{ { "X", 0.0f },{ "Y", 0.0f },{ "Z", 0.0f } } },
{ "to",{ { "X", 360.0f },{ "Y", 560.0f },{ "Z", 25.0f } } },
{ "stride",{ { "X", 3.0f },{ "Y", 3.0f },{ "Z", 3.0f } } } },
false);
auto pli_resource = PLILoader::Load(declaration);
/*
auto pli_resource = ResourceUtils::LoadResourceFromFile<phx::PLIRegion>(
R"(O:\Documents\MSA0309_s0536-0695.h5)",
{ { "from",{ { "X", 0.0f },{ "Y", 0.0f },{ "Z", 0.0f } } },
{ "to",{ { "X", 360.0f },{ "Y", 560.0f },{ "Z", 25.0f } } },
{ "stride",{ { "X", 3.0f },{ "Y", 3.0f },{ "Z", 3.0f } } } });
auto resource = dynamic_cast<Resource *>(pli_resource);
auto mesh = make_hedgehog(pli_resource, 1.0f, 1.0f);
*/
}
}
\ No newline at end of file
#ifndef LIBRARY_PHX_PLI_PROCESSOR_HPP_
#define LIBRARY_PHX_PLI_PROCESSOR_HPP_
#include "phx/pli_processor.hpp"
#include "phx/pli_region.hpp"
#include "phx/resource_declaration.hpp"
#include "phx/resource_manager.hpp"
#include "phx/line_segments.hpp"
namespace phx{
line_segments make_hedgehog(Resource* resource, const float length = 1.0f, const float radius = 1.0f);
}
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment