Salome HOME
Copyright update: 2016
[modules/smesh.git] / src / DriverUNV / UNV164_Structure.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "UNV164_Structure.hxx"
24 #include "UNV_Utilities.hxx"
25
26 #include <fstream>
27 #include <cstdio>
28 #include <cmath>
29
30 using namespace std;
31 using namespace UNV;
32 using namespace UNV164;
33
34 static string _label_dataset = "164";
35
36 void UNV164::Read(std::ifstream& in_stream, TRecord& theUnitsRecord )
37 {
38   if(!in_stream.good())
39     EXCEPTION(runtime_error,"ERROR: Input file not good.");
40
41   if(!beginning_of_dataset(in_stream,_label_dataset))
42     return;
43
44   string num_buf;
45   char line[theMaxLineLen] = "";
46
47   in_stream >> theUnitsRecord.units_code;
48   in_stream.readsome( line, 20 );
49   theUnitsRecord.units_description = line;
50   in_stream >> theUnitsRecord.temp_mode;
51
52   for ( int i = 0; i < 4; i++ )
53   {
54     in_stream >> num_buf;
55     theUnitsRecord.factors[i] = D_to_e(num_buf);
56   }
57 }
58
59 void UNV164::Write(std::ofstream& out_stream)
60 {
61   if(!out_stream.good())
62     EXCEPTION(runtime_error,"ERROR: Output file not good.");
63   
64   out_stream<<"    -1" << endl;
65   out_stream<<"   "<<_label_dataset << endl;
66
67   out_stream<<"         1  SI: Meter (newton)         2"                                    << endl;
68   out_stream<<"    1.0000000000000000E+0    1.0000000000000000E+0    1.0000000000000000E+0" << endl;
69   out_stream<<"    2.7314999999999998E+2"                                                   << endl;
70
71   out_stream<<"    -1"  << endl;
72 }
73
74 UNV164::TRecord::TRecord()
75 {
76   units_code        = 1;
77   units_description = "SI: Meter (newton)";
78   temp_mode         = 2;
79   factors[0]        = 1.0;
80   factors[1]        = 1.0;
81   factors[2]        = 1.0;
82   factors[3]        = 273.15;
83 }