diff --git a/apps/OpenSpace/ext/launcher/include/launcherwindow.h b/apps/OpenSpace/ext/launcher/include/launcherwindow.h index 6a67b1eaff..6ea2a689f7 100644 --- a/apps/OpenSpace/ext/launcher/include/launcherwindow.h +++ b/apps/OpenSpace/ext/launcher/include/launcherwindow.h @@ -32,6 +32,7 @@ #include #include #include +#include #include namespace openspace { struct Configuration; } @@ -89,7 +90,7 @@ public: private: QWidget* createCentralWidget(); - void setBackgroundImage(const std::string& syncPath); + void setBackgroundImage(const std::filesystem::path& syncPath); void openProfileEditor(const std::string& profile, bool isUserProfile); void openWindowEditor(const std::string& winCfg, bool isUserWinCfg); @@ -99,15 +100,15 @@ private: void populateProfilesList(const std::string& preset); void populateWindowConfigsList(const std::string& preset); void handleReturnFromWindowEditor(const sgct::config::Cluster& cluster, - std::filesystem::path savePath, const std::string& saveWindowCfgPath); + std::filesystem::path savePath, const std::filesystem::path& saveWindowCfgPath); void onNewWindowConfigSelection(int newIndex); - const std::string _assetPath; - const std::string _userAssetPath; - const std::string _configPath; - const std::string _userConfigPath; - const std::string _profilePath; - const std::string _userProfilePath; + const std::filesystem::path _assetPath; + const std::filesystem::path _userAssetPath; + const std::filesystem::path _configPath; + const std::filesystem::path _userConfigPath; + const std::filesystem::path _profilePath; + const std::filesystem::path _userProfilePath; bool _shouldLaunch = false; int _userAssetCount = 0; int _userConfigStartingIdx = 0; diff --git a/apps/OpenSpace/ext/launcher/include/profile/assetsdialog.h b/apps/OpenSpace/ext/launcher/include/profile/assetsdialog.h index ba17c32986..ec06ba98bb 100644 --- a/apps/OpenSpace/ext/launcher/include/profile/assetsdialog.h +++ b/apps/OpenSpace/ext/launcher/include/profile/assetsdialog.h @@ -74,7 +74,8 @@ public: * living */ AssetsDialog(QWidget* parent, openspace::Profile* profile, - const std::string& assetBasePath, const std::string& userAssetBasePath); + const std::filesystem::path& assetBasePath, + const std::filesystem::path& userAssetBasePath); private slots: void searchTextChanged(const QString& text); diff --git a/apps/OpenSpace/ext/launcher/include/profile/profileedit.h b/apps/OpenSpace/ext/launcher/include/profile/profileedit.h index 6a1203b17a..e50a490a7c 100644 --- a/apps/OpenSpace/ext/launcher/include/profile/profileedit.h +++ b/apps/OpenSpace/ext/launcher/include/profile/profileedit.h @@ -53,8 +53,9 @@ public: * \param parent Pointer to parent Qt widget */ ProfileEdit(openspace::Profile& profile, const std::string& profileName, - std::string assetBasePath, std::string userAssetBasePath, - std::string builtInProfileBasePath, std::string profileBasePath, QWidget* parent); + std::filesystem::path assetBasePath, std::filesystem::path userAssetBasePath, + std::filesystem::path builtInProfileBasePath, + std::filesystem::path profileBasePath, QWidget* parent); /** * Gets the status of the save when the window is closed; was the file saved? @@ -98,10 +99,10 @@ private: void initSummaryTextForEachCategory(); openspace::Profile& _profile; - const std::string _assetBasePath; - const std::string _userAssetBasePath; - const std::string _profileBasePath; - const std::string _builtInProfilesPath; + const std::filesystem::path _assetBasePath; + const std::filesystem::path _userAssetBasePath; + const std::filesystem::path _profileBasePath; + const std::filesystem::path _builtInProfilesPath; bool _saveSelected = false; QLineEdit* _profileEdit = nullptr; diff --git a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h index 4db02f5a9b..850364dafc 100644 --- a/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h +++ b/apps/OpenSpace/ext/launcher/include/sgctedit/sgctedit.h @@ -54,7 +54,7 @@ public: * \param userConfigPath A string containing the file path of the user config * directory where all window configs are stored */ - SgctEdit(QWidget* parent, std::string userConfigPath); + SgctEdit(QWidget* parent, std::filesystem::path userConfigPath); /** * Constructor for SgctEdit class, the underlying class for the full window @@ -67,7 +67,7 @@ public: * \param parent Pointer to parent Qt widget */ SgctEdit(sgct::config::Cluster& cluster, std::string configName, - std::string& configBasePath, QWidget* parent); + std::filesystem::path& configBasePath, QWidget* parent); /** * Returns the saved filename. @@ -124,7 +124,7 @@ private: DisplayWindowUnion* _displayWidget = nullptr; SettingsWidget* _settingsWidget = nullptr; sgct::config::Cluster _cluster; - const std::string _userConfigPath; + const std::filesystem::path _userConfigPath; const std::array _colorsForWindows = { QColor(0x2B, 0x9E, 0xC3), QColor(0xFC, 0xAB, 0x10), diff --git a/apps/OpenSpace/ext/launcher/src/filesystemaccess.cpp b/apps/OpenSpace/ext/launcher/src/filesystemaccess.cpp index 075280fee9..f6ca441454 100644 --- a/apps/OpenSpace/ext/launcher/src/filesystemaccess.cpp +++ b/apps/OpenSpace/ext/launcher/src/filesystemaccess.cpp @@ -101,7 +101,7 @@ void FileSystemAccess::parseChildFile(std::string filename, bool& hasDirHeaderBe if (!hasDirHeaderBeenAdded) { for (const std::string& d : dirNames) { - if (d.length() > 0) { + if (!d.empty()) { output.push_back(cbox + d); } } diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 8d7c14b5d8..162d11b0d9 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -96,7 +96,9 @@ namespace { ); } // namespace geometry - std::optional loadProfileFromFile(QWidget* parent, std::string filename) { + std::optional loadProfileFromFile(QWidget* parent, + std::filesystem::path filename) + { // Verify that the file actually exists if (!std::filesystem::exists(filename)) { QMessageBox::critical( @@ -210,14 +212,12 @@ LauncherWindow::LauncherWindow(bool profileEnabled, bool sgctConfigEnabled, std::string sgctConfigName, QWidget* parent) : QMainWindow(parent) - , _assetPath(absPath(globalConfig.pathTokens.at("ASSETS")).string() + '/') - , _userAssetPath(absPath(globalConfig.pathTokens.at("USER_ASSETS")).string() + '/') - , _configPath(absPath(globalConfig.pathTokens.at("CONFIG")).string() + '/') - , _userConfigPath(absPath(globalConfig.pathTokens.at("USER_CONFIG")).string() + '/') - , _profilePath(absPath(globalConfig.pathTokens.at("PROFILES")).string() + '/') - , _userProfilePath( - absPath(globalConfig.pathTokens.at("USER_PROFILES")).string() + '/' - ) + , _assetPath(absPath(globalConfig.pathTokens.at("ASSETS")) / "") + , _userAssetPath(absPath(globalConfig.pathTokens.at("USER_ASSETS")) / "") + , _configPath(absPath(globalConfig.pathTokens.at("CONFIG")) / "") + , _userConfigPath(absPath(globalConfig.pathTokens.at("USER_CONFIG")) / "") + , _profilePath(absPath(globalConfig.pathTokens.at("PROFILES")) / "") + , _userProfilePath(absPath(globalConfig.pathTokens.at("USER_PROFILES")) / "") , _sgctConfigName(std::move(sgctConfigName)) { Q_INIT_RESOURCE(resources); @@ -256,7 +256,7 @@ LauncherWindow::LauncherWindow(bool profileEnabled, ); if (std::filesystem::exists(p)) { try { - setBackgroundImage(p.string()); + setBackgroundImage(p); } catch (const std::exception& e) { std::cerr << "Error occurrred while reading background images: " << e.what(); @@ -414,7 +414,7 @@ QWidget* LauncherWindow::createCentralWidget() { return centralWidget; } -void LauncherWindow::setBackgroundImage(const std::string& syncPath) { +void LauncherWindow::setBackgroundImage(const std::filesystem::path& syncPath) { namespace fs = std::filesystem; // First, we iterate through all folders in the launcher_images sync folder and we get @@ -444,17 +444,17 @@ void LauncherWindow::setBackgroundImage(const std::string& syncPath) { } // Now we know which folder to use, we will pick an image at random - std::vector files; + std::vector files; for (const fs::directory_entry& p : fs::directory_iterator(latest.path)) { - files.push_back(p.path().string()); + files.push_back(p.path()); } std::random_device rd; std::mt19937 g(rd()); std::shuffle(files.begin(), files.end(), g); // We know there has to be at least one folder, so it's fine to just pick the first while (!files.empty()) { - const std::string& p = files.front(); - if (std::filesystem::path(p).extension() == ".png") { + const std::filesystem::path& p = files.front(); + if (p.extension() == ".png") { // If the top path starts with the png extension, we have found our candidate break; } @@ -467,7 +467,7 @@ void LauncherWindow::setBackgroundImage(const std::string& syncPath) { // There better be at least one file left, but just in in case if (!files.empty()) { - const std::string& image = files.front(); + std::string image = files.front().string(); _backgroundImage->setPixmap(QPixmap(QString::fromStdString(image))); } } @@ -510,8 +510,8 @@ void LauncherWindow::populateProfilesList(const std::string& preset) { QString::fromStdString(path.string()) ); - // Add toooltip - std::optional p = loadProfileFromFile(this, path.string()); + // Add tooltip + std::optional p = loadProfileFromFile(this, path); const int idx = _profileBox->count() - 1; if (p.has_value() && (*p).meta.has_value()) { const std::optional& d = p->meta.value().description; @@ -549,7 +549,7 @@ void LauncherWindow::populateProfilesList(const std::string& preset) { ); // Add toooltip - std::optional p = loadProfileFromFile(this, path.string()); + std::optional p = loadProfileFromFile(this, path); const int idx = _profileBox->count() - 1; if (p.has_value() && (*p).meta.has_value()) { const std::optional& d = p->meta.value().description; @@ -594,7 +594,7 @@ bool handleConfigurationFile(QComboBox& box, const std::filesystem::directory_en if (isJson) { std::string tooltipDescription; try { - const sgct::config::Meta meta = sgct::readMeta(p.path().string()); + const sgct::config::Meta meta = sgct::readMeta(p.path()); tooltipDescription = meta.description; } catch (const sgct::Error&) { @@ -719,7 +719,6 @@ void LauncherWindow::populateWindowConfigsList(const std::string& preset) { void LauncherWindow::onNewWindowConfigSelection(int newIndex) { const std::filesystem::path pathSelected = absPath(selectedWindowConfig()); - const std::string fileSelected = pathSelected.string(); if (newIndex == _windowConfigBoxIndexSgctCfgDefault) { _editWindowButton->setEnabled(false); _editWindowButton->setToolTip( @@ -731,14 +730,14 @@ void LauncherWindow::onNewWindowConfigSelection(int newIndex) { _editWindowButton->setToolTip( QString::fromStdString(std::format( "Cannot edit '{}'\nsince it is one of the configuration " - "files provided in the OpenSpace installation", fileSelected + "files provided in the OpenSpace installation", pathSelected )) ); } else { try { sgct::config::GeneratorVersion previewGenVersion = - sgct::readConfigGenerator(fileSelected); + sgct::readConfigGenerator(pathSelected); if (!versionCheck(previewGenVersion)) { _editWindowButton->setEnabled(false); _editWindowButton->setToolTip(QString::fromStdString(std::format( @@ -759,14 +758,14 @@ void LauncherWindow::onNewWindowConfigSelection(int newIndex) { void LauncherWindow::openProfileEditor(const std::string& profile, bool isUserProfile) { std::optional p; - std::string saveProfilePath = isUserProfile ? _userProfilePath : _profilePath; + std::filesystem::path savePath = isUserProfile ? _userProfilePath : _profilePath; if (profile.empty()) { // If the requested profile is the empty string, then we want to create a new one p = Profile(); } else { // Otherwise, we want to load that profile - std::string fullProfilePath = saveProfilePath + profile + ".profile"; + std::string fullProfilePath = std::format("{}{}.profile", savePath, profile); p = loadProfileFromFile(this, std::move(fullProfilePath)); if (!p.has_value()) { return; @@ -779,16 +778,17 @@ void LauncherWindow::openProfileEditor(const std::string& profile, bool isUserPr _assetPath, _userAssetPath, _profilePath, - saveProfilePath, + savePath, this ); editor.exec(); if (editor.wasSaved()) { if (editor.specifiedFilename() != profile) { - saveProfilePath = _userProfilePath; + savePath = _userProfilePath; } - const std::string path = - saveProfilePath + editor.specifiedFilename() + ".profile"; + const std::string path = std::format( + "{}{}.profile", savePath, editor.specifiedFilename() + ); saveProfile(this, path, *p); populateProfilesList(editor.specifiedFilename()); } @@ -812,7 +812,7 @@ void LauncherWindow::editRefusalDialog(const std::string& title, const std::stri void LauncherWindow::openWindowEditor(const std::string& winCfg, bool isUserWinCfg) { using namespace sgct; - std::string saveWindowCfgPath = isUserWinCfg ? _userConfigPath : _configPath; + std::filesystem::path saveWindowPath = isUserWinCfg ? _userConfigPath : _configPath; int ret = QDialog::DialogCode::Rejected; config::Cluster preview; if (winCfg.empty()) { @@ -822,7 +822,7 @@ void LauncherWindow::openWindowEditor(const std::string& winCfg, bool isUserWinC handleReturnFromWindowEditor( editor.cluster(), editor.saveFilename(), - saveWindowCfgPath + saveWindowPath ); } } @@ -831,12 +831,12 @@ void LauncherWindow::openWindowEditor(const std::string& winCfg, bool isUserWinC config::GeneratorVersion previewGenVersion = readConfigGenerator(winCfg); loadFileAndSchemaThenValidate( winCfg, - _configPath + "/schema/sgct.schema.json", + _configPath / "schema/sgct.schema.json", "This configuration file is unable to generate a proper display" ); loadFileAndSchemaThenValidate( winCfg, - _configPath + "/schema/sgcteditor.schema.json", + _configPath / "schema/sgcteditor.schema.json", "This configuration file is valid for generating a display, but " "its format does not match the window editor requirements and " "cannot be opened in the editor" @@ -856,10 +856,10 @@ void LauncherWindow::openWindowEditor(const std::string& winCfg, bool isUserWinC "problem detected in the readConfig function:\n\n{}", e.what() )); } - SgctEdit editor( + SgctEdit editor = SgctEdit( preview, winCfg, - saveWindowCfgPath, + saveWindowPath, this ); ret = editor.exec(); @@ -867,7 +867,7 @@ void LauncherWindow::openWindowEditor(const std::string& winCfg, bool isUserWinC handleReturnFromWindowEditor( editor.cluster(), editor.saveFilename(), - saveWindowCfgPath + saveWindowPath ); } } @@ -894,7 +894,7 @@ void LauncherWindow::openWindowEditor(const std::string& winCfg, bool isUserWinC void LauncherWindow::handleReturnFromWindowEditor(const sgct::config::Cluster& cluster, std::filesystem::path savePath, - const std::string& saveWindowCfgPath) + const std::filesystem::path& saveWindowCfgPath) { savePath.replace_extension(".json"); saveWindowConfig(this, savePath, cluster); diff --git a/apps/OpenSpace/ext/launcher/src/profile/assetsdialog.cpp b/apps/OpenSpace/ext/launcher/src/profile/assetsdialog.cpp index 6e9b5e697d..d44fa22386 100644 --- a/apps/OpenSpace/ext/launcher/src/profile/assetsdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/profile/assetsdialog.cpp @@ -125,13 +125,13 @@ namespace { } // namespace AssetsDialog::AssetsDialog(QWidget* parent, openspace::Profile* profile, - const std::string& assetBasePath, - const std::string& userAssetBasePath) + const std::filesystem::path& assetBasePath, + const std::filesystem::path& userAssetBasePath) : QDialog(parent) , _profile(profile) { setWindowTitle("Assets"); - _assetTreeModel.importModelData(assetBasePath, userAssetBasePath); + _assetTreeModel.importModelData(assetBasePath.string(), userAssetBasePath.string()); QBoxLayout* layout = new QVBoxLayout(this); { diff --git a/apps/OpenSpace/ext/launcher/src/profile/horizonsdialog.cpp b/apps/OpenSpace/ext/launcher/src/profile/horizonsdialog.cpp index 31f9755d1e..94b5d24882 100644 --- a/apps/OpenSpace/ext/launcher/src/profile/horizonsdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/profile/horizonsdialog.cpp @@ -733,11 +733,11 @@ bool HorizonsDialog::handleRequest() { const bool isValid = handleResult(result); if (!isValid && std::filesystem::is_regular_file(_horizonsFile.file())) { - const std::string newName = _horizonsFile.file().filename().stem().string(); + const std::filesystem::path newName = _horizonsFile.file().filename().stem(); const std::filesystem::path& oldFile = _horizonsFile.file(); std::filesystem::path newFile = oldFile; - newFile.replace_filename(newName + "_error.txt"); + newFile.replace_filename(std::format("{}_error.txt", newName)); std::filesystem::rename(oldFile, newFile); @@ -916,9 +916,9 @@ bool HorizonsDialog::handleResult(openspace::HorizonsResultCode& result) { // If the request worked then delete the corresponding error file if it exist std::filesystem::path validFile =_horizonsFile.file(); - const std::string errorName = validFile.filename().stem().string(); + const std::filesystem::path errorName = validFile.filename().stem(); const std::filesystem::path errorFile = validFile.replace_filename( - errorName + "_error.txt" + std::format("{}_error.txt", errorName) ); if (std::filesystem::is_regular_file(errorFile)) { diff --git a/apps/OpenSpace/ext/launcher/src/profile/profileedit.cpp b/apps/OpenSpace/ext/launcher/src/profile/profileedit.cpp index cb36d5ed21..64760c0205 100644 --- a/apps/OpenSpace/ext/launcher/src/profile/profileedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/profile/profileedit.cpp @@ -96,10 +96,10 @@ namespace { } // namespace ProfileEdit::ProfileEdit(Profile& profile, const std::string& profileName, - std::string assetBasePath, - std::string userAssetBasePath, - std::string builtInProfileBasePath, - std::string profileBasePath, + std::filesystem::path assetBasePath, + std::filesystem::path userAssetBasePath, + std::filesystem::path builtInProfileBasePath, + std::filesystem::path profileBasePath, QWidget* parent) : QDialog(parent) , _profile(profile) @@ -392,8 +392,10 @@ void ProfileEdit::duplicateProfile() { while (true) { version++; - const std::string candidate = profile + Separator + std::to_string(version); - const std::string candidatePath = _profileBasePath + candidate + ".profile"; + const std::string candidate = std::format("{}{}{}", profile, Separator, version); + const std::string candidatePath = std::format( + "{}{}.profile", _profileBasePath, candidate + ); if (!std::filesystem::exists(candidatePath)) { _profileEdit->setText(QString::fromStdString(candidate)); diff --git a/apps/OpenSpace/ext/launcher/src/profile/scriptlogdialog.cpp b/apps/OpenSpace/ext/launcher/src/profile/scriptlogdialog.cpp index c0893a974c..97496890ed 100644 --- a/apps/OpenSpace/ext/launcher/src/profile/scriptlogdialog.cpp +++ b/apps/OpenSpace/ext/launcher/src/profile/scriptlogdialog.cpp @@ -126,8 +126,8 @@ void ScriptlogDialog::createWidgets() { void ScriptlogDialog::loadScriptFile() { _scripts.clear(); - const std::string log = absPath(_scriptLogFile).string(); - QFile file(QString::fromStdString(log)); + const std::filesystem::path log = absPath(_scriptLogFile); + QFile file = QFile(QString::fromStdString(log.string())); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); while (!in.atEnd()) { diff --git a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp index 0adde4e76c..5db67f8228 100644 --- a/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp +++ b/apps/OpenSpace/ext/launcher/src/sgctedit/sgctedit.cpp @@ -70,7 +70,7 @@ namespace { template overloaded(Ts...) -> overloaded; } // namespace -SgctEdit::SgctEdit(QWidget* parent, std::string userConfigPath) +SgctEdit::SgctEdit(QWidget* parent, std::filesystem::path userConfigPath) : QDialog(parent) , _userConfigPath(std::move(userConfigPath)) { @@ -79,7 +79,7 @@ SgctEdit::SgctEdit(QWidget* parent, std::string userConfigPath) } SgctEdit::SgctEdit(sgct::config::Cluster& cluster, std::string configName, - std::string& configBasePath, QWidget* parent) + std::filesystem::path& configBasePath, QWidget* parent) : QDialog(parent) , _cluster(cluster) , _userConfigPath(configBasePath) @@ -411,7 +411,7 @@ void SgctEdit::save() { const QString fileName = QFileDialog::getSaveFileName( this, "Save Window Configuration File", - QString::fromStdString(_userConfigPath), + QString::fromStdString(_userConfigPath.string()), "Window Configuration (*.json)", nullptr #ifdef __linux__ @@ -444,7 +444,7 @@ void SgctEdit::apply() { } } - std::string userCfgTempDir = _userConfigPath; + std::string userCfgTempDir = _userConfigPath.string(); if (userCfgTempDir.back() != '/') { userCfgTempDir += '/'; } diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 98c7b2f838..5ffaa631d3 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 98c7b2f83822d7aef447256f35f42107b5afad5e +Subproject commit 5ffaa631d35bed3ea6b94ed4ff3c3a766bc00d9f diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 49cab344db..79936ec5b8 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -282,7 +282,7 @@ void mainInitFunc(GLFWwindow*) { // We save the startup value of the screenshots just in case we want to add a date // to them later in the RenderEngine std::filesystem::path screenshotPath = absPath("${SCREENSHOTS}"); - sgct::Settings::instance().setCapturePath(screenshotPath.string()); + sgct::Settings::instance().setCapturePath(screenshotPath); FileSys.registerPathToken("${STARTUP_SCREENSHOT}", std::move(screenshotPath)); LDEBUG("Initializing OpenSpace Engine started"); @@ -296,7 +296,8 @@ void mainInitFunc(GLFWwindow*) { int x = 0; int y = 0; int n = 0; - unsigned char* data = stbi_load(path.string().c_str(), &x, &y, &n, 0); + const std::string p = path.string(); + unsigned char* data = stbi_load(p.c_str(), &x, &y, &n, 0); GLFWimage icon; icon.pixels = data; @@ -1236,7 +1237,7 @@ int main(int argc, char* argv[]) { // Loading configuration from disk LDEBUG("Loading configuration from disk"); *global::configuration = loadConfigurationFromFile( - configurationFilePath.string(), + configurationFilePath, findSettings(), size ); @@ -1332,7 +1333,7 @@ int main(int argc, char* argv[]) { nullptr, "OpenSpace", QString::fromStdString(std::format( - "The OpenSpace folder is started must not contain any of \"'\", " + "The OpenSpace folder is started from must not contain any of \"'\", " "\"\"\", [, or ]. Path is: {}. Unexpected errors will occur when " "proceeding to run the software", pwd )) @@ -1389,7 +1390,7 @@ int main(int argc, char* argv[]) { #endif // WIN32 *global::configuration = loadConfigurationFromFile( - configurationFilePath.string(), + configurationFilePath, findSettings(), size ); diff --git a/ext/ghoul b/ext/ghoul index 4f09dfcd6c..0ce1437b33 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 4f09dfcd6c2628af1d3646afefc0aa50ced3bd50 +Subproject commit 0ce1437b338cd83248925e9ed84d85bb615ad8b4 diff --git a/include/openspace/documentation/verifier.h b/include/openspace/documentation/verifier.h index 8b9d10ee90..5fa838f988 100644 --- a/include/openspace/documentation/verifier.h +++ b/include/openspace/documentation/verifier.h @@ -253,8 +253,11 @@ public: * \param documentationEntries The DocumentationEntry%s that are used to recursively * test the ghoul::Dictionary that is contained inside. If this list is empty, * only a type check is performed + * \param nEntries The exact number of entries that should be in the table. If the + * value is not provided, any number (including 0) is allowed */ - TableVerifier(std::vector documentationEntries = {}); + TableVerifier(std::vector documentationEntries = {}, + std::optional nEntries = std::nullopt); /** * Checks whether the \p key%'s value is a table (= ghoul::Dictionary) and (if @@ -277,6 +280,7 @@ public: /// The documentations passed in the constructor std::vector documentations; + std::optional count; }; /** diff --git a/include/openspace/engine/downloadmanager.h b/include/openspace/engine/downloadmanager.h index 8549415175..11bf5d7081 100644 --- a/include/openspace/engine/downloadmanager.h +++ b/include/openspace/engine/downloadmanager.h @@ -44,7 +44,7 @@ public: // Since the FileFuture object will be used from multiple threads, we have to be // careful about the access pattern, that is, no values should be read and written // by both the DownloadManager and the outside threads. - FileFuture(std::string file); + FileFuture(std::filesystem::path file); // Values that are written by the DownloadManager to be consumed by others long long currentSize = -1; @@ -53,7 +53,7 @@ public: float secondsRemaining = -1.f; bool isFinished = false; bool isAborted = false; - std::string filePath; + std::filesystem::path filePath; std::string errorMessage; std::string format; // Values set by others to be consumed by the DownloadManager diff --git a/include/openspace/rendering/transferfunction.h b/include/openspace/rendering/transferfunction.h index cf6e923b16..3e70eb8d34 100644 --- a/include/openspace/rendering/transferfunction.h +++ b/include/openspace/rendering/transferfunction.h @@ -40,13 +40,13 @@ class TransferFunction { public: using TfChangedCallback = std::function; - TransferFunction(const std::string& filepath, + TransferFunction(const std::filesystem::path& filepath, TfChangedCallback tfChangedCallback = TfChangedCallback()); ~TransferFunction(); TransferFunction(TransferFunction&& rhs) = default; - void setPath(const std::string& filepath); + void setPath(const std::filesystem::path& filepath); ghoul::opengl::Texture& texture(); void bind(); void update(); diff --git a/include/openspace/rendering/volumeraycaster.h b/include/openspace/rendering/volumeraycaster.h index 25949e67d9..586f3e62c6 100644 --- a/include/openspace/rendering/volumeraycaster.h +++ b/include/openspace/rendering/volumeraycaster.h @@ -26,6 +26,7 @@ #define __OPENSPACE_CORE___VOLUMERAYCASTER___H__ #include +#include #include #include @@ -84,7 +85,7 @@ public: * The shader preprocessor will have access to: * - A `#{namespace}` variable (unique per helper file) */ - virtual std::string boundsVertexShaderPath() const = 0; + virtual std::filesystem::path boundsVertexShaderPath() const = 0; /** * Return a path to a file with the functions, uniforms and fragment shader in @@ -95,7 +96,7 @@ public: * The shader preprocessor will have access to: * - A `#{namespace}` variable (unique per helper file) */ - virtual std::string boundsFragmentShaderPath() const = 0; + virtual std::filesystem::path boundsFragmentShaderPath() const = 0; /** * Return a path to a file with all the uniforms, functions, etc. Required to perform @@ -114,7 +115,7 @@ public: * - An #{id} variable (unique per volume) * - A #{namespace} variable (unique per helper file) */ - virtual std::string raycasterPath() const = 0; + virtual std::filesystem::path raycasterPath() const = 0; /** * Return a path to a glsl file with helper functions required for the transformation @@ -125,7 +126,7 @@ public: * The shader preprocessor will have access to the #{namespace} variable (unique per * helper file) which should be a prefix to all symbols defined by the helper */ - virtual std::string helperPath() const = 0; + virtual std::filesystem::path helperPath() const = 0; void setMaxSteps(int nsteps); diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index 7041c7514c..8776856ec4 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -127,7 +127,7 @@ private: // Logging variables bool _logFileExists = false; bool _logScripts = true; - std::string _logFilename; + std::filesystem::path _logFilename; }; } // namespace openspace::scripting diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index 7428bc89ad..52b1369d5f 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -214,7 +215,7 @@ public: * * \see http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/furnsh_c.html */ - KernelHandle loadKernel(std::string filePath); + KernelHandle loadKernel(std::filesystem::path filePath); /** * Unloads a SPICE kernel identified by the \p kernelId which was returned by the @@ -238,7 +239,7 @@ public: * * \return The list of all loaded kernels that have been loaded through this manager */ - std::vector loadedKernels() const; + std::vector loadedKernels() const; /** * Unloads a SPICE kernel identified by the \p filePath which was used in the @@ -254,7 +255,7 @@ public: * * \see http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/unload_c.html */ - void unloadKernel(std::string filePath); + void unloadKernel(std::filesystem::path filePath); /** * Returns whether a given \p target has an SPK kernel covering it at the designated @@ -1017,7 +1018,7 @@ private: */ struct KernelInformation { /// The path from which the kernel was loaded - std::string path; + std::filesystem::path path; /// A unique identifier for each kernel KernelHandle id; /// How many parts loaded this kernel and are interested in it @@ -1049,7 +1050,7 @@ private: * \see http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckobj_c.html * \see http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/ckcov_c.html */ - void findCkCoverage(const std::string& path); + void findCkCoverage(const std::filesystem::path& path); /** * Function to find and store the intervals covered by a spk file, this is done @@ -1063,7 +1064,7 @@ private: * \see http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkobj_c.html * \see http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkcov_c.html */ - void findSpkCoverage(const std::string& path); + void findSpkCoverage(const std::filesystem::path& path); /** * If a position is requested for an uncovered time in the SPK kernels, this function diff --git a/modules/base/rendering/pointcloud/renderablepointcloud.cpp b/modules/base/rendering/pointcloud/renderablepointcloud.cpp index 901f9488e3..c43cd3ff3f 100644 --- a/modules/base/rendering/pointcloud/renderablepointcloud.cpp +++ b/modules/base/rendering/pointcloud/renderablepointcloud.cpp @@ -597,7 +597,7 @@ RenderablePointCloud::RenderablePointCloud(const ghoul::Dictionary& dictionary) if (p.file.has_value()) { _hasDataFile = true; - _dataFile = absPath(*p.file).string(); + _dataFile = absPath(*p.file); } if (p.dataMapping.has_value()) { @@ -637,7 +637,7 @@ RenderablePointCloud::RenderablePointCloud(const ghoul::Dictionary& dictionary) if (t.folder.has_value()) { _textureMode = TextureInputMode::Multi; _hasSpriteTexture = true; - _texturesDirectory = absPath(*t.folder).string(); + _texturesDirectory = absPath(*t.folder); if (t.file.has_value()) { LWARNING(std::format( @@ -653,11 +653,14 @@ RenderablePointCloud::RenderablePointCloud(const ghoul::Dictionary& dictionary) _textureMode = TextureInputMode::Single; _hasSpriteTexture = true; _texture.spriteTexturePath = absPath(*t.file).string(); - _texture.spriteTexturePath.onChange([this]() { _spriteTextureIsDirty = true; }); + _texture.spriteTexturePath.onChange( + [this]() { _spriteTextureIsDirty = true; } + ); } _texture.enabled = t.enabled.value_or(_texture.enabled); - _texture.allowCompression = t.allowCompression.value_or(_texture.allowCompression); + _texture.allowCompression = + t.allowCompression.value_or(_texture.allowCompression); _texture.useAlphaChannel = t.useAlphaChannel.value_or(_texture.useAlphaChannel); } @@ -912,7 +915,7 @@ void RenderablePointCloud::loadTexture(const std::filesystem::path& path, int in } std::unique_ptr t = - ghoul::io::TextureReader::ref().loadTexture(path.string(), 2); + ghoul::io::TextureReader::ref().loadTexture(path, 2); bool useAlpha = (t->numberOfChannels() > 3) && _texture.useAlphaChannel; diff --git a/modules/base/rendering/pointcloud/renderablepointcloud.h b/modules/base/rendering/pointcloud/renderablepointcloud.h index 8537585498..28f5d28e62 100644 --- a/modules/base/rendering/pointcloud/renderablepointcloud.h +++ b/modules/base/rendering/pointcloud/renderablepointcloud.h @@ -42,6 +42,7 @@ #include #include #include +#include #include namespace ghoul::opengl { @@ -223,7 +224,7 @@ protected: outlineWeight, aspectRatioScale ) _uniformCache; - std::string _dataFile; + std::filesystem::path _dataFile; DistanceUnit _unit = DistanceUnit::Parsec; diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 8ef6682a6b..7d303292ee 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -355,7 +355,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) } } - _file = absPath(p.geometryFile.string()); + _file = absPath(p.geometryFile); if (!std::filesystem::exists(_file)) { throw ghoul::RuntimeError(std::format("Cannot find model file '{}'", _file)); } diff --git a/modules/base/rendering/renderableplaneimagelocal.cpp b/modules/base/rendering/renderableplaneimagelocal.cpp index 9066e74764..83787db5de 100644 --- a/modules/base/rendering/renderableplaneimagelocal.cpp +++ b/modules/base/rendering/renderableplaneimagelocal.cpp @@ -168,10 +168,7 @@ void RenderablePlaneImageLocal::loadTexture() { std::to_string(hash), [path = _texturePath]() -> std::unique_ptr { std::unique_ptr texture = - ghoul::io::TextureReader::ref().loadTexture( - absPath(path).string(), - 2 - ); + ghoul::io::TextureReader::ref().loadTexture(absPath(path), 2); LDEBUGC( "RenderablePlaneImageLocal", diff --git a/modules/base/rendering/renderableplanetimevaryingimage.cpp b/modules/base/rendering/renderableplanetimevaryingimage.cpp index ed6dc0e92a..4e367ccf39 100644 --- a/modules/base/rendering/renderableplanetimevaryingimage.cpp +++ b/modules/base/rendering/renderableplanetimevaryingimage.cpp @@ -145,7 +145,7 @@ void RenderablePlaneTimeVaryingImage::initializeGL() { _textureFiles.resize(_sourceFiles.size()); for (size_t i = 0; i < _sourceFiles.size(); i++) { _textureFiles[i] = ghoul::io::TextureReader::ref().loadTexture( - absPath(_sourceFiles[i]).string(), + absPath(_sourceFiles[i]), 2 ); _textureFiles[i]->setInternalFormat(GL_COMPRESSED_RGBA); @@ -168,7 +168,7 @@ bool RenderablePlaneTimeVaryingImage::extractMandatoryInfoFromDictionary() { namespace fs = std::filesystem; for (const fs::directory_entry& e : fs::directory_iterator(sourceFolder)) { if (e.is_regular_file()) { - _sourceFiles.push_back(e.path().string()); + _sourceFiles.push_back(e.path()); } } std::sort(_sourceFiles.begin(), _sourceFiles.end()); @@ -246,9 +246,9 @@ void RenderablePlaneTimeVaryingImage::render(const RenderData& data, RendererTas // Requires time to be formated as such: 'YYYY-MM-DDTHH-MM-SS-XXX' void RenderablePlaneTimeVaryingImage::extractTriggerTimesFromFileNames() { - for (const std::string& filePath : _sourceFiles) { + for (const std::filesystem::path& filePath : _sourceFiles) { // Extract the filename from the path (without extension) - std::string timeString = std::filesystem::path(filePath).stem().string(); + std::string timeString = filePath.stem().string(); // Ensure the separators are correct timeString.replace(4, 1, "-"); diff --git a/modules/base/rendering/renderableplanetimevaryingimage.h b/modules/base/rendering/renderableplanetimevaryingimage.h index 8afde80dc2..e61d64ce59 100644 --- a/modules/base/rendering/renderableplanetimevaryingimage.h +++ b/modules/base/rendering/renderableplanetimevaryingimage.h @@ -27,6 +27,8 @@ #include +#include + namespace ghoul::filesystem { class File; } namespace ghoul::opengl { class Texture; } @@ -62,7 +64,7 @@ private: // If there's just one state it should never disappear double _sequenceEndTime = std::numeric_limits::max(); - std::vector _sourceFiles; + std::vector _sourceFiles; std::vector _startTimes; int _activeTriggerTimeIndex = 0; properties::StringProperty _sourceFolder; diff --git a/modules/base/rendering/renderablesphereimagelocal.cpp b/modules/base/rendering/renderablesphereimagelocal.cpp index 7740aa4ab0..c82abf7788 100644 --- a/modules/base/rendering/renderablesphereimagelocal.cpp +++ b/modules/base/rendering/renderablesphereimagelocal.cpp @@ -112,7 +112,7 @@ void RenderableSphereImageLocal::loadTexture() { } std::unique_ptr texture = - ghoul::io::TextureReader::ref().loadTexture(_texturePath, 2); + ghoul::io::TextureReader::ref().loadTexture(_texturePath.value(), 2); if (!texture) { LWARNINGC( diff --git a/modules/base/rendering/renderabletimevaryingsphere.cpp b/modules/base/rendering/renderabletimevaryingsphere.cpp index affa8e718d..317a414155 100644 --- a/modules/base/rendering/renderabletimevaryingsphere.cpp +++ b/modules/base/rendering/renderabletimevaryingsphere.cpp @@ -36,9 +36,9 @@ namespace { // Extract J2000 time from file names // Requires files to be named as such: 'YYYY-MM-DDTHH-MM-SS-XXX.png' - double extractTriggerTimeFromFileName(const std::string& filePath) { + double extractTriggerTimeFromFileName(const std::filesystem::path& filePath) { // Extract the filename from the path (without extension) - std::string timeString = std::filesystem::path(filePath).stem().string(); + std::string timeString = filePath.stem().string(); // Ensure the separators are correct timeString.replace(4, 1, "-"); @@ -118,7 +118,7 @@ void RenderableTimeVaryingSphere::extractMandatoryInfoFromSourceFolder() { if (!e.is_regular_file()) { continue; } - const std::string filePath = e.path().string(); + std::filesystem::path filePath = e.path(); const double time = extractTriggerTimeFromFileName(filePath); std::unique_ptr t = ghoul::io::TextureReader::ref().loadTexture(filePath, 2); @@ -128,7 +128,7 @@ void RenderableTimeVaryingSphere::extractMandatoryInfoFromSourceFolder() { t->setFilter(ghoul::opengl::Texture::FilterMode::Linear); t->purgeFromRAM(); - _files.push_back({ filePath, time, std::move(t) }); + _files.push_back({ std::move(filePath), time, std::move(t) }); } std::sort( diff --git a/modules/base/rendering/renderabletimevaryingsphere.h b/modules/base/rendering/renderabletimevaryingsphere.h index 3add139bbe..d869d6e544 100644 --- a/modules/base/rendering/renderabletimevaryingsphere.h +++ b/modules/base/rendering/renderabletimevaryingsphere.h @@ -27,6 +27,8 @@ #include +#include + namespace ghoul::opengl { class Texture; } namespace openspace { @@ -54,7 +56,7 @@ protected: private: struct FileData { - std::string path; + std::filesystem::path path; double time; std::unique_ptr texture; }; diff --git a/modules/base/rendering/screenspaceimagelocal.cpp b/modules/base/rendering/screenspaceimagelocal.cpp index 504f6db33f..188423fdde 100644 --- a/modules/base/rendering/screenspaceimagelocal.cpp +++ b/modules/base/rendering/screenspaceimagelocal.cpp @@ -120,10 +120,7 @@ bool ScreenSpaceImageLocal::deinitializeGL() { void ScreenSpaceImageLocal::update() { if (_textureIsDirty && !_texturePath.value().empty()) { std::unique_ptr texture = - ghoul::io::TextureReader::ref().loadTexture( - absPath(_texturePath).string(), - 2 - ); + ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath), 2); if (texture) { // Images don't need to start on 4-byte boundaries, for example if the diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index a5e87cc96f..aa17764658 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -203,7 +203,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) addProperty(Fadeable::_opacity); - _speckFile = absPath(p.file).string(); + _speckFile = absPath(p.file); _drawElements.onChange([this]() { _hasSpeckFile = !_hasSpeckFile; }); addProperty(_drawElements); @@ -230,7 +230,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) addProperty(_lineWidth); if (p.labelFile.has_value()) { - _labelFile = absPath(*p.labelFile).string(); + _labelFile = absPath(*p.labelFile); _hasLabel = true; _drawLabels = p.drawLabels.value_or(_drawLabels); @@ -456,8 +456,7 @@ bool RenderableDUMeshes::loadData() { } } - const std::string labelFile = _labelFile; - if (!labelFile.empty()) { + if (!_labelFile.empty()) { _labelset = dataloader::label::loadFileWithCache(_labelFile); } diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.h b/modules/digitaluniverse/rendering/renderabledumeshes.h index d24962ffa9..1ecb169ee0 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.h +++ b/modules/digitaluniverse/rendering/renderabledumeshes.h @@ -37,6 +37,7 @@ #include #include #include +#include #include namespace ghoul::filesystem { class File; } @@ -124,8 +125,8 @@ private: color) _uniformCache; std::shared_ptr _font = nullptr; - std::string _speckFile; - std::string _labelFile; + std::filesystem::path _speckFile; + std::filesystem::path _labelFile; DistanceUnit _unit = DistanceUnit::Parsec; diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index 4316e1876d..b26d2029a8 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -494,7 +494,7 @@ void RenderablePlanesCloud::update(const UpdateData&) { void RenderablePlanesCloud::loadTextures() { for (const dataloader::Dataset::Texture& tex : _dataset.textures) { - std::filesystem::path fullPath = absPath(_texturesPath.string() + '/' + tex.file); + std::filesystem::path fullPath = absPath(_texturesPath / tex.file); std::filesystem::path pngPath = fullPath; pngPath.replace_extension(".png"); @@ -513,7 +513,7 @@ void RenderablePlanesCloud::loadTextures() { } std::unique_ptr t = - ghoul::io::TextureReader::ref().loadTexture(path.string(), 2); + ghoul::io::TextureReader::ref().loadTexture(path, 2); if (t) { LINFOC("RenderablePlanesCloud", std::format("Loaded texture '{}'", path)); diff --git a/modules/exoplanets/exoplanetshelper.cpp b/modules/exoplanets/exoplanetshelper.cpp index 24d7fc8d98..ff8c5287bc 100644 --- a/modules/exoplanets/exoplanetshelper.cpp +++ b/modules/exoplanets/exoplanetshelper.cpp @@ -60,7 +60,7 @@ bool hasSufficientData(const ExoplanetDataEntry& p) { glm::vec3 computeStarColor(float bv) { const ExoplanetsModule* module = global::moduleEngine->module(); - const std::string bvColormapPath = module->bvColormapPath(); + const std::filesystem::path bvColormapPath = module->bvColormapPath(); std::ifstream colorMap(absPath(bvColormapPath), std::ios::in); diff --git a/modules/exoplanets/exoplanetsmodule.cpp b/modules/exoplanets/exoplanetsmodule.cpp index 37f9b366f4..bfc6137b23 100644 --- a/modules/exoplanets/exoplanetsmodule.cpp +++ b/modules/exoplanets/exoplanetsmodule.cpp @@ -264,52 +264,52 @@ bool ExoplanetsModule::hasDataFiles() const { return !_exoplanetsDataFolder.value().empty(); } -std::string ExoplanetsModule::exoplanetsDataPath() const { +std::filesystem::path ExoplanetsModule::exoplanetsDataPath() const { ghoul_assert(hasDataFiles(), "Data files not loaded"); return absPath( std::format("{}/{}", _exoplanetsDataFolder.value(), ExoplanetsDataFileName) - ).string(); + ); } -std::string ExoplanetsModule::lookUpTablePath() const { +std::filesystem::path ExoplanetsModule::lookUpTablePath() const { ghoul_assert(hasDataFiles(), "Data files not loaded"); return absPath( std::format("{}/{}", _exoplanetsDataFolder.value(), LookupTableFileName) - ).string(); + ); } -std::string ExoplanetsModule::teffToBvConversionFilePath() const { +std::filesystem::path ExoplanetsModule::teffToBvConversionFilePath() const { ghoul_assert(hasDataFiles(), "Data files not loaded"); return absPath(std::format( "{}/{}", _exoplanetsDataFolder.value(), TeffToBvConversionFileName - )).string(); + )); } -std::string ExoplanetsModule::bvColormapPath() const { - return _bvColorMapPath; +std::filesystem::path ExoplanetsModule::bvColormapPath() const { + return _bvColorMapPath.value(); } -std::string ExoplanetsModule::starTexturePath() const { - return _starTexturePath; +std::filesystem::path ExoplanetsModule::starTexturePath() const { + return _starTexturePath.value(); } -std::string ExoplanetsModule::starGlareTexturePath() const { - return _starGlareTexturePath; +std::filesystem::path ExoplanetsModule::starGlareTexturePath() const { + return _starGlareTexturePath.value(); } -std::string ExoplanetsModule::noDataTexturePath() const { - return _noDataTexturePath; +std::filesystem::path ExoplanetsModule::noDataTexturePath() const { + return _noDataTexturePath.value(); } -std::string ExoplanetsModule::orbitDiscTexturePath() const { - return _orbitDiscTexturePath; +std::filesystem::path ExoplanetsModule::orbitDiscTexturePath() const { + return _orbitDiscTexturePath.value(); } -std::string ExoplanetsModule::habitableZoneTexturePath() const { - return _habitableZoneTexturePath; +std::filesystem::path ExoplanetsModule::habitableZoneTexturePath() const { + return _habitableZoneTexturePath.value(); } glm::vec3 ExoplanetsModule::comparisonCircleColor() const { @@ -342,31 +342,31 @@ void ExoplanetsModule::internalInitialize(const ghoul::Dictionary& dict) { _enabled = p.enabled.value_or(_enabled); if (p.dataFolder.has_value()) { - _exoplanetsDataFolder = p.dataFolder.value().string(); + _exoplanetsDataFolder = p.dataFolder->string(); } if (p.bvColormap.has_value()) { - _bvColorMapPath = p.bvColormap.value().string(); + _bvColorMapPath = p.bvColormap->string(); } if (p.starTexture.has_value()) { - _starTexturePath = p.starTexture.value().string(); + _starTexturePath = p.starTexture->string(); } if (p.starGlareTexture.has_value()) { - _starGlareTexturePath = p.starGlareTexture.value().string(); + _starGlareTexturePath = p.starGlareTexture->string(); } if (p.noDataTexture.has_value()) { - _noDataTexturePath = p.noDataTexture.value().string(); + _noDataTexturePath = p.noDataTexture->string(); } if (p.orbitDiscTexture.has_value()) { - _orbitDiscTexturePath = p.orbitDiscTexture.value().string(); + _orbitDiscTexturePath = p.orbitDiscTexture->string(); } if (p.habitableZoneTexture.has_value()) { - _habitableZoneTexturePath = p.habitableZoneTexture.value().string(); + _habitableZoneTexturePath = p.habitableZoneTexture->string(); } _comparisonCircleColor = p.comparisonCircleColor.value_or(_comparisonCircleColor); diff --git a/modules/exoplanets/exoplanetsmodule.h b/modules/exoplanets/exoplanetsmodule.h index 0cba1a263f..c1ff4a787a 100644 --- a/modules/exoplanets/exoplanetsmodule.h +++ b/modules/exoplanets/exoplanetsmodule.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace openspace { @@ -43,15 +44,15 @@ public: ~ExoplanetsModule() override = default; bool hasDataFiles() const; - std::string exoplanetsDataPath() const; - std::string lookUpTablePath() const; - std::string teffToBvConversionFilePath() const; - std::string bvColormapPath() const; - std::string starTexturePath() const; - std::string starGlareTexturePath() const; - std::string noDataTexturePath() const; - std::string orbitDiscTexturePath() const; - std::string habitableZoneTexturePath() const; + std::filesystem::path exoplanetsDataPath() const; + std::filesystem::path lookUpTablePath() const; + std::filesystem::path teffToBvConversionFilePath() const; + std::filesystem::path bvColormapPath() const; + std::filesystem::path starTexturePath() const; + std::filesystem::path starGlareTexturePath() const; + std::filesystem::path noDataTexturePath() const; + std::filesystem::path orbitDiscTexturePath() const; + std::filesystem::path habitableZoneTexturePath() const; glm::vec3 comparisonCircleColor() const; bool showComparisonCircle() const; bool showOrbitUncertainty() const; diff --git a/modules/exoplanets/exoplanetsmodule_lua.inl b/modules/exoplanets/exoplanetsmodule_lua.inl index 5b00eae729..2a12c3ddb5 100644 --- a/modules/exoplanets/exoplanetsmodule_lua.inl +++ b/modules/exoplanets/exoplanetsmodule_lua.inl @@ -37,8 +37,8 @@ constexpr std::string_view _loggerCat = "ExoplanetsModule"; constexpr std::string_view ExoplanetsGuiPath = "/Milky Way/Exoplanets/Exoplanet Systems/"; // Lua cannot handle backslashes, so replace these with forward slashes -std::string formatPathToLua(const std::string& path) { - std::string resPath = path; +std::string formatPathToLua(const std::filesystem::path& path) { + std::string resPath = path.string(); std::replace(resPath.begin(), resPath.end(), '\\', '/'); return resPath; } @@ -51,14 +51,14 @@ openspace::exoplanets::ExoplanetSystem findExoplanetSystemInData( const ExoplanetsModule* module = global::moduleEngine->module(); - const std::string binPath = module->exoplanetsDataPath(); + const std::filesystem::path binPath = module->exoplanetsDataPath(); std::ifstream data(absPath(binPath), std::ios::in | std::ios::binary); if (!data.good()) { LERROR(std::format("Failed to open exoplanets data file '{}'", binPath)); return ExoplanetSystem(); } - const std::string lutPath = module->lookUpTablePath(); + const std::filesystem::path lutPath = module->lookUpTablePath(); std::ifstream lut(absPath(lutPath)); if (!lut.good()) { LERROR(std::format("Failed to open exoplanets look-up table '{}'", lutPath)); @@ -154,7 +154,7 @@ void createExoplanetSystem(const std::string& starName, if (!std::isnan(bv)) { starColor = computeStarColor(bv); - const std::string starTexture = module->starTexturePath(); + const std::filesystem::path starTexture = module->starTexturePath(); colorLayers = "{" "Identifier = 'StarColor'," @@ -171,7 +171,7 @@ void createExoplanetSystem(const std::string& starName, "}"; } else { - const std::string noDataTexture = module->noDataTexturePath(); + const std::filesystem::path noDataTexture = module->noDataTexturePath(); colorLayers = "{" "Identifier = 'NoDataStarTexture'," @@ -355,7 +355,7 @@ void createExoplanetSystem(const std::string& starName, const float lowerOffset = static_cast(planet.aLower / planet.a); const float upperOffset = static_cast(planet.aUpper / planet.a); - const std::string discTexture = module->orbitDiscTexturePath(); + const std::filesystem::path discTexture = module->orbitDiscTexturePath(); bool isDiscEnabled = module->showOrbitUncertainty(); @@ -462,7 +462,7 @@ void createExoplanetSystem(const std::string& starName, "the greenhouse effect would not be able to maintain surface temperature " "above freezing anywhere on the planet"; - const std::string hzTexture = module->habitableZoneTexturePath(); + const std::filesystem::path hzTexture = module->habitableZoneTexturePath(); bool isHzEnabled = module->showHabitableZone(); bool useOptimistic = module->useOptimisticZone(); float opacity = module->habitableZoneOpacity(); @@ -514,7 +514,7 @@ void createExoplanetSystem(const std::string& starName, size *= std::pow(system.starData.teff / sunTeff, 2.0); } - const std::string glareTexture = module->starGlareTexturePath(); + const std::filesystem::path glareTexture = module->starGlareTexturePath(); const std::string starGlare = "{" "Identifier = '" + starIdentifier + "_Glare'," @@ -559,14 +559,14 @@ std::vector hostStarsWithSufficientData() { return {}; } - const std::string lutPath = module->lookUpTablePath(); + const std::filesystem::path lutPath = module->lookUpTablePath(); std::ifstream lookupTableFile(absPath(lutPath)); if (!lookupTableFile.good()) { LERROR(std::format("Failed to open lookup table file '{}'", lutPath)); return {}; } - const std::string binPath = module->exoplanetsDataPath(); + const std::filesystem::path binPath = module->exoplanetsDataPath(); std::ifstream data(absPath(binPath), std::ios::in | std::ios::binary); if (!data.good()) { LERROR(std::format("Failed to open data file '{}'", binPath)); @@ -734,7 +734,8 @@ listOfExoplanetsDeprecated() ExoplanetsDataPreparationTask::readFirstDataRow(inputDataFile); const ExoplanetsModule* module = global::moduleEngine->module(); - const std::string teffBvConversionPath = module->teffToBvConversionFilePath(); + const std::filesystem::path + teffBvConversionPath = module->teffToBvConversionFilePath(); std::map hostNameToSystemDataMap; diff --git a/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index 1d6d04d7dd..f382a7b532 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -437,8 +437,9 @@ RenderableFieldlines::generateFieldlinesVolumeKameleon() LERROR(std::format("'{}' does not name a file", KeyVectorField)); return {}; } - std::string fileName = _vectorFieldInfo.value(KeyVectorFieldFile); - fileName = absPath(fileName).string(); + std::filesystem::path fileName = absPath( + _vectorFieldInfo.value(KeyVectorFieldFile) + ); //KameleonWrapper::Model modelType; if (model != VectorFieldKameleonModelBATSRUS) { @@ -473,7 +474,7 @@ RenderableFieldlines::generateFieldlinesVolumeKameleon() std::string yVariable = _vectorFieldInfo.value(v2); std::string zVariable = _vectorFieldInfo.value(v3); - KameleonWrapper kw(fileName); + KameleonWrapper kw = KameleonWrapper(fileName); return kw.classifiedFieldLines( xVariable, yVariable, @@ -484,7 +485,7 @@ RenderableFieldlines::generateFieldlinesVolumeKameleon() } if (lorentzForce) { - KameleonWrapper kw(fileName); + KameleonWrapper kw = KameleonWrapper(fileName); return kw.lorentzTrajectories(_seedPoints, _fieldlineColor, _stepSize); } diff --git a/modules/fieldlinessequence/fieldlinessequencemodule.cpp b/modules/fieldlinessequence/fieldlinessequencemodule.cpp index 9973fd4fa5..9c98e97bb2 100644 --- a/modules/fieldlinessequence/fieldlinessequencemodule.cpp +++ b/modules/fieldlinessequence/fieldlinessequencemodule.cpp @@ -48,14 +48,12 @@ mappingkey 1.0 255 255 255 255 namespace openspace { -std::string FieldlinesSequenceModule::DefaultTransferFunctionFile = ""; +std::filesystem::path FieldlinesSequenceModule::DefaultTransferFunctionFile = ""; FieldlinesSequenceModule::FieldlinesSequenceModule() : OpenSpaceModule(Name) { - DefaultTransferFunctionFile = absPath( - "${TEMPORARY}/default_transfer_function.txt" - ).string(); + DefaultTransferFunctionFile = absPath("${TEMPORARY}/default_transfer_function.txt"); - std::ofstream file(DefaultTransferFunctionFile); + std::ofstream file = std::ofstream(DefaultTransferFunctionFile); file << DefaultTransferfunctionSource; } diff --git a/modules/fieldlinessequence/fieldlinessequencemodule.h b/modules/fieldlinessequence/fieldlinessequencemodule.h index e9a71fb144..2272170596 100644 --- a/modules/fieldlinessequence/fieldlinessequencemodule.h +++ b/modules/fieldlinessequence/fieldlinessequencemodule.h @@ -27,6 +27,8 @@ #include +#include + namespace openspace { class FieldlinesSequenceModule : public OpenSpaceModule { @@ -37,7 +39,7 @@ public: std::vector documentations() const override; - static std::string DefaultTransferFunctionFile; + static std::filesystem::path DefaultTransferFunctionFile; private: void internalInitialize(const ghoul::Dictionary&) override; diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index 9bf9d159d5..e68845d67c 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -232,7 +232,7 @@ namespace { // A list of paths to transferfunction .txt files containing color tables // used for colorizing the fieldlines according to different parameters - std::optional> colorTablePaths; + std::optional> colorTablePaths; // [[codegen::verbatim(ColorMethodInfo.description)]] std::optional colorMethod; @@ -420,9 +420,7 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence( // Ensure that there are available and valid source files left if (_sourceFiles.empty()) { - LERROR(std::format( - "'{}' contains no {} files", sourcePath.string(), fileTypeString - )); + LERROR(std::format("'{}' contains no {} files", sourcePath, fileTypeString)); } _extraVars = p.extraVariables.value_or(_extraVars); _flowEnabled = p.flowEnabled.value_or(_flowEnabled); @@ -438,7 +436,7 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence( _maskingEnabled = p.maskingEnabled.value_or(_maskingEnabled); _maskingQuantityTemp = p.maskingQuantity.value_or(_maskingQuantityTemp); if (p.colorTablePaths.has_value()) { - _colorTablePaths = p.colorTablePaths.value(); + _colorTablePaths = *p.colorTablePaths; } else { // Set a default color table, just in case the (optional) user defined paths are @@ -499,9 +497,7 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence( } void RenderableFieldlinesSequence::initialize() { - _transferFunction = std::make_unique( - absPath(_colorTablePaths[0]).string() - ); + _transferFunction = std::make_unique(absPath(_colorTablePaths[0])); } void RenderableFieldlinesSequence::initializeGL() { @@ -680,7 +676,7 @@ void RenderableFieldlinesSequence::setupProperties() { // Each quantity should have its own color table and color table range // no more, no less _colorTablePaths.resize(nExtraQuantities, _colorTablePaths.back()); - _colorTablePath = _colorTablePaths[0]; + _colorTablePath = _colorTablePaths[0].string(); _colorTableRanges.resize(nExtraQuantities, _colorTableRanges.back()); _maskingRanges.resize(nExtraQuantities, _maskingRanges.back()); } @@ -704,11 +700,11 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() { _colorQuantity.onChange([this]() { _shouldUpdateColorBuffer = true; _colorQuantityMinMax = _colorTableRanges[_colorQuantity]; - _colorTablePath = _colorTablePaths[_colorQuantity]; + _colorTablePath = _colorTablePaths[_colorQuantity].string(); }); _colorTablePath.onChange([this]() { - _transferFunction->setPath(_colorTablePath); + _transferFunction->setPath(_colorTablePath.value()); }); _colorQuantityMinMax.onChange([this]() { diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h index b704a9b8d3..b2bcb92e1d 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h @@ -147,7 +147,7 @@ private: std::unique_ptr _transferFunction; // Paths to color tables. One for each 'extraQuantity' - std::vector _colorTablePaths; + std::vector _colorTablePaths; // Values represents min & max values represented in the color table std::vector _colorTableRanges; // Values represents min & max limits for valid masking range diff --git a/modules/gaia/rendering/octreemanager.cpp b/modules/gaia/rendering/octreemanager.cpp index f77492ad78..506c3c7e4b 100644 --- a/modules/gaia/rendering/octreemanager.cpp +++ b/modules/gaia/rendering/octreemanager.cpp @@ -604,7 +604,7 @@ void OctreeManager::writeNodeToFile(std::ofstream& outFileStream, const OctreeNo } int OctreeManager::readFromFile(std::ifstream& inFileStream, bool readData, - const std::string& folderPath) + const std::filesystem::path& folderPath) { int nStarsRead = 0; const int oldMaxdist = static_cast(MAX_DIST); @@ -699,11 +699,11 @@ int OctreeManager::readNodeFromFile(std::ifstream& inFileStream, OctreeNode& nod return numStars; } -void OctreeManager::writeToMultipleFiles(const std::string& outFolderPath, +void OctreeManager::writeToMultipleFiles(const std::filesystem::path& outFolderPath, size_t branchIndex) { // Write entire branch to disc, with one file per node - const std::string outFilePrefix = outFolderPath + std::to_string(branchIndex); + const std::string outFilePrefix = std::format("{}{}", outFolderPath, branchIndex); // More threads doesn't make it much faster, disk speed still the limiter writeNodeToMultipleFiles(outFilePrefix, *_root->children[branchIndex], false); @@ -797,7 +797,9 @@ void OctreeManager::fetchNodeDataFromFile(OctreeNode& node) { std::string posId = std::to_string(node.octreePositionIndex); posId.erase(posId.begin()); - const std::string inFilePath = _streamFolderPath + posId + BINARY_SUFFIX; + const std::string inFilePath = std::format( + "{}{}{}", _streamFolderPath, posId, BINARY_SUFFIX + ); std::ifstream inFileStream(inFilePath, std::ifstream::binary); // LINFO("Fetch node data file: " + inFilePath); diff --git a/modules/gaia/rendering/octreemanager.h b/modules/gaia/rendering/octreemanager.h index 05a56a5908..5be8d38d53 100644 --- a/modules/gaia/rendering/octreemanager.h +++ b/modules/gaia/rendering/octreemanager.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -150,7 +151,7 @@ public: * \return the total number of (distinct) stars read */ int readFromFile(std::ifstream& inFileStream, bool readData, - const std::string& folderPath = std::string()); + const std::filesystem::path& folderPath = std::filesystem::path()); /** * Write specified part of Octree to multiple files, including all data. @@ -159,7 +160,8 @@ public: * \param branchIndex Defines which branch to write. Clears specified branch after * writing is done. Calls `writeNodeToMultipleFiles()` for the specified branch */ - void writeToMultipleFiles(const std::string& outFolderPath, size_t branchIndex); + void writeToMultipleFiles(const std::filesystem::path& outFolderPath, + size_t branchIndex); /** * Getters. @@ -410,7 +412,7 @@ private: long long _cpuRamBudget = 0; long long _maxCpuRamBudget = 0; unsigned long long _parentNodeOfCamera = 8; - std::string _streamFolderPath; + std::filesystem::path _streamFolderPath; size_t _traversedBranchesInRenderCall = 0; }; // class OctreeManager diff --git a/modules/gaia/rendering/renderablegaiastars.cpp b/modules/gaia/rendering/renderablegaiastars.cpp index 8caea6a862..ee99034969 100644 --- a/modules/gaia/rendering/renderablegaiastars.cpp +++ b/modules/gaia/rendering/renderablegaiastars.cpp @@ -2101,7 +2101,7 @@ void RenderableGaiaStars::update(const UpdateData&) { _pointSpreadFunctionTexture = nullptr; if (!_pointSpreadFunctionTexturePath.value().empty()) { _pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_pointSpreadFunctionTexturePath).string(), + absPath(_pointSpreadFunctionTexturePath), 2 ); @@ -2130,7 +2130,7 @@ void RenderableGaiaStars::update(const UpdateData&) { _colorTexture = nullptr; if (!_colorTexturePath.value().empty()) { _colorTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_colorTexturePath).string(), + absPath(_colorTexturePath), 1 ); if (_colorTexture) { @@ -2199,24 +2199,24 @@ bool RenderableGaiaStars::readDataFile() { switch (fileReaderOption) { case gaia::FileReaderOption::Fits: - // Read raw fits file and construct Octree. + // Read raw fits file and construct Octree nReadStars = readFitsFile(file); break; case gaia::FileReaderOption::Speck: - // Read raw speck file and construct Octree. + // Read raw speck file and construct Octree nReadStars = readSpeckFile(file); break; case gaia::FileReaderOption::BinaryRaw: - // Stars are stored in an ordered binary file. + // Stars are stored in an ordered binary file nReadStars = readBinaryRawFile(file); break; case gaia::FileReaderOption::BinaryOctree: - // Octree already constructed and stored as a binary file. + // Octree already constructed and stored as a binary file nReadStars = readBinaryOctreeFile(file); break; case gaia::FileReaderOption::StreamOctree: - // Read Octree structure from file, without data. - nReadStars = readBinaryOctreeStructureFile(file.string()); + // Read Octree structure from file, without data + nReadStars = readBinaryOctreeStructureFile(file); break; default: LERROR("Wrong FileReaderOption - no data file loaded"); @@ -2332,21 +2332,17 @@ int RenderableGaiaStars::readBinaryOctreeFile(const std::filesystem::path& fileP int RenderableGaiaStars::readBinaryOctreeStructureFile( const std::filesystem::path& folderPath) { - int nReadStars = 0; - std::string indexFile = folderPath.string() + "index.bin"; + std::filesystem::path indexFile = folderPath / "index.bin"; - std::ifstream fileStream(indexFile, std::ifstream::binary); - if (fileStream.good()) { - nReadStars = _octreeManager.readFromFile(fileStream, false, folderPath.string()); - - fileStream.close(); - } - else { + std::ifstream fileStream = std::ifstream(indexFile, std::ifstream::binary); + if (!fileStream.good()) { LERROR(std::format( "Error opening file '{}' for loading binary Octree file", indexFile )); - return nReadStars; + return 0; } + + const int nReadStars = _octreeManager.readFromFile(fileStream, false, folderPath); return nReadStars; } diff --git a/modules/gaia/tasks/constructoctreetask.cpp b/modules/gaia/tasks/constructoctreetask.cpp index b555002cdd..1151890488 100644 --- a/modules/gaia/tasks/constructoctreetask.cpp +++ b/modules/gaia/tasks/constructoctreetask.cpp @@ -561,7 +561,7 @@ void ConstructOctreeTask::constructOctreeFromFolder( std::thread t( &OctreeManager::writeToMultipleFiles, _indexOctreeManager, - _outFileOrFolderPath.string(), + _outFileOrFolderPath, idx ); writeThreads[idx] = std::move(t); @@ -591,10 +591,8 @@ void ConstructOctreeTask::constructOctreeFromFolder( // " - 5000kPc is " + std::to_string(starsOutside5000)); // Write index file of Octree structure. - std::filesystem::path indexFileOutPath = std::format( - "{}/index.bin", _outFileOrFolderPath.string() - ); - std::ofstream outFileStream(indexFileOutPath, std::ofstream::binary); + std::filesystem::path indexFileOutPath = _outFileOrFolderPath / "index.bin"; + std::ofstream outFileStream = std::ofstream(indexFileOutPath, std::ofstream::binary); if (outFileStream.good()) { LINFO("Writing index file"); _indexOctreeManager->writeToFile(outFileStream, false); diff --git a/modules/gaia/tasks/readfilejob.cpp b/modules/gaia/tasks/readfilejob.cpp index 2e9e0ffca3..f9b21efcda 100644 --- a/modules/gaia/tasks/readfilejob.cpp +++ b/modules/gaia/tasks/readfilejob.cpp @@ -35,9 +35,10 @@ namespace { namespace openspace::gaia { -ReadFileJob::ReadFileJob(std::string filePath, std::vector allColumns, - int firstRow, int lastRow, size_t nDefaultCols, - int nValuesPerStar, std::shared_ptr fitsReader) +ReadFileJob::ReadFileJob(std::filesystem::path filePath, + std::vector allColumns, int firstRow, int lastRow, + size_t nDefaultCols, int nValuesPerStar, + std::shared_ptr fitsReader) : _inFilePath(std::move(filePath)) , _firstRow(firstRow) , _lastRow(lastRow) diff --git a/modules/gaia/tasks/readfilejob.h b/modules/gaia/tasks/readfilejob.h index 9409704084..6ab2469a33 100644 --- a/modules/gaia/tasks/readfilejob.h +++ b/modules/gaia/tasks/readfilejob.h @@ -28,6 +28,7 @@ #include #include +#include namespace openspace::gaia { @@ -49,8 +50,8 @@ struct ReadFileJob : public Job>> { * \param nValuesPerStar Defines how many values that will be stored per star * \param fitsReader The reader that should be used in this job */ - ReadFileJob(std::string filePath, std::vector allColumns, int firstRow, - int lastRow, size_t nDefaultCols, int nValuesPerStar, + ReadFileJob(std::filesystem::path filePath, std::vector allColumns, + int firstRow, int lastRow, size_t nDefaultCols, int nValuesPerStar, std::shared_ptr fitsReader); ~ReadFileJob() override = default; @@ -60,7 +61,7 @@ struct ReadFileJob : public Job>> { std::vector> product() override; private: - std::string _inFilePath; + std::filesystem::path _inFilePath; int _firstRow; int _lastRow; size_t _nDefaultCols; diff --git a/modules/gaia/tasks/readfitstask.cpp b/modules/gaia/tasks/readfitstask.cpp index c44ab59257..a334b62ba5 100644 --- a/modules/gaia/tasks/readfitstask.cpp +++ b/modules/gaia/tasks/readfitstask.cpp @@ -132,7 +132,7 @@ void ReadFitsTask::readSingleFitsFile(const Task::ProgressCallback& progressCall FitsFileReader fileReader(false); std::vector fullData = fileReader.readFitsFile( - _inFileOrFolderPath.string(), + _inFileOrFolderPath, nValuesPerStar, _firstRow, _lastRow, @@ -255,7 +255,7 @@ void ReadFitsTask::readAllFitsFilesFromFolder(const Task::ProgressCallback&) { // Add reading of file to jobmanager, which will distribute it to our threadpool. auto readFileJob = std::make_shared( - fileToRead.string(), + fileToRead, _allColumnNames, _firstRow, _lastRow, diff --git a/modules/galaxy/rendering/galaxyraycaster.cpp b/modules/galaxy/rendering/galaxyraycaster.cpp index a550a98eef..649de64569 100644 --- a/modules/galaxy/rendering/galaxyraycaster.cpp +++ b/modules/galaxy/rendering/galaxyraycaster.cpp @@ -26,8 +26,9 @@ #include #include -#include +#include #include +#include #include #include #include @@ -142,19 +143,19 @@ bool GalaxyRaycaster::isCameraInside(const RenderData& data, glm::vec3& localPos localPosition.z > 0 && localPosition.z < 1); } -std::string GalaxyRaycaster::boundsVertexShaderPath() const { - return std::string(GlslBoundsVsPath); +std::filesystem::path GalaxyRaycaster::boundsVertexShaderPath() const { + return absPath(GlslBoundsVsPath); } -std::string GalaxyRaycaster::boundsFragmentShaderPath() const { - return std::string(GlslBoundsFsPath); +std::filesystem::path GalaxyRaycaster::boundsFragmentShaderPath() const { + return absPath(GlslBoundsFsPath); } -std::string GalaxyRaycaster::raycasterPath() const { - return _raycastingShader.string(); +std::filesystem::path GalaxyRaycaster::raycasterPath() const { + return _raycastingShader; } -std::string GalaxyRaycaster::helperPath() const { +std::filesystem::path GalaxyRaycaster::helperPath() const { return ""; // no helper file } diff --git a/modules/galaxy/rendering/galaxyraycaster.h b/modules/galaxy/rendering/galaxyraycaster.h index 25da69373b..f364fb6b98 100644 --- a/modules/galaxy/rendering/galaxyraycaster.h +++ b/modules/galaxy/rendering/galaxyraycaster.h @@ -62,10 +62,10 @@ public: bool isCameraInside(const RenderData& data, glm::vec3& localPosition) override; - std::string boundsVertexShaderPath() const override; - std::string boundsFragmentShaderPath() const override; - std::string raycasterPath() const override; - std::string helperPath() const override; + std::filesystem::path boundsVertexShaderPath() const override; + std::filesystem::path boundsFragmentShaderPath() const override; + std::filesystem::path raycasterPath() const override; + std::filesystem::path helperPath() const override; void setAspect(const glm::vec3& aspect); void setModelTransform(glm::mat4 transform); diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index f14fd544ac..ea11d39242 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -302,15 +302,15 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) _rotation = p.rotation.value_or(_rotation); - _volumeFilename = p.volume.filename.string(); + _volumeFilename = p.volume.filename; _volumeDimensions = p.volume.dimensions; _volumeSize = p.volume.size; _numberOfRayCastingSteps = p.volume.steps.value_or(_numberOfRayCastingSteps); _downScaleVolumeRendering = p.volume.downscale.value_or(_downScaleVolumeRendering); - _pointsFilename = p.points.filename.string(); + _pointsFilename = p.points.filename; _enabledPointsRatio = p.points.enabledPointsRatio.value_or(_enabledPointsRatio); - _pointSpreadFunctionTexturePath = p.points.texture.string(); + _pointSpreadFunctionTexturePath = p.points.texture; _pointSpreadFunctionFile = std::make_unique( _pointSpreadFunctionTexturePath ); @@ -455,7 +455,7 @@ void RenderableGalaxy::initializeGL() { if (!_pointSpreadFunctionTexturePath.empty()) { _pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_pointSpreadFunctionTexturePath).string(), + absPath(_pointSpreadFunctionTexturePath), 2 ); diff --git a/modules/galaxy/rendering/renderablegalaxy.h b/modules/galaxy/rendering/renderablegalaxy.h index 4da5da407e..39639363b9 100644 --- a/modules/galaxy/rendering/renderablegalaxy.h +++ b/modules/galaxy/rendering/renderablegalaxy.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace ghoul::opengl { class ProgramObject; } @@ -84,10 +85,10 @@ private: std::unique_ptr _pointSpreadFunctionTexture; std::unique_ptr _pointSpreadFunctionFile; - std::string _volumeFilename; + std::filesystem::path _volumeFilename; glm::ivec3 _volumeDimensions = glm::ivec3(0); - std::string _pointsFilename; - std::string _pointSpreadFunctionTexturePath; + std::filesystem::path _pointsFilename; + std::filesystem::path _pointSpreadFunctionTexturePath; std::filesystem::path _raycastingShader; std::unique_ptr _raycaster; diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index fbf03fff1a..956823ea4f 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -701,7 +701,7 @@ geoPositionForCameraDeprecated(bool useEyePosition = false) std::string identifier = makeIdentifier(name.value_or(path.stem().string())); d.setValue("Identifier", identifier); - d.setValue("File", path.string()); + d.setValue("File", path); if (name.has_value()) { d.setValue("Name", *name); } diff --git a/modules/globebrowsing/src/gdalwrapper.cpp b/modules/globebrowsing/src/gdalwrapper.cpp index 3bb7c0093d..de23b519a7 100644 --- a/modules/globebrowsing/src/gdalwrapper.cpp +++ b/modules/globebrowsing/src/gdalwrapper.cpp @@ -97,9 +97,9 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize , _gdalMaximumCacheSize( GdalMaximumCacheInfo, static_cast(maximumCacheSize / (1024ULL * 1024ULL)), // Default - 0, // Minimum: No caching + 0, // Minimum: No caching static_cast(maximumMaximumCacheSize / (1024ULL * 1024ULL)), // Maximum - 1 // Step: One MB + 1 // Step: One MB ) { ZoneScoped; @@ -108,11 +108,10 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize addProperty(_gdalMaximumCacheSize); GDALAllRegister(); - CPLSetConfigOption( - "GDAL_DATA", - absPath("${MODULE_GLOBEBROWSING}/gdal_data").string().c_str() - ); - CPLSetConfigOption("CPL_TMPDIR", absPath("${BASE}").string().c_str()); + const std::string data = absPath("${MODULE_GLOBEBROWSING}/gdal_data").string(); + CPLSetConfigOption("GDAL_DATA", data.c_str()); + const std::string base = absPath("${BASE}").string(); + CPLSetConfigOption("CPL_TMPDIR", base.c_str()); CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES"); CPLSetConfigOption("GDAL_HTTP_TIMEOUT", "3"); // 3 seconds @@ -121,7 +120,7 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize setGdalProxyConfiguration(); CPLSetErrorHandler(gdalErrorHandler); - _gdalMaximumCacheSize.onChange([&] { + _gdalMaximumCacheSize.onChange([this] { // MB to Bytes GDALSetCacheMax64( static_cast(_gdalMaximumCacheSize) * 1024ULL * 1024ULL diff --git a/modules/globebrowsing/src/globelabelscomponent.cpp b/modules/globebrowsing/src/globelabelscomponent.cpp index 5211972ea7..ce1253a0a6 100644 --- a/modules/globebrowsing/src/globelabelscomponent.cpp +++ b/modules/globebrowsing/src/globelabelscomponent.cpp @@ -327,7 +327,7 @@ void GlobeLabelsComponent::initialize(const ghoul::Dictionary& dictionary, return; } - const bool loadSuccess = loadLabelsData(absPath(p.fileName->string()).string()); + const bool loadSuccess = loadLabelsData(absPath(*p.fileName)); if (!loadSuccess) { return; } diff --git a/modules/globebrowsing/src/rawtiledatareader.cpp b/modules/globebrowsing/src/rawtiledatareader.cpp index 47fd4447c4..0b0ff30478 100644 --- a/modules/globebrowsing/src/rawtiledatareader.cpp +++ b/modules/globebrowsing/src/rawtiledatareader.cpp @@ -296,8 +296,8 @@ std::optional RawTileDataReader::mrfCache() { std::to_string(std::hash{}(_datasetFilePath)); const std::string path = std::format("{}/{}/{}/", mod.mrfCacheLocation(), _cacheProperties.path, datasetIdentifier); - const std::string root = absPath(path).string(); - std::string mrf = root + datasetIdentifier + ".mrf"; + const std::filesystem::path root = absPath(path); + const std::string mrf = std::format("{}{}.mrf", root, datasetIdentifier); if (!std::filesystem::exists(mrf)) { std::error_code ec; diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index a7fe337ac0..20bc7cd980 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -285,7 +285,7 @@ void RingsComponent::initialize() { addProperty(_size); if (p.texture.has_value()) { - _texturePath = absPath(p.texture->string()).string(); + _texturePath = absPath(*p.texture).string(); _textureFile = std::make_unique(_texturePath.value()); _texturePath.onChange([this]() { loadTexture(); }); addProperty(_texturePath); @@ -293,7 +293,7 @@ void RingsComponent::initialize() { } if (p.textureFwrd.has_value()) { - _textureFwrdPath = absPath(p.textureFwrd->string()).string(); + _textureFwrdPath = absPath(*p.textureFwrd).string(); _textureFileForwards = std::make_unique(_textureFwrdPath.value()); _textureFwrdPath.onChange([this]() { loadTexture(); }); addProperty(_textureFwrdPath); @@ -301,7 +301,7 @@ void RingsComponent::initialize() { } if (p.textureBckwrd.has_value()) { - _textureBckwrdPath = absPath(p.textureBckwrd->string()).string(); + _textureBckwrdPath = absPath(*p.textureBckwrd).string(); _textureFileBackwards = std::make_unique(_textureBckwrdPath.value()); _textureBckwrdPath.onChange([this]() { loadTexture(); }); addProperty(_textureBckwrdPath); @@ -309,7 +309,7 @@ void RingsComponent::initialize() { } if (p.textureUnlit.has_value()) { - _textureUnlitPath = absPath(p.textureUnlit->string()).string(); + _textureUnlitPath = absPath(*p.textureUnlit).string(); _textureFileUnlit = std::make_unique(_textureUnlitPath.value()); _textureUnlitPath.onChange([this]() { loadTexture(); }); addProperty(_textureUnlitPath); @@ -317,7 +317,7 @@ void RingsComponent::initialize() { } if (p.textureColor.has_value()) { - _textureColorPath = absPath(p.textureColor->string()).string(); + _textureColorPath = absPath(*p.textureColor).string(); _textureFileColor = std::make_unique(_textureColorPath.value()); _textureColorPath.onChange([this]() { loadTexture(); }); addProperty(_textureColorPath); @@ -325,7 +325,7 @@ void RingsComponent::initialize() { } if (p.textureTransparency.has_value()) { - _textureTransparencyPath = absPath(p.textureTransparency->string()).string(); + _textureTransparencyPath = absPath(*p.textureTransparency).string(); _textureFileTransparency = std::make_unique( _textureTransparencyPath.value() ); @@ -658,15 +658,12 @@ void RingsComponent::loadTexture() { if (!_texturePath.value().empty()) { std::unique_ptr texture = TextureReader::ref().loadTexture( - absPath(_texturePath).string(), + absPath(_texturePath), 1 ); if (texture) { - LDEBUGC( - "RingsComponent", - std::format("Loaded texture from '{}'", absPath(_texturePath)) - ); + LDEBUG(std::format("Loaded texture from '{}'", absPath(_texturePath))); _texture = std::move(texture); _texture->uploadTexture(); @@ -681,13 +678,12 @@ void RingsComponent::loadTexture() { if (!_textureFwrdPath.value().empty()) { std::unique_ptr textureForwards = TextureReader::ref().loadTexture( - absPath(_textureFwrdPath).string(), + absPath(_textureFwrdPath), 1 ); if (textureForwards) { - LDEBUGC( - "RingsComponent", + LDEBUG( std::format( "Loaded forwards scattering texture from '{}'", absPath(_textureFwrdPath) @@ -708,13 +704,12 @@ void RingsComponent::loadTexture() { if (!_textureBckwrdPath.value().empty()) { std::unique_ptr textureBackwards = TextureReader::ref().loadTexture( - absPath(_textureBckwrdPath).string(), + absPath(_textureBckwrdPath), 1 ); if (textureBackwards) { - LDEBUGC( - "RingsComponent", + LDEBUG( std::format( "Loaded backwards scattering texture from '{}'", absPath(_textureBckwrdPath) @@ -735,13 +730,12 @@ void RingsComponent::loadTexture() { if (!_textureUnlitPath.value().empty()) { std::unique_ptr textureUnlit = TextureReader::ref().loadTexture( - absPath(_textureUnlitPath).string(), + absPath(_textureUnlitPath), 1 ); if (textureUnlit) { - LDEBUGC( - "RingsComponent", + LDEBUG( std::format("Loaded unlit texture from '{}'", absPath(_textureUnlitPath)) ); _textureUnlit = std::move(textureUnlit); @@ -758,13 +752,12 @@ void RingsComponent::loadTexture() { if (!_textureColorPath.value().empty()) { std::unique_ptr textureColor = TextureReader::ref().loadTexture( - absPath(_textureColorPath).string(), + absPath(_textureColorPath), 1 ); if (textureColor) { - LDEBUGC( - "RingsComponent", + LDEBUG( std::format("Loaded color texture from '{}'", absPath(_textureColorPath)) ); _textureColor = std::move(textureColor); @@ -781,13 +774,12 @@ void RingsComponent::loadTexture() { if (!_textureTransparencyPath.value().empty()) { std::unique_ptr textureTransparency = TextureReader::ref().loadTexture( - absPath(_textureTransparencyPath).string(), + absPath(_textureTransparencyPath), 1 ); if (textureTransparency) { - LDEBUGC( - "RingsComponent", + LDEBUG( std::format("Loaded unlit texture from '{}'", absPath(_textureUnlitPath)) ); _textureTransparency = std::move(textureTransparency); diff --git a/modules/globebrowsing/src/tileprovider/singleimagetileprovider.cpp b/modules/globebrowsing/src/tileprovider/singleimagetileprovider.cpp index cd7f1af860..0ddfef9fd0 100644 --- a/modules/globebrowsing/src/tileprovider/singleimagetileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider/singleimagetileprovider.cpp @@ -82,7 +82,7 @@ void SingleImageProvider::reset() { return; } - _tileTexture = ghoul::io::TextureReader::ref().loadTexture(_filePath, 2); + _tileTexture = ghoul::io::TextureReader::ref().loadTexture(_filePath.value(), 2); if (!_tileTexture) { throw ghoul::RuntimeError( std::format("Unable to load texture '{}'", _filePath.value()) diff --git a/modules/iswa/rendering/iswakameleongroup.cpp b/modules/iswa/rendering/iswakameleongroup.cpp index c7fa089606..0cf2b1e6d0 100644 --- a/modules/iswa/rendering/iswakameleongroup.cpp +++ b/modules/iswa/rendering/iswakameleongroup.cpp @@ -73,8 +73,8 @@ std::set IswaKameleonGroup::fieldlineValue() const { return _fieldlines; } -void IswaKameleonGroup::setFieldlineInfo(std::string fieldlineIndexFile, - std::string kameleonPath) +void IswaKameleonGroup::setFieldlineInfo(std::filesystem::path fieldlineIndexFile, + std::filesystem::path kameleonPath) { if (fieldlineIndexFile != _fieldlineIndexFile) { _fieldlineIndexFile = std::move(fieldlineIndexFile); @@ -99,7 +99,7 @@ void IswaKameleonGroup::registerProperties() { _fieldlines.onChange([this]() { updateFieldlineSeeds(); }); } -void IswaKameleonGroup::readFieldlinePaths(const std::string& indexFile) { +void IswaKameleonGroup::readFieldlinePaths(const std::filesystem::path& indexFile) { LINFO(std::format("Reading seed points paths from file '{}'", indexFile)); // Read the index file from disk diff --git a/modules/iswa/rendering/iswakameleongroup.h b/modules/iswa/rendering/iswakameleongroup.h index f0532560cb..2c8e4f223e 100644 --- a/modules/iswa/rendering/iswakameleongroup.h +++ b/modules/iswa/rendering/iswakameleongroup.h @@ -37,21 +37,22 @@ public: virtual void clearGroup() override; std::set fieldlineValue() const; - void setFieldlineInfo(std::string fieldlineIndexFile, std::string kameleonPath); + void setFieldlineInfo(std::filesystem::path fieldlineIndexFile, + std::filesystem::path kameleonPath); void changeCdf(std::string path); protected: void registerProperties(); - void readFieldlinePaths(const std::string& indexFile); + void readFieldlinePaths(const std::filesystem::path& indexFile); void updateFieldlineSeeds(); void clearFieldlines(); properties::FloatProperty _resolution; properties::SelectionProperty _fieldlines; - std::string _fieldlineIndexFile; - std::string _kameleonPath; + std::filesystem::path _fieldlineIndexFile; + std::filesystem::path _kameleonPath; std::map> _fieldlineState; }; diff --git a/modules/iswa/rendering/kameleonplane.cpp b/modules/iswa/rendering/kameleonplane.cpp index 707aa8dd45..3bc8372b16 100644 --- a/modules/iswa/rendering/kameleonplane.cpp +++ b/modules/iswa/rendering/kameleonplane.cpp @@ -134,7 +134,7 @@ void KameleonPlane::initializeGL() { initializeTime(); createGeometry(); - readFieldlinePaths(absPath(_fieldlineIndexFile).string()); + readFieldlinePaths(absPath(_fieldlineIndexFile)); if (_group) { _dataProcessor = _group->dataProcessor(); @@ -317,7 +317,7 @@ void KameleonPlane::updateFieldlineSeeds() { } } -void KameleonPlane::readFieldlinePaths(const std::string& indexFile) { +void KameleonPlane::readFieldlinePaths(const std::filesystem::path& indexFile) { LINFO(std::format("Reading seed points paths from file '{}'", indexFile)); if (_group) { dynamic_cast(_group)->setFieldlineInfo( diff --git a/modules/iswa/rendering/kameleonplane.h b/modules/iswa/rendering/kameleonplane.h index 52e6041608..f0abf5ca78 100644 --- a/modules/iswa/rendering/kameleonplane.h +++ b/modules/iswa/rendering/kameleonplane.h @@ -66,7 +66,7 @@ private: * * \param indexFile Path to json index file */ - void readFieldlinePaths(const std::string& indexFile); + void readFieldlinePaths(const std::filesystem::path& indexFile); /** * Updates the _fieldlineState map to match the _fieldlines SelectionProperty and diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index ba8469e968..f3d06cc35a 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -413,7 +413,7 @@ std::string IswaManager::parseKWToLuaTable(const CdfInfo& info, const std::strin std::filesystem::path ext = std::filesystem::path(absPath(info.path)).extension(); if (ext == ".cdf") { - KameleonWrapper kw = KameleonWrapper(absPath(info.path).string()); + KameleonWrapper kw = KameleonWrapper(absPath(info.path)); std::string parent = kw.parent(); std::string frame = kw.frame(); @@ -628,7 +628,7 @@ void IswaManager::createKameleonPlane(CdfInfo info, std::string cut) { } } -void IswaManager::createFieldline(std::string name, std::string cdfPath, +void IswaManager::createFieldline(std::string name, std::filesystem::path cdfPath, std::string seedPath) { std::filesystem::path ext = absPath(cdfPath).extension(); @@ -640,7 +640,7 @@ void IswaManager::createFieldline(std::string name, std::string cdfPath, "Type = 'RenderableFieldlines'," "VectorField = {" "Type = 'VolumeKameleon'," - "File = '" + cdfPath + "'," + "File = '" + cdfPath.string() + "'," "Model = 'BATSRUS'," "Variables = {'bx', 'by', 'bz'}" "}," @@ -664,7 +664,7 @@ void IswaManager::createFieldline(std::string name, std::string cdfPath, } } else { - LWARNING(cdfPath + " is not a cdf file or can't be found"); + LWARNING(std::format("{} is not a CDF file or cannot be found", cdfPath)); } } diff --git a/modules/iswa/util/iswamanager.h b/modules/iswa/util/iswamanager.h index a2f4b44115..cb1aa92607 100644 --- a/modules/iswa/util/iswamanager.h +++ b/modules/iswa/util/iswamanager.h @@ -83,7 +83,8 @@ public: void addIswaCygnet(int id, const std::string& type = "Texture", std::string group = ""); void addKameleonCdf(std::string group, int pos); - void createFieldline(std::string name, std::string cdfPath, std::string seedPath); + void createFieldline(std::string name, std::filesystem::path cdfPath, + std::string seedPath); std::future fetchImageCygnet(int id, double timestamp); std::future fetchDataCygnet(int id, double timestamp); diff --git a/modules/kameleon/include/kameleonwrapper.h b/modules/kameleon/include/kameleonwrapper.h index 63e583b893..37e2b468d3 100644 --- a/modules/kameleon/include/kameleonwrapper.h +++ b/modules/kameleon/include/kameleonwrapper.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -78,10 +79,10 @@ public: using Fieldlines = std::vector>; - explicit KameleonWrapper(const std::string& filename); + explicit KameleonWrapper(const std::filesystem::path& filename); ~KameleonWrapper(); - bool open(const std::string& filename); + bool open(const std::filesystem::path& filename); void close(); float* uniformSampledValues(const std::string& var, diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index 17e7bc59bf..c103d86625 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -90,7 +90,7 @@ std::array gridVariables(ccmc::Model* model) { return { x, y, z }; } -KameleonWrapper::KameleonWrapper(const std::string& filename) { +KameleonWrapper::KameleonWrapper(const std::filesystem::path& filename) { open(filename); } @@ -98,7 +98,7 @@ KameleonWrapper::~KameleonWrapper() { close(); } -bool KameleonWrapper::open(const std::string& filename) { +bool KameleonWrapper::open(const std::filesystem::path& filename) { close(); if (!std::filesystem::is_regular_file(filename)) { @@ -106,7 +106,7 @@ bool KameleonWrapper::open(const std::string& filename) { } _kameleon = new ccmc::Kameleon; - long status = _kameleon->open(filename); + long status = _kameleon->open(filename.string()); if (status == ccmc::FileReader::OK) { _model = _kameleon->model; _interpolator = _model->createNewInterpolator(); diff --git a/modules/kameleonvolume/kameleonvolumereader.cpp b/modules/kameleonvolume/kameleonvolumereader.cpp index e217b42208..b920611377 100644 --- a/modules/kameleonvolume/kameleonvolumereader.cpp +++ b/modules/kameleonvolume/kameleonvolumereader.cpp @@ -76,12 +76,14 @@ namespace { namespace openspace::kameleonvolume { -KameleonVolumeReader::KameleonVolumeReader(std::string path) : _path(std::move(path)) { +KameleonVolumeReader::KameleonVolumeReader(std::filesystem::path path) + : _path(std::move(path)) +{ if (!std::filesystem::is_regular_file(_path)) { throw ghoul::FileNotFoundError(_path); } - const long status = _kameleon->open(_path); + const long status = _kameleon->open(_path.string()); if (status != ccmc::FileReader::OK) { throw ghoul::RuntimeError(std::format( "Failed to open file '{}' with Kameleon", _path diff --git a/modules/kameleonvolume/kameleonvolumereader.h b/modules/kameleonvolume/kameleonvolumereader.h index 665224d8c6..7c53b30bc8 100644 --- a/modules/kameleonvolume/kameleonvolumereader.h +++ b/modules/kameleonvolume/kameleonvolumereader.h @@ -26,6 +26,7 @@ #define __OPENSPACE_MODULE_KAMELEONVOLUME___KAMELEONVOLUMEREADER___H__ #include +#include #include #include #include @@ -43,7 +44,7 @@ namespace openspace::kameleonvolume { class KameleonVolumeReader { public: - KameleonVolumeReader(std::string path); + KameleonVolumeReader(std::filesystem::path path); ~KameleonVolumeReader(); std::unique_ptr> readFloatVolume( @@ -75,7 +76,7 @@ private: static void addAttributeToDictionary(ghoul::Dictionary& dictionary, const std::string& key, ccmc::Attribute& attr); - std::string _path; + std::filesystem::path _path; std::unique_ptr _kameleon; std::unique_ptr _interpolator; }; diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp index 3413e7c901..96b948be76 100644 --- a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp @@ -182,7 +182,7 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict if (dictionary.hasValue(KeyTransferFunction)) { _transferFunctionPath = dictionary.value(KeyTransferFunction); _transferFunction = std::make_shared( - _transferFunctionPath, [](const openspace::TransferFunction&) {} + _transferFunctionPath.value() ); } diff --git a/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp b/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp index f3d9ba8042..9cca71ce20 100644 --- a/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp +++ b/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp @@ -59,7 +59,7 @@ documentation::Documentation KameleonDocumentationTask::documentation() { KameleonDocumentationTask::KameleonDocumentationTask(const ghoul::Dictionary& dictionary) { const Parameters p = codegen::bake(dictionary); - _inputPath = absPath(p.input.string()); + _inputPath = absPath(p.input); _outputPath = absPath(p.output); } @@ -71,7 +71,7 @@ std::string KameleonDocumentationTask::description() { } void KameleonDocumentationTask::perform(const Task::ProgressCallback & progressCallback) { - KameleonVolumeReader reader(_inputPath.string()); + KameleonVolumeReader reader = KameleonVolumeReader(_inputPath.string()); ghoul::Dictionary kameleonDictionary = reader.readMetaData(); progressCallback(0.33f); diff --git a/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp b/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp index 1855ebcaf7..bb2edd39f6 100644 --- a/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp +++ b/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp @@ -53,7 +53,7 @@ KameleonMetadataToJsonTask::KameleonMetadataToJsonTask( const ghoul::Dictionary& dictionary) { const Parameters p = codegen::bake(dictionary); - _inputPath = absPath(p.input.string()); + _inputPath = absPath(p.input); _outputPath = absPath(p.output); } @@ -65,7 +65,7 @@ std::string KameleonMetadataToJsonTask::description() { } void KameleonMetadataToJsonTask::perform(const Task::ProgressCallback& progressCallback) { - KameleonVolumeReader reader(_inputPath.string()); + KameleonVolumeReader reader = KameleonVolumeReader(_inputPath); ghoul::Dictionary dictionary = reader.readMetaData(); progressCallback(0.5f); diff --git a/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp b/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp index 0452e04f8c..db84c5aa65 100644 --- a/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp +++ b/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp @@ -75,7 +75,7 @@ documentation::Documentation KameleonVolumeToRawTask::documentation() { KameleonVolumeToRawTask::KameleonVolumeToRawTask(const ghoul::Dictionary& dictionary) { const Parameters p = codegen::bake(dictionary); - _inputPath = absPath(p.input.string()); + _inputPath = p.input; _rawVolumeOutputPath = absPath(p.rawVolumeOutput); _dictionaryOutputPath = absPath(p.dictionaryOutput); _variable = p.variable; @@ -105,7 +105,7 @@ std::string KameleonVolumeToRawTask::description() { } void KameleonVolumeToRawTask::perform(const Task::ProgressCallback& progressCallback) { - KameleonVolumeReader reader(_inputPath.string()); + KameleonVolumeReader reader = KameleonVolumeReader(_inputPath); std::array variables = reader.gridVariableNames(); @@ -132,7 +132,7 @@ void KameleonVolumeToRawTask::perform(const Task::ProgressCallback& progressCall progressCallback(0.5f); - volume::RawVolumeWriter writer(_rawVolumeOutputPath.string()); + volume::RawVolumeWriter writer(_rawVolumeOutputPath); writer.write(*rawVolume); progressCallback(0.9f); diff --git a/modules/multiresvolume/rendering/multiresvolumeraycaster.cpp b/modules/multiresvolume/rendering/multiresvolumeraycaster.cpp index 64ad947e1c..3b8217f713 100644 --- a/modules/multiresvolume/rendering/multiresvolumeraycaster.cpp +++ b/modules/multiresvolume/rendering/multiresvolumeraycaster.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -173,20 +174,20 @@ void MultiresVolumeRaycaster::postRaycast(const RaycastData&, _tfUnit = nullptr; } -std::string MultiresVolumeRaycaster::boundsVertexShaderPath() const { - return std::string(GlslBoundsVsPath); +std::filesystem::path MultiresVolumeRaycaster::boundsVertexShaderPath() const { + return absPath(GlslBoundsVsPath); } -std::string MultiresVolumeRaycaster::boundsFragmentShaderPath() const { - return std::string(GlslBoundsFsPath); +std::filesystem::path MultiresVolumeRaycaster::boundsFragmentShaderPath() const { + return absPath(GlslBoundsFsPath); } -std::string MultiresVolumeRaycaster::raycasterPath() const { - return std::string(GlslRaycastPath); +std::filesystem::path MultiresVolumeRaycaster::raycasterPath() const { + return absPath(GlslRaycastPath); } -std::string MultiresVolumeRaycaster::helperPath() const { - return std::string(GlslHelperPath); // no helper file +std::filesystem::path MultiresVolumeRaycaster::helperPath() const { + return absPath(GlslHelperPath); // no helper file } void MultiresVolumeRaycaster::setModelTransform(glm::mat4 transform) { diff --git a/modules/multiresvolume/rendering/multiresvolumeraycaster.h b/modules/multiresvolume/rendering/multiresvolumeraycaster.h index 075b71a166..1f14f7c851 100644 --- a/modules/multiresvolume/rendering/multiresvolumeraycaster.h +++ b/modules/multiresvolume/rendering/multiresvolumeraycaster.h @@ -66,10 +66,10 @@ public: ghoul::opengl::ProgramObject& program) override; bool isCameraInside(const RenderData& data, glm::vec3& localPosition) override; - std::string boundsVertexShaderPath() const override; - std::string boundsFragmentShaderPath() const override; - std::string raycasterPath() const override; - std::string helperPath() const override; + std::filesystem::path boundsVertexShaderPath() const override; + std::filesystem::path boundsFragmentShaderPath() const override; + std::filesystem::path raycasterPath() const override; + std::filesystem::path helperPath() const override; void setModelTransform(glm::mat4 transform); //void setTime(double time); diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp index 89a30c0e6f..805e8f8fe0 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp @@ -189,7 +189,7 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict , _scaling(ScalingInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(10.f)) { if (dictionary.hasValue(KeyDataSource)) { - _filename = absPath(dictionary.value(KeyDataSource)).string(); + _filename = absPath(dictionary.value(KeyDataSource)); } else { LERROR(std::format("Node did not contain a valid '{}'", KeyDataSource)); @@ -241,7 +241,7 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict if (dictionary.hasValue(KeyTransferFunction)) { _transferFunctionPath = absPath( dictionary.value(KeyTransferFunction) - ).string(); + ); _transferFunction = std::make_shared(_transferFunctionPath); } else { @@ -474,10 +474,7 @@ bool RenderableMultiresVolume::initializeSelector() { case Selector::TF: if (_errorHistogramManager) { std::filesystem::path cached = FileSys.cacheManager()->cachedFilename( - std::format( - "{}_{}_errorHistograms", - std::filesystem::path(_filename).stem().string(), nHistograms - ), + std::format("{}_{}_errorHistograms", _filename.stem(), nHistograms), "" ); std::ifstream cacheFile(cached, std::ios::in | std::ios::binary); @@ -494,9 +491,7 @@ bool RenderableMultiresVolume::initializeSelector() { LINFO(std::format( "Loading histograms from scene data '{}'", _errorHistogramsPath )); - success &= _errorHistogramManager->loadFromFile( - _errorHistogramsPath.string() - ); + success &= _errorHistogramManager->loadFromFile(_errorHistogramsPath); } else { // Build histograms from tsp file @@ -514,9 +509,7 @@ bool RenderableMultiresVolume::initializeSelector() { case Selector::SIMPLE: if (_histogramManager) { std::filesystem::path cached = FileSys.cacheManager()->cachedFilename( - std::format("{}_{}_histogram", - std::filesystem::path(_filename).stem().string(), nHistograms - ), + std::format("{}_{}_histogram", _filename.stem(), nHistograms), "" ); std::ifstream cacheFile(cached, std::ios::in | std::ios::binary); @@ -546,8 +539,7 @@ bool RenderableMultiresVolume::initializeSelector() { if (_localErrorHistogramManager) { std::filesystem::path cached = FileSys.cacheManager()->cachedFilename( std::format( - "{}_{}_localErrorHistograms", - std::filesystem::path(_filename).stem().string(), nHistograms + "{}_{}_localErrorHistograms", _filename.stem(), nHistograms ), "" ); diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.h b/modules/multiresvolume/rendering/renderablemultiresvolume.h index ab906a7b63..87edab8b84 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.h +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.h @@ -117,12 +117,12 @@ private: int _timestep = 0; - std::string _filename; + std::filesystem::path _filename; std::string _transferFunctionName; std::string _volumeName; - std::string _transferFunctionPath; + std::filesystem::path _transferFunctionPath; std::filesystem::path _errorHistogramsPath; std::shared_ptr _transferFunction; diff --git a/modules/multiresvolume/rendering/tsp.cpp b/modules/multiresvolume/rendering/tsp.cpp index 0bcd739914..0cacd4cae6 100644 --- a/modules/multiresvolume/rendering/tsp.cpp +++ b/modules/multiresvolume/rendering/tsp.cpp @@ -40,7 +40,7 @@ namespace { namespace openspace { -TSP::TSP(const std::string& filename) +TSP::TSP(const std::filesystem::path& filename) : _filename(filename) { _file.open(_filename, std::ios::in | std::ios::binary); diff --git a/modules/multiresvolume/rendering/tsp.h b/modules/multiresvolume/rendering/tsp.h index 1ef06fd9fd..9148a2f6e0 100644 --- a/modules/multiresvolume/rendering/tsp.h +++ b/modules/multiresvolume/rendering/tsp.h @@ -26,6 +26,7 @@ #define __OPENSPACE_MODULE_MULTIRESVOLUME___TSP___H__ #include +#include #include #include #include @@ -55,7 +56,7 @@ public: NUM_DATA }; - TSP(const std::string& filename); + TSP(const std::filesystem::path& filename); ~TSP(); // load performs readHeader, readCache, writeCache and construct @@ -113,7 +114,7 @@ private: */ std::list childBricks(unsigned int brickIndex); - std::string _filename; + std::filesystem::path _filename; std::ifstream _file; std::streampos _dataOffset; diff --git a/modules/skybrowser/src/wwtdatahandler.cpp b/modules/skybrowser/src/wwtdatahandler.cpp index 3789c998a2..85b198cc8e 100644 --- a/modules/skybrowser/src/wwtdatahandler.cpp +++ b/modules/skybrowser/src/wwtdatahandler.cpp @@ -132,7 +132,7 @@ namespace { { using namespace openspace; // Download file from url - const std::filesystem::path file = directory.string() + fileName + ".aspx"; + const std::filesystem::path file = std::format("{}{}.aspx", directory, fileName); const bool success = downloadFile(url, file); if (!success) { LINFO(std::format( @@ -143,7 +143,8 @@ namespace { // Parse file to XML auto document = std::make_unique(); - document->LoadFile(file.string().c_str()); + const std::string f = file.string(); + document->LoadFile(f.c_str()); // Search XML file for folders with urls const tinyxml2::XMLElement* root = document->RootElement(); diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index 3d3ad545f9..a2e0f3444f 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -85,7 +85,7 @@ RenderableConstellationBounds::RenderableConstellationBounds( const Parameters p = codegen::bake(dictionary); // Avoid reading files here, instead do it in multithreaded initialize() - _vertexFilename = absPath(p.file.string()).string(); + _vertexFilename = absPath(p.file).string(); _vertexFilename.onChange([this](){ loadData(); }); addProperty(_vertexFilename); diff --git a/modules/space/rendering/renderableconstellationlines.cpp b/modules/space/rendering/renderableconstellationlines.cpp index a54bd31aa6..727c9f7ba1 100644 --- a/modules/space/rendering/renderableconstellationlines.cpp +++ b/modules/space/rendering/renderableconstellationlines.cpp @@ -113,7 +113,7 @@ RenderableConstellationLines::RenderableConstellationLines( const Parameters p = codegen::bake(dictionary); // Avoid reading files here, instead do it in multithreaded initialize() - _speckFile = absPath(p.file.string()).string(); + _speckFile = absPath(p.file).string(); _speckFile.onChange([this]() { loadData(); }); addProperty(_speckFile); diff --git a/modules/space/rendering/renderableconstellationsbase.cpp b/modules/space/rendering/renderableconstellationsbase.cpp index 172fe0dd83..7de1232b4c 100644 --- a/modules/space/rendering/renderableconstellationsbase.cpp +++ b/modules/space/rendering/renderableconstellationsbase.cpp @@ -106,7 +106,7 @@ RenderableConstellationsBase::RenderableConstellationsBase( // Avoid reading files here, instead do it in multithreaded initialize() if (p.namesFile.has_value()) { - _namesFilename = absPath(p.namesFile.value().string()).string(); + _namesFilename = absPath(*p.namesFile).string(); } _namesFilename.onChange([this]() { loadConstellationFile(); }); addProperty(_namesFilename); diff --git a/modules/space/rendering/renderablefluxnodes.cpp b/modules/space/rendering/renderablefluxnodes.cpp index a4d30c1065..2e7112a6fd 100644 --- a/modules/space/rendering/renderablefluxnodes.cpp +++ b/modules/space/rendering/renderablefluxnodes.cpp @@ -342,7 +342,7 @@ RenderableFluxNodes::RenderableFluxNodes(const ghoul::Dictionary& dictionary) const Parameters p = codegen::bake(dictionary); _colorTablePath = p.colorTablePath; - _transferFunction = std::make_unique(_colorTablePath); + _transferFunction = std::make_unique(_colorTablePath.value()); _colorTableRange = p.colorTableRange.value_or(_colorTableRange); _binarySourceFolderPath = p.sourceFolder; @@ -353,7 +353,7 @@ RenderableFluxNodes::RenderableFluxNodes(const ghoul::Dictionary& dictionary) fs::directory_iterator(_binarySourceFolderPath)) { if (e.is_regular_file()) { - _binarySourceFiles.push_back(e.path().string()); + _binarySourceFiles.push_back(e.path()); } } std::sort(_binarySourceFiles.begin(), _binarySourceFiles.end()); @@ -431,7 +431,7 @@ void RenderableFluxNodes::definePropertyCallbackFunctions() { loadNodeData(_goesEnergyBins.option().value); }); _colorTablePath.onChange([this]() { - _transferFunction->setPath(_colorTablePath); + _transferFunction->setPath(_colorTablePath.value()); }); } @@ -448,13 +448,19 @@ void RenderableFluxNodes::loadNodeData(int energybinOption) { break; } - const std::string file = _binarySourceFolderPath.string() + "\\positions" + energybin; - const std::string file2 = _binarySourceFolderPath.string() + "\\fluxes" + energybin; - const std::string file3 = _binarySourceFolderPath.string() + "\\radiuses" + energybin; + const std::string file = std::format( + "{}/positions{}", _binarySourceFolderPath, energybin + ); + const std::string file2 = std::format( + "{}/fluxes/{}", _binarySourceFolderPath, energybin + ); + const std::string file3 = std::format( + "{}/radiuses{}", _binarySourceFolderPath, energybin + ); - std::ifstream fileStream(file, std::ifstream::binary); - std::ifstream fileStream2(file2, std::ifstream::binary); - std::ifstream fileStream3(file3, std::ifstream::binary); + std::ifstream fileStream = std::ifstream(file, std::ifstream::binary); + std::ifstream fileStream2 = std::ifstream(file2, std::ifstream::binary); + std::ifstream fileStream3 = std::ifstream(file3, std::ifstream::binary); if (!fileStream.good()) { LERROR(std::format("Could not read file '{}'", file)); @@ -580,27 +586,21 @@ bool RenderableFluxNodes::isReady() const { } void RenderableFluxNodes::populateStartTimes() { - std::string timeFile; - for (const std::string& filePath : _binarySourceFiles) { - if (filePath.substr(filePath.find_last_of('.') + 1) == "csv") { - timeFile = filePath; - break; - } - else if (filePath.substr(filePath.find_last_of('.') + 1) == "dat") { - timeFile = filePath; - break; - } - else if (filePath.substr(filePath.find_last_of('.') + 1) == "txt") { - timeFile = filePath; - break; - } - //if no file extention but word "time" in file name - else if (filePath.find("time") != std::string::npos && - filePath.find('.') == std::string::npos) + std::filesystem::path timeFile; + for (const std::filesystem::path& filePath : _binarySourceFiles) { + if (filePath.extension() == ".csv" || filePath.extension() == ".dat" || + filePath.extension() == ".txt") { timeFile = filePath; break; } + + const std::string f = filePath.string(); + // if no file extention but word "time" in file name + if (f.find("time") != std::string::npos && f.find('.') == std::string::npos) { + timeFile = filePath; + break; + } } if (timeFile.empty()) { @@ -611,7 +611,7 @@ void RenderableFluxNodes::populateStartTimes() { } // time filestream - std::ifstream tfs(timeFile); + std::ifstream tfs = std::ifstream(timeFile); if (!tfs.is_open()) { throw ghoul::RuntimeError("Could not open file"); } diff --git a/modules/space/rendering/renderablefluxnodes.h b/modules/space/rendering/renderablefluxnodes.h index 917a16748c..fd77b34b13 100644 --- a/modules/space/rendering/renderablefluxnodes.h +++ b/modules/space/rendering/renderablefluxnodes.h @@ -36,6 +36,7 @@ #include #include #include +#include namespace openspace { @@ -129,7 +130,7 @@ private: // Transfer function used to color lines when _colorMethod is set to by_flux_value std::unique_ptr _transferFunction; - std::vector _binarySourceFiles; + std::vector _binarySourceFiles; // Contains the _triggerTimes for all streams in the sequence std::vector _startTimes; // Contains vertexPositions diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index fbd66b88cd..d7241129c0 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -88,7 +88,7 @@ namespace { struct [[codegen::Dictionary(RenderableRings)]] Parameters { // [[codegen::verbatim(TextureInfo.description)]] - std::string texture; + std::filesystem::path texture; // [[codegen::verbatim(SizeInfo.description)]] float size; @@ -128,7 +128,7 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary) _size.onChange([this]() { _planeIsDirty = true; }); addProperty(_size); - _texturePath = absPath(p.texture).string(); + _texturePath = p.texture.string(); _textureFile = std::make_unique(_texturePath.value()); _offset = p.offset.value_or(_offset); @@ -239,7 +239,7 @@ void RenderableRings::loadTexture() { using namespace ghoul::io; using namespace ghoul::opengl; std::unique_ptr texture = TextureReader::ref().loadTexture( - absPath(_texturePath).string(), + absPath(_texturePath), 1 ); diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 76f8dede5e..cfa5a658ed 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -701,7 +701,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) _renderingMethodOption = codegen::map(p.renderMethod); - _pointSpreadFunctionTexturePath = absPath(p.texture.string()).string(); + _pointSpreadFunctionTexturePath = absPath(p.texture).string(); _pointSpreadFunctionFile = std::make_unique( _pointSpreadFunctionTexturePath.value() ); @@ -900,7 +900,7 @@ void RenderableStars::loadPSFTexture() { std::filesystem::exists(_pointSpreadFunctionTexturePath.value())) { _pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_pointSpreadFunctionTexturePath).string(), + absPath(_pointSpreadFunctionTexturePath), 2 ); @@ -1304,7 +1304,7 @@ void RenderableStars::update(const UpdateData&) { _colorTexture = nullptr; if (!_colorTexturePath.value().empty()) { _colorTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_colorTexturePath).string(), + absPath(_colorTexturePath), 1 ); if (_colorTexture) { @@ -1329,7 +1329,7 @@ void RenderableStars::update(const UpdateData&) { _otherDataColorMapTexture = nullptr; if (!_otherDataColorMapPath.value().empty()) { _otherDataColorMapTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(_otherDataColorMapPath).string(), + absPath(_otherDataColorMapPath), 1 ); if (_otherDataColorMapTexture) { diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 97a5371bea..028aeac567 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -118,9 +118,9 @@ RenderableModelProjection::RenderableModelProjection(const ghoul::Dictionary& di { const Parameters p = codegen::bake(dictionary); - const std::filesystem::path file = absPath(p.geometryFile.string()); + const std::filesystem::path file = absPath(p.geometryFile); _geometry = ghoul::io::ModelReader::ref().loadModel( - file.string(), + file, ghoul::io::ModelReader::ForceRenderInvisible::No, ghoul::io::ModelReader::NotifyInvisibleDropped::Yes ); diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp index 1bbadb7caa..6017a83789 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp @@ -77,7 +77,7 @@ RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& di _defaultTarget = p.defaultTarget.value_or(_defaultTarget); if (p.texture.has_value()) { - _texturePath = absPath(*p.texture).string(); + _texturePath = absPath(*p.texture); _textureFile = std::make_unique(_texturePath); } } @@ -185,7 +185,7 @@ void RenderablePlaneProjection::loadTexture() { } std::unique_ptr texture = - ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath).string(), 2); + ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath), 2); if (!texture) { return; } diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.h b/modules/spacecraftinstruments/rendering/renderableplaneprojection.h index fcb974c765..6a33874f7b 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.h +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace ghoul::filesystem { class File; } @@ -63,7 +64,7 @@ private: void updatePlane(const Image& img, double currentTime); void setTarget(std::string body); - std::string _texturePath; + std::filesystem::path _texturePath; bool _planeIsDirty = false; diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 4668b24a38..5cd40e7710 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -653,7 +653,7 @@ void RenderablePlanetProjection::loadColorTexture() { _baseTexture = nullptr; if (selectedPath != NoImageText) { _baseTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(selectedPath).string(), + absPath(selectedPath), 2 ); if (_baseTexture) { @@ -676,7 +676,7 @@ void RenderablePlanetProjection::loadHeightTexture() { _heightMapTexture = nullptr; if (selectedPath != NoImageText) { _heightMapTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath(selectedPath).string(), + absPath(selectedPath), 2 ); if (_heightMapTexture) { diff --git a/modules/spacecraftinstruments/util/hongkangparser.cpp b/modules/spacecraftinstruments/util/hongkangparser.cpp index 919d98881c..ee21d3269e 100644 --- a/modules/spacecraftinstruments/util/hongkangparser.cpp +++ b/modules/spacecraftinstruments/util/hongkangparser.cpp @@ -59,7 +59,7 @@ namespace { namespace openspace { -HongKangParser::HongKangParser(std::string name, std::string fileName, +HongKangParser::HongKangParser(std::string name, std::filesystem::path fileName, std::string spacecraft, const ghoul::Dictionary& translationDictionary, std::vector potentialTargets) @@ -140,12 +140,7 @@ bool HongKangParser::create() { "HongKangParser" ); } - const size_t position = _fileName.find_last_of('.') + 1; - if (position == 0 || position == std::string::npos) { - return true; - } - - if (std::filesystem::path(_fileName).extension() != ".txt") { + if (_fileName.extension() != ".txt") { return true; } @@ -192,7 +187,7 @@ bool HongKangParser::create() { // fill image Image image = { .timeRange = TimeRange(time, time + Exposure), - .path = _defaultCaptureImage.string(), + .path = _defaultCaptureImage, .activeInstruments = std::move(cameraSpiceID), .target = cameraTarget, .isPlaceholder = true, @@ -242,7 +237,7 @@ bool HongKangParser::create() { // store individual image Image image = { .timeRange = std::move(scanRange), - .path = _defaultCaptureImage.string(), + .path = _defaultCaptureImage, .activeInstruments = it->second->translations(), .target = cameraTarget, .isPlaceholder = true, diff --git a/modules/spacecraftinstruments/util/hongkangparser.h b/modules/spacecraftinstruments/util/hongkangparser.h index 16acd7920b..2bbe754efd 100644 --- a/modules/spacecraftinstruments/util/hongkangparser.h +++ b/modules/spacecraftinstruments/util/hongkangparser.h @@ -33,8 +33,8 @@ namespace openspace { class HongKangParser : public SequenceParser { public: - HongKangParser(std::string name, std::string fileName, std::string spacecraft, - const ghoul::Dictionary& translationDictionary, + HongKangParser(std::string name, std::filesystem::path fileName, + std::string spacecraft, const ghoul::Dictionary& translationDictionary, std::vector potentialTargets); bool create() override; @@ -45,7 +45,7 @@ private: double _metRef = 299180517; std::string _name; - std::string _fileName; + std::filesystem::path _fileName; std::string _spacecraft; std::vector _potentialTargets; }; diff --git a/modules/spacecraftinstruments/util/image.h b/modules/spacecraftinstruments/util/image.h index 98433ea121..92169c0458 100644 --- a/modules/spacecraftinstruments/util/image.h +++ b/modules/spacecraftinstruments/util/image.h @@ -34,7 +34,7 @@ namespace openspace { struct Image { TimeRange timeRange; - std::string path; + std::filesystem::path path; std::vector activeInstruments; std::string target; bool isPlaceholder = false; diff --git a/modules/spacecraftinstruments/util/imagesequencer.cpp b/modules/spacecraftinstruments/util/imagesequencer.cpp index 0d50e38327..5bb97c6e90 100644 --- a/modules/spacecraftinstruments/util/imagesequencer.cpp +++ b/modules/spacecraftinstruments/util/imagesequencer.cpp @@ -45,7 +45,7 @@ ImageSequencer& ImageSequencer::ref() { void ImageSequencer::initialize() { ghoul_assert(_instance == nullptr, "Instance already has been initialized"); _instance = new ImageSequencer; - _instance->_defaultCaptureImage = absPath("${DATA}/placeholder.png").string(); + _instance->_defaultCaptureImage = absPath("${DATA}/placeholder.png"); } void ImageSequencer::deinitialize() { diff --git a/modules/spacecraftinstruments/util/imagesequencer.h b/modules/spacecraftinstruments/util/imagesequencer.h index ea7dbb8ee5..d7b4799335 100644 --- a/modules/spacecraftinstruments/util/imagesequencer.h +++ b/modules/spacecraftinstruments/util/imagesequencer.h @@ -181,7 +181,7 @@ private: std::vector _captureProgression; // default capture image - std::string _defaultCaptureImage; + std::filesystem::path _defaultCaptureImage; std::map _latestImages; diff --git a/modules/spacecraftinstruments/util/instrumenttimesparser.cpp b/modules/spacecraftinstruments/util/instrumenttimesparser.cpp index c93606a75f..5dfcaacfc0 100644 --- a/modules/spacecraftinstruments/util/instrumenttimesparser.cpp +++ b/modules/spacecraftinstruments/util/instrumenttimesparser.cpp @@ -50,7 +50,8 @@ namespace { namespace openspace { -InstrumentTimesParser::InstrumentTimesParser(std::string name, std::string sequenceSource, +InstrumentTimesParser::InstrumentTimesParser(std::string name, + std::filesystem::path sequenceSource, ghoul::Dictionary& inputDict) : _pattern("\"(.{23})\" \"(.{23})\"") , _name(std::move(name)) diff --git a/modules/spacecraftinstruments/util/instrumenttimesparser.h b/modules/spacecraftinstruments/util/instrumenttimesparser.h index 31af6937f1..2667e01573 100644 --- a/modules/spacecraftinstruments/util/instrumenttimesparser.h +++ b/modules/spacecraftinstruments/util/instrumenttimesparser.h @@ -27,13 +27,14 @@ #include +#include #include namespace openspace { class InstrumentTimesParser : public SequenceParser { public: - InstrumentTimesParser(std::string name, std::string sequenceSource, + InstrumentTimesParser(std::string name, std::filesystem::path sequenceSource, ghoul::Dictionary& inputDict); bool create() override; @@ -44,7 +45,7 @@ private: std::map> _instrumentFiles; std::string _name; - std::string _fileName; + std::filesystem::path _fileName; std::string _spacecraft; std::vector _specsOfInterest; diff --git a/modules/spacecraftinstruments/util/labelparser.cpp b/modules/spacecraftinstruments/util/labelparser.cpp index a9a52c3bd2..1fd93bd8d5 100644 --- a/modules/spacecraftinstruments/util/labelparser.cpp +++ b/modules/spacecraftinstruments/util/labelparser.cpp @@ -43,7 +43,8 @@ namespace { namespace openspace { -LabelParser::LabelParser(std::string fileName, const ghoul::Dictionary& dictionary) +LabelParser::LabelParser(std::filesystem::path fileName, + const ghoul::Dictionary& dictionary) : _fileName(std::move(fileName)) { using ghoul::Dictionary; @@ -151,19 +152,13 @@ bool LabelParser::create() { continue; } - std::string path = e.path().string(); - - const size_t position = path.find_last_of('.') + 1; - if (position == 0 || position == std::string::npos) { - continue; - } - - const std::filesystem::path extension = std::filesystem::path(path).extension(); + const std::filesystem::path path = e.path(); + const std::filesystem::path extension = path.extension(); if (extension != ".lbl" && extension != ".LBL") { continue; } - std::ifstream file(path); + std::ifstream file = std::ifstream(path); if (!file.good()) { LERROR(std::format("Failed to open label file '{}'", path)); @@ -264,10 +259,9 @@ bool LabelParser::create() { count = 0; - using namespace std::literals; - const std::string p = path.substr(0, path.size() - ("lbl"s).size()); for (const std::string& ext : extensions) { - const std::string imagePath = p + ext; + std::filesystem::path imagePath = path; + imagePath.replace_extension(ext); if (std::filesystem::is_regular_file(imagePath)) { std::vector spiceInstrument; spiceInstrument.push_back(_instrumentID); diff --git a/modules/spacecraftinstruments/util/labelparser.h b/modules/spacecraftinstruments/util/labelparser.h index 50982b602f..f17d8fc1a4 100644 --- a/modules/spacecraftinstruments/util/labelparser.h +++ b/modules/spacecraftinstruments/util/labelparser.h @@ -27,11 +27,14 @@ #include +#include + namespace openspace { class LabelParser : public SequenceParser { public: - LabelParser(std::string fileName, const ghoul::Dictionary& translationDictionary); + LabelParser(std::filesystem::path fileName, + const ghoul::Dictionary& translationDictionary); bool create() override; @@ -39,7 +42,7 @@ private: std::string encode(const std::string& line) const; std::string decode(const std::string& line); - std::string _fileName; + std::filesystem::path _fileName; std::vector _specsOfInterest; std::string _target; diff --git a/modules/spacecraftinstruments/util/projectioncomponent.cpp b/modules/spacecraftinstruments/util/projectioncomponent.cpp index 8a735f1889..8f76694284 100644 --- a/modules/spacecraftinstruments/util/projectioncomponent.cpp +++ b/modules/spacecraftinstruments/util/projectioncomponent.cpp @@ -96,7 +96,9 @@ namespace { // This value specifies one or more directories from which images are being used // for image projections. If the sequence type is set to 'playbook', this value is // ignored - std::optional>> sequence; + std::optional< + std::variant> + > sequence [[codegen::directory()]]; struct Instrument { // The instrument that is used to perform the projections @@ -123,7 +125,7 @@ namespace { // uses both methods std::optional sequenceType; - std::optional eventFile; + std::optional eventFile; // The observer that is doing the projection. This has to be a valid SPICE name // or SPICE integer @@ -208,30 +210,28 @@ void ProjectionComponent::initialize(const std::string& identifier, _shadowing.isEnabled = p.shadowMap.value_or(_shadowing.isEnabled); _projectionTextureAspectRatio = p.aspectRatio.value_or(_projectionTextureAspectRatio); - if (!p.sequence.has_value()) { // we are done here, the rest only applies if we do have a sequence return; } - std::variant> sequence = *p.sequence; + //std::variant> s = *p.sequence; - std::vector sequenceSources; - if (std::holds_alternative(sequence)) { - sequenceSources.push_back(absPath(std::get(sequence)).string()); + std::vector sequenceSources; + if (std::holds_alternative(*p.sequence)) { + sequenceSources.push_back(absPath(std::get(*p.sequence))); } else { ghoul_assert( - std::holds_alternative>(sequence), + std::holds_alternative>(*p.sequence), "Something is wrong with the generated documentation" ); - sequenceSources = std::get>(sequence); - for (std::string& s : sequenceSources) { - s = absPath(s).string(); + sequenceSources = std::get>(*p.sequence); + for (std::filesystem::path& s : sequenceSources) { + s = absPath(s); } } - if (!p.sequenceType.has_value()) { throw ghoul::RuntimeError("Missing SequenceType"); } @@ -246,7 +246,7 @@ void ProjectionComponent::initialize(const std::string& identifier, } std::vector> parsers; - for (std::string& source : sequenceSources) { + for (std::filesystem::path& source : sequenceSources) { switch (*p.sequenceType) { case Parameters::Type::Playbook: parsers.push_back( @@ -274,7 +274,7 @@ void ProjectionComponent::initialize(const std::string& identifier, parsers.push_back( std::make_unique( identifier, - absPath(*p.eventFile).string(), + *p.eventFile, _projectorID, translations, _potentialTargets @@ -312,7 +312,7 @@ void ProjectionComponent::initialize(const std::string& identifier, parsers.push_back( std::make_unique( identifier, - absPath(*p.timesSequence).string(), + *p.timesSequence, timesTranslationDictionary ) ); @@ -360,7 +360,7 @@ bool ProjectionComponent::initializeGL() { using ghoul::opengl::Texture; std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture( - absPath(placeholderFile).string(), + absPath(placeholderFile), 2 ); if (texture) { @@ -877,7 +877,7 @@ void ProjectionComponent::generateMipMap() { } std::shared_ptr ProjectionComponent::loadProjectionTexture( - const std::string& texturePath, + const std::filesystem::path& texturePath, bool isPlaceholder) { using ghoul::opengl::Texture; @@ -887,7 +887,7 @@ std::shared_ptr ProjectionComponent::loadProjectionTextu } std::unique_ptr texture = ghoul::io::TextureReader::ref().loadTexture( - absPath(texturePath).string(), + absPath(texturePath), 2 ); if (texture) { diff --git a/modules/spacecraftinstruments/util/projectioncomponent.h b/modules/spacecraftinstruments/util/projectioncomponent.h index c8ca7855ff..0681d9330f 100644 --- a/modules/spacecraftinstruments/util/projectioncomponent.h +++ b/modules/spacecraftinstruments/util/projectioncomponent.h @@ -66,7 +66,7 @@ public: bool depthRendertarget(); std::shared_ptr loadProjectionTexture( - const std::string& texturePath, bool isPlaceholder = false); + const std::filesystem::path& texturePath, bool isPlaceholder = false); glm::mat4 computeProjectorMatrix(const glm::vec3& loc, const glm::dvec3& aim, const glm::vec3& up, const glm::dmat3& instrumentMatrix, float fieldOfViewY, diff --git a/modules/statemachine/include/statemachine.h b/modules/statemachine/include/statemachine.h index 62761dbe7b..18d7f725f1 100644 --- a/modules/statemachine/include/statemachine.h +++ b/modules/statemachine/include/statemachine.h @@ -54,7 +54,7 @@ public: * \param filename This is the full name of the file, including the directory, * but without the extension */ - void saveToDotFile(const std::string& filename) const; + void saveToDotFile(const std::filesystem::path& filename) const; static documentation::Documentation Documentation(); diff --git a/modules/statemachine/src/statemachine.cpp b/modules/statemachine/src/statemachine.cpp index ca1a743b79..9c1dbe4f64 100644 --- a/modules/statemachine/src/statemachine.cpp +++ b/modules/statemachine/src/statemachine.cpp @@ -197,10 +197,13 @@ std::vector StateMachine::possibleTransitions() const { return res; } -void StateMachine::saveToDotFile(const std::string& filename) const { - const std::string outputFile = filename + ".dot"; +void StateMachine::saveToDotFile(const std::filesystem::path& filename) const { + std::filesystem::path outputFile = filename; + if (!outputFile.has_extension()) { + outputFile.replace_extension(".dot"); + } - std::ofstream file(outputFile); + std::ofstream file = std::ofstream(outputFile); if (!file.good()) { LERROR(std::format( "Error opening file '{}' for saving state machine dot file", outputFile diff --git a/modules/statemachine/statemachinemodule.cpp b/modules/statemachine/statemachinemodule.cpp index 0654a8ecd4..356c3775c6 100644 --- a/modules/statemachine/statemachinemodule.cpp +++ b/modules/statemachine/statemachinemodule.cpp @@ -140,7 +140,7 @@ void StateMachineModule::saveToFile(const std::string& filename, directory += '/'; } - const std::string outputFile = absPath(directory + filename).string(); + const std::filesystem::path outputFile = absPath(directory + filename); _machine->saveToDotFile(outputFile); } diff --git a/modules/sync/syncs/httpsynchronization.cpp b/modules/sync/syncs/httpsynchronization.cpp index 08d66a95f4..f179178bc6 100644 --- a/modules/sync/syncs/httpsynchronization.cpp +++ b/modules/sync/syncs/httpsynchronization.cpp @@ -401,7 +401,7 @@ HttpSynchronization::trySyncFromUrl(std::string url) { const std::string dest = _unzipFilesDestination.has_value() ? (originalName.parent_path() / *_unzipFilesDestination).string() : - originalName.replace_extension().string();; + originalName.replace_extension().string(); struct zip_t* z = zip_open(source.c_str(), 0, 'r'); const bool is64 = zip_is64(z); diff --git a/modules/toyvolume/rendering/toyvolumeraycaster.cpp b/modules/toyvolume/rendering/toyvolumeraycaster.cpp index be3acef255..16b4c79804 100644 --- a/modules/toyvolume/rendering/toyvolumeraycaster.cpp +++ b/modules/toyvolume/rendering/toyvolumeraycaster.cpp @@ -125,19 +125,19 @@ bool ToyVolumeRaycaster::isCameraInside(const RenderData& data, glm::vec3& local localPosition.z > 0.f && localPosition.z < 1.f); } -std::string ToyVolumeRaycaster::boundsVertexShaderPath() const { - return absPath(GlslBoundsVsPath).string(); +std::filesystem::path ToyVolumeRaycaster::boundsVertexShaderPath() const { + return absPath(GlslBoundsVsPath); } -std::string ToyVolumeRaycaster::boundsFragmentShaderPath() const { - return absPath(GlslBoundsFsPath).string(); +std::filesystem::path ToyVolumeRaycaster::boundsFragmentShaderPath() const { + return absPath(GlslBoundsFsPath); } -std::string ToyVolumeRaycaster::raycasterPath() const { - return absPath(GlslRaycastPath).string(); +std::filesystem::path ToyVolumeRaycaster::raycasterPath() const { + return absPath(GlslRaycastPath); } -std::string ToyVolumeRaycaster::helperPath() const { +std::filesystem::path ToyVolumeRaycaster::helperPath() const { return ""; // no helper file } diff --git a/modules/toyvolume/rendering/toyvolumeraycaster.h b/modules/toyvolume/rendering/toyvolumeraycaster.h index 25e371707f..f980300e05 100644 --- a/modules/toyvolume/rendering/toyvolumeraycaster.h +++ b/modules/toyvolume/rendering/toyvolumeraycaster.h @@ -58,10 +58,10 @@ public: ghoul::opengl::ProgramObject& program) override; bool isCameraInside(const RenderData& data, glm::vec3& localPosition) override; - std::string boundsVertexShaderPath() const override; - std::string boundsFragmentShaderPath() const override; - std::string raycasterPath() const override; - std::string helperPath() const override; + std::filesystem::path boundsVertexShaderPath() const override; + std::filesystem::path boundsFragmentShaderPath() const override; + std::filesystem::path raycasterPath() const override; + std::filesystem::path helperPath() const override; void setColor(glm::vec4 color); void setModelTransform(glm::mat4 transform); diff --git a/modules/volume/rendering/basicvolumeraycaster.cpp b/modules/volume/rendering/basicvolumeraycaster.cpp index 75f350b7c8..f8d7e5ced3 100644 --- a/modules/volume/rendering/basicvolumeraycaster.cpp +++ b/modules/volume/rendering/basicvolumeraycaster.cpp @@ -161,20 +161,20 @@ bool BasicVolumeRaycaster::isCameraInside(const RenderData& data, localPosition.z > 0 && localPosition.z < 1); } -std::string BasicVolumeRaycaster::boundsVertexShaderPath() const { - return absPath(GlslBoundsVs).string(); +std::filesystem::path BasicVolumeRaycaster::boundsVertexShaderPath() const { + return absPath(GlslBoundsVs); } -std::string BasicVolumeRaycaster::boundsFragmentShaderPath() const { - return absPath(GlslBoundsFs).string(); +std::filesystem::path BasicVolumeRaycaster::boundsFragmentShaderPath() const { + return absPath(GlslBoundsFs); } -std::string BasicVolumeRaycaster::raycasterPath() const { - return absPath(GlslRaycast).string(); +std::filesystem::path BasicVolumeRaycaster::raycasterPath() const { + return absPath(GlslRaycast); } -std::string BasicVolumeRaycaster::helperPath() const { - return absPath(GlslHelper).string(); +std::filesystem::path BasicVolumeRaycaster::helperPath() const { + return absPath(GlslHelper); } void BasicVolumeRaycaster::setTransferFunction( diff --git a/modules/volume/rendering/basicvolumeraycaster.h b/modules/volume/rendering/basicvolumeraycaster.h index 43c3d24208..7fc60f5379 100644 --- a/modules/volume/rendering/basicvolumeraycaster.h +++ b/modules/volume/rendering/basicvolumeraycaster.h @@ -68,10 +68,10 @@ public: ghoul::opengl::ProgramObject& program) override; bool isCameraInside(const RenderData& data, glm::vec3& localPosition) override; - std::string boundsVertexShaderPath() const override; - std::string boundsFragmentShaderPath() const override; - std::string raycasterPath() const override; - std::string helperPath() const override; + std::filesystem::path boundsVertexShaderPath() const override; + std::filesystem::path boundsFragmentShaderPath() const override; + std::filesystem::path raycasterPath() const override; + std::filesystem::path helperPath() const override; void setVolumeTexture(std::shared_ptr texture); diff --git a/modules/volume/rendering/renderabletimevaryingvolume.cpp b/modules/volume/rendering/renderabletimevaryingvolume.cpp index f936f027aa..22ca620a4b 100644 --- a/modules/volume/rendering/renderabletimevaryingvolume.cpp +++ b/modules/volume/rendering/renderabletimevaryingvolume.cpp @@ -194,7 +194,7 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume( _sourceDirectory = absPath(p.sourceDirectory).string(); _transferFunctionPath = absPath(p.transferFunction).string(); _transferFunction = std::make_shared( - _transferFunctionPath, + _transferFunctionPath.value(), [](const openspace::TransferFunction&) {} ); @@ -239,7 +239,7 @@ void RenderableTimeVaryingVolume::initializeGL() { 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()); + loadTimestepMetadata(e.path()); } } @@ -328,13 +328,14 @@ void RenderableTimeVaryingVolume::initializeGL() { _transferFunctionPath.onChange([this] { _transferFunction = std::make_shared( - _transferFunctionPath + _transferFunctionPath.value() ); _raycaster->setTransferFunction(_transferFunction); }); } -void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::string& path) { +void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::filesystem::path& path) +{ RawVolumeMetadata metadata; try { @@ -351,7 +352,7 @@ void RenderableTimeVaryingVolume::loadTimestepMetadata(const std::string& path) Timestep t; t.metadata = metadata; - t.baseName = std::filesystem::path(path).stem().string(); + t.baseName = path.stem(); t.inRam = false; t.onGpu = false; diff --git a/modules/volume/rendering/renderabletimevaryingvolume.h b/modules/volume/rendering/renderabletimevaryingvolume.h index a5d1f1a9cd..ecdd2be8f9 100644 --- a/modules/volume/rendering/renderabletimevaryingvolume.h +++ b/modules/volume/rendering/renderabletimevaryingvolume.h @@ -61,7 +61,7 @@ public: private: struct Timestep { - std::string baseName; + std::filesystem::path baseName; bool inRam; bool onGpu; RawVolumeMetadata metadata; @@ -75,7 +75,7 @@ private: Timestep* timestepFromIndex(int target); void jumpToTimestep(int target); - void loadTimestepMetadata(const std::string& path); + void loadTimestepMetadata(const std::filesystem::path& path); properties::OptionProperty _gridType; std::shared_ptr _clipPlanes; diff --git a/modules/volume/tasks/generaterawvolumetask.cpp b/modules/volume/tasks/generaterawvolumetask.cpp index 4a8279d622..23685f6c07 100644 --- a/modules/volume/tasks/generaterawvolumetask.cpp +++ b/modules/volume/tasks/generaterawvolumetask.cpp @@ -104,7 +104,7 @@ void GenerateRawVolumeTask::perform(const Task::ProgressCallback& progressCallba // Spice kernel is required for time conversions. // Todo: Make this dependency less hard coded. SpiceManager::KernelHandle kernel = SpiceManager::ref().loadKernel( - absPath("${DATA}/assets/spice/naif0012.tls").string() + absPath("${DATA}/assets/spice/naif0012.tls") ); defer { @@ -169,7 +169,7 @@ void GenerateRawVolumeTask::perform(const Task::ProgressCallback& progressCallba std::filesystem::create_directories(directory); } - volume::RawVolumeWriter writer(_rawVolumeOutputPath.string()); + volume::RawVolumeWriter writer(_rawVolumeOutputPath); writer.write(rawVolume); progressCallback(0.9f); diff --git a/modules/volume/transferfunctionhandler.cpp b/modules/volume/transferfunctionhandler.cpp index b840c5516d..d8dec3f83d 100644 --- a/modules/volume/transferfunctionhandler.cpp +++ b/modules/volume/transferfunctionhandler.cpp @@ -78,7 +78,7 @@ TransferFunctionHandler::TransferFunctionHandler(properties::StringProperty prop , _transferFunctionProperty(TransferFunctionInfo) { _transferFunction = std::make_shared( - _transferFunctionPath + _transferFunctionPath.value() ); } diff --git a/modules/webgui/webguimodule.cpp b/modules/webgui/webguimodule.cpp index acc3add544..1cf99bd700 100644 --- a/modules/webgui/webguimodule.cpp +++ b/modules/webgui/webguimodule.cpp @@ -279,19 +279,19 @@ void WebGuiModule::startProcess() { const std::string command = std::format( "\"{}\" \"{}\" --directories \"{}\" {} --http-port \"{}\" --ws-address \"{}\" " "--ws-port {} --auto-close --local", - node.string(), absPath(_entryPoint.value()).string(), formattedDirectories, + node.string(), absPath(_entryPoint.value()), formattedDirectories, defaultEndpoint, _port.value(), _address.value(), webSocketPort ); _process = std::make_unique( command, - absPath("${BIN}").string(), + absPath("${BIN}"), [](const char* data, size_t n) { - const std::string str(data, n); + const std::string str = std::string(data, n); LDEBUG(std::format("Web GUI server output: {}", str)); }, [](const char* data, size_t n) { - const std::string str(data, n); + const std::string str = std::string(data, n); LERROR(std::format("Web GUI server error: {}", str)); } ); diff --git a/src/data/csvloader.cpp b/src/data/csvloader.cpp index e59e205676..f29cdf061a 100644 --- a/src/data/csvloader.cpp +++ b/src/data/csvloader.cpp @@ -74,11 +74,7 @@ Dataset loadCsvFile(std::filesystem::path filePath, std::optional s LDEBUG("Parsing CSV file"); - std::vector> rows = ghoul::loadCSVFile( - filePath.string(), - true - ); - + std::vector> rows = ghoul::loadCSVFile(filePath, true); if (rows.size() < 2) { LWARNING(std::format( "Error loading data file '{}'. No data items read", filePath diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp index 0323e6be76..3597e53e00 100644 --- a/src/documentation/documentationengine.cpp +++ b/src/documentation/documentationengine.cpp @@ -608,12 +608,10 @@ void DocumentationEngine::writeDocumentation() const { ZoneScoped; // Write documentation to json files if config file supplies path for doc files - std::string path = global::configuration->documentation.path; - if (path.empty()) { + if (global::configuration->documentation.path.empty()) { // if path was empty, that means that no documentation is requested return; } - path = absPath(path).string() + '/'; // Start the async requests as soon as possible so they are finished when we need them std::future settings = std::async( diff --git a/src/documentation/verifier.cpp b/src/documentation/verifier.cpp index f221454833..ac8911163b 100644 --- a/src/documentation/verifier.cpp +++ b/src/documentation/verifier.cpp @@ -612,8 +612,10 @@ TestResult TemplateVerifier::operator()(const ghoul::Dictionary& dic } } -TableVerifier::TableVerifier(std::vector documentationEntries) +TableVerifier::TableVerifier(std::vector documentationEntries, + std::optional nEntries) : documentations(std::move(documentationEntries)) + , count(nEntries) {} TestResult TableVerifier::operator()(const ghoul::Dictionary& dictionary, @@ -625,8 +627,8 @@ TestResult TableVerifier::operator()(const ghoul::Dictionary& dictionary, TestResult res = testSpecification(doc, d); // Add the 'key' as a prefix to make the new offender a fully qualified identifer - for (TestResult::Offense& s : res.offenses) { - s.offender = std::format("{}.{}", key, s.offender); + for (TestResult::Offense& o : res.offenses) { + o.offender = std::format("{}.{}", key, o.offender); } // Add the 'key' as a prefix to make the new warning a fully qualified identifer @@ -634,6 +636,17 @@ TestResult TableVerifier::operator()(const ghoul::Dictionary& dictionary, w.offender = std::format("{}.{}", key, w.offender); } + if (count.has_value()) { + if (d.size() != *count) { + res.success = false; + res.offenses.emplace_back( + "Count", + TestResult::Offense::Reason::Verification, + std::format("Expected {} entries, but only got {}", *count, d.size()) + ); + } + } + return res; } else { diff --git a/src/engine/configuration.cpp b/src/engine/configuration.cpp index 7f6f1dd0a9..4bde284f72 100644 --- a/src/engine/configuration.cpp +++ b/src/engine/configuration.cpp @@ -715,11 +715,11 @@ Configuration loadConfigurationFromFile(const std::filesystem::path& configurati // If there is an initial config helper file, load it into the state if (std::filesystem::is_regular_file(absPath(InitialConfigHelper))) { - ghoul::lua::runScriptFile(result.state, absPath(InitialConfigHelper).string()); + ghoul::lua::runScriptFile(result.state, absPath(InitialConfigHelper)); } // Load the configuration file into the state - ghoul::lua::runScriptFile(result.state, configurationFile.string()); + ghoul::lua::runScriptFile(result.state, configurationFile); parseLuaState(result); diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index d611e5d1a9..34e5691e39 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -112,7 +112,7 @@ namespace { namespace openspace { -DownloadManager::FileFuture::FileFuture(std::string file) +DownloadManager::FileFuture::FileFuture(std::filesystem::path file) : filePath(std::move(file)) {} @@ -135,18 +135,20 @@ std::shared_ptr DownloadManager::downloadFile( return nullptr; } - auto future = std::make_shared(file.filename().string()); + auto future = std::make_shared(file.filename()); errno = 0; #ifdef WIN32 FILE* fp; - errno_t error = fopen_s(&fp, file.string().c_str(), "wb"); + const std::string f = file.string(); + errno_t error = fopen_s(&fp, f.c_str(), "wb"); if (error != 0) { LERROR(std::format( "Could not open/create file: {}. Errno: {}", file, errno )); } #else - FILE* fp = fopen(file.string().c_str(), "wb"); // write binary + const std::string f = file.string(); + FILE* fp = fopen(f.c_str(), "wb"); // write binary #endif // WIN32 if (!fp) { LERROR(std::format( diff --git a/src/engine/logfactory.cpp b/src/engine/logfactory.cpp index c0f0020bbb..69ff60a67e 100644 --- a/src/engine/logfactory.cpp +++ b/src/engine/logfactory.cpp @@ -112,14 +112,14 @@ std::unique_ptr createLog(const ghoul::Dictionary& dictiona switch (p.type) { case Parameters::Type::Html: { - const std::vector cssFiles = { - absPath(BootstrapPath).string(), - absPath(CssPath).string() + const std::vector cssFiles = { + absPath(BootstrapPath), + absPath(CssPath) }; - const std::vector jsFiles = { absPath(JsPath).string() }; + const std::vector jsFiles = { absPath(JsPath) }; return std::make_unique( - filename.string(), + filename, nLogRotation, ghoul::logging::Log::TimeStamping(timeStamp), ghoul::logging::Log::DateStamping(dateStamp), @@ -132,7 +132,7 @@ std::unique_ptr createLog(const ghoul::Dictionary& dictiona } case Parameters::Type::Text: return std::make_unique( - filename.string(), + filename, nLogRotation, ghoul::logging::TextLog::Append(append), ghoul::logging::Log::TimeStamping(timeStamp), diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 54d74d0f65..cf91a8cf1c 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -267,9 +267,9 @@ void OpenSpaceEngine::initialize() { _printEvents = global::configuration->isPrintingEvents; _visibility = static_cast(global::configuration->propertyVisibility); - std::string cacheFolder = absPath("${CACHE}").string(); + std::filesystem::path cacheFolder = absPath("${CACHE}"); if (global::configuration->usePerProfileCache) { - cacheFolder = cacheFolder + "-" + global::configuration->profile; + cacheFolder = std::format("{}-{}", cacheFolder, global::configuration->profile); LINFO(std::format("Old cache: {}", absPath("${CACHE}"))); LINFO(std::format("New cache: {}", cacheFolder)); @@ -346,8 +346,8 @@ void OpenSpaceEngine::initialize() { // Move all of the existing logs one position up const std::filesystem::path file = absPath(global::configuration->scriptLog); - const std::string fname = file.stem().string(); - const std::string ext = file.extension().string(); + const std::filesystem::path fname = file.stem(); + const std::filesystem::path ext = file.extension(); std::filesystem::path newCandidate = file; newCandidate.replace_filename(std::format("{}-{}{}", fname, rot, ext)); @@ -911,7 +911,7 @@ void OpenSpaceEngine::runGlobalCustomizationScripts() { if (std::filesystem::is_regular_file(s)) { try { LINFO(std::format("Running global customization script: {}", s)); - ghoul::lua::runScriptFile(state, s.string()); + ghoul::lua::runScriptFile(state, s); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.message); @@ -1374,7 +1374,8 @@ void OpenSpaceEngine::touchExitCallback(TouchInput input) { void OpenSpaceEngine::handleDragDrop(std::filesystem::path file) { const ghoul::lua::LuaState s(ghoul::lua::LuaState::IncludeStandardLibrary::Yes); const std::filesystem::path path = absPath("${SCRIPTS}/drag_drop_handler.lua"); - int status = luaL_loadfile(s, path.string().c_str()); + const std::string p = path.string(); + int status = luaL_loadfile(s, p.c_str()); if (status != LUA_OK) { const std::string error = lua_tostring(s, -1); LERROR(error); @@ -1384,7 +1385,7 @@ void OpenSpaceEngine::handleDragDrop(std::filesystem::path file) { ghoul::lua::push(s, file); lua_setglobal(s, "filename"); - std::string basename = file.filename().string(); + std::filesystem::path basename = file.filename(); ghoul::lua::push(s, std::move(basename)); lua_setglobal(s, "basename"); diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index c615a72fa1..031eaa5193 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -223,9 +223,8 @@ namespace { throw ghoul::lua::LuaError(std::format("Could not find file '{}'", file)); } - std::vector> res = - ghoul::loadCSVFile(file.string(), includeFirstLine); - return res; + std::vector> r = ghoul::loadCSVFile(file, includeFirstLine); + return r; } /** diff --git a/src/navigation/navigationhandler.cpp b/src/navigation/navigationhandler.cpp index 4e45a6041f..c3e56d725e 100644 --- a/src/navigation/navigationhandler.cpp +++ b/src/navigation/navigationhandler.cpp @@ -629,7 +629,7 @@ void NavigationHandler::loadNavigationState(const std::string& filepath, } if (!std::filesystem::is_regular_file(absolutePath)) { - throw ghoul::FileNotFoundError(absolutePath.string(), "NavigationState"); + throw ghoul::FileNotFoundError(absolutePath, "NavigationState"); } std::ifstream f = std::ifstream(absolutePath); diff --git a/src/rendering/colormappingcomponent.cpp b/src/rendering/colormappingcomponent.cpp index 4dbf91e9ee..79d5398158 100644 --- a/src/rendering/colormappingcomponent.cpp +++ b/src/rendering/colormappingcomponent.cpp @@ -155,7 +155,7 @@ namespace { std::optional enabled; // [[codegen::verbatim(FileInfo.description)]] - std::optional file; + std::optional file; struct ColorMapParameter { // The key for the data variable to use for color @@ -319,7 +319,7 @@ ColorMappingComponent::ColorMappingComponent(const ghoul::Dictionary& dictionary } if (p.file.has_value()) { - colorMapFile = absPath(*p.file).string(); + colorMapFile = p.file->string(); } invert = p.invert.value_or(invert); diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index d63722b271..be3f1d9db3 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -950,18 +950,18 @@ void FramebufferRenderer::updateRaycastData() { RaycastData data = { .id = nextId++, .namespaceName = "Helper" }; - const std::string& vsPath = raycaster->boundsVertexShaderPath(); - std::string fsPath = raycaster->boundsFragmentShaderPath(); + const std::filesystem::path& vsPath = raycaster->boundsVertexShaderPath(); + std::filesystem::path fsPath = raycaster->boundsFragmentShaderPath(); ghoul::Dictionary dict; dict.setValue("rendererData", _rendererData); - dict.setValue("fragmentPath", std::move(fsPath)); + dict.setValue("fragmentPath", fsPath); dict.setValue("id", data.id); - std::string helperPath = raycaster->helperPath(); + std::filesystem::path helperPath = raycaster->helperPath(); ghoul::Dictionary helpersDict; if (!helperPath.empty()) { - helpersDict.setValue("0", std::move(helperPath)); + helpersDict.setValue("0", helperPath); } dict.setValue("helperPaths", std::move(helpersDict)); dict.setValue("raycastPath", raycaster->raycasterPath()); @@ -1029,7 +1029,7 @@ void FramebufferRenderer::updateDeferredcastData() { const std::filesystem::path helperPath = caster->helperPath(); ghoul::Dictionary helpersDict; if (!helperPath.empty()) { - helpersDict.setValue("0", helperPath.string()); + helpersDict.setValue("0", helperPath); } dict.setValue("helperPaths", helpersDict); diff --git a/src/rendering/loadingscreen.cpp b/src/rendering/loadingscreen.cpp index 17b2145937..7e4b043769 100644 --- a/src/rendering/loadingscreen.cpp +++ b/src/rendering/loadingscreen.cpp @@ -151,7 +151,7 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName { // Logo stuff _logoTexture = ghoul::io::TextureReader::ref().loadTexture( - absPath("${DATA}/openspace-logo.png").string(), + absPath("${DATA}/openspace-logo.png"), 2 ); _logoTexture->uploadTexture(); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 4f21e42357..fe71de25d7 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -975,7 +975,7 @@ std::unique_ptr RenderEngine::buildRenderProgram( // parameterize the main fragment shader program with specific contents. // fsPath should point to a shader file defining a Fragment getFragment() function // instead of a void main() setting glFragColor, glFragDepth, etc. - dict.setValue("fragmentPath", fsPath.string()); + dict.setValue("fragmentPath", fsPath); using namespace ghoul::opengl; std::unique_ptr program = ProgramObject::Build( @@ -1007,7 +1007,7 @@ std::unique_ptr RenderEngine::buildRenderProgram( // parameterize the main fragment shader program with specific contents. // fsPath should point to a shader file defining a Fragment getFragment() function // instead of a void main() setting glFragColor, glFragDepth, etc. - dict.setValue("fragmentPath", fsPath.string()); + dict.setValue("fragmentPath", fsPath); using namespace ghoul::opengl; std::unique_ptr program = ProgramObject::Build( diff --git a/src/rendering/texturecomponent.cpp b/src/rendering/texturecomponent.cpp index dcda824d91..bcd825bfe2 100644 --- a/src/rendering/texturecomponent.cpp +++ b/src/rendering/texturecomponent.cpp @@ -87,29 +87,31 @@ void TextureComponent::uploadToGpu() { } void TextureComponent::loadFromFile(const std::filesystem::path& path) { - if (!path.empty()) { - using namespace ghoul::io; - using namespace ghoul::opengl; + if (path.empty()) { + return; + } - std::filesystem::path absolutePath = absPath(path); + using namespace ghoul::io; + using namespace ghoul::opengl; - std::unique_ptr texture = TextureReader::ref().loadTexture( - absolutePath.string(), - _nDimensions - ); + std::filesystem::path absolutePath = absPath(path); - if (texture) { - LDEBUG(std::format("Loaded texture from '{}'", absolutePath)); - _texture = std::move(texture); + std::unique_ptr texture = TextureReader::ref().loadTexture( + absolutePath, + _nDimensions + ); - _textureFile = std::make_unique(absolutePath); - if (_shouldWatchFile) { - _textureFile->setCallback([this]() { _fileIsDirty = true; }); - } + if (texture) { + LDEBUG(std::format("Loaded texture from '{}'", absolutePath)); + _texture = std::move(texture); - _fileIsDirty = false; - _textureIsDirty = true; + _textureFile = std::make_unique(absolutePath); + if (_shouldWatchFile) { + _textureFile->setCallback([this]() { _fileIsDirty = true; }); } + + _fileIsDirty = false; + _textureIsDirty = true; } } diff --git a/src/rendering/transferfunction.cpp b/src/rendering/transferfunction.cpp index 9773746445..232437a9c5 100644 --- a/src/rendering/transferfunction.cpp +++ b/src/rendering/transferfunction.cpp @@ -42,7 +42,7 @@ namespace { namespace openspace { -TransferFunction::TransferFunction(const std::string& filepath, +TransferFunction::TransferFunction(const std::filesystem::path& filepath, TfChangedCallback tfChangedCallback) : _filepath(filepath) { @@ -52,7 +52,7 @@ TransferFunction::TransferFunction(const std::string& filepath, TransferFunction::~TransferFunction() {} -void TransferFunction::setPath(const std::string& filepath) { +void TransferFunction::setPath(const std::filesystem::path& filepath) { if (_file) { _file = nullptr; } @@ -95,11 +95,10 @@ void TransferFunction::setCallback(TfChangedCallback callback) { } void TransferFunction::setTextureFromTxt() { - std::ifstream in; - in.open(_filepath); + std::ifstream in = std::ifstream(_filepath); if (!in.is_open()) { - throw ghoul::FileNotFoundError(_filepath.string()); + throw ghoul::FileNotFoundError(_filepath); } int width = 512; @@ -209,7 +208,7 @@ void TransferFunction::setTextureFromTxt() { } void TransferFunction::setTextureFromImage() { - _texture = ghoul::io::TextureReader::ref().loadTexture(_filepath.string(), 1); + _texture = ghoul::io::TextureReader::ref().loadTexture(_filepath, 1); _texture->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToEdge); } diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index 21a5772115..0ce4a6109a 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -992,20 +992,20 @@ std::filesystem::path AssetManager::generateAssetPath( // 2) Relative to the global asset root (*) const PathType pathType = classifyPath(assetPath); - std::string prefix; + std::filesystem::path prefix; if (pathType == PathType::RelativeToAsset) { - prefix = baseDirectory.string() + '/'; + prefix = baseDirectory / ""; } else if (pathType == PathType::RelativeToAssetRoot) { - prefix = _assetRootDirectory.string() + '/'; + prefix = _assetRootDirectory / ""; } // We treat the Absolute and the Tokenized paths the same here since they will // behave the same when passed into the `absPath` function // Construct the full path including the .asset extension - std::string fullAssetPath = prefix + assetPath; - if (std::filesystem::path(assetPath).extension() != ".asset") { - fullAssetPath += ".asset"; + std::filesystem::path fullAssetPath = std::format("{}{}", prefix, assetPath); + if (fullAssetPath.extension() != ".asset") { + fullAssetPath.replace_extension(".asset"); } // We don't check whether the file exists here as the error will be more diff --git a/src/scene/assetmanager_lua.inl b/src/scene/assetmanager_lua.inl index 5c3a7f0a84..623409b5f6 100644 --- a/src/scene/assetmanager_lua.inl +++ b/src/scene/assetmanager_lua.inl @@ -73,13 +73,13 @@ namespace { * Returns the paths to all loaded assets, loaded directly or indirectly, as a table * containing the paths to all loaded assets. */ -[[codegen::luawrap]] std::vector allAssets() { +[[codegen::luawrap]] std::vector allAssets() { using namespace openspace; std::vector as = global::openSpaceEngine->assetManager().allAssets(); - std::vector res; + std::vector res; res.reserve(as.size()); for (const Asset* a : as) { - res.push_back(a->path().string()); + res.push_back(a->path()); } return res; } @@ -88,13 +88,13 @@ namespace { * Returns the paths to all loaded root assets, which are assets that are loaded directly * either through a profile or by calling the `openspace.asset.add` method. */ -[[codegen::luawrap]] std::vector rootAssets() { +[[codegen::luawrap]] std::vector rootAssets() { using namespace openspace; std::vector as = global::openSpaceEngine->assetManager().rootAssets(); - std::vector res; + std::vector res; res.reserve(as.size()); for (const Asset* a : as) { - res.push_back(a->path().string()); + res.push_back(a->path()); } return res; } diff --git a/src/scene/profile_lua.inl b/src/scene/profile_lua.inl index 9fd8f3de0f..57eb927230 100644 --- a/src/scene/profile_lua.inl +++ b/src/scene/profile_lua.inl @@ -54,19 +54,17 @@ namespace { ); std::filesystem::path path = global::configuration->profile; path.replace_extension(); - std::string newFile = std::format("{}_{}", path.string(), time); + std::string newFile = std::format("{}_{}", path, time); std::string sourcePath = std::format( - "{}/{}.profile", - absPath("${USER_PROFILES}").string(), global::configuration->profile + "{}/{}.profile", absPath("${USER_PROFILES}"), global::configuration->profile ); std::string destPath = std::format( - "{}/{}.profile", - absPath("${PROFILES}").string(), global::configuration->profile + "{}/{}.profile", absPath("${PROFILES}"), global::configuration->profile ); if (!std::filesystem::is_regular_file(sourcePath)) { sourcePath = std::format( "{}/{}.profile", - absPath("${USER_PROFILES}").string(), global::configuration->profile + absPath("${USER_PROFILES}"), global::configuration->profile ); } LINFOC( @@ -99,7 +97,7 @@ namespace { } std::string absFilename = std::format( - "{}/{}.profile", absPath("${PROFILES}").string(), *saveFilePath + "{}/{}.profile", absPath("${PROFILES}"), *saveFilePath ); if (!std::filesystem::is_regular_file(absFilename)) { absFilename = absPath("${USER_PROFILES}/" + *saveFilePath + ".profile").string(); diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index f7361e9705..773a4ec609 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -324,7 +324,7 @@ void ScriptEngine::addLibraryFunctions(lua_State* state, LuaLibrary& library, library.documentations.clear(); for (const std::filesystem::path& script : library.scripts) { // First we run the script to set its values in the current state - ghoul::lua::runScriptFile(state, script.string()); + ghoul::lua::runScriptFile(state, script); // Then, we extract the documentation information from the file @@ -430,20 +430,17 @@ void ScriptEngine::writeLog(const std::string& script) { if (!_logFileExists) { // If a ScriptLogFile was specified, generate it now if (!global::configuration->scriptLog.empty()) { - _logFilename = absPath(global::configuration->scriptLog).string(); + _logFilename = absPath(global::configuration->scriptLog); _logFileExists = true; - LDEBUG(std::format( - "Using script log file {}", std::filesystem::path(_logFilename) - )); + LDEBUG(std::format("Using script log file '{}'", _logFilename)); // Test file and clear previous input std::ofstream file(_logFilename, std::ofstream::out | std::ofstream::trunc); if (!file.good()) { LERROR(std::format( - "Could not open file {} for logging scripts", - std::filesystem::path(_logFilename) + "Could not open file '{}' for logging scripts", _logFilename )); return; diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 64b6e60d9b..135a11ecb5 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -109,23 +109,24 @@ namespace { return e; } -std::vector walkCommon(std::string path, bool recursive, bool sorted, +std::vector walkCommon(const std::filesystem::path& path, + bool recursive, bool sorted, std::function filter) { namespace fs = std::filesystem; - std::vector result; + std::vector result; if (fs::is_directory(path)) { if (recursive) { for (fs::directory_entry e : fs::recursive_directory_iterator(path)) { if (filter(e)) { - result.push_back(e.path().string()); + result.push_back(e.path()); } } } else { for (fs::directory_entry e : fs::directory_iterator(path)) { if (filter(e)) { - result.push_back(e.path().string()); + result.push_back(e.path()); } } } @@ -143,9 +144,10 @@ std::vector walkCommon(std::string path, bool recursive, bool sorte * default value for this parameter is "false". The third argument determines whether the * table that is returned is sorted. The default value for this parameter is "false". */ -[[codegen::luawrap]] std::vector walkDirectory(std::string path, - bool recursive = false, - bool sorted = false) +[[codegen::luawrap]] std::vector walkDirectory( + std::filesystem::path path, + bool recursive = false, + bool sorted = false) { namespace fs = std::filesystem; return walkCommon( @@ -163,9 +165,10 @@ std::vector walkCommon(std::string path, bool recursive, bool sorte * default value for this parameter is "false". The third argument determines whether the * table that is returned is sorted. The default value for this parameter is "false". */ -[[codegen::luawrap]] std::vector walkDirectoryFiles(std::string path, - bool recursive = false, - bool sorted = false) +[[codegen::luawrap]] std::vector walkDirectoryFiles( + std::filesystem::path path, + bool recursive = false, + bool sorted = false) { namespace fs = std::filesystem; return walkCommon( @@ -183,9 +186,10 @@ std::vector walkCommon(std::string path, bool recursive, bool sorte * default value for this parameter is "false". The third argument determines whether the * table that is returned is sorted. The default value for this parameter is "false". */ -[[codegen::luawrap]] std::vector walkDirectoryFolders(std::string path, +[[codegen::luawrap]] std::vector walkDirectoryFolders( + std::filesystem::path path, bool recursive = false, - bool sorted = false) + bool sorted = false) { namespace fs = std::filesystem; return walkCommon( diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index b1766b6f44..1b3557c220 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -170,7 +170,8 @@ SpiceManager::SpiceManager() { SpiceManager::~SpiceManager() { for (const KernelInformation& i : _loadedKernels) { - unload_c(i.path.c_str()); + const std::string p = i.path.string(); + unload_c(p.c_str()); } // Set values back to default @@ -214,7 +215,7 @@ void throwSpiceError(const std::string& errorMessage) { } } -SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) { +SpiceManager::KernelHandle SpiceManager::loadKernel(std::filesystem::path filePath) { ghoul_assert(!filePath.empty(), "Empty file path"); ghoul_assert( std::filesystem::is_regular_file(filePath), @@ -228,11 +229,10 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) { ) ); - const std::filesystem::path path = absPath(std::move(filePath)); const auto it = std::find_if( _loadedKernels.begin(), _loadedKernels.end(), - [path](const KernelInformation& info) { return info.path == path; } + [filePath](const KernelInformation& info) { return info.path == filePath; } ); if (it != _loadedKernels.end()) { @@ -245,12 +245,13 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) { // kernels const std::filesystem::path currentDirectory = std::filesystem::current_path(); - const std::filesystem::path p = path.parent_path(); + const std::filesystem::path p = filePath.parent_path(); std::filesystem::current_path(p); - LINFO(std::format("Loading SPICE kernel '{}'", path)); + LINFO(std::format("Loading SPICE kernel '{}'", filePath)); // Load the kernel - furnsh_c(path.string().c_str()); + const std::string k = filePath.string(); + furnsh_c(k.c_str()); // Reset the current directory to the previous one std::filesystem::current_path(currentDirectory); @@ -259,17 +260,17 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) { throwSpiceError("Kernel loading"); } - const std::filesystem::path fileExtension = path.extension(); + const std::filesystem::path fileExtension = filePath.extension(); if (fileExtension == ".bc" || fileExtension == ".BC") { - findCkCoverage(path.string()); // binary ck kernel + findCkCoverage(filePath); // binary ck kernel } else if (fileExtension == ".bsp" || fileExtension == ".BSP") { - findSpkCoverage(path.string()); // binary spk kernel + findSpkCoverage(filePath); // binary spk kernel } const KernelHandle kernelId = ++_lastAssignedKernel; ghoul_assert(kernelId != 0, "Kernel Handle wrapped around to 0"); - _loadedKernels.push_back({ path.string(), kernelId, 1 }); + _loadedKernels.push_back({ std::move(filePath), kernelId, 1 }); return kernelId; } @@ -288,7 +289,8 @@ void SpiceManager::unloadKernel(KernelHandle kernelId) { if (it->refCount == 1) { // No need to check for errors as we do not allow empty path names LINFO(std::format("Unloading SPICE kernel '{}'", it->path)); - unload_c(it->path.c_str()); + const std::string p = it->path.string(); + unload_c(p.c_str()); _loadedKernels.erase(it); } // Otherwise, we hold on to it, but reduce the reference counter by 1 @@ -299,21 +301,19 @@ void SpiceManager::unloadKernel(KernelHandle kernelId) { } } -void SpiceManager::unloadKernel(std::string filePath) { +void SpiceManager::unloadKernel(std::filesystem::path filePath) { ghoul_assert(!filePath.empty(), "Empty filename"); - const std::filesystem::path path = absPath(std::move(filePath)); - const auto it = std::find_if( _loadedKernels.begin(), _loadedKernels.end(), - [&path](const KernelInformation& info) { return info.path == path; } + [&filePath](const KernelInformation& info) { return info.path == filePath; } ); if (it == _loadedKernels.end()) { if (_useExceptions) { throw SpiceException( - std::format("'{}' did not correspond to a loaded kernel", path) + std::format("'{}' did not correspond to a loaded kernel", filePath) ); } else { @@ -323,8 +323,9 @@ void SpiceManager::unloadKernel(std::string filePath) { else { // If there was only one part interested in the kernel, we can unload it if (it->refCount == 1) { - LINFO(std::format("Unloading SPICE kernel '{}'", path)); - unload_c(path.string().c_str()); + LINFO(std::format("Unloading SPICE kernel '{}'", filePath)); + const std::string p = filePath.string(); + unload_c(p.c_str()); _loadedKernels.erase(it); } else { @@ -335,8 +336,8 @@ void SpiceManager::unloadKernel(std::string filePath) { } } -std::vector SpiceManager::loadedKernels() const { - std::vector res; +std::vector SpiceManager::loadedKernels() const { + std::vector res; res.reserve(_loadedKernels.size()); for (const KernelInformation& info : _loadedKernels) { res.push_back(info.path); @@ -1048,7 +1049,7 @@ SpiceManager::TerminatorEllipseResult SpiceManager::terminatorEllipse( return res; } -void SpiceManager::findCkCoverage(const std::string& path) { +void SpiceManager::findCkCoverage(const std::filesystem::path& path) { ghoul_assert(!path.empty(), "Empty file path"); ghoul_assert( std::filesystem::is_regular_file(path), @@ -1069,7 +1070,8 @@ void SpiceManager::findCkCoverage(const std::string& path) { SPICEINT_CELL(ids, MaxObj); SPICEDOUBLE_CELL(cover, WinSiz); - ckobj_c(path.c_str(), &ids); + const std::string p = path.string(); + ckobj_c(p.c_str(), &ids); if (failed_c()) { throwSpiceError("Error finding Ck Coverage"); } @@ -1084,7 +1086,7 @@ void SpiceManager::findCkCoverage(const std::string& path) { #endif scard_c(0, &cover); - ckcov_c(path.c_str(), frame, SPICEFALSE, "SEGMENT", 0.0, "TDB", &cover); + ckcov_c(p.c_str(), frame, SPICEFALSE, "SEGMENT", 0.0, "TDB", &cover); if (failed_c()) { throwSpiceError("Error finding Ck Coverage"); } @@ -1108,7 +1110,7 @@ void SpiceManager::findCkCoverage(const std::string& path) { } } -void SpiceManager::findSpkCoverage(const std::string& path) { +void SpiceManager::findSpkCoverage(const std::filesystem::path &path) { ghoul_assert(!path.empty(), "Empty file path"); ghoul_assert( std::filesystem::is_regular_file(path), @@ -1129,7 +1131,8 @@ void SpiceManager::findSpkCoverage(const std::string& path) { SPICEINT_CELL(ids, MaxObj); SPICEDOUBLE_CELL(cover, WinSiz); - spkobj_c(path.c_str(), &ids); + const std::string p = path.string(); + spkobj_c(p.c_str(), &ids); if (failed_c()) { throwSpiceError("Error finding Spk ID for coverage"); } @@ -1144,7 +1147,7 @@ void SpiceManager::findSpkCoverage(const std::string& path) { #endif scard_c(0, &cover); - spkcov_c(path.c_str(), obj, &cover); + spkcov_c(p.c_str(), obj, &cover); if (failed_c()) { throwSpiceError("Error finding Spk coverage"); } @@ -1537,7 +1540,7 @@ const std::filesystem::path path = std::filesystem::temp_directory_path(); std::ofstream f(file); f << Naif00012tlsSource; } - loadKernel(file.string()); + loadKernel(file); std::filesystem::remove(file); } @@ -1671,7 +1674,7 @@ References: std::ofstream f(file); f << GeoPhysicalConstantsKernelSource; } - loadKernel(file.string()); + loadKernel(file); std::filesystem::remove(file); } diff --git a/src/util/spicemanager_lua.inl b/src/util/spicemanager_lua.inl index dec8e0df24..c7af06d963 100644 --- a/src/util/spicemanager_lua.inl +++ b/src/util/spicemanager_lua.inl @@ -73,7 +73,7 @@ namespace { /** * Returns a list of all loaded kernels */ -[[codegen::luawrap]] std::vector kernels() { +[[codegen::luawrap]] std::vector kernels() { return openspace::SpiceManager::ref().loadedKernels(); } diff --git a/src/util/taskloader.cpp b/src/util/taskloader.cpp index 4ca220b510..1139e34d64 100644 --- a/src/util/taskloader.cpp +++ b/src/util/taskloader.cpp @@ -79,7 +79,7 @@ std::vector> TaskLoader::tasksFromFile(const std::string& ghoul::Dictionary tasksDictionary; try { - ghoul::lua::loadDictionaryFromFile(absTasksFile.string(), tasksDictionary); + ghoul::lua::loadDictionaryFromFile(absTasksFile, tasksDictionary); } catch (const ghoul::RuntimeError& e) { LERROR(std::format( diff --git a/support/coding/codegen b/support/coding/codegen index 7dcdb14583..dd4812b4ea 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit 7dcdb145830916da1202efb1707ce9890193b606 +Subproject commit dd4812b4ea775fa7b208474900b98a54603edfa9 diff --git a/tests/main.cpp b/tests/main.cpp index 7f918ca4d8..77dd2a7844 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -63,11 +63,7 @@ int main(int argc, char** argv) { const std::filesystem::path base = configFile.parent_path(); FileSys.registerPathToken("${BASE}", base); - *global::configuration = loadConfigurationFromFile( - configFile.string(), - "", - glm::ivec2(0) - ); + *global::configuration = loadConfigurationFromFile(configFile, "", glm::ivec2(0)); global::openSpaceEngine->registerPathTokens(); global::openSpaceEngine->initialize(); diff --git a/tests/test_documentation.cpp b/tests/test_documentation.cpp index d76b851dcd..35f53fc078 100644 --- a/tests/test_documentation.cpp +++ b/tests/test_documentation.cpp @@ -553,13 +553,13 @@ TEST_CASE("Documentation: FileVerifier", "[documentation]") { }; ghoul::Dictionary positive; - positive.setValue("File", absPath("${TESTDIR}/verifier/dummyfile.txt").string()); + positive.setValue("File", absPath("${TESTDIR}/verifier/dummyfile.txt")); const TestResult positiveRes = testSpecification(doc, positive); CHECK(positiveRes.success); CHECK(positiveRes.offenses.empty()); ghoul::Dictionary negative404; - negative404.setValue("File", absPath("${TESTDIR}/verifier/404.txt").string()); + negative404.setValue("File", absPath("${TESTDIR}/verifier/404.txt")); TestResult negativeRes = testSpecification(doc, negative404); CHECK(!negativeRes.success); REQUIRE(negativeRes.offenses.size() == 1); @@ -594,13 +594,13 @@ TEST_CASE("Documentation: DirectoryVerifier", "[documentation]") { }; ghoul::Dictionary positive; - positive.setValue("Dir", absPath("${TESTDIR}/verifier").string()); + positive.setValue("Dir", absPath("${TESTDIR}/verifier")); const TestResult positiveRes = testSpecification(doc, positive); CHECK(positiveRes.success); CHECK(positiveRes.offenses.empty()); ghoul::Dictionary negative404; - negative404.setValue("Dir", absPath("${TESTDIR}/verifier404").string()); + negative404.setValue("Dir", absPath("${TESTDIR}/verifier404")); TestResult negativeRes = testSpecification(doc, negative404); CHECK(!negativeRes.success); REQUIRE(negativeRes.offenses.size() == 1); diff --git a/tests/test_horizons.cpp b/tests/test_horizons.cpp index c87537e1d2..477b37362e 100644 --- a/tests/test_horizons.cpp +++ b/tests/test_horizons.cpp @@ -112,7 +112,7 @@ void testReadingHorizons(HorizonsType type, const std::filesystem::path& filePat // Initialize SpiceManager and load leap second kernel SpiceManager::initialize(); - openspace::SpiceManager::ref().loadKernel(kernel.string()); + openspace::SpiceManager::ref().loadKernel(kernel); // Read the file HorizonsResult result = readHorizonsFile(filePath); @@ -142,7 +142,7 @@ void testReadingHorizons(HorizonsType type, const std::filesystem::path& filePat CHECK(data[2].position.z == Catch::Approx(z2)); // Clean up - openspace::SpiceManager::ref().unloadKernel(kernel.string()); + openspace::SpiceManager::ref().unloadKernel(kernel); openspace::SpiceManager::deinitialize(); } #endif // OPENSPACE_MODULE_SPACE_ENABLED diff --git a/tests/test_lua_createsinglecolorimage.cpp b/tests/test_lua_createsinglecolorimage.cpp index bd0f518523..d23ab2163c 100644 --- a/tests/test_lua_createsinglecolorimage.cpp +++ b/tests/test_lua_createsinglecolorimage.cpp @@ -42,20 +42,14 @@ TEST_CASE("CreateSingleColorImage: Create image and check return value", glm::dvec3(1.0, 0.0, 0.0) ); - CHECK_THAT( - path.string(), - Catch::Matchers::ContainsSubstring("colorFile.ppm") - ); + CHECK_THAT(path, Catch::Matchers::ContainsSubstring("colorFile.ppm")); } TEST_CASE("CreateSingleColorImage: Faulty color value (invalid values)", "[createsinglecolorimage]") { CHECK_THROWS_WITH( - createSingleColorImage( - "notCreatedColorFile", - glm::dvec3(255.0, 0.0, 0.0) - ).string(), + createSingleColorImage("notCreatedColorFile", glm::dvec3(255.0, 0.0, 0.0)), Catch::Matchers::Equals( "Invalid color. Expected three double values {r, g, b} in range 0 to 1" ) diff --git a/tests/test_rawvolumeio.cpp b/tests/test_rawvolumeio.cpp index 6aa574be19..b890e0c6d6 100644 --- a/tests/test_rawvolumeio.cpp +++ b/tests/test_rawvolumeio.cpp @@ -46,11 +46,11 @@ TEST_CASE("RawVolumeIO: TinyInputOutput", "[rawvolumeio]") { const std::filesystem::path volumePath = absPath("${TESTDIR}/tinyvolume.rawvolume"); // Write the 1x1x1 volume to disk - RawVolumeWriter writer(volumePath.string()); + RawVolumeWriter writer(volumePath); writer.write(vol); // Read the 1x1x1 volume and make sure the value is the same. - RawVolumeReader reader(volumePath.string(), dims); + RawVolumeReader reader(volumePath, dims); std::unique_ptr> storedVolume = reader.read(); CHECK(storedVolume->get({ 0, 0, 0 }) == value); } @@ -72,11 +72,11 @@ TEST_CASE("RawVolumeIO: BasicInputOutput", "[rawvolumeio]") { const std::filesystem::path volumePath = absPath("${TESTDIR}/basicvolume.rawvolume"); // Write the 2x4x8 volume to disk - RawVolumeWriter writer(volumePath.string()); + RawVolumeWriter writer(volumePath); writer.write(vol); // Read the 2x4x8 volume and make sure the value is the same. - RawVolumeReader reader(volumePath.string(), dims); + RawVolumeReader reader(volumePath, dims); const std::unique_ptr> storedVolume = reader.read(); vol.forEachVoxel([&value](const glm::uvec3& x, float v) { CHECK(v == value(x)); diff --git a/tests/test_scriptscheduler.cpp b/tests/test_scriptscheduler.cpp index 0288c26e96..42ac160e85 100644 --- a/tests/test_scriptscheduler.cpp +++ b/tests/test_scriptscheduler.cpp @@ -37,7 +37,7 @@ TEST_CASE("ScriptScheduler: Simple Forward", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); @@ -71,7 +71,7 @@ TEST_CASE("ScriptScheduler: Multiple Forward Single Jump", "[scriptscheduler]") SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -114,7 +114,7 @@ TEST_CASE("ScriptScheduler: Multiple Forward Ordering", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); @@ -155,7 +155,7 @@ TEST_CASE("ScriptScheduler: Simple Backward", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -188,7 +188,7 @@ TEST_CASE("ScriptScheduler: Multiple Backward Single Jump", "[scriptscheduler]") SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); @@ -232,7 +232,7 @@ TEST_CASE("ScriptScheduler: Multiple Backward Ordering", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -271,7 +271,7 @@ TEST_CASE("ScriptScheduler: Empty", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); static const std::vector TestTimes = { @@ -303,7 +303,7 @@ TEST_CASE("ScriptScheduler: Forward Backwards", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -350,7 +350,7 @@ TEST_CASE("ScriptScheduler: Rewind", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -390,7 +390,7 @@ TEST_CASE("ScriptScheduler: CurrentTime", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); static const std::vector TestValues = { @@ -414,7 +414,7 @@ TEST_CASE("ScriptScheduler: All Scripts", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -457,7 +457,7 @@ TEST_CASE("ScriptScheduler: Jump Equal", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -497,7 +497,7 @@ TEST_CASE("ScriptScheduler: Same Time", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -530,7 +530,7 @@ TEST_CASE("ScriptScheduler: Multi Inner Jump", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); std::vector scripts; @@ -572,7 +572,7 @@ TEST_CASE( SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); ScriptScheduler::ScheduledScript script1; @@ -613,7 +613,7 @@ TEST_CASE("ScriptScheduler: Multiple Forward Ordering Multiple Load" "[scriptsch SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); ScriptScheduler::ScheduledScript script1; @@ -652,7 +652,7 @@ TEST_CASE( SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); ScriptScheduler::ScheduledScript script1; @@ -694,7 +694,7 @@ TEST_CASE( SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); ScriptScheduler scheduler; @@ -731,7 +731,7 @@ TEST_CASE("ScriptScheduler: Forward Backwards Multiple Load", "[scriptscheduler] SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); ScriptScheduler::ScheduledScript script1; @@ -774,7 +774,7 @@ TEST_CASE("ScriptScheduler: Rewind Multiple Load", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); ScriptScheduler::ScheduledScript script1; @@ -811,7 +811,7 @@ TEST_CASE("ScriptScheduler: All Scripts Multiple Load", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); ScriptScheduler::ScheduledScript script1; @@ -850,7 +850,7 @@ TEST_CASE("ScriptScheduler: All Scripts Mixed Load", "[scriptscheduler]") { SpiceManager::initialize(); SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); ScriptScheduler::ScheduledScript script1; diff --git a/tests/test_sgctedit.cpp b/tests/test_sgctedit.cpp index 283cbcf3ac..6efb810e24 100644 --- a/tests/test_sgctedit.cpp +++ b/tests/test_sgctedit.cpp @@ -37,7 +37,7 @@ using namespace openspace; namespace { - std::string stringify(const std::string& filename) { + std::string stringify(const std::filesystem::path& filename) { const std::ifstream myfile = std::ifstream(filename); std::stringstream buffer; buffer << myfile.rdbuf(); @@ -46,9 +46,7 @@ namespace { void attemptValidation(const std::string& cfgString) { const std::filesystem::path schemaDir = absPath("${TESTDIR}/../config/schema"); - const std::string schemaString = stringify( - schemaDir.string() + "/sgcteditor.schema.json" - ); + const std::string schemaString = stringify(schemaDir / "sgcteditor.schema.json"); sgct::validateConfigAgainstSchema(cfgString, schemaString, schemaDir); } } // namespace @@ -450,9 +448,9 @@ R"({ TEST_CASE("SgctEdit: minimumVersion", "[sgctedit]") { const sgct::config::GeneratorVersion minVersion { "SgctWindowConfig", 1, 1 }; - const std::string inputCfg = - absPath("${TESTDIR}/sgctedit/fails_minimum_version.json").string(); - const sgct::config::GeneratorVersion ver = sgct::readConfigGenerator(inputCfg); + const std::filesystem::path cfg = + absPath("${TESTDIR}/sgctedit/fails_minimum_version.json"); + const sgct::config::GeneratorVersion ver = sgct::readConfigGenerator(cfg); CHECK_FALSE(ver.versionCheck(minVersion)); } diff --git a/tests/test_spicemanager.cpp b/tests/test_spicemanager.cpp index 0b9d8f72ab..2f8b2be770 100644 --- a/tests/test_spicemanager.cpp +++ b/tests/test_spicemanager.cpp @@ -37,54 +37,54 @@ namespace { // The remaining methods rely on multiple kernels, loaded as a SPICE 'meta-kernel' void loadMetaKernel() { const int k1 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); CHECK(k1 == 1); const int k2 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/cas00084.tsc").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/cas00084.tsc") ); CHECK(k2 == 2); const int k3 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/981005_PLTEPH-DE405S.bsp").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/981005_PLTEPH-DE405S.bsp") ); CHECK(k3 == 3); const int k4 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/020514_SE_SAT105.bsp").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/020514_SE_SAT105.bsp") ); CHECK(k4 == 4); const int k5 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/030201AP_SK_SM546_T45.bsp").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/030201AP_SK_SM546_T45.bsp") ); CHECK(k5 == 5); const int k6 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/cas_v37.tf").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/cas_v37.tf") ); CHECK(k6 == 6); const int k7 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/04135_04171pc_psiv2.bc").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/04135_04171pc_psiv2.bc") ); CHECK(k7 == 7); const int k8 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/cpck05Mar2004.tpc").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/cpck05Mar2004.tpc") ); CHECK(k8 == 8); const int k9 = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/cas_iss_v09.ti").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/cas_iss_v09.ti") ); CHECK(k9 == 9); } int loadLSKKernel() { const int kernelID = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); CHECK(kernelID == 1); return kernelID; @@ -92,7 +92,7 @@ namespace { int loadPCKKernel() { const int kernelID = SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/cpck05Mar2004.tpc").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/cpck05Mar2004.tpc") ); CHECK(kernelID == 1); return kernelID; @@ -160,7 +160,7 @@ TEST_CASE("SpiceManager: Unload Kernel String", "[spicemanager]") { // unload using string keyword SpiceManager::ref().unloadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); found = SPICEFALSE; diff --git a/tests/test_timequantizer.cpp b/tests/test_timequantizer.cpp index 1a82d0137e..25df8bee32 100644 --- a/tests/test_timequantizer.cpp +++ b/tests/test_timequantizer.cpp @@ -36,7 +36,7 @@ using namespace openspace; namespace { int loadLSKKernel() { const int kernelID = openspace::SpiceManager::ref().loadKernel( - absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls").string() + absPath("${TESTDIR}/SpiceTest/spicekernels/naif0008.tls") ); CHECK(kernelID == 1); return kernelID;