mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 06:19:02 -06:00
Move the mapping target->frame from SpiceManager to SpacecraftInstrumentModule (#closes 21)
This commit is contained in:
@@ -652,36 +652,6 @@ public:
|
||||
FieldOfViewMethod method, AberrationCorrection aberrationCorrection,
|
||||
double& ephemerisTime) const;
|
||||
|
||||
/**
|
||||
* Determine whether a specific \p target is in the field-of-view of a specified
|
||||
* \p instrument or an \p observer at a given time. The reference frame used is
|
||||
* derived from the \p target by converting it into an \c IAU inertial reference
|
||||
* frame.
|
||||
*
|
||||
* \param target The name or NAIF ID code string of the target
|
||||
* \param observer The name or NAIF ID code string of the observer
|
||||
* \param instrument The name or NAIF ID code string of the instrument
|
||||
* \param method The type of shape model used for the target
|
||||
* \param aberrationCorrection The aberration correction method
|
||||
* \param ephemerisTime Time of the observation (seconds past J2000)
|
||||
* \return \c true if the target is visible, \c false otherwise
|
||||
*
|
||||
* \throw SpiceException If the \p target or \p observer do not name valid
|
||||
* NAIF objects, the \p target or \p observer name the same NAIF object, the
|
||||
* \p instrument does not name a valid NAIF object, or insufficient kernel
|
||||
* information has been loaded.
|
||||
* \pre \p target must not be empty.
|
||||
* \pre \p observer must not be empty.
|
||||
* \pre \p target and \p observer must not be different strings
|
||||
* \pre \p referenceFrame must not be empty.
|
||||
* \pre \p instrument must not be empty.
|
||||
*
|
||||
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/fovtrg_c.html
|
||||
*/
|
||||
bool isTargetInFieldOfView(const std::string& target, const std::string& observer,
|
||||
const std::string& instrument, FieldOfViewMethod method,
|
||||
AberrationCorrection aberrationCorrection, double& ephemerisTime) const;
|
||||
|
||||
/// Struct that is used as the return value from the #targetState method
|
||||
struct TargetStateResult {
|
||||
/// The target position
|
||||
@@ -902,26 +872,6 @@ public:
|
||||
AberrationCorrection aberrationCorrection, double ephemerisTime,
|
||||
int numberOfTerminatorPoints);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* \todo I think this function should die ---abock
|
||||
*/
|
||||
bool addFrame(std::string body, 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
|
||||
* \todo I think this function should die ---abock
|
||||
*/
|
||||
std::string frameFromBody(const std::string& body) const;
|
||||
|
||||
/**
|
||||
* Sets the SpiceManager's exception handling. If UseException::No is passed to this
|
||||
* function, all subsequent calls will not throw an error, but fail silently instead.
|
||||
@@ -1048,8 +998,6 @@ 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;
|
||||
|
||||
/// Stores whether the SpiceManager throws exceptions (Yes) or fails silently (No)
|
||||
UseException _useExceptions = UseException::Yes;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
@@ -151,7 +152,6 @@ namespace {
|
||||
return 0.5 * bisect(p1, half, testFunction, half);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -294,7 +294,10 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
|
||||
if (dictionary.hasKey(KeyFrameConversions)) {
|
||||
ghoul::Dictionary fc = dictionary.value<ghoul::Dictionary>(KeyFrameConversions);
|
||||
for (const std::string& key : fc.keys()) {
|
||||
openspace::SpiceManager::ref().addFrame(key, fc.value<std::string>(key));
|
||||
global::moduleEngine.module<SpacecraftInstrumentsModule>()->addFrame(
|
||||
key,
|
||||
fc.value<std::string>(key)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,7 +527,12 @@ void RenderableFov::computeIntercepts(const UpdateData& data, const std::string&
|
||||
{
|
||||
const bool convert = (ref.find("IAU_") == std::string::npos);
|
||||
if (convert) {
|
||||
return { SpiceManager::ref().frameFromBody(target), true };
|
||||
return {
|
||||
global::moduleEngine.module<SpacecraftInstrumentsModule>()->frameFromBody(
|
||||
target
|
||||
),
|
||||
true
|
||||
};
|
||||
}
|
||||
else {
|
||||
return { ref, false };
|
||||
@@ -917,6 +925,7 @@ std::pair<std::string, bool> RenderableFov::determineTarget(double time) {
|
||||
bool inFOV = SpiceManager::ref().isTargetInFieldOfView(
|
||||
pt,
|
||||
_instrument.spacecraft,
|
||||
global::moduleEngine.module<SpacecraftInstrumentsModule>()->frameFromBody(pt),
|
||||
_instrument.name,
|
||||
SpiceManager::FieldOfViewMethod::Ellipsoid,
|
||||
_instrument.aberrationCorrection,
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
|
||||
#include <modules/spacecraftinstruments/rendering/renderableplaneprojection.h>
|
||||
|
||||
#include <modules/spacecraftinstruments/spacecraftinstrumentsmodule.h>
|
||||
#include <modules/spacecraftinstruments/util/imagesequencer.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
@@ -309,7 +311,8 @@ void RenderablePlaneProjection::setTarget(std::string body) {
|
||||
return;
|
||||
}
|
||||
|
||||
_target.frame = SpiceManager::ref().frameFromBody(body);
|
||||
_target.frame =
|
||||
global::moduleEngine.module<SpacecraftInstrumentsModule>()->frameFromBody(body);
|
||||
_target.body = std::move(body);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,4 +94,31 @@ SpacecraftInstrumentsModule::documentations() const
|
||||
};
|
||||
}
|
||||
|
||||
bool SpacecraftInstrumentsModule::addFrame(std::string body, std::string frame) {
|
||||
if (body.empty() || frame.empty()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
_frameByBody.emplace_back(body, frame);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string SpacecraftInstrumentsModule::frameFromBody(const std::string& body) {
|
||||
for (const std::pair<std::string, std::string>& pair : _frameByBody) {
|
||||
if (pair.first == body) {
|
||||
return pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr const char* unionPrefix = "IAU_";
|
||||
|
||||
if (body.find(unionPrefix) == std::string::npos) {
|
||||
return unionPrefix + body;
|
||||
}
|
||||
else {
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -41,10 +41,16 @@ public:
|
||||
|
||||
static ghoul::opengl::ProgramObjectManager ProgramObjectManager;
|
||||
|
||||
bool addFrame(std::string body, std::string frame);
|
||||
std::string frameFromBody(const std::string& body);
|
||||
|
||||
protected:
|
||||
void internalInitialize(const ghoul::Dictionary&) override;
|
||||
void internalDeinitialize() override;
|
||||
void internalDeinitializeGL() override;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<std::string, std::string>> _frameByBody;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -687,24 +687,6 @@ bool SpiceManager::isTargetInFieldOfView(const std::string& target,
|
||||
return visible == SPICETRUE;
|
||||
}
|
||||
|
||||
bool SpiceManager::isTargetInFieldOfView(const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& instrument,
|
||||
FieldOfViewMethod method,
|
||||
AberrationCorrection aberrationCorrection,
|
||||
double& ephemerisTime) const
|
||||
{
|
||||
return isTargetInFieldOfView(
|
||||
target,
|
||||
observer,
|
||||
frameFromBody(target),
|
||||
instrument,
|
||||
method,
|
||||
aberrationCorrection,
|
||||
ephemerisTime
|
||||
);
|
||||
}
|
||||
|
||||
SpiceManager::TargetStateResult SpiceManager::targetState(const std::string& target,
|
||||
const std::string& observer,
|
||||
const std::string& referenceFrame,
|
||||
@@ -913,33 +895,6 @@ SpiceManager::TerminatorEllipseResult SpiceManager::terminatorEllipse(
|
||||
return res;
|
||||
}
|
||||
|
||||
bool SpiceManager::addFrame(std::string body, std::string frame) {
|
||||
if (body.empty() || frame.empty()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
_frameByBody.emplace_back(body, frame);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
std::string SpiceManager::frameFromBody(const std::string& body) const {
|
||||
for (const std::pair<std::string, std::string>& pair : _frameByBody) {
|
||||
if (pair.first == body) {
|
||||
return pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr const char* unionPrefix = "IAU_";
|
||||
|
||||
if (body.find(unionPrefix) == std::string::npos) {
|
||||
return unionPrefix + body;
|
||||
}
|
||||
else {
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
void SpiceManager::findCkCoverage(const std::string& path) {
|
||||
ghoul_assert(!path.empty(), "Empty file path");
|
||||
ghoul_assert(FileSys.fileExists(path), fmt::format("File '{}' does not exist", path));
|
||||
|
||||
Reference in New Issue
Block a user