Added task code for conversion to ascii

This commit is contained in:
GPayne
2020-02-27 13:35:10 -07:00
parent 88135c1db0
commit 97e393b0f6
5 changed files with 99 additions and 30 deletions
@@ -362,6 +362,15 @@ public:
static void saveScriptKeyframeAscii(timestamps times,
datamessagestructures::ScriptMessage& sm, std::ofstream& file);
/**
* Reads header information from a session recording file
*
* \param stream reference to ifstream that contains the session recording file data
* \param readLen_chars number of characters to be read, which may be the expected
* length of the header line, or an arbitrary number of characters within it
*/
static std::string readHeaderElement(std::ifstream& stream, size_t readLen_chars);
private:
enum class RecordedType {
Camera = 0,
@@ -51,4 +51,11 @@ T prevKeyframeObj(unsigned int index, const std::vector<T>& keyframeContainer) {
}
}
template <typename T>
T readFromPlayback(std::ifstream& stream) {
T res;
stream.read(reinterpret_cast<char*>(&res), sizeof(T));
return res;
}
} // namespace openspace::interaction
@@ -26,6 +26,7 @@
#define __OPENSPACE_CORE___CONVERTRECFORMATTASK___H__
#include <openspace/util/task.h>
#include <openspace/interaction/sessionrecording.h>
#include <ghoul/glm.h>
@@ -38,7 +39,7 @@ namespace {
constexpr const char* KeyOutFilePath = "OutputFilePath";
}
namespace openspace {
namespace openspace::interaction {
class ConvertRecFormatTask : public Task {
public:
@@ -51,19 +52,23 @@ public:
std::string description() override;
void perform(const Task::ProgressCallback& progressCallback) override;
static documentation::Documentation documentation();
void convert();
SessionRecording::RecordedDataMode ConvertRecFormatTask::formatType();
private:
void convertToAscii();
void convertToBinary();
std::string addFileSuffix(const std::string& filePath, const std::string& suffix);
std::string _inFilePath;
std::string _outFilePath;
std::ifstream _iFile;
std::ifstream _oFile;
std::ofstream _oFile;
std::string _valueFunctionLua;
SessionRecording sr;
};
} // namespace openspace
} // namespace openspace::interaction
#endif //__OPENSPACE_CORE___CONVERTRECFORMATTASK___H__