Move stringToModel function to utils/commons.cpp

This commit is contained in:
Oskar Carlbaum
2017-10-09 19:45:04 +02:00
parent c4c576eaa2
commit caa98a4a62
4 changed files with 45 additions and 13 deletions

View File

@@ -35,6 +35,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefieldlinessequence.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefieldlinessequencesetup.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/fieldlinesstate.cpp
${CMAKE_CURRENT_SOURCE_DIR}/util/commons.cpp
)
source_group("Source Files" FILES ${SOURCE_FILES})

View File

@@ -149,17 +149,6 @@ namespace {
}
return tmp;
}
openspace::fls::Model stringToModel(const std::string S) {
if (S == "batsrus") {
return openspace::fls::Model::BATSRUS;
} else if (S == "enlil") {
return openspace::fls::Model::ENLIL;
} else if (S == "pfss") {
return openspace::fls::Model::PFSS;
}
return openspace::fls::Model::INVALID;
}
} // namespace
namespace openspace {
@@ -445,7 +434,7 @@ bool RenderableFieldlinesSequence::extractJsonInfoFromDictionary(fls::Model& mod
std::string modelStr;
if (_dictionary->getValue(KEY_JSON_SIMULATION_MODEL, modelStr)) {
std::transform(modelStr.begin(), modelStr.end(), modelStr.begin(), ::tolower);
model = stringToModel(modelStr);
model = fls::stringToModel(modelStr);
} else {
LERROR(_name << ": Must specify '" << KEY_JSON_SIMULATION_MODEL << "'");
return false;

View File

@@ -0,0 +1,42 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2017 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/fieldlinessequence/util/commons.h>
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;
}
return Model::INVALID;
}
} // namespace fls
} // namespace openspace

View File

@@ -37,7 +37,7 @@ enum Model : int {
INVALID
};
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