1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // File : SauvUtilities.hxx
20 // Created : Mon Aug 22 18:27:34 2011
21 // Author : Edward AGAPOV (eap)
23 #ifndef __SAUVUTILITIES_HXX__
24 #define __SAUVUTILITIES_HXX__
26 #include "MEDLoaderDefines.hxx"
27 #include "MEDCouplingRefCountObject.hxx"
28 #include "NormalizedUnstructuredMesh.hxx"
33 #define THROW_IK_EXCEPTION(text) \
35 std::ostringstream oss; oss << text; \
36 throw INTERP_KERNEL::Exception(oss.str().c_str()); \
39 namespace SauvUtilities
41 INTERP_KERNEL::NormalizedCellType MEDLOADER_EXPORT gibi2medGeom( size_t gibiType );
42 int med2gibiGeom( INTERP_KERNEL::NormalizedCellType medGeomType );
43 const int * getGibi2MedQuadraticInterlace( INTERP_KERNEL::NormalizedCellType type );
44 unsigned getDimension( INTERP_KERNEL::NormalizedCellType type );
48 PILE_SOUS_MAILLAGE=1 ,
64 //================================================================================
66 * \brief Converts anything to string
68 //================================================================================
70 template<class T> std::string toString(const T& anything)
72 std::ostringstream s; s << anything; return s.str();
75 // ==============================================================================
76 // IMP 0020434: mapping GIBI names to MED names
80 int gibi_pile; // PILE_SOUS_MAILLAGE or PILE_FIELD/PILE_NODES_FIELD, or PILE_STRINGS(for components)
82 std::string gibi_name; // used only for components
84 // med_pile = 27; // PILE_STRINGS
85 int med_id; // used only on reading
86 std::string med_name; // used only on writing
89 // ==============================================================================
91 * \brief Base class for ASCII and XDR file readers
93 class FileReader : public ParaMEDMEM::RefCountObject
96 FileReader(const char* fileName);
97 virtual ~FileReader() {}
98 virtual bool isASCII() const = 0;
100 virtual bool open() = 0;
101 virtual bool getNextLine (char* & line, bool raiseOEF = true ) = 0;
102 virtual void initNameReading(int nbValues, int width = 8) = 0;
103 virtual void initIntReading(int nbValues) = 0;
104 virtual void initDoubleReading(int nbValues) = 0;
105 virtual bool more() const = 0;
106 virtual void next() = 0;
107 virtual int index() const { return _iRead; }
108 virtual int getInt() const = 0;
109 virtual float getFloat() const = 0;
110 virtual double getDouble() const = 0;
111 virtual std::string getName() const = 0;
113 std::size_t getHeapMemorySize() const { return 0; }
115 std::string _fileName, _curLocale;
116 int _iRead, _nbToRead;