feat(opatIO): opat fileformat addedd
This commit is contained in:
93
src/opatIO/public/opatIO.h
Normal file
93
src/opatIO/public/opatIO.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef OPATIO_H
|
||||
#define OPATIO_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
struct Header {
|
||||
char magic[4];
|
||||
uint16_t version;
|
||||
uint32_t numTables;
|
||||
uint32_t headerSize;
|
||||
uint64_t indexOffset;
|
||||
char creationDate[16];
|
||||
char sourceInfo[64];
|
||||
char comment[128];
|
||||
char reserved[26];
|
||||
};
|
||||
|
||||
struct TableIndex {
|
||||
double X;
|
||||
double Z;
|
||||
// double C; // For type 2 OPAL tables. When not set will be 0
|
||||
// double O; // For type 2 OPAL tables. When not set will be 0
|
||||
uint64_t byteStart;
|
||||
uint64_t byteEnd;
|
||||
char sha256[32];
|
||||
};
|
||||
|
||||
struct OPATTable {
|
||||
uint32_t N_R;
|
||||
uint32_t N_T;
|
||||
std::vector<double> logR;
|
||||
std::vector<double> logT;
|
||||
std::vector<std::vector<double>> logKappa;
|
||||
};
|
||||
|
||||
class OpatIO {
|
||||
private:
|
||||
Header header;
|
||||
std::vector<TableIndex> tableIndex;
|
||||
std::queue<OPATTable> tableQueue;
|
||||
int maxQDepth = 10;
|
||||
std::string filename;
|
||||
bool loaded = false;
|
||||
|
||||
void readHeader(std::ifstream &file);
|
||||
void readTableIndex(std::ifstream &file);
|
||||
|
||||
bool isTableInQueue(double X, double Z);
|
||||
OPATTable getTableFromQueue(double X, double Z);
|
||||
void addTableToQueue(OPATTable table);
|
||||
void removeTableFromQueue();
|
||||
|
||||
void flushQueue();
|
||||
|
||||
uint16_t getOPATVersion();
|
||||
|
||||
uint16_t getTableID(double X, double Z);
|
||||
uint64_t getTableByteStart(uint16_t tableID);
|
||||
uint64_t getTableByteEnd(uint16_t tableID);
|
||||
|
||||
public:
|
||||
OpatIO();
|
||||
OpatIO(std::string filename);
|
||||
~OpatIO();
|
||||
|
||||
OPATTable getTable(double X, double, double C=0, double O=0);
|
||||
OPATTable getTable(uint16_t tableID);
|
||||
void setMaxQDepth(int depth);
|
||||
int getMaxQDepth();
|
||||
void setFilename(std::string filename);
|
||||
void load();
|
||||
void unload();
|
||||
bool isLoaded();
|
||||
|
||||
void printHeader();
|
||||
void printTableIndex();
|
||||
void printTable(OPATTable table);
|
||||
|
||||
std::vector<OPATTable> getTables();
|
||||
std::vector<TableIndex> getTableIndex();
|
||||
Header getHeader();
|
||||
|
||||
std::vector<OPATTable> getClosestXTables(double X, double ZExact, double C=0, double O=0, int numTables=1);
|
||||
std::vector<OPATTable> getClosestZTables(double XExact, double Z, double C=0, double O=0, int numTables=1);
|
||||
std::vector<OPATTable> getClosestTables(double X, double Z, double C=0, double O=0, int numTables=1);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user