mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 03:00:58 -06:00
Storing frame-to-body relationship
Store frames for bodies in SpiceManager, still adding "IAU_" if no frame is added for the body. Adding frames in renderableModel for 67p to get proper inertial frame.
This commit is contained in:
@@ -630,6 +630,22 @@ public:
|
||||
*/
|
||||
bool getFieldOfView(int instrument, std::string& fovShape, std::string& frameName,
|
||||
glm::dvec3& boresightVector, std::vector<glm::dvec3>& bounds) const;
|
||||
|
||||
/**
|
||||
* This function adds a frame to a body
|
||||
* \param body - the name of the body
|
||||
* \param frame - the name of the frame
|
||||
* \return false if the arguments are empty
|
||||
*/
|
||||
bool addFrame(const std::string body, const std::string frame);
|
||||
|
||||
/**
|
||||
* This function returns the frame of a body if defined, otherwise it returns
|
||||
* IAU_ + body (most frames are known by the International Astronomical Union)
|
||||
* \param body - the name of the body
|
||||
* \return the frame of the body
|
||||
*/
|
||||
std::string frameFromBody(const std::string body) const;
|
||||
|
||||
/**
|
||||
* This method checks if one of the previous SPICE methods has failed. If it has, the
|
||||
@@ -673,6 +689,8 @@ private:
|
||||
std::map<int, std::vector< std::pair<double, double> > > _spkIntervals;
|
||||
std::map<int, std::set<double> > _ckCoverageTimes;
|
||||
std::map<int, std::set<double> > _spkCoverageTimes;
|
||||
// Vector of pairs: Body, Frame
|
||||
std::vector< std::pair<std::string, std::string> > _frameByBody;
|
||||
|
||||
const static bool _showErrors = false;
|
||||
|
||||
|
||||
@@ -96,6 +96,8 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
dictionary.getValue(keyDestination, _destination);
|
||||
dictionary.getValue(keyBody, _target);
|
||||
|
||||
openspace::SpiceManager::ref().addFrame(_target, _source);
|
||||
|
||||
setBoundingSphere(pss(1.f, 9.f));
|
||||
addProperty(_performShading);
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ void RenderablePlaneProjection::setTarget(std::string body) {
|
||||
}
|
||||
if (found) {
|
||||
_target.body = body;
|
||||
_target.frame = "IAU_" + body;
|
||||
_target.frame = openspace::SpiceManager::ref().frameFromBody(body);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -641,13 +641,12 @@ bool SpiceManager::targetWithinFieldOfView(const std::string& instrument,
|
||||
|
||||
int visible;
|
||||
|
||||
std::string bodyfixed = "IAU_";
|
||||
bodyfixed += target;
|
||||
std::string frame = frameFromBody(target);
|
||||
|
||||
fovtrg_c(instrument.c_str(),
|
||||
target.c_str(),
|
||||
method.c_str(),
|
||||
bodyfixed.c_str(),
|
||||
frame.c_str(),
|
||||
aberrationCorrection.c_str(),
|
||||
observer.c_str(),
|
||||
&targetEpoch,
|
||||
@@ -688,9 +687,9 @@ bool SpiceManager::getSurfaceIntercept(const std::string& target,
|
||||
// allow client specify non-inertial frame.
|
||||
std::string bodyfixed = "IAU_";
|
||||
convert = (referenceFrame.find(bodyfixed) == std::string::npos);
|
||||
if (convert){
|
||||
bodyfixed += target;
|
||||
}else{
|
||||
if (convert) {
|
||||
bodyfixed = frameFromBody(target);
|
||||
} else {
|
||||
bodyfixed = referenceFrame;
|
||||
}
|
||||
|
||||
@@ -813,11 +812,11 @@ bool SpiceManager::getPositionTransformMatrix(const std::string& fromFrame,
|
||||
ephemerisTime, (double(*)[3])glm::value_ptr(positionMatrix));
|
||||
|
||||
success = !(failed_c());
|
||||
if (!success && !_showErrors) {
|
||||
if (!success) {
|
||||
reset_c();
|
||||
estimated = getEstimatedTransformMatrix(ephemerisTime, fromFrame, toFrame, positionMatrix);
|
||||
}
|
||||
else {
|
||||
if (_showErrors) {
|
||||
bool hasError = checkForError("Error retrieving position transform matrix from "
|
||||
"frame '" + fromFrame + "' to frame '" + toFrame +
|
||||
"' at time '" + std::to_string(ephemerisTime));
|
||||
@@ -958,6 +957,34 @@ bool SpiceManager::getFieldOfView(int instrument,
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string SpiceManager::frameFromBody(const std::string body) const {
|
||||
|
||||
for (auto pair : _frameByBody) {
|
||||
if (pair.first == body) {
|
||||
return pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
std::string unionPrefix = "IAU_";
|
||||
std::string frame = "";
|
||||
|
||||
if (body.find(unionPrefix) == std::string::npos)
|
||||
frame = unionPrefix + body;
|
||||
else
|
||||
frame = body;
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
bool SpiceManager::addFrame(const std::string body, const std::string frame) {
|
||||
if (body == "" || frame == "")
|
||||
return false;
|
||||
else {
|
||||
_frameByBody.push_back(std::make_pair(body, frame));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool SpiceManager::checkForError(std::string errorMessage) {
|
||||
|
||||
int failed = failed_c();
|
||||
|
||||
Reference in New Issue
Block a user