mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-28 07:10:33 +05:00
0022638: [CEA 1210] Wrong import of an UNV file
Support reading a mesh in 2D space
This commit is contained in:
parent
d9faba6c84
commit
a5f7916fb6
@ -21,7 +21,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "UNV2411_Structure.hxx"
|
#include "UNV2411_Structure.hxx"
|
||||||
#include "UNV_Utilities.hxx"
|
#include "UNV_Utilities.hxx"
|
||||||
@ -36,7 +36,9 @@ UNV2411::TRecord::TRecord():
|
|||||||
exp_coord_sys_num(1),
|
exp_coord_sys_num(1),
|
||||||
disp_coord_sys_num(1),
|
disp_coord_sys_num(1),
|
||||||
color(11)//(0) - 0019936: EDF 794 SMESH : Export UNV : Node color and group id
|
color(11)//(0) - 0019936: EDF 794 SMESH : Export UNV : Node color and group id
|
||||||
{}
|
{
|
||||||
|
coord[1] = coord[2] = 0.0; // prepare to e.g. 2D mesh
|
||||||
|
}
|
||||||
|
|
||||||
void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet)
|
void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet)
|
||||||
{
|
{
|
||||||
@ -54,7 +56,40 @@ void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet)
|
|||||||
* always 3 coordinates in the UNV file, no matter
|
* always 3 coordinates in the UNV file, no matter
|
||||||
* which dimensionality libMesh is in
|
* which dimensionality libMesh is in
|
||||||
*/
|
*/
|
||||||
|
int dim = 3;
|
||||||
std::string num_buf;
|
std::string num_buf;
|
||||||
|
|
||||||
|
// Issue 22638. Find out space dimension to read a 2D mesh from a file
|
||||||
|
// generated by SIMAIL from Simulog
|
||||||
|
if ( !in_stream.eof() )
|
||||||
|
{
|
||||||
|
int where = in_stream.tellg();
|
||||||
|
|
||||||
|
TRecord aRec;
|
||||||
|
in_stream >> aRec.label ;
|
||||||
|
if ( aRec.label == -1 ) return; // dataset end
|
||||||
|
|
||||||
|
dim = 0;
|
||||||
|
num_buf = read_line( in_stream );
|
||||||
|
for ( size_t i = 0; i < num_buf.size(); )
|
||||||
|
{
|
||||||
|
// skip spaces
|
||||||
|
while ( i < num_buf.size() && num_buf[i] == ' ' )
|
||||||
|
++i;
|
||||||
|
|
||||||
|
dim += ( i < num_buf.size() );
|
||||||
|
|
||||||
|
// skip non-spaces
|
||||||
|
while ( i < num_buf.size() && num_buf[i] != ' ' )
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
if ( dim == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
in_stream.seekg( where, in_stream.beg );
|
||||||
|
}
|
||||||
|
|
||||||
|
// read the rest records
|
||||||
while ( !in_stream.eof() )
|
while ( !in_stream.eof() )
|
||||||
{
|
{
|
||||||
TRecord aRec;
|
TRecord aRec;
|
||||||
@ -72,7 +107,7 @@ void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet)
|
|||||||
* take care of the
|
* take care of the
|
||||||
* floating-point data
|
* floating-point data
|
||||||
*/
|
*/
|
||||||
for(int d = 0; d < 3; d++){
|
for(int d = 0; d < dim; d++){
|
||||||
in_stream>>num_buf;
|
in_stream>>num_buf;
|
||||||
aRec.coord[d] = D_to_e(num_buf);
|
aRec.coord[d] = D_to_e(num_buf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user