Back to index

salome-smesh  6.5.0
UNV164_Structure.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "UNV164_Structure.hxx"
00024 #include "UNV_Utilities.hxx"
00025 
00026 #include <fstream>
00027 #include <cstdio>
00028 #include <cmath>
00029 
00030 using namespace std;
00031 using namespace UNV;
00032 using namespace UNV164;
00033 
00034 static string _label_dataset = "164";
00035 
00036 void UNV164::Read(std::ifstream& in_stream, TRecord& theUnitsRecord )
00037 {
00038   if(!in_stream.good())
00039     EXCEPTION(runtime_error,"ERROR: Input file not good.");
00040 
00041   if(!beginning_of_dataset(in_stream,_label_dataset))
00042     return;
00043 
00044   string num_buf;
00045   char line[theMaxLineLen];
00046 
00047   in_stream >> theUnitsRecord.units_code;
00048   in_stream.readsome( line, 20 );
00049   theUnitsRecord.units_description = line;
00050   in_stream >> theUnitsRecord.temp_mode;
00051 
00052   for ( int i = 0; i < 4; i++ )
00053   {
00054     in_stream >> num_buf;
00055     theUnitsRecord.factors[i] = D_to_e(num_buf);
00056   }
00057 }
00058 
00059 void UNV164::Write(std::ofstream& out_stream)
00060 {
00061   if(!out_stream.good())
00062     EXCEPTION(runtime_error,"ERROR: Output file not good.");
00063   
00064   out_stream<<"    -1" << endl;
00065   out_stream<<"  "<<_label_dataset << endl;
00066 
00067   out_stream<<"         1  SI: Meter (newton)         2"                                    << endl;
00068   out_stream<<"    1.0000000000000000E+0    1.0000000000000000E+0    1.0000000000000000E+0" << endl;
00069   out_stream<<"    2.7314999999999998E+2"                                                   << endl;
00070 
00071   out_stream<<"    -1"  << endl;
00072 }
00073 
00074 UNV164::TRecord::TRecord()
00075 {
00076   units_code        = 1;
00077   units_description = "SI: Meter (newton)";
00078   temp_mode         = 2;
00079   factors[0]        = 1.0;
00080   factors[1]        = 1.0;
00081   factors[2]        = 1.0;
00082   factors[3]        = 273.15;
00083 }