Navigation Menu

Skip to content

Commit

Permalink
mdal 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec authored and github-actions[bot] committed Dec 15, 2021
1 parent 314b302 commit 733827d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion external/mdal/frmts/mdal_dynamic_driver.cpp
Expand Up @@ -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>
Expand Down
39 changes: 17 additions & 22 deletions external/mdal/frmts/mdal_selafin.cpp
Expand Up @@ -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)
*/
Expand Down Expand Up @@ -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" );
Expand Down Expand Up @@ -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
Expand All @@ -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),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
)
{
Expand All @@ -635,7 +630,7 @@ bool MDAL::DriverSelafin::canReadMesh( const std::string &uri )
try
{
SelafinFile file( uri );
file.readHeader();
file.parseMeshFrame();
return true;
}
catch ( ... )
Expand All @@ -651,7 +646,7 @@ bool MDAL::DriverSelafin::canReadDatasets( const std::string &uri )
try
{
SelafinFile file( uri );
file.readHeader();
file.parseMeshFrame();
return true;
}
catch ( ... )
Expand Down
9 changes: 6 additions & 3 deletions external/mdal/frmts/mdal_selafin.hpp
Expand Up @@ -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 );
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion external/mdal/mdal.cpp
Expand Up @@ -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()
Expand Down

0 comments on commit 733827d

Please sign in to comment.