Change ALL_CAPS constants to camelCase

This commit is contained in:
Oskar Carlbaum
2017-10-18 23:29:09 +02:00
parent 1a00d8a34f
commit ecc760ac12
10 changed files with 356 additions and 363 deletions

View File

@@ -31,13 +31,12 @@
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
namespace {
std::string _loggerCat = "RenderableFieldlinesSequence";
const GLuint _VA_POSITION = 0; // MUST CORRESPOND TO THE SHADER PROGRAM
const GLuint _VA_COLOR = 1; // MUST CORRESPOND TO THE SHADER PROGRAM
const GLuint _VA_MASKING = 2; // MUST CORRESPOND TO THE SHADER PROGRAM
const GLuint VaPosition = 0; // MUST CORRESPOND TO THE SHADER PROGRAM
const GLuint VaColor = 1; // MUST CORRESPOND TO THE SHADER PROGRAM
const GLuint VaMasking = 2; // MUST CORRESPOND TO THE SHADER PROGRAM
} // namespace
namespace openspace {
@@ -76,23 +75,22 @@ void RenderableFieldlinesSequence::render(const RenderData& data, RendererTasks&
_shaderProgram->activate();
// Calculate Model View MatrixProjection
const glm::dmat4 ROT_MAT = glm::dmat4(data.modelTransform.rotation);
// const glm::mat4 SCALE_TRANSFORM = glm::mat4(1.0); // TODO remove if no use
const glm::dmat4 MODEL_MAT =
const glm::dmat4 rotMat = glm::dmat4(data.modelTransform.rotation);
const glm::dmat4 modelMat =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
ROT_MAT *
rotMat *
glm::dmat4(glm::scale(glm::dmat4(1), glm::dvec3(data.modelTransform.scale)));
const glm::dmat4 MODEL_VIEW_MAT = data.camera.combinedViewMatrix() * MODEL_MAT;
const glm::dmat4 modelViewMat = data.camera.combinedViewMatrix() * modelMat;
_shaderProgram->setUniform("modelViewProjection",
data.camera.sgctInternal.projectionMatrix() * glm::mat4(MODEL_VIEW_MAT));
data.camera.sgctInternal.projectionMatrix() * glm::mat4(modelViewMat));
_shaderProgram->setUniform("colorMethod", _pColorMethod);
_shaderProgram->setUniform("lineColor", _pColorUniform);
_shaderProgram->setUniform("usingDomain", _pDomainEnabled);
_shaderProgram->setUniform("usingMasking", _pMaskingEnabled);
if (_pColorMethod == ColorMethod::BY_QUANTITY) {
if (_pColorMethod == ColorMethod::ByQuantity) {
ghoul::opengl::TextureUnit textureUnit;
textureUnit.activate();
_transferFunction->bind(); // Calls update internally
@@ -120,11 +118,11 @@ void RenderableFieldlinesSequence::render(const RenderData& data, RendererTasks&
bool additiveBlending = false;
if (_pColorABlendEnabled) {
const auto RENDERER = OsEng.renderEngine().rendererImplementation();
bool usingFBufferRenderer = RENDERER ==
const auto renderer = OsEng.renderEngine().rendererImplementation();
bool usingFBufferRenderer = renderer ==
RenderEngine::RendererImplementation::Framebuffer;
bool usingABufferRenderer = RENDERER ==
bool usingABufferRenderer = renderer ==
RenderEngine::RendererImplementation::ABuffer;
if (usingABufferRenderer) {
@@ -163,15 +161,15 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
// This node shouldn't do anything if its been disabled from the gui!
if (_enabled) {
const double CURRENT_TIME = data.time.j2000Seconds();
const double currentTime = data.time.j2000Seconds();
// Check if current time in OpenSpace is within sequence interval
if (isWithinSequenceInterval(CURRENT_TIME)) {
const int NEXT_IDX = _activeTriggerTimeIndex + 1;
if (_activeTriggerTimeIndex < 0 // true => Previous frame was not within the sequence interval
|| CURRENT_TIME < _startTimes[_activeTriggerTimeIndex] // true => OpenSpace has stepped back to a time represented by another state
|| (NEXT_IDX < _nStates && CURRENT_TIME >= _startTimes[NEXT_IDX])) { // true => OpenSpace has stepped forward to a time represented by another state
if (isWithinSequenceInterval(currentTime)) {
const int nextIdx = _activeTriggerTimeIndex + 1;
if (_activeTriggerTimeIndex < 0 // true => Previous frame was not within the sequence interval
|| currentTime < _startTimes[_activeTriggerTimeIndex] // true => OpenSpace has stepped back to a time represented by another state
|| (nextIdx < _nStates && currentTime >= _startTimes[nextIdx])) { // true => OpenSpace has stepped forward to a time represented by another state
updateActiveTriggerTimeIndex(CURRENT_TIME);
updateActiveTriggerTimeIndex(currentTime);
if (_loadingStatesDynamically) {
_mustLoadNewStateFromDisk = true;
@@ -191,9 +189,9 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
if (!_isLoadingStateFromDisk && !_newStateIsReady) {
_isLoadingStateFromDisk = true;
_mustLoadNewStateFromDisk = false;
const std::string FILEPATH = _sourceFiles[_activeTriggerTimeIndex];
std::thread readBinaryThread([this, FILEPATH] {
this->readNewState(FILEPATH);
const std::string filePath = _sourceFiles[_activeTriggerTimeIndex];
std::thread readBinaryThread([this, filePath] {
this->readNewState(filePath);
});
readBinaryThread.detach();
}
@@ -228,13 +226,13 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
}
}
inline bool RenderableFieldlinesSequence::isWithinSequenceInterval(const double CURRENT_TIME) const {
return (CURRENT_TIME >= _startTimes[0]) && (CURRENT_TIME < _sequenceEndTime);
inline bool RenderableFieldlinesSequence::isWithinSequenceInterval(const double currentTime) const {
return (currentTime >= _startTimes[0]) && (currentTime < _sequenceEndTime);
}
// Assumes we already know that CURRENT_TIME is within the sequence interval
void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(const double CURRENT_TIME) {
auto iter = std::upper_bound(_startTimes.begin(), _startTimes.end(), CURRENT_TIME);
// Assumes we already know that currentTime is within the sequence interval
void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(const double currentTime) {
auto iter = std::upper_bound(_startTimes.begin(), _startTimes.end(), currentTime);
if (iter != _startTimes.end()) {
if ( iter != _startTimes.begin()) {
_activeTriggerTimeIndex =
@@ -248,9 +246,9 @@ void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(const double CUR
}
// Reading state from disk. Must be thread safe!
void RenderableFieldlinesSequence::readNewState(const std::string& FILEPATH) {
void RenderableFieldlinesSequence::readNewState(const std::string& filePath) {
_newState = std::make_unique<FieldlinesState>();
if (_newState->loadStateFromOsfls(FILEPATH)) {
if (_newState->loadStateFromOsfls(filePath)) {
_newStateIsReady = true;
}
_isLoadingStateFromDisk = false;
@@ -266,14 +264,14 @@ void RenderableFieldlinesSequence::updateVertexPositionBuffer() {
glBindVertexArray(_vertexArrayObject);
glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer);
const std::vector<glm::vec3>& VERTEX_POS_VEC =
const std::vector<glm::vec3>& vertexPosVec =
_states[_activeStateIndex].vertexPositions();
glBufferData(GL_ARRAY_BUFFER, VERTEX_POS_VEC.size() * sizeof(glm::vec3),
&VERTEX_POS_VEC.front(), GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, vertexPosVec.size() * sizeof(glm::vec3),
&vertexPosVec.front(), GL_STATIC_DRAW);
glEnableVertexAttribArray(_VA_POSITION);
glVertexAttribPointer(_VA_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(VaPosition);
glVertexAttribPointer(VaPosition, 3, GL_FLOAT, GL_FALSE, 0, 0);
unbindGL();
}
@@ -283,15 +281,15 @@ void RenderableFieldlinesSequence::updateVertexColorBuffer() {
glBindBuffer(GL_ARRAY_BUFFER, _vertexColorBuffer);
bool isSuccessful;
const std::vector<float>& QUANTITY_VEC =
const std::vector<float>& quantityVec =
_states[_activeStateIndex].extraQuantity(_pColorQuantity, isSuccessful);
if (isSuccessful) {
glBufferData(GL_ARRAY_BUFFER, QUANTITY_VEC.size() * sizeof(float),
&QUANTITY_VEC.front(), GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, quantityVec.size() * sizeof(float),
&quantityVec.front(), GL_STATIC_DRAW);
glEnableVertexAttribArray(_VA_COLOR);
glVertexAttribPointer(_VA_COLOR, 1, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(VaColor);
glVertexAttribPointer(VaColor, 1, GL_FLOAT, GL_FALSE, 0, 0);
unbindGL();
}
@@ -302,22 +300,18 @@ void RenderableFieldlinesSequence::updateVertexMaskingBuffer() {
glBindBuffer(GL_ARRAY_BUFFER, _vertexMaskingBuffer);
bool isSuccessful;
const std::vector<float>& QUANTITY_VEC =
const std::vector<float>& quantityVec =
_states[_activeStateIndex].extraQuantity(_pMaskingQuantity, isSuccessful);
if (isSuccessful) {
glBufferData(GL_ARRAY_BUFFER, QUANTITY_VEC.size() * sizeof(float),
&QUANTITY_VEC.front(), GL_STATIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, quantityVec.size() * sizeof(float),
&quantityVec.front(), GL_STATIC_DRAW);
glEnableVertexAttribArray(_VA_MASKING);
glVertexAttribPointer(_VA_MASKING, 1, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(VaMasking);
glVertexAttribPointer(VaMasking, 1, GL_FLOAT, GL_FALSE, 0, 0);
unbindGL();
}
}
} // namespace openspace

View File

@@ -59,8 +59,8 @@ public:
private:
// ------------------------------------- ENUMS -------------------------------------//
enum ColorMethod : int { // Used to determine if lines should be colored UNIFORMLY or by an extraQuantity
UNIFORM = 0,
BY_QUANTITY
Uniform = 0,
ByQuantity
};
// ------------------------------------ STRINGS ------------------------------------//
@@ -144,8 +144,8 @@ private:
void extractOptionalInfoFromDictionary(std::string& outputFolderPath);
void extractOsflsInfoFromDictionary();
void extractTriggerTimesFromFileNames();
bool loadJsonStatesIntoRAM(const std::string& OUTPUT_FOLDER);
void loadOsflsStatesIntoRAM(const std::string& OUTPUT_FOLDER);
bool loadJsonStatesIntoRAM(const std::string& outputFolder);
void loadOsflsStatesIntoRAM(const std::string& outputFolder);
void setModelDependentConstants();
void setupProperties();
bool prepareForOsflsStreaming();
@@ -158,13 +158,13 @@ private:
std::vector<glm::vec3>& outVec);
void extractMagnitudeVarsFromStrings(std::vector<std::string>& extraVars,
std::vector<std::string>& extraMagVars);
bool getStatesFromCdfFiles(const std::string& OUTPUT_FOLDER);
bool getStatesFromCdfFiles(const std::string& outputFolder);
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
// ------------------------- FUNCTIONS USED DURING RUNTIME ------------------------ //
inline bool isWithinSequenceInterval(const double CURRENT_TIME) const;
void readNewState(const std::string& FILEPATH);
void updateActiveTriggerTimeIndex(const double CURRENT_TIME);
inline bool isWithinSequenceInterval(const double currentTime) const;
void readNewState(const std::string& filePath);
void updateActiveTriggerTimeIndex(const double currentTime);
void updateVertexPositionBuffer();
void updateVertexColorBuffer();
void updateVertexMaskingBuffer();

View File

@@ -46,29 +46,29 @@ namespace {
// ----- KEYS POSSIBLE IN MODFILE. EXPECTED DATA TYPE OF VALUE IN [BRACKETS] ----- //
// ---------------------------- MANDATORY MODFILE KEYS ---------------------------- //
const char* KEY_INPUT_FILE_TYPE = "InputFileType"; // [STRING] "cdf", "json" or "osfls"
const char* KEY_SOURCE_FOLDER = "SourceFolder"; // [STRING] should be path to folder containing the input files
const char* KeyInputFileType = "InputFileType"; // [STRING] "cdf", "json" or "osfls"
const char* KeySourceFolder = "SourceFolder"; // [STRING] should be path to folder containing the input files
// ---------------------- MANDATORY INPUT TYPE SPECIFIC KEYS ---------------------- //
const char* KEY_CDF_SEED_POINT_FILE = "SeedPointFile"; // [STRING] Path to a .txt file containing seed points
const char* KEY_JSON_SIMULATION_MODEL = "SimulationModel"; // [STRING] Currently supports: "batsrus", "enlil" & "pfss"
const char* KeyCdfSeedPointFile = "SeedPointFile"; // [STRING] Path to a .txt file containing seed points
const char* KeyJsonSimulationModel = "SimulationModel"; // [STRING] Currently supports: "batsrus", "enlil" & "pfss"
// ----------------------- OPTIONAL INPUT TYPE SPECIFIC KEYS ---------------------- //
const char* KEY_CDF_EXTRA_VARIABLES = "ExtraVariables"; // [STRING ARRAY]
const char* KEY_CDF_TRACING_VARIABLE = "TracingVariable"; // [STRING]
const char* KEY_JSON_SCALING_FACTOR = "ScaleToMeters"; // [STRING]
const char* KEY_OSLFS_LOAD_AT_RUNTIME = "LoadAtRuntime"; // [BOOLEAN] If value False => Load in initializing step and store in RAM
const char* KeyCdfExtraVariables = "ExtraVariables"; // [STRING ARRAY]
const char* KeyCdfTracingVariable = "TracingVariable"; // [STRING]
const char* KeyJsonScalingFactor = "ScaleToMeters"; // [STRING]
const char* KeyOslfsLoadAtRuntime = "LoadAtRuntime"; // [BOOLEAN] If value False => Load in initializing step and store in RAM
// ---------------------------- OPTIONAL MODFILE KEYS ---------------------------- //
const char* KEY_COLOR_TABLE_PATHS = "ColorTablePaths"; // [STRING ARRAY] Values should be paths to .txt files
const char* KEY_COLOR_TABLE_RANGES = "ColorTableRanges";// [VEC2 ARRAY] Values should be entered as {X, Y}, where X & Y are numbers
const char* KEY_MASKING_RANGES = "MaskingRanges"; // [VEC2 ARRAY] Values should be entered as {X, Y}, where X & Y are numbers
const char* KEY_OUTPUT_FOLDER = "OutputFolder"; // [STRING] Value should be path to folder where states are saved (JSON/CDF input => osfls output & oslfs input => JSON output)
const char* KeyColorTablePaths = "ColorTablePaths"; // [STRING ARRAY] Values should be paths to .txt files
const char* KeyColorTableRanges = "ColorTableRanges";// [VEC2 ARRAY] Values should be entered as {X, Y}, where X & Y are numbers
const char* KeyMaskingRanges = "MaskingRanges"; // [VEC2 ARRAY] Values should be entered as {X, Y}, where X & Y are numbers
const char* KeyOutputFolder = "OutputFolder"; // [STRING] Value should be path to folder where states are saved (JSON/CDF input => osfls output & oslfs input => JSON output)
// ------------- POSSIBLE STRING VALUES FOR CORRESPONDING MODFILE KEY ------------- //
const char* VALUE_INPUT_FILE_TYPE_CDF = "cdf";
const char* VALUE_INPUT_FILE_TYPE_JSON = "json";
const char* VALUE_INPUT_FILE_TYPE_OSFLS = "osfls";
const char* ValueInputFileTypeCdf = "cdf";
const char* ValueInputFileTypeJson = "json";
const char* ValueInputFileTypeOsfls = "osfls";
// --------------------------------- Property Info -------------------------------- //
static const openspace::properties::Property::PropertyInfo ColorMethodInfo = {
@@ -147,20 +147,20 @@ namespace {
};
enum class SourceFileType : int {
CDF = 0,
JSON,
OSFLS,
INVALID
Cdf = 0,
Json,
Osfls,
Invalid
};
float stringToFloat(const std::string INPUT, const float BACKUP_VALUE = 0.f) {
float stringToFloat(const std::string input, const float backupValue = 0.f) {
float tmp;
try {
tmp = std::stof(INPUT);
tmp = std::stof(input);
} catch (const std::invalid_argument& ia) {
LWARNING("Invalid argument: " << ia.what() << ". '" << INPUT <<
LWARNING("Invalid argument: " << ia.what() << ". '" << input <<
"' is NOT a valid number!");
return BACKUP_VALUE;
return backupValue;
}
return tmp;
}
@@ -168,8 +168,8 @@ namespace {
namespace openspace {
RenderableFieldlinesSequence::RenderableFieldlinesSequence(const ghoul::Dictionary& DICTIONARY)
: Renderable(DICTIONARY),
RenderableFieldlinesSequence::RenderableFieldlinesSequence(const ghoul::Dictionary& dictionary)
: Renderable(dictionary),
_pColorGroup({ "Color" }),
_pColorMethod(ColorMethodInfo, properties::OptionProperty::DisplayType::Radio),
_pColorQuantity(ColorQuantityInfo, properties::OptionProperty::DisplayType::Dropdown),
@@ -201,14 +201,14 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence(const ghoul::Dictiona
_pFocusOnOriginBtn(OriginButtonInfo),
_pJumpToStartBtn(TimeJumpButtonInfo) {
_dictionary = std::make_unique<ghoul::Dictionary>(DICTIONARY);
_dictionary = std::make_unique<ghoul::Dictionary>(dictionary);
}
void RenderableFieldlinesSequence::initialize() {
LINFO("RenderableFieldlinesSequence::initialize()");
// EXTRACT MANDATORY INFORMATION FROM DICTIONARY
SourceFileType sourceFileType = SourceFileType::INVALID;
SourceFileType sourceFileType = SourceFileType::Invalid;
if (!extractMandatoryInfoFromDictionary(sourceFileType)) {
return;
}
@@ -223,19 +223,19 @@ void RenderableFieldlinesSequence::initialize() {
// EXTRACT SOURCE FILE TYPE SPECIFIC INFOMRATION FROM DICTIONARY & GET STATES FROM SOURCE
switch (sourceFileType) {
case SourceFileType::CDF:
case SourceFileType::Cdf:
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
if (!getStatesFromCdfFiles(outputFolderPath)) {
return;
}
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
break;
case SourceFileType::JSON:
case SourceFileType::Json:
if (!loadJsonStatesIntoRAM(outputFolderPath)) {
return;
}
break;
case SourceFileType::OSFLS:
case SourceFileType::Osfls:
extractOsflsInfoFromDictionary();
if (_loadingStatesDynamically) {
if (!prepareForOsflsStreaming()) {
@@ -277,7 +277,7 @@ void RenderableFieldlinesSequence::initialize() {
if (!_shaderProgram) {
LERROR("Shader program failed initialization!");
sourceFileType = SourceFileType::INVALID;
sourceFileType = SourceFileType::Invalid;
}
//------------------ Initialize OpenGL VBOs and VAOs-------------------------------//
@@ -304,34 +304,34 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
// ------------------- EXTRACT MANDATORY VALUES FROM DICTIONARY ------------------- //
std::string inputFileTypeString;
if (!_dictionary->getValue(KEY_INPUT_FILE_TYPE, inputFileTypeString)) {
LERROR(_name << ": The field " << std::string(KEY_INPUT_FILE_TYPE) << " is missing!");
if (!_dictionary->getValue(KeyInputFileType, inputFileTypeString)) {
LERROR(_name << ": The field " << std::string(KeyInputFileType) << " is missing!");
return false;
} else {
std::transform(inputFileTypeString.begin(), inputFileTypeString.end(),
inputFileTypeString.begin(), ::tolower);
// Verify that the input type is correct
if (inputFileTypeString == VALUE_INPUT_FILE_TYPE_CDF) {
sourceFileType = SourceFileType::CDF;
if (inputFileTypeString == ValueInputFileTypeCdf) {
sourceFileType = SourceFileType::Cdf;
#ifndef OPENSPACE_MODULE_KAMELEON_ENABLED
LERROR(_name << ": CDF file inputs requires the 'Kameleon' module to be enabled!");
return false;
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
} else if (inputFileTypeString == VALUE_INPUT_FILE_TYPE_JSON) {
sourceFileType = SourceFileType::JSON;
} else if (inputFileTypeString == VALUE_INPUT_FILE_TYPE_OSFLS) {
sourceFileType = SourceFileType::OSFLS;
} else if (inputFileTypeString == ValueInputFileTypeJson) {
sourceFileType = SourceFileType::Json;
} else if (inputFileTypeString == ValueInputFileTypeOsfls) {
sourceFileType = SourceFileType::Osfls;
} else {
LERROR(_name << ": " << inputFileTypeString << " is not a recognised "
<< KEY_INPUT_FILE_TYPE);
sourceFileType = SourceFileType::INVALID;
<< KeyInputFileType);
sourceFileType = SourceFileType::Invalid;
return false;
}
}
std::string sourceFolderPath;
if (!_dictionary->getValue(KEY_SOURCE_FOLDER, sourceFolderPath)) {
LERROR(_name << ": The field " << std::string(KEY_SOURCE_FOLDER) << " is missing!");
if (!_dictionary->getValue(KeySourceFolder, sourceFolderPath)) {
LERROR(_name << ": The field " << std::string(KeySourceFolder) << " is missing!");
return false;
}
@@ -345,8 +345,8 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
// Remove all files that don't have <inputFileTypeString> as extension
_sourceFiles.erase(std::remove_if(_sourceFiles.begin(), _sourceFiles.end(),
[inputFileTypeString](std::string str) {
const size_t EXT_LENGTH = inputFileTypeString.length();
std::string sub = str.substr(str.length() - EXT_LENGTH, EXT_LENGTH);
const size_t extLength = inputFileTypeString.length();
std::string sub = str.substr(str.length() - extLength, extLength);
std::transform(sub.begin(), sub.end(), sub.begin(), ::tolower);
return sub != inputFileTypeString;
}), _sourceFiles.end());
@@ -369,7 +369,7 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary(
std::string& outputFolderPath) {
// ------------------- EXTRACT OPTIONAL VALUES FROM DICTIONARY ------------------- //
if (_dictionary->getValue(KEY_OUTPUT_FOLDER, outputFolderPath)) {
if (_dictionary->getValue(KeyOutputFolder, outputFolderPath)) {
ghoul::filesystem::Directory outputFolder(outputFolderPath);
if (FileSys.directoryExists(outputFolder)) {
outputFolderPath = absPath(outputFolderPath);
@@ -380,12 +380,12 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary(
}
ghoul::Dictionary colorTablesPathsDictionary;
if (_dictionary->getValue(KEY_COLOR_TABLE_PATHS, colorTablesPathsDictionary)) {
const size_t N_PROVIDED_PATHS = colorTablesPathsDictionary.size();
if (N_PROVIDED_PATHS > 0) {
if (_dictionary->getValue(KeyColorTablePaths, colorTablesPathsDictionary)) {
const size_t nProvidedPaths = colorTablesPathsDictionary.size();
if (nProvidedPaths > 0) {
// Clear the default! It is already specified in the transferFunction
_colorTablePaths.clear();
for (size_t i = 1; i <= N_PROVIDED_PATHS; ++i) {
for (size_t i = 1; i <= nProvidedPaths; ++i) {
_colorTablePaths.push_back(
colorTablesPathsDictionary.value<std::string>(std::to_string(i)));
}
@@ -393,9 +393,9 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary(
}
ghoul::Dictionary colorTablesRangesDictionary;
if (_dictionary->getValue(KEY_COLOR_TABLE_RANGES, colorTablesRangesDictionary)) {
const size_t N_PROVIDED_RANGES = colorTablesRangesDictionary.size();
for (size_t i = 1; i <= N_PROVIDED_RANGES; ++i) {
if (_dictionary->getValue(KeyColorTableRanges, colorTablesRangesDictionary)) {
const size_t nProvidedRanges = colorTablesRangesDictionary.size();
for (size_t i = 1; i <= nProvidedRanges; ++i) {
_colorTableRanges.push_back(
colorTablesRangesDictionary.value<glm::vec2>(std::to_string(i)));
}
@@ -404,9 +404,9 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary(
}
ghoul::Dictionary maskingRangesDictionary;
if (_dictionary->getValue(KEY_MASKING_RANGES, maskingRangesDictionary)) {
const size_t N_PROVIDED_RANGES = maskingRangesDictionary.size();
for (size_t i = 1; i <= N_PROVIDED_RANGES; ++i) {
if (_dictionary->getValue(KeyMaskingRanges, maskingRangesDictionary)) {
const size_t nProvidedRanges = maskingRangesDictionary.size();
for (size_t i = 1; i <= nProvidedRanges; ++i) {
_maskingRanges.push_back(
maskingRangesDictionary.value<glm::vec2>(std::to_string(i)));
}
@@ -420,16 +420,16 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary(
*/
bool RenderableFieldlinesSequence::extractJsonInfoFromDictionary(fls::Model& model) {
std::string modelStr;
if (_dictionary->getValue(KEY_JSON_SIMULATION_MODEL, modelStr)) {
if (_dictionary->getValue(KeyJsonSimulationModel, modelStr)) {
std::transform(modelStr.begin(), modelStr.end(), modelStr.begin(), ::tolower);
model = fls::stringToModel(modelStr);
} else {
LERROR(_name << ": Must specify '" << KEY_JSON_SIMULATION_MODEL << "'");
LERROR(_name << ": Must specify '" << KeyJsonSimulationModel << "'");
return false;
}
float scaleFactor;
if (_dictionary->getValue(KEY_JSON_SCALING_FACTOR, scaleFactor)) {
if (_dictionary->getValue(KeyJsonScalingFactor, scaleFactor)) {
_scalingFactor = scaleFactor;
} else {
LWARNING(_name << ": Does not provide scalingFactor! " <<
@@ -438,7 +438,7 @@ bool RenderableFieldlinesSequence::extractJsonInfoFromDictionary(fls::Model& mod
return true;
}
bool RenderableFieldlinesSequence::loadJsonStatesIntoRAM(const std::string& OUTPUT_FOLDER) {
bool RenderableFieldlinesSequence::loadJsonStatesIntoRAM(const std::string& outputFolder) {
fls::Model model;
if (!extractJsonInfoFromDictionary(model)) {
return false;
@@ -450,8 +450,8 @@ bool RenderableFieldlinesSequence::loadJsonStatesIntoRAM(const std::string& OUTP
_scalingFactor);
if (loadedSuccessfully) {
addStateToSequence(newState);
if (!OUTPUT_FOLDER.empty()) {
newState.saveStateToOsfls(OUTPUT_FOLDER);
if (!outputFolder.empty()) {
newState.saveStateToOsfls(outputFolder);
}
}
}
@@ -472,28 +472,28 @@ bool RenderableFieldlinesSequence::prepareForOsflsStreaming() {
}
void RenderableFieldlinesSequence::loadOsflsStatesIntoRAM(const std::string& OUTPUT_FOLDER) {
void RenderableFieldlinesSequence::loadOsflsStatesIntoRAM(const std::string& outputFolder) {
// Load states from .osfls files into RAM!
for (const std::string FILEPATH : _sourceFiles) {
for (const std::string filePath : _sourceFiles) {
FieldlinesState newState;
if (newState.loadStateFromOsfls(FILEPATH)) {
if (newState.loadStateFromOsfls(filePath)) {
addStateToSequence(newState);
if (!OUTPUT_FOLDER.empty()) {
ghoul::filesystem::File tmpFile(FILEPATH);
newState.saveStateToJson(OUTPUT_FOLDER + tmpFile.baseName());
if (!outputFolder.empty()) {
ghoul::filesystem::File tmpFile(filePath);
newState.saveStateToJson(outputFolder + tmpFile.baseName());
}
} else {
LWARNING("Failed to load state from: " << FILEPATH);
LWARNING("Failed to load state from: " << filePath);
}
}
}
void RenderableFieldlinesSequence::extractOsflsInfoFromDictionary() {
bool shouldLoadInRealtime = false;
if (_dictionary->getValue(KEY_OSLFS_LOAD_AT_RUNTIME, shouldLoadInRealtime)) {
if (_dictionary->getValue(KeyOslfsLoadAtRuntime, shouldLoadInRealtime)) {
_loadingStatesDynamically = shouldLoadInRealtime;
} else {
LWARNING(_name << ": " << KEY_OSLFS_LOAD_AT_RUNTIME <<
LWARNING(_name << ": " << KeyOslfsLoadAtRuntime <<
" isn't specified! States will be stored in RAM!");
}
}
@@ -537,21 +537,21 @@ void RenderableFieldlinesSequence::setupProperties() {
_pMaskingGroup.addProperty(_pMaskingQuantity);
// --------------------- Add Options to OptionProperties --------------------- //
_pColorMethod.addOption(ColorMethod::UNIFORM, "Uniform");
_pColorMethod.addOption(ColorMethod::BY_QUANTITY, "By Quantity");
_pColorMethod.addOption(ColorMethod::Uniform, "Uniform");
_pColorMethod.addOption(ColorMethod::ByQuantity, "By Quantity");
// Add option for each extra quantity. Assumes there are just as many names to
// extra quantities as there are extra quantities. Also assume that all states in
// the given sequence have the same extra quantities! */
const size_t N_EXTRA_QUANTITIES = _states[0].nExtraQuantities();
const std::vector<std::string>& XTRA_NAMES_VEC = _states[0].extraQuantityNames();
for (int i = 0; i < N_EXTRA_QUANTITIES; ++i) {
_pColorQuantity.addOption(i, XTRA_NAMES_VEC[i]);
_pMaskingQuantity.addOption(i, XTRA_NAMES_VEC[i]);
const size_t nExtraQuantities = _states[0].nExtraQuantities();
const std::vector<std::string>& extraNamesVec = _states[0].extraQuantityNames();
for (int i = 0; i < nExtraQuantities; ++i) {
_pColorQuantity.addOption(i, extraNamesVec[i]);
_pMaskingQuantity.addOption(i, extraNamesVec[i]);
}
// Each quantity should have its own color table and color table range, no more, no less
_colorTablePaths.resize(N_EXTRA_QUANTITIES, _colorTablePaths.back());
_colorTableRanges.resize(N_EXTRA_QUANTITIES, _colorTableRanges.back());
_maskingRanges.resize(N_EXTRA_QUANTITIES, _maskingRanges.back());
_colorTablePaths.resize(nExtraQuantities, _colorTablePaths.back());
_colorTableRanges.resize(nExtraQuantities, _colorTableRanges.back());
_maskingRanges.resize(nExtraQuantities, _maskingRanges.back());
}
definePropertyCallbackFunctions();
@@ -642,11 +642,11 @@ void RenderableFieldlinesSequence::definePropertyCallbackFunctions() {
// Calculate expected end time.
void RenderableFieldlinesSequence::computeSequenceEndTime() {
if (_nStates > 1) {
const double LAST_TRIGGER_TIME = _startTimes[_nStates - 1];
const double SEQUENCE_DURATION = LAST_TRIGGER_TIME - _startTimes[0];
const double AVERAGE_STATE_DURATION = SEQUENCE_DURATION /
(static_cast<double>(_nStates) - 1.0);
_sequenceEndTime = LAST_TRIGGER_TIME + AVERAGE_STATE_DURATION;
const double lastTriggerTime = _startTimes[_nStates - 1];
const double sequenceDuration = lastTriggerTime - _startTimes[0];
const double averageStateDuration = sequenceDuration /
(static_cast<double>(_nStates) - 1.0);
_sequenceEndTime = lastTriggerTime + averageStateDuration;
} else {
// If there's just one state it should never disappear!
_sequenceEndTime = DBL_MAX;
@@ -657,17 +657,17 @@ void RenderableFieldlinesSequence::setModelDependentConstants() {
const fls::Model simulationModel = _states[0].model();
float limit = 100.f; // Just used as a default value.
switch (simulationModel) {
case fls::Model::BATSRUS:
_scalingFactor = fls::R_E_TO_METER;
case fls::Model::Batsrus:
_scalingFactor = fls::ReToMeter;
limit = 300; // Should include a long magnetotail
break;
case fls::Model::ENLIL:
case fls::Model::Enlil:
_pFlowReversed = true;
_scalingFactor = fls::A_U_TO_METER;
_scalingFactor = fls::AuToMeter;
limit = 50; // Should include Plutos furthest distance from the Sun
break;
case fls::Model::PFSS:
_scalingFactor = fls::R_S_TO_METER;
case fls::Model::Pfss:
_scalingFactor = fls::RsToMeter;
limit = 100; // Just a default value far away from the solar surface
break;
default:
@@ -682,28 +682,28 @@ void RenderableFieldlinesSequence::setModelDependentConstants() {
_pDomainX = glm::vec2(-limit, limit);
_pDomainY = glm::vec2(-limit, limit);
_pDomainZ = glm::vec2(-limit, limit);
_pDomainR = glm::vec2(0, limit*1.5f);
_pDomainR = glm::vec2(0, limit * 1.5f);
}
// Extract J2000 time from file names
// Requires files to be named as such: 'YYYY-MM-DDTHH-MM-SS-XXX.osfls'
void RenderableFieldlinesSequence::extractTriggerTimesFromFileNames() {
const size_t FILENAME_SIZE = 23; // number of characters in filename (excluding '.osfls')
const size_t EXT_SIZE = 6; // size(".osfls")
const size_t filenameSize = 23; // number of characters in filename (excluding '.osfls')
const size_t extSize = 6; // size(".osfls")
for (const std::string& FILEPATH : _sourceFiles) {
const size_t STR_LENGTH = FILEPATH.size();
for (const std::string& filePath : _sourceFiles) {
const size_t strLength = filePath.size();
// Extract the filename from the path (without extension)
std::string timeString = FILEPATH.substr(STR_LENGTH - FILENAME_SIZE - EXT_SIZE,
FILENAME_SIZE - 1);
std::string timeString = filePath.substr(strLength - filenameSize - extSize,
filenameSize - 1);
// Ensure the separators are correct
timeString.replace(4, 1, "-");
timeString.replace(7, 1, "-");
timeString.replace(13, 1, ":");
timeString.replace(16, 1, ":");
timeString.replace(19, 1, ".");
const double TRIGGER_TIME = Time::convertTime(timeString);
_startTimes.push_back(TRIGGER_TIME);
const double triggerTime = Time::convertTime(timeString);
_startTimes.push_back(triggerTime);
}
}
@@ -714,7 +714,7 @@ void RenderableFieldlinesSequence::addStateToSequence(FieldlinesState& state) {
}
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
bool RenderableFieldlinesSequence::getStatesFromCdfFiles(const std::string& OUTPUT_FOLDER) {
bool RenderableFieldlinesSequence::getStatesFromCdfFiles(const std::string& outputFolder) {
std::string seedFilePath;
std::string tracingVar;
@@ -746,19 +746,19 @@ bool RenderableFieldlinesSequence::getStatesFromCdfFiles(const std::string& OUTP
// the extraQuantites, as the iterpolator needs the unaltered positions
newState.addExtraQuantities(kameleon.get(), extraVars, extraMagVars);
switch (newState.model()) {
case fls::BATSRUS:
newState.scalePositions(fls::R_E_TO_METER);
case fls::Batsrus:
newState.scalePositions(fls::ReToMeter);
break;
case fls::ENLIL :
newState.convertLatLonToCartesian(fls::A_U_TO_METER);
case fls::Enlil :
newState.convertLatLonToCartesian(fls::AuToMeter);
break;
default:
break;
}
addStateToSequence(newState);
if (!OUTPUT_FOLDER.empty()) {
newState.saveStateToOsfls(OUTPUT_FOLDER);
if (!outputFolder.empty()) {
newState.saveStateToOsfls(outputFolder);
}
}
}
@@ -775,7 +775,7 @@ bool RenderableFieldlinesSequence::extractCdfInfoFromDictionary(
std::string& tracingVar,
std::vector<std::string>& extraVars) {
if (_dictionary->getValue(KEY_CDF_SEED_POINT_FILE, seedFilePath)) {
if (_dictionary->getValue(KeyCdfSeedPointFile, seedFilePath)) {
ghoul::filesystem::File seedPointFile(seedFilePath);
if (FileSys.fileExists(seedPointFile)) {
seedFilePath = absPath(seedFilePath);
@@ -785,20 +785,20 @@ bool RenderableFieldlinesSequence::extractCdfInfoFromDictionary(
return false;
}
} else {
LERROR(_name << ": Must specify '" << KEY_CDF_SEED_POINT_FILE << "'");
LERROR(_name << ": Must specify '" << KeyCdfSeedPointFile << "'");
return false;
}
if (!_dictionary->getValue(KEY_CDF_TRACING_VARIABLE, tracingVar)) {
if (!_dictionary->getValue(KeyCdfTracingVariable, tracingVar)) {
tracingVar = "b"; // Magnetic field variable as default
LWARNING(_name << ": No '" << KEY_CDF_TRACING_VARIABLE << "', using default: "
LWARNING(_name << ": No '" << KeyCdfTracingVariable << "', using default: "
<< tracingVar);
}
ghoul::Dictionary extraQuantityNamesDictionary;
if (_dictionary->getValue(KEY_CDF_EXTRA_VARIABLES, extraQuantityNamesDictionary)) {
const size_t N_PROVIDED_EXTRAS = extraQuantityNamesDictionary.size();
for (size_t i = 1; i <= N_PROVIDED_EXTRAS; ++i) {
if (_dictionary->getValue(KeyCdfExtraVariables, extraQuantityNamesDictionary)) {
const size_t nProvidedExtras = extraQuantityNamesDictionary.size();
for (size_t i = 1; i <= nProvidedExtras; ++i) {
extraVars.push_back(
extraQuantityNamesDictionary.value<std::string>(std::to_string(i)));
}
@@ -846,10 +846,10 @@ void RenderableFieldlinesSequence::extractMagnitudeVarsFromStrings(
for (int i = 0; i < extraVars.size(); i++) {
const std::string STR = extraVars[i];
const std::string str = extraVars[i];
// Check if string is in the format specified for magnitude variables
if (STR.substr(0, 2) == "|(" && STR.substr(STR.size() - 2, 2) == ")|") {
std::istringstream ss(STR.substr(2, STR.size() - 4));
if (str.substr(0, 2) == "|(" && str.substr(str.size() - 2, 2) == ")|") {
std::istringstream ss(str.substr(2, str.size() - 4));
std::string magVar;
size_t counter = 0;
while(std::getline(ss, magVar, ',')) {

View File

@@ -58,8 +58,8 @@ layout(location = 1) in float in_color_scalar; // The extra value used to colo
layout(location = 2) in float in_masking_scalar; // The extra value used to mask out parts of lines. Location must correspond to _VA_MASKING in renderablefieldlinessequence.h
// These should correspond to the enum 'ColorMethod' in renderablefieldlinesequence.cpp
const int UNIFORM_COLOR = 0;
const int COLOR_BY_QUANTITY = 1;
const int uniformColor = 0;
const int colorByQuantity = 1;
out vec4 vs_color;
out float vs_depth;
@@ -67,15 +67,15 @@ out float vs_depth;
vec4 getTransferFunctionColor() {
// Remap the color scalar to a [0,1] range
const float LOOK_UP_VAL = (in_color_scalar - colorTableRange.x) /
(colorTableRange.y - colorTableRange.x);
return texture(colorTable, LOOK_UP_VAL);
const float lookUpVal = (in_color_scalar - colorTableRange.x) /
(colorTableRange.y - colorTableRange.x);
return texture(colorTable, lookUpVal);
}
bool isPartOfParticle(const double TIME, const int VERTEX_ID, const int PARTICLE_SIZE,
const int PARTICLE_SPEED, const int PARTICLE_SPACING) {
const int MODULUS_RESULT = int(double(PARTICLE_SPEED) * TIME + VERTEX_ID) % PARTICLE_SPACING;
return MODULUS_RESULT > 0 && MODULUS_RESULT <= PARTICLE_SIZE;
bool isPartOfParticle(const double time, const int vertexId, const int particleSize,
const int particleSpeed, const int particleSpacing) {
const int modulusResult = int(double(particleSpeed) * time + vertexId) % particleSpacing;
return modulusResult > 0 && modulusResult <= particleSize;
}
void main() {
@@ -88,32 +88,32 @@ void main() {
}
if (usingDomain && hasColor) {
const float RADIUS = length(in_position);
const float radius = length(in_position);
if (in_position.x < domainLimX.x || in_position.x > domainLimX.y ||
in_position.y < domainLimY.x || in_position.y > domainLimY.y ||
in_position.z < domainLimZ.x || in_position.z > domainLimZ.y ||
RADIUS < domainLimR.x || RADIUS > domainLimR.y) {
radius < domainLimR.x || radius > domainLimR.y) {
hasColor = false;
}
}
if (hasColor) {
const bool IS_PARTICLE = usingParticles && isPartOfParticle(time, gl_VertexID,
const bool isParticle = usingParticles && isPartOfParticle(time, gl_VertexID,
particleSize,
particleSpeed,
particleSpacing);
if (IS_PARTICLE) {
if (isParticle) {
vs_color = flowColor;
} else {
vs_color = lineColor;
}
if (colorMethod == COLOR_BY_QUANTITY) {
const vec4 QUANTITY_COLOR = getTransferFunctionColor();
vs_color = vec4(QUANTITY_COLOR.xyz, vs_color.a * QUANTITY_COLOR.a);
if (colorMethod == colorByQuantity) {
const vec4 quantityColor = getTransferFunctionColor();
vs_color = vec4(quantityColor.xyz, vs_color.a * quantityColor.a);
}
} else {
vs_color = vec4(0);

View File

@@ -27,15 +27,15 @@
namespace openspace {
namespace fls {
Model stringToModel(const std::string S) {
if (S == "batsrus") {
return Model::BATSRUS;
} else if (S == "enlil") {
return Model::ENLIL;
} else if (S == "pfss") {
return Model::PFSS;
Model stringToModel(const std::string s) {
if (s == "batsrus") {
return Model::Batsrus;
} else if (s == "enlil") {
return Model::Enlil;
} else if (s == "pfss") {
return Model::Pfss;
}
return Model::INVALID;
return Model::Invalid;
}
} // namespace fls

View File

@@ -31,17 +31,17 @@ namespace openspace {
namespace fls { // (F)ield(L)ines(S)equence
enum Model : int {
BATSRUS = 0,
ENLIL,
PFSS,
INVALID
Batsrus = 0,
Enlil,
Pfss,
Invalid
};
Model stringToModel(const std::string S);
Model stringToModel(const std::string s);
const float A_U_TO_METER = 149597870700.f; // Astronomical Units
const float R_E_TO_METER = 6371000.f; // Earth radius
const float R_S_TO_METER = 695700000.f; // Sun radius
const float AuToMeter = 149597870700.f; // Astronomical Units
const float ReToMeter = 6371000.f; // Earth radius
const float RsToMeter = 695700000.f; // Sun radius
} // namespace fls
} // namespace openspace

View File

@@ -40,11 +40,11 @@
namespace {
std::string _loggerCat = "FieldlinesState";
const int CURRENT_VERSION = 0;
const int CurrentVersion = 0;
const std::string T_AS_P_OVER_RHO = "T = p/rho";
const std::string J_PARALLEL_B = "Current: mag(J||B)";
const float TO_KELVIN = 72429735.6984f; // <-- [nPa]/[amu/cm^3] * TO_KELVIN => Temperature in Kelvin
const std::string TAsPOverRho = "T = p/rho";
const std::string JParallelB = "Current: mag(J||B)";
const float ToKelvin = 72429735.6984f; // <-- [nPa]/[amu/cm^3] * ToKelvin => Temperature in Kelvin
using json = nlohmann::json;
}
@@ -58,18 +58,18 @@ namespace openspace {
* Note that extraQuantities will NOT be set!
*/
bool FieldlinesState::addLinesFromKameleon(ccmc::Kameleon* kameleon,
const std::vector<glm::vec3>& SEED_POINTS,
const std::string TRACING_VAR) {
const std::vector<glm::vec3>& seedPoints,
const std::string tracingVar) {
_model = fls::stringToModel(kameleon->getModelName());
float innerBoundaryLimit;
switch (_model) {
case fls::Model::BATSRUS :
case fls::Model::Batsrus :
innerBoundaryLimit = 2.5f; // TODO specify in Lua?
break;
case fls::Model::ENLIL :
case fls::Model::Enlil :
innerBoundaryLimit = 0.11f; // TODO specify in Lua?
break;
default:
@@ -79,15 +79,15 @@ bool FieldlinesState::addLinesFromKameleon(ccmc::Kameleon* kameleon,
}
// --------------------------- LOAD TRACING VARIABLE ---------------------------- //
if (!kameleon->loadVariable(TRACING_VAR)) {
LERROR("FAILED TO LOAD TRACING VARIABLE: " << TRACING_VAR);
if (!kameleon->loadVariable(tracingVar)) {
LERROR("FAILED TO LOAD TRACING VARIABLE: " << tracingVar);
return false;
}
LINFO("TRACING FIELD LINES!");
// - LOOP THROUGH THE SEED POINTS, TRACE LINES AND CONVERT TO THE DESIRED FORMAT - //
size_t lineStart = 0;
for (glm::vec3 seed : SEED_POINTS) {
for (glm::vec3 seed : seedPoints) {
//--------------------------------------------------------------------------//
// We have to create a new tracer (or actually a new interpolator) for each //
// new line, otherwise some issues occur //
@@ -96,18 +96,18 @@ bool FieldlinesState::addLinesFromKameleon(ccmc::Kameleon* kameleon,
std::make_unique<ccmc::KameleonInterpolator>(kameleon->model);
ccmc::Tracer tracer(kameleon, interpolator.get());
tracer.setInnerBoundary(innerBoundaryLimit); // TODO specify in Lua?
ccmc::Fieldline ccmcFieldline = tracer.bidirectionalTrace(TRACING_VAR,
ccmc::Fieldline ccmcFieldline = tracer.bidirectionalTrace(tracingVar,
seed.x,
seed.y,
seed.z);
const std::vector<ccmc::Point3f>& POSITIONS = ccmcFieldline.getPositions();
const std::vector<ccmc::Point3f>& positions = ccmcFieldline.getPositions();
_lineStart.push_back(lineStart);
const size_t N_LINE_POINTS = POSITIONS.size();
_lineCount.push_back(static_cast<GLsizei>(N_LINE_POINTS));
lineStart += static_cast<GLint>(N_LINE_POINTS);
const size_t nLinePoints = positions.size();
_lineCount.push_back(static_cast<GLsizei>(nLinePoints));
lineStart += static_cast<GLint>(nLinePoints);
for (const ccmc::Point3f& p : POSITIONS) {
for (const ccmc::Point3f& p : positions) {
_vertexPositions.emplace_back(
glm::vec3(p.component1, p.component2, p.component3));
}
@@ -127,13 +127,13 @@ void FieldlinesState::loadExtrasIntoKameleon(ccmc::Kameleon* kameleon,
std::string& str = xtraScalarVars[i];
bool isSuccesful = kameleon->doesVariableExist(str) && kameleon->loadVariable(str);
if (!isSuccesful &&
(_model == fls::Model::BATSRUS && (str == T_AS_P_OVER_RHO || str == "T" ))) {
(_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");
const std::string P = "p", R = "rho";
isSuccesful = kameleon->doesVariableExist(P) && kameleon->loadVariable(P)
&& kameleon->doesVariableExist(R) && kameleon->loadVariable(R);
str = T_AS_P_OVER_RHO;
const std::string p = "p", r = "rho";
isSuccesful = kameleon->doesVariableExist(p) && kameleon->loadVariable(p)
&& kameleon->doesVariableExist(r) && kameleon->loadVariable(r);
str = TAsPOverRho;
}
if (!isSuccesful) {
LWARNING("FAILED TO LOAD EXTRA VARIABLE: '" << str << "'. Ignoring it!");
@@ -158,7 +158,7 @@ void FieldlinesState::loadExtrasIntoKameleon(ccmc::Kameleon* kameleon,
kameleon->loadVariable(s2) &&
kameleon->loadVariable(s3);
std::string name = "Magnitude of (" + s1 + ", "+ s2 + ", "+ s3 + ")";
if (isSuccesful && _model == fls::Model::BATSRUS && s1 == "jx" && s2 == "jy"
if (isSuccesful && _model == fls::Model::Batsrus && s1 == "jx" && s2 == "jy"
&& s3 == "jz") {
// CCMC isn't really interested in the magnitude of current, but by the
// magnitude of the part of the current's vector that is parallel to the
@@ -169,7 +169,7 @@ void FieldlinesState::loadExtrasIntoKameleon(ccmc::Kameleon* kameleon,
kameleon->loadVariable("bx") &&
kameleon->loadVariable("by") &&
kameleon->loadVariable("bz");
name = J_PARALLEL_B;
name = JParallelB;
}
if (!isSuccesful) {
LWARNING("FAILED TO LOAD AT LEAST ONE OF THE MAGNITUDE VARIABLES: "
@@ -211,56 +211,56 @@ void FieldlinesState::addExtraQuantities(ccmc::Kameleon* kameleon,
loadExtrasIntoKameleon(kameleon, xtraScalarVars, xtraMagVars);
const size_t N_XTRA_SCALARS = xtraScalarVars.size();
const size_t N_XTRA_MAGNITUDES = xtraMagVars.size() / 3;
const size_t nXtraScalars = xtraScalarVars.size();
const size_t nXtraMagnitudes = xtraMagVars.size() / 3;
_extraQuantities.resize(N_XTRA_SCALARS + N_XTRA_MAGNITUDES);
_extraQuantities.resize(nXtraScalars + nXtraMagnitudes);
std::unique_ptr<ccmc::Interpolator> interpolator =
std::make_unique<ccmc::KameleonInterpolator>(kameleon->model);
// ------ Extract all the extraQuantities from kameleon and store in state! ------ //
for (const glm::vec3& P : _vertexPositions) {
for (const glm::vec3& p : _vertexPositions) {
// Load the scalars!
for (size_t i = 0; i < N_XTRA_SCALARS; i++) {
for (size_t i = 0; i < nXtraScalars; i++) {
float val;
if (xtraScalarVars[i] == T_AS_P_OVER_RHO) {
val = interpolator->interpolate("p", P.x, P.y, P.z);
val *= TO_KELVIN;
val /= interpolator->interpolate("rho", P.x, P.y, P.z);
if (xtraScalarVars[i] == TAsPOverRho) {
val = interpolator->interpolate("p", p.x, p.y, p.z);
val *= ToKelvin;
val /= interpolator->interpolate("rho", p.x, p.y, p.z);
} else {
val = interpolator->interpolate(xtraScalarVars[i], P.x, P.y, P.z);
val = interpolator->interpolate(xtraScalarVars[i], p.x, p.y, p.z);
// When measuring density in ENLIL CCMC multiply by the radius^2
if (xtraScalarVars[i] == "rho" && _model == fls::Model::ENLIL) {
val *= std::pow(P.x * fls::A_U_TO_METER, 2.0f);
if (xtraScalarVars[i] == "rho" && _model == fls::Model::Enlil) {
val *= std::pow(p.x * fls::AuToMeter, 2.0f);
}
}
_extraQuantities[i].push_back(val);
}
// Calculate and store the magnitudes!
for (size_t i = 0; i < N_XTRA_MAGNITUDES; ++i) {
const size_t IDX = i*3;
for (size_t i = 0; i < nXtraMagnitudes; ++i) {
const size_t idx = i*3;
const float X = interpolator->interpolate(xtraMagVars[IDX] , P.x, P.y, P.z);
const float Y = interpolator->interpolate(xtraMagVars[IDX+1], P.x, P.y, P.z);
const float Z = interpolator->interpolate(xtraMagVars[IDX+2], P.x, P.y, P.z);
const float x = interpolator->interpolate(xtraMagVars[idx] , p.x, p.y, p.z);
const float y = interpolator->interpolate(xtraMagVars[idx+1], p.x, p.y, p.z);
const float z = interpolator->interpolate(xtraMagVars[idx+2], p.x, p.y, p.z);
float val;
// When looking at the current's magnitude in Batsrus, CCMC staff are
// only interested in the magnitude parallel to the magnetic field
if (_extraQuantityNames[N_XTRA_SCALARS + i] == J_PARALLEL_B) {
const glm::vec3 NORM_MAGNETIC = glm::normalize(glm::vec3(
interpolator->interpolate("bx", P.x, P.y, P.z),
interpolator->interpolate("by", P.x, P.y, P.z),
interpolator->interpolate("bz", P.x, P.y, P.z)));
if (_extraQuantityNames[nXtraScalars + i] == JParallelB) {
const glm::vec3 normMagnetic = glm::normalize(glm::vec3(
interpolator->interpolate("bx", p.x, p.y, p.z),
interpolator->interpolate("by", p.x, p.y, p.z),
interpolator->interpolate("bz", p.x, p.y, p.z)));
// Magnitude of the part of the current vector that's parallel to
// the magnetic field vector!
val = glm::dot(glm::vec3(X,Y,Z), NORM_MAGNETIC);
val = glm::dot(glm::vec3(x,y,z), normMagnetic);
} else {
val = std::sqrt(X*X + Y*Y + Z*Z);
val = std::sqrt(x*x + y*y + z*z);
}
_extraQuantities[i + N_XTRA_SCALARS].push_back(val);
_extraQuantities[i + nXtraScalars].push_back(val);
}
}
}
@@ -270,33 +270,33 @@ void FieldlinesState::addExtraQuantities(ccmc::Kameleon* kameleon,
/**
* Converts all glm::vec3 in _vertexPositions from spherical (radius, latitude, longitude)
* coordinates into cartesian coordinates. The longitude and latitude coordinates are
* expected to be in degrees. SCALE is an optional scaling factor.
* expected to be in degrees. scale is an optional scaling factor.
*/
void FieldlinesState::convertLatLonToCartesian(const float SCALE /* = 1.f */) {
void FieldlinesState::convertLatLonToCartesian(const float scale /* = 1.f */) {
for (glm::vec3& p : _vertexPositions) {
const float R = p.x * SCALE;
const float LAT = glm::radians(p.y);
const float LON = glm::radians(p.z);
const float R_COS_LAT = R * cos(LAT);
const float r = p.x * scale;
const float lat = glm::radians(p.y);
const float lon = glm::radians(p.z);
const float rCosLat = r * cos(lat);
p = glm::vec3(R_COS_LAT * cos(LON), R_COS_LAT* sin(LON), R * sin(LAT));
p = glm::vec3(rCosLat * cos(lon), rCosLat* sin(lon), r * sin(lat));
}
}
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
void FieldlinesState::scalePositions(const float SCALE) {
void FieldlinesState::scalePositions(const float scale) {
for (glm::vec3& p : _vertexPositions) {
p *= SCALE;
p *= scale;
}
}
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
bool FieldlinesState::loadStateFromOsfls(const std::string& PATH_TO_OSFLS_FILE) {
std::ifstream ifs(PATH_TO_OSFLS_FILE, std::ifstream::binary);
bool FieldlinesState::loadStateFromOsfls(const std::string& pathToOsflsFile) {
std::ifstream ifs(pathToOsflsFile, std::ifstream::binary);
if (!ifs.is_open()) {
LERRORC("FieldlinesState", "Couldn't open file: " + PATH_TO_OSFLS_FILE);
LERRORC("FieldlinesState", "Couldn't open file: " + pathToOsflsFile);
return false;
}
@@ -366,15 +366,15 @@ bool FieldlinesState::loadStateFromOsfls(const std::string& PATH_TO_OSFLS_FILE)
return true;
}
bool FieldlinesState::loadStateFromJson(const std::string& PATH_TO_JSON_FILE,
const fls::Model MODEL,
const float COORD_TO_METERS = 1.f) {
bool FieldlinesState::loadStateFromJson(const std::string& pathToJsonFile,
const fls::Model Model,
const float coordToMeters = 1.f) {
// --------------------- ENSURE FILE IS VALID, THEN PARSE IT --------------------- //
std::ifstream ifs(PATH_TO_JSON_FILE);
std::ifstream ifs(pathToJsonFile);
if (!ifs.is_open()) {
LERROR("FAILED TO OPEN FILE: " << PATH_TO_JSON_FILE);
LERROR("FAILED TO OPEN FILE: " << pathToJsonFile);
return false;
}
@@ -382,70 +382,70 @@ bool FieldlinesState::loadStateFromJson(const std::string& PATH_TO_JSON_FILE,
ifs >> jFile;
// -------------------------------------------------------------------------------- //
_model = MODEL;
_model = Model;
const std::string S_DATA = "data";
const std::string S_TRACE = "trace";
const std::string sData = "data";
const std::string sTrace = "trace";
// ----- EXTRACT THE EXTRA QUANTITY NAMES & TRIGGER TIME (same for all lines) ----- //
{
const json J_TMP = *jFile.begin(); // First field line in the file
_triggerTime = Time::convertTime(J_TMP["time"]);
const json jTmp = *jFile.begin(); // First field line in the file
_triggerTime = Time::convertTime(jTmp["time"]);
const std::string S_COLUMNS = "columns";
auto variableNameVec = J_TMP[S_TRACE][S_COLUMNS];
const size_t N_VARIABLES = variableNameVec.size();
const size_t N_POS_COMPONENTS = 3; // x,y,z
const std::string sColumns = "columns";
auto variableNameVec = jTmp[sTrace][sColumns];
const size_t nVariables = variableNameVec.size();
const size_t nPosComponents = 3; // x,y,z
if (N_VARIABLES < N_POS_COMPONENTS) {
LERROR(PATH_TO_JSON_FILE + ": Each field '" + S_COLUMNS +
if (nVariables < nPosComponents) {
LERROR(pathToJsonFile + ": Each field '" + sColumns +
"' must contain the variables: 'x', 'y' and 'z' (order is important).");
return false;
}
for (size_t i = N_POS_COMPONENTS ; i < N_VARIABLES ; i++) {
for (size_t i = nPosComponents ; i < nVariables ; i++) {
_extraQuantityNames.push_back(variableNameVec[i]);
}
}
const size_t N_EXTRAS = _extraQuantityNames.size();
_extraQuantities.resize(N_EXTRAS);
const size_t nExtras = _extraQuantityNames.size();
_extraQuantities.resize(nExtras);
size_t lineStartIdx = 0;
// Loop through all fieldlines
for (json::iterator fieldlineIt = jFile.begin(); fieldlineIt != jFile.end(); ++fieldlineIt) {
for (json::iterator lineIter = jFile.begin(); lineIter != jFile.end(); ++lineIter) {
// The 'data' field in the 'trace' variable contains all vertex positions and the
// extra quantities. Each element is an array related to one vertex point.
const std::vector<std::vector<float>> J_DATA = (*fieldlineIt)[S_TRACE][S_DATA];
const size_t N_POINTS = J_DATA.size();
const std::vector<std::vector<float>> jData = (*lineIter)[sTrace][sData];
const size_t nPoints = jData.size();
for (size_t j = 0; j < N_POINTS; ++j) {
const std::vector<float>& VARIABLES = J_DATA[j];
for (size_t j = 0; j < nPoints; ++j) {
const std::vector<float>& variables = jData[j];
// Expects the x, y and z variables to be stored first!
const size_t X_IDX = 0, Y_IDX = 1, Z_IDX = 2;
_vertexPositions.push_back(COORD_TO_METERS * glm::vec3(VARIABLES[X_IDX],
VARIABLES[Y_IDX],
VARIABLES[Z_IDX]));
const size_t xIdx = 0, yIdx = 1, zIdx = 2;
_vertexPositions.push_back(coordToMeters * glm::vec3(variables[xIdx],
variables[yIdx],
variables[zIdx]));
// Add the extra quantites. Stored in the same array as the x,y,z variables.
// Hence index of the first extra quantity = 3
for (size_t xtraIdx = 3, k = 0 ; k < N_EXTRAS; ++k, ++xtraIdx) {
_extraQuantities[k].push_back(VARIABLES[xtraIdx]);
for (size_t xtraIdx = 3, k = 0 ; k < nExtras; ++k, ++xtraIdx) {
_extraQuantities[k].push_back(variables[xtraIdx]);
}
}
_lineCount.push_back(static_cast<GLsizei>(N_POINTS));
_lineCount.push_back(static_cast<GLsizei>(nPoints));
_lineStart.push_back(static_cast<GLsizei>(lineStartIdx));
lineStartIdx += N_POINTS;
lineStartIdx += nPoints;
}
return true;
}
/**
* @param ABS_FILEPATH must be the path to the file (incl. filename but excl. extension!)
* @param absPath must be the path to the file (incl. filename but excl. extension!)
* Directory must exist! File is created (or overwritten if already existing).
* File is structured like this: (for version 0)
* 0. int - version number of binary state file! (in case something needs to be altered in the future, then increase CURRENT_VERSION)
* 0. int - version number of binary state file! (in case something needs to be altered in the future, then increase CurrentVersion)
* 1. double - _triggerTime
* 2. int - _model
* 3. bool - _isMorphable
@@ -459,17 +459,17 @@ bool FieldlinesState::loadStateFromJson(const std::string& PATH_TO_JSON_FILE,
* 10. std::vector<float> - _extraQuantities
* 11. array of c_str - Strings naming the extra quantities (elements of _extraQuantityNames). Each string ends with null char '\0'
*/
void FieldlinesState::saveStateToOsfls(const std::string& ABS_FILEPATH) {
void FieldlinesState::saveStateToOsfls(const std::string& absPath) {
// ------------------------------- Create the file ------------------------------- //
std::string pathSafeTimeString = Time(_triggerTime).ISO8601();
pathSafeTimeString.replace(13, 1, "-");
pathSafeTimeString.replace(16, 1, "-");
pathSafeTimeString.replace(19, 1, "-");
const std::string FILENAME = pathSafeTimeString + ".osfls";
const std::string fileName = pathSafeTimeString + ".osfls";
std::ofstream ofs(ABS_FILEPATH + FILENAME, std::ofstream::binary | std::ofstream::trunc);
std::ofstream ofs(absPath + fileName, std::ofstream::binary | std::ofstream::trunc);
if (!ofs.is_open()) {
LERROR("Failed to save state to binary file: " << ABS_FILEPATH << FILENAME);
LERROR("Failed to save state to binary file: " << absPath << fileName);
return;
}
@@ -479,34 +479,34 @@ void FieldlinesState::saveStateToOsfls(const std::string& ABS_FILEPATH) {
allExtraQuantityNamesInOne += str + '\0'; // Add the null char '\0' for easier reading
}
const size_t N_LINES = _lineStart.size();
const size_t N_POINTS = _vertexPositions.size();
const size_t N_EXTRAS = _extraQuantities.size();
const size_t N_STRING_BYTES = allExtraQuantityNamesInOne.size();
const size_t nLines = _lineStart.size();
const size_t nPoints = _vertexPositions.size();
const size_t nExtras = _extraQuantities.size();
const size_t nStringBytes = allExtraQuantityNamesInOne.size();
//------------------------------ WRITE EVERYTHING TO FILE ------------------------------
// WHICH VERSION OF BINARY FIELDLINES STATE FILE - IN CASE STRUCTURE CHANGES IN THE FUTURE
ofs.write( (char*)(&CURRENT_VERSION), sizeof( int ) );
ofs.write( (char*)(&CurrentVersion), sizeof( int ) );
//-------------------- WRITE META DATA FOR STATE --------------------------------
ofs.write( reinterpret_cast<char*>(&_triggerTime), sizeof( _triggerTime ) );
ofs.write( reinterpret_cast<char*>(&_model), sizeof( int ) );
ofs.write( reinterpret_cast<char*>(&_isMorphable), sizeof( bool ) );
ofs.write( reinterpret_cast<char*>(&_triggerTime), sizeof( _triggerTime ) );
ofs.write( reinterpret_cast<char*>(&_model), sizeof( int ) );
ofs.write( reinterpret_cast<char*>(&_isMorphable), sizeof( bool ) );
ofs.write( reinterpret_cast<const char*>(&N_LINES), sizeof( size_t ) );
ofs.write( reinterpret_cast<const char*>(&N_POINTS), sizeof( size_t ) );
ofs.write( reinterpret_cast<const char*>(&N_EXTRAS), sizeof( size_t ) );
ofs.write( reinterpret_cast<const char*>(&N_STRING_BYTES), sizeof( size_t ) );
ofs.write( reinterpret_cast<const char*>(&nLines), sizeof( size_t ) );
ofs.write( reinterpret_cast<const char*>(&nPoints), sizeof( size_t ) );
ofs.write( reinterpret_cast<const char*>(&nExtras), sizeof( size_t ) );
ofs.write( reinterpret_cast<const char*>(&nStringBytes), sizeof( size_t ) );
//---------------------- WRITE ALL ARRAYS OF DATA --------------------------------
ofs.write( reinterpret_cast<char*>(_lineStart.data()), sizeof(GLint) * N_LINES);
ofs.write( reinterpret_cast<char*>(_lineCount.data()), sizeof(GLsizei) * N_LINES);
ofs.write( reinterpret_cast<char*>(_vertexPositions.data()), sizeof(glm::vec3) * N_POINTS);
ofs.write( reinterpret_cast<char*>(_lineStart.data()), sizeof(GLint) * nLines);
ofs.write( reinterpret_cast<char*>(_lineCount.data()), sizeof(GLsizei) * nLines);
ofs.write( reinterpret_cast<char*>(_vertexPositions.data()), sizeof(glm::vec3) * nPoints);
// Write the data for each vector in _extraQuantities
for (std::vector<float>& vec : _extraQuantities) {
ofs.write( reinterpret_cast<char*>(vec.data()), sizeof(float) * N_POINTS);
ofs.write( reinterpret_cast<char*>(vec.data()), sizeof(float) * nPoints);
}
ofs.write( allExtraQuantityNamesInOne.c_str(), N_STRING_BYTES);
ofs.write( allExtraQuantityNamesInOne.c_str(), nStringBytes);
}
// TODO: This should probably be rewritten, but this is the way the files were structured by CCMC
@@ -529,15 +529,15 @@ void FieldlinesState::saveStateToOsfls(const std::string& ABS_FILEPATH) {
// },
// }
// }
void FieldlinesState::saveStateToJson(const std::string& ABS_FILEPATH) {
void FieldlinesState::saveStateToJson(const std::string& absPath) {
// Create the file
const std::string EXT = ".json";
std::ofstream ofs(ABS_FILEPATH + EXT, std::ofstream::trunc);
const std::string ext = ".json";
std::ofstream ofs(absPath + ext, std::ofstream::trunc);
if (!ofs.is_open()) {
LERROR("Failed to save state to json file at location: " << ABS_FILEPATH << EXT);
LERROR("Failed to save state to json file at location: " << absPath << ext);
return;
}
LINFO("Saving fieldline state to: " << ABS_FILEPATH << EXT );
LINFO("Saving fieldline state to: " << absPath << ext );
json jColumns = {"x", "y", "z"};
for (std::string s : _extraQuantityNames) {
@@ -546,27 +546,26 @@ void FieldlinesState::saveStateToJson(const std::string& ABS_FILEPATH) {
json jFile;
const std::string TIME_STRING = Time(_triggerTime).ISO8601();
const size_t N_LINES = _lineStart.size();
const size_t N_POINTS = _vertexPositions.size();
const size_t N_EXTRAS = _extraQuantities.size();
const std::string timeStr = Time(_triggerTime).ISO8601();
const size_t nLines = _lineStart.size();
const size_t nPoints = _vertexPositions.size();
const size_t nExtras = _extraQuantities.size();
size_t pointIndex = 0;
for (size_t lineIndex = 0; lineIndex < N_LINES; lineIndex++) {
for (size_t lineIndex = 0; lineIndex < nLines; lineIndex++) {
json jData = json::array();
for (size_t i = 0; i < _lineCount[lineIndex]; i++, pointIndex++) {
const glm::vec3 POS = _vertexPositions[pointIndex];
json jDataElement = {POS.x, POS.y, POS.z};
const glm::vec3 pos = _vertexPositions[pointIndex];
json jDataElement = {pos.x, pos.y, pos.z};
for (size_t extraIndex = 0; extraIndex < N_EXTRAS; extraIndex++) {
for (size_t extraIndex = 0; extraIndex < nExtras; extraIndex++) {
jDataElement.push_back(_extraQuantities[extraIndex][pointIndex]);
}
jData.push_back(jDataElement);
}
jFile[std::to_string(lineIndex)] = {
{"time", TIME_STRING},
{"time", timeStr},
{"trace", {
{"columns", jColumns},
{"data", jData}
@@ -575,19 +574,19 @@ void FieldlinesState::saveStateToJson(const std::string& ABS_FILEPATH) {
}
//------------------------------ WRITE EVERYTHING TO FILE ------------------------------
const int INDENTATION_SPACES = 2;
ofs << std::setw(INDENTATION_SPACES) << jFile << std::endl;
const int indentationSpaces = 2;
ofs << std::setw(indentationSpaces) << jFile << std::endl;
LINFO("Saved fieldline state to: " << ABS_FILEPATH << EXT );
LINFO("Saved fieldline state to: " << absPath << ext );
}
// Returns one of the extra quantity vectors, _extraQuantities[INDEX].
// If INDEX is out of scope an empty vector is returned and the referenced bool will be false.
const std::vector<float>& FieldlinesState::extraQuantity(const size_t INDEX,
// Returns one of the extra quantity vectors, _extraQuantities[index].
// If index is out of scope an empty vector is returned and the referenced bool will be false.
const std::vector<float>& FieldlinesState::extraQuantity(const size_t index,
bool& isSuccessful) const {
if (INDEX < _extraQuantities.size()) {
if (index < _extraQuantities.size()) {
isSuccessful = true;
return _extraQuantities[INDEX];
return _extraQuantities[index];
}
isSuccessful = false;
// return empty vector which goes out of scope hence unusable!

View File

@@ -46,23 +46,23 @@ public:
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
bool addLinesFromKameleon(ccmc::Kameleon* kameleon,
const std::vector<glm::vec3>& SEED_POINTS,
const std::string TRACING_VAR);
const std::vector<glm::vec3>& seedPoints,
const std::string tracingVar);
void addExtraQuantities(ccmc::Kameleon* kameleon,
std::vector<std::string>& xtraScalarVars,
std::vector<std::string>& xtraMagVars);
void convertLatLonToCartesian(const float SCALE = 1.f);
void scalePositions(const float SCALE);
void convertLatLonToCartesian(const float scale = 1.f);
void scalePositions(const float scale);
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
bool loadStateFromOsfls(const std::string& PATH_TO_OSFLS_FILE);
void saveStateToOsfls(const std::string& PATH_TO_OSFLS_FILE);
bool loadStateFromOsfls(const std::string& pathToOsflsFile);
void saveStateToOsfls(const std::string& pathToOsflsFile);
bool loadStateFromJson(const std::string& PATH_TO_JSON_FILE,
const fls::Model MODEL, const float COORD_TO_METERS);
void saveStateToJson(const std::string& PATH_TO_JSON_FILE);
bool loadStateFromJson(const std::string& pathToJsonFile,
const fls::Model model, const float coordToMeters);
void saveStateToJson(const std::string& pathToJsonFile);
// ------------------------------GETTERS-----------------------------------------//
// ----------------------------------- GETTERS ----------------------------------- //
const std::vector<std::vector<float>>& extraQuantities() const { return _extraQuantities; }
const std::vector<std::string>& extraQuantityNames() const { return _extraQuantityNames; }
const std::vector<GLsizei>& lineCount() const { return _lineCount; }

View File

@@ -34,7 +34,7 @@ namespace ccmc {
namespace openspace::kameleonHelper {
std::unique_ptr<ccmc::Kameleon> createKameleonObject(const std::string& CDF_FILE_PATH);
std::unique_ptr<ccmc::Kameleon> createKameleonObject(const std::string& cdfFilePath);
double getTime(ccmc::Kameleon* kameleon);
} //namespace openspace::kameleonHelper

View File

@@ -42,18 +42,18 @@ namespace openspace::kameleonHelper {
*
* Returns 'nullptr' if the file fails to open!
*/
std::unique_ptr<ccmc::Kameleon> createKameleonObject(const std::string& CDF_FILE_PATH) {
std::unique_ptr<ccmc::Kameleon> createKameleonObject(const std::string& cdfFilePath) {
// ---------------------------- CREATE KAMELEON OBJECT ---------------------------- //
std::unique_ptr<ccmc::Kameleon> kameleon = std::make_unique<ccmc::Kameleon>();
LDEBUG("\tOpening the cdf file: " << CDF_FILE_PATH);
long kamStatus = kameleon->open(CDF_FILE_PATH);
LDEBUG("\tOpening the cdf file: " << cdfFilePath);
long kamStatus = kameleon->open(cdfFilePath);
if (kamStatus != ccmc::FileReader::OK) {
LERROR("Failed to create a Kameleon Object from file: " << CDF_FILE_PATH);
LERROR("Failed to create a Kameleon Object from file: " << cdfFilePath);
return nullptr;
}
LDEBUG("\tSuccessfully opened : " << CDF_FILE_PATH);
LDEBUG("\tSuccessfully opened : " << cdfFilePath);
return kameleon;
}