mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-08 20:39:47 -05:00
Started cleanup of SpiceManager
Clean boost message output Update to new Ghoul with cppformat library
This commit is contained in:
@@ -191,7 +191,6 @@ if (NOT DEFINED Boost_INCLUDE_DIR OR NOT DEFINED Boost_LIBRARIES)
|
||||
endif ()
|
||||
target_include_directories(libtorrent PUBLIC ${Boost_INCLUDE_DIR})
|
||||
target_link_libraries(libtorrent ${Boost_LIBRARIES})
|
||||
message(${Boost_LIBRARIES})
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(libtorrent wsock32 ws2_32 Iphlpapi.lib)
|
||||
|
||||
+1
-1
Submodule ext/ghoul updated: 19c3dcc66e...b2278ce9d3
@@ -25,9 +25,6 @@
|
||||
#ifndef __SPICEMANAGER_H__
|
||||
#define __SPICEMANAGER_H__
|
||||
|
||||
#include "SpiceUsr.h"
|
||||
#include "SpiceZpr.h"
|
||||
|
||||
#include <openspace/util/powerscaledcoordinate.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
@@ -41,26 +38,34 @@
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "SpiceUsr.h"
|
||||
#include "SpiceZpr.h"
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class SpiceManager : public ghoul::Singleton<SpiceManager> {
|
||||
friend class ghoul::Singleton<SpiceManager>;
|
||||
|
||||
public:
|
||||
typedef std::array<double, 36> TransformMatrix;
|
||||
typedef unsigned int KernelIdentifier;
|
||||
using TransformMatrix = std::array<double, 36>;
|
||||
using KernelHandle = unsigned int;
|
||||
|
||||
static const KernelIdentifier KernelFailed = KernelIdentifier(-1);
|
||||
static const KernelHandle InvalidKernel = KernelHandle(-1);
|
||||
|
||||
/**
|
||||
* Loads one or more SPICE kernels into a program. The provided path can either be a
|
||||
* binary, text-kernel, or meta-kernel which gets loaded into the kernel pool. The
|
||||
* loading is done by passing the <code>filePath</code> to the <code>furnsh_c</code>
|
||||
* loading is done by passing the \p filePath to the <code>furnsh_c</code>
|
||||
* function. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/furnsh_c.html
|
||||
* \param filePath The path to the kernel that should be loaded
|
||||
* \return The loaded kernel's unique identifier that can be used to unload the kernel
|
||||
* \pre \p filePath is a non-empty absolute or relative path pointing to an
|
||||
* existing file that contains a SPICE kernel
|
||||
* \post The kernel is loaded or has its reference counter incremented and the handle
|
||||
* to the kernel is returned if the SPICE kernel is valid, or \a KernelInvalid if the
|
||||
* kernel is invalid
|
||||
*/
|
||||
KernelIdentifier loadKernel(const std::string& filePath);
|
||||
KernelHandle loadKernel(std::string filePath);
|
||||
|
||||
/**
|
||||
* Function to find and store the intervals covered by a ck file, this is done
|
||||
@@ -107,7 +112,7 @@ public:
|
||||
* \param kernelId The unique identifier that was returned from the call to
|
||||
* loadKernel which loaded the kernel
|
||||
*/
|
||||
void unloadKernel(KernelIdentifier kernelId);
|
||||
void unloadKernel(KernelHandle kernelId);
|
||||
|
||||
/**
|
||||
* Unloads a SPICE kernel identified by the <code>filePath</code> which was used in
|
||||
@@ -694,7 +699,7 @@ public:
|
||||
protected:
|
||||
struct KernelInformation {
|
||||
std::string path; /// The path from which the kernel was loaded
|
||||
KernelIdentifier id; /// A unique identifier for each kernel
|
||||
KernelHandle id; /// A unique identifier for each kernel
|
||||
int refCount; /// How many parts loaded this kernel and are interested in it
|
||||
};
|
||||
|
||||
@@ -717,7 +722,7 @@ protected:
|
||||
const static bool _showErrors = false;
|
||||
|
||||
/// The last assigned kernel-id, used to determine the next free kernel id
|
||||
KernelIdentifier _lastAssignedKernel;
|
||||
KernelHandle _lastAssignedKernel;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -62,8 +62,8 @@ SpiceEphemeris::SpiceEphemeris(const ghoul::Dictionary& dictionary)
|
||||
if (!success)
|
||||
LERROR("'" << KeyKernels << "' has to be an array-style table");
|
||||
|
||||
SpiceManager::KernelIdentifier id = SpiceManager::ref().loadKernel(kernel);
|
||||
_kernelsLoadedSuccessfully &= (id != SpiceManager::KernelFailed);
|
||||
SpiceManager::KernelHandle id = SpiceManager::ref().loadKernel(kernel);
|
||||
_kernelsLoadedSuccessfully &= (id != SpiceManager::InvalidKernel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -485,9 +485,9 @@ bool OpenSpaceEngine::loadSpiceKernels() {
|
||||
LERROR("Configuration file does not contain a '" << ConfigurationManager::KeySpiceTimeKernel << "'");
|
||||
return false;
|
||||
}
|
||||
SpiceManager::KernelIdentifier id =
|
||||
SpiceManager::KernelHandle id =
|
||||
SpiceManager::ref().loadKernel(timeKernel);
|
||||
if (id == SpiceManager::KernelFailed) {
|
||||
if (id == SpiceManager::InvalidKernel) {
|
||||
LERROR("Error loading time kernel '" << timeKernel << "'");
|
||||
return false;
|
||||
}
|
||||
@@ -501,7 +501,7 @@ bool OpenSpaceEngine::loadSpiceKernels() {
|
||||
return false;
|
||||
}
|
||||
id = SpiceManager::ref().loadKernel(std::move(leapSecondKernel));
|
||||
if (id == SpiceManager::KernelFailed) {
|
||||
if (id == SpiceManager::InvalidKernel) {
|
||||
LERROR("Error loading leap second kernel '" << leapSecondKernel << "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
+16
-13
@@ -26,11 +26,14 @@
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <format.h>
|
||||
|
||||
#define MAXOBJ 64
|
||||
#define WINSIZ 10000
|
||||
|
||||
@@ -59,17 +62,17 @@ SpiceManager::~SpiceManager() {
|
||||
}
|
||||
|
||||
|
||||
SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& filePath) {
|
||||
if (filePath.empty()) {
|
||||
LERROR("No filename provided");
|
||||
return KernelFailed;
|
||||
}
|
||||
|
||||
std::string&& path = absPath(filePath);
|
||||
SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) {
|
||||
ghoul_assert(!filePath.empty(), "Empty file path");
|
||||
ghoul_assert(FileSys.fileExists(filePath),
|
||||
fmt::format("File '{}' does not exist", filePath)
|
||||
);
|
||||
|
||||
std::string path = absPath(filePath);
|
||||
|
||||
if (!FileSys.fileExists(path)) {
|
||||
LERROR("Kernel file '" << path << "' does not exist");
|
||||
return KernelFailed;
|
||||
return InvalidKernel;
|
||||
}
|
||||
|
||||
// We need to set the current directory as meta-kernels are usually defined relative
|
||||
@@ -81,7 +84,7 @@ SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& fileP
|
||||
|
||||
if (!FileSys.directoryExists(fileDirectory)) {
|
||||
LERROR("Could not find directory for kernel '" << path << "'");
|
||||
return KernelFailed;
|
||||
return InvalidKernel;
|
||||
}
|
||||
|
||||
auto it = std::find_if(
|
||||
@@ -97,7 +100,7 @@ SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& fileP
|
||||
return it->id;
|
||||
}
|
||||
|
||||
KernelIdentifier kernelId = ++_lastAssignedKernel;
|
||||
KernelHandle kernelId = ++_lastAssignedKernel;
|
||||
|
||||
FileSys.setCurrentDirectory(fileDirectory);
|
||||
|
||||
@@ -123,12 +126,12 @@ SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& fileP
|
||||
LERROR("Error loading kernel '" + path + "'");
|
||||
LERROR("Spice reported: " + std::string(msg));
|
||||
reset_c();
|
||||
return KernelFailed;
|
||||
return InvalidKernel;
|
||||
}
|
||||
|
||||
bool hasError = checkForError("Error loading kernel '" + path + "'");
|
||||
if (hasError)
|
||||
return KernelFailed;
|
||||
return InvalidKernel;
|
||||
else {
|
||||
KernelInformation&& info = { path, std::move(kernelId), 1 };
|
||||
_loadedKernels.push_back(info);
|
||||
@@ -240,7 +243,7 @@ bool SpiceManager::hasCkCoverage(std::string frame, double& et) const
|
||||
return idSuccess && hasCoverage;
|
||||
}
|
||||
|
||||
void SpiceManager::unloadKernel(KernelIdentifier kernelId) {
|
||||
void SpiceManager::unloadKernel(KernelHandle kernelId) {
|
||||
auto it = std::find_if(_loadedKernels.begin(), _loadedKernels.end(),
|
||||
[&kernelId](const KernelInformation& info) { return info.id == kernelId ; });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user