mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Feature/filesystem cleanup (#1587)
* Adapting to the changes in Ghoul * First step of moving filesystem functions to std * Remove persistence flag from cachemanager
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
@@ -209,32 +210,26 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume(
|
||||
RenderableTimeVaryingVolume::~RenderableTimeVaryingVolume() {}
|
||||
|
||||
void RenderableTimeVaryingVolume::initializeGL() {
|
||||
using RawPath = ghoul::filesystem::Directory::RawPath;
|
||||
ghoul::filesystem::Directory sequenceDir(_sourceDirectory, RawPath::Yes);
|
||||
std::string sequenceDir = absPath(_sourceDirectory);
|
||||
|
||||
if (!FileSys.directoryExists(sequenceDir)) {
|
||||
LERROR(fmt::format("Could not load sequence directory '{}'", sequenceDir.path()));
|
||||
if (!std::filesystem::is_directory(sequenceDir)) {
|
||||
LERROR(fmt::format("Could not load sequence directory '{}'", sequenceDir));
|
||||
return;
|
||||
}
|
||||
|
||||
using Recursive = ghoul::filesystem::Directory::Recursive;
|
||||
using Sort = ghoul::filesystem::Directory::Sort;
|
||||
|
||||
std::vector<std::string> sequencePaths = sequenceDir.read(Recursive::Yes, Sort::No);
|
||||
for (const std::string& path : sequencePaths) {
|
||||
ghoul::filesystem::File currentFile(path);
|
||||
std::string extension = currentFile.fileExtension();
|
||||
if (extension == "dictionary") {
|
||||
loadTimestepMetadata(path);
|
||||
namespace fs = std::filesystem;
|
||||
for (const fs::directory_entry& e : fs::recursive_directory_iterator(sequenceDir)) {
|
||||
if (e.is_regular_file() && e.path().extension() == ".dictionary") {
|
||||
loadTimestepMetadata(e.path().string());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: defer loading of data to later (separate thread or at least not when loading)
|
||||
for (std::pair<const double, Timestep>& p : _volumeTimesteps) {
|
||||
Timestep& t = p.second;
|
||||
std::string path = FileSys.pathByAppendingComponent(
|
||||
_sourceDirectory, t.baseName
|
||||
) + ".rawvolume";
|
||||
std::string path = fmt::format(
|
||||
"{}/{}.rawvolume", _sourceDirectory.value(), t.baseName
|
||||
);
|
||||
RawVolumeReader<float> reader(path, t.metadata.dimensions);
|
||||
t.rawVolume = reader.read();
|
||||
|
||||
@@ -334,7 +329,7 @@ void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::string& path)
|
||||
|
||||
Timestep t;
|
||||
t.metadata = metadata;
|
||||
t.baseName = ghoul::filesystem::File(path).baseName();
|
||||
t.baseName = std::filesystem::path(path).stem().string();
|
||||
t.inRam = false;
|
||||
t.onGpu = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user