mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-02 01:30:34 -06:00
.vti reader wip
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
#include <modules/volume/xmlreader.h>
|
||||
|
||||
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)
|
||||
|
||||
92
modules/volume/xmlreader.cpp
Normal file
92
modules/volume/xmlreader.cpp
Normal file
@@ -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 <modules/volume/xmlreader.h>
|
||||
#include <fstream>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/misc/stringhelper.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <tinyxml>
|
||||
|
||||
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("<ImageData") != std::string::npos) {
|
||||
// const std::string wholeExtent = getAttribute(line, "WholeExtent");
|
||||
// const std::string origin = getAttribute(line, "Origin");
|
||||
// const std::string spacing = getAttribute(line, "Spacing");
|
||||
|
||||
// std::cout << "Whole extent '" << wholeExtent << "'\n"
|
||||
// << "origin '" << origin << "'\n"
|
||||
// << "spacing '" << spacing << "'\n";
|
||||
// }
|
||||
// else if (line.find("<Piece") != std::string::npos) {
|
||||
// const std::string extent = getAttribute(line, "Extent");
|
||||
// std::cout << "Extent: " << extent << std::endl;
|
||||
// }
|
||||
|
||||
// else if (line.find("<DataArray") != std::string::npos) {
|
||||
// ghoul::getline(file, line);
|
||||
// ss << line << " ";
|
||||
// }
|
||||
//}
|
||||
|
||||
//float value = 0.f;
|
||||
//std::vector<float> dataValues;
|
||||
//while (ss >> value) {
|
||||
// dataValues.push_back(value);
|
||||
//}
|
||||
|
||||
//file.close();
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
31
modules/volume/xmlreader.h
Normal file
31
modules/volume/xmlreader.h
Normal file
@@ -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 <ghoul/filesystem/filesystem.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void readVTIFile(const std::filesystem::path& path);
|
||||
|
||||
} // namespace openspace
|
||||
Reference in New Issue
Block a user