From 527173127d3c598a47508b7b3f89ad7228eeeb5f Mon Sep 17 00:00:00 2001 From: Moritz Heinemann Date: Mon, 15 Jan 2024 17:52:54 +0100 Subject: [PATCH 1/2] add datraw port --- cmake/vcpkg_ports/datraw/portfile.cmake | 14 ++++++++++++++ cmake/vcpkg_ports/datraw/vcpkg.json | 7 +++++++ plugins/volume/CMakeLists.txt | 3 +++ vcpkg.json | 1 + 4 files changed, 25 insertions(+) create mode 100644 cmake/vcpkg_ports/datraw/portfile.cmake create mode 100644 cmake/vcpkg_ports/datraw/vcpkg.json diff --git a/cmake/vcpkg_ports/datraw/portfile.cmake b/cmake/vcpkg_ports/datraw/portfile.cmake new file mode 100644 index 0000000000..d1b09b09d8 --- /dev/null +++ b/cmake/vcpkg_ports/datraw/portfile.cmake @@ -0,0 +1,14 @@ +# header-only library + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO UniStuttgart-VISUS/datraw + REF "v${VERSION}" + SHA512 f38401e0e878f8df8e1b7b9750f4e7fec6920495bfb914a694aab166a0ffbda6dec189693a0d5b9aadb760789706e255f49a382d4e902002aef7120033dce016 + HEAD_REF master +) + +file(COPY "${SOURCE_PATH}/datraw/datraw.h" "${SOURCE_PATH}/datraw/datraw" + DESTINATION "${CURRENT_PACKAGES_DIR}/include") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENCE.md") diff --git a/cmake/vcpkg_ports/datraw/vcpkg.json b/cmake/vcpkg_ports/datraw/vcpkg.json new file mode 100644 index 0000000000..428deb8e2c --- /dev/null +++ b/cmake/vcpkg_ports/datraw/vcpkg.json @@ -0,0 +1,7 @@ +{ + "name": "datraw", + "version": "1.0.9", + "description": "C++ reimplementation of VIS's datraw library.", + "homepage": "https://github.com/UniStuttgart-VISUS/datraw", + "license": "MIT" +} diff --git a/plugins/volume/CMakeLists.txt b/plugins/volume/CMakeLists.txt index 5b5b64fa03..602d4fbb61 100644 --- a/plugins/volume/CMakeLists.txt +++ b/plugins/volume/CMakeLists.txt @@ -10,6 +10,9 @@ megamol_plugin(volume geometry_calls) if (volume_PLUGIN_ENABLED) + find_path(DATRAW_INCLUDE_DIRS "datraw.h") + target_include_directories(volume PRIVATE ${DATRAW_INCLUDE_DIRS}) + #XXX: hacky appraoch to include datraw add_subdirectory(datraw) diff --git a/vcpkg.json b/vcpkg.json index bb25792267..0a3c8686b4 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -16,6 +16,7 @@ "cppzmq", "curl", "cxxopts", + "datraw", "delaunator-cpp", "eigen3", "glfw3", From 142ad6afe38c3cbb26cf0c5e7adf8036f4e68a7b Mon Sep 17 00:00:00 2001 From: tmarm Date: Thu, 4 Apr 2024 15:12:50 +0200 Subject: [PATCH 2/2] Begin new call --- plugins/volume/src/NewDatRawReader.cpp | 108 +++++++++++++++++++++++++ plugins/volume/src/NewDatRawReader.h | 61 ++++++++++++++ plugins/volume/src/volume.cpp | 2 + 3 files changed, 171 insertions(+) create mode 100644 plugins/volume/src/NewDatRawReader.cpp create mode 100644 plugins/volume/src/NewDatRawReader.h diff --git a/plugins/volume/src/NewDatRawReader.cpp b/plugins/volume/src/NewDatRawReader.cpp new file mode 100644 index 0000000000..7b967e7151 --- /dev/null +++ b/plugins/volume/src/NewDatRawReader.cpp @@ -0,0 +1,108 @@ +/* + * VolumetricDataSource.cpp + * + * Copyright (C) 2024 by Visualisierungsinstitut der Universit�t Stuttgart. + * Alle rechte vorbehalten. + */ + +#include "NewDatRawReader.h" + +#include "mmcore/param/BoolParam.h" +#include "mmcore/param/EnumParam.h" +#include "mmcore/param/FilePathParam.h" +#include "mmcore/param/FloatParam.h" +#include "mmcore/param/IntParam.h" +#include "mmcore/param/StringParam.h" + +#include "datraw.h" +#include "mmcore/utility/log/Log.h" + +megamol::volume::NewDatRawReader::NewDatRawReader() + : core::Module() + , slotGetData("GetData", "Slot for requesting data.") + , paramFileName("FileName", "Path to file.") { + using geocalls::VolumetricDataCall; + this->slotGetData.SetCallback(VolumetricDataCall::ClassName(), + VolumetricDataCall::FunctionName(VolumetricDataCall::IDX_GET_DATA), &NewDatRawReader::onGetData); + this->slotGetData.SetCallback(VolumetricDataCall::ClassName(), + VolumetricDataCall::FunctionName(VolumetricDataCall::IDX_GET_EXTENTS), &NewDatRawReader::onGetExtents); + this->slotGetData.SetCallback(VolumetricDataCall::ClassName(), + VolumetricDataCall::FunctionName(VolumetricDataCall::IDX_GET_METADATA), &NewDatRawReader::onGetMetadata); + this->slotGetData.SetCallback(VolumetricDataCall::ClassName(), + VolumetricDataCall::FunctionName(VolumetricDataCall::IDX_START_ASYNC), &NewDatRawReader::onStartAsync); + this->slotGetData.SetCallback(VolumetricDataCall::ClassName(), + VolumetricDataCall::FunctionName(VolumetricDataCall::IDX_STOP_ASYNC), &NewDatRawReader::onStopAsync); + this->slotGetData.SetCallback(VolumetricDataCall::ClassName(), + VolumetricDataCall::FunctionName(VolumetricDataCall::IDX_TRY_GET_DATA), &NewDatRawReader::onTryGetData); + + this->MakeSlotAvailable(&this->slotGetData); + + this->paramFileName.SetParameter(new core::param::FilePathParam("")); + this->paramFileName.SetUpdateCallback(&NewDatRawReader::onFileNameChange); + this->MakeSlotAvailable(&this->paramFileName); +} + +megamol::volume::NewDatRawReader::~NewDatRawReader() {} + +bool megamol::volume::NewDatRawReader::create() { + return true; +} + +void megamol::volume::NewDatRawReader::release() {} + +bool megamol::volume::NewDatRawReader::onGetData(core::Call& call) { + geocalls::VolumetricDataCall& c = dynamic_cast(call); + return true; +} + +bool megamol::volume::NewDatRawReader::onGetMetadata(core::Call& call) { + return false; +} + +bool megamol::volume::NewDatRawReader::onGetExtents(core::Call& call) { + try { + std::vector volExt; + volExt.push_back(datInfo.slice_thickness()[0] * datInfo.resolution()[0]); + volExt.push_back(datInfo.slice_thickness()[1] * datInfo.resolution()[1]); + volExt.push_back(datInfo.slice_thickness()[2] * datInfo.resolution()[2]); + + geocalls::VolumetricDataCall& c = dynamic_cast(call); + c.SetExtent(datInfo.time_steps(), datInfo.origin()[0], datInfo.origin()[1], datInfo.origin()[2] + , datInfo.origin()[0] + volExt[0], datInfo.origin()[1] + volExt[1], datInfo.origin()[2] + volExt[2]); + return true; + } catch (vislib::Exception e) { + //TODO exception + return false; + } +} + +bool megamol::volume::NewDatRawReader::onStartAsync(core::Call& call) { + return true; +} + +bool megamol::volume::NewDatRawReader::onStopAsync(core::Call& call) { + return true; +} + +bool megamol::volume::NewDatRawReader::onTryGetData(core::Call& call) { + try { + + } + catch (std::exception e) { + geocalls::VolumetricDataCall& c = dynamic_cast(call); + //what does this do? + c.SetDataHash(12345u); + return false; + } + return false; +} + +bool megamol::volume::NewDatRawReader::onFileNameChange(core::param::ParamSlot& slot) { + // does this actually throw file not found exceptions? + try { + datInfo = datraw::info::load(slot.Param()->Value().generic_string().c_str()); + } catch (std::exception e) { + megamol::core::utility::log::Log::DefaultLog.WriteInfo("%s\n", e.what()); + } + return true; +} diff --git a/plugins/volume/src/NewDatRawReader.h b/plugins/volume/src/NewDatRawReader.h new file mode 100644 index 0000000000..250aad3ca5 --- /dev/null +++ b/plugins/volume/src/NewDatRawReader.h @@ -0,0 +1,61 @@ +/* + * VolumetricDataSource.h + * + * Copyright (C) 2024 by Visualisierungsinstitut der Universität Stuttgart. + * Alle rechte vorbehalten. + */ + +#pragma once + +#include +#include +#include + +#include "datraw/raw_reader.h" + +#include "geometry_calls/VolumetricDataCall.h" + +#include "mmcore/param/ParamSlot.h" + +#include "mmcore/Call.h" +#include "mmcore/CalleeSlot.h" +#include "mmcore/Module.h" + +#include "vislib/PtrArray.h" +#include "vislib/RawStorage.h" +#include "vislib/sys/Event.h" +#include "vislib/sys/Thread.h" + +namespace megamol::volume { +class NewDatRawReader : public core::Module { + +public: + static inline const char* ClassName() { + return "NewDatRawReader"; + } + static inline const char* Description() { + return "Data source for DatRaw volumetric data."; + } + static inline bool IsAvailable() { + return true; + } + NewDatRawReader(); + ~NewDatRawReader() override; + +protected: + bool create() override; + void release() override; + +private: + core::CalleeSlot slotGetData; + core::param::ParamSlot paramFileName; + datraw::info datInfo; + bool onGetData(core::Call& call); + bool onGetMetadata(core::Call& call); + bool onGetExtents(core::Call& call); + bool onStartAsync(core::Call& call); + bool onStopAsync(core::Call& call); + bool onTryGetData(core::Call& call); + bool onFileNameChange(core::param::ParamSlot& slot); +}; +} // namespace megamol::volume diff --git a/plugins/volume/src/volume.cpp b/plugins/volume/src/volume.cpp index a971f86fec..02a6f9ff59 100644 --- a/plugins/volume/src/volume.cpp +++ b/plugins/volume/src/volume.cpp @@ -11,6 +11,7 @@ #include "DatRawWriter.h" #include "DifferenceVolume.h" #include "VolumetricDataSource.h" +#include "NewDatRawReader.h" namespace megamol::volume { class VolumePluginInstance : public megamol::core::factories::AbstractPluginInstance { @@ -30,6 +31,7 @@ class VolumePluginInstance : public megamol::core::factories::AbstractPluginInst this->module_descriptions.RegisterAutoDescription(); this->module_descriptions.RegisterAutoDescription(); this->module_descriptions.RegisterAutoDescription(); + this->module_descriptions.RegisterAutoDescription(); // register calls }