X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FDriverUNV%2FUNV2411_Structure.cxx;h=182e9d7e8d723ccfb1a97344ee10707c29c4f4ab;hp=8425f943b9704e848543ab6baa8f2baba4ba5c90;hb=a0f09b9f1b8f5eac0e1c9277f76d65eb643cac94;hpb=c3bf92bd87b770fd81631a3853f7f5bb1ac6a4e8 diff --git a/src/DriverUNV/UNV2411_Structure.cxx b/src/DriverUNV/UNV2411_Structure.cxx index 8425f943b..182e9d7e8 100644 --- a/src/DriverUNV/UNV2411_Structure.cxx +++ b/src/DriverUNV/UNV2411_Structure.cxx @@ -1,23 +1,27 @@ -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - -#include +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include #include "UNV2411_Structure.hxx" #include "UNV_Utilities.hxx" @@ -26,19 +30,15 @@ using namespace std; using namespace UNV; using namespace UNV2411; -#ifdef _DEBUG_ -static int MYDEBUG = 1; -#else -static int MYDEBUG = 0; -#endif - static string _label_dataset = "2411"; UNV2411::TRecord::TRecord(): - exp_coord_sys_num(0), - disp_coord_sys_num(0), - color(0) -{} + exp_coord_sys_num(1), + disp_coord_sys_num(1), + 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) { @@ -56,16 +56,49 @@ void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet) * always 3 coordinates in the UNV file, no matter * which dimensionality libMesh is in */ - TNodeLab aLabel; + int dim = 3; std::string num_buf; - for(; !in_stream.eof();){ - in_stream >> aLabel ; - if(aLabel == -1){ + + // 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() ) + { + TRecord aRec; + in_stream >> aRec.label ; + if ( aRec.label == -1 ) { // end of dataset is reached break; } - TRecord aRec; in_stream>>aRec.exp_coord_sys_num; in_stream>>aRec.disp_coord_sys_num; in_stream>>aRec.color; @@ -74,12 +107,12 @@ void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet) * take care of the * floating-point data */ - for(int d = 0; d < 3; d++){ + for(int d = 0; d < dim; d++){ in_stream>>num_buf; aRec.coord[d] = D_to_e(num_buf); } - theDataSet.insert(TDataSet::value_type(aLabel,aRec)); + theDataSet.push_back(aRec); } } @@ -96,22 +129,22 @@ void UNV2411::Write(std::ofstream& out_stream, const TDataSet& theDataSet) out_stream<<" "<<_label_dataset<<"\n"; TDataSet::const_iterator anIter = theDataSet.begin(); - for(; anIter != theDataSet.end(); anIter++){ - const TNodeLab& aLabel = anIter->first; - const TRecord& aRec = anIter->second; + for(; anIter != theDataSet.end(); anIter++) + { + const TRecord& aRec = *anIter; char buf[78]; sprintf(buf, "%10d%10d%10d%10d\n", - aLabel, - aRec.exp_coord_sys_num, - aRec.disp_coord_sys_num, - aRec.color); + aRec.label, + aRec.exp_coord_sys_num, + aRec.disp_coord_sys_num, + aRec.color); out_stream<