Back to index

salome-med  6.5.0
SauvUtilities.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 // File      : SauvUtilities.hxx
00020 // Created   : Mon Aug 22 18:27:34 2011
00021 // Author    : Edward AGAPOV (eap)
00022 
00023 #ifndef __SAUVUTILITIES_HXX__
00024 #define __SAUVUTILITIES_HXX__
00025 
00026 #include "MEDLoaderDefines.hxx"
00027 #include "MEDCouplingRefCountObject.hxx"
00028 #include "NormalizedUnstructuredMesh.hxx"
00029 
00030 #include <string>
00031 #include <sstream>
00032 
00033 #define THROW_IK_EXCEPTION(text)                        \
00034   {                                                     \
00035     std::ostringstream oss; oss << text;                \
00036     throw INTERP_KERNEL::Exception(oss.str().c_str());  \
00037   }
00038 
00039 namespace SauvUtilities
00040 {
00041   INTERP_KERNEL::NormalizedCellType MEDLOADER_EXPORT gibi2medGeom( size_t gibiType );
00042   int med2gibiGeom( INTERP_KERNEL::NormalizedCellType medGeomType );
00043   const int * getGibi2MedQuadraticInterlace( INTERP_KERNEL::NormalizedCellType type );
00044   unsigned getDimension( INTERP_KERNEL::NormalizedCellType type );
00045 
00046   enum Readable_Piles
00047     {
00048       PILE_SOUS_MAILLAGE=1 ,
00049       PILE_NODES_FIELD  =2 ,
00050       PILE_TABLES       =10,
00051       PILE_LREEL        =18,
00052       PILE_LOGIQUES     =24,
00053       PILE_FLOATS       =25,
00054       PILE_INTEGERS     =26,
00055       PILE_STRINGS      =27,
00056       PILE_LMOTS        =29,
00057       PILE_NOEUDS       =32,
00058       PILE_COORDONNEES  =33,
00059       PILE_MODL         =38,
00060       PILE_FIELD        =39,
00061       PILE_LAST_READABLE=39
00062     };
00063 
00064   //================================================================================
00068   //================================================================================
00069 
00070   template<class T> std::string toString(const T& anything)
00071   {
00072     std::ostringstream s; s << anything; return s.str();
00073   }
00074 
00075   // ==============================================================================
00076   // IMP 0020434: mapping GIBI names to MED names
00077   struct nameGIBItoMED
00078   {
00079     // GIBI value
00080     int gibi_pile;    // PILE_SOUS_MAILLAGE or PILE_FIELD/PILE_NODES_FIELD, or PILE_STRINGS(for components)
00081     int gibi_id;
00082     std::string gibi_name; // used only for components
00083     // MED value
00084     // med_pile = 27; // PILE_STRINGS
00085     int         med_id;    // used only on reading
00086     std::string med_name;  // used only on writing
00087   };
00088 
00089   // ==============================================================================
00093   class FileReader : public ParaMEDMEM::RefCountObject
00094   {
00095   public:
00096     FileReader(const char* fileName);
00097     virtual ~FileReader() {}
00098     virtual bool isASCII() const = 0;
00099 
00100     virtual bool open() = 0;
00101     virtual bool getNextLine (char* & line, bool raiseOEF = true ) = 0;
00102     virtual void initNameReading(int nbValues, int width = 8) = 0;
00103     virtual void initIntReading(int nbValues) = 0;
00104     virtual void initDoubleReading(int nbValues) = 0;
00105     virtual bool more() const = 0;
00106     virtual void next() = 0;
00107     virtual int  index() const { return _iRead; }
00108     virtual int    getInt() const = 0;
00109     virtual float  getFloat() const = 0;
00110     virtual double getDouble() const = 0;
00111     virtual std::string getName() const = 0;
00112 
00113   protected:
00114     std::string _fileName, _curLocale;
00115     int _iRead, _nbToRead;
00116   };
00117 }
00118 #endif