Untabify more files

This commit is contained in:
Alexander Bock
2016-04-18 15:15:30 +02:00
parent c8da825098
commit a21c9538b6
10 changed files with 533 additions and 533 deletions
+4 -4
View File
@@ -166,11 +166,11 @@ QScrollBar::add-page, QScrollBar::sub-page {
)style";
int main(int argc, char** argv) {
QApplication app(argc, argv);
QApplication app(argc, argv);
app.setStyleSheet(style);
MainWindow window;
window.show();
MainWindow window;
window.show();
return app.exec();
return app.exec();
}
+16 -16
View File
@@ -104,58 +104,58 @@ MainWindow::MainWindow()
QWidget* container = new QWidget;
{
QGridLayout* layout = new QGridLayout;
QGridLayout* innerLayout = new QGridLayout;
QLabel* shortcutLabel = new QLabel("Keyboard Shortcuts:");
layout->addWidget(shortcutLabel, 0, 0);
innerLayout->addWidget(shortcutLabel, 0, 0);
QPushButton* shortcutButton = new QPushButton("Open...");
QObject::connect(shortcutButton, SIGNAL(clicked(bool)),
this, SLOT(shortcutButtonPressed())
);
layout->addWidget(shortcutButton, 0, 1);
innerLayout->addWidget(shortcutButton, 0, 1);
layout->setRowStretch(1, 10);
innerLayout->setRowStretch(1, 10);
QLabel* configurationSelectionLabel = new QLabel("Configuration:");
layout->addWidget(configurationSelectionLabel, 2, 0);
innerLayout->addWidget(configurationSelectionLabel, 2, 0);
_configurations = new QComboBox;
layout->addWidget(_configurations, 2, 1);
innerLayout->addWidget(_configurations, 2, 1);
QLabel* sceneSelectionLabel = new QLabel("Scenes:");
layout->addWidget(sceneSelectionLabel, 3, 0);
innerLayout->addWidget(sceneSelectionLabel, 3, 0);
_scenes = new QComboBox;
layout->addWidget(_scenes, 3, 1);
innerLayout->addWidget(_scenes, 3, 1);
container->setLayout(layout);
container->setLayout(innerLayout);
}
layout->addWidget(container, 1, 1);
container = new QWidget;
{
QBoxLayout* layout = new QHBoxLayout;
QBoxLayout* innerLayout = new QHBoxLayout;
QPushButton* cancelButton = new QPushButton("Cancel");
QObject::connect(
cancelButton, SIGNAL(clicked(bool)),
QApplication::instance(), SLOT(quit())
);
layout->addWidget(cancelButton);
innerLayout->addWidget(cancelButton);
QPushButton* syncButton = new QPushButton("Sync");
QObject::connect(
syncButton, SIGNAL(clicked(bool)),
this, SLOT(syncButtonPressed())
);
layout->addWidget(syncButton);
innerLayout->addWidget(syncButton);
QPushButton* startButton = new QPushButton("Start");
QObject::connect(
startButton, SIGNAL(clicked(bool)),
this, SLOT(startButtonPressed())
);
layout->addWidget(startButton);
innerLayout->addWidget(startButton);
container->setLayout(layout);
container->setLayout(innerLayout);
}
layout->addWidget(container, 2, 1);
@@ -257,8 +257,8 @@ void MainWindow::newsNetworkError() {
}
void MainWindow::newsReadyRead() {
QByteArray data = _newsReply->readAll();
QString news = QString::fromLatin1(data);
QByteArray arrayData = _newsReply->readAll();
QString news = QString::fromLatin1(arrayData);
_informationWidget->setText(news);
_newsReply->deleteLater();
}
+3 -3
View File
@@ -167,9 +167,9 @@ int main(int argc, char** argv) {
LDEBUG("Starting rendering loop");
_sgctEngine->render();
//clear function bindings to avoid crash after destroying the OpenSpace Engine
sgct::MessageHandler::instance()->setLogToCallback(false);
sgct::MessageHandler::instance()->setLogCallback(nullptr);
//clear function bindings to avoid crash after destroying the OpenSpace Engine
sgct::MessageHandler::instance()->setLogToCallback(false);
sgct::MessageHandler::instance()->setLogCallback(nullptr);
LDEBUG("Destroying OpenSpaceEngine");
openspace::OpenSpaceEngine::destroy();
@@ -116,7 +116,7 @@ public:
* configuration file
* \pre \p filename must not be empty
*/
void loadFromFile(const std::string& filename);
void loadFromFile(const std::string& filename);
private:
/**
@@ -126,7 +126,7 @@ private:
* \return <code>true</code> if the configuration file was complete;
* <code>false</code> otherwise
*/
bool checkCompleteness() const;
bool checkCompleteness() const;
};
} // namespace openspace
+38 -38
View File
@@ -60,16 +60,16 @@ public:
Invalid
};
static const std::string PerformanceMeasurementSharedData;
static const std::string PerformanceMeasurementSharedData;
static const std::string KeyFontMono;
static const std::string KeyFontLight;
RenderEngine();
~RenderEngine();
bool initialize();
bool deinitialize();
RenderEngine();
~RenderEngine();
bool initialize();
bool deinitialize();
void setSceneGraph(Scene* sceneGraph);
Scene* scene();
@@ -79,24 +79,24 @@ public:
RendererImplementation rendererImplementation() const;
RaycasterManager& raycasterManager();
// sgct wrapped functions
// sgct wrapped functions
bool initializeGL();
void postSynchronizationPreDraw();
void preSynchronization();
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
void preSynchronization();
void render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix);
void postDraw();
void takeScreenshot();
void toggleInfoText(bool b);
void takeScreenshot();
void toggleInfoText(bool b);
void setPerformanceMeasurements(bool performanceMeasurements);
bool doesPerformanceMeasurements() const;
void setPerformanceMeasurements(bool performanceMeasurements);
bool doesPerformanceMeasurements() const;
void serialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
void serialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
float globalBlackOutFactor();
void setGlobalBlackOutFactor(float factor);
float globalBlackOutFactor();
void setGlobalBlackOutFactor(float factor);
void setDisableRenderingOnMaster(bool enabled);
@@ -122,18 +122,18 @@ public:
* as a 'rendererData' variable in the dictionary.
*/
void setRendererData(const ghoul::Dictionary& renderer);
/**
* Returns the Lua library that contains all Lua functions available to affect the
* rendering.
*/
static scripting::ScriptEngine::LuaLibrary luaLibrary();
/**
* Returns the Lua library that contains all Lua functions available to affect the
* rendering.
*/
static scripting::ScriptEngine::LuaLibrary luaLibrary();
// This is a temporary method to change the origin of the coordinate system ---abock
void changeViewPoint(std::string origin);
// Temporary fade functionality
void startFading(int direction, float fadeDuration);
// Temporary fade functionality
void startFading(int direction, float fadeDuration);
// This is temporary until a proper screenspace solution is found ---abock
struct {
@@ -145,30 +145,30 @@ public:
private:
void setRenderer(std::unique_ptr<Renderer> renderer);
RendererImplementation rendererFromString(const std::string& method);
void storePerformanceMeasurements();
void storePerformanceMeasurements();
void renderInformation();
void renderScreenLog();
Camera* _mainCamera;
Scene* _sceneGraph;
Camera* _mainCamera;
Scene* _sceneGraph;
RaycasterManager* _raycasterManager;
std::unique_ptr<Renderer> _renderer;
RendererImplementation _rendererImplementation;
ghoul::Dictionary _rendererData;
ScreenLog* _log;
ScreenLog* _log;
bool _showInfo;
bool _showLog;
bool _takeScreenshot;
bool _showInfo;
bool _showLog;
bool _takeScreenshot;
bool _doPerformanceMeasurements;
ghoul::SharedMemory* _performanceMemory;
bool _doPerformanceMeasurements;
ghoul::SharedMemory* _performanceMemory;
float _globalBlackOutFactor;
float _fadeDuration;
float _currentFadeTime;
int _fadeDirection;
float _globalBlackOutFactor;
float _fadeDuration;
float _currentFadeTime;
int _fadeDirection;
std::vector<ghoul::opengl::ProgramObject*> _programs;
+75 -75
View File
@@ -57,20 +57,20 @@ namespace openspace {
RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _colorTexturePath("colorTexture", "Color Texture")
, _colorTexturePath("colorTexture", "Color Texture")
, _programObject(nullptr)
, _texture(nullptr)
, _nightTexture(nullptr)
, _nightTexture(nullptr)
, _geometry(nullptr)
, _performShading("performShading", "Perform Shading", true)
, _rotation("rotation", "Rotation", 0, 0, 360)
, _alpha(1.f)
, _rotation("rotation", "Rotation", 0, 0, 360)
, _alpha(1.f)
, _nightTexturePath("")
, _hasNightTexture(false)
{
std::string name;
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
ghoul_assert(success,
std::string name;
bool success = dictionary.getValue(SceneGraphNode::KeyName, name);
ghoul_assert(success,
"RenderablePlanet need the '" << SceneGraphNode::KeyName<<"' be specified");
//std::string path;
@@ -80,35 +80,35 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
ghoul::Dictionary geometryDictionary;
success = dictionary.getValue(keyGeometry, geometryDictionary);
if (success) {
geometryDictionary.setValue(SceneGraphNode::KeyName, name);
if (success) {
geometryDictionary.setValue(SceneGraphNode::KeyName, name);
//geometryDictionary.setValue(constants::scenegraph::keyPathModule, path);
_geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary);
}
}
dictionary.getValue(keyFrame, _frame);
dictionary.getValue(keyBody, _target);
if (_target != "")
setBody(_target);
dictionary.getValue(keyFrame, _frame);
dictionary.getValue(keyBody, _target);
if (_target != "")
setBody(_target);
// TODO: textures need to be replaced by a good system similar to the geometry as soon
// as the requirements are fixed (ab)
std::string texturePath = "";
success = dictionary.getValue("Textures.Color", texturePath);
if (success)
success = dictionary.getValue("Textures.Color", texturePath);
if (success)
_colorTexturePath = absPath(texturePath);
std::string nightTexturePath = "";
dictionary.getValue("Textures.Night", nightTexturePath);
if (nightTexturePath != ""){
_hasNightTexture = true;
_nightTexturePath = absPath(nightTexturePath);
}
std::string nightTexturePath = "";
dictionary.getValue("Textures.Night", nightTexturePath);
if (nightTexturePath != ""){
_hasNightTexture = true;
_nightTexturePath = absPath(nightTexturePath);
}
addPropertySubOwner(_geometry);
addPropertySubOwner(_geometry);
addProperty(_colorTexturePath);
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderablePlanet::loadTexture, this));
if (dictionary.hasKeyAndValue<bool>(keyShading)) {
@@ -118,8 +118,8 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
}
addProperty(_performShading);
// Mainly for debugging purposes @AA
addProperty(_rotation);
// Mainly for debugging purposes @AA
addProperty(_rotation);
}
RenderablePlanet::~RenderablePlanet() {
@@ -167,7 +167,7 @@ bool RenderablePlanet::deinitialize() {
_geometry = nullptr;
_texture = nullptr;
_nightTexture = nullptr;
_nightTexture = nullptr;
return true;
}
@@ -176,7 +176,7 @@ bool RenderablePlanet::isReady() const {
ready &= (_programObject != nullptr);
ready &= (_texture != nullptr);
ready &= (_geometry != nullptr);
return ready;
return ready;
}
void RenderablePlanet::render(const RenderData& data)
@@ -186,50 +186,50 @@ void RenderablePlanet::render(const RenderData& data)
// scale the planet to appropriate size since the planet is a unit sphere
glm::mat4 transform = glm::mat4(1);
//earth needs to be rotated for that to work.
glm::mat4 rot = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
glm::mat4 roty = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, -1, 0));
glm::mat4 rotProp = glm::rotate(transform, glm::radians(static_cast<float>(_rotation)), glm::vec3(0, 1, 0));
//earth needs to be rotated for that to work.
glm::mat4 rot = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(1, 0, 0));
glm::mat4 roty = glm::rotate(transform, static_cast<float>(M_PI_2), glm::vec3(0, -1, 0));
glm::mat4 rotProp = glm::rotate(transform, glm::radians(static_cast<float>(_rotation)), glm::vec3(0, 1, 0));
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}
transform = transform * rot * roty * rotProp;
//glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
//glm::vec3 camSpaceEye = (-(modelview*data.position.vec4())).xyz;
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}
transform = transform * rot * roty * rotProp;
//glm::mat4 modelview = data.camera.viewMatrix()*data.camera.modelMatrix();
//glm::vec3 camSpaceEye = (-(modelview*data.position.vec4())).xyz;
double lt;
double lt;
glm::dvec3 p =
SpiceManager::ref().targetPosition("SUN", _target, "GALACTIC", {}, _time, lt);
psc sun_pos = PowerScaledCoordinate::CreatePowerScaledCoordinate(p.x, p.y, p.z);
// setup the data to the shader
// _programObject->setUniform("camdir", camSpaceEye);
_programObject->setUniform("transparency", _alpha);
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(*_programObject.get(), data.camera, data.position);
_programObject->setUniform("transparency", _alpha);
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(*_programObject.get(), data.camera, data.position);
_programObject->setUniform("_performShading", _performShading);
// Bind texture
ghoul::opengl::TextureUnit dayUnit;
dayUnit.activate();
ghoul::opengl::TextureUnit dayUnit;
dayUnit.activate();
_texture->bind();
_programObject->setUniform("texture1", dayUnit);
_programObject->setUniform("texture1", dayUnit);
// Bind possible night texture
if (_hasNightTexture) {
ghoul::opengl::TextureUnit nightUnit;
nightUnit.activate();
_nightTexture->bind();
_programObject->setUniform("nightTex", nightUnit);
}
// Bind possible night texture
if (_hasNightTexture) {
ghoul::opengl::TextureUnit nightUnit;
nightUnit.activate();
_nightTexture->bind();
_programObject->setUniform("nightTex", nightUnit);
}
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
@@ -242,37 +242,37 @@ void RenderablePlanet::render(const RenderData& data)
}
void RenderablePlanet::update(const UpdateData& data){
// set spice-orientation in accordance to timestamp
// set spice-orientation in accordance to timestamp
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time);
_time = data.time;
_time = data.time;
}
void RenderablePlanet::loadTexture() {
_texture = nullptr;
if (_colorTexturePath.value() != "") {
if (_colorTexturePath.value() != "") {
_texture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath)));
if (_texture) {
LDEBUG("Loaded texture from '" << _colorTexturePath << "'");
_texture->uploadTexture();
_texture->uploadTexture();
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
// Textures of planets looks much smoother with AnisotropicMipMap rather than linear
// TODO: AnisotropicMipMap crashes on ATI cards ---abock
//_texture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_texture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
}
}
if (_hasNightTexture) {
_nightTexture = nullptr;
if (_nightTexturePath != "") {
if (_hasNightTexture) {
_nightTexture = nullptr;
if (_nightTexturePath != "") {
_nightTexture = std::move(ghoul::io::TextureReader::ref().loadTexture(absPath(_nightTexturePath)));
if (_nightTexture) {
LDEBUG("Loaded texture from '" << _nightTexturePath << "'");
_nightTexture->uploadTexture();
if (_nightTexture) {
LDEBUG("Loaded texture from '" << _nightTexturePath << "'");
_nightTexture->uploadTexture();
_nightTexture->setFilter(ghoul::opengl::Texture::FilterMode::Linear);
//_nightTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
}
}
}
//_nightTexture->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
}
}
}
}
} // namespace openspace
+215 -215
View File
@@ -36,9 +36,9 @@
#include <modules/newhorizons/util/labelparser.h>
namespace {
const std::string _loggerCat = "LabelParser";
const std::string keySpecs = "Read";
const std::string keyConvert = "Convert";
const std::string _loggerCat = "LabelParser";
const std::string keySpecs = "Read";
const std::string keyConvert = "Convert";
const std::string PlaybookIdentifierName = "LabelParser";
}
@@ -50,170 +50,170 @@ LabelParser::LabelParser(std::string name, const std::string& fileName,
: _name(std::move(name))
, _badDecoding(false)
{
_fileName = fileName;
//get the different instrument types
const std::vector<std::string>& decoders = translationDictionary.keys();
//for each decoder (assuming might have more if hong makes changes)
for (int i = 0; i < decoders.size(); i++){
ghoul::Dictionary typeDictionary;
translationDictionary.getValue(decoders[i], typeDictionary);
_fileName = fileName;
//get the different instrument types
const std::vector<std::string>& decoders = translationDictionary.keys();
//for each decoder (assuming might have more if hong makes changes)
for (int i = 0; i < decoders.size(); i++){
ghoul::Dictionary typeDictionary;
translationDictionary.getValue(decoders[i], typeDictionary);
//create dictionary containing all {playbookKeys , spice IDs}
if (decoders[i] == "Instrument"){
//for each playbook call -> create a Decoder object
const std::vector<std::string>& keys = typeDictionary.keys();
for (int j = 0; j < keys.size(); j++){
std::string currentKey = decoders[i] + "." + keys[j];
//create dictionary containing all {playbookKeys , spice IDs}
if (decoders[i] == "Instrument"){
//for each playbook call -> create a Decoder object
const std::vector<std::string>& keys = typeDictionary.keys();
for (int j = 0; j < keys.size(); j++){
std::string currentKey = decoders[i] + "." + keys[j];
ghoul::Dictionary decoderDictionary;
translationDictionary.getValue(currentKey, decoderDictionary);
ghoul::Dictionary decoderDictionary;
translationDictionary.getValue(currentKey, decoderDictionary);
Decoder *decoder = Decoder::createFromDictionary(decoderDictionary, decoders[i]);
//insert decoder to map - this will be used in the parser to determine
//behavioral characteristics of each instrument
_fileTranslation[keys[j]] = decoder;
}
}
if (decoders[i] == "Target"){
ghoul::Dictionary specsOfInterestDictionary;
typeDictionary.getValue(keySpecs, specsOfInterestDictionary);
Decoder *decoder = Decoder::createFromDictionary(decoderDictionary, decoders[i]);
//insert decoder to map - this will be used in the parser to determine
//behavioral characteristics of each instrument
_fileTranslation[keys[j]] = decoder;
}
}
if (decoders[i] == "Target"){
ghoul::Dictionary specsOfInterestDictionary;
typeDictionary.getValue(keySpecs, specsOfInterestDictionary);
_specsOfInterest.resize(specsOfInterestDictionary.size());
for (int n = 0; n < _specsOfInterest.size(); ++n) {
std::string readMe;
specsOfInterestDictionary.getValue(std::to_string(n + 1), readMe);
_specsOfInterest[n] = readMe;
}
ghoul::Dictionary convertDictionary;
typeDictionary.getValue(keyConvert, convertDictionary);
_specsOfInterest.resize(specsOfInterestDictionary.size());
for (int n = 0; n < _specsOfInterest.size(); ++n) {
std::string readMe;
specsOfInterestDictionary.getValue(std::to_string(n + 1), readMe);
_specsOfInterest[n] = readMe;
}
ghoul::Dictionary convertDictionary;
typeDictionary.getValue(keyConvert, convertDictionary);
const std::vector<std::string>& keys = convertDictionary.keys();
for (int j = 0; j < keys.size(); j++){
ghoul::Dictionary itemDictionary;
convertDictionary.getValue(keys[j], itemDictionary);
Decoder *decoder = Decoder::createFromDictionary(itemDictionary, decoders[i]);
//insert decoder to map - this will be used in the parser to determine
//behavioral characteristics of each instrument
_fileTranslation[keys[j]] = decoder;
};
}
}
const std::vector<std::string>& keys = convertDictionary.keys();
for (int j = 0; j < keys.size(); j++){
ghoul::Dictionary itemDictionary;
convertDictionary.getValue(keys[j], itemDictionary);
Decoder *decoder = Decoder::createFromDictionary(itemDictionary, decoders[i]);
//insert decoder to map - this will be used in the parser to determine
//behavioral characteristics of each instrument
_fileTranslation[keys[j]] = decoder;
};
}
}
}
std::string LabelParser::decode(std::string line){
for (auto key : _fileTranslation){
std::size_t value = line.find(key.first);
if (value != std::string::npos){
std::string toTranslate = line.substr(value);
//if (_fileTranslation.find(toTranslate) == _fileTranslation.end()) {
// // not found
// _badDecoding = true;
// LERROR("Could not fins '" << toTranslate << "' in translation map." <<
// "\nPlease check label files");
// return "";
//}
return _fileTranslation[toTranslate]->getTranslation()[0]; //lbls always 1:1 -> single value return
for (auto key : _fileTranslation){
std::size_t value = line.find(key.first);
if (value != std::string::npos){
std::string toTranslate = line.substr(value);
//if (_fileTranslation.find(toTranslate) == _fileTranslation.end()) {
// // not found
// _badDecoding = true;
// LERROR("Could not fins '" << toTranslate << "' in translation map." <<
// "\nPlease check label files");
// return "";
//}
return _fileTranslation[toTranslate]->getTranslation()[0]; //lbls always 1:1 -> single value return
}
}
return "";
}
}
return "";
}
std::string LabelParser::encode(std::string line) {
for (auto key : _fileTranslation) {
std::size_t value = line.find(key.first);
if (value != std::string::npos) {
return line.substr(value);
}
}
return "";
for (auto key : _fileTranslation) {
std::size_t value = line.find(key.first);
if (value != std::string::npos) {
return line.substr(value);
}
}
return "";
}
bool LabelParser::create() {
auto imageComparer = [](const Image &a, const Image &b)->bool{
return a.startTime < b.startTime;
};
auto targetComparer = [](const std::pair<double, std::string> &a,
const std::pair<double, std::string> &b)->bool{
return a.first < b.first;
};
std::string previousTarget;
std::string lblName = "";
auto imageComparer = [](const Image &a, const Image &b)->bool{
return a.startTime < b.startTime;
};
auto targetComparer = [](const std::pair<double, std::string> &a,
const std::pair<double, std::string> &b)->bool{
return a.first < b.first;
};
std::string previousTarget;
std::string lblName = "";
using RawPath = ghoul::filesystem::Directory::RawPath;
ghoul::filesystem::Directory sequenceDir(_fileName, RawPath::Yes);
ghoul::filesystem::Directory sequenceDir(_fileName, RawPath::Yes);
if (!FileSys.directoryExists(sequenceDir)) {
LERROR("Could not load Label Directory '" << sequenceDir.path() << "'");
return false;
}
using Recursive = ghoul::filesystem::Directory::Recursive;
using Sort = ghoul::filesystem::Directory::Sort;
std::vector<std::string> sequencePaths = sequenceDir.read(Recursive::Yes, Sort::No);
for (auto path : sequencePaths){
if (size_t position = path.find_last_of(".") + 1){
if (position != std::string::npos){
ghoul::filesystem::File currentFile(path);
std::string extension = currentFile.fileExtension();
if (extension == "lbl" || extension == "LBL"){ // discovered header file
std::ifstream file(currentFile.path());
std::vector<std::string> sequencePaths = sequenceDir.read(Recursive::Yes, Sort::No);
for (auto path : sequencePaths){
if (size_t position = path.find_last_of(".") + 1){
if (position != std::string::npos){
ghoul::filesystem::File currentFile(path);
std::string extension = currentFile.fileExtension();
if (extension == "lbl" || extension == "LBL"){ // discovered header file
std::ifstream file(currentFile.path());
if (!file.good()){
LERROR("Failed to open label file '" << currentFile.path() << "'");
return false;
}
int count = 0;
if (!file.good()){
LERROR("Failed to open label file '" << currentFile.path() << "'");
return false;
}
int count = 0;
// open up label files
std::string line = "";
std::string previousSequence;
TimeRange instrumentRange;
// open up label files
std::string line = "";
std::string previousSequence;
TimeRange instrumentRange;
do {
std::getline(file, line);
do {
std::getline(file, line);
std::string read = line.substr(0, line.find_first_of(" "));
std::string read = line.substr(0, line.find_first_of(" "));
line.erase(std::remove(line.begin(), line.end(), '"'), line.end());
line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
line.erase(std::remove(line.begin(), line.end(), '"'), line.end());
line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
_detectorType = "CAMERA"; //default value
_detectorType = "CAMERA"; //default value
/* Add more */
if (read == "TARGET_NAME"){
_target = decode(line);
count++;
}
if (read == "INSTRUMENT_HOST_NAME"){
_instrumentHostID = decode(line);
count++;
}
if (read == "INSTRUMENT_ID"){
_instrumentID = decode(line);
lblName = encode(line);
count++;
}
if (read == "DETECTOR_TYPE"){
_detectorType = decode(line);
count++;
}
// if (_badDecoding){
// LERROR("Please examine file: '" << currentFile.path() << "'");
// return false;
// }
/* Add more */
if (read == "TARGET_NAME"){
_target = decode(line);
count++;
}
if (read == "INSTRUMENT_HOST_NAME"){
_instrumentHostID = decode(line);
count++;
}
if (read == "INSTRUMENT_ID"){
_instrumentID = decode(line);
lblName = encode(line);
count++;
}
if (read == "DETECTOR_TYPE"){
_detectorType = decode(line);
count++;
}
// if (_badDecoding){
// LERROR("Please examine file: '" << currentFile.path() << "'");
// return false;
// }
if (read == "START_TIME"){
std::string start = line.substr(line.find("=") + 2);
start.erase(std::remove(start.begin(), start.end(), ' '), start.end());
if (read == "START_TIME"){
std::string start = line.substr(line.find("=") + 2);
start.erase(std::remove(start.begin(), start.end(), ' '), start.end());
_startTime = SpiceManager::ref().ephemerisTimeFromDate(start);
count++;
count++;
getline(file, line);
read = line.substr(0, line.find_first_of(" "));
if (read == "STOP_TIME"){
std::string stop = line.substr(line.find("=") + 2);
getline(file, line);
read = line.substr(0, line.find_first_of(" "));
if (read == "STOP_TIME"){
std::string stop = line.substr(line.find("=") + 2);
stop.erase(
std::remove_if(
stop.begin(),
@@ -223,98 +223,98 @@ bool LabelParser::create() {
stop.end()
);
_stopTime = SpiceManager::ref().ephemerisTimeFromDate(stop);
count++;
}
else{
LERROR("Label file " + currentFile.path() + " deviates from generic standard!");
LINFO("Please make sure input data adheres to format https://pds.jpl.nasa.gov/documents/qs/labels.html");
}
}
if (count == _specsOfInterest.size()){
count = 0;
std::string ext = "jpg";
path.replace(path.begin() + position, path.end(), ext);
bool fileExists = FileSys.fileExists(path);
if (!fileExists) {
ext = "JPG";
path.replace(path.begin() + position, path.end(), ext);
fileExists = FileSys.fileExists(path);
}
if (fileExists) {
Image image;
std::vector<std::string> spiceInstrument;
spiceInstrument.push_back(_instrumentID);
createImage(image, _startTime, _startTime, spiceInstrument, _target, path);
_subsetMap[image.target]._subset.push_back(image);
_subsetMap[image.target]._range.setRange(_startTime);
count++;
}
else{
LERROR("Label file " + currentFile.path() + " deviates from generic standard!");
LINFO("Please make sure input data adheres to format https://pds.jpl.nasa.gov/documents/qs/labels.html");
}
}
if (count == _specsOfInterest.size()){
count = 0;
std::string ext = "jpg";
path.replace(path.begin() + position, path.end(), ext);
bool fileExists = FileSys.fileExists(path);
if (!fileExists) {
ext = "JPG";
path.replace(path.begin() + position, path.end(), ext);
fileExists = FileSys.fileExists(path);
}
if (fileExists) {
Image image;
std::vector<std::string> spiceInstrument;
spiceInstrument.push_back(_instrumentID);
createImage(image, _startTime, _startTime, spiceInstrument, _target, path);
_subsetMap[image.target]._subset.push_back(image);
_subsetMap[image.target]._range.setRange(_startTime);
_captureProgression.push_back(_startTime);
std::stable_sort(_captureProgression.begin(), _captureProgression.end());
}
}
} while (!file.eof());
}
}
}
}
std::vector<Image> tmp;
for (auto key : _subsetMap){
for (auto image : key.second._subset){
tmp.push_back(image);
}
}
std::sort(tmp.begin(), tmp.end(), imageComparer);
_captureProgression.push_back(_startTime);
std::stable_sort(_captureProgression.begin(), _captureProgression.end());
}
}
} while (!file.eof());
}
}
}
}
std::vector<Image> tmp;
for (auto key : _subsetMap){
for (auto image : key.second._subset){
tmp.push_back(image);
}
}
std::sort(tmp.begin(), tmp.end(), imageComparer);
for (auto image : tmp){
if (previousTarget != image.target){
previousTarget = image.target;
std::pair<double, std::string> v_target = std::make_pair(image.startTime, image.target);
_targetTimes.push_back(v_target);
std::sort(_targetTimes.begin(), _targetTimes.end(), targetComparer);
}
}
for (auto image : tmp){
if (previousTarget != image.target){
previousTarget = image.target;
std::pair<double, std::string> v_target = std::make_pair(image.startTime, image.target);
_targetTimes.push_back(v_target);
std::sort(_targetTimes.begin(), _targetTimes.end(), targetComparer);
}
}
for (auto target : _subsetMap){
_instrumentTimes.push_back(std::make_pair(lblName, _subsetMap[target.first]._range));
for (auto target : _subsetMap){
_instrumentTimes.push_back(std::make_pair(lblName, _subsetMap[target.first]._range));
// std::string min, max;
// SpiceManager::ref().getDateFromET(target.second._range._min, min);
// SpiceManager::ref().getDateFromET(target.second._range._max, max);
// std::string min, max;
// SpiceManager::ref().getDateFromET(target.second._range._min, min);
// SpiceManager::ref().getDateFromET(target.second._range._max, max);
// myfile << std::endl;
// for (auto image : target.second._subset){
// std::string time_beg;
// std::string time_end;
// SpiceManager::ref().getDateFromET(image.startTime, time_beg);
// SpiceManager::ref().getDateFromET(image.stopTime, time_end);
// myfile << std::endl;
// for (auto image : target.second._subset){
// std::string time_beg;
// std::string time_end;
// SpiceManager::ref().getDateFromET(image.startTime, time_beg);
// SpiceManager::ref().getDateFromET(image.stopTime, time_end);
// myfile << std::fixed
// << " " << time_beg
// << "-->" << time_end
// << " [ " << image.startTime
// << " ] " << image.target << std::setw(10);
// for (auto instrument : image.activeInstruments){
// myfile << " " << instrument;
// }
// myfile << std::endl;
// }
}
// myfile << std::fixed
// << " " << time_beg
// << "-->" << time_end
// << " [ " << image.startTime
// << " ] " << image.target << std::setw(10);
// for (auto instrument : image.activeInstruments){
// myfile << " " << instrument;
// }
// myfile << std::endl;
// }
}
sendPlaybookInformation(PlaybookIdentifierName);
return true;
return true;
}
void LabelParser::createImage(Image& image, double startTime, double stopTime, std::vector<std::string> instr, std::string targ, std::string pot) {
image.startTime = startTime;
image.stopTime = stopTime;
image.path = pot;
for (int i = 0; i < instr.size(); i++){
image.activeInstruments.push_back(instr[i]);
}
image.target = targ;
image.projected = false;
image.startTime = startTime;
image.stopTime = stopTime;
image.path = pot;
for (int i = 0; i < instr.size(); i++){
image.activeInstruments.push_back(instr[i]);
}
image.target = targ;
image.projected = false;
}
}
+28 -28
View File
@@ -34,7 +34,7 @@ using std::string;
namespace {
const string _configurationFile = "openspace.cfg";
const string _keyBasePath = "BASE_PATH";
const string _keyBasePath = "BASE_PATH";
}
namespace openspace {
@@ -91,24 +91,24 @@ string ConfigurationManager::findConfiguration(const string& filename) {
}
void ConfigurationManager::loadFromFile(const string& filename) {
using ghoul::filesystem::FileSystem;
using ghoul::filesystem::FileSystem;
if (!FileSys.fileExists(filename))
throw ghoul::FileNotFoundError(filename, "ConfigurationManager");
// ${BASE_PATH}
string basePathToken = FileSystem::TokenOpeningBraces + _keyBasePath
// ${BASE_PATH}
string basePathToken = FileSystem::TokenOpeningBraces + _keyBasePath
+ FileSystem::TokenClosingBraces;
// Retrieving the directory in which the configuration file lies
// Retrieving the directory in which the configuration file lies
string absolutePath = FileSys.absolutePath(filename);
string basePath = ghoul::filesystem::File(absolutePath).directoryName();
FileSys.registerPathToken(basePathToken, basePath);
string basePath = ghoul::filesystem::File(absolutePath).directoryName();
FileSys.registerPathToken(basePathToken, basePath);
// Loading the configuration file into ourselves
// Loading the configuration file into ourselves
ghoul::lua::loadDictionaryFromFile(filename, *this);
// Register all the paths
// Register all the paths
ghoul::Dictionary dictionary = value<ghoul::Dictionary>(KeyPaths);
std::vector<std::string> pathKeys = dictionary.keys();
@@ -118,8 +118,8 @@ void ConfigurationManager::loadFromFile(const string& filename) {
std::string fullKey =
FileSystem::TokenOpeningBraces + key + FileSystem::TokenClosingBraces;
LDEBUGC("ConfigurationManager", "Registering path " << fullKey << ": " << p);
bool override = (basePathToken == fullKey);
bool override = (basePathToken == fullKey);
if (override)
LINFOC("ConfigurationManager", "Overriding base path with '" << p << "'");
@@ -132,7 +132,7 @@ void ConfigurationManager::loadFromFile(const string& filename) {
}
}
bool complete = checkCompleteness();
bool complete = checkCompleteness();
if (!complete) {
throw ghoul::RuntimeError(
"Configuration file '" + filename + "' was not complete",
@@ -140,34 +140,34 @@ void ConfigurationManager::loadFromFile(const string& filename) {
);
}
// Remove the Paths dictionary from the configuration manager as those paths might
// change later and we don't want to be forced to keep our local copy up to date
removeKey(KeyPaths);
// Remove the Paths dictionary from the configuration manager as those paths might
// change later and we don't want to be forced to keep our local copy up to date
removeKey(KeyPaths);
}
bool ConfigurationManager::checkCompleteness() const {
std::vector<std::string> requiredTokens = {
KeyPaths,
KeyPaths + "." + KeyCache,
KeyFonts,
KeyConfigSgct
};
std::vector<std::string> requiredTokens = {
KeyPaths,
KeyPaths + "." + KeyCache,
KeyFonts,
KeyConfigSgct
};
bool totalSuccess = true;
for (const std::string& token : requiredTokens) {
bool success = hasKey(token);
bool totalSuccess = true;
for (const std::string& token : requiredTokens) {
bool success = hasKey(token);
if (!success) {
LFATALC(
LFATALC(
"ConfigurationManager",
"Configuration file did not contain required key '" << token << "'"
);
}
totalSuccess &= success;
}
totalSuccess &= success;
}
return totalSuccess;
return totalSuccess;
}
} // namespace openspace
+64 -64
View File
@@ -71,7 +71,7 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di
ghoul::Dictionary renderableDictionary;
dictionary.getValue(KeyRenderable, renderableDictionary);
renderableDictionary.setValue(KeyName, name);
renderableDictionary.setValue(KeyName, name);
result->_renderable = Renderable::createFromDictionary(renderableDictionary);
if (result->_renderable == nullptr) {
@@ -80,7 +80,7 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di
delete result;
return nullptr;
}
result->addPropertySubOwner(result->_renderable);
result->addPropertySubOwner(result->_renderable);
LDEBUG("Successfully create renderable for '" << result->name() << "'");
}
@@ -95,7 +95,7 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di
delete result;
return nullptr;
}
//result->addPropertySubOwner(result->_ephemeris);
//result->addPropertySubOwner(result->_ephemeris);
LDEBUG("Successfully create ephemeris for '" << result->name() << "'");
}
@@ -147,18 +147,18 @@ bool SceneGraphNode::deinitialize() {
LDEBUG("Deinitialize: " << name());
if (_renderable) {
_renderable->deinitialize();
_renderable->deinitialize();
delete _renderable;
_renderable = nullptr;
}
_renderable = nullptr;
}
delete _ephemeris;
_ephemeris = nullptr;
// for (SceneGraphNode* child : _children) {
// child->deinitialize();
// delete child;
//}
// child->deinitialize();
// delete child;
//}
_children.clear();
// reset variables
@@ -171,35 +171,35 @@ bool SceneGraphNode::deinitialize() {
}
void SceneGraphNode::update(const UpdateData& data) {
if (_ephemeris) {
if (data.doPerformanceMeasurement) {
glFinish();
if (_ephemeris) {
if (data.doPerformanceMeasurement) {
glFinish();
auto start = std::chrono::high_resolution_clock::now();
_ephemeris->update(data);
_ephemeris->update(data);
glFinish();
auto end = std::chrono::high_resolution_clock::now();
_performanceRecord.updateTimeEphemeris = (end - start).count();
}
else
_ephemeris->update(data);
}
glFinish();
auto end = std::chrono::high_resolution_clock::now();
_performanceRecord.updateTimeEphemeris = (end - start).count();
}
else
_ephemeris->update(data);
}
if (_renderable && _renderable->isReady()) {
if (data.doPerformanceMeasurement) {
glFinish();
auto start = std::chrono::high_resolution_clock::now();
if (_renderable && _renderable->isReady()) {
if (data.doPerformanceMeasurement) {
glFinish();
auto start = std::chrono::high_resolution_clock::now();
_renderable->update(data);
_renderable->update(data);
glFinish();
auto end = std::chrono::high_resolution_clock::now();
_performanceRecord.updateTimeRenderable = (end - start).count();
}
else
_renderable->update(data);
}
glFinish();
auto end = std::chrono::high_resolution_clock::now();
_performanceRecord.updateTimeRenderable = (end - start).count();
}
else
_renderable->update(data);
}
}
void SceneGraphNode::evaluate(const Camera* camera, const psc& parentPosition) {
@@ -222,7 +222,7 @@ void SceneGraphNode::evaluate(const Camera* camera, const psc& parentPosition) {
return;
}
}
*/
*/
#endif
// inside boudningsphere or parts of the sphere is visible, individual
@@ -245,22 +245,22 @@ void SceneGraphNode::evaluate(const Camera* camera, const psc& parentPosition) {
void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) {
const psc thisPosition = worldPosition();
RenderData newData = {data.camera, thisPosition, data.doPerformanceMeasurement};
RenderData newData = {data.camera, thisPosition, data.doPerformanceMeasurement};
_performanceRecord.renderTime = 0;
_performanceRecord.renderTime = 0;
if (_renderableVisible && _renderable->isVisible() && _renderable->isReady() && _renderable->isEnabled()) {
if (data.doPerformanceMeasurement) {
glFinish();
auto start = std::chrono::high_resolution_clock::now();
if (data.doPerformanceMeasurement) {
glFinish();
auto start = std::chrono::high_resolution_clock::now();
_renderable->render(newData, tasks);
_renderable->render(newData, tasks);
glFinish();
auto end = std::chrono::high_resolution_clock::now();
_performanceRecord.renderTime = (end - start).count();
}
else
_renderable->render(newData, tasks);
glFinish();
auto end = std::chrono::high_resolution_clock::now();
_performanceRecord.renderTime = (end - start).count();
}
else
_renderable->render(newData, tasks);
}
// evaluate all the children, tail-recursive function(?)
@@ -326,8 +326,8 @@ const std::vector<SceneGraphNode*>& SceneGraphNode::children() const{
// bounding sphere
PowerScaledScalar SceneGraphNode::calculateBoundingSphere(){
// set the bounding sphere to 0.0
_boundingSphere = 0.0;
_boundingSphere = 0.0;
if (!_children.empty()) { // node
PowerScaledScalar maxChild;
@@ -338,7 +338,7 @@ PowerScaledScalar SceneGraphNode::calculateBoundingSphere(){
// position
//PowerScaledScalar child = _children.at(i)->position().length()
// + _children.at(i)->calculateBoundingSphere();
PowerScaledScalar child = _children.at(i)->calculateBoundingSphere();
PowerScaledScalar child = _children.at(i)->calculateBoundingSphere();
if (child > maxChild) {
maxChild = child;
}
@@ -352,8 +352,8 @@ PowerScaledScalar SceneGraphNode::calculateBoundingSphere(){
if(renderableBS > _boundingSphere)
_boundingSphere = renderableBS;
}
//LINFO("Bounding Sphere of '" << name() << "': " << _boundingSphere);
//LINFO("Bounding Sphere of '" << name() << "': " << _boundingSphere);
return _boundingSphere;
}
@@ -372,7 +372,7 @@ const Renderable* SceneGraphNode::renderable() const
}
Renderable* SceneGraphNode::renderable() {
return _renderable;
return _renderable;
}
// private helper methods
@@ -422,21 +422,21 @@ SceneGraphNode* SceneGraphNode::childNode(const std::string& name)
void SceneGraphNode::updateCamera(Camera* camera) const{
psc origin = worldPosition();
//int i = 0;
// the camera position
psc relative = camera->position();
psc focus = camera->focusPosition();
psc relative_focus = relative - focus;
psc origin = worldPosition();
//int i = 0;
// the camera position
psc relative = camera->position();
psc focus = camera->focusPosition();
psc relative_focus = relative - focus;
psc target = origin + relative_focus;
camera->setPosition(target);
camera->setFocusPosition(origin);
psc target = origin + relative_focus;
camera->setPosition(target);
camera->setFocusPosition(origin);
//printf("target: %f, %f, %f, %f\n", target.vec4().x, target.vec4().y, target.vec4().z, target.vec4().w);
//printf("target: %f, %f, %f, %f\n", target.vec4().x, target.vec4().y, target.vec4().z, target.vec4().w);
}
} // namespace openspace
+88 -88
View File
@@ -35,7 +35,7 @@
#include <cppformat/format.h>
namespace {
const std::string _loggerCat = "SpiceManager";
const std::string _loggerCat = "SpiceManager";
// The value comes from
// http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/getmsg_c.html
@@ -189,7 +189,7 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(string filePath) {
)
);
string path = absPath(filePath);
string path = absPath(filePath);
auto it = std::find_if(
_loadedKernels.begin(),
_loadedKernels.end(),
@@ -213,11 +213,11 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(string filePath) {
ghoul::filesystem::Directory currentDirectory = FileSys.currentDirectory();
using RawPath = ghoul::filesystem::File::RawPath;
string fileDirectory = ghoul::filesystem::File(path, RawPath::Yes).directoryName();
FileSys.setCurrentDirectory(fileDirectory);
FileSys.setCurrentDirectory(fileDirectory);
LINFO("Loading SPICE kernel '" << path << "'");
// Load the kernel
furnsh_c(path.c_str());
furnsh_c(path.c_str());
// Reset the current directory to the previous one
FileSys.setCurrentDirectory(currentDirectory);
@@ -226,9 +226,9 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(string filePath) {
string fileExtension = ghoul::filesystem::File(path, RawPath::Yes).fileExtension();
if (fileExtension == "bc" || fileExtension == "BC")
findCkCoverage(path); // binary ck kernel
else if (fileExtension == "bsp" || fileExtension == "BSP")
findSpkCoverage(path); // binary spk kernel
findCkCoverage(path); // binary ck kernel
else if (fileExtension == "bsp" || fileExtension == "BSP")
findSpkCoverage(path); // binary spk kernel
KernelHandle kernelId = ++_lastAssignedKernel;
ghoul_assert(kernelId != 0, fmt::format("Kernel Handle wrapped around to 0"));
@@ -240,23 +240,23 @@ void SpiceManager::unloadKernel(KernelHandle kernelId) {
ghoul_assert(kernelId <= _lastAssignedKernel, "Invalid unassigned kernel");
ghoul_assert(kernelId != KernelHandle(0), "Invalid zero handle");
auto it = std::find_if(_loadedKernels.begin(), _loadedKernels.end(),
[&kernelId](const KernelInformation& info) { return info.id == kernelId; });
auto it = std::find_if(_loadedKernels.begin(), _loadedKernels.end(),
[&kernelId](const KernelInformation& info) { return info.id == kernelId; });
if (it != _loadedKernels.end()) {
if (it != _loadedKernels.end()) {
// 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
// No need to check for errors as we do not allow empty path names
LINFO(format("Unloading SPICE kernel '{}'", it->path));
unload_c(it->path.c_str());
_loadedKernels.erase(it);
unload_c(it->path.c_str());
_loadedKernels.erase(it);
}
// Otherwise, we hold on to it, but reduce the reference counter by 1
else {
it->refCount--;
LDEBUG(format("Reducing reference counter to: {}", it->refCount));
}
}
}
}
void SpiceManager::unloadKernel(std::string filePath) {
@@ -264,15 +264,15 @@ void SpiceManager::unloadKernel(std::string filePath) {
string path = absPath(filePath);
auto it = std::find_if(_loadedKernels.begin(), _loadedKernels.end(),
[&path](const KernelInformation& info) { return info.path == path; });
auto it = std::find_if(_loadedKernels.begin(), _loadedKernels.end(),
[&path](const KernelInformation& info) { return info.path == path; });
if (it == _loadedKernels.end()) {
throw SpiceException(
format("'{}' did not correspond to a loaded kernel", path)
);
}
else {
else {
// If there was only one part interested in the kernel, we can unload it
if (it->refCount == 1) {
LINFO(format("Unloading SPICE kernel '{}'", path));
@@ -284,7 +284,7 @@ void SpiceManager::unloadKernel(std::string filePath) {
it->refCount--;
LDEBUG(format("Reducing reference counter to: {}", it->refCount));
}
}
}
}
bool SpiceManager::hasSpkCoverage(const string& target, double et) const {
@@ -319,14 +319,14 @@ bool SpiceManager::hasCkCoverage(const string& frame, double et) const {
}
bool SpiceManager::hasValue(int naifId, const std::string& item) const {
return bodfnd_c(naifId, item.c_str());
return bodfnd_c(naifId, item.c_str());
}
bool SpiceManager::hasValue(const std::string& body, const std::string& item) const {
ghoul_assert(!body.empty(), "Empty body");
ghoul_assert(!item.empty(), "Empty item");
int id = naifId(body);
int id = naifId(body);
return hasValue(id, item);
}
@@ -370,14 +370,14 @@ bool SpiceManager::hasFrameId(const std::string& frame) const {
}
void getValueInternal(const std::string& body, const std::string& value, int size,
double* v)
double* v)
{
ghoul_assert(!body.empty(), "Empty body");
ghoul_assert(!value.empty(), "Empty value");
ghoul_assert(v != nullptr, "Empty value pointer");
SpiceInt n;
bodvrd_c(body.c_str(), value.c_str(), size, &n, v);
SpiceInt n;
bodvrd_c(body.c_str(), value.c_str(), size, &n, v);
throwOnSpiceError(
format("Error getting value '{}' for body '{}'",
@@ -390,7 +390,7 @@ void getValueInternal(const std::string& body, const std::string& value, int siz
void SpiceManager::getValue(const std::string& body, const std::string& value,
double& v) const
{
getValueInternal(body, value, 1, &v);
getValueInternal(body, value, 1, &v);
}
void SpiceManager::getValue(const std::string& body, const std::string& value,
@@ -402,17 +402,17 @@ void SpiceManager::getValue(const std::string& body, const std::string& value,
void SpiceManager::getValue(const std::string& body, const std::string& value,
glm::dvec3& v) const
{
getValueInternal(body, value, 3, glm::value_ptr(v));
getValueInternal(body, value, 3, glm::value_ptr(v));
}
void SpiceManager::getValue(const std::string& body, const std::string& value,
glm::dvec4& v) const
glm::dvec4& v) const
{
getValueInternal(body, value, 4, glm::value_ptr(v));
getValueInternal(body, value, 4, glm::value_ptr(v));
}
void SpiceManager::getValue(const std::string& body, const std::string& value,
std::vector<double>& v) const
std::vector<double>& v) const
{
ghoul_assert(!v.empty(), "Array for values has to be preallocaed");
@@ -424,19 +424,19 @@ double SpiceManager::spacecraftClockToET(const std::string& craft, double craftT
int craftId = naifId(craft);
double et;
sct2e_c(craftId, craftTicks, &et);
sct2e_c(craftId, craftTicks, &et);
throwOnSpiceError(format(
"Error transforming spacecraft clock of '{}' at time {}",
craft, craftTicks)
);
return et;
return et;
}
double SpiceManager::ephemerisTimeFromDate(const std::string& timeString) const {
ghoul_assert(!timeString.empty(), "Empty timeString");
double et;
str2et_c(timeString.c_str(), &et);
str2et_c(timeString.c_str(), &et);
throwOnSpiceError(format("Error converting date '{}'", timeString));
return et;
}
@@ -469,26 +469,26 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target,
ghoul_assert(!observer.empty(), "Observer is not empty");
ghoul_assert(!referenceFrame.empty(), "Reference frame is not empty");
bool targetHasCoverage = hasSpkCoverage(target, ephemerisTime);
bool observerHasCoverage = hasSpkCoverage(observer, ephemerisTime);
if (!targetHasCoverage && !observerHasCoverage){
bool targetHasCoverage = hasSpkCoverage(target, ephemerisTime);
bool observerHasCoverage = hasSpkCoverage(observer, ephemerisTime);
if (!targetHasCoverage && !observerHasCoverage){
throw SpiceException(
format("Neither the target '{}' nor observer '{}' has SPK coverage",
target,
observer
)
);
}
else if (targetHasCoverage && observerHasCoverage) {
}
else if (targetHasCoverage && observerHasCoverage) {
glm::dvec3 position;
spkpos_c(
spkpos_c(
target.c_str(),
ephemerisTime,
referenceFrame.c_str(),
aberrationCorrection,
observer.c_str(),
glm::value_ptr(position),
&lightTime
&lightTime
);
throwOnSpiceError(format(
"Error getting target position from '{}' to '{}' in reference frame '{}",
@@ -497,7 +497,7 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target,
referenceFrame
));
return position;
}
}
else if (targetHasCoverage) {
// observer has no coverage
return getEstimatedPosition(
@@ -531,13 +531,13 @@ glm::dmat3 SpiceManager::frameTransformationMatrix(const std::string& from,
// get rotation matrix from frame A - frame B
glm::dmat3 transform;
pxform_c(
pxform_c(
from.c_str(),
to.c_str(),
ephemerisTime,
reinterpret_cast<double(*)[3]>(glm::value_ptr(transform))
);
throwOnSpiceError(
format("Error converting from frame '{}' to frame '{}' at time '{}'",
from, to, ephemerisTime
@@ -601,8 +601,8 @@ bool SpiceManager::isTargetInFieldOfView(const std::string& target,
ghoul_assert(!referenceFrame.empty(), "Reference frame must not be empty");
ghoul_assert(!instrument.empty(), "Instrument must not be empty");
int visible;
fovtrg_c(instrument.c_str(),
int visible;
fovtrg_c(instrument.c_str(),
target.c_str(),
toString(method),
referenceFrame.c_str(),
@@ -617,7 +617,7 @@ bool SpiceManager::isTargetInFieldOfView(const std::string& target,
target, instrument
));
return visible == SPICETRUE;
return visible == SPICETRUE;
}
bool SpiceManager::isTargetInFieldOfView(const std::string& target,
@@ -648,7 +648,7 @@ SpiceManager::TargetStateResult SpiceManager::targetState(const std::string& tar
double buffer[6];
spkezr_c(
spkezr_c(
target.c_str(),
ephemerisTime,
referenceFrame.c_str(),
@@ -676,7 +676,7 @@ SpiceManager::TransformMatrix SpiceManager::stateTransformMatrix(const string& f
ghoul_assert(!toFrame.empty(), "toFrame must not be empty");
TransformMatrix m;
sxform_c(
sxform_c(
fromFrame.c_str(),
toFrame.c_str(),
ephemerisTime,
@@ -697,7 +697,7 @@ glm::dmat3 SpiceManager::positionTransformMatrix(const std::string& fromFrame,
ghoul_assert(!toFrame.empty(), "toFrame must not be empty");
glm::dmat3 result;
pxform_c(
pxform_c(
fromFrame.c_str(),
toFrame.c_str(),
ephemerisTime,
@@ -705,11 +705,11 @@ glm::dmat3 SpiceManager::positionTransformMatrix(const std::string& fromFrame,
);
throwOnSpiceError("");
SpiceBoolean success = !(failed_c());
SpiceBoolean success = !(failed_c());
reset_c();
bool estimated = false;
if (!success)
result = getEstimatedTransformMatrix(fromFrame, toFrame, ephemerisTime);
if (!success)
result = getEstimatedTransformMatrix(fromFrame, toFrame, ephemerisTime);
return glm::transpose(result);
}
@@ -722,7 +722,7 @@ glm::dmat3 SpiceManager::positionTransformMatrix(const std::string& fromFrame,
glm::dmat3 result;
pxfrm2_c(
pxfrm2_c(
fromFrame.c_str(),
toFrame.c_str(),
ephemerisTimeFrom,
@@ -745,24 +745,24 @@ SpiceManager::fieldOfView(const std::string& instrument) const
}
SpiceManager::FieldOfViewResult SpiceManager::fieldOfView(int instrument) const {
static const int MaxBoundsSize = 64;
static const int BufferSize = 128;
static const int MaxBoundsSize = 64;
static const int BufferSize = 128;
FieldOfViewResult res;
SpiceInt nrReturned;
double boundsArr[MaxBoundsSize][3];
SpiceInt nrReturned;
double boundsArr[MaxBoundsSize][3];
char fovShapeBuffer[BufferSize];
char frameNameBuffer[BufferSize];
getfov_c(instrument, // instrument id
getfov_c(instrument, // instrument id
MaxBoundsSize, // maximum size for the bounds vector
BufferSize, // maximum size for the fov shape buffer
BufferSize, // maximum size for the frame name buffer
fovShapeBuffer, // the fov shape buffer
frameNameBuffer, // the frame name buffer
glm::value_ptr(res.boresightVector), // the boresight vector
&nrReturned, // the number of returned array values
boundsArr // the bounds
BufferSize, // maximum size for the frame name buffer
fovShapeBuffer, // the fov shape buffer
frameNameBuffer, // the frame name buffer
glm::value_ptr(res.boresightVector), // the boresight vector
&nrReturned, // the number of returned array values
boundsArr // the bounds
);
throwOnSpiceError(format(
@@ -770,7 +770,7 @@ SpiceManager::FieldOfViewResult SpiceManager::fieldOfView(int instrument) const
));
res.bounds.reserve(nrReturned);
for (int i = 0; i < nrReturned; ++i)
for (int i = 0; i < nrReturned; ++i)
res.bounds.emplace_back(boundsArr[i][0], boundsArr[i][1], boundsArr[i][2]);
string shape = string(fovShapeBuffer);
@@ -783,7 +783,7 @@ SpiceManager::FieldOfViewResult SpiceManager::fieldOfView(int instrument) const
res.shape = Map.at(shape);
res.frameName = string(frameNameBuffer);
return res;
return res;
}
SpiceManager::TerminatorEllipseResult SpiceManager::terminatorEllipse(
@@ -803,24 +803,24 @@ SpiceManager::TerminatorEllipseResult SpiceManager::terminatorEllipse(
// Warning: This assumes std::vector<glm::dvec3> to have all values memory contiguous
res.terminatorPoints.resize(numberOfTerminatorPoints);
edterm_c(toString(terminatorType),
lightSource.c_str(),
target.c_str(),
ephemerisTime,
frame.c_str(),
aberrationCorrection,
observer.c_str(),
numberOfTerminatorPoints,
&res.targetEphemerisTime,
glm::value_ptr(res.observerPosition),
(double(*)[3])res.terminatorPoints.data()
edterm_c(toString(terminatorType),
lightSource.c_str(),
target.c_str(),
ephemerisTime,
frame.c_str(),
aberrationCorrection,
observer.c_str(),
numberOfTerminatorPoints,
&res.targetEphemerisTime,
glm::value_ptr(res.observerPosition),
(double(*)[3])res.terminatorPoints.data()
);
throwOnSpiceError(format(
"Error getting terminator ellipse for target '{}' from observer '{}' in frame "
"'{}' with light source '{}' at time '{}'",
target, observer, frame, lightSource, ephemerisTime
));
return res;
return res;
}
bool SpiceManager::addFrame(std::string body, std::string frame) {
@@ -833,21 +833,21 @@ bool SpiceManager::addFrame(std::string body, std::string frame) {
}
std::string SpiceManager::frameFromBody(const std::string& body) const {
for (auto pair : _frameByBody) {
if (pair.first == body) {
return pair.second;
}
}
for (auto pair : _frameByBody) {
if (pair.first == body) {
return pair.second;
}
}
std::string unionPrefix = "IAU_";
std::string frame = "";
std::string unionPrefix = "IAU_";
std::string frame = "";
if (body.find(unionPrefix) == std::string::npos)
frame = unionPrefix + body;
else
frame = body;
if (body.find(unionPrefix) == std::string::npos)
frame = unionPrefix + body;
else
frame = body;
return frame;
return frame;
}
void SpiceManager::findCkCoverage(const std::string& path) {