Move all kameleon dependency to separate files named 'kameleonfieldlinehelper'

This commit is contained in:
Oskar Carlbaum
2017-10-22 14:55:59 +02:00
parent 69fd2ed8a4
commit afd91fc4af
7 changed files with 454 additions and 323 deletions
@@ -136,38 +136,33 @@ private:
properties::TriggerProperty _pJumpToStartBtn; // Button which executes a time jump to start of sequence
// --------------------- FUNCTIONS USED DURING INITIALIZATION --------------------- //
void addStateToSequence(FieldlinesState& STATE);
void computeSequenceEndTime();
void definePropertyCallbackFunctions();
bool extractJsonInfoFromDictionary(fls::Model& model);
bool extractMandatoryInfoFromDictionary(SourceFileType& sourceFileType);
void extractOptionalInfoFromDictionary(std::string& outputFolderPath);
void extractOsflsInfoFromDictionary();
void extractTriggerTimesFromFileNames();
bool loadJsonStatesIntoRAM(const std::string& outputFolder);
void loadOsflsStatesIntoRAM(const std::string& outputFolder);
void setModelDependentConstants();
void setupProperties();
bool prepareForOsflsStreaming();
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
// --- Initialization functions which require the kameleon module to be loaded! --- //
bool extractCdfInfoFromDictionary(std::string& seedFilePath,
std::string& tracingVar,
std::vector<std::string>& extraVars);
bool extractSeedPointsFromFile(const std::string& path,
std::vector<glm::vec3>& outVec);
void extractMagnitudeVarsFromStrings(std::vector<std::string>& extraVars,
std::vector<std::string>& extraMagVars);
bool getStatesFromCdfFiles(const std::string& outputFolder);
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
void addStateToSequence(FieldlinesState& STATE);
void computeSequenceEndTime();
void definePropertyCallbackFunctions();
bool extractCdfInfoFromDictionary(std::string& seedFilePath, std::string& tracingVar,
std::vector<std::string>& extraVars);
bool extractJsonInfoFromDictionary(fls::Model& model);
void extractMagnitudeVarsFromStrings(std::vector<std::string>& extraVars,
std::vector<std::string>& extraMagVars);
bool extractMandatoryInfoFromDictionary(SourceFileType& sourceFileType);
void extractOptionalInfoFromDictionary(std::string& outputFolderPath);
void extractOsflsInfoFromDictionary();
bool extractSeedPointsFromFile(const std::string& path, std::vector<glm::vec3>& outVec);
void extractTriggerTimesFromFileNames();
bool loadJsonStatesIntoRAM(const std::string& outputFolder);
void loadOsflsStatesIntoRAM(const std::string& outputFolder);
bool getStatesFromCdfFiles(const std::string& outputFolder);
void setModelDependentConstants();
void setupProperties();
bool prepareForOsflsStreaming();
// ------------------------- FUNCTIONS USED DURING RUNTIME ------------------------ //
inline bool isWithinSequenceInterval(const double currentTime) const;
void readNewState(const std::string& filePath);
void updateActiveTriggerTimeIndex(const double currentTime);
void updateVertexPositionBuffer();
void updateVertexColorBuffer();
void updateVertexMaskingBuffer();
void readNewState(const std::string& filePath);
void updateActiveTriggerTimeIndex(const double currentTime);
void updateVertexPositionBuffer();
void updateVertexColorBuffer();
void updateVertexMaskingBuffer();
};
} // namespace openspace
@@ -24,10 +24,7 @@
#include <modules/fieldlinessequence/rendering/renderablefieldlinessequence.h>
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
#include <ccmc/Kameleon.h>
#include <modules/kameleon/include/kameleonhelper.h>
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
#include <modules/fieldlinessequence/util/kameleonfieldlinehelper.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/interaction/navigationhandler.h>
@@ -224,11 +221,9 @@ void RenderableFieldlinesSequence::initialize() {
// EXTRACT SOURCE FILE TYPE SPECIFIC INFOMRATION FROM DICTIONARY & GET STATES FROM SOURCE
switch (sourceFileType) {
case SourceFileType::Cdf:
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
if (!getStatesFromCdfFiles(outputFolderPath)) {
return;
}
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
break;
case SourceFileType::Json:
if (!loadJsonStatesIntoRAM(outputFolderPath)) {
@@ -313,10 +308,6 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary(
// Verify that the input type is correct
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 == ValueInputFileTypeJson) {
sourceFileType = SourceFileType::Json;
} else if (inputFileTypeString == ValueInputFileTypeOsfls) {
@@ -705,7 +696,6 @@ void RenderableFieldlinesSequence::addStateToSequence(FieldlinesState& state) {
_nStates++;
}
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
bool RenderableFieldlinesSequence::getStatesFromCdfFiles(const std::string& outputFolder) {
std::string seedFilePath;
@@ -724,30 +714,13 @@ bool RenderableFieldlinesSequence::getStatesFromCdfFiles(const std::string& outp
extractMagnitudeVarsFromStrings(extraVars, extraMagVars);
// Load states into RAM!
for (std::string filePath : _sourceFiles) {
// Create Kameleon object and open CDF file!
std::unique_ptr<ccmc::Kameleon> kameleon =
kameleonHelper::createKameleonObject(filePath);
for (std::string cdfPath : _sourceFiles) {
FieldlinesState newState;
newState.setTriggerTime(kameleonHelper::getTime(kameleon.get()));
if (newState.addLinesFromKameleon(kameleon.get(), seedPoints, tracingVar)) {
// The line points are in their RAW format (unscaled & maybe spherical)
// Before we scale to meters (and maybe cartesian) we must extract
// the extraQuantites, as the iterpolator needs the unaltered positions
newState.addExtraQuantities(kameleon.get(), extraVars, extraMagVars);
switch (newState.model()) {
case fls::Batsrus:
newState.scalePositions(fls::ReToMeter);
break;
case fls::Enlil :
newState.convertLatLonToCartesian(fls::AuToMeter);
break;
default:
break;
}
bool isSuccessful = fls::convertCdfToFieldlinesState(newState, cdfPath,
seedPoints, tracingVar, extraVars, extraMagVars);
if (isSuccessful) {
addStateToSequence(newState);
if (!outputFolder.empty()) {
newState.saveStateToOsfls(outputFolder);
@@ -756,9 +729,7 @@ bool RenderableFieldlinesSequence::getStatesFromCdfFiles(const std::string& outp
}
return true;
}
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
/*
* Returns false if it fails to extract mandatory information!
*/
@@ -798,9 +769,7 @@ bool RenderableFieldlinesSequence::extractCdfInfoFromDictionary(
return true;
}
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
bool RenderableFieldlinesSequence::extractSeedPointsFromFile(
const std::string& path,
std::vector<glm::vec3>& outVec) {
@@ -829,14 +798,11 @@ bool RenderableFieldlinesSequence::extractSeedPointsFromFile(
return true;
}
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
#ifdef OPENSPACE_MODULE_KAMELEON_ENABLED
void RenderableFieldlinesSequence::extractMagnitudeVarsFromStrings(
std::vector<std::string>& extraVars,
std::vector<std::string>& extraMagVars) {
for (int i = 0; i < extraVars.size(); i++) {
const std::string str = extraVars[i];
// Check if string is in the format specified for magnitude variables
@@ -861,6 +827,5 @@ void RenderableFieldlinesSequence::extractMagnitudeVarsFromStrings(
}
}
}
#endif // OPENSPACE_MODULE_KAMELEON_ENABLED
} // namespace openspace