mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-23 05:19:18 -06:00
Fixes to prevent crashes when data is not available
This commit is contained in:
@@ -231,7 +231,8 @@ bool RenderablePlanetProjection::initialize() {
|
||||
|
||||
completeSuccess &= _geometry->initialize(this);
|
||||
|
||||
completeSuccess &= auxiliaryRendertarget();
|
||||
if (completeSuccess)
|
||||
completeSuccess &= auxiliaryRendertarget();
|
||||
|
||||
return completeSuccess;
|
||||
}
|
||||
@@ -289,7 +290,7 @@ bool RenderablePlanetProjection::deinitialize(){
|
||||
return true;
|
||||
}
|
||||
bool RenderablePlanetProjection::isReady() const {
|
||||
return _geometry && _programObject;
|
||||
return _geometry && _programObject && _texture && _textureWhiteSquare;
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::imageProjectGPU(){
|
||||
@@ -414,7 +415,7 @@ void RenderablePlanetProjection::attitudeParameters(double time){
|
||||
}
|
||||
|
||||
|
||||
void RenderablePlanetProjection::textureBind(){
|
||||
void RenderablePlanetProjection::textureBind() {
|
||||
ghoul::opengl::TextureUnit unit[2];
|
||||
unit[0].activate();
|
||||
_texture->bind();
|
||||
@@ -424,7 +425,7 @@ void RenderablePlanetProjection::textureBind(){
|
||||
_programObject->setUniform("texture2", unit[1]);
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::project(){
|
||||
void RenderablePlanetProjection::project() {
|
||||
for (auto img : _imageTimes){
|
||||
std::thread t1(&RenderablePlanetProjection::attitudeParameters, this, img.startTime);
|
||||
t1.join();
|
||||
@@ -484,7 +485,7 @@ void RenderablePlanetProjection::render(const RenderData& data){
|
||||
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::update(const UpdateData& data){
|
||||
void RenderablePlanetProjection::update(const UpdateData& data) {
|
||||
// set spice-orientation in accordance to timestamp
|
||||
_time = Time::ref().currentTime();
|
||||
_capture = false;
|
||||
@@ -498,7 +499,7 @@ void RenderablePlanetProjection::update(const UpdateData& data){
|
||||
_programObject->rebuildFromFile();
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::loadProjectionTexture(){
|
||||
void RenderablePlanetProjection::loadProjectionTexture() {
|
||||
delete _textureProj;
|
||||
_textureProj = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
@@ -513,7 +514,7 @@ void RenderablePlanetProjection::loadProjectionTexture(){
|
||||
}
|
||||
}
|
||||
|
||||
void RenderablePlanetProjection::loadTexture(){
|
||||
void RenderablePlanetProjection::loadTexture() {
|
||||
delete _texture;
|
||||
_texture = nullptr;
|
||||
if (_colorTexturePath.value() != "") {
|
||||
|
||||
@@ -98,12 +98,12 @@ void findPlaybookSpecifiedTarget(std::string line, std::string& target){
|
||||
}
|
||||
}
|
||||
|
||||
void HongKangParser::create(){
|
||||
bool HongKangParser::create(){
|
||||
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
|
||||
if (extension == "txt") {// Hong Kang. pre-parsed playbook
|
||||
LINFO("Using Preparsed Playbook V9H");
|
||||
std::ifstream file(_fileName , std::ios::binary);
|
||||
if (!file.good()) LERROR("Failed to open txt file '" << _fileName << "'");
|
||||
@@ -130,8 +130,8 @@ void HongKangParser::create(){
|
||||
std::string cameraTarget = "VOID";
|
||||
std::string scannerTarget = "VOID";
|
||||
|
||||
while (!file.eof()){//only while inte do, FIX
|
||||
std::getline(file, line);
|
||||
while (std::getline(file, line)) {//only while inte do, FIX
|
||||
//std::getline(file, line);
|
||||
|
||||
std::string event = line.substr(0, line.find_first_of(" "));
|
||||
|
||||
@@ -249,36 +249,7 @@ void HongKangParser::create(){
|
||||
}
|
||||
|
||||
sendPlaybookInformation(PlaybookIdentifierName);
|
||||
|
||||
//std::ofstream myfile;
|
||||
//myfile.open("HongKangOutput.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_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_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){
|
||||
// myfile << " " << instrument;
|
||||
// }
|
||||
// myfile << std::endl;
|
||||
// }
|
||||
//}
|
||||
//myfile.close();
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HongKangParser::augmentWithSpice(Image& image,
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
std::string spacecraft,
|
||||
ghoul::Dictionary dictionary,
|
||||
std::vector<std::string> potentialTargets);
|
||||
virtual void create();
|
||||
bool create() override;
|
||||
|
||||
// temporary need to figure this out
|
||||
virtual std::map<std::string, Decoder*> getTranslation(){ return _fileTranslation; };
|
||||
|
||||
@@ -297,35 +297,31 @@ void ImageSequencer2::sortData(){
|
||||
}
|
||||
|
||||
void ImageSequencer2::runSequenceParser(SequenceParser* parser){
|
||||
parser->create();
|
||||
bool success = parser->create();
|
||||
if (!success)
|
||||
return;
|
||||
// get new data
|
||||
std::map<std::string, Decoder*> in1 = parser->getTranslation();
|
||||
std::map<std::string, ImageSubset> in2 = parser->getSubsetMap();
|
||||
std::vector<std::pair<std::string, TimeRange>> in3 = parser->getIstrumentTimes();
|
||||
std::vector<std::pair<double, std::string>> in4 = parser->getTargetTimes();
|
||||
std::vector<double> in5 = parser->getCaptureProgression();
|
||||
std::map<std::string, Decoder*> translations = parser->getTranslation();
|
||||
std::map<std::string, ImageSubset> imageData = parser->getSubsetMap();
|
||||
std::vector<std::pair<std::string, TimeRange>> instrumentTimes = parser->getIstrumentTimes();
|
||||
std::vector<std::pair<double, std::string>> targetTimes = parser->getTargetTimes();
|
||||
std::vector<double> captureProgression = parser->getCaptureProgression();
|
||||
|
||||
// check for sanity
|
||||
// TODO: This cannot crash the program! ---abock
|
||||
ghoul_assert(in1.size() > 0, "Sequencer failed to load Translation" );
|
||||
ghoul_assert(in2.size() > 0, "Sequencer failed to load Image data" );
|
||||
ghoul_assert(in3.size() > 0, "Sequencer failed to load Instrument Switching schedule");
|
||||
ghoul_assert(in4.size() > 0, "Sequencer failed to load Target Switching schedule" );
|
||||
ghoul_assert(in5.size() > 0, "Sequencer failed to load Capture progression" );
|
||||
if (translations.empty() || imageData.empty() || instrumentTimes.empty() || targetTimes.empty() || captureProgression.empty())
|
||||
return;
|
||||
|
||||
|
||||
// append data
|
||||
_fileTranslation.insert ( in1.begin(), in1.end());
|
||||
_subsetMap.insert ( in2.begin(), in2.end());
|
||||
_instrumentTimes.insert ( _instrumentTimes.end(), in3.begin(), in3.end());
|
||||
_targetTimes.insert ( _targetTimes.end(), in4.begin(), in4.end());
|
||||
_captureProgression.insert(_captureProgression.end(), in5.begin(), in5.end());
|
||||
_fileTranslation.insert(translations.begin(), translations.end());
|
||||
_subsetMap.insert(imageData.begin(), imageData.end());
|
||||
_instrumentTimes.insert(_instrumentTimes.end(), instrumentTimes.begin(), instrumentTimes.end());
|
||||
_targetTimes.insert(_targetTimes.end(), targetTimes.begin(), targetTimes.end());
|
||||
_captureProgression.insert(_captureProgression.end(), captureProgression.begin(), captureProgression.end());
|
||||
|
||||
// sorting of data _not_ optional
|
||||
sortData();
|
||||
|
||||
// extract payload from _fileTranslation
|
||||
for (auto t : _fileTranslation){
|
||||
for (auto t : _fileTranslation) {
|
||||
if (t.second->getDecoderType() == "CAMERA" ||
|
||||
t.second->getDecoderType() == "SCANNER" ){
|
||||
std::vector<std::string> spiceIDs = t.second->getTranslation();
|
||||
@@ -336,4 +332,5 @@ void ImageSequencer2::runSequenceParser(SequenceParser* parser){
|
||||
}
|
||||
_hasData = true;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -118,7 +118,7 @@ std::string LabelParser::encode(std::string line) {
|
||||
return "";
|
||||
}
|
||||
|
||||
void LabelParser::create(){
|
||||
bool LabelParser::create() {
|
||||
auto imageComparer = [](const Image &a, const Image &b)->bool{
|
||||
return a.startTime < b.startTime;
|
||||
};
|
||||
@@ -132,7 +132,7 @@ void LabelParser::create(){
|
||||
ghoul::filesystem::Directory sequenceDir(_fileName, true);
|
||||
if (!FileSys.directoryExists(sequenceDir)) {
|
||||
LERROR("Could not load Label Directory '" << sequenceDir.path() << "'");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> sequencePaths = sequenceDir.read(true, false); // check inputs
|
||||
for (auto path : sequencePaths){
|
||||
@@ -255,6 +255,7 @@ void LabelParser::create(){
|
||||
////print all
|
||||
for (auto target : _subsetMap){
|
||||
_instrumentTimes.push_back(std::make_pair(lblName, _subsetMap[target.first]._range));
|
||||
|
||||
// std::string min, max;
|
||||
// SpiceManager::ref().getDateFromET(target.second._range._min, min);
|
||||
// SpiceManager::ref().getDateFromET(target.second._range._max, max);
|
||||
@@ -281,6 +282,7 @@ void LabelParser::create(){
|
||||
|
||||
sendPlaybookInformation(PlaybookIdentifierName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void LabelParser::createImage(Image& image, double startTime, double stopTime, std::vector<std::string> instr, std::string targ, std::string pot) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
LabelParser();
|
||||
LabelParser(const std::string& fileName,
|
||||
ghoul::Dictionary translationDictionary);
|
||||
virtual void create();
|
||||
bool create() override;
|
||||
|
||||
// temporary need to figure this out
|
||||
std::map<std::string, Decoder*> getTranslation(){ return _fileTranslation; };
|
||||
|
||||
@@ -67,7 +67,7 @@ struct ImageSubset {
|
||||
|
||||
class SequenceParser {
|
||||
public:
|
||||
virtual void create() = 0;
|
||||
virtual bool create() = 0;
|
||||
virtual std::map<std::string, ImageSubset> getSubsetMap() final;
|
||||
virtual std::vector<std::pair<std::string, TimeRange>> getIstrumentTimes() final;
|
||||
virtual std::vector<std::pair<double, std::string>> getTargetTimes() final;
|
||||
|
||||
@@ -87,10 +87,4 @@ bool ABufferFramebuffer::initializeABuffer() {
|
||||
_resolveShader->setProgramObjectCallback(shaderCallback);
|
||||
}
|
||||
|
||||
void ABufferFramebuffer::resolve()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // openspace
|
||||
} // openspace
|
||||
|
||||
Reference in New Issue
Block a user