6 #ifndef MDAL_SELAFIN_HPP
7 #define MDAL_SELAFIN_HPP
15 #include "mdal_data_model.hpp"
16 #include "mdal_memory_data_model.hpp"
18 #include "mdal_driver.hpp"
48 static std::unique_ptr<Mesh>
createMesh(
const std::string &fileName );
67 size_t verticesCount();
71 size_t verticesPerFace();
74 std::vector<double> datasetValues(
size_t timeStepIndex,
size_t variableIndex,
size_t offset,
size_t count );
76 std::vector<int> connectivityIndex(
size_t offset,
size_t count );
78 std::vector<double> vertices(
size_t offset,
size_t count );
81 std::string readString(
size_t len );
87 std::vector<double> readDoubleArr(
size_t len );
93 std::vector<int> readIntArr(
size_t len );
99 std::vector<double> readDoubleArr(
const std::streampos &position,
size_t offset,
size_t len );
105 std::vector<int> readIntArr(
const std::streampos &position,
size_t offset,
size_t len );
108 bool checkIntArraySize(
size_t len );
111 bool checkDoubleArraySize(
size_t len );
114 size_t remainingBytes();
120 std::streampos passThroughIntArray(
size_t size );
126 std::streampos passThroughDoubleArray(
size_t size );
128 double readDouble( );
132 void ignoreArrayLength( );
133 std::string readStringWithoutLength(
size_t len );
134 void ignore(
int len );
141 std::vector<int> mParameters;
144 std::vector<std::vector<std::streampos>> mVariableStreamPosition;
145 std::vector<RelativeTimestamp> mTimeSteps;
146 std::vector<std::string> mVariableNames;
148 size_t mVerticesCount;
150 size_t mVerticesPerFace;
151 std::streampos mXStreamPosition;
152 std::streampos mYStreamPosition;
153 std::streampos mConnectivityStreamPosition;
154 std::streampos mIPOBOStreamPosition;
158 std::string mFileName;
159 bool mStreamInFloatPrecision =
true;
160 bool mChangeEndianness =
true;
161 long long mFileSize = -1;
164 bool mParsed =
false;
186 std::shared_ptr<SelafinFile> reader,
187 size_t timeStepIndex );
189 size_t scalarData(
size_t indexStart,
size_t count,
double *buffer )
override;
190 size_t vectorData(
size_t indexStart,
size_t count,
double *buffer )
override;
198 std::shared_ptr<SelafinFile> mReader;
200 size_t mXVariableIndex = 0;
201 size_t mYVariableIndex = 0;
202 size_t mTimeStepIndex = 0;
216 size_t next(
size_t vertexCount,
double *coordinates )
override;
219 std::shared_ptr<SelafinFile> mReader;
220 size_t mPosition = 0;
234 size_t next(
size_t faceOffsetsBufferLen,
int *faceOffsetsBuffer,
size_t vertexIndicesBufferLen,
int *vertexIndicesBuffer )
override;
237 std::shared_ptr<SelafinFile> mReader;
238 size_t mPosition = 0;
251 std::shared_ptr<SelafinFile> reader );
253 std::unique_ptr<MeshVertexIterator> readVertices()
override;
256 std::unique_ptr<MeshEdgeIterator>
readEdges()
override;
258 std::unique_ptr<MeshFaceIterator> readFaces()
override;
260 size_t verticesCount()
const override {
return mReader->verticesCount();}
261 size_t edgesCount()
const override {
return 0;}
262 size_t facesCount()
const override {
return mReader->facesCount();}
263 BBox extent()
const override;
265 void closeSource()
override;
268 mutable bool mIsExtentUpToDate =
false;
269 mutable BBox mExtent;
271 std::shared_ptr<SelafinFile> mReader;
273 void calculateExtent()
const;
319 bool canReadMesh(
const std::string &uri )
override;
320 bool canReadDatasets(
const std::string &uri )
override;
322 std::unique_ptr< Mesh > load(
const std::string &meshFile,
const std::string &meshName =
"" )
override;
323 void load(
const std::string &datFile,
Mesh *mesh )
override;
328 void save(
const std::string &fileName,
const std::string &meshName,
Mesh *mesh )
override;
330 std::string writeDatasetOnFileSuffix()
const override;
331 std::string saveMeshOnFileSuffix()
const override;
334 bool saveDatasetGroupOnFile(
DatasetGroup *datasetGroup );
Definition: mdal_data_model.hpp:97
Definition: mdal_data_model.hpp:137
Definition: mdal_selafin.hpp:174
void setYVariableIndex(size_t index)
Sets the position of the Y array in the stream.
Definition: mdal_selafin.cpp:918
size_t scalarData(size_t indexStart, size_t count, double *buffer) override
For DataOnVertices or DataOnFaces.
Definition: mdal_selafin.cpp:883
DatasetSelafin(DatasetGroup *parent, std::shared_ptr< SelafinFile > reader, size_t timeStepIndex)
Contructs a dataset with a SelafinFile object and the index of the time step.
Definition: mdal_selafin.cpp:875
size_t vectorData(size_t indexStart, size_t count, double *buffer) override
For DataOnVertices or DataOnFaces.
Definition: mdal_selafin.cpp:895
void setXVariableIndex(size_t index)
Sets the position of the X array in the stream.
Definition: mdal_selafin.cpp:913
Definition: mdal_datetime.hpp:48
Serafin format (also called Selafin)
Definition: mdal_selafin.hpp:313
int faceVerticesMaximumCount() const override
returns the maximum vertices per face
Definition: mdal_selafin.hpp:327
Definition: mdal_driver.hpp:28
Definition: mdal_data_model.hpp:227
Definition: mdal_selafin.hpp:224
MeshSelafinFaceIterator(std::shared_ptr< SelafinFile > reader)
Contructs a face iterator with a SerafinFile instance.
Definition: mdal_selafin.cpp:832
Definition: mdal_selafin.hpp:206
MeshSelafinVertexIterator(std::shared_ptr< SelafinFile > reader)
Contructs a vertex iterator with a SerafinFile instance.
Definition: mdal_selafin.cpp:812
Definition: mdal_selafin.hpp:242
std::unique_ptr< MeshEdgeIterator > readEdges() override
Selafin format doesn't support edges in MDAL, returns a void unique_ptr.
Definition: mdal_selafin.cpp:756
MeshSelafin(const std::string &uri, std::shared_ptr< SelafinFile > reader)
Contructs a dataset with a SerafinFile instance reader.
Definition: mdal_selafin.cpp:744
Definition: mdal_data_model.hpp:209
Definition: mdal_data_model.hpp:238
This class is used to read the selafin file format.
Definition: mdal_selafin.hpp:42
SelafinFile(const std::string &fileName)
Constructor.
Definition: mdal_selafin.cpp:32
bool addDatasetGroup(DatasetGroup *datasetGroup)
Add the dataset group to the file (persist), replace dataset in the new group by Selafindataset with ...
Definition: mdal_selafin.cpp:1138
std::string readHeader()
Read the header of the file and return the project name.
Definition: mdal_selafin.cpp:200
static void populateDataset(Mesh *mesh, const std::string &fileName)
Populates the mesh with dataset from the file.
Definition: mdal_selafin.cpp:262
static std::unique_ptr< Mesh > createMesh(const std::string &fileName)
Returns a mesh created with the file.
Definition: mdal_selafin.cpp:250
Definition: mdal_data_model.hpp:24