@@ -67,9 +67,8 @@ void MDAL::SelafinFile::initialize()
67
67
mParsed = false ;
68
68
}
69
69
70
- void MDAL::SelafinFile::parseFile ()
70
+ void MDAL::SelafinFile::parseMeshFrame ()
71
71
{
72
-
73
72
/* 1 record containing the title of the study (72 characters) and a 8 characters
74
73
string indicating the type of format (SERAFIN or SERAFIND)
75
74
*/
@@ -115,7 +114,7 @@ void MDAL::SelafinFile::parseFile()
115
114
mXOrigin = static_cast <double >( mParameters [2 ] );
116
115
mYOrigin = static_cast <double >( mParameters [3 ] );
117
116
118
- if ( mParameters [6 ] != 0 )
117
+ if ( mParameters [6 ] != 0 && mParameters [ 6 ] != 1 ) // some tools set this value to one for 2D mesh
119
118
{
120
119
// would need additional parsing
121
120
throw MDAL::Error ( MDAL_Status::Err_MissingDriver, " File " + mFileName + " would need additional parsing" );
@@ -159,10 +158,15 @@ void MDAL::SelafinFile::parseFile()
159
158
160
159
/* 1 record containing table X (real array of dimension NPOIN containing the
161
160
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
162
164
*/
163
165
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" );
166
170
mXStreamPosition = passThroughDoubleArray ( size );
167
171
168
172
/* 1 record containing table Y (real array of dimension NPOIN containing the
@@ -172,6 +176,11 @@ void MDAL::SelafinFile::parseFile()
172
176
if ( ! checkDoubleArraySize ( size ) )
173
177
throw MDAL::Error ( MDAL_Status::Err_UnknownFormat, " File format problem while reading abscisse values" );
174
178
mYStreamPosition = passThroughDoubleArray ( size );
179
+ }
180
+
181
+ void MDAL::SelafinFile::parseFile ()
182
+ {
183
+ parseMeshFrame ();
175
184
176
185
/* Next, for each time step, the following are found:
177
186
- 1 record containing time T (real),
@@ -205,20 +214,6 @@ std::string MDAL::SelafinFile::readHeader()
205
214
std::string title = header.substr ( 0 , 72 );
206
215
title = trim ( title );
207
216
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
-
222
217
if ( header.size () < 80 ) // IF "SERAFIN", the readString method remove the last character that is a space
223
218
header.append ( " " );
224
219
return header;
@@ -615,7 +610,7 @@ void MDAL::SelafinFile::ignoreArrayLength( )
615
610
MDAL::DriverSelafin::DriverSelafin ():
616
611
Driver( " SELAFIN" ,
617
612
" Selafin File" ,
618
- " *.slf" ,
613
+ " *.slf;;*.ser;;*.geo;;*.res " ,
619
614
Capability::ReadMesh | Capability::SaveMesh | Capability::WriteDatasetsOnVertices | Capability::ReadDatasets
620
615
)
621
616
{
@@ -635,7 +630,7 @@ bool MDAL::DriverSelafin::canReadMesh( const std::string &uri )
635
630
try
636
631
{
637
632
SelafinFile file ( uri );
638
- file.readHeader ();
633
+ file.parseMeshFrame ();
639
634
return true ;
640
635
}
641
636
catch ( ... )
@@ -651,7 +646,7 @@ bool MDAL::DriverSelafin::canReadDatasets( const std::string &uri )
651
646
try
652
647
{
653
648
SelafinFile file ( uri );
654
- file.readHeader ();
649
+ file.parseMeshFrame ();
655
650
return true ;
656
651
}
657
652
catch ( ... )
0 commit comments