Merge in master

This commit is contained in:
Malin Ejdbo
2021-07-02 09:53:53 +02:00
parent 505601b1c9
commit bec5274ff0
62 changed files with 429 additions and 381 deletions

View File

@@ -54,6 +54,7 @@ set_folder_location(GhoulTest "Unit Tests")
# Spice
begin_dependency("Spice")
set(SPICE_BUILD_SHARED_LIBRARY OFF CACHE BOOL "" FORCE)
add_subdirectory(spice)
set_folder_location(spice "External")
end_dependency()

View File

@@ -23,9 +23,11 @@
****************************************************************************************/
#include <openspace/util/json_helper.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/ghoul_lua.h>
#include <glm/ext/matrix_common.hpp>
#include <cmath>
#include <type_traits>
namespace openspace::properties {
@@ -90,6 +92,35 @@ float NumericalProperty<T>::exponent() const {
template <typename T>
void NumericalProperty<T>::setExponent(float exponent) {
ghoul_assert(std::abs(exponent) > 0.f, "Exponent for property input cannot be zero");
auto isValidRange = [](const T& minValue, const T& maxValue) {
if constexpr (ghoul::isGlmVector<T>() || ghoul::isGlmMatrix<T>()) {
return glm::all(glm::greaterThanEqual(minValue, T(0))) &&
glm::all(glm::greaterThanEqual(maxValue, T(0)));
}
else {
return (minValue >= T(0) && maxValue >= T(0));
}
};
// While the exponential slider does not support ranges with negative values,
// prevent setting the exponent for such ranges
// @ TODO (2021-06-30, emmbr), remove this check when no longer needed
if (!std::is_unsigned<T>::value) {
if (!isValidRange(_minimumValue, _maximumValue)) {
LWARNINGC(
"NumericalProperty: setExponent",
fmt::format(
"Setting exponent for properties with negative values in "
"[min, max] range is not yet supported. Property: {}",
this->fullyQualifiedIdentifier()
)
);
_exponent = 1.f;
return;
}
}
_exponent = exponent;
}

View File

@@ -31,9 +31,10 @@
#include <openspace/scripting/lualibrary.h>
#include <ghoul/lua/luastate.h>
#include <ghoul/misc/boolean.h>
#include <filesystem>
#include <mutex>
#include <queue>
#include <optional>
#include <queue>
#include <functional>
namespace openspace { class SyncBuffer; }
@@ -82,7 +83,7 @@ public:
bool hasLibrary(const std::string& name);
bool runScript(const std::string& script, ScriptCallback callback = ScriptCallback());
bool runScriptFile(const std::string& filename);
bool runScriptFile(const std::filesystem::path& filename);
bool writeLog(const std::string& script);

View File

@@ -74,8 +74,8 @@ namespace {
"cullAtmosphere", "Rg", "Rt", "groundRadianceEmission", "HR", "betaRayleigh",
"HM", "betaMieExtinction", "mieG", "sunRadiance", "ozoneLayerEnabled", "HO",
"betaOzoneExtinction", "SAMPLES_R", "SAMPLES_MU", "SAMPLES_MU_S", "SAMPLES_NU",
"dInverseModelTransformMatrix", "dModelTransformMatrix",
"dSgctProjectionToModelTransformMatrix", "dSGCTViewToWorldMatrix", "dCamPosObj",
"inverseModelTransformMatrix", "modelTransformMatrix",
"projectionToModelTransformMatrix", "viewToWorldMatrix", "camPosObj",
"sunDirectionObj", "hardShadows", "transmittanceTexture", "irradianceTexture",
"inscatterTexture"
};
@@ -309,53 +309,38 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
// Object Space
glm::dmat4 inverseModelMatrix = glm::inverse(_modelTransform);
program.setUniform(
_uniformCache.dInverseModelTransformMatrix,
inverseModelMatrix
_uniformCache.inverseModelTransformMatrix, inverseModelMatrix
);
program.setUniform(_uniformCache.dModelTransformMatrix, _modelTransform);
program.setUniform(_uniformCache.modelTransformMatrix, _modelTransform);
// Eye Space in SGCT to Eye Space in OS (SGCT View to OS Camera Rig)
// glm::dmat4 dSgctEye2OSEye = glm::inverse(
// glm::dmat4(renderData.camera.viewMatrix()));
glm::dmat4 dSGCTViewToWorldMatrix = glm::inverse(
glm::dmat4 viewToWorldMatrix = glm::inverse(
renderData.camera.combinedViewMatrix()
);
// Eye Space in SGCT to OS World Space
program.setUniform(
_uniformCache.dSGCTViewToWorldMatrix,
dSGCTViewToWorldMatrix
);
// Eye Space to World Space
program.setUniform(_uniformCache.viewToWorldMatrix, viewToWorldMatrix);
// SGCT Projection to SGCT Eye Space
// Projection to Eye Space
glm::dmat4 dInverseProjection = glm::inverse(
glm::dmat4(renderData.camera.projectionMatrix())
);
glm::dmat4 inverseWholeMatrixPipeline =
inverseModelMatrix * dSGCTViewToWorldMatrix * dInverseProjection;
inverseModelMatrix * viewToWorldMatrix * dInverseProjection;
program.setUniform(
_uniformCache.dSgctProjectionToModelTransformMatrix,
_uniformCache.projectionToModelTransformMatrix,
inverseWholeMatrixPipeline
);
glm::dvec4 camPosObjCoords =
inverseModelMatrix * glm::dvec4(renderData.camera.eyePositionVec3(), 1.0);
program.setUniform(_uniformCache.dCamPosObj, camPosObjCoords);
program.setUniform(_uniformCache.camPosObj, glm::dvec3(camPosObjCoords));
SceneGraphNode* node = sceneGraph()->sceneGraphNode("Sun");
glm::dvec3 sunPosWorld = node ? node->worldPosition() : glm::dvec3(0.0);
double lt;
glm::dvec3 sunPosWorld = SpiceManager::ref().targetPosition(
"SUN",
"SSB",
"GALACTIC",
{},
_time,
lt
);
glm::dvec4 sunPosObj;
// Sun following camera position
if (_sunFollowingCameraEnabled) {
sunPosObj = inverseModelMatrix * glm::dvec4(
@@ -365,7 +350,10 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
}
else {
sunPosObj = inverseModelMatrix *
glm::dvec4(sunPosWorld - renderData.modelTransform.translation, 1.0);
glm::dvec4(
(sunPosWorld - renderData.modelTransform.translation) * 1000.0,
1.0
);
}
// Sun Position in Object Space
@@ -374,6 +362,8 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
glm::normalize(glm::dvec3(sunPosObj))
);
ghoul::opengl::updateUniformLocations(program, _uniformCache, UniformNames);
// Shadow calculations..
if (!_shadowConfArray.empty()) {
ZoneScopedN("Shadow Configuration")
@@ -384,6 +374,7 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData,
// TO REMEMBER: all distances and lengths in world coordinates are in
// meters!!! We need to move this to view space...
// Getting source and caster:
double lt;
glm::dvec3 sourcePos = SpiceManager::ref().targetPosition(
shadowConf.source.first,
"SSB",

View File

@@ -126,9 +126,9 @@ private:
UniformCache(cullAtmosphere, Rg, Rt, groundRadianceEmission, HR, betaRayleigh, HM,
betaMieExtinction, mieG, sunRadiance, ozoneLayerEnabled, HO, betaOzoneExtinction,
SAMPLES_R, SAMPLES_MU, SAMPLES_MU_S, SAMPLES_NU, dInverseModelTransformMatrix,
dModelTransformMatrix, dSgctProjectionToModelTransformMatrix,
dSGCTViewToWorldMatrix, dCamPosObj, sunDirectionObj, hardShadows,
SAMPLES_R, SAMPLES_MU, SAMPLES_MU_S, SAMPLES_NU, inverseModelTransformMatrix,
modelTransformMatrix, projectionToModelTransformMatrix,
viewToWorldMatrix, camPosObj, sunDirectionObj, hardShadows,
transmittanceTexture, irradianceTexture, inscatterTexture) _uniformCache;
GLuint _transmittanceTableTexture = 0;

View File

@@ -62,7 +62,6 @@
in vec2 texCoord;
out vec4 renderTarget;
uniform int nAaSamples;
uniform int cullAtmosphere;
uniform sampler2D irradianceTexture;
@@ -71,17 +70,21 @@ uniform sampler2D mainPositionTexture;
uniform sampler2D mainNormalTexture;
uniform sampler2D mainColorTexture;
uniform dmat4 dInverseModelTransformMatrix;
uniform dmat4 dModelTransformMatrix;
uniform dmat4 dSGCTViewToWorldMatrix;
uniform dmat4 dSgctProjectionToModelTransformMatrix;
uniform dmat4 inverseModelTransformMatrix;
uniform dmat4 modelTransformMatrix;
uniform dmat4 viewToWorldMatrix;
uniform dmat4 projectionToModelTransformMatrix;
uniform vec4 viewport;
uniform vec2 resolution;
uniform dvec4 dCamPosObj;
uniform dvec3 camPosObj;
uniform dvec3 sunDirectionObj;
uniform dvec3 sunWorld;
uniform dvec3 viewDirWorld;
uniform dvec3 sunModel;
/*******************************************************************************
***** ALL CALCULATIONS FOR ECLIPSE ARE IN METERS AND IN WORLD SPACE SYSTEM ****
*******************************************************************************/
@@ -215,13 +218,13 @@ Ray calculateRayRenderableGlobe(vec2 st) {
dvec4 clipCoords = dvec4(interpolatedNDCPos, 1.0, 1.0);
// Clip to Object Coords
dvec4 objectCoords = dSgctProjectionToModelTransformMatrix * clipCoords;
objectCoords /= objectCoords.w;
dvec4 objectCoords = projectionToModelTransformMatrix * clipCoords;
objectCoords.xyz /= objectCoords.w;
// Building Ray
// Ray in object space (in KM)
Ray ray;
ray.origin = dvec3(dCamPosObj * dvec4(0.001, 0.001, 0.001, 1.0));
ray.origin = camPosObj * 0.001;
ray.direction = normalize(objectCoords.xyz * dvec3(0.001) - ray.origin);
return ray;
}
@@ -244,16 +247,15 @@ Ray calculateRayRenderableGlobe(vec2 st) {
* attenuation := out of transmittance T(x,x0). This will be used later when calculating
* the reflectance R[L]
*/
vec3 inscatterRadiance(vec3 x, inout float t, out float irradianceFactor, vec3 v, vec3 s,
out float r, out float mu, out vec3 attenuation, vec3 fragPosObj,
vec3 inscatterRadiance(vec3 x, inout float t, inout float irradianceFactor, vec3 v, vec3 s,
float r, out float mu, out vec3 attenuation, vec3 fragPosObj,
out bool groundHit, double maxLength, double pixelDepth,
vec4 spaceColor, float sunIntensity)
vec3 spaceColor, float sunIntensity)
{
const float INTERPOLATION_EPS = 0.004; // precision const from Brunetton
vec3 radiance;
r = length(x);
mu = dot(x, v) / r;
float r2 = r * r;
@@ -303,16 +305,15 @@ vec3 inscatterRadiance(vec3 x, inout float t, out float irradianceFactor, vec3 v
}
// cos(PI-thetaH) = dist/r
// cos(thetaH) = - dist/r
// cos(thetaH) = -dist/r
// muHorizon = -sqrt(r^2-Rg^2)/r = -sqrt(1-(Rg/r)^2)
float muHorizon = -sqrt(1.0 - Rg2 / r2);
// In order to avoid imprecision problems near horizon, we interpolate between two
// In order to avoid precision problems near horizon, we interpolate between two
// points: above and below horizon
if (abs(mu - muHorizon) < INTERPOLATION_EPS) {
// We want an interpolation value close to 1/2, so the contribution of each radiance
// value is almost the same or it has a heavy weight if from above or
// below horizon
// value is almost the same or it has a heavy weight if from above or below horizon
float interpolationValue = (mu - muHorizon + INTERPOLATION_EPS) / (2.0 * INTERPOLATION_EPS);
// Above Horizon
@@ -321,9 +322,9 @@ vec3 inscatterRadiance(vec3 x, inout float t, out float irradianceFactor, vec3 v
// From cosine law where t = distance between x and x0
// r0^2 = r^2 + t^2 - 2 * r * t * cos(PI-theta)
// r0 = sqrt(r2 + t2 + 2.0f * r * t * mu);
float halfCossineLaw1 = r2 + (t * t);
float halfCossineLaw2 = 2.0 * r * t;
r0 = sqrt(halfCossineLaw1 + halfCossineLaw2 * mu);
float halfCosineLaw1 = r2 + (t * t);
float halfCosineLaw2 = 2.0 * r * t;
r0 = sqrt(halfCosineLaw1 + halfCosineLaw2 * mu);
// From the dot product: cos(theta0) = (x0 dot v)/(||ro||*||v||)
// mu0 = ((x + t) dot v) / r0
@@ -339,7 +340,7 @@ vec3 inscatterRadiance(vec3 x, inout float t, out float irradianceFactor, vec3 v
// Below Horizon
mu = muHorizon + INTERPOLATION_EPS;
//r0 = sqrt(r2 + t2 + 2.0f * r * t * mu);
r0 = sqrt(halfCossineLaw1 + halfCossineLaw2 * mu);
r0 = sqrt(halfCosineLaw1 + halfCosineLaw2 * mu);
mu0 = (r * mu + t) * (1.0 / r0);
@@ -374,7 +375,7 @@ vec3 inscatterRadiance(vec3 x, inout float t, out float irradianceFactor, vec3 v
return finalScatteringRadiance;
}
else {
return spaceColor.rgb + finalScatteringRadiance;
return spaceColor + finalScatteringRadiance;
}
}
@@ -457,16 +458,23 @@ vec3 groundColor(vec3 x, float t, vec3 v, vec3 s, vec3 attenuationXtoX0, vec3 gr
* attenuation := transmittance T(x,x0)
*/
vec3 sunColor(vec3 v, vec3 s, float r, float mu, float irradianceFactor) {
vec3 tm = vec3(1.0);
if (r <= Rt) {
tm = mu < -sqrt(1.0 - Rg2 / (r * r)) ? vec3(0.0) : transmittance(r, mu);
}
// JCC: Change this function to a impostor texture with gaussian decay color weighted
// by the sunRadiance, transmittance and irradianceColor (11/03/2017)
float sunFinalColor = smoothstep(cos(M_PI / 500.0), cos(M_PI / 900.0), dot(v, s)) *
sunRadiance * (1.0 - irradianceFactor);
// v = normalize(vec3(inverseModelTransformMatrix * dvec4(sunWorld, 1.0)));
float angle = dot(v, s);
return tm * sunFinalColor;
// JCC: Change this function to a impostor texture with gaussian decay color weighted
// by the sunRadiance, transmittance and irradianceColor (11/03/2017)
// @TODO (abock, 2021-07-01) This value is hard-coded to our sun right now
// Convert 0.3 degrees -> radians
const float SunAngularSize = (0.3 * M_PI / 180.0);
const float FuzzyFactor = 0.5; // How fuzzy should the edges be
const float p1 = cos(SunAngularSize);
const float p2 = cos(SunAngularSize * FuzzyFactor);
float t = (angle - p1) / (p2 - p1);
float scale = clamp(t, 0.0, 1.0);
return scale * transmittance(r, mu) * sunRadiance * (1.0 - irradianceFactor);
}
void main() {
@@ -481,17 +489,13 @@ void main() {
st.x = st.x / (resolution.x / viewport[2]) + (viewport[0] / resolution.x);
st.y = st.y / (resolution.y / viewport[3]) + (viewport[1] / resolution.y);
// Color from G-Buffer
vec3 color = texture(mainColorTexture, st).rgb;
if (cullAtmosphere == 1) {
renderTarget = texture(mainColorTexture, st);
renderTarget.rgb = color;
return;
}
vec4 atmosphereFinalColor = vec4(0.0);
int nSamples = 1;
// Color from G-Buffer
vec4 color = texture(mainColorTexture, st);
// Get the ray from camera to atm in object space
Ray ray = calculateRayRenderableGlobe(texCoord);
@@ -499,7 +503,7 @@ void main() {
double maxLength = 0.0; // in KM
bool intersect = atmosphereIntersection(ray, Rt - (ATM_EPSILON * 0.001), offset, maxLength);
if (!intersect) {
renderTarget = color;
renderTarget.rgb = color;
return;
}
@@ -509,14 +513,11 @@ void main() {
// Space (View plus Camera Rig Coords) when using their positions later, one must
// convert them to the planet's coords
//
// Get data from G-Buffer
// Normal is stored in SGCT View Space and transformed to the current object space
// Normal is stored in view space and transformed to the current object space
vec4 normalViewSpaceAndWaterReflectance = texture(mainNormalTexture, st);
dvec4 normalViewSpace = vec4(normalViewSpaceAndWaterReflectance.xyz, 0.0);
dvec4 normalWorldSpace = dSGCTViewToWorldMatrix * normalViewSpace;
vec4 normal = vec4(dInverseModelTransformMatrix * normalWorldSpace);
dvec4 normalWorldSpace = viewToWorldMatrix * normalViewSpace;
vec4 normal = vec4(inverseModelTransformMatrix * normalWorldSpace);
normal.xyz = normalize(normal.xyz);
normal.w = normalViewSpaceAndWaterReflectance.w;
@@ -524,19 +525,20 @@ void main() {
vec4 position = texture(mainPositionTexture, st);
// OS Eye to World coords
dvec4 positionWorldCoords = dSGCTViewToWorldMatrix * position;
dvec4 positionWorldCoords = viewToWorldMatrix * position;
// World to Object (Normal and Position in meters)
dvec4 positionObjectsCoords = dInverseModelTransformMatrix * positionWorldCoords;
dvec3 positionObjectsCoords = (inverseModelTransformMatrix * positionWorldCoords).xyz;
// Distance of the pixel in the gBuffer to the observer
// JCC (12/12/2017): AMD distance function is buggy.
//double pixelDepth = distance(cameraPositionInObject.xyz, positionObjectsCoords.xyz);
double pixelDepth = length(dCamPosObj.xyz - positionObjectsCoords.xyz);
double pixelDepth = length(camPosObj - positionObjectsCoords);
// JCC (12/13/2017): Trick to remove floating error in texture.
// We see a squared noise on planet's surface when seeing the planet from far away
float dC = float(length(dCamPosObj.xyz));
// @TODO (abock, 2021-07-01) I don't think this does anything. Remove?
float dC = float(length(camPosObj));
const float x1 = 1e8;
if (dC > x1) {
pixelDepth += 1000.0;
@@ -552,22 +554,21 @@ void main() {
// All calculations are done in KM:
pixelDepth *= 0.001;
positionObjectsCoords.xyz *= 0.001;
positionObjectsCoords *= 0.001;
if (pixelDepth < offset) {
// ATM Occluded - Something in front of ATM
renderTarget = color;
renderTarget.rgb = color;
return;
}
// Following paper nomenclature
double t = offset;
vec3 attenuation;
// Moving observer from camera location to top atmosphere. If the observer is already
// inside the atm, offset = 0.0 and no changes at all
vec3 x = vec3(ray.origin + t * ray.direction);
float r = 0.0; // length(x);
float r = length(x);
vec3 v = vec3(ray.direction);
float mu = 0.0; // dot(x, v) / r;
vec3 s = vec3(sunDirectionObj);
@@ -578,27 +579,30 @@ void main() {
// comparison with the planet's ground make sense:
pixelDepth -= offset;
dvec3 onATMPos = (dModelTransformMatrix * dvec4(x * 1000.0, 1.0)).xyz;
dvec3 onATMPos = (modelTransformMatrix * dvec4(x * 1000.0, 1.0)).xyz;
float eclipseShadowATM = calcShadow(shadowDataArray, onATMPos, false);
float sunIntensityInscatter = sunRadiance * eclipseShadowATM;
float irradianceFactor = 0.0;
bool groundHit = false;
vec3 attenuation;
vec3 inscatterColor = inscatterRadiance(x, tF, irradianceFactor, v, s, r, mu,
attenuation, vec3(positionObjectsCoords.xyz), groundHit, maxLength, pixelDepth,
color, sunIntensityInscatter);
attenuation, vec3(positionObjectsCoords), groundHit, maxLength, pixelDepth,
color, sunIntensityInscatter);
vec3 atmColor = vec3(0.0);
if (groundHit) {
float eclipseShadowPlanet = calcShadow(shadowDataArray, positionWorldCoords.xyz, true);
float sunIntensityGround = sunRadiance * eclipseShadowPlanet;
atmColor = groundColor(x, tF, v, s, attenuation, color.rgb, normal.xyz,
atmColor = groundColor(x, tF, v, s, attenuation, color, normal.xyz,
irradianceFactor, normal.w, sunIntensityGround);
}
else {
// In order to get better performance, we are not tracing multiple rays per pixel
// when the ray doesn't intersect the ground
atmColor = sunColor(v, s, r, mu, irradianceFactor);
atmColor = sunColor(v, s, r, mu, irradianceFactor);
}
// Final Color of ATM plus terrain:

View File

@@ -213,6 +213,7 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
ScreenSpaceImageLocal::Documentation(),
ScreenSpaceImageOnline::Documentation(),
ConstantRotation::Documentation(),
FixedRotation::Documentation(),
LuaRotation::Documentation(),
StaticRotation::Documentation(),

View File

@@ -196,7 +196,7 @@ void RenderablePlaneImageLocal::loadTexture() {
LDEBUGC(
"RenderablePlaneImageLocal",
fmt::format("Loaded texture from '{}'", absPath(path))
fmt::format("Loaded texture from {}", absPath(path))
);
texture->uploadTexture();
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);

View File

@@ -96,53 +96,55 @@ void RenderablePlaneImageOnline::bindTexture() {
}
void RenderablePlaneImageOnline::update(const UpdateData&) {
if (_textureIsDirty) {
if (!_imageFuture.valid()) {
std::future<DownloadManager::MemoryFile> future = downloadImageToMemory(
_texturePath
if (!_textureIsDirty) {
return;
}
if (!_imageFuture.valid()) {
std::future<DownloadManager::MemoryFile> future = downloadImageToMemory(
_texturePath
);
if (future.valid()) {
_imageFuture = std::move(future);
}
}
if (_imageFuture.valid() && DownloadManager::futureReady(_imageFuture)) {
DownloadManager::MemoryFile imageFile = _imageFuture.get();
if (imageFile.corrupted) {
LERRORC(
"ScreenSpaceImageOnline",
fmt::format("Error loading image from URL '{}'", _texturePath)
);
if (future.valid()) {
_imageFuture = std::move(future);
}
return;
}
if (_imageFuture.valid() && DownloadManager::futureReady(_imageFuture)) {
DownloadManager::MemoryFile imageFile = _imageFuture.get();
if (imageFile.corrupted) {
LERRORC(
"ScreenSpaceImageOnline",
fmt::format("Error loading image from URL '{}'", _texturePath)
try {
std::unique_ptr<ghoul::opengl::Texture> texture =
ghoul::io::TextureReader::ref().loadTexture(
reinterpret_cast<void*>(imageFile.buffer),
imageFile.size,
imageFile.format
);
return;
}
try {
std::unique_ptr<ghoul::opengl::Texture> texture =
ghoul::io::TextureReader::ref().loadTexture(
reinterpret_cast<void*>(imageFile.buffer),
imageFile.size,
imageFile.format
);
if (texture) {
// Images don't need to start on 4-byte boundaries, for example if the
// image is only RGB
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (texture) {
// Images don't need to start on 4-byte boundaries, for example if the
// image is only RGB
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
texture->uploadTexture();
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
texture->purgeFromRAM();
texture->uploadTexture();
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
texture->purgeFromRAM();
_texture = std::move(texture);
_textureIsDirty = false;
}
}
catch (const ghoul::io::TextureReader::InvalidLoadException& e) {
_texture = std::move(texture);
_textureIsDirty = false;
LERRORC(e.component, e.message);
}
}
catch (const ghoul::io::TextureReader::InvalidLoadException& e) {
_textureIsDirty = false;
LERRORC(e.component, e.message);
}
}
}

View File

@@ -268,8 +268,8 @@ void RenderablePrism::updateVertexData() {
_indexArray.push_back(255);
// Indices for Top shape
for (uint8_t i = _nShapeSegments; i < 2 * _nShapeSegments; ++i) {
_indexArray.push_back(i);
for (int i = _nShapeSegments; i < 2 * _nShapeSegments; ++i) {
_indexArray.push_back(static_cast<uint8_t>(i));
}
// Indices for connecting lines
@@ -277,8 +277,8 @@ void RenderablePrism::updateVertexData() {
// Reset
_indexArray.push_back(255);
_indexArray.push_back(2 * _nShapeSegments + k);
_indexArray.push_back(2 * _nShapeSegments + k + 1);
_indexArray.push_back(static_cast<uint8_t>(2 * _nShapeSegments + k));
_indexArray.push_back(static_cast<uint8_t>(2 * _nShapeSegments + k + 1));
}
}

View File

@@ -452,7 +452,7 @@ void RenderableSphere::loadTexture() {
if (texture) {
LDEBUGC(
"RenderableSphere",
fmt::format("Loaded texture from '{}'", absPath(_texturePath))
fmt::format("Loaded texture from {}", absPath(_texturePath))
);
texture->uploadTexture();
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);

View File

@@ -79,7 +79,7 @@ LuaRotation::LuaRotation(const ghoul::Dictionary& dictionary) : LuaRotation() {
}
glm::dmat3 LuaRotation::matrix(const UpdateData& data) const {
ghoul::lua::runScriptFile(_state, _luaScriptFile);
ghoul::lua::runScriptFile(_state, _luaScriptFile.value());
// Get the scaling function
lua_getglobal(_state, "rotation");
@@ -87,7 +87,9 @@ glm::dmat3 LuaRotation::matrix(const UpdateData& data) const {
if (!isFunction) {
LERRORC(
"LuaRotation",
fmt::format("Script '{}' does nto have a function 'rotation'", _luaScriptFile)
fmt::format(
"Script '{}' does not have a function 'rotation'", _luaScriptFile.value()
)
);
return glm::dmat3(1.0);
}

View File

@@ -77,7 +77,7 @@ LuaScale::LuaScale(const ghoul::Dictionary& dictionary) : LuaScale() {
}
glm::dvec3 LuaScale::scaleValue(const UpdateData& data) const {
ghoul::lua::runScriptFile(_state, _luaScriptFile);
ghoul::lua::runScriptFile(_state, _luaScriptFile.value());
// Get the scaling function
lua_getglobal(_state, "scale");
@@ -85,7 +85,9 @@ glm::dvec3 LuaScale::scaleValue(const UpdateData& data) const {
if (!isFunction) {
LERRORC(
"LuaScale",
fmt::format("Script '{}' does not have a function 'scale'", _luaScriptFile)
fmt::format(
"Script '{}' does not have a function 'scale'", _luaScriptFile.value()
)
);
return glm::dvec3(1.0);
}

View File

@@ -81,7 +81,7 @@ LuaTranslation::LuaTranslation(const ghoul::Dictionary& dictionary) : LuaTransla
}
glm::dvec3 LuaTranslation::position(const UpdateData& data) const {
ghoul::lua::runScriptFile(_state, _luaScriptFile);
ghoul::lua::runScriptFile(_state, _luaScriptFile.value());
// Get the scaling function
lua_getglobal(_state, "translation");
@@ -91,7 +91,7 @@ glm::dvec3 LuaTranslation::position(const UpdateData& data) const {
"LuaScale",
fmt::format(
"Script '{}' does not have a function 'translation'",
_luaScriptFile
_luaScriptFile.value()
)
);
return glm::dvec3(0.0);
@@ -119,7 +119,7 @@ glm::dvec3 LuaTranslation::position(const UpdateData& data) const {
double values[3];
for (int i = 1; i <= 3; ++i) {
values[i] = ghoul::lua::value<double>(_state, i);
values[i - 1] = ghoul::lua::value<double>(_state, i);
}
return glm::make_vec3(values);

View File

@@ -970,7 +970,7 @@ void RenderableBillboardsCloud::update(const UpdateData&) {
_spriteTexture = DigitalUniverseModule::TextureManager.request(
std::to_string(hash),
[path = _spriteTexturePath]() -> std::unique_ptr<ghoul::opengl::Texture> {
LINFO(fmt::format("Loaded texture from '{}'", absPath(path)));
LINFO(fmt::format("Loaded texture from {}", absPath(path)));
std::unique_ptr<ghoul::opengl::Texture> t =
ghoul::io::TextureReader::ref().loadTexture(absPath(path).string());
t->uploadTexture();

View File

@@ -484,7 +484,7 @@ void RenderableDUMeshes::update(const UpdateData&) {
bool RenderableDUMeshes::loadData() {
bool success = false;
if (_hasSpeckFile) {
LINFO(fmt::format("Loading Speck file '{}'", _speckFile));
LINFO(fmt::format("Loading Speck file {}", std::filesystem::path(_speckFile)));
success = readSpeckFile();
if (!success) {
return false;
@@ -502,7 +502,9 @@ bool RenderableDUMeshes::loadData() {
bool RenderableDUMeshes::readSpeckFile() {
std::ifstream file(_speckFile);
if (!file.good()) {
LERROR(fmt::format("Failed to open Speck file '{}'", _speckFile));
LERROR(fmt::format(
"Failed to open Speck file {}", std::filesystem::path(_speckFile)
));
return false;
}

View File

@@ -272,7 +272,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
addProperty(_opacity);
if (p.file.has_value()) {
_speckFile = absPath(*p.file).string();
_speckFile = absPath(*p.file);
_hasSpeckFile = true;
_drawElements.onChange([&]() { _hasSpeckFile = !_hasSpeckFile; });
addProperty(_drawElements);
@@ -320,7 +320,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
_scaleFactor.onChange([&]() { _dataIsDirty = true; });
if (p.labelFile.has_value()) {
_labelFile = absPath(*p.labelFile).string();
_labelFile = absPath(*p.labelFile);
_hasLabel = true;
_textColor = p.textColor.value_or(_textColor);
@@ -368,7 +368,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
}
}
_texturesPath = absPath(p.texturePath).string();
_texturesPath = absPath(p.texturePath);
_luminosityVar = p.luminosity.value_or(_luminosityVar);
_sluminosity = p.scaleLuminosity.value_or(_sluminosity);
@@ -403,7 +403,7 @@ void RenderablePlanesCloud::initialize() {
}
if (!_labelFile.empty()) {
LINFO(fmt::format("Loading Label file '{}'", _labelFile));
LINFO(fmt::format("Loading Label file {}", _labelFile));
_labelset = speck::label::loadFileWithCache(_labelFile);
for (speck::Labelset::Entry& e : _labelset.entries) {
e.position = glm::vec3(_transformationMatrix * glm::dvec4(e.position, 1.0));
@@ -612,7 +612,7 @@ void RenderablePlanesCloud::update(const UpdateData&) {
void RenderablePlanesCloud::loadTextures() {
for (const speck::Dataset::Texture& tex : _dataset.textures) {
std::filesystem::path fullPath = absPath(_texturesPath + '/' + tex.file);
std::filesystem::path fullPath = absPath(_texturesPath.string() + '/' + tex.file);
std::filesystem::path pngPath = fullPath;
pngPath.replace_extension(".png");
@@ -634,7 +634,7 @@ void RenderablePlanesCloud::loadTextures() {
ghoul::io::TextureReader::ref().loadTexture(path.string());
if (t) {
LINFOC("RenderablePlanesCloud", fmt::format("Loaded texture '{}'", path));
LINFOC("RenderablePlanesCloud", fmt::format("Loaded texture {}", path));
t->uploadTexture();
t->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
t->purgeFromRAM();

View File

@@ -34,10 +34,9 @@
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec2property.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/opengl/uniformcache.h>
#include <filesystem>
#include <functional>
#include <unordered_map>
@@ -129,9 +128,9 @@ private:
std::unordered_map<int, std::string> _textureFileMap;
std::unordered_map<int, PlaneAggregate> _planesMap;
std::string _speckFile;
std::string _labelFile;
std::string _texturesPath;
std::filesystem::path _speckFile;
std::filesystem::path _labelFile;
std::filesystem::path _texturesPath;
std::string _luminosityVar;
Unit _unit = Parsec;

View File

@@ -135,7 +135,7 @@ RenderablePoints::RenderablePoints(const ghoul::Dictionary& dictionary)
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_speckFile = absPath(p.file).string();
_speckFile = absPath(p.file);
if (p.unit.has_value()) {
switch (*p.unit) {
@@ -185,7 +185,7 @@ RenderablePoints::RenderablePoints(const ghoul::Dictionary& dictionary)
}
if (p.colorMap.has_value()) {
_colorMapFile = absPath(*p.colorMap).string();
_colorMapFile = absPath(*p.colorMap);
_hasColorMapFile = true;
}
@@ -347,9 +347,9 @@ void RenderablePoints::update(const UpdateData&) {
absPath(_spriteTexturePath).string()
);
if (_spriteTexture) {
LDEBUG(fmt::format(
"Loaded texture from '{}'",absPath(_spriteTexturePath)
));
LDEBUG(
fmt::format("Loaded texture from {}", absPath(_spriteTexturePath))
);
_spriteTexture->uploadTexture();
}
_spriteTexture->setFilter(
@@ -369,7 +369,7 @@ void RenderablePoints::readColorMapFile() {
std::ifstream file(_colorMapFile);
if (!file.good()) {
throw ghoul::RuntimeError(fmt::format(
"Failed to open Color Map file '{}'", _colorMapFile
"Failed to open Color Map file {}", _colorMapFile
));
}
@@ -396,7 +396,7 @@ void RenderablePoints::readColorMapFile() {
}
else if (file.eof()) {
throw ghoul::RuntimeError(fmt::format(
"Failed to load colors from Color Map file '{}'", _colorMapFile
"Failed to load colors from Color Map file {}", _colorMapFile
));
}
}

View File

@@ -35,6 +35,7 @@
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/opengl/uniformcache.h>
#include <filesystem>
namespace ghoul::filesystem { class File; }
@@ -95,8 +96,8 @@ private:
spriteTexture, hasColorMap
) _uniformCache;
std::string _speckFile;
std::string _colorMapFile;
std::filesystem::path _speckFile;
std::filesystem::path _colorMapFile;
Unit _unit = Parsec;

View File

@@ -65,8 +65,7 @@ glm::vec3 computeStarColor(float bv) {
if (!colorMap.good()) {
LERROR(fmt::format(
"Failed to open colormap data file: '{}'",
absPath(bvColormapPath)
"Failed to open colormap data file: {}", absPath(bvColormapPath)
));
return glm::vec3(0.f);
}

View File

@@ -158,8 +158,8 @@ void createExoplanetSystem(const std::string& starName) {
const glm::vec3 starPosInParsec = system.starData.position;
if (!isValidPosition(starPosInParsec)) {
LERROR(fmt::format(
"Insufficient data available for exoplanet system: '{}'. "
"Could not determine star position", starName
"Insufficient data available for exoplanet system: '{}'. Could not determine "
"star position", starName
));
return;
}

View File

@@ -303,8 +303,10 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon,
if (!success &&
(model == fls::Model::Batsrus && (str == TAsPOverRho || str == "T")))
{
LDEBUG("BATSRUS doesn't contain variable T for temperature. Trying to "
"calculate it using the ideal gas law: T = pressure/density");
LDEBUG(
"BATSRUS doesn't contain variable T for temperature. Trying to calculate "
"it using the ideal gas law: T = pressure/density"
);
constexpr const char* p = "p";
constexpr const char* r = "rho";
success = kameleon->doesVariableExist(p) && kameleon->loadVariable(p) &&
@@ -312,9 +314,7 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon,
str = TAsPOverRho;
}
if (!success) {
LWARNING(fmt::format(
"Failed to load extra variable: '{}'. Ignoring", str
));
LWARNING(fmt::format("Failed to load extra variable: '{}'. Ignoring", str));
extraScalarVars.erase(extraScalarVars.begin() + i);
--i;
}

View File

@@ -25,6 +25,7 @@
#ifndef __OPENSPACE_MODULE_FITSFILEREADER___FITSFILEREADER___H__
#define __OPENSPACE_MODULE_FITSFILEREADER___FITSFILEREADER___H__
#include <filesystem>
#include <string>
#include <memory>
#include <mutex>
@@ -63,7 +64,7 @@ public:
~FitsFileReader();
template<typename T>
std::shared_ptr<ImageData<T>> readImage(const std::string& path);
std::shared_ptr<ImageData<T>> readImage(const std::filesystem::path& path);
template<typename T>
std::shared_ptr<std::unordered_map<std::string, T>> readHeader(
@@ -78,7 +79,7 @@ public:
* If no HDU index is given the current Extension HDU will be read from.
*/
template<typename T>
std::shared_ptr<TableData<T>> readTable(std::string& path,
std::shared_ptr<TableData<T>> readTable(const std::filesystem::path& path,
const std::vector<std::string>& columnNames, int startRow = 1, int endRow = 10,
int hduIdx = 1, bool readAll = false);
@@ -88,7 +89,7 @@ public:
* If additional columns are given by <code>filterColumnNames</code>, they will be
* read but it will slow doen the reading tremendously.
*/
std::vector<float> readFitsFile(std::string filePath, int& nValuesPerStar,
std::vector<float> readFitsFile(std::filesystem::path filePath, int& nValuesPerStar,
int firstRow, int lastRow, std::vector<std::string> filterColumnNames,
int multiplier = 1);
@@ -96,7 +97,8 @@ public:
* Reads a single SPECK file and returns a vector with <code>nRenderValues</code>
* per star. Reads data in pre-defined order based on AMNH's star data files.
*/
std::vector<float> readSpeckFile(const std::string& filePath, int& nRenderValues);
std::vector<float> readSpeckFile(const std::filesystem::path& filePath,
int& nRenderValues);
private:
std::unique_ptr<CCfits::FITS> _infile;

View File

@@ -69,7 +69,8 @@ bool FitsFileReader::isPrimaryHDU() {
}
template <typename T>
std::shared_ptr<ImageData<T>> FitsFileReader::readImage(const std::string& path) {
std::shared_ptr<ImageData<T>> FitsFileReader::readImage(const std::filesystem::path& path)
{
try {
_infile = std::make_unique<FITS>(path, Read, true);
// Primary HDU Object
@@ -136,7 +137,7 @@ std::shared_ptr<T> FitsFileReader::readHeaderValue(const std::string key) {
}
template<typename T>
std::shared_ptr<TableData<T>> FitsFileReader::readTable(std::string& path,
std::shared_ptr<TableData<T>> FitsFileReader::readTable(const std::filesystem::path& path,
const std::vector<std::string>& columnNames,
int startRow,
int endRow,
@@ -148,7 +149,7 @@ std::shared_ptr<TableData<T>> FitsFileReader::readTable(std::string& path,
std::lock_guard g(_mutex);
try {
_infile = std::make_unique<FITS>(path, Read, readAll);
_infile = std::make_unique<FITS>(path.string(), Read, readAll);
// Make sure FITS file is not a Primary HDU Object (aka an image).
if (!isPrimaryHDU()) {
@@ -191,8 +192,9 @@ std::shared_ptr<TableData<T>> FitsFileReader::readTable(std::string& path,
return nullptr;
}
std::vector<float> FitsFileReader::readFitsFile(std::string filePath, int& nValuesPerStar,
int firstRow, int lastRow,
std::vector<float> FitsFileReader::readFitsFile(std::filesystem::path filePath,
int& nValuesPerStar, int firstRow,
int lastRow,
std::vector<std::string> filterColumnNames,
int multiplier)
{
@@ -245,7 +247,7 @@ std::vector<float> FitsFileReader::readFitsFile(std::string filePath, int& nValu
);
if (!table) {
throw ghoul::RuntimeError(fmt::format("Failed to open Fits file '{}'", filePath));
throw ghoul::RuntimeError(fmt::format("Failed to open Fits file {}", filePath));
}
int nStars = table->readRows - firstRow + 1;
@@ -520,7 +522,7 @@ std::vector<float> FitsFileReader::readFitsFile(std::string filePath, int& nValu
return fullData;
}
std::vector<float> FitsFileReader::readSpeckFile(const std::string& filePath,
std::vector<float> FitsFileReader::readSpeckFile(const std::filesystem::path& filePath,
int& nRenderValues)
{
std::vector<float> fullData;
@@ -528,7 +530,7 @@ std::vector<float> FitsFileReader::readSpeckFile(const std::string& filePath,
std::ifstream fileStream(filePath);
if (!fileStream.good()) {
LERROR(fmt::format("Failed to open Speck file '{}'", filePath));
LERROR(fmt::format("Failed to open Speck file {}", filePath));
return fullData;
}

View File

@@ -2131,9 +2131,7 @@ void RenderableGaiaStars::update(const UpdateData&) {
absPath(_colorTexturePath).string()
);
if (_colorTexture) {
LDEBUG(fmt::format(
"Loaded texture from '{}'", absPath(_colorTexturePath)
));
LDEBUG(fmt::format("Loaded texture from {}", absPath(_colorTexturePath)));
_colorTexture->uploadTexture();
}
@@ -2188,28 +2186,29 @@ bool RenderableGaiaStars::readDataFile() {
_octreeManager.initOctree(_cpuRamBudgetInBytes);
LINFO("Loading data file: " + _filePath.value());
std::filesystem::path file = absPath(_filePath.value());
LINFO(fmt::format("Loading data file: {}", file));
switch (fileReaderOption) {
case gaia::FileReaderOption::Fits:
// Read raw fits file and construct Octree.
nReadStars = readFitsFile(_filePath);
nReadStars = readFitsFile(file);
break;
case gaia::FileReaderOption::Speck:
// Read raw speck file and construct Octree.
nReadStars = readSpeckFile(_filePath);
nReadStars = readSpeckFile(file);
break;
case gaia::FileReaderOption::BinaryRaw:
// Stars are stored in an ordered binary file.
nReadStars = readBinaryRawFile(_filePath);
nReadStars = readBinaryRawFile(file);
break;
case gaia::FileReaderOption::BinaryOctree:
// Octree already constructed and stored as a binary file.
nReadStars = readBinaryOctreeFile(_filePath);
nReadStars = readBinaryOctreeFile(file);
break;
case gaia::FileReaderOption::StreamOctree:
// Read Octree structure from file, without data.
nReadStars = readBinaryOctreeStructureFile(_filePath);
nReadStars = readBinaryOctreeStructureFile(file.string());
break;
default:
LERROR("Wrong FileReaderOption - no data file loaded!");
@@ -2218,13 +2217,13 @@ bool RenderableGaiaStars::readDataFile() {
//_octreeManager->printStarsPerNode();
_nRenderedStars.setMaxValue(nReadStars);
LINFO("Dataset contains a total of " + std::to_string(nReadStars) + " stars.");
LINFO(fmt::format("Dataset contains a total of {} stars", nReadStars));
_totalDatasetSizeInBytes = nReadStars * (PositionSize + ColorSize + VelocitySize) * 4;
return nReadStars > 0;
}
int RenderableGaiaStars::readFitsFile(const std::string& filePath) {
int RenderableGaiaStars::readFitsFile(const std::filesystem::path& filePath) {
int nReadValuesPerStar = 0;
FitsFileReader fitsFileReader(false);
@@ -2248,7 +2247,7 @@ int RenderableGaiaStars::readFitsFile(const std::string& filePath) {
return static_cast<int>(fullData.size() / nReadValuesPerStar);
}
int RenderableGaiaStars::readSpeckFile(const std::string& filePath) {
int RenderableGaiaStars::readSpeckFile(const std::filesystem::path& filePath) {
int nReadValuesPerStar = 0;
FitsFileReader fileReader(false);
@@ -2266,7 +2265,7 @@ int RenderableGaiaStars::readSpeckFile(const std::string& filePath) {
return static_cast<int>(fullData.size() / nReadValuesPerStar);
}
int RenderableGaiaStars::readBinaryRawFile(const std::string& filePath) {
int RenderableGaiaStars::readBinaryRawFile(const std::filesystem::path& filePath) {
std::vector<float> fullData;
int nReadStars = 0;
@@ -2299,14 +2298,14 @@ int RenderableGaiaStars::readBinaryRawFile(const std::string& filePath) {
}
else {
LERROR(fmt::format(
"Error opening file '{}' for loading raw binary file!", filePath
"Error opening file '{}' for loading raw binary file", filePath
));
return nReadStars;
}
return nReadStars;
}
int RenderableGaiaStars::readBinaryOctreeFile(const std::string& filePath) {
int RenderableGaiaStars::readBinaryOctreeFile(const std::filesystem::path& filePath) {
int nReadStars = 0;
std::ifstream fileStream(filePath, std::ifstream::binary);
@@ -2317,26 +2316,28 @@ int RenderableGaiaStars::readBinaryOctreeFile(const std::string& filePath) {
}
else {
LERROR(fmt::format(
"Error opening file '{}' for loading binary Octree file!", filePath
"Error opening file '{}' for loading binary Octree file", filePath
));
return nReadStars;
}
return nReadStars;
}
int RenderableGaiaStars::readBinaryOctreeStructureFile(const std::string& folderPath) {
int RenderableGaiaStars::readBinaryOctreeStructureFile(
const std::filesystem::path& folderPath)
{
int nReadStars = 0;
std::string indexFile = folderPath + "index.bin";
std::string indexFile = folderPath.string() + "index.bin";
std::ifstream fileStream(indexFile, std::ifstream::binary);
if (fileStream.good()) {
nReadStars = _octreeManager.readFromFile(fileStream, false, folderPath);
nReadStars = _octreeManager.readFromFile(fileStream, false, folderPath.string());
fileStream.close();
}
else {
LERROR(fmt::format(
"Error opening file '{}' for loading binary Octree file!", indexFile
"Error opening file '{}' for loading binary Octree file", indexFile
));
return nReadStars;
}

View File

@@ -78,28 +78,28 @@ private:
*
* \return the number of stars read.
*/
int readFitsFile(const std::string& filePath);
int readFitsFile(const std::filesystem::path& filePath);
/**
* Read a SPECK file by using FitsFileReader.readSpeckFile() and constructs an octree.
*
* \return the number of stars read.
*/
int readSpeckFile(const std::string& filePath);
int readSpeckFile(const std::filesystem::path& filePath);
/**
* Reads a preprocessed binary file and constructs an octree.
*
* \return the number of stars read.
*/
int readBinaryRawFile(const std::string& filePath);
int readBinaryRawFile(const std::filesystem::path& filePath);
/**
* Reads a pre-constructed octree, with all data, from a binary file.
*
* \return the number of stars read.
*/
int readBinaryOctreeFile(const std::string& filePath);
int readBinaryOctreeFile(const std::filesystem::path& filePath);
/**
* Reads the structure of a pre-constructed octree from a binary file, without any
@@ -107,7 +107,7 @@ private:
*
* \return the number of stars read.
*/
int readBinaryOctreeStructureFile(const std::string& folderPath);
int readBinaryOctreeStructureFile(const std::filesystem::path& folderPath);
/**
* Checks for any OpenGL errors and reports these to the log if _reportGlErrors is

View File

@@ -68,8 +68,10 @@ void ReadFileJob::execute() {
int nNullArr = 0;
size_t nColumnsRead = _allColumns.size();
if (nColumnsRead != _nDefaultCols) {
LINFO("Additional columns will be read! Consider add column in code for "
"significant speedup!");
LINFO(
"Additional columns will be read! Consider add column in code for "
"significant speedup"
);
}
// Copy columns to local variables.

View File

@@ -182,14 +182,15 @@ namespace {
#include "renderablegalaxy_codegen.cpp"
void saveCachedFile(const std::string& file, const std::vector<glm::vec3>& positions,
void saveCachedFile(const std::filesystem::path& file,
const std::vector<glm::vec3>& positions,
const std::vector<glm::vec3>& colors, int64_t nPoints,
float pointsRatio)
{
std::ofstream fileStream(file, std::ofstream::binary);
if (!fileStream.good()) {
LERROR(fmt::format("Error opening file '{}' for save cache file", file));
LERROR(fmt::format("Error opening file {} for save cache file", file));
return;
}
@@ -321,13 +322,13 @@ void RenderableGalaxy::initialize() {
);
_volume = reader.read();
std::string cachedPointsFile = FileSys.cacheManager()->cachedFilename(
std::filesystem::path cachedPointsFile = FileSys.cacheManager()->cachedFilename(
_pointsFilename
);
const bool hasCachedFile = std::filesystem::is_regular_file(cachedPointsFile);
if (hasCachedFile) {
LINFO(fmt::format("Cached file '{}' used for galaxy point file '{}'",
cachedPointsFile, _pointsFilename
LINFO(fmt::format("Cached file {} used for galaxy point file {}",
cachedPointsFile, std::filesystem::path(_pointsFilename)
));
Result res = loadCachedFile(cachedPointsFile);
@@ -730,17 +731,19 @@ RenderableGalaxy::Result RenderableGalaxy::loadPointFile() {
return res;
}
RenderableGalaxy::Result RenderableGalaxy::loadCachedFile(const std::string& file) {
RenderableGalaxy::Result RenderableGalaxy::loadCachedFile(
const std::filesystem::path& file)
{
std::ifstream fileStream(file, std::ifstream::binary);
if (!fileStream.good()) {
LERROR(fmt::format("Error opening file '{}' for loading cache file", file));
LERROR(fmt::format("Error opening file {} for loading cache file", file));
return { false, {}, {} };
}
int8_t cacheVersion;
fileStream.read(reinterpret_cast<char*>(&cacheVersion), sizeof(int8_t));
if (cacheVersion != CurrentCacheVersion) {
LINFO(fmt::format("Removing cache file '{}' as the version changed"));
LINFO(fmt::format("Removing cache file {} as the version changed", file));
return { false, {}, {} };
}

View File

@@ -64,7 +64,7 @@ private:
std::vector<glm::vec3> color;
};
Result loadPointFile();
Result loadCachedFile(const std::string& file);
Result loadCachedFile(const std::filesystem::path& file);
glm::vec3 _volumeSize = glm::vec3(0.f);
glm::vec3 _pointScaling = glm::vec3(0.f);

View File

@@ -306,15 +306,15 @@ void GlobeLabelsComponent::initializeFonts() {
);
}
bool GlobeLabelsComponent::loadLabelsData(const std::string& file) {
std::string cachedFile = FileSys.cacheManager()->cachedFilename(
bool GlobeLabelsComponent::loadLabelsData(const std::filesystem::path& file) {
std::filesystem::path cachedFile = FileSys.cacheManager()->cachedFilename(
file,
"GlobeLabelsComponent|" + identifier()
);
bool hasCachedFile = std::filesystem::is_regular_file(cachedFile);
if (hasCachedFile) {
LINFO(fmt::format("Cached file '{}' used for labels file: {}", cachedFile, file));
LINFO(fmt::format("Cached file {} used for labels file {}", cachedFile, file));
const bool hasCache = loadCachedFile(cachedFile);
if (hasCache) {
@@ -327,9 +327,9 @@ bool GlobeLabelsComponent::loadLabelsData(const std::string& file) {
}
}
else {
LINFO(fmt::format("Cache for labels file '{}' not found", file));
LINFO(fmt::format("Cache for labels file {} not found", file));
}
LINFO(fmt::format("Loading labels file '{}'", file));
LINFO(fmt::format("Loading labels file {}", file));
bool success = readLabelsFile(file);
if (success) {
@@ -338,11 +338,11 @@ bool GlobeLabelsComponent::loadLabelsData(const std::string& file) {
return success;
}
bool GlobeLabelsComponent::readLabelsFile(const std::string& file) {
bool GlobeLabelsComponent::readLabelsFile(const std::filesystem::path& file) {
try {
std::fstream csvLabelFile(file);
if (!csvLabelFile.good()) {
LERROR(fmt::format("Failed to open labels file '{}'", file));
LERROR(fmt::format("Failed to open labels file {}", file));
return false;
}
if (!csvLabelFile.is_open()) {
@@ -427,16 +427,16 @@ bool GlobeLabelsComponent::readLabelsFile(const std::string& file) {
return true;
}
catch (const std::fstream::failure& e) {
LERROR(fmt::format("Failed reading labels file '{}'", file));
LERROR(fmt::format("Failed reading labels file {}", file));
LERROR(e.what());
return false;
}
}
bool GlobeLabelsComponent::loadCachedFile(const std::string& file) {
bool GlobeLabelsComponent::loadCachedFile(const std::filesystem::path& file) {
std::ifstream fileStream(file, std::ifstream::binary);
if (!fileStream.good()) {
LERROR(fmt::format("Error opening file '{}' for loading cache file", file));
LERROR(fmt::format("Error opening file {} for loading cache file", file));
return false;
}
@@ -463,10 +463,10 @@ bool GlobeLabelsComponent::loadCachedFile(const std::string& file) {
return fileStream.good();
}
bool GlobeLabelsComponent::saveCachedFile(const std::string& file) const {
bool GlobeLabelsComponent::saveCachedFile(const std::filesystem::path& file) const {
std::ofstream fileStream(file, std::ofstream::binary);
if (!fileStream.good()) {
LERROR(fmt::format("Error opening file '{}' for save cache file", file));
LERROR(fmt::format("Error opening file {} for save cache file", file));
return false;
}
fileStream.write(reinterpret_cast<const char*>(&CurrentCacheVersion), sizeof(int8_t));

View File

@@ -62,10 +62,10 @@ public:
void draw(const RenderData& data);
private:
bool loadLabelsData(const std::string& file);
bool readLabelsFile(const std::string& file);
bool loadCachedFile(const std::string& file);
bool saveCachedFile(const std::string& file) const;
bool loadLabelsData(const std::filesystem::path& file);
bool readLabelsFile(const std::filesystem::path& file);
bool loadCachedFile(const std::filesystem::path& file);
bool saveCachedFile(const std::filesystem::path& file) const;
void renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix,
float distToCamera, float fadeInVariable);
bool isLabelInFrustum(const glm::dmat4& MVMatrix, const glm::dvec3& position) const;

View File

@@ -620,7 +620,7 @@ void RingsComponent::loadTexture() {
if (texture) {
LDEBUGC(
"RingsComponent",
fmt::format("Loaded texture from '{}'", absPath(_texturePath))
fmt::format("Loaded texture from {}", absPath(_texturePath))
);
_texture = std::move(texture);
@@ -643,7 +643,7 @@ void RingsComponent::loadTexture() {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded forwards scattering texture from '{}'",
"Loaded forwards scattering texture from {}",
absPath(_textureFwrdPath)
)
);
@@ -669,7 +669,7 @@ void RingsComponent::loadTexture() {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded backwards scattering texture from '{}'",
"Loaded backwards scattering texture from {}",
absPath(_textureBckwrdPath)
)
);
@@ -694,10 +694,7 @@ void RingsComponent::loadTexture() {
if (textureUnlit) {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded unlit texture from '{}'",
absPath(_textureUnlitPath)
)
fmt::format("Loaded unlit texture from {}", absPath(_textureUnlitPath))
);
_textureUnlit = std::move(textureUnlit);
@@ -719,10 +716,7 @@ void RingsComponent::loadTexture() {
if (textureColor) {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded color texture from '{}'",
absPath(_textureColorPath)
)
fmt::format("Loaded color texture from {}", absPath(_textureColorPath))
);
_textureColor = std::move(textureColor);
@@ -744,10 +738,7 @@ void RingsComponent::loadTexture() {
if (textureTransparency) {
LDEBUGC(
"RingsComponent",
fmt::format(
"Loaded unlit texture from '{}'",
absPath(_textureUnlitPath)
)
fmt::format("Loaded unlit texture from {}", absPath(_textureUnlitPath))
);
_textureTransparency = std::move(textureTransparency);

View File

@@ -204,17 +204,17 @@ void GUI::deinitialize() {
}
void GUI::initializeGL() {
std::string cachedFile = FileSys.cacheManager()->cachedFilename(
std::filesystem::path cachedFile = FileSys.cacheManager()->cachedFilename(
configurationFile,
""
);
LDEBUG(fmt::format("Using {} as ImGUI cache location", cachedFile));
iniFileBuffer = new char[cachedFile.size() + 1];
iniFileBuffer = new char[cachedFile.string().size() + 1];
#ifdef WIN32
strcpy_s(iniFileBuffer, cachedFile.size() + 1, cachedFile.c_str());
strcpy_s(iniFileBuffer, cachedFile.string().size() + 1, cachedFile.string().c_str());
#else
strcpy(iniFileBuffer, cachedFile.c_str());
#endif

View File

@@ -332,7 +332,7 @@ void RenderableKameleonVolume::load() {
loadFromPath(_sourcePath);
return;
}
std::string cachePath = FileSys.cacheManager()->cachedFilename(
std::filesystem::path cachePath = FileSys.cacheManager()->cachedFilename(
std::filesystem::path(_sourcePath.value()).stem(),
cacheSuffix()
);
@@ -360,7 +360,7 @@ void RenderableKameleonVolume::loadFromPath(const std::string& path) {
}
}
void RenderableKameleonVolume::loadRaw(const std::string& path) {
void RenderableKameleonVolume::loadRaw(const std::filesystem::path& path) {
volume::RawVolumeReader<float> reader(path, _dimensions);
_rawVolume = reader.read();
updateTextureFromVolume();
@@ -433,7 +433,7 @@ void RenderableKameleonVolume::updateTextureFromVolume() {
_volumeTexture->setPixelData(data, ghoul::opengl::Texture::TakeOwnership::No);
}
void RenderableKameleonVolume::storeRaw(const std::string& path) {
void RenderableKameleonVolume::storeRaw(const std::filesystem::path& path) {
volume::RawVolumeWriter<float> writer(path);
writer.write(*_rawVolume);
}

View File

@@ -62,9 +62,9 @@ public:
private:
void load();
void loadFromPath(const std::string& path);
void loadRaw(const std::string& path);
void loadRaw(const std::filesystem::path& path);
void loadCdf(const std::string& path);
void storeRaw(const std::string& path);
void storeRaw(const std::filesystem::path& path);
std::string cacheSuffix() const;
void updateTextureFromVolume();

View File

@@ -179,7 +179,7 @@ bool ErrorHistogramManager::buildFromLeaf(unsigned int bstOffset,
return true;
}
bool ErrorHistogramManager::loadFromFile(const std::string& filename) {
bool ErrorHistogramManager::loadFromFile(const std::filesystem::path& filename) {
std::ifstream file(filename, std::ios::in | std::ios::binary);
if (!file.is_open()) {
return false;
@@ -210,7 +210,7 @@ bool ErrorHistogramManager::loadFromFile(const std::string& filename) {
}
bool ErrorHistogramManager::saveToFile(const std::string& filename) {
bool ErrorHistogramManager::saveToFile(const std::filesystem::path& filename) {
std::ofstream file(filename, std::ios::out | std::ios::binary);
if (!file.is_open()) {
return false;

View File

@@ -27,6 +27,7 @@
#include <openspace/util/histogram.h>
#include <ghoul/glm.h>
#include <filesystem>
#include <iosfwd>
#include <map>
@@ -42,8 +43,8 @@ public:
bool buildHistograms(int numBins);
const Histogram* histogram(unsigned int brickIndex) const;
bool loadFromFile(const std::string& filename);
bool saveToFile(const std::string& filename);
bool loadFromFile(const std::filesystem::path& filename);
bool saveToFile(const std::filesystem::path& filename);
private:
TSP* _tsp;

View File

@@ -121,7 +121,7 @@ std::vector<float> HistogramManager::readValues(TSP* tsp, unsigned int brickInde
return voxelValues;
}
bool HistogramManager::loadFromFile(const std::string& filename) {
bool HistogramManager::loadFromFile(const std::filesystem::path& filename) {
std::ifstream file(filename, std::ios::in | std::ios::binary);
if (!file.is_open()) {
return false;
@@ -151,7 +151,7 @@ bool HistogramManager::loadFromFile(const std::string& filename) {
return true;
}
bool HistogramManager::saveToFile(const std::string& filename) {
bool HistogramManager::saveToFile(const std::filesystem::path& filename) {
std::ofstream file(filename, std::ios::out | std::ios::binary);
if (!file.is_open()) {
return false;

View File

@@ -26,6 +26,7 @@
#define __OPENSPACE_MODULE_MULTIRESVOLUME___HISTOGRAMMANAGER___H__
#include <openspace/util/histogram.h>
#include <filesystem>
#include <string>
namespace openspace {
@@ -36,8 +37,8 @@ class HistogramManager {
public:
bool buildHistograms(TSP* tsp, int numBins);
Histogram* histogram(unsigned int brickIndex);
bool loadFromFile(const std::string& filename);
bool saveToFile(const std::string& filename);
bool loadFromFile(const std::filesystem::path& filename);
bool saveToFile(const std::filesystem::path& filename);
private:
bool buildHistogram(TSP* tsp, unsigned int brickIndex);

View File

@@ -305,7 +305,7 @@ bool LocalErrorHistogramManager::buildFromBstChild(unsigned int bstOffset,
return true;
}
bool LocalErrorHistogramManager::loadFromFile(const std::string& filename) {
bool LocalErrorHistogramManager::loadFromFile(const std::filesystem::path& filename) {
std::ifstream file(filename, std::ios::in | std::ios::binary);
if (!file.is_open()) {
return false;
@@ -344,7 +344,7 @@ bool LocalErrorHistogramManager::loadFromFile(const std::string& filename) {
}
bool LocalErrorHistogramManager::saveToFile(const std::string& filename) {
bool LocalErrorHistogramManager::saveToFile(const std::filesystem::path& filename) {
std::ofstream file(filename, std::ios::out | std::ios::binary);
if (!file.is_open()) {
return false;

View File

@@ -27,6 +27,7 @@
#include <openspace/util/histogram.h>
#include <ghoul/glm.h>
#include <filesystem>
#include <iosfwd>
#include <map>
@@ -42,8 +43,8 @@ public:
const Histogram* spatialHistogram(unsigned int brickIndex) const;
const Histogram* temporalHistogram(unsigned int brickIndex) const;
bool loadFromFile(const std::string& filename);
bool saveToFile(const std::string& filename);
bool loadFromFile(const std::filesystem::path& filename);
bool saveToFile(const std::filesystem::path& filename);
private:
TSP* _tsp = nullptr;

View File

@@ -455,21 +455,21 @@ bool RenderableMultiresVolume::initializeSelector() {
switch (_selector) {
case Selector::TF:
if (_errorHistogramManager) {
std::string cacheFilename = FileSys.cacheManager()->cachedFilename(
std::filesystem::path cached = FileSys.cacheManager()->cachedFilename(
fmt::format(
"{}_{}_errorHistograms",
std::filesystem::path(_filename).stem().string(), nHistograms
),
""
);
std::ifstream cacheFile(cacheFilename, std::ios::in | std::ios::binary);
std::ifstream cacheFile(cached, std::ios::in | std::ios::binary);
if (cacheFile.is_open()) {
// Read histograms from cache.
cacheFile.close();
LINFO(
fmt::format("Loading histograms from cache: {}", cacheFilename)
fmt::format("Loading histograms from cache: {}", cached)
);
success &= _errorHistogramManager->loadFromFile(cacheFilename);
success &= _errorHistogramManager->loadFromFile(cached);
}
else if (!_errorHistogramsPath.empty()) {
// Read histograms from scene data.
@@ -482,11 +482,11 @@ bool RenderableMultiresVolume::initializeSelector() {
}
else {
// Build histograms from tsp file.
LWARNING(fmt::format("Failed to open {}", cacheFilename));
LWARNING(fmt::format("Failed to open {}", cached));
success &= _errorHistogramManager->buildHistograms(nHistograms);
if (success) {
LINFO(fmt::format("Writing cache to {}", cacheFilename));
_errorHistogramManager->saveToFile(cacheFilename);
LINFO(fmt::format("Writing cache to {}", cached));
_errorHistogramManager->saveToFile(cached);
}
}
success &= _tfBrickSelector && _tfBrickSelector->initialize();
@@ -495,29 +495,29 @@ bool RenderableMultiresVolume::initializeSelector() {
case Selector::SIMPLE:
if (_histogramManager) {
std::string cacheFilename = FileSys.cacheManager()->cachedFilename(
std::filesystem::path cached = FileSys.cacheManager()->cachedFilename(
fmt::format("{}_{}_histogram",
std::filesystem::path(_filename).stem().string(), nHistograms
),
""
);
std::ifstream cacheFile(cacheFilename, std::ios::in | std::ios::binary);
std::ifstream cacheFile(cached, std::ios::in | std::ios::binary);
if (cacheFile.is_open()) {
// Read histograms from cache.
cacheFile.close();
LINFO(fmt::format("Loading histograms from {}", cacheFilename));
success &= _histogramManager->loadFromFile(cacheFilename);
LINFO(fmt::format("Loading histograms from {}", cached));
success &= _histogramManager->loadFromFile(cached);
}
else {
// Build histograms from tsp file.
LWARNING(fmt::format("Failed to open '{}'", cacheFilename));
LWARNING(fmt::format("Failed to open {}", cached));
success &= _histogramManager->buildHistograms(
_tsp.get(),
nHistograms
);
if (success) {
LINFO(fmt::format("Writing cache to {}", cacheFilename));
_histogramManager->saveToFile(cacheFilename);
LINFO(fmt::format("Writing cache to {}", cached));
_histogramManager->saveToFile(cached);
}
}
success &= _simpleTfBrickSelector && _simpleTfBrickSelector->initialize();
@@ -526,27 +526,27 @@ bool RenderableMultiresVolume::initializeSelector() {
case Selector::LOCAL:
if (_localErrorHistogramManager) {
std::string cacheFilename = FileSys.cacheManager()->cachedFilename(
std::filesystem::path cached = FileSys.cacheManager()->cachedFilename(
fmt::format(
"{}_{}_localErrorHistograms",
std::filesystem::path(_filename).stem().string(), nHistograms
),
""
);
std::ifstream cacheFile(cacheFilename, std::ios::in | std::ios::binary);
std::ifstream cacheFile(cached, std::ios::in | std::ios::binary);
if (cacheFile.is_open()) {
// Read histograms from cache.
cacheFile.close();
LINFO(fmt::format("Loading histograms from {}", cacheFilename));
success &= _localErrorHistogramManager->loadFromFile(cacheFilename);
LINFO(fmt::format("Loading histograms from {}", cached));
success &= _localErrorHistogramManager->loadFromFile(cached);
}
else {
// Build histograms from tsp file.
LWARNING(fmt::format("Failed to open {}", cacheFilename));
LWARNING(fmt::format("Failed to open {}", cached));
success &= _localErrorHistogramManager->buildHistograms(nHistograms);
if (success) {
LINFO(fmt::format("Writing cache to {}", cacheFilename));
_localErrorHistogramManager->saveToFile(cacheFilename);
LINFO(fmt::format("Writing cache to {}", cached));
_localErrorHistogramManager->saveToFile(cached);
}
}
success &= _localTfBrickSelector && _localTfBrickSelector->initialize();

View File

@@ -507,7 +507,7 @@ bool TSP::readCache() {
if (!FileSys.cacheManager())
return false;
std::string cacheFilename = FileSys.cacheManager()->cachedFilename(
std::filesystem::path cacheFilename = FileSys.cacheManager()->cachedFilename(
std::filesystem::path(_filename).stem(),
""
);
@@ -545,7 +545,7 @@ bool TSP::writeCache() {
return false;
}
std::string cacheFilename = FileSys.cacheManager()->cachedFilename(
std::filesystem::path cacheFilename = FileSys.cacheManager()->cachedFilename(
std::filesystem::path(_filename).stem(),
""
);

View File

@@ -865,7 +865,7 @@ void RenderableStars::loadPSFTexture() {
if (_pointSpreadFunctionTexture) {
LDEBUG(fmt::format(
"Loaded texture from '{}'", absPath(_pointSpreadFunctionTexturePath)
"Loaded texture from {}", absPath(_pointSpreadFunctionTexturePath)
));
_pointSpreadFunctionTexture->uploadTexture();
}
@@ -1267,10 +1267,7 @@ void RenderableStars::update(const UpdateData&) {
absPath(_colorTexturePath).string()
);
if (_colorTexture) {
LDEBUG(fmt::format(
"Loaded texture from '{}'",
absPath(_colorTexturePath)
));
LDEBUG(fmt::format("Loaded texture from {}", absPath(_colorTexturePath)));
_colorTexture->uploadTexture();
}
@@ -1293,7 +1290,7 @@ void RenderableStars::update(const UpdateData&) {
);
if (_otherDataColorMapTexture) {
LDEBUG(fmt::format(
"Loaded texture from '{}'",
"Loaded texture from {}",
absPath(_otherDataColorMapPath)
));
_otherDataColorMapTexture->uploadTexture();

View File

@@ -99,23 +99,21 @@ namespace {
std::is_same_v<T, openspace::speck::ColorMap>
);
std::string cachePath = FileSys.cacheManager()->cachedFilename(speckPath);
std::filesystem::path cached = FileSys.cacheManager()->cachedFilename(speckPath);
if (std::filesystem::exists(cachePath)) {
if (std::filesystem::exists(cached)) {
LINFOC(
"SpeckLoader",
fmt::format(
"Cached file '{}' used for file {}", cachePath, speckPath
)
fmt::format("Cached file {} used for file {}", cached, speckPath)
);
std::optional<T> dataset = loadCacheFunction(cachePath);
std::optional<T> dataset = loadCacheFunction(cached);
if (dataset.has_value()) {
// We could load the cache file and we are now done with this
return *dataset;
}
else {
FileSys.cacheManager()->removeCacheFile(cachePath);
FileSys.cacheManager()->removeCacheFile(cached);
}
}
LINFOC("SpeckLoader", fmt::format("Loading file {}", speckPath));
@@ -123,7 +121,7 @@ namespace {
if (!dataset.entries.empty()) {
LINFOC("SpeckLoader", "Saving cache");
saveCacheFunction(dataset, cachePath);
saveCacheFunction(dataset, cached);
}
return dataset;
}
@@ -547,7 +545,7 @@ Labelset loadFile(std::filesystem::path path, SkipAllZeroLines) {
std::ifstream file(path);
if (!file.good()) {
throw ghoul::RuntimeError(fmt::format("Failed to open speck file '{}'", path));
throw ghoul::RuntimeError(fmt::format("Failed to open speck file {}", path));
}
Labelset res;
@@ -582,7 +580,7 @@ Labelset loadFile(std::filesystem::path path, SkipAllZeroLines) {
// included in the speck file)
if (res.textColorIndex != -1) {
throw ghoul::RuntimeError(fmt::format(
"Error loading label file '{}': Textcolor defined twice", path
"Error loading label file {}: Textcolor defined twice", path
));
}
@@ -621,7 +619,7 @@ Labelset loadFile(std::filesystem::path path, SkipAllZeroLines) {
// data section of the file
if (!std::isdigit(line[0]) && line[0] != '-') {
throw ghoul::RuntimeError(fmt::format(
"Error loading label file '{}': Header information and datasegment "
"Error loading label file {}: Header information and datasegment "
"intermixed", path
));
}
@@ -640,7 +638,7 @@ Labelset loadFile(std::filesystem::path path, SkipAllZeroLines) {
if (!startsWith(rest, "text")) {
throw ghoul::RuntimeError(fmt::format(
"Error loading label file '{}': File contains some value between "
"Error loading label file {}: File contains some value between "
"positions and text label, which is unsupported", path
));
}
@@ -755,7 +753,7 @@ ColorMap loadFile(std::filesystem::path path, SkipAllZeroLines) {
std::ifstream file(path);
if (!file.good()) {
throw ghoul::RuntimeError(fmt::format("Failed to open speck file '{}'", path));
throw ghoul::RuntimeError(fmt::format("Failed to open speck file {}", path));
}
ColorMap res;

View File

@@ -113,17 +113,15 @@ glm::dvec3 HorizonsTranslation::position(const UpdateData& data) const {
}
void HorizonsTranslation::loadData() {
std::string file = _horizonsTextFile;
if (!std::filesystem::is_regular_file(absPath(file))) {
std::filesystem::path file = absPath(_horizonsTextFile.value());
if (!std::filesystem::is_regular_file(file)) {
return;
}
std::string cachedFile = FileSys.cacheManager()->cachedFilename(file);
std::filesystem::path cachedFile = FileSys.cacheManager()->cachedFilename(file);
bool hasCachedFile = std::filesystem::is_regular_file(cachedFile);
if (hasCachedFile) {
LINFO(fmt::format(
"Cached file '{}' used for Horizon file '{}'", cachedFile, file
));
LINFO(fmt::format("Cached file {} used for Horizon file {}", cachedFile, file));
bool success = loadCachedFile(cachedFile);
if (success) {
@@ -136,9 +134,9 @@ void HorizonsTranslation::loadData() {
}
}
else {
LINFO(fmt::format("Cache for Horizon file '{}' not found", file));
LINFO(fmt::format("Cache for Horizon file {} not found", file));
}
LINFO(fmt::format("Loading Horizon file '{}'", file));
LINFO(fmt::format("Loading Horizon file {}", file));
readHorizonsTextFile();
@@ -147,12 +145,11 @@ void HorizonsTranslation::loadData() {
}
void HorizonsTranslation::readHorizonsTextFile() {
std::ifstream fileStream(_horizonsTextFile);
std::filesystem::path f = absPath(_horizonsTextFile);
std::ifstream fileStream(f);
if (!fileStream.good()) {
LERROR(fmt::format(
"Failed to open Horizons text file '{}'", _horizonsTextFile
));
LERROR(fmt::format("Failed to open Horizons text file {}", f));
return;
}
@@ -202,11 +199,11 @@ void HorizonsTranslation::readHorizonsTextFile() {
fileStream.close();
}
bool HorizonsTranslation::loadCachedFile(const std::string& file) {
bool HorizonsTranslation::loadCachedFile(const std::filesystem::path& file) {
std::ifstream fileStream(file, std::ifstream::binary);
if (!fileStream.good()) {
LERROR(fmt::format("Error opening file '{}' for loading cache file", file));
LERROR(fmt::format("Error opening file {} for loading cache file", file));
return false;
}
@@ -241,10 +238,10 @@ bool HorizonsTranslation::loadCachedFile(const std::string& file) {
return fileStream.good();
}
void HorizonsTranslation::saveCachedFile(const std::string& file) const {
void HorizonsTranslation::saveCachedFile(const std::filesystem::path& file) const {
std::ofstream fileStream(file, std::ofstream::binary);
if (!fileStream.good()) {
LERROR(fmt::format("Error opening file '{}' for save cache file", file));
LERROR(fmt::format("Error opening file {} for save cache file", file));
return;
}

View File

@@ -61,8 +61,8 @@ public:
private:
void loadData();
void readHorizonsTextFile();
bool loadCachedFile(const std::string& file);
void saveCachedFile(const std::string& file) const;
bool loadCachedFile(const std::filesystem::path& file);
void saveCachedFile(const std::filesystem::path& file) const;
properties::StringProperty _horizonsTextFile;
std::unique_ptr<ghoul::filesystem::File> _fileHandle;

View File

@@ -166,7 +166,9 @@ bool LabelParser::create() {
std::ifstream file(path);
if (!file.good()) {
LERROR(fmt::format("Failed to open label file '{}'", path));
LERROR(fmt::format(
"Failed to open label file {}", std::filesystem::path(path)
));
return false;
}

View File

@@ -26,6 +26,7 @@
#define __OPENSPACE_MODULE_VOLUME___RAWVOLUMEREADER___H__
#include <ghoul/glm.h>
#include <filesystem>
#include <string>
namespace openspace::volume {
@@ -37,11 +38,11 @@ class RawVolumeReader {
public:
using VoxelType = Type;
RawVolumeReader(const std::string& path, const glm::uvec3& dimensions);
RawVolumeReader(const std::filesystem::path& path, const glm::uvec3& dimensions);
glm::uvec3 dimensions() const;
std::string path() const;
void setPath(const std::string& path);
std::filesystem::path path() const;
void setPath(std::filesystem::path path);
void setDimensions(const glm::uvec3& dimensions);
//VoxelType get(const glm::ivec3& coordinates) const; // TODO: Implement this
//VoxelType get(const size_t index) const; // TODO: Implement this
@@ -51,7 +52,7 @@ private:
size_t coordsToIndex(const glm::uvec3& cartesian) const;
glm::uvec3 indexToCoords(size_t linear) const;
glm::uvec3 _dimensions;
std::string _path;
std::filesystem::path _path;
};
} // namespace openspace::volume

View File

@@ -28,10 +28,10 @@
namespace openspace::volume {
template <typename VoxelType>
RawVolumeReader<VoxelType>::RawVolumeReader(const std::string& path,
RawVolumeReader<VoxelType>::RawVolumeReader(const std::filesystem::path& path,
const glm::uvec3& dimensions)
: _dimensions(dimensions)
, _path(path)
, _path(std::move(path))
{}
template <typename VoxelType>
@@ -45,16 +45,15 @@ void RawVolumeReader<VoxelType>::setDimensions(const glm::uvec3& dimensions) {
}
template <typename VoxelType>
std::string RawVolumeReader<VoxelType>::path() const {
std::filesystem::path RawVolumeReader<VoxelType>::path() const {
return _path;
}
template <typename VoxelType>
void RawVolumeReader<VoxelType>::setPath(const std::string& path) {
_path = path;
void RawVolumeReader<VoxelType>::setPath(std::filesystem::path path) {
_path = std::move(path);
}
/*
TODO: Implement these methods for random access in raw volume file
template <typename VoxelType>

View File

@@ -25,6 +25,7 @@
#ifndef __OPENSPACE_MODULE_VOLUME___RAWVOLUMEWRITER___H__
#define __OPENSPACE_MODULE_VOLUME___RAWVOLUMEWRITER___H__
#include <filesystem>
#include <functional>
#include <string>
@@ -35,9 +36,9 @@ template <typename T> class RawVolume;
template <typename VoxelType>
class RawVolumeWriter {
public:
RawVolumeWriter(std::string path, size_t bufferSize = 1024);
RawVolumeWriter(std::filesystem::path path, size_t bufferSize = 1024);
void setPath(const std::string& path);
void setPath(std::filesystem::path path);
glm::uvec3 dimensions() const;
void setDimensions(glm::uvec3 dimensions);
void write(const std::function<VoxelType(const glm::uvec3&)>& fn,
@@ -49,7 +50,7 @@ public:
private:
glm::ivec3 _dimensions = glm::ivec3(0);
std::string _path;
std::filesystem::path _path;
size_t _bufferSize = 0;
};

View File

@@ -25,12 +25,13 @@
#include <modules/volume/rawvolume.h>
#include <modules/volume/volumeutils.h>
#include <ghoul/misc/exception.h>
#include <ghoul/fmt.h>
#include <fstream>
namespace openspace::volume {
template <typename VoxelType>
RawVolumeWriter<VoxelType>::RawVolumeWriter(std::string path, size_t bufferSize)
RawVolumeWriter<VoxelType>::RawVolumeWriter(std::filesystem::path path, size_t bufferSize)
: _path(std::move(path))
, _bufferSize(bufferSize)
{}
@@ -99,7 +100,7 @@ void RawVolumeWriter<VoxelType>::write(const RawVolume<VoxelType>& volume) {
std::ofstream file(_path, std::ios::binary);
if (!file.good()) {
throw ghoul::RuntimeError("Could not create file '" + _path + "'");
throw ghoul::RuntimeError(fmt::format("Could not create file {}", _path));
}
file.write(buffer, length);

View File

@@ -1092,7 +1092,7 @@ void OpenSpaceEngine::preSynchronization() {
global::memoryManager->TemporaryMemory.reset();
if (_hasScheduledAssetLoading) {
LINFO(fmt::format("Loading asset: {}", _scheduledAssetPathToLoad));
LINFO(fmt::format("Loading asset: {}", absPath(_scheduledAssetPathToLoad)));
global::profile->setIgnoreUpdates(true);
loadSingleAsset(_scheduledAssetPathToLoad);
global::profile->setIgnoreUpdates(false);

View File

@@ -332,7 +332,10 @@ int createSingleColorImage(lua_State* L) {
const glm::dvec3 color = colorDict.value<glm::dvec3>(key);
std::string fileName = FileSys.cacheManager()->cachedFilename(name + ".ppm", "");
std::filesystem::path fileName = FileSys.cacheManager()->cachedFilename(
name + ".ppm",
""
);
const bool hasCachedFile = std::filesystem::is_regular_file(fileName);
if (hasCachedFile) {
LDEBUGC("OpenSpaceEngine", fmt::format("Cached file '{}' used", fileName));

View File

@@ -170,7 +170,10 @@ LuaConsole::~LuaConsole() {} // NOLINT
void LuaConsole::initialize() {
ZoneScoped
const std::string filename = FileSys.cacheManager()->cachedFilename(HistoryFile, "");
const std::filesystem::path filename = FileSys.cacheManager()->cachedFilename(
HistoryFile,
""
);
if (std::filesystem::is_regular_file(filename)) {
std::ifstream file(filename, std::ios::binary | std::ios::in);
@@ -230,7 +233,10 @@ void LuaConsole::initialize() {
void LuaConsole::deinitialize() {
ZoneScoped
const std::string filename = FileSys.cacheManager()->cachedFilename(HistoryFile, "");
const std::filesystem::path filename = FileSys.cacheManager()->cachedFilename(
HistoryFile,
""
);
// We want to limit the command history to a realistic value, so that it doesn't
// grow without bounds

View File

@@ -86,7 +86,7 @@ void TextureComponent::loadFromFile(const std::filesystem::path& path) {
);
if (texture) {
LDEBUG(fmt::format("Loaded texture from '{}'", absPath(path.string())));
LDEBUG(fmt::format("Loaded texture from {}", absPath(path.string())));
_texture = std::move(texture);
_textureFile = std::make_unique<ghoul::filesystem::File>(path);

View File

@@ -502,7 +502,7 @@ bool Asset::initialize() {
LERROR(fmt::format("Cannot initialize unsynchronized asset {}", id()));
return false;
}
LDEBUG(fmt::format("Initializing asset {}", id()));
LDEBUG(fmt::format("Initializing asset '{}'", id()));
// 1. Initialize requirements
for (const std::shared_ptr<Asset>& child : _requiredAssets) {
@@ -593,7 +593,7 @@ void Asset::deinitialize() {
if (!isInitialized()) {
return;
}
LDEBUG(fmt::format("Deintializing asset {}", id()));
LDEBUG(fmt::format("Deintializing asset '{}'", id()));
// Perform inverse actions as in initialize, in reverse order (7 - 1)

View File

@@ -229,7 +229,7 @@ namespace {
// A user-facing description about this scene graph node
std::optional<std::string> description;
// If this value is specified, GUI applications are incouraged to ignore this
// If this value is specified, GUI applications are incouraged to ignore this
// scenegraph node. This is most useful to trim collective lists of nodes and
// not display, for example, barycenters
std::optional<bool> hidden;
@@ -447,7 +447,9 @@ SceneGraphNode::SceneGraphNode()
_overrideBoundingSphere = std::nullopt;
}
});
_boundingSphere.setExponent(10.f);
// @TODO (2021-06-30, emmbr) Uncomment this when exponential sliders support
// negative values
//_boundingSphere.setExponent(10.f);
addProperty(_boundingSphere);
_interactionSphere.onChange([this]() {
if (_interactionSphere >= 0.0) {
@@ -456,8 +458,10 @@ SceneGraphNode::SceneGraphNode()
else {
_overrideInteractionSphere = std::nullopt;
}
});
_interactionSphere.setExponent(10.f);
});
// @TODO (2021-06-30, emmbr) Uncomment this when exponential sliders support
// negative values
//_interactionSphere.setExponent(10.f);
addProperty(_interactionSphere);
addProperty(_showDebugSphere);
}

View File

@@ -214,15 +214,11 @@ bool ScriptEngine::runScript(const std::string& script, ScriptCallback callback)
return true;
}
bool ScriptEngine::runScriptFile(const std::string& filename) {
bool ScriptEngine::runScriptFile(const std::filesystem::path& filename) {
ZoneScoped
if (filename.empty()) {
LWARNING("Filename was empty");
return false;
}
if (!std::filesystem::is_regular_file(filename)) {
LERROR(fmt::format("Script with name '{}' did not exist", filename));
LERROR(fmt::format("Script with name {} did not exist", filename));
return false;
}
@@ -649,14 +645,17 @@ bool ScriptEngine::writeLog(const std::string& script) {
_logFilename = absPath(global::configuration->scriptLog).string();
_logFileExists = true;
LDEBUG(fmt::format("Using script log file '{}'", _logFilename));
LDEBUG(fmt::format(
"Using script log file {}", std::filesystem::path(_logFilename)
));
// Test file and clear previous input
std::ofstream file(_logFilename, std::ofstream::out | std::ofstream::trunc);
if (!file.good()) {
LERROR(fmt::format(
"Could not open file '{}' for logging scripts", _logFilename
"Could not open file {} for logging scripts",
std::filesystem::path(_logFilename)
));
return false;

View File

@@ -204,13 +204,13 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) {
ghoul_assert(!filePath.empty(), "Empty file path");
ghoul_assert(
std::filesystem::is_regular_file(filePath),
fmt::format("File '{}' ('{}') does not exist", filePath, absPath(filePath))
fmt::format("File '{}' ({}) does not exist", filePath, absPath(filePath))
);
ghoul_assert(
std::filesystem::is_directory(std::filesystem::path(filePath).parent_path()),
fmt::format(
"File '{}' exists, but directory '{}' doesn't",
absPath(filePath), std::filesystem::path(filePath).parent_path().string()
"File {} exists, but directory {} does not",
absPath(filePath), std::filesystem::path(filePath).parent_path()
)
);
@@ -234,7 +234,7 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) {
std::filesystem::path p = std::filesystem::path(path).parent_path();
std::filesystem::current_path(p);
LINFO(fmt::format("Loading SPICE kernel '{}'", path));
LINFO(fmt::format("Loading SPICE kernel {}", path));
// Load the kernel
furnsh_c(path.string().c_str());
@@ -273,7 +273,7 @@ void SpiceManager::unloadKernel(KernelHandle kernelId) {
// If there was only one part interested in the kernel, we can unload it
if (it->refCount == 1) {
// No need to check for errors as we do not allow empty path names
LINFO(fmt::format("Unloading SPICE kernel '{}'", it->path));
LINFO(fmt::format("Unloading SPICE kernel {}", it->path));
unload_c(it->path.c_str());
_loadedKernels.erase(it);
}
@@ -299,7 +299,7 @@ void SpiceManager::unloadKernel(std::string filePath) {
if (it == _loadedKernels.end()) {
if (_useExceptions) {
throw SpiceException(
fmt::format("'{}' did not correspond to a loaded kernel", path)
fmt::format("{} did not correspond to a loaded kernel", path)
);
}
else {
@@ -309,7 +309,7 @@ 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(fmt::format("Unloading SPICE kernel '{}'", path));
LINFO(fmt::format("Unloading SPICE kernel {}", path));
unload_c(path.string().c_str());
_loadedKernels.erase(it);
}
@@ -1011,8 +1011,8 @@ void SpiceManager::findCkCoverage(const std::string& path) {
fmt::format("File '{}' does not exist", path)
);
constexpr unsigned int MaxObj = 256;
constexpr unsigned int WinSiz = 10000;
constexpr unsigned int MaxObj = 1024;
constexpr unsigned int WinSiz = 16384;
#if defined __clang__
#pragma clang diagnostic push
@@ -1070,8 +1070,8 @@ void SpiceManager::findSpkCoverage(const std::string& path) {
fmt::format("File '{}' does not exist", path)
);
constexpr unsigned int MaxObj = 256;
constexpr unsigned int WinSiz = 10000;
constexpr unsigned int MaxObj = 1024;
constexpr unsigned int WinSiz = 16384;
#if defined __clang__
#pragma clang diagnostic push