Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 733827d

Browse files
vcloarecgithub-actions[bot]
authored andcommittedDec 15, 2021
mdal 0.9.1
1 parent 314b302 commit 733827d

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed
 

‎external/mdal/frmts/mdal_dynamic_driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "mdal_dynamic_driver.hpp"
88
#include "mdal_logger.hpp"
9-
#if not defined (WIN32)
9+
#ifndef WIN32
1010
#include <dlfcn.h>
1111
#endif
1212
#include <string.h>

‎external/mdal/frmts/mdal_selafin.cpp

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ void MDAL::SelafinFile::initialize()
6767
mParsed = false;
6868
}
6969

70-
void MDAL::SelafinFile::parseFile()
70+
void MDAL::SelafinFile::parseMeshFrame()
7171
{
72-
7372
/* 1 record containing the title of the study (72 characters) and a 8 characters
7473
string indicating the type of format (SERAFIN or SERAFIND)
7574
*/
@@ -115,7 +114,7 @@ void MDAL::SelafinFile::parseFile()
115114
mXOrigin = static_cast<double>( mParameters[2] );
116115
mYOrigin = static_cast<double>( mParameters[3] );
117116

118-
if ( mParameters[6] != 0 )
117+
if ( mParameters[6] != 0 && mParameters[6] != 1 ) //some tools set this value to one for 2D mesh
119118
{
120119
// would need additional parsing
121120
throw MDAL::Error( MDAL_Status::Err_MissingDriver, "File " + mFileName + " would need additional parsing" );
@@ -159,10 +158,15 @@ void MDAL::SelafinFile::parseFile()
159158

160159
/* 1 record containing table X (real array of dimension NPOIN containing the
161160
abscisse of the points)
161+
AND here, we can know if float of this file is simple or double precision:
162+
result of size of record divided by number of vertices gives the byte size of the float:
163+
-> 4 : simple precision -> 8 : double precision
162164
*/
163165
size = mVerticesCount;
164-
if ( ! checkDoubleArraySize( size ) )
165-
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "File format problem while reading abscisse values" );
166+
size_t recordSize = readSizeT();
167+
mStreamInFloatPrecision = recordSize / size == 4;
168+
if ( !mStreamInFloatPrecision && recordSize / size != 8 )
169+
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "File format problem: could not determine if simple or double precision" );
166170
mXStreamPosition = passThroughDoubleArray( size );
167171

168172
/* 1 record containing table Y (real array of dimension NPOIN containing the
@@ -172,6 +176,11 @@ void MDAL::SelafinFile::parseFile()
172176
if ( ! checkDoubleArraySize( size ) )
173177
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "File format problem while reading abscisse values" );
174178
mYStreamPosition = passThroughDoubleArray( size );
179+
}
180+
181+
void MDAL::SelafinFile::parseFile()
182+
{
183+
parseMeshFrame();
175184

176185
/* Next, for each time step, the following are found:
177186
- 1 record containing time T (real),
@@ -205,20 +214,6 @@ std::string MDAL::SelafinFile::readHeader()
205214
std::string title = header.substr( 0, 72 );
206215
title = trim( title );
207216

208-
std::string varType = header.substr( 72, 8 );
209-
varType = trim( varType );
210-
211-
if ( varType == "SERAFIN" )
212-
{
213-
mStreamInFloatPrecision = true;
214-
}
215-
else if ( varType == "SERAFIND" )
216-
{
217-
mStreamInFloatPrecision = false;
218-
}
219-
else
220-
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "Not found stream precision" );
221-
222217
if ( header.size() < 80 ) // IF "SERAFIN", the readString method remove the last character that is a space
223218
header.append( " " );
224219
return header;
@@ -615,7 +610,7 @@ void MDAL::SelafinFile::ignoreArrayLength( )
615610
MDAL::DriverSelafin::DriverSelafin():
616611
Driver( "SELAFIN",
617612
"Selafin File",
618-
"*.slf",
613+
"*.slf;;*.ser;;*.geo;;*.res",
619614
Capability::ReadMesh | Capability::SaveMesh | Capability::WriteDatasetsOnVertices | Capability::ReadDatasets
620615
)
621616
{
@@ -635,7 +630,7 @@ bool MDAL::DriverSelafin::canReadMesh( const std::string &uri )
635630
try
636631
{
637632
SelafinFile file( uri );
638-
file.readHeader();
633+
file.parseMeshFrame();
639634
return true;
640635
}
641636
catch ( ... )
@@ -651,7 +646,7 @@ bool MDAL::DriverSelafin::canReadDatasets( const std::string &uri )
651646
try
652647
{
653648
SelafinFile file( uri );
654-
file.readHeader();
649+
file.parseMeshFrame();
655650
return true;
656651
}
657652
catch ( ... )

‎external/mdal/frmts/mdal_selafin.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ namespace MDAL
4949
//! Populates the mesh with dataset from the file
5050
static void populateDataset( Mesh *mesh, const std::string &fileName );
5151

52-
//! Read the header of the file and return the project name
53-
std::string readHeader();
52+
//! Extracts data related to the mesh frame for the file
53+
void parseMeshFrame();
5454

5555
//! Add the dataset group to the file (persist), replace dataset in the new group by Selafindataset with lazy loading
5656
bool addDatasetGroup( DatasetGroup *datasetGroup );
@@ -60,7 +60,10 @@ namespace MDAL
6060
//! Initializes and open the file file with the \a fileName
6161
void initialize();
6262

63-
//! Extracts data from files
63+
//! Reads the header of the file and return the project name
64+
std::string readHeader();
65+
66+
//! Extracts data from the file
6467
void parseFile();
6568

6669
//! Returns the vertices count in the mesh stored in the file

‎external/mdal/mdal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static const char *EMPTY_STR = "";
2121

2222
const char *MDAL_Version()
2323
{
24-
return "0.9.0";
24+
return "0.9.1";
2525
}
2626

2727
MDAL_Status MDAL_LastStatus()

0 commit comments

Comments
 (0)
Please sign in to comment.