mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2025-12-31 00:10:44 -06:00
Remove CppCheck warnings
This commit is contained in:
Submodule ext/ghoul updated: 48df906c11...05790cd99b
@@ -109,9 +109,7 @@ bool RenderablePath::initialize() {
|
||||
|
||||
bool intervalSet = hasTimeInterval();
|
||||
if (intervalSet) {
|
||||
getInterval(_start, _stop);
|
||||
std::string start = SpiceManager::ref().dateFromEphemerisTime(_start);
|
||||
std::string stop = SpiceManager::ref().dateFromEphemerisTime(_stop);
|
||||
completeSuccess &= getInterval(_start, _stop);
|
||||
}
|
||||
|
||||
return completeSuccess;
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
const unsigned int NU_SAMPLES = 16;*/
|
||||
|
||||
public:
|
||||
RenderablePlanet(const ghoul::Dictionary& dictionary);
|
||||
explicit RenderablePlanet(const ghoul::Dictionary& dictionary);
|
||||
~RenderablePlanet();
|
||||
|
||||
bool initialize() override;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace openspace {
|
||||
|
||||
class RenderableStars : public Renderable {
|
||||
public:
|
||||
RenderableStars(const ghoul::Dictionary& dictionary);
|
||||
explicit RenderableStars(const ghoul::Dictionary& dictionary);
|
||||
~RenderableStars();
|
||||
|
||||
bool initialize() override;
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace openspace {
|
||||
|
||||
class RenderableTrail : public Renderable {
|
||||
public:
|
||||
RenderableTrail(const ghoul::Dictionary& dictionary);
|
||||
explicit RenderableTrail(const ghoul::Dictionary& dictionary);
|
||||
|
||||
bool initialize() override;
|
||||
bool deinitialize() override;
|
||||
|
||||
@@ -52,6 +52,8 @@ RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictiona
|
||||
, _imageSequenceTime(-1.f)
|
||||
, _vao(0)
|
||||
, _vbo(0)
|
||||
, _frameCounter(0)
|
||||
, _drawLine(false)
|
||||
{
|
||||
dictionary.getValue(KeySource, _source);
|
||||
dictionary.getValue(KeyTarget, _target);
|
||||
@@ -75,7 +77,6 @@ bool RenderableCrawlingLine::isReady() const {
|
||||
}
|
||||
|
||||
bool RenderableCrawlingLine::initialize() {
|
||||
_frameCounter = 0;
|
||||
bool completeSuccess = true;
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
|
||||
@@ -56,6 +56,11 @@ namespace {
|
||||
const std::string keyInstrumentMethod = "Instrument.Method";
|
||||
const std::string keyInstrumentAberration = "Instrument.Aberration";
|
||||
const std::string keyPotentialTargets = "PotentialTargets";
|
||||
|
||||
const int InterpolationSteps = 10;
|
||||
const int Stride = 8;
|
||||
|
||||
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
@@ -68,6 +73,10 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
|
||||
, _texture(nullptr)
|
||||
, _drawFOV(false)
|
||||
, _mode(GL_LINES)
|
||||
, _interceptTag{false, false, false, false, false, false, false, false}
|
||||
, _withinFOV(false)
|
||||
, _vBoundsSize(0)
|
||||
, _vPlaneSize(40)
|
||||
{
|
||||
bool success = dictionary.getValue(keyBody, _spacecraft);
|
||||
ghoul_assert(success, "");
|
||||
@@ -109,16 +118,12 @@ void RenderableFov::allocateData() {
|
||||
_bounds = std::move(res.bounds);
|
||||
_boresight = std::move(res.boresightVector);
|
||||
|
||||
_stride = 8;
|
||||
|
||||
_projectionBounds.resize(_bounds.size());
|
||||
int initBoundPoints = 2 * (_bounds.size() + 1);
|
||||
_fovBounds.resize(initBoundPoints*_stride);
|
||||
_fovBounds.resize(initBoundPoints * Stride);
|
||||
_vBoundsSize = static_cast<unsigned int>(_fovBounds.size());
|
||||
// allocate second vbo data
|
||||
_fovPlane.resize(40);
|
||||
_vPlaneSize = 40;
|
||||
_isteps = 10; // Interpolation steps per intersecting segment
|
||||
_fovPlane.resize(_vPlaneSize);
|
||||
|
||||
}
|
||||
catch (const SpiceManager::SpiceException& e) {
|
||||
@@ -172,7 +177,7 @@ void RenderableFov::sendToGPU() {
|
||||
glBufferData(GL_ARRAY_BUFFER, _vBoundsSize * sizeof(GLfloat), NULL, GL_STATIC_DRAW); // orphaning the buffer, sending NULL data.
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vBoundsSize * sizeof(GLfloat), _fovBounds.data());
|
||||
|
||||
GLsizei st = sizeof(GLfloat) * _stride;
|
||||
GLsizei st = sizeof(GLfloat) * Stride;
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
@@ -212,7 +217,7 @@ void RenderableFov::updateGPU() {
|
||||
glBufferData(GL_ARRAY_BUFFER, _vPlaneSize * sizeof(GLfloat), NULL, GL_STATIC_DRAW); // orphaning the buffer, sending NULL data.
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, _vPlaneSize * sizeof(GLfloat), _fovPlane.data());
|
||||
|
||||
GLsizei st = sizeof(GLfloat) * _stride;
|
||||
GLsizei st = sizeof(GLfloat) * Stride;
|
||||
glEnableVertexAttribArray(0);
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, st, (void*)0);
|
||||
@@ -268,8 +273,9 @@ psc RenderableFov::checkForIntercept(glm::dvec3 ray) {
|
||||
}
|
||||
// Orthogonal projection next to planets surface
|
||||
psc RenderableFov::orthogonalProjection(glm::dvec3 vecFov) {
|
||||
double lt;
|
||||
glm::dvec3 vecToTarget =
|
||||
SpiceManager::ref().targetPosition(_fovTarget, _spacecraft, _frame, _aberrationCorrection, _time, _lt);
|
||||
SpiceManager::ref().targetPosition(_fovTarget, _spacecraft, _frame, _aberrationCorrection, _time, lt);
|
||||
vecFov = SpiceManager::ref().frameTransformationMatrix(_instrumentID, _frame, _time) * vecFov;
|
||||
glm::dvec3 p = glm::proj(vecToTarget, vecFov);
|
||||
|
||||
@@ -279,7 +285,9 @@ psc RenderableFov::orthogonalProjection(glm::dvec3 vecFov) {
|
||||
return projection;
|
||||
}
|
||||
// Bisection method, simple recurtion
|
||||
glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance) {
|
||||
glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2) {
|
||||
const double Tolerance = 0.000000001; // very low tolerance factor
|
||||
|
||||
//check if point is on surface
|
||||
glm::dvec3 half = interpolate(p1, p2, 0.5f);
|
||||
|
||||
@@ -302,17 +310,17 @@ glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2, double toleran
|
||||
ivec = result.surfaceVector;
|
||||
bool intercepted = result.interceptFound;
|
||||
|
||||
if (glm::distance(_previousHalf, half) < tolerance){
|
||||
if (glm::distance(_previousHalf, half) < Tolerance){
|
||||
_previousHalf = glm::dvec3(0);
|
||||
return half;
|
||||
}
|
||||
_previousHalf = half;
|
||||
//recursive search
|
||||
if (!intercepted){
|
||||
return bisection(p1, half, tolerance);
|
||||
return bisection(p1, half);
|
||||
}
|
||||
else{
|
||||
return bisection(half, p2, tolerance);
|
||||
return bisection(half, p2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +329,6 @@ void RenderableFov::fovSurfaceIntercept(bool H[], std::vector<glm::dvec3> bounds
|
||||
_nrInserted = 0;
|
||||
_fovPlane.clear();// empty the array
|
||||
|
||||
double tolerance = 0.000000001; // very low tolerance factor
|
||||
|
||||
glm::dvec3 mid;
|
||||
glm::dvec3 interpolated;
|
||||
@@ -365,12 +372,12 @@ void RenderableFov::fovSurfaceIntercept(bool H[], std::vector<glm::dvec3> bounds
|
||||
|
||||
if (intercepted){
|
||||
// find the two outer most points of intersection
|
||||
glm::dvec3 root1 = bisection(half, current, tolerance);
|
||||
glm::dvec3 root2 = bisection(half, next, tolerance);
|
||||
glm::dvec3 root1 = bisection(half, current);
|
||||
glm::dvec3 root2 = bisection(half, next);
|
||||
|
||||
insertPoint(_fovPlane, orthogonalProjection(root1).vec4(), col_sq);
|
||||
for (int j = 1; j < _isteps; j++){
|
||||
float t = (static_cast<float>(j) / _isteps);
|
||||
for (int j = 1; j < InterpolationSteps; j++){
|
||||
float t = (static_cast<float>(j) / InterpolationSteps);
|
||||
interpolated = interpolate(root1, root2, t);
|
||||
_interceptVector = checkForIntercept(interpolated);
|
||||
insertPoint(_fovPlane, _interceptVector.vec4(), col_sq);
|
||||
@@ -381,26 +388,26 @@ void RenderableFov::fovSurfaceIntercept(bool H[], std::vector<glm::dvec3> bounds
|
||||
}
|
||||
if (H[i] == true && H[i + 1] == false){ // current point is interceptive, next is not
|
||||
// find outer most point for interpolation
|
||||
mid = bisection(current, next, tolerance);
|
||||
for (int j = 1; j <= _isteps; j++){
|
||||
float t = (static_cast<float>(j) / _isteps);
|
||||
mid = bisection(current, next);
|
||||
for (int j = 1; j <= InterpolationSteps; j++){
|
||||
float t = (static_cast<float>(j) / InterpolationSteps);
|
||||
interpolated = interpolate(current, mid, t);
|
||||
_interceptVector = (j < _isteps) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
|
||||
_interceptVector = (j < InterpolationSteps) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
|
||||
insertPoint(_fovPlane, _interceptVector.vec4(), col_sq);
|
||||
}
|
||||
}
|
||||
if (H[i] == false && H[i + 1] == true){ // current point is non-interceptive, next is
|
||||
mid = bisection(next, current, tolerance);
|
||||
for (int j = 1; j <= _isteps; j++){
|
||||
float t = (static_cast<float>(j) / _isteps);
|
||||
mid = bisection(next, current);
|
||||
for (int j = 1; j <= InterpolationSteps; j++){
|
||||
float t = (static_cast<float>(j) / InterpolationSteps);
|
||||
interpolated = interpolate(mid, next, t);
|
||||
_interceptVector = (j > 1) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
|
||||
insertPoint(_fovPlane, _interceptVector.vec4(), col_sq);
|
||||
}
|
||||
}
|
||||
if (H[i] == true && H[i + 1] == true){ // both points intercept
|
||||
for (int j = 0; j <= _isteps; j++){
|
||||
float t = (static_cast<float>(j) / _isteps);
|
||||
for (int j = 0; j <= InterpolationSteps; j++){
|
||||
float t = (static_cast<float>(j) / InterpolationSteps);
|
||||
interpolated = interpolate(current, next, t);
|
||||
_interceptVector = checkForIntercept(interpolated);
|
||||
insertPoint(_fovPlane, _interceptVector.vec4(), col_sq);
|
||||
@@ -451,25 +458,25 @@ void RenderableFov::computeColors() {
|
||||
col_end.w = alpha;
|
||||
}
|
||||
|
||||
void RenderableFov::determineTarget(){
|
||||
void RenderableFov::determineTarget() {
|
||||
_fovTarget = _potentialTargets[0]; //default;
|
||||
for (int i = 0; i < _potentialTargets.size(); i++){
|
||||
for (int i = 0; i < _potentialTargets.size(); i++) {
|
||||
_withinFOV = openspace::SpiceManager::ref().isTargetInFieldOfView(
|
||||
_potentialTargets[i], _spacecraft,
|
||||
|
||||
_potentialTargets[i],
|
||||
_spacecraft,
|
||||
_instrumentID,
|
||||
SpiceManager::FieldOfViewMethod::Ellipsoid,
|
||||
_aberrationCorrection,
|
||||
SpiceManager::FieldOfViewMethod::Ellipsoid,
|
||||
_aberrationCorrection,
|
||||
_time
|
||||
);
|
||||
if (_withinFOV){
|
||||
);
|
||||
if (_withinFOV) {
|
||||
_fovTarget = _potentialTargets[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableFov::computeIntercepts(const RenderData& data){
|
||||
void RenderableFov::computeIntercepts(const RenderData& data) {
|
||||
// for each FOV vector
|
||||
_fovBounds.clear();
|
||||
for (int i = 0; i <= _bounds.size(); i++){
|
||||
@@ -494,7 +501,8 @@ void RenderableFov::computeIntercepts(const RenderData& data){
|
||||
_interceptTag[r] = res.interceptFound;
|
||||
|
||||
// if not found, use the orthogonal projected point
|
||||
if (!_interceptTag[r]) _projectionBounds[r] = orthogonalProjection(_bounds[r]);
|
||||
if (!_interceptTag[r])
|
||||
_projectionBounds[r] = orthogonalProjection(_bounds[r]);
|
||||
|
||||
glm::vec4 fovOrigin = glm::vec4(0); //This will have to be fixed once spacecraft is 1:1!
|
||||
|
||||
@@ -522,13 +530,14 @@ void RenderableFov::computeIntercepts(const RenderData& data){
|
||||
fovSurfaceIntercept(_interceptTag, _bounds);
|
||||
|
||||
glm::vec3 aim = (_spacecraftRotation * glm::vec4(_boresight, 1)).xyz();
|
||||
double lt;
|
||||
glm::dvec3 position =
|
||||
SpiceManager::ref().targetPosition(_fovTarget,
|
||||
_spacecraft,
|
||||
_frame,
|
||||
_aberrationCorrection,
|
||||
_time,
|
||||
_lt);
|
||||
lt);
|
||||
psc p = PowerScaledCoordinate::CreatePowerScaledCoordinate(position.x, position.y, position.z);
|
||||
pss length = p.length();
|
||||
if (length[0] < DBL_EPSILON) {
|
||||
@@ -567,13 +576,13 @@ void RenderableFov::render(const RenderData& data) {
|
||||
|
||||
glLineWidth(_lineWidth);
|
||||
glBindVertexArray(_fovBoundsVAO);
|
||||
glDrawArrays(_mode, 0, static_cast<int>(_vBoundsSize / _stride));
|
||||
glDrawArrays(_mode, 0, static_cast<int>(_vBoundsSize / Stride));
|
||||
glBindVertexArray(0);
|
||||
|
||||
if (_drawFOV){
|
||||
glLineWidth(2.f);
|
||||
glBindVertexArray(_fovPlaneVAO);
|
||||
glDrawArrays(GL_LINE_LOOP, 0, static_cast<int>(_vPlaneSize / _stride));
|
||||
glDrawArrays(GL_LINE_LOOP, 0, static_cast<int>(_vPlaneSize / Stride));
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
glLineWidth(1.f);
|
||||
|
||||
@@ -53,13 +53,6 @@ public:
|
||||
void update(const UpdateData& data) override;
|
||||
|
||||
private:
|
||||
// properties
|
||||
properties::FloatProperty _lineWidth;
|
||||
properties::BoolProperty _drawSolid;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
openspace::SceneGraphNode* _targetNode;
|
||||
|
||||
// class methods
|
||||
void loadTexture();
|
||||
void allocateData();
|
||||
@@ -77,11 +70,17 @@ public:
|
||||
psc checkForIntercept(glm::dvec3 ray);
|
||||
psc pscInterpolate(psc p0, psc p1, float t);
|
||||
glm::dvec3 interpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
|
||||
glm::dvec3 bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance);
|
||||
glm::dvec3 bisection(glm::dvec3 p1, glm::dvec3 p2);
|
||||
|
||||
// properties
|
||||
properties::FloatProperty _lineWidth;
|
||||
properties::BoolProperty _drawSolid;
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
|
||||
ghoul::opengl::Texture* _texture;
|
||||
|
||||
|
||||
// instance variables
|
||||
int _nrInserted = 0;
|
||||
int _isteps;
|
||||
bool _rebuild = false;
|
||||
bool _interceptTag[8];
|
||||
bool _withinFOV;
|
||||
@@ -106,7 +105,6 @@ public:
|
||||
std::vector<glm::dvec3> _bounds;
|
||||
std::vector<std::string> _potentialTargets;
|
||||
bool _drawFOV;
|
||||
double _lt;
|
||||
|
||||
// GPU
|
||||
GLuint _fovBoundsVAO;
|
||||
@@ -116,7 +114,6 @@ public:
|
||||
GLuint _fovPlaneVBO;
|
||||
unsigned int _vPlaneSize;
|
||||
GLenum _mode;
|
||||
unsigned int _stride;
|
||||
|
||||
// time
|
||||
double _time = 0;
|
||||
|
||||
@@ -48,7 +48,8 @@ namespace {
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
RenderableShadowCylinder::RenderableShadowCylinder(const ghoul::Dictionary& dictionary)
|
||||
|
||||
RenderableShadowCylinder::RenderableShadowCylinder(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _numberOfPoints("amountOfPoints", "Points", 190, 1, 300)
|
||||
, _shadowLength("shadowLength", "Shadow Length", 0.1, 0.0, 0.5)
|
||||
@@ -150,10 +151,9 @@ void RenderableShadowCylinder::render(const RenderData& data){
|
||||
|
||||
void RenderableShadowCylinder::update(const UpdateData& data) {
|
||||
_stateMatrix = SpiceManager::ref().positionTransformMatrix(_bodyFrame, _mainFrame, data.time);
|
||||
_time = data.time;
|
||||
if (_shader->isDirty())
|
||||
_shader->rebuildFromFile();
|
||||
createCylinder();
|
||||
createCylinder(data.time);
|
||||
}
|
||||
|
||||
glm::vec4 psc_addition(glm::vec4 v1, glm::vec4 v2) {
|
||||
@@ -169,7 +169,7 @@ glm::vec4 psc_addition(glm::vec4 v1, glm::vec4 v2) {
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableShadowCylinder::createCylinder() {
|
||||
void RenderableShadowCylinder::createCylinder(double time) {
|
||||
double targetEpoch;
|
||||
glm::dvec3 observerPosition;
|
||||
std::vector<psc> terminatorPoints;
|
||||
@@ -180,7 +180,7 @@ void RenderableShadowCylinder::createCylinder() {
|
||||
// t = SpiceManager::TerminatorType::Penumbral;
|
||||
|
||||
auto res = SpiceManager::ref().terminatorEllipse(_body, _observer, _bodyFrame,
|
||||
_lightSource, t, _aberration, _time, _numberOfPoints);
|
||||
_lightSource, t, _aberration, time, _numberOfPoints);
|
||||
|
||||
targetEpoch = res.targetEphemerisTime;
|
||||
observerPosition = std::move(res.observerPosition);
|
||||
@@ -194,9 +194,9 @@ void RenderableShadowCylinder::createCylinder() {
|
||||
|
||||
double lt;
|
||||
glm::dvec3 vecLightSource =
|
||||
SpiceManager::ref().targetPosition(_body, _lightSource, _mainFrame, _aberration, _time, lt);
|
||||
SpiceManager::ref().targetPosition(_body, _lightSource, _mainFrame, _aberration, time, lt);
|
||||
|
||||
glm::dmat3 _stateMatrix = glm::inverse(SpiceManager::ref().positionTransformMatrix(_bodyFrame, _mainFrame, _time));
|
||||
glm::dmat3 _stateMatrix = glm::inverse(SpiceManager::ref().positionTransformMatrix(_bodyFrame, _mainFrame, time));
|
||||
|
||||
vecLightSource = _stateMatrix * vecLightSource;
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace openspace {
|
||||
float x, y, z, e;
|
||||
};
|
||||
|
||||
void createCylinder();
|
||||
void createCylinder(double time);
|
||||
properties::IntProperty _numberOfPoints;
|
||||
properties::FloatProperty _shadowLength;
|
||||
properties::Vec4Property _shadowColor;
|
||||
@@ -90,8 +90,6 @@ namespace openspace {
|
||||
std::string _bodyFrame;
|
||||
std::string _mainFrame;
|
||||
SpiceManager::AberrationCorrection _aberration;
|
||||
|
||||
double _time;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -22,17 +22,22 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/newhorizons/util/hongkangparser.h>
|
||||
|
||||
#include <modules/newhorizons/util/imagesequencer.h>
|
||||
#include <modules/newhorizons/util/instrumentdecoder.h>
|
||||
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/directory.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <modules/newhorizons/util/hongkangparser.h>
|
||||
#include <modules/newhorizons/util/instrumentdecoder.h>
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -43,35 +48,34 @@ namespace {
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
HongKangParser::HongKangParser(std::string name, const std::string& fileName,
|
||||
HongKangParser::HongKangParser(std::string name, std::string fileName,
|
||||
std::string spacecraft,
|
||||
ghoul::Dictionary translationDictionary,
|
||||
std::vector<std::string> potentialTargets)
|
||||
: _name(std::move(name))
|
||||
, _defaultCaptureImage(absPath("${OPENSPACE_DATA}/scene/common/textures/placeholder.png"))
|
||||
, _fileName(std::move(fileName))
|
||||
, _spacecraft(std::move(spacecraft))
|
||||
, _potentialTargets(std::move(potentialTargets))
|
||||
{
|
||||
_fileName = fileName;
|
||||
_spacecraft = spacecraft;
|
||||
_potentialTargets = potentialTargets;
|
||||
|
||||
//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++){
|
||||
for (int i = 0; i < decoders.size(); ++i) {
|
||||
//create dictionary containing all {playbookKeys , spice IDs}
|
||||
if (decoders[i] == "Instrument"){
|
||||
if (decoders[i] == "Instrument") {
|
||||
ghoul::Dictionary typeDictionary;
|
||||
translationDictionary.getValue(decoders[i], typeDictionary);
|
||||
//for each playbook call -> create a Decoder object
|
||||
const std::vector<std::string>& keys = typeDictionary.keys();
|
||||
//std::string abort = decoders[i] + "." + keyStopCommand;
|
||||
for (int j = 0; j < keys.size(); j++){
|
||||
for (int j = 0; j < keys.size(); ++j) {
|
||||
std::string currentKey = decoders[i] + "." + keys[j];
|
||||
|
||||
ghoul::Dictionary decoderDictionary;
|
||||
translationDictionary.getValue(currentKey, decoderDictionary);
|
||||
|
||||
Decoder *decoder = Decoder::createFromDictionary(decoderDictionary, decoders[i]);
|
||||
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;
|
||||
@@ -81,43 +85,26 @@ HongKangParser::HongKangParser(std::string name, const std::string& fileName,
|
||||
}
|
||||
}
|
||||
|
||||
void HongKangParser::findPlaybookSpecifiedTarget(std::string line, std::string& target){
|
||||
void HongKangParser::findPlaybookSpecifiedTarget(std::string line, std::string& target) {
|
||||
//remembto add this lua later...
|
||||
std::transform(line.begin(), line.end(), line.begin(), toupper);
|
||||
std::vector<std::string> ptarg = _potentialTargets;
|
||||
for (auto p : ptarg){
|
||||
for (const auto& p : ptarg) {
|
||||
// loop over all targets and determine from 4th col which target this instrument points to
|
||||
std::transform(line.begin(), line.end(), line.begin(), toupper);
|
||||
if (line.find(p) != std::string::npos){
|
||||
target = p;
|
||||
break;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// not found - we set void until we have more info.
|
||||
target = "VOID";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HongKangParser::writeUTCEventFile(const Image image){
|
||||
std::string time_beg = SpiceManager::ref().dateFromEphemerisTime(image.startTime);
|
||||
std::string time_end = SpiceManager::ref().dateFromEphemerisTime(image.stopTime);
|
||||
|
||||
_eventsAsUTCFile << std::fixed
|
||||
<< std::setw(10) << time_beg << "->"
|
||||
<< std::setw(10) << time_end
|
||||
<< std::setw(10) << (int)getMetFromET(image.startTime) << "->"
|
||||
<< std::setw(10) << (int)getMetFromET(image.stopTime)
|
||||
<< std::setw(10) << image.target << std::setw(10);
|
||||
for (auto instrument : image.activeInstruments){
|
||||
_eventsAsUTCFile << " " << instrument;
|
||||
}
|
||||
}
|
||||
|
||||
bool HongKangParser::create(){
|
||||
bool HongKangParser::create() {
|
||||
//check input for errors.
|
||||
int tmp;
|
||||
bool hasObserver = SpiceManager::ref().hasNaifId(_spacecraft);
|
||||
tmp = SpiceManager::ref().naifId(_spacecraft);
|
||||
if (!hasObserver){
|
||||
LERROR("SPICE navigation system has no pooled observer: '" << _spacecraft << "' in kernel" <<
|
||||
"Please check that all necessary kernels are loaded"<<
|
||||
@@ -129,8 +116,6 @@ bool HongKangParser::create(){
|
||||
<< "please check modfile");
|
||||
}
|
||||
|
||||
_eventsAsUTCFile.open("utcEvents.txt");
|
||||
|
||||
if (size_t position = _fileName.find_last_of(".") + 1){
|
||||
if (position != std::string::npos){
|
||||
std::string extension = ghoul::filesystem::File(_fileName).fileExtension();
|
||||
@@ -149,7 +134,6 @@ bool HongKangParser::create(){
|
||||
std::string previousTarget;
|
||||
|
||||
std::string previousCamera;
|
||||
std::string previousScanner;
|
||||
|
||||
TimeRange cameraRange;
|
||||
TimeRange scanRange;
|
||||
@@ -176,8 +160,6 @@ bool HongKangParser::create(){
|
||||
std::string met = line.substr(25, 9);
|
||||
double time = getETfromMet(met);
|
||||
|
||||
Image image;
|
||||
|
||||
if (foundEvent){
|
||||
//store the time, this is used for getNextCaptureTime()
|
||||
_captureProgression.push_back(time);
|
||||
@@ -194,8 +176,17 @@ bool HongKangParser::create(){
|
||||
findPlaybookSpecifiedTarget(line, cameraTarget);
|
||||
|
||||
//fill image
|
||||
createImage(image, time, time + shutter, cameraSpiceID, cameraTarget, _defaultCaptureImage);
|
||||
writeUTCEventFile(image);
|
||||
|
||||
Image image;
|
||||
image.startTime = time;
|
||||
image.stopTime = time + shutter;
|
||||
image.path = _defaultCaptureImage;
|
||||
image.activeInstruments = cameraSpiceID;
|
||||
image.target = cameraTarget;
|
||||
image.isPlaceholder = true;
|
||||
image.projected = false;
|
||||
//createImage(image, time, time + shutter, cameraSpiceID, cameraTarget, _defaultCaptureImage);
|
||||
|
||||
//IFF spaccraft has decided to switch target, store in target map (used for: 'next observation focus')
|
||||
if (previousTarget != image.target){
|
||||
previousTarget = image.target;
|
||||
@@ -234,11 +225,17 @@ bool HongKangParser::create(){
|
||||
_instrumentTimes.push_back(std::make_pair(it->first, scanRange));
|
||||
|
||||
//store individual image
|
||||
createImage(image, scan_start, scan_stop, scannerSpiceID, scannerTarget, _defaultCaptureImage);
|
||||
writeUTCEventFile(image);
|
||||
Image image;
|
||||
image.startTime = scan_start;
|
||||
image.stopTime = scan_stop;
|
||||
image.path = _defaultCaptureImage;
|
||||
image.activeInstruments = cameraSpiceID;
|
||||
image.target = cameraTarget;
|
||||
image.isPlaceholder = true;
|
||||
image.projected = false;
|
||||
|
||||
_subsetMap[image.target]._subset.push_back(image);
|
||||
_subsetMap[image.target]._range.setRange(scan_start);
|
||||
_subsetMap[scannerTarget]._subset.push_back(image);
|
||||
_subsetMap[scannerTarget]._range.setRange(scan_start);
|
||||
}
|
||||
}
|
||||
//go back to stored position in file
|
||||
@@ -256,7 +253,6 @@ bool HongKangParser::create(){
|
||||
capture_start = -1;
|
||||
}
|
||||
}
|
||||
_eventsAsUTCFile << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,31 +266,33 @@ bool HongKangParser::create(){
|
||||
bool HongKangParser::augmentWithSpice(Image& image,
|
||||
std::string spacecraft,
|
||||
std::vector<std::string> payload,
|
||||
std::vector<std::string> potentialTargets){
|
||||
std::vector<std::string> potentialTargets)
|
||||
{
|
||||
image.target = "VOID";
|
||||
// we have (?) to cast to int, unfortunately
|
||||
// Why? --abock
|
||||
// because: old comment --m
|
||||
int exposureTime = image.stopTime - image.startTime;
|
||||
if (exposureTime == 0)
|
||||
if (exposureTime == 0) {
|
||||
exposureTime = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < potentialTargets.size(); i++){
|
||||
bool success = false;
|
||||
for (int i = 0; i < potentialTargets.size(); ++i) {
|
||||
bool _withinFOV = false;
|
||||
for (int j = 0; j < image.activeInstruments.size(); j++){
|
||||
for (int j = 0; j < image.activeInstruments.size(); ++j) {
|
||||
double time = image.startTime;
|
||||
for (int k = 0; k < exposureTime; k++){
|
||||
time += k;
|
||||
_withinFOV = SpiceManager::ref().isTargetInFieldOfView(
|
||||
potentialTargets[i],
|
||||
spacecraft,
|
||||
potentialTargets[i],
|
||||
spacecraft,
|
||||
image.activeInstruments[j],
|
||||
SpiceManager::FieldOfViewMethod::Ellipsoid,
|
||||
{},
|
||||
SpiceManager::FieldOfViewMethod::Ellipsoid,
|
||||
{},
|
||||
time
|
||||
);
|
||||
if (_withinFOV){
|
||||
);
|
||||
|
||||
if (_withinFOV) {
|
||||
image.target = potentialTargets[i];
|
||||
_withinFOV = false;
|
||||
}
|
||||
@@ -304,17 +302,17 @@ bool HongKangParser::augmentWithSpice(Image& image,
|
||||
return false;
|
||||
}
|
||||
|
||||
void HongKangParser::createImage(Image& image, double startTime, double stopTime, std::vector<std::string> instr, std::string targ, std::string path) {
|
||||
image.startTime = startTime;
|
||||
image.stopTime = stopTime;
|
||||
image.path = path;
|
||||
for (int i = 0; i < instr.size(); i++){
|
||||
image.activeInstruments.push_back(instr[i]);
|
||||
}
|
||||
image.target = targ;
|
||||
image.projected = false;
|
||||
image.isPlaceholder = true;
|
||||
}
|
||||
//Image HongKangParser::createImage(double startTime, double stopTime, std::vector<std::string> instr, std::string targ, std::string path) {
|
||||
// image.startTime = startTime;
|
||||
// image.stopTime = stopTime;
|
||||
// image.path = path;
|
||||
// for (int i = 0; i < instr.size(); i++){
|
||||
// image.activeInstruments.push_back(instr[i]);
|
||||
// }
|
||||
// image.target = targ;
|
||||
// image.projected = false;
|
||||
// image.isPlaceholder = true;
|
||||
//}
|
||||
|
||||
double HongKangParser::getETfromMet(std::string line){
|
||||
std::string::size_type sz;
|
||||
|
||||
@@ -28,17 +28,18 @@
|
||||
#include <modules/newhorizons/util/imagesequencer.h>
|
||||
#include <modules/newhorizons/util/sequenceparser.h>
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class HongKangParser : public SequenceParser {
|
||||
public:
|
||||
HongKangParser();
|
||||
HongKangParser(std::string name, const std::string& fileName,
|
||||
HongKangParser(std::string name, std::string fileName,
|
||||
std::string spacecraft,
|
||||
ghoul::Dictionary dictionary,
|
||||
std::vector<std::string> potentialTargets);
|
||||
@@ -47,19 +48,16 @@ public:
|
||||
void findPlaybookSpecifiedTarget(std::string line, std::string& target);
|
||||
virtual std::map<std::string, Decoder*> getTranslation(){ return _fileTranslation; };
|
||||
|
||||
void writeUTCEventFile(const Image image);
|
||||
|
||||
private:
|
||||
double getMetFromET(double et);
|
||||
double getETfromMet(std::string timestr);
|
||||
double getETfromMet(double met);
|
||||
|
||||
void createImage(Image& image,
|
||||
double startTime,
|
||||
double stopTime,
|
||||
std::vector<std::string> instr,
|
||||
std::string targ,
|
||||
std::string pot);
|
||||
//Image createImage(double startTime,
|
||||
// double stopTime,
|
||||
// std::vector<std::string> instr,
|
||||
// std::string targ,
|
||||
// std::string pot);
|
||||
|
||||
bool augmentWithSpice(Image& image,
|
||||
std::string spacecraft,
|
||||
@@ -74,7 +72,6 @@ private:
|
||||
std::string _spacecraft;
|
||||
std::map<std::string, Decoder*> _fileTranslation;
|
||||
std::vector<std::string> _potentialTargets;
|
||||
std::ofstream _eventsAsUTCFile;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -46,6 +46,10 @@ ImageSequencer* ImageSequencer::_instance = nullptr;
|
||||
|
||||
ImageSequencer::ImageSequencer()
|
||||
: _hasData(false)
|
||||
//, _currentTime(0.0)
|
||||
//, _previousTime(0.0)
|
||||
//, _intervalLength(0.0)
|
||||
//, _nextCapture(0.0)
|
||||
{}
|
||||
|
||||
ImageSequencer& ImageSequencer::ref() {
|
||||
@@ -63,22 +67,22 @@ void ImageSequencer::deinitialize() {
|
||||
_instance = nullptr;
|
||||
}
|
||||
|
||||
bool ImageSequencer::isReady(){
|
||||
bool ImageSequencer::isReady() {
|
||||
return _hasData;
|
||||
}
|
||||
|
||||
void ImageSequencer::updateSequencer(double time){
|
||||
if (Time::ref().timeJumped() && Time::ref().deltaTime() == 0){
|
||||
void ImageSequencer::updateSequencer(double time) {
|
||||
if (Time::ref().timeJumped() && Time::ref().deltaTime() == 0) {
|
||||
Time::ref().setDeltaTime(0.1);
|
||||
} // Time is not properly updated when time jump with dt = 0
|
||||
|
||||
if (_currentTime != time){
|
||||
if (_currentTime != time) {
|
||||
_previousTime = _currentTime;
|
||||
_currentTime = time;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<double, std::string> ImageSequencer::getNextTarget(){
|
||||
std::pair<double, std::string> ImageSequencer::getNextTarget() {
|
||||
auto compareTime = [](const std::pair<double, std::string> &a,
|
||||
const std::pair<double, std::string> &b)->bool{
|
||||
return a.first < b.first;
|
||||
@@ -93,7 +97,7 @@ std::pair<double, std::string> ImageSequencer::getNextTarget(){
|
||||
return std::make_pair(0.0, "");
|
||||
}
|
||||
|
||||
std::pair<double, std::string> ImageSequencer::getCurrentTarget(){
|
||||
std::pair<double, std::string> ImageSequencer::getCurrentTarget() {
|
||||
auto compareTime = [](const std::pair<double, std::string> &a,
|
||||
const std::pair<double, std::string> &b)->bool{
|
||||
return a.first < b.first;
|
||||
@@ -109,7 +113,7 @@ std::pair<double, std::string> ImageSequencer::getCurrentTarget(){
|
||||
return std::make_pair(0.0, "No Target");
|
||||
}
|
||||
|
||||
std::pair<double, std::vector<std::string>> ImageSequencer::getIncidentTargetList(int range){
|
||||
std::pair<double, std::vector<std::string>> ImageSequencer::getIncidentTargetList(int range) {
|
||||
std::pair<double, std::vector<std::string>> incidentTargets;
|
||||
|
||||
auto compareTime = [](const std::pair<double, std::string> &a,
|
||||
|
||||
@@ -170,6 +170,8 @@ bool LabelParser::create() {
|
||||
std::string previousSequence;
|
||||
TimeRange instrumentRange;
|
||||
|
||||
double startTime = 0.0;
|
||||
double stopTime = 0.0;
|
||||
do {
|
||||
std::getline(file, line);
|
||||
|
||||
@@ -204,10 +206,11 @@ bool LabelParser::create() {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
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);
|
||||
startTime = SpiceManager::ref().ephemerisTimeFromDate(start);
|
||||
count++;
|
||||
|
||||
getline(file, line);
|
||||
@@ -222,7 +225,7 @@ bool LabelParser::create() {
|
||||
),
|
||||
stop.end()
|
||||
);
|
||||
_stopTime = SpiceManager::ref().ephemerisTimeFromDate(stop);
|
||||
stopTime = SpiceManager::ref().ephemerisTimeFromDate(stop);
|
||||
count++;
|
||||
}
|
||||
else{
|
||||
@@ -244,12 +247,12 @@ bool LabelParser::create() {
|
||||
Image image;
|
||||
std::vector<std::string> spiceInstrument;
|
||||
spiceInstrument.push_back(_instrumentID);
|
||||
createImage(image, _startTime, _startTime, spiceInstrument, _target, path);
|
||||
createImage(image, startTime, stopTime, spiceInstrument, _target, path);
|
||||
|
||||
_subsetMap[image.target]._subset.push_back(image);
|
||||
_subsetMap[image.target]._range.setRange(_startTime);
|
||||
_subsetMap[image.target]._range.setRange(startTime);
|
||||
|
||||
_captureProgression.push_back(_startTime);
|
||||
_captureProgression.push_back(startTime);
|
||||
std::stable_sort(_captureProgression.begin(), _captureProgression.end());
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,6 @@ private:
|
||||
std::string _instrumentHostID;
|
||||
std::string _detectorType;
|
||||
std::string _sequenceID;
|
||||
double _startTime;
|
||||
double _stopTime;
|
||||
bool _badDecoding;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -74,11 +74,9 @@
|
||||
#include <modules/iswa/util/iswamanager.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifdef OPENSPACE_ENABLE_VLD
|
||||
#if defined(_MSC_VER) && defined(OPENSPACE_ENABLE_VLD)
|
||||
#include <vld.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <WinBase.h>
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
// This is not a memleak because the placement new operator does not
|
||||
// actually create any memory that could leak
|
||||
memleak:src/performance/performancemanager.cpp
|
||||
|
||||
|
||||
missingInclude
|
||||
noExplicitConstructor
|
||||
|
||||
Reference in New Issue
Block a user