Skip to content
Snippets Groups Projects
Select Git revision
  • 88cbbf1051c9ad88679ba9b347b29e38e9c0582b
  • main default protected
  • release
3 results

I-V_new.ipynb

Blame
  • pli_processor.cpp 2.32 KiB
    
    #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);
    		*/
    
    	}
    }