mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-26 05:58:48 -05:00
Fix case dependent kernels in OsirisRex
Fix stitched trail rendering for RenderableTrailTrajectory Adapt Lua scheduler helper scripts to new Dictionary layout Make Spice throw exceptions on default again Enable caching on default for CTX and MOLA data Add NOAA rt data (commented out in LodEarth)
This commit is contained in:
+3
-17
@@ -22,28 +22,14 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
|
||||
#include <openspace/util/gpudata.h>
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/texture.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "GPUData";
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
void UniformLocation::bind(ProgramObject* program, const std::string& name){
|
||||
_uniformLocation = program->uniformLocation(name);
|
||||
LDEBUG(name);
|
||||
}
|
||||
void UniformLocation::bind(ProgramObject* program, const std::string& name){
|
||||
_uniformLocation = program->uniformLocation(name);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
+70
-33
@@ -47,9 +47,10 @@ namespace {
|
||||
|
||||
// This method checks if one of the previous SPICE methods has failed. If it has, an
|
||||
// exception with the SPICE error message is thrown
|
||||
void throwOnSpiceError(std::string errorMessage) {
|
||||
// If an error occurred, true is returned, otherwise, false
|
||||
bool throwOnSpiceError(std::string errorMessage) {
|
||||
SpiceBoolean failed = failed_c();
|
||||
if (openspace::SpiceManager::ref().exceptionHandling()) {
|
||||
SpiceBoolean failed = failed_c();
|
||||
if (failed) {
|
||||
char buffer[SpiceErrorBufferSize];
|
||||
getmsg_c("LONG", SpiceErrorBufferSize, buffer);
|
||||
@@ -58,6 +59,12 @@ namespace {
|
||||
errorMessage + ": " + buffer
|
||||
);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return failed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +171,7 @@ SpiceManager::TerminatorType SpiceManager::terminatorTypeFromString( const strin
|
||||
}
|
||||
|
||||
SpiceManager::SpiceManager()
|
||||
: _useExceptions(UseException::No)
|
||||
: _useExceptions(UseException::Yes)
|
||||
{
|
||||
// Set the SPICE library to not exit the program if an error occurs
|
||||
erract_c("SET", 0, const_cast<char*>("REPORT"));
|
||||
@@ -173,15 +180,15 @@ SpiceManager::SpiceManager()
|
||||
}
|
||||
|
||||
SpiceManager::~SpiceManager() {
|
||||
for (const KernelInformation& i : _loadedKernels)
|
||||
for (const KernelInformation& i : _loadedKernels) {
|
||||
unload_c(i.path.c_str());
|
||||
}
|
||||
|
||||
// Set values back to default
|
||||
erract_c("SET", 0, const_cast<char*>("DEFAULT"));
|
||||
errprt_c("SET", 0, const_cast<char*>("DEFAULT"));
|
||||
}
|
||||
|
||||
|
||||
SpiceManager::KernelHandle SpiceManager::loadKernel(string filePath) {
|
||||
ghoul_assert(!filePath.empty(), "Empty file path");
|
||||
ghoul_assert(
|
||||
@@ -237,10 +244,12 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(string filePath) {
|
||||
throwOnSpiceError("Kernel loading");
|
||||
|
||||
string fileExtension = ghoul::filesystem::File(path, RawPath::Yes).fileExtension();
|
||||
if (fileExtension == "bc" || fileExtension == "BC")
|
||||
if (fileExtension == "bc" || fileExtension == "BC") {
|
||||
findCkCoverage(path); // binary ck kernel
|
||||
else if (fileExtension == "bsp" || fileExtension == "BSP")
|
||||
}
|
||||
else if (fileExtension == "bsp" || fileExtension == "BSP") {
|
||||
findSpkCoverage(path); // binary spk kernel
|
||||
}
|
||||
|
||||
KernelHandle kernelId = ++_lastAssignedKernel;
|
||||
ghoul_assert(kernelId != 0, fmt::format("Kernel Handle wrapped around to 0"));
|
||||
@@ -280,9 +289,14 @@ void SpiceManager::unloadKernel(std::string filePath) {
|
||||
[&path](const KernelInformation& info) { return info.path == path; });
|
||||
|
||||
if (it == _loadedKernels.end()) {
|
||||
throw SpiceException(
|
||||
format("'{}' did not correspond to a loaded kernel", path)
|
||||
);
|
||||
if (_useExceptions) {
|
||||
throw SpiceException(
|
||||
format("'{}' did not correspond to a loaded kernel", path)
|
||||
);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If there was only one part interested in the kernel, we can unload it
|
||||
@@ -307,8 +321,9 @@ bool SpiceManager::hasSpkCoverage(const string& target, double et) const {
|
||||
if (it != _spkIntervals.end()) {
|
||||
std::vector<std::pair<double, double>> intervalVector = it->second;
|
||||
for (const auto& vecElement : intervalVector) {
|
||||
if (vecElement.first < et && vecElement.second > et)
|
||||
if (vecElement.first < et && vecElement.second > et) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -323,8 +338,9 @@ bool SpiceManager::hasCkCoverage(const string& frame, double et) const {
|
||||
if (it != _ckIntervals.end()) {
|
||||
std::vector<std::pair<double, double>> intervalVector = it->second;
|
||||
for (const auto& i : intervalVector) {
|
||||
if (i.first < et && i.second > et)
|
||||
if (i.first < et && i.second > et) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -348,8 +364,9 @@ int SpiceManager::naifId(const std::string& body) const {
|
||||
SpiceBoolean success;
|
||||
SpiceInt id;
|
||||
bods2c_c(body.c_str(), &id, &success);
|
||||
if (!success)
|
||||
if (!success && _useExceptions) {
|
||||
throw SpiceException(format("Could not find NAIF ID of body '{}'", body));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -368,8 +385,9 @@ int SpiceManager::frameId(const std::string& frame) const {
|
||||
|
||||
SpiceInt id;
|
||||
namfrm_c(frame.c_str(), &id);
|
||||
if (id == 0)
|
||||
if (id == 0 && _useExceptions) {
|
||||
throw SpiceException(format("Could not find NAIF ID of frame '{}'", frame));
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -483,14 +501,19 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target,
|
||||
|
||||
bool targetHasCoverage = hasSpkCoverage(target, ephemerisTime);
|
||||
bool observerHasCoverage = hasSpkCoverage(observer, ephemerisTime);
|
||||
if (!targetHasCoverage && !observerHasCoverage && _useExceptions) {
|
||||
throw SpiceException(
|
||||
format("Neither target '{}' nor observer '{}' has SPK coverage at time {}",
|
||||
target,
|
||||
observer,
|
||||
ephemerisTime
|
||||
)
|
||||
);
|
||||
if (!targetHasCoverage && !observerHasCoverage) {
|
||||
if (_useExceptions) {
|
||||
throw SpiceException(
|
||||
format("Neither target '{}' nor observer '{}' has SPK coverage at time {}",
|
||||
target,
|
||||
observer,
|
||||
ephemerisTime
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
return glm::dvec3();
|
||||
}
|
||||
}
|
||||
else if (targetHasCoverage && observerHasCoverage) {
|
||||
glm::dvec3 position;
|
||||
@@ -778,13 +801,17 @@ SpiceManager::FieldOfViewResult SpiceManager::fieldOfView(int instrument) const
|
||||
boundsArr // the bounds
|
||||
);
|
||||
|
||||
throwOnSpiceError(format(
|
||||
bool failed = throwOnSpiceError(format(
|
||||
"Error getting field-of-view parameters for instrument '{}'", instrument
|
||||
));
|
||||
if (failed) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res.bounds.reserve(nrReturned);
|
||||
for (int i = 0; i < nrReturned; ++i)
|
||||
for (int i = 0; i < nrReturned; ++i) {
|
||||
res.bounds.emplace_back(boundsArr[i][0], boundsArr[i][1], boundsArr[i][2]);
|
||||
}
|
||||
|
||||
string shape = string(fovShapeBuffer);
|
||||
static const std::map<string, FieldOfViewResult::Shape> Map = {
|
||||
@@ -955,9 +982,14 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target,
|
||||
return glm::dvec3(0.0);
|
||||
}
|
||||
|
||||
if (_spkCoverageTimes.find(targetId) == _spkCoverageTimes.end() && _useExceptions) {
|
||||
// no coverage
|
||||
throw SpiceException(format("No position for '{}' at any time", target));
|
||||
if (_spkCoverageTimes.find(targetId) == _spkCoverageTimes.end()) {
|
||||
if (_useExceptions) {
|
||||
// no coverage
|
||||
throw SpiceException(format("No position for '{}' at any time", target));
|
||||
}
|
||||
else {
|
||||
return glm::dvec3();
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<double>& coveredTimes = _spkCoverageTimes.find(targetId)->second;
|
||||
@@ -1044,12 +1076,17 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram
|
||||
glm::dmat3 result;
|
||||
int idFrame = frameId(fromFrame);
|
||||
|
||||
if (_ckCoverageTimes.find(idFrame) == _ckCoverageTimes.end() && _useExceptions) {
|
||||
// no coverage
|
||||
throw SpiceException(format(
|
||||
"No data available for the transform matrix from '{}' to '{}' at any time",
|
||||
fromFrame, toFrame
|
||||
));
|
||||
if (_ckCoverageTimes.find(idFrame) == _ckCoverageTimes.end()) {
|
||||
if (_useExceptions) {
|
||||
// no coverage
|
||||
throw SpiceException(format(
|
||||
"No data available for the transform matrix from '{}' to '{}' at any time",
|
||||
fromFrame, toFrame
|
||||
));
|
||||
}
|
||||
else {
|
||||
return glm::dmat3();
|
||||
}
|
||||
}
|
||||
|
||||
std::set<double> coveredTimes = _ckCoverageTimes.find(idFrame)->second;
|
||||
|
||||
Reference in New Issue
Block a user