mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 19:29:04 -05:00
Remove old Spice wrapper
This commit is contained in:
@@ -42,8 +42,6 @@ public:
|
||||
private:
|
||||
std::string _targetName;
|
||||
std::string _originName;
|
||||
int _target;
|
||||
int _origin;
|
||||
psc _position;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#ifndef SPICE_H
|
||||
#define SPICE_H
|
||||
|
||||
// std includes
|
||||
#include <string>
|
||||
|
||||
namespace openspace
|
||||
{
|
||||
|
||||
class Spice {
|
||||
public:
|
||||
virtual ~Spice();
|
||||
|
||||
static void init();
|
||||
static void deinit();
|
||||
static Spice& ref();
|
||||
static bool isInitialized();
|
||||
|
||||
void loadDefaultKernels();
|
||||
bool loadKernel(const std::string &path);
|
||||
|
||||
void bod_NameToInt(const std::string &name, int *id, int *success);
|
||||
bool getRadii(const std::string & name, double radii[3], int *n);
|
||||
|
||||
bool spk_getPosition(const std::string &target, const std::string &origin, double state[3]);
|
||||
void spk_getPosition(int target, int origin, double state[3]);
|
||||
bool spk_getOrientation(const std::string &target, double state[3][3]);
|
||||
|
||||
private:
|
||||
static Spice* this_;
|
||||
Spice(void);
|
||||
Spice(const Spice& src);
|
||||
Spice& operator=(const Spice& rhs);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spice.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/util/constants.h>
|
||||
@@ -75,7 +74,6 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName)
|
||||
OpenSpaceEngine::~OpenSpaceEngine()
|
||||
{
|
||||
SpiceManager::deinitialize();
|
||||
Spice::deinit();
|
||||
Time::deinitialize();
|
||||
DeviceIdentifier::deinit();
|
||||
FileSystem::deinitialize();
|
||||
@@ -252,8 +250,6 @@ bool OpenSpaceEngine::initialize()
|
||||
// initialize OpenSpace helpers
|
||||
SpiceManager::initialize();
|
||||
Time::initialize(timeKernel);
|
||||
Spice::init();
|
||||
Spice::ref().loadDefaultKernels(); // changeto: instantiate spicemanager, load kernels.
|
||||
|
||||
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/de430_1850-2150.bsp"), "SPK_EARTH");
|
||||
SpiceManager::ref().loadKernel(absPath("${OPENSPACE_DATA}/spice/MAR063.bsp") , "SPK_MARS");
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
#include <openspace/rendering/planets/renderableplanet.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/spice.h>
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/shadercreator.h>
|
||||
#include <openspace/query/query.h>
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
// open space includes
|
||||
#include <openspace/scenegraph/scenegraphnode.h>
|
||||
#include <openspace/util/spice.h>
|
||||
#include <openspace/query/query.h>
|
||||
#include <openspace/util/constants.h>
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <openspace/scenegraph/spiceephemeris.h>
|
||||
|
||||
#include <openspace/util/constants.h>
|
||||
#include <openspace/util/spice.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/util/time.h>
|
||||
|
||||
@@ -40,8 +39,6 @@ using namespace constants::spiceephemeris;
|
||||
SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
|
||||
: _targetName("")
|
||||
, _originName("")
|
||||
, _target(0)
|
||||
, _origin(0)
|
||||
, _position()
|
||||
{
|
||||
const bool hasBody = dictionary.hasKeyAndValue<std::string>(keyBody);
|
||||
@@ -61,17 +58,17 @@ SpiceEphemeris::~SpiceEphemeris() {}
|
||||
|
||||
bool SpiceEphemeris::initialize()
|
||||
{
|
||||
if (!_targetName.empty() && !_originName.empty()) {
|
||||
int bsuccess = 0;
|
||||
int osuccess = 0;
|
||||
Spice::ref().bod_NameToInt(_targetName, &_target, &bsuccess);
|
||||
Spice::ref().bod_NameToInt(_originName, &_origin, &osuccess);
|
||||
|
||||
if (bsuccess && osuccess)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
//if (!_targetName.empty() && !_originName.empty()) {
|
||||
// int bsuccess = 0;
|
||||
// int osuccess = 0;
|
||||
// Spice::ref().bod_NameToInt(_targetName, &_target, &bsuccess);
|
||||
// Spice::ref().bod_NameToInt(_originName, &_origin, &osuccess);
|
||||
//
|
||||
// if (bsuccess && osuccess)
|
||||
// return true;
|
||||
//}
|
||||
//
|
||||
return true;
|
||||
}
|
||||
|
||||
const psc& SpiceEphemeris::position() const {
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
|
||||
// openspace stuff
|
||||
#include <openspace/util/spice.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
#include <openspace/interaction/interactionhandler.h>
|
||||
|
||||
// spice
|
||||
#include "SpiceUsr.h"
|
||||
|
||||
// other
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include "ghoul/logging/logmanager.h"
|
||||
#include "ghoul/logging/consolelog.h"
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
#define lenout 81
|
||||
#define shrtms_len 81
|
||||
|
||||
Spice* Spice::this_ = nullptr;
|
||||
|
||||
Spice::Spice() {
|
||||
|
||||
// logger string
|
||||
std::string _loggerCat = "Spice::Spice()";
|
||||
|
||||
// print spice toolkit version
|
||||
ConstSpiceChar * versn;
|
||||
versn = tkvrsn_c( "TOOLKIT" );
|
||||
LINFO("Spice Toolkit version: " << versn);
|
||||
|
||||
// make the spice framework not exit on error
|
||||
erract_c (const_cast<char*>("SET"), lenout, const_cast<char*>("RETURN"));
|
||||
|
||||
// make spice print the errors to a log file
|
||||
errdev_c (const_cast<char*>("SET"), lenout, const_cast<char*>("NULL") );
|
||||
|
||||
}
|
||||
|
||||
Spice::~Spice() {
|
||||
|
||||
}
|
||||
|
||||
void Spice::init() {
|
||||
assert( ! this_);
|
||||
this_ = new Spice();
|
||||
}
|
||||
|
||||
void Spice::deinit() {
|
||||
assert(this_);
|
||||
delete this_;
|
||||
this_ = nullptr;
|
||||
}
|
||||
|
||||
Spice& Spice::ref() {
|
||||
assert(this_);
|
||||
return *this_;
|
||||
}
|
||||
|
||||
bool Spice::isInitialized() {
|
||||
return this_ != nullptr;
|
||||
}
|
||||
|
||||
void Spice::loadDefaultKernels() {
|
||||
assert(this_);
|
||||
|
||||
// load
|
||||
loadKernel(absPath("${OPENSPACE_DATA}/spice/de430_1850-2150.bsp"));
|
||||
//Summary for: de430_1850-2150.bsp
|
||||
//Bodies: MERCURY BARYCENTER (1) SATURN BARYCENTER (6) MERCURY (199)
|
||||
// VENUS BARYCENTER (2) URANUS BARYCENTER (7) VENUS (299)
|
||||
// EARTH BARYCENTER (3) NEPTUNE BARYCENTER (8) MOON (301)
|
||||
// MARS BARYCENTER (4) PLUTO BARYCENTER (9) EARTH (399)
|
||||
// JUPITER BARYCENTER (5) SUN (10)
|
||||
// Start of Interval (ET) End of Interval (ET)
|
||||
// ----------------------------- -----------------------------
|
||||
// 1849 DEC 26 00:00:00.000 2150 JAN 22 00:00:00.000
|
||||
|
||||
loadKernel(absPath("${OPENSPACE_DATA}/spice/pck00010.tpc"));
|
||||
}
|
||||
|
||||
bool Spice::loadKernel(const std::string &path) {
|
||||
assert(this_);
|
||||
|
||||
// ghoul logging
|
||||
std::string _loggerCat = "Spice::loadKernel";
|
||||
|
||||
furnsh_c ( path.c_str() );
|
||||
int failed = failed_c();
|
||||
if(failed) {
|
||||
char shrtms[shrtms_len];
|
||||
getmsg_c ( "SHORT", shrtms_len, shrtms );
|
||||
LERROR("Error when loading kernel with path: " << path);
|
||||
LERROR("Spice reported: " << shrtms);
|
||||
reset_c();
|
||||
}
|
||||
return ( ! failed);
|
||||
}
|
||||
|
||||
void Spice::bod_NameToInt(const std::string & name, int *id, int *success) {
|
||||
assert(this_);
|
||||
bodn2c_c (name.c_str(), id, success);
|
||||
}
|
||||
|
||||
bool Spice::getRadii(const std::string & name, double radii[3], int *n) {
|
||||
assert(this_);
|
||||
|
||||
// ghoul logging
|
||||
std::string _loggerCat = "Spice::getRadii";
|
||||
|
||||
bodvrd_c (name.c_str(), "RADII", 3, n, radii );
|
||||
int failed = failed_c();
|
||||
if(failed) {
|
||||
char shrtms[shrtms_len];
|
||||
getmsg_c ( "SHORT", shrtms_len, shrtms );
|
||||
LERROR("Error when fetching radii");
|
||||
LERROR("Spice reported: " << shrtms);
|
||||
reset_c();
|
||||
}
|
||||
return ( ! failed);
|
||||
}
|
||||
|
||||
// has error checking
|
||||
bool Spice::spk_getPosition(const std::string &target, const std::string &origin, double state[3]) {
|
||||
assert(this_);
|
||||
assert(Time::ref().isInitialized());
|
||||
|
||||
SpiceDouble et = Time::ref().currentTime();
|
||||
SpiceDouble lt;
|
||||
spkpos_c(target.c_str(), et, "J2000", "LT+S", origin.c_str(), state, <);
|
||||
int failed = failed_c();
|
||||
if(failed) {
|
||||
reset_c();
|
||||
}
|
||||
return ( ! failed);
|
||||
}
|
||||
|
||||
// no error checking
|
||||
void Spice::spk_getPosition(int target, int origin, double state[3]) {
|
||||
assert(this_);
|
||||
assert(Time::ref().isInitialized());
|
||||
|
||||
SpiceDouble et = Time::ref().currentTime();
|
||||
SpiceDouble lt;
|
||||
spkezp_c (target, et, "J2000", "NONE", origin, state, <);
|
||||
}
|
||||
|
||||
// has error checking
|
||||
bool Spice::spk_getOrientation(const std::string &target, double state[3][3]) {
|
||||
assert(this_);
|
||||
assert(Time::ref().isInitialized());
|
||||
|
||||
// ghoul logging
|
||||
std::string _loggerCat = "Spice::spk_getOrientation";
|
||||
|
||||
SpiceDouble et = Time::ref().currentTime();
|
||||
std::string newname = "IAU_";
|
||||
newname += target;
|
||||
pxform_c ( "J2000", newname.c_str(), et, state );
|
||||
int failed = failed_c();
|
||||
if(failed) {
|
||||
char shrtms[shrtms_len];
|
||||
getmsg_c ( "SHORT", shrtms_len, shrtms );
|
||||
LERROR("Error when fetching orientation");
|
||||
LERROR("Spice reported: " << shrtms);
|
||||
reset_c();
|
||||
}
|
||||
return ( ! failed);
|
||||
}
|
||||
|
||||
/*
|
||||
The following example retrieves radii for Mars and computes
|
||||
orientation of the Mars body-fixed frame:
|
||||
|
||||
SpiceDouble et;
|
||||
SpiceDouble mat[3][3];
|
||||
SpiceDouble radii[3];
|
||||
SpiceInt n;
|
||||
|
||||
furnsh_c ( "naif0008.tls" );
|
||||
furnsh_c ( "pck00008.tpc" );
|
||||
|
||||
// retrieve Mars radii
|
||||
bodvrd_c ( "MARS", "RADII", 3, &n, radii );
|
||||
|
||||
// convert UTC to ET
|
||||
str2et_c ( "2005-DEC-28 12:00", &et );
|
||||
|
||||
// compute Mars orientation relative to the J2000 frame
|
||||
pxform_c ( "J2000", "IAU_MARS", et, mat );
|
||||
*/
|
||||
|
||||
} // namespace openspace
|
||||
Reference in New Issue
Block a user