diff --git a/modules/volume/CMakeLists.txt b/modules/volume/CMakeLists.txt index 7fe70d9b27..defa6fc0e4 100644 --- a/modules/volume/CMakeLists.txt +++ b/modules/volume/CMakeLists.txt @@ -50,6 +50,7 @@ set(HEADER_FILES rendering/volumeclipplanes.h tasks/generaterawvolumetask.h tasks/generaterawvolumefromfiletask.h + xmlreader.h ) source_group("Header Files" FILES ${HEADER_FILES}) @@ -72,6 +73,7 @@ set(SOURCE_FILES rendering/volumeclipplanes.cpp tasks/generaterawvolumetask.cpp tasks/generaterawvolumefromfiletask.cpp + xmlreader.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/modules/volume/rendering/renderabletimevaryingvolume.cpp b/modules/volume/rendering/renderabletimevaryingvolume.cpp index acd8f5944c..07bc97f7dd 100644 --- a/modules/volume/rendering/renderabletimevaryingvolume.cpp +++ b/modules/volume/rendering/renderabletimevaryingvolume.cpp @@ -48,6 +48,8 @@ #include #include +#include + namespace { constexpr std::string_view _loggerCat = "RenderableTimeVaryingVolume"; @@ -236,6 +238,9 @@ void RenderableTimeVaryingVolume::initializeGL() { if (e.is_regular_file() && e.path().extension() == ".dictionary") { loadTimestepMetadata(e.path()); } + if (e.is_regular_file() && e.path().extension() == ".vti") { + readVTIFile(e.path()); + } } // TODO: defer loading of data to later (separate thread or at least not when loading) diff --git a/modules/volume/xmlreader.cpp b/modules/volume/xmlreader.cpp new file mode 100644 index 0000000000..49e86c3d18 --- /dev/null +++ b/modules/volume/xmlreader.cpp @@ -0,0 +1,92 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2025 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include + +namespace openspace { + +std::string getAttribute(const std::string& line, const std::string& attribute) { + size_t pos = line.find(attribute + "=\""); + if (pos == std::string::npos) { + return ""; + } + pos += attribute.length() + 2; + const size_t end = line.find("\"", pos); + if (pos == std::string::npos) { + return ""; + } + + return line.substr(pos, end - pos); + +} + +void readVTIFile(const std::filesystem::path& path) { + tinyxml2::XMLDocument doc; + + //std::ifstream file; + //file.open(path); + //ghoul_assert(file.good(), "File handle should be good"); + + //std::stringstream ss; + //std::string line; + //while (ghoul::getline(file, line)) { + // std::cout << line << std::endl; + + // if (line.find(" dataValues; + //while (ss >> value) { + // dataValues.push_back(value); + //} + + //file.close(); +} + +} // namespace openspace diff --git a/modules/volume/xmlreader.h b/modules/volume/xmlreader.h new file mode 100644 index 0000000000..f78722c91c --- /dev/null +++ b/modules/volume/xmlreader.h @@ -0,0 +1,31 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2025 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include + +namespace openspace { + + void readVTIFile(const std::filesystem::path& path); + +} // namespace openspace