mdal 0.9.1 (#46489)

This commit is contained in:
Vincent Cloarec 2021-12-15 09:31:15 -04:00 committed by GitHub
parent fab5d8a84e
commit f355f3bd80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 27 deletions

View File

@ -6,7 +6,7 @@
#include "mdal_dynamic_driver.hpp"
#include "mdal_logger.hpp"
#if not defined (WIN32)
#ifndef WIN32
#include <dlfcn.h>
#endif
#include <string.h>

View File

@ -67,9 +67,8 @@ void MDAL::SelafinFile::initialize()
mParsed = false;
}
void MDAL::SelafinFile::parseFile()
void MDAL::SelafinFile::parseMeshFrame()
{
/* 1 record containing the title of the study (72 characters) and a 8 characters
string indicating the type of format (SERAFIN or SERAFIND)
*/
@ -115,7 +114,7 @@ void MDAL::SelafinFile::parseFile()
mXOrigin = static_cast<double>( mParameters[2] );
mYOrigin = static_cast<double>( mParameters[3] );
if ( mParameters[6] != 0 )
if ( mParameters[6] != 0 && mParameters[6] != 1 ) //some tools set this value to one for 2D mesh
{
// would need additional parsing
throw MDAL::Error( MDAL_Status::Err_MissingDriver, "File " + mFileName + " would need additional parsing" );
@ -159,10 +158,15 @@ void MDAL::SelafinFile::parseFile()
/* 1 record containing table X (real array of dimension NPOIN containing the
abscisse of the points)
AND here, we can know if float of this file is simple or double precision:
result of size of record divided by number of vertices gives the byte size of the float:
-> 4 : simple precision -> 8 : double precision
*/
size = mVerticesCount;
if ( ! checkDoubleArraySize( size ) )
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "File format problem while reading abscisse values" );
size_t recordSize = readSizeT();
mStreamInFloatPrecision = recordSize / size == 4;
if ( !mStreamInFloatPrecision && recordSize / size != 8 )
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "File format problem: could not determine if simple or double precision" );
mXStreamPosition = passThroughDoubleArray( size );
/* 1 record containing table Y (real array of dimension NPOIN containing the
@ -172,6 +176,11 @@ void MDAL::SelafinFile::parseFile()
if ( ! checkDoubleArraySize( size ) )
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "File format problem while reading abscisse values" );
mYStreamPosition = passThroughDoubleArray( size );
}
void MDAL::SelafinFile::parseFile()
{
parseMeshFrame();
/* Next, for each time step, the following are found:
- 1 record containing time T (real),
@ -205,20 +214,6 @@ std::string MDAL::SelafinFile::readHeader()
std::string title = header.substr( 0, 72 );
title = trim( title );
std::string varType = header.substr( 72, 8 );
varType = trim( varType );
if ( varType == "SERAFIN" )
{
mStreamInFloatPrecision = true;
}
else if ( varType == "SERAFIND" )
{
mStreamInFloatPrecision = false;
}
else
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "Not found stream precision" );
if ( header.size() < 80 ) // IF "SERAFIN", the readString method remove the last character that is a space
header.append( " " );
return header;
@ -615,7 +610,7 @@ void MDAL::SelafinFile::ignoreArrayLength( )
MDAL::DriverSelafin::DriverSelafin():
Driver( "SELAFIN",
"Selafin File",
"*.slf",
"*.slf;;*.ser;;*.geo;;*.res",
Capability::ReadMesh | Capability::SaveMesh | Capability::WriteDatasetsOnVertices | Capability::ReadDatasets
)
{
@ -635,7 +630,7 @@ bool MDAL::DriverSelafin::canReadMesh( const std::string &uri )
try
{
SelafinFile file( uri );
file.readHeader();
file.parseMeshFrame();
return true;
}
catch ( ... )
@ -651,7 +646,7 @@ bool MDAL::DriverSelafin::canReadDatasets( const std::string &uri )
try
{
SelafinFile file( uri );
file.readHeader();
file.parseMeshFrame();
return true;
}
catch ( ... )

View File

@ -49,8 +49,8 @@ namespace MDAL
//! Populates the mesh with dataset from the file
static void populateDataset( Mesh *mesh, const std::string &fileName );
//! Read the header of the file and return the project name
std::string readHeader();
//! Extracts data related to the mesh frame for the file
void parseMeshFrame();
//! Add the dataset group to the file (persist), replace dataset in the new group by Selafindataset with lazy loading
bool addDatasetGroup( DatasetGroup *datasetGroup );
@ -60,7 +60,10 @@ namespace MDAL
//! Initializes and open the file file with the \a fileName
void initialize();
//! Extracts data from files
//! Reads the header of the file and return the project name
std::string readHeader();
//! Extracts data from the file
void parseFile();
//! Returns the vertices count in the mesh stored in the file

View File

@ -21,7 +21,7 @@ static const char *EMPTY_STR = "";
const char *MDAL_Version()
{
return "0.9.0";
return "0.9.1";
}
MDAL_Status MDAL_LastStatus()