completely new imagesequencer class - WIP

This commit is contained in:
Michal Marcinkowski
2015-04-16 11:57:23 -04:00
parent d124209281
commit de6fcf1583
24 changed files with 834 additions and 584 deletions
@@ -33,7 +33,8 @@
#include <openspace/util/sequenceparser.h>
#include <openspace/util/hongkangparser.h>
#include <openspace/util/payload.h>
#include <openspace/util/labelparser.h>
#include <openspace/util/decoder.h>
#include <openspace/properties/stringproperty.h>
@@ -77,7 +78,7 @@ protected:
private:
void imageProjectGPU();
std::map<std::string, Payload*> _fileTranslation;
std::map<std::string, Decoder*> _fileTranslation;
properties::StringProperty _colorTexturePath;
properties::StringProperty _projectionTexturePath;
@@ -134,6 +135,8 @@ private:
GLuint _fboID;
GLuint _quad;
GLuint _vertexPositionBuffer;
bool _once; //fml
};
} // namespace openspace
@@ -124,59 +124,3 @@ public:
};
}
#endif
// Scrap stuff i need to keep for now (michal)
/* // idk how we will compute the aberrated state.
double RenderableFov::computeTargetLocalTime(PowerScaledScalar d){
double c = 299792456.075; // m/s
double dt = ( (d[0]*pow(10, d[1])) / c );
double t_local = _time - dt*86400;
std::string localTime;
std::string currentTime;
openspace::SpiceManager::ref().getDateFromET(t_local, localTime);
openspace::SpiceManager::ref().getDateFromET(_time , currentTime);
std::cout << "time at jupiter : " << localTime << "\time at NH" << currentTime << std::endl;
return t_local;
}*/
/*
psc RenderableFov::sphericalInterpolate(glm::dvec3 p0, glm::dvec3 p1, float t){
double targetEt, lt;
glm::dvec3 ip, iv;
psc targetPos;
SpiceManager::ref().getTargetPosition("JUPITER", _spacecraft, _frame, _aberrationCorrection, _time, targetPos, lt);
openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
_frame, _method, _aberrationCorrection, _time, targetEt, p0, ip, iv);
psc psc0 = PowerScaledCoordinate::CreatePowerScaledCoordinate(iv[0], iv[1], iv[2]);
openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
_frame, _method, _aberrationCorrection, _time, targetEt, p1, ip, iv);
psc psc1 = PowerScaledCoordinate::CreatePowerScaledCoordinate(iv[0], iv[1], iv[2]);
psc0[3] += 3;
psc1[3] += 3;
psc0 -= targetPos;
psc1 -= targetPos;
double angle = psc0.angle(psc1);
std::cout << angle << std::endl;
double sin_a = sin(angle); // opt
double l[2] = { sin((1.f - t)*angle) / sin_a, sin((t)*angle) / sin_a };
std::cout << l[0] << " " << l[1] << std::endl;
float s = ((t-1)*psc0[3] + (t)*psc1[3]);
float x = (l[0]*psc0[0] + l[1]*psc1[0]);
float y = (l[0]*psc0[1] + l[1]*psc1[1]);
float z = (l[0]*psc0[2] + l[1]*psc1[2]);
psc interpolated = PowerScaledCoordinate::PowerScaledCoordinate(x, y, z, 10);
return interpolated;
}
*/
@@ -22,26 +22,26 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __PAYLOAD_H__
#define __PAYLOAD_H__
#ifndef __DECODER_H__
#define __DECODER_H__
#include <ghoul/misc/dictionary.h>
#include <openspace/util/updatestructures.h>
namespace openspace {
class Payload {
class Decoder {
public:
static Payload* createFromDictionary(const ghoul::Dictionary& dictionary, const std::string type);
static Decoder* createFromDictionary(const ghoul::Dictionary& dictionary, const std::string type);
Payload(const ghoul::Dictionary& dictionary);
virtual ~Payload();
virtual std::string getType() = 0;
virtual std::vector<std::string> getSpiceIDs() = 0;
Decoder(const ghoul::Dictionary& dictionary);
virtual ~Decoder();
virtual std::string getDecoderType() = 0;
virtual std::vector<std::string> getTranslation() = 0;
protected:
Payload();
Decoder();
};
} // namespace openspace
#endif // __PAYLOAD_H__
#endif // __DECODER_H__
+11 -11
View File
@@ -28,27 +28,26 @@
#include <openspace/util/ImageSequencer2.h>
#include <openspace/util/sequenceparser.h>
#include <map>
#include <string>
#include <vector>
namespace openspace {
class HongKangParser : public SequenceParser{
public:
HongKangParser();
HongKangParser(const std::string& fileName,
std::string spacecraft,
std::map<std::string, Payload*> acronymDictionary,
ghoul::Dictionary dictionary,
std::vector<std::string> potentialTargets);
virtual void create();
virtual std::map<std::string, ImageSubset> getSubsetMap();
virtual std::vector<std::pair<double, std::string>> getIstrumentTimes();
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes();
virtual std::vector<std::pair<double, std::string>> getTargetTimes();
// temporary need to figure this out
std::map<std::string, Payload*> getAcronymDictionary(){ return _fileTranslation; };
virtual std::map<std::string, Decoder*> getTranslation(){ return _fileTranslation; };
virtual std::vector<double> getCaptureProgression();
private:
double getMetFromET(double et);
@@ -67,18 +66,19 @@ namespace openspace {
std::vector<std::string> payload,
std::vector<std::string> potentialTargets);
std::map<std::string, ImageSubset> _subsetMap;
std::vector<std::pair<double, std::string>> _instrumentTimes;
std::vector<std::pair<double, std::string>> _targetTimes;
std::string _defaultCaptureImage;
double _metRef = 299180517;
std::string _fileName;
std::string _spacecraft;
std::map<std::string, Payload*> _fileTranslation;
std::map<std::string, Decoder*> _fileTranslation;
std::vector<std::string> _potentialTargets;
//returnable
std::map<std::string, ImageSubset> _subsetMap;
std::vector<std::pair<std::string, TimeRange>> _instrumentTimes;
std::vector<std::pair<double, std::string>> _targetTimes;
std::vector<double> _captureProgression;
};
}
+13 -10
View File
@@ -48,9 +48,10 @@ public:
static void initialize();
static void deinitialize();
bool isReady();
//provides the sequencer with current time
void updateSequencer(double time);
void runSequenceParser(SequenceParser* parser);
//translates playbook ambiguous namesetting to spice calls, augments each observation with targets and
@@ -68,11 +69,12 @@ public:
std::pair<double, std::vector<std::string>> getIncidentTargetList(int range = 2);
double getNextCaptureTime();
double getIntervalLength();
std::vector<std::pair<std::string, bool>> getActiveInstruments();
bool ImageSequencer2::getImagePaths(std::vector<std::pair<double, std::string>>& captures, std::string projectee, std::string instrumentID);
bool ImageSequencer2::getImagePaths(std::vector<std::pair<double, std::string>>& captures, std::string projectee);
//a fov class can check whether or not its active
bool instumentActive(std::string instrumentID);
//get all currently active instruments
std::vector<std::string> getActiveInstruments();
const Image* findLatestImageInSubset( ImageSubset& subset);
private:
@@ -88,18 +90,19 @@ private:
//var
double _currentTime;
double _previousTime;
double _intervalLength;
double _nextCapture;
std::string _defaultCaptureImage;
std::vector<std::string> _currentlyActiveInstruments;
std::vector<std::pair<std::string, bool>> _instrumentOnOff;
std::map<std::string, ImageSubset> _subsetMap;
std::vector<std::pair<double, std::string>> _targetTimes;
std::vector<std::pair<double, std::string>> _instrumentTimes;
//std::vector<std::string, TimeRange> _activeInstruments
std::map<std::string, std::vector<std::string>> _acronymDictionary;
static bool hasData();
std::vector<std::pair<std::string, TimeRange>> _instrumentTimes;
std::vector<double> _captureProgression;
std::map<std::string, Decoder*> _fileTranslation;
bool _hasData;
};
} // namespace openspace
@@ -22,20 +22,20 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __SCANNERINSTRUMENT_H__
#define __SCANNERINSTRUMENT_H__
#ifndef __INSTRUMENTDECODER_H__
#define __INSTRUMENTDECODER_H__
#include <openspace/util/payload.h>
#include <openspace/util/decoder.h>
#include <openspace/util/powerscaledcoordinate.h>
namespace openspace {
class ScannerInstrument : public Payload {
class InstrumentDecoder : public Decoder {
public:
ScannerInstrument(const ghoul::Dictionary& dictionary);
virtual std::string getType();
virtual std::vector<std::string> getSpiceIDs();
InstrumentDecoder(const ghoul::Dictionary& dictionary);
virtual std::string getDecoderType();
virtual std::vector<std::string> getTranslation();
private:
std::string _type;
std::vector<std::string> _spiceIDs;
@@ -43,4 +43,4 @@ private:
} // namespace openspace
#endif // __SCANNERINSTRUMENT_H__
#endif // __INSTRUMENTDECODER_H__
+76
View File
@@ -0,0 +1,76 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* 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. *
****************************************************************************************/
#ifndef __LABELPARSER_H__
#define __LABELPARSER_H__
#include <openspace/util/ImageSequencer2.h>
#include <openspace/util/sequenceparser.h>
#include <map>
#include <string>
#include <vector>
namespace openspace {
class LabelParser : public SequenceParser{
public:
LabelParser();
LabelParser(const std::string& fileName,
ghoul::Dictionary translationDictionary);
virtual void create();
virtual std::map<std::string, ImageSubset> getSubsetMap();
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes();
virtual std::vector<std::pair<double, std::string>> getTargetTimes();
// temporary need to figure this out
std::map<std::string, Decoder*> getTranslation(){ return _fileTranslation; };
virtual std::vector<double> getCaptureProgression(){ return _captureProgression; };
private:
void createImage(Image& image,
double startTime,
double stopTime,
std::vector<std::string> instr,
std::string targ,
std::string pot);
bool augmentWithSpice(Image& image,
std::string spacecraft,
std::vector<std::string> payload,
std::vector<std::string> potentialTargets);
std::string _fileName;
std::string _spacecraft;
std::map<std::string, Decoder*> _fileTranslation;
std::vector<std::string> _specsOfInterest;
//returnable
std::map<std::string, ImageSubset> _subsetMap;
std::vector<std::pair<std::string, TimeRange>> _instrumentTimes;
std::vector<std::pair<double, std::string>> _targetTimes;
std::vector<double> _captureProgression;
};
}
#endif //__LABELPARSER_H__
@@ -22,19 +22,18 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __CAMERAINSTRUMENT_H__
#define __CAMERAINSTRUMENT_H__
#include <openspace/util/payload.h>
#ifndef __SCANNERDECODER_H__
#define __SCANNERDECODER_H__
#include <openspace/util/decoder.h>
#include <openspace/util/powerscaledcoordinate.h>
namespace openspace {
class CameraInstrument : public Payload {
class ScannerDecoder : public Decoder {
public:
CameraInstrument(const ghoul::Dictionary& dictionary);
virtual std::string getType();
ScannerDecoder(const ghoul::Dictionary& dictionary);
virtual std::string getDecoderType();
virtual std::vector<std::string> getSpiceIDs();
private:
std::string _type;
@@ -43,4 +42,4 @@ private:
} // namespace openspace
#endif // __CAMERAINSTRUMENT_H__
#endif // __SCANNERDECODER_H__
+11 -8
View File
@@ -25,9 +25,8 @@
#ifndef __SEQUENCEPARSER_H__
#define __SEQUENCEPARSER_H__
#include <openspace/util/sequenceparser.h>
#include <openspace/util/hongkangparser.h>
#include <openspace/util/payload.h>
#include <openspace/util/decoder.h>
#include <map>
#include <string>
@@ -45,12 +44,15 @@ namespace openspace {
struct TimeRange{
TimeRange() : _min(-1), _max(-1){};
void setRange(double val){
if (_min > val || _min < 0) _min = val;
if (_max < val || _max < 0) _max = val;
if (_min > val) _min = val;
if (_max < val) _max = val;
};
bool inRange(double min, double max){
return (min >= _min && max <= _max);
}
bool inRange(double val){
return (val >= _min && val <= _max);
}
double _min;
double _max;
};
@@ -63,9 +65,10 @@ class SequenceParser{
public:
virtual void create() = 0;
virtual std::map<std::string, ImageSubset> getSubsetMap() = 0;
virtual std::vector<std::pair<double, std::string>> getIstrumentTimes() = 0;
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes() = 0;
virtual std::vector<std::pair<double, std::string>> getTargetTimes() = 0;
virtual std::map<std::string, Payload*> getAcronymDictionary() = 0;
virtual std::map<std::string, Decoder*> getTranslation() = 0;
virtual std::vector<double> getCaptureProgression() = 0;
};
}
#endif //__SEQUENCEPARSER_H__
#endif //__SEQUENCEPARSER_H__
+46
View File
@@ -0,0 +1,46 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* 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. *
****************************************************************************************/
#ifndef __TARGETDECODER_H__
#define __TARGETDECODER_H__
#include <openspace/util/decoder.h>
#include <openspace/util/powerscaledcoordinate.h>
namespace openspace {
class TargetDecoder : public Decoder {
public:
TargetDecoder(const ghoul::Dictionary& dictionary);
virtual std::string getDecoderType();
virtual std::vector<std::string> getTranslation();
private:
std::string _type;
std::vector<std::string> _names;
};
} // namespace openspace
#endif // __TARGETDECODER_H__
+1 -1
View File
@@ -14,7 +14,7 @@ dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) -- Load the default keyb
-- openspace.time.setDeltaTime(50);
openspace.time.setTime("2015-07-14T11:49:40.00") -- PLUTO
openspace.time.setTime("2015-07-14T10:10:00.00") -- PLUTO
-- NH takes series of images from visible to dark side (across terminator)
-- Sequence lasts ~10 mins, (recommended dt = 10)
@@ -61,7 +61,7 @@ namespace {
const std::string keySequenceDir = "Projection.Sequence";
const std::string keySequenceType = "Projection.SequenceType";
const std::string keyPotentialTargets = "PotentialTargets";
const std::string keyTranslation = "PlaybookTranslation";
const std::string keyTranslation = "DataInputTranslation";
@@ -93,6 +93,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _textureProj(nullptr)
, _geometry(nullptr)
, _sequenceID(-1)
, _once(false)
{
std::string name;
bool success = dictionary.getValue(constants::scenegraphnode::keyName, name);
@@ -166,6 +167,8 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
addProperty(_projectionTexturePath);
_projectionTexturePath.onChange(std::bind(&RenderablePlanetProjection::loadProjectionTexture, this));
SequenceParser* parser;
// std::string sequenceSource;
bool _foundSequence = dictionary.getValue(keySequenceDir, _sequenceSource);
if (_foundSequence) {
@@ -173,49 +176,38 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
_foundSequence = dictionary.getValue(keySequenceType, _sequenceType);
//Important: client must define translation-list in mod file IFF playbook
if (dictionary.hasKey(keyTranslation) && _sequenceType == sequenceTypePlaybook){
if (dictionary.hasKey(keyTranslation)){
ghoul::Dictionary translationDictionary;
//get translation dictionary
dictionary.getValue(keyTranslation, translationDictionary);
//get the different instrument types
const std::vector<std::string>& types = translationDictionary.keys();
//for each instrument
for (int i = 0; i < types.size(); i++){
std::string classtype = types[i];
std::string currentType = keyTranslation + "." + classtype;
//create dictionary containing all {playbookKeys , spice IDs}
ghoul::Dictionary typeDictionary;
dictionary.getValue(keyTranslation + "." + classtype, typeDictionary);
//for each playbook call -> create a Payload object
const std::vector<std::string>& keys = typeDictionary.keys();
for (int j = 0; j < keys.size(); j++){
std::string playbookKey = keys[j];
std::string currentKey = currentType + "." + playbookKey;
//using dictionary as a way to extract the spiceIDs we need
ghoul::Dictionary spiceDictionary;
dictionary.getValue(currentKey, spiceDictionary);
//create payload
Payload *payload = Payload::createFromDictionary(spiceDictionary, classtype);
//insert payload to map - this will be used in the parser to determine
//behavioral characteristics of each instrument
_fileTranslation[playbookKey] = payload;
}
if (_sequenceType == sequenceTypePlaybook){
// eeh to many inputs, bit ugly. beautify later.
parser = new HongKangParser(_sequenceSource,
"NEW HORIZONS",
translationDictionary,
_potentialTargets);
}
/*else if (_sequenceType == sequenceTypeImage){
parser = new LabelParser(_sequenceSource, translationDictionary);
}*/
}
else{
LWARNING("No playbook translation provided, please make sure all spice calls match playbook!");
}
// Have to delay playbook load in order to augment with targets once current AND spacecraft kernels loaded
for (auto p : _fileTranslation){
std::vector<std::string> k = _fileTranslation[p.first]->getSpiceIDs();
std::cout << "TYPE : " << _fileTranslation[p.first]->getType() << std::endl;
std::cout << "FILE-CALL : " << p.first << std::endl;
std::cout << "SPICE ID'S :" << std::endl;
for (auto r : k){
std::cout << r << std::endl;
}
std::cout << std::endl;
/*if (_sequenceType == sequenceTypeImage) {
LWARNING("LOADING STUFF FOR JUPITER!");
//openspace::ImageSequencer::ref().loadSequence(_sequenceSource, _sequenceID);
// SequenceParser *parser = new LabelParser(_sequenceSource,
//"NEW HORIZONS",
//_fileTranslation,
//_potentialTargets);
//openspace::ImageSequencer2::ref().runSequenceParser(parser);
}*/
/*else*/ if (_sequenceType == sequenceTypePlaybook) {
openspace::ImageSequencer2::ref().runSequenceParser(parser);
}
}
}
@@ -421,18 +413,17 @@ void RenderablePlanetProjection::render(const RenderData& data){
_up = data.camera.lookUpVector();
#ifdef GPU_PROJ
/* if (_capture){
if (_capture){
for (auto imgSubset : _imageTimes){
attitudeParameters(imgSubset.first); // projector viewmatrix
_projectionTexturePath = imgSubset.second; // path to current images
imageProjectGPU(); //fbopass
}
_capture = false;
}*/
}
#endif
attitudeParameters(_time);
_projectionTexturePath = _defaultProjImage;
_imageTimes.clear();
psc sun_pos;
double lt;
@@ -466,61 +457,13 @@ void RenderablePlanetProjection::update(const UpdateData& data){
// set spice-orientation in accordance to timestamp
_time = data.time;
_capture = false;
#ifndef ORIGINAL_SEQUENCER
static bool once;
if (Time::ref().deltaTime() > 0 && !once){
if (_foundSequence) {
if (_sequenceType == sequenceTypeImage) {
openspace::ImageSequencer::ref().loadSequence(_sequenceSource, _sequenceID);
}
else if (_sequenceType == sequenceTypePlaybook) {
SequenceParser* parser = new HongKangParser(_sequenceSource,
"NEW HORIZONS",
_fileTranslation,
_potentialTargets);
openspace::ImageSequencer2::ref().runSequenceParser(parser);
}
}
once = true;
}
if (Time::ref().deltaTime() > 10){
if (openspace::ImageSequencer2::ref().isReady()){
openspace::ImageSequencer2::ref().updateSequencer(_time);
_capture = openspace::ImageSequencer2::ref().getImagePaths(_imageTimes, _projecteeID, _instrumentID);
}
#else
//happens only once
//ImageSequencer::ref().augumentSequencesWithTargets(_sequenceID);
openspace::ImageSequencer::ref().findActiveInstrument(_time, _sequenceID);
openspace::ImageSequencer::ref().nextCaptureTime(_time, _sequenceID);
bool _withinFOV;
if (_sequenceID != -1){
std::string _fovTarget = "";
for (int i = 0; i < _potentialTargets.size(); i++){
bool success = openspace::SpiceManager::ref().targetWithinFieldOfView(
_instrumentID,
_potentialTargets[i],
_projectorID,
"ELLIPSOID",
_aberration,
_time,
_withinFOV);
if (success && _withinFOV){
_fovTarget = _potentialTargets[i];
break;
}
}
//if (_projecteeID == _fovTarget){
if (_time >= openspace::ImageSequencer::ref().getNextCaptureTime()){
openspace::ImageSequencer::ref().getImagePath(_imageTimes, _sequenceID, _projecteeID, _withinFOV);
_capture = true;
}
//}
}
#endif
}
void RenderablePlanetProjection::loadProjectionTexture(){
+23 -46
View File
@@ -104,9 +104,9 @@ namespace openspace{
}
void RenderableFov::allocateData(){
int points = 8;
int points = 10;
_stride[0] = points;
_isize[0] = points;
_isize[0] = points;
_iarray1[0] = new int[_isize[0]];
for (int i = 0; i < points; i++){
for (int j = 0; j < 4; j++){
@@ -123,7 +123,7 @@ void RenderableFov::allocateData(){
_vtotal[0] = static_cast<int>(_vsize[0] / _stride[0]);
// allocate second vbo data
int cornerPoints = 5;
int cornerPoints = 6;
_isize[1] = cornerPoints;
_iarray1[1] = new int[_isize[1]];
for (int i = 0; i < _isize[1]; i++){
@@ -213,14 +213,6 @@ void RenderableFov::insertPoint(std::vector<float>& arr, psc p, glm::vec4 c){
_nrInserted++;
}
psc RenderableFov::pscInterpolate(psc p0, psc p1, float t){
assert(t >= 0 && t <= 1);
float t2 = (1.f - t);
return PowerScaledCoordinate(t2*p0[0] + t*p1[0],
t2*p0[1] + t*p1[1],
t2*p0[2] + t*p1[2],
t2*p0[3] + t*p1[3]);
}
glm::dvec3 RenderableFov::interpolate(glm::dvec3 p0, glm::dvec3 p1, float t){
assert(t >= 0 && t <= 1);
float t2 = (1.f - t);
@@ -340,8 +332,6 @@ void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
}
}
}
// only if new points are inserted are we interested in rebuilding the
// vbo. Note that this can be optimized but is left as is for now.
if (_nrInserted == 0){
_rebuild = false;
}else{
@@ -383,20 +373,20 @@ void RenderableFov::updateData(){
}
}
void RenderableFov::computeColors(){
double t2 = openspace::ImageSequencer::ref().getNextCaptureTime();
double t2 = openspace::ImageSequencer2::ref().getNextCaptureTime();
double diff = (t2 - _time);
double t = 0.0;
if (diff <= 7.0) t = 1.f - diff / 7.0;
if (diff < 0) t = 0.0;
// i need to add an *.h file with colortables....
c_project = glm::vec4(0.0, 1.0, 0.00,1);
col_end = glm::vec4(1.00, 0.29, 0.00, 1);
blue = glm::vec4(0, 0.5, 0.7, 1);
col_gray = glm::vec4(0.3, 0.3, 0.3, 1);
col_gray = glm::vec4(0.5, 0.5, 0.5, 0.5);
col_start = glm::vec4(1.00, 0.89, 0.00, 1);
col_sq = glm::vec4(1.00, 0.29, 0.00, 1);
/*
col_end.x = c_project.x*t + col_end.x*(1 - t);
col_end.y = c_project.y*t + col_end.y*(1 - t);
col_end.z = c_project.z*t + col_end.z*(1 - t);
@@ -408,7 +398,7 @@ void RenderableFov::computeColors(){
col_sq.x = c_project.x*t + col_sq.x*(1 - t);
col_sq.y = c_project.y*t + col_sq.y*(1 - t);
col_sq.z = c_project.z*t + col_sq.z*(1 - t);
*/
blue.w = 0.5;
c_project.w = 0.5;
col_end.w = 0.5;
@@ -420,10 +410,10 @@ void RenderableFov::render(const RenderData& data){
// fetch data
glm::mat4 transform(1);
glm::mat4 tmp = glm::mat4(1);
glm::mat4 spacecraftRot = glm::mat4(1);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
tmp[i][j] = _stateMatrix[i][j];
spacecraftRot[i][j] = _stateMatrix[i][j];
}
}
@@ -431,11 +421,10 @@ void RenderableFov::render(const RenderData& data){
_programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_programObject->setUniform("ModelTransform", transform);
setPscUniforms(_programObject, &data.camera, data.position);
bool drawFOV = false;
if (Time::ref().deltaTime() > 10){
if (openspace::ImageSequencer2::ref().isReady()){
drawFOV = ImageSequencer2::ref().instumentActive(_instrumentID);
}
@@ -475,20 +464,19 @@ void RenderableFov::render(const RenderData& data){
double targetEpoch;
// for each FOV vector
for (int i = 0; i < bounds.size(); i++){
for (int i = 0; i <= bounds.size(); i++){
// compute surface intercept
int r = (i == bounds.size()) ? 0 : i;
openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
_frame, _method, _aberrationCorrection,
_time, targetEpoch, bounds[i], ipoint, ivec, _interceptTag[i]);
_time, targetEpoch, bounds[r], ipoint, ivec, _interceptTag[r]);
// if not found, use the orthogonal projected point
if (!_interceptTag[i]) _projectionBounds[i] = orthogonalProjection(bounds[i]);
if (!_interceptTag[r]) _projectionBounds[r] = orthogonalProjection(bounds[r]);
// VBO1 : draw vectors representing outer points of FOV.
if (_interceptTag[i]){
if (_interceptTag[r]){
_interceptVector = PowerScaledCoordinate::CreatePowerScaledCoordinate(ivec[0], ivec[1], ivec[2]);
_interceptVector[3] += 3;
//_interceptVector = pscInterpolate(_interceptVector, bsvec, t);
// INTERCEPTIONS
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
indx += 4;
@@ -505,14 +493,14 @@ void RenderableFov::render(const RenderData& data){
indx += 4;
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0, 0, 1, 1)), size);
indx += 4;
memcpy(&_varray1[indx], glm::value_ptr(_projectionBounds[i].vec4()), size);
memcpy(&_varray1[indx], glm::value_ptr(_projectionBounds[r].vec4()), size);
indx += 4;
memcpy(&_varray1[indx], glm::value_ptr(blue), size);
indx += 4;
}
else{
glm::vec4 corner(bounds[i][0], bounds[i][1], bounds[i][2], data.position[3] + 2);
corner = tmp*corner;
glm::vec4 corner(bounds[r][0], bounds[r][1], bounds[r][2], data.position[3] + 2);
corner = spacecraftRot*corner;
// "INFINITE" FOV
memcpy(&_varray1[indx], glm::value_ptr(glm::vec4(0)), size);
indx += 4;
@@ -524,7 +512,8 @@ void RenderableFov::render(const RenderData& data){
indx += 4;
}
}
_interceptTag[4] = _interceptTag[0]; // 0 & 5 same point
_interceptTag[4] = _interceptTag[0];
fovProjection(_interceptTag, bounds);
updateData();
}
@@ -532,7 +521,7 @@ void RenderableFov::render(const RenderData& data){
glLineWidth(_lineWidth);
glBindVertexArray(_vaoID[0]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, _vtotal[0]);
glDrawArrays(GL_LINES, 0, _vtotal[0]);
glBindVertexArray(0);
glLineWidth(_lineWidth);
@@ -540,26 +529,14 @@ void RenderableFov::render(const RenderData& data){
glDrawArrays(GL_LINES, 0, _vtotal[0]);
glBindVertexArray(0);
//render points
glPointSize(2.f);
glBindVertexArray(_vaoID[0]);
glDrawArrays(GL_POINTS, 0, _vtotal[0]);
glBindVertexArray(0);
//second vbo
if (_withinFOV){
if (drawFOV){
glLineWidth(1.f);
glBindVertexArray(_vaoID[1]);
glDrawArrays(GL_LINE_LOOP, 0, _vtotal[1]);
glBindVertexArray(0);
}
glLineWidth(1.f);
/*glPointSize(5.f);
glBindVertexArray(_vaoID2);
glDrawArrays(GL_POINTS, 0, _vtotal2);
glBindVertexArray(0);
*/
}
_programObject->deactivate();
}
+55 -36
View File
@@ -548,7 +548,7 @@ namespace openspace {
);
}
std::vector<std::string> instrVec = ImageSequencer2::ref().getActiveInstruments();
/*std::vector<std::string> instrVec = ImageSequencer2::ref().getActiveInstruments();
std::string active ="";
for (int i = 0; i < instrVec.size(); i++){
@@ -561,7 +561,7 @@ namespace openspace {
glm::vec4(0.3, 0.6, 1, 1),
"Active Instrument : %s",
active.c_str()
);
);*/
}
}
@@ -595,6 +595,7 @@ namespace openspace {
int i = 0;
PrintText(i++, "Date: %s", Time::ref().currentTimeUTC().c_str());
/*
PrintText(i++, "Avg. Frametime: %.5f", sgct::Engine::instance()->getAvgDt());
PrintText(i++, "Drawtime: %.5f", sgct::Engine::instance()->getDrawTime());
PrintText(i++, "Frametime: %.5f", sgct::Engine::instance()->getDt());
@@ -603,32 +604,28 @@ namespace openspace {
PrintText(i++, "View dir: (% .5f, % .5f, % .5f)", viewdirection[0], viewdirection[1], viewdirection[2]);
PrintText(i++, "Cam->origin: (% .15f, % .4f)", pssl[0], pssl[1]);
PrintText(i++, "Scaling: (% .5f, % .5f)", scaling[0], scaling[1]);
*/
if (openspace::ImageSequencer2::ref().isReady()){
double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - currentTime;
double t = 1.f - remaining / openspace::ImageSequencer2::ref().getIntervalLength();
std::string progress = "|";
int g = ((t)* 30) + 1;
for (int i = 0; i < g; i++) progress.append("-"); progress.append(">");
for (int i = 0; i < 31 - g; i++) progress.append(" ");
std::string str = "";
openspace::SpiceManager::ref().getDateFromET(openspace::ImageSequencer2::ref().getNextCaptureTime(), str);
double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - currentTime;
double t = 1.f - remaining / openspace::ImageSequencer::ref().getIntervalLength();
std::string progress = "|";
int g = ((t)* 20) + 1;
for (int i = 0; i < g; i++) progress.append("-"); progress.append(">");
for (int i = 0; i < 21 - g; i++) progress.append(" ");
progress.append("|");
if (remaining > 0){
glm::vec4 g1(0, t, 0, 1);
glm::vec4 g2(1 - t);
PrintColorText(i++, "Next projection in:", 10, g1 + g2);
PrintColorText(i++, "%.0f sec %s %.1f %%", 10, g1 + g2, remaining, progress.c_str(), t * 100);
}
glm::vec4 w(1);
PrintColorText(i++, "Ucoming capture : %s", 10, w, str.c_str());
std::string str = "";
openspace::SpiceManager::ref().getDateFromET(openspace::ImageSequencer::ref().getNextCaptureTime(), str);
progress.append("|");
if (remaining > 0){
glm::vec4 g1(0, t, 0, 1);
glm::vec4 g2(1 - t);
PrintColorText(i++, "Next projection in | %.0f seconds", 10, g1 + g2, remaining);
PrintColorText(i++, "%s %.1f %%", 10, g1 + g2, progress.c_str(), t * 100);
}
glm::vec4 w(1);
glm::vec4 b(0.3, 0.6, 1, 1);
glm::vec4 b2(0.5, 1, 0.5, 1);
PrintColorText(i++, "Ucoming capture : %s", 10, w, str.c_str());
if (Time::ref().deltaTime() > 10){
std::pair<double, std::string> nextTarget = ImageSequencer2::ref().getNextTarget();
std::pair<double, std::string> currentTarget = ImageSequencer2::ref().getCurrentTarget();
@@ -648,7 +645,9 @@ namespace openspace {
hh.append(std::to_string(hour));
mm.append(std::to_string(minute));
ss.append(std::to_string(second));
glm::vec4 b2(1.00, 0.51, 0.00, 1);
PrintColorText(i++, "Switching observation focus in : [%s:%s:%s]", 10, b2, hh.c_str(), mm.c_str(), ss.c_str());
std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer2::ref().getIncidentTargetList(2);
@@ -659,23 +658,43 @@ namespace openspace {
double t = (double)(p + 1) / (double)(isize+1);
t = (p > isize / 2) ? 1-t : t;
t += 0.3;
color = (p == isize / 2) ? glm::vec4(0, 1, 0, 1) : glm::vec4(t, t, t, 1);
color = (p == isize / 2) ? glm::vec4(1.00, 0.51, 0.00, 1) : glm::vec4(t, t, t, 1);
PrintColorText(i, "%s%s", 10, color, space.c_str(), incidentTargets.second[p].c_str());
for (int k = 0; k < 10; k++){ space += " "; }
}
i++;
std::vector<std::pair<std::string, bool>> instrVec = ImageSequencer2::ref().getActiveInstruments();
glm::vec4 active(0.58, 1, 0.00, 1);
glm::vec4 firing(0.58-t, 1-t, 1-t, 1);
glm::vec4 notFiring(0.5, 0.5, 0.5, 1);
double reduce = 0.01;
PrintColorText(i++, "Active Instruments : ", 10, active);
for (int k = 0; k < instrVec.size(); k++){
if (instrVec[k].second == false){
PrintColorText(i, "| |", 10, glm::vec4(0.3, 0.3, 0.3, 1));
PrintColorText(i++, " %5s", 10, glm::vec4(0.3, 0.3, 0.3, 1), instrVec[k].first.c_str());
}
else{
PrintColorText(i, "|", 10, glm::vec4(0.3, 0.3, 0.3, 1));
if (instrVec[k].first == "NH_LORRI"){
PrintColorText(i, " + ", 10, firing);
}
PrintColorText(i, " |", 10, glm::vec4(0.3, 0.3, 0.3, 1));
PrintColorText(i++, " %5s", 10, active, instrVec[k].first.c_str());
}
}
}
std::vector<std::string> instrVec = ImageSequencer2::ref().getActiveInstruments();
std::string active = "";
for (int i = 0; i < instrVec.size(); i++){
active.append(instrVec[i]);
active.append("\n");
}
PrintColorText(i++, "Active Instrument : %5s", 10, b, active.c_str());
#undef PrintText
}
@@ -22,20 +22,20 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/util/payload.h>
#include <openspace/util/decoder.h>
#include <openspace/util/factorymanager.h>
namespace {
const std::string _loggerCat = "Payload";
const std::string _loggerCat = "Decoder";
}
namespace openspace {
Payload* Payload::createFromDictionary(const ghoul::Dictionary& dictionary, const std::string type)
Decoder* Decoder::createFromDictionary(const ghoul::Dictionary& dictionary, const std::string type)
{
ghoul::TemplateFactory<Payload>* factory
= FactoryManager::ref().factory<Payload>();
Payload* result = factory->create(type, dictionary);
ghoul::TemplateFactory<Decoder>* factory
= FactoryManager::ref().factory<Decoder>();
Decoder* result = factory->create(type, dictionary);
if (result == nullptr) {
LERROR("Failed creating Payload object of type '" << type << "'");
@@ -44,15 +44,15 @@ Payload* Payload::createFromDictionary(const ghoul::Dictionary& dictionary, cons
return result;
}
Payload::Payload()
Decoder::Decoder()
{
}
Payload::Payload(const ghoul::Dictionary& dictionary)
Decoder::Decoder(const ghoul::Dictionary& dictionary)
{
}
Payload::~Payload()
Decoder::~Decoder()
{
}
+7 -6
View File
@@ -51,9 +51,9 @@
#include <openspace/rendering/planets/simplespheregeometryprojection.h>
#include <openspace/rendering/planets/planetgeometryprojection.h>
#include <openspace/util/payload.h>
#include <openspace/util/camerainstrument.h>
#include <openspace/util/scannerinstrument.h>
#include <openspace/util/decoder.h>
#include <openspace/util/instrumentdecoder.h>
#include <openspace/util/targetdecoder.h>
// std
@@ -103,9 +103,10 @@ void FactoryManager::initialize()
_manager->factory<Ephemeris>()->registerClass<StaticEphemeris>("Static");
_manager->factory<Ephemeris>()->registerClass<SpiceEphemeris>("Spice");
_manager->addFactory(new ghoul::TemplateFactory<Payload>);
_manager->factory<Payload>()->registerClass<CameraInstrument>("Camera");
_manager->factory<Payload>()->registerClass<ScannerInstrument>("Scanner");
_manager->addFactory(new ghoul::TemplateFactory<Decoder>);
_manager->factory<Decoder>()->registerClass<InstrumentDecoder>("Instrument");
_manager->factory<Decoder>()->registerClass<TargetDecoder>("Target");
// Add PlanetGeometry
_manager->addFactory(new ghoul::TemplateFactory<planetgeometry::PlanetGeometry>);
+146 -86
View File
@@ -37,19 +37,61 @@
namespace {
const std::string _loggerCat = "HongKangParser";
const std::string keyTranslation = "DataInputTranslation";
}
namespace openspace {
HongKangParser::HongKangParser(const std::string& fileName,
std::string spacecraft,
std::map<std::string, Payload*> fileTranslation,
std::vector<std::string> potentialTargets) :
_defaultCaptureImage(absPath("C:/Users/michal/openspace/openspace-data/scene/common/textures/placeholder_blank.png"))
HongKangParser::HongKangParser(const std::string& fileName,
std::string spacecraft,
ghoul::Dictionary translationDictionary,
std::vector<std::string> potentialTargets) :
_defaultCaptureImage(absPath("C:/Users/michal/openspace/openspace-data/scene/common/textures/placeholder_blank.png"))
{
_fileName = fileName;
_spacecraft = spacecraft;
_fileTranslation = fileTranslation;
_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++){
//create dictionary containing all {playbookKeys , spice IDs}
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();
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]);
//insert decoder to map - this will be used in the parser to determine
//behavioral characteristics of each instrument
_fileTranslation[keys[j]] = decoder;
}
}
//Hong's playbook needs _only_ instrument translation though.
}
}
void findPlaybookSpecifiedTarget(std::string line, std::string& target){
//remembto add this lua later...
std::vector<std::string> ptarg = { "PLUTO", "CHARON", "NIX", "HYDRA", "P5", "P4" };
for (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{
// not found - we set void until we have more info.
target = "VOID";
}
}
}
void HongKangParser::create(){
@@ -62,100 +104,110 @@ void HongKangParser::create(){
std::ifstream file(_fileName);
if (!file.good()) LERROR("Failed to open txt file '" << _fileName << "'");
std::string timestr = "";
std::string line = "";
double shutter = 0.01;
double startTime, stopTime;
// for augmentation we only need the keys in acronymDictionary as a vector
std::vector<std::string> payload;
for (auto p : _acronymDictionary)
for (auto t : p.second)
payload.push_back(t);
payload.erase(std::unique(payload.begin(), payload.end()), payload.end());
std::string previousInstrument;
std::string previousTarget;
double longExposureStart = 0;
double longExposureStop = 0;
std::string longExposureKeyword;
std::string previousCamera;
std::string previousScanner;
TimeRange cameraRange;
TimeRange scanRange;
std::vector<std::string> scannerSpiceID;
std::vector<std::string> cameraSpiceID;
double capture_start = -1;
double capture_stop = -1;
double scan_start = -1;
double scan_stop = -1;
std::string cameraTarget = "VOID";
std::string scannerTarget = "VOID";
do{
std::getline(file, timestr);
//For each instrument in acronym dictionary
for (auto it : _acronymDictionary){
// check if first col in line has keyword of interest
std::string keyword = timestr.substr(0, timestr.find_first_of(" "));
auto pos = keyword.find(it.first);
if (pos != std::string::npos){
// grab the time
std::string met = timestr.substr(24, 9);
//convert to ephemeris time
startTime = getETfromMet(met);
/*
std::string checkIfMVIC = "MVIC";
int count = 0;
bool foundStopTime = false;
if (findExactMatch("MVIC", keyword)){
std::string abortLine;
int len = file.tellg();
while (!file.eof() && !findExactMatch("ABORT", abortLine)){
std::getline(file, line);
std::string event = line.substr(0, line.find_first_of(" "));
std::getline(file, abortLine);
std::string abortCommand = abortLine.substr(0, abortLine.find_first_of(" "));
count++;
if (findExactMatch("ABORT", abortCommand)){
met = abortLine.substr(24, 9);
stopTime = getETfromMet(met);
foundStopTime = true;
}
}
file.seekg(len, std::ios_base::beg);
}else{
//assume regular shutter speed;
stopTime = startTime + shutter;
}
if (foundStopTime){
longExposureStart = startTime;
longExposureStop = stopTime;
longExposureKeyword = keyword;
}*/
// retrieve corresponding SPICE call
std::vector<std::string> instrument = it.second;
// create image
Image image;
//stoptime- quick setting for now
stopTime = startTime + 0.01;
createImage(image, startTime, stopTime, instrument, "", _defaultCaptureImage);
// add targets
augmentWithSpice(image, _spacecraft, payload, _potentialTargets);
//SKA ERSATTAS MED NAGOT ANNAT - "instrument times"
if (previousInstrument != it.first){
previousInstrument = it.first;
std::pair<double, std::string> v_time = std::make_pair(image.startTime, keyword);
_instrumentTimes.push_back(v_time);
auto it = _fileTranslation.find(event);
bool foundEvent = (it != _fileTranslation.end());
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);
if (it->second->getDecoderType() == "CAMERA"){
if (capture_start == -1){
//encountered new camera sequence- store start time
capture_start = time;
previousCamera = it->first;
}
//always store individual image for camera
cameraSpiceID = it->second->getTranslation();
//rely on playboook mdl column to determine target
findPlaybookSpecifiedTarget(line, cameraTarget);
//fill image
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;
std::pair<double, std::string> v_target = std::make_pair(image.startTime, image.target);
std::pair<double, std::string> v_target = std::make_pair(time, image.target);
_targetTimes.push_back(v_target);
}
//_subsetMap[image.target]._subset[keyword].push_back(image);
//store actual image in map. All targets get _only_ their corresp. subset.
_subsetMap[image.target]._subset.push_back(image);
_subsetMap[image.target]._range.setRange(image.startTime);
//compute and store the range for each subset
_subsetMap[image.target]._range.setRange(time);
}
if (scan_start == -1 && it->second->getDecoderType() == "SCANNER"){
//scanner works like state-machine -only store start time now
scan_start = time;
previousScanner = it->first;
//store scanning instrument - store image once stopTime is found!
findPlaybookSpecifiedTarget(line, scannerTarget);
scannerSpiceID = it->second->getTranslation();
}
}
else{ // we have reached the end of a scan or consecutive capture sequence!
if (capture_start != -1){
//end of capture sequence for camera, store end time of this sequence
capture_stop = time;
cameraRange._min = capture_start;
cameraRange._max = capture_stop;
_instrumentTimes.push_back(std::make_pair(previousCamera, cameraRange));
capture_start = -1;
}
if (line.find("END_NOM") != std::string::npos){
assert(scan_start != -1, "SCAN end occured before SCAN call!");
//end of scan, store end time of this scan + store the scan image
scan_stop = time;
scanRange._min = scan_start;
scanRange._max = scan_stop;
_instrumentTimes.push_back(std::make_pair(previousScanner, scanRange));
//store individual image
createImage(image, scan_start, scan_stop, scannerSpiceID, scannerTarget, _defaultCaptureImage);
_subsetMap[image.target]._subset.push_back(image);
_subsetMap[image.target]._range.setRange(scan_start);
scan_start = -1;
}
}
} while (!file.eof());
}
}
}
//PRINT TO FILE FUNCTION
std::ofstream myfile;
myfile.open("HongKangOutput.txt");
@@ -167,10 +219,14 @@ void HongKangParser::create(){
myfile << std::endl;
for (auto image : target.second._subset){
std::string time;
SpiceManager::ref().getDateFromET(image.startTime, time);
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
<< std::setw(10) << time
<< std::setw(10) << time_beg
<< std::setw(10) << time_end
<< std::setw(10) << (int)getMetFromET(image.startTime)
<< std::setw(10) << image.target << std::setw(10);
for (auto instrument : image.activeInstruments){
@@ -180,6 +236,7 @@ void HongKangParser::create(){
}
}
myfile.close();
}
bool HongKangParser::augmentWithSpice(Image& image,
@@ -227,9 +284,9 @@ void HongKangParser::createImage(Image& image, double startTime, double stopTime
image.projected = false;
}
double HongKangParser::getETfromMet(std::string timestr){
double HongKangParser::getETfromMet(std::string line){
std::string::size_type sz;
return getETfromMet(std::stod(timestr, &sz));
return getETfromMet(std::stod(line, &sz));
}
double HongKangParser::getETfromMet(double met){
@@ -256,8 +313,7 @@ double HongKangParser::getMetFromET(double et){
if (et >= referenceET){
met = _metRef + (et - referenceET);
}
else{
}else{
met = _metRef - (referenceET - et);
}
@@ -267,10 +323,14 @@ double HongKangParser::getMetFromET(double et){
std::map<std::string, ImageSubset> HongKangParser::getSubsetMap(){
return _subsetMap;
}
std::vector<std::pair<double, std::string>> HongKangParser::getIstrumentTimes(){
std::vector<std::pair<std::string, TimeRange>> HongKangParser::getIstrumentTimes(){
return _instrumentTimes;
}
std::vector<std::pair<double, std::string>> HongKangParser::getTargetTimes(){
return _targetTimes;
}
std::vector<double> HongKangParser::getCaptureProgression(){
return _captureProgression;
};
}
-1
View File
@@ -140,7 +140,6 @@ void createImage(std::vector<ImageParams>& vec, double t1, std::string instrumen
image.projected = false;
vec.push_back(image);
// sort
}
double ImageSequencer::getNextCaptureTime(){
+105 -177
View File
@@ -45,6 +45,7 @@ namespace openspace {
ImageSequencer2* ImageSequencer2::_instance = nullptr;
ImageSequencer2::ImageSequencer2() :
_hasData(false),
_defaultCaptureImage(absPath("C:/Users/michal/openspace/openspace-data/scene/common/textures/placeholder_blank.png"))
{}
@@ -62,10 +63,10 @@ void ImageSequencer2::deinitialize() {
delete _instance;
_instance = nullptr;
}
/*
auto cmp = [](const Image &a, const Image &b)->bool{
return a.startTime < b.startTime;
};*/
bool ImageSequencer2::isReady(){
return _hasData;
}
bool ImageSequencer2::imageComparer(const Image &a, const Image &b){
return a.startTime < b.startTime;
@@ -77,7 +78,7 @@ std::vector<Image>::iterator ImageSequencer2::binary_find(std::vector<Image>::it
bool(*compareFunc)(const Image &a, const Image &b)){
// Finds the lower bound in at most log(last - first) + 1 comparisons
std::vector<Image>::iterator it = std::lower_bound(begin, end, val, compareFunc);
if (it != begin){
if (it != begin && it != end){
return it;
}
return end;
@@ -144,192 +145,119 @@ std::pair<double, std::vector<std::string>> ImageSequencer2::getIncidentTargetLi
return incidentTargets;
}
std::vector<std::string> ImageSequencer2::getActiveInstruments(){
return _currentlyActiveInstruments;
double ImageSequencer2::getIntervalLength(){
double upcoming = getNextCaptureTime();
if (_nextCapture != upcoming){
_nextCapture = upcoming;
_intervalLength = upcoming - _currentTime;
}
return _intervalLength;
}
double ImageSequencer2::getNextCaptureTime(){
auto compareTime = [](const double &a, const double &b)->bool{
return a < b;
};
double nextCaptureTime = 0;
auto it = std::lower_bound(_captureProgression.begin(), _captureProgression.end(), _currentTime, compareTime);
if (it != _captureProgression.end())
nextCaptureTime = *it;
return nextCaptureTime;
}
std::vector<std::pair<std::string, bool>> ImageSequencer2::getActiveInstruments(){
for (int i = 0; i < _instrumentOnOff.size(); i++){
_instrumentOnOff[i].second = false;
}
for (auto key : _fileTranslation){
for (auto instrumentID : key.second->getTranslation()){
if (instumentActive(instrumentID)){
for (int i = 0; i < _instrumentOnOff.size(); i++){
if (instrumentID == _instrumentOnOff[i].first){
_instrumentOnOff[i].second = true;
}
}
}
}
}
return _instrumentOnOff;
}
bool ImageSequencer2::instumentActive(std::string instrumentID){
// make into template func
auto compareTime = [](const std::pair<double, std::string> &a,
const std::pair<double, std::string> &b)->bool{
return a.first < b.first;
};
std::pair<double, std::string> findEqualToThis;
findEqualToThis.first = _currentTime;
auto it = std::lower_bound(_instrumentTimes.begin(), _instrumentTimes.end(), findEqualToThis, compareTime);
it = std::prev(it);
if (it != _instrumentTimes.end()){
std::string key = it->second;
std::vector<std::string> instruments = _acronymDictionary[key];
for (auto i : instruments){
if (i == instrumentID){
_currentlyActiveInstruments = instruments;
return true;
for (auto i : _instrumentTimes){
//check if this instrument is in range
if (i.second.inRange(_currentTime)){
//if so, then get the corresponding spiceIDs
std::vector < std::string> spiceIDs = _fileTranslation[i.first]->getTranslation();
//check which specific subinstrument is firing
for (auto s : spiceIDs){
if (s == instrumentID){
return true;
}
}
}
}
return false;
}
double ImageSequencer2::getNextCaptureTime(){
// to do this we need getCurrentTarget to ALWAYS work!
return 0.0;
bool ImageSequencer2::getImagePaths(std::vector<std::pair<double, std::string>>& captures, std::string projectee, std::string instrumentID){
if (!instumentActive(instrumentID) && !Time::ref().timeJumped()) return false;
return (instrumentID == "NH_LORRI") ? getImagePaths(captures, projectee) : false;
}
bool ImageSequencer2::getImagePaths(std::vector<std::pair<double, std::string>>& captures,
std::string projectee){
if (_subsetMap[projectee]._range.inRange(_currentTime) ||
_subsetMap[projectee]._range.inRange(_previousTime)){
auto compareTime = [](const Image &a,
const Image &b)->bool{
return a.startTime < b.startTime;
};
auto begin = _subsetMap[projectee]._subset.begin();
auto end = _subsetMap[projectee]._subset.end();
std::vector<std::pair<double, std::string>> captureTimes;
Image findPrevious;
findPrevious.startTime = _previousTime;
Image findCurrent;
findCurrent.startTime = _currentTime;
auto curr = std::lower_bound(begin, end, findCurrent, compareTime);
auto prev = std::lower_bound(begin, end, findPrevious, compareTime);
if (curr != begin && curr != end && prev != begin && prev != end){
std::transform(prev, curr, std::back_inserter(captureTimes),
[](const Image& i) {
return std::make_pair(i.startTime, i.path);
});
std::reverse(captureTimes.begin(), captureTimes.end());
captures = captureTimes;
return true;
}
}
return false;
}
void ImageSequencer2::runSequenceParser(SequenceParser* parser){
parser->create();
_fileTranslation = parser->getTranslation(); // should perhaps be named 'instrumentTranslation'
_subsetMap = parser->getSubsetMap();
_instrumentTimes = parser->getIstrumentTimes();
_targetTimes = parser->getTargetTimes();
_captureProgression = parser->getCaptureProgression();
_subsetMap = parser->getSubsetMap();
_instrumentTimes = parser->getIstrumentTimes();
//_targetTimes = parser->getTargetTimes();
_acronymDictionary = parser->getAcronymDictionary();
}
/*
bool ImageSequencer2::parsePlaybookFile(const std::string& fileName,
std::string spacecraft,
std::map<std::string, std::vector<std::string>> acronymDictionary,
std::vector<std::string> potentialTargets) {
_acronymDictionary = acronymDictionary;
if (size_t position = fileName.find_last_of(".") + 1){
if (position != std::string::npos){
std::string extension = ghoul::filesystem::File(fileName).fileExtension();
if (extension == "txt"){// Hong Kang. pre-parsed playbook
LINFO("Using Preparsed Playbook V9H");
std::ifstream file(fileName);
if (!file.good()) LERROR("Failed to open txt file '" << fileName << "'");
std::string timestr = "";
double shutter = 0.01;
double startTime, stopTime;
// for augmentation we only need the keys in acronymDictionary as a vector
std::vector<std::string> payload;
for (auto p : acronymDictionary)
for (auto t : p.second)
payload.push_back(t);
payload.erase(std::unique(payload.begin(), payload.end()), payload.end());
std::string previousInstrument;
std::string previousTarget;
double longExposureStart = 0;
double longExposureStop = 0;
std::string longExposureKeyword;
do{
std::getline(file, timestr);
//For each instrument in acronym dictionary
for (auto it : _acronymDictionary){
// check if first col in line has keyword of interest
std::string keyword = timestr.substr(0, timestr.find_first_of(" "));
auto pos = keyword.find(it.first);
if (pos != std::string::npos){
// grab the time
std::string met = timestr.substr(24, 9);
//convert to ephemeris time
startTime = getETfromMet(met);
//std::string checkIfMVIC = "MVIC";
//int count = 0;
//bool foundStopTime = false;
//if (findExactMatch("MVIC", keyword)){
// std::string abortLine;
// int len = file.tellg();
// while (!file.eof() && !findExactMatch("ABORT", abortLine)){
//
// std::getline(file, abortLine);
// std::string abortCommand = abortLine.substr(0, abortLine.find_first_of(" "));
// count++;
// if (findExactMatch("ABORT", abortCommand)){
// met = abortLine.substr(24, 9);
// stopTime = getETfromMet(met);
// foundStopTime = true;
// }
// }
// file.seekg(len, std::ios_base::beg);
//}else{
// //assume regular shutter speed;
// stopTime = startTime + shutter;
//}
//
//if (foundStopTime){
// longExposureStart = startTime;
// longExposureStop = stopTime;
// longExposureKeyword = keyword;
//}
// retrieve corresponding SPICE call
std::vector<std::string> instrument = it.second;
// create image
Image image;
//stoptime- quick setting for now
stopTime = startTime + 0.01;
createImage(image, startTime, stopTime, instrument, "", _defaultCaptureImage);
// add targets
augmentWithSpice(image, spacecraft, payload, potentialTargets);
//SKA ERSATTAS MED NAGOT ANNAT - "instrument times"
if (previousInstrument != it.first){
previousInstrument = it.first;
std::pair<double, std::string> v_time = std::make_pair(image.startTime, keyword);
_instrumentTimes.push_back(v_time);
}
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);
}
//_subsetMap[image.target]._subset[keyword].push_back(image);
_subsetMap[image.target]._subset.push_back(image);
_subsetMap[image.target]._range.setRange(image.startTime);
}
}
} while (!file.eof());
}
//copy payload from _fileTranslation
for (auto t : _fileTranslation){
std::vector<std::string> spiceIDs = t.second->getTranslation();
for (auto id : spiceIDs){
_instrumentOnOff.push_back(std::make_pair(id, false));
}
}
_instrumentOnOff.erase(std::unique(_instrumentOnOff.begin(),
_instrumentOnOff.end()),
_instrumentOnOff.end());
_hasData = true;
//PRINT FUNCTION
std::string st1 = "2015-07-14T10:00:00.00";
std::string st2 = "2015-07-14T12:00:00.00";
double start, stop;
SpiceManager::ref().getETfromDate(st1, start);
SpiceManager::ref().getETfromDate(st2, stop);
std::ofstream myfile;
myfile.open("augmentedPef.txt");
//print all
for (auto target : _subsetMap){
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;
SpiceManager::ref().getDateFromET(image.startTime, time);
myfile << std::fixed
<< std::setw(10) << time
<< std::setw(10) << (int)getMetFromET(image.startTime)
<< std::setw(10) << image.target << std::setw(10);
for (auto instrument : image.activeInstruments){
myfile << " " << instrument;
}
myfile << std::endl;
}
}
myfile.close();
return true;
}
*/
} // namespace openspace
+63
View File
@@ -0,0 +1,63 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* 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 <openspace/util/instrumentdecoder.h>
namespace {
const std::string _loggerCat = "InstrumentDecoder";
const std::string keyDetector = "DetectorType";
const std::string keySpice = "Spice";
}
namespace openspace {
InstrumentDecoder::InstrumentDecoder(const ghoul::Dictionary& dictionary)
{
bool success = dictionary.getValue(keyDetector, _type);
ghoul_assert(success, "Instrument has not provided detector type");
for_each(_type.begin(), _type.end(), [](char& in){ in = ::toupper(in); });
std::vector<std::string> spice;
ghoul::Dictionary spiceDictionary;
success = dictionary.getValue(keySpice, spiceDictionary);
ghoul_assert(success, "Instrument did not provide spice ids");
_spiceIDs.resize(spiceDictionary.size());
for (int i = 0; i < _spiceIDs.size(); ++i) {
std::string id;
spiceDictionary.getValue(std::to_string(i + 1), id);
_spiceIDs[i] = id;
}
}
std::string InstrumentDecoder::getDecoderType(){
return _type;
}
std::vector<std::string> InstrumentDecoder::getTranslation(){
return _spiceIDs;
}
} // namespace openspace
+185
View File
@@ -0,0 +1,185 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* 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 <openspace/util/ImageSequencer2.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 <openspace/util/labelparser.h>
namespace {
const std::string _loggerCat = "LabelParser";
const std::string keySpecs = "Read";
const std::string keyConvert = "Convert";
}
namespace openspace {
LabelParser::LabelParser(const std::string& fileName,
ghoul::Dictionary translationDictionary)
{
_fileName = fileName;
//_fileTranslation = fileTranslation;
//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];
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);
_specsOfInterest.resize(specsOfInterestDictionary.size());
for (int i = 0; i < _specsOfInterest.size(); ++i) {
std::string readMe;
specsOfInterestDictionary.getValue(std::to_string(i + 1), readMe);
_specsOfInterest[i] = 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;
};
}
}
for (auto t : _fileTranslation){
std::cout << t.first << std::endl;
for (auto b : t.second->getTranslation()){
std::cout << " " << b << std::endl;
}
}
}
void LabelParser::create(){
std::vector<Image> tmp;
ghoul::filesystem::Directory sequenceDir(_fileName, true);
std::vector<std::string> sequencePaths = sequenceDir.read(true, false); // check inputs
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"){ // discovered header file
std::ifstream file(currentFile.path());
if (!file.good()) LERROR("Failed to open label file '" << currentFile.path() << "'");
// open up label files
std::string line = "";
double timestamp = 0.0;
bool found = false;
do {
std::getline(file, line);
for (auto spec : _specsOfInterest){
auto pos = line.find(spec);
if (pos != std::string::npos){
if (line.substr(0, line.find_first_of(" ")) == "TARGET_NAME"){
/* std::string target = line.substr(line.find("=") + 2, line.find(" "));
target.erase(std::remove(target.begin(), target.end(), '"'), target.end());
for (auto t : _fileTranslation[target]->getTranslation()){
std::cout << t << std::endl;
}*/
}
}
/*if (timestamp != 0.0){
found = true;
std::string ext = "jpg";
path.replace(path.begin() + position, path.end(), ext);
bool fileExists = FileSys.fileExists(path);
if (fileExists) {
// createImage(tmp, timestamp, "NH_LORRI", "", path); /// fix active instrument!
// std::sort(tmp.begin(), tmp.end(), imageComparer);
}
}*/
}
} while (!file.eof() && found == false);
}
}
}
}
int pause;
std::cin >> pause;
}
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;
}
std::map<std::string, ImageSubset> LabelParser::getSubsetMap(){
return _subsetMap;
}
std::vector<std::pair<std::string, TimeRange>> LabelParser::getIstrumentTimes(){
return _instrumentTimes;
}
std::vector<std::pair<double, std::string>> LabelParser::getTargetTimes(){
return _targetTimes;
}
}
@@ -22,15 +22,15 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/util/camerainstrument.h>
#include <openspace/util/scannerdecoder.h>
namespace {
const std::string _loggerCat = "CameraInstrument";
const std::string _loggerCat = "ScannerDecoder";
}
namespace openspace {
CameraInstrument::CameraInstrument(const ghoul::Dictionary& dictionary) :_type("CAMERA")
ScannerDecoder::ScannerDecoder(const ghoul::Dictionary& dictionary) : _type("SCANNER")
{
std::string value;
for (int k = 0; k < dictionary.size(); k++){
@@ -38,12 +38,11 @@ CameraInstrument::CameraInstrument(const ghoul::Dictionary& dictionary) :_type("
_spiceIDs.push_back(value);
}
}
std::string CameraInstrument::getType(){
std::string ScannerDecoder::getDecoderType(){
return _type;
}
std::vector<std::string> CameraInstrument::getSpiceIDs(){
std::vector<std::string> ScannerDecoder::getSpiceIDs(){
return _spiceIDs;
}
@@ -22,28 +22,30 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/util/scannerinstrument.h>
#include <openspace/util/targetdecoder.h>
namespace {
const std::string _loggerCat = "ScannerInstrument";
const std::string _loggerCat = "TargetDecoder";
}
namespace openspace {
ScannerInstrument::ScannerInstrument(const ghoul::Dictionary& dictionary) : _type("SCANNER")
TargetDecoder::TargetDecoder(const ghoul::Dictionary& dictionary) :_type("TARGET")
{
std::string value;
for (int k = 0; k < dictionary.size(); k++){
dictionary.getValue(std::to_string(k + 1), value);
_spiceIDs.push_back(value);
_names.resize(dictionary.size());
for (int i = 0; i < _names.size(); ++i) {
std::string readMe;
dictionary.getValue(std::to_string(i + 1), readMe);
_names[i] = readMe;
}
}
std::string ScannerInstrument::getType(){
std::string TargetDecoder::getDecoderType(){
return _type;
}
std::vector<std::string> ScannerInstrument::getSpiceIDs(){
return _spiceIDs;
std::vector<std::string> TargetDecoder::getTranslation(){
return _names;
}
} // namespace openspace