Back to index

salome-med  6.5.0
SauvReader.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      : SauvReader.hxx
00020 // Created   : Tue Aug 16 13:04:25 2011
00021 // Author    : Edward AGAPOV (eap)
00022 //
00023 #ifndef __SAUVREADER_HXX__
00024 #define __SAUVREADER_HXX__
00025 
00026 #include "MEDLoaderDefines.hxx"
00027 #include "InterpKernelException.hxx"
00028 #include "SauvUtilities.hxx"
00029 #include "MEDCouplingRefCountObject.hxx"
00030 
00031 #include <vector>
00032 #include <string>
00033 #include <set>
00034 
00035 namespace SauvUtilities
00036 {
00037   class FileReader;
00038   class IntermediateMED;
00039   class Group;
00040   class DoubleField;
00041 }
00042 namespace ParaMEDMEM
00043 {
00044   class MEDFileData;
00045 
00046 class MEDLOADER_EXPORT SauvReader : public ParaMEDMEM::RefCountObject
00047 {
00048  public:
00049   static SauvReader* New(const char *fileName) throw(INTERP_KERNEL::Exception);
00050   ParaMEDMEM::MEDFileData * loadInMEDFileDS() throw(INTERP_KERNEL::Exception);
00051   ~SauvReader();
00052 
00053  private:
00054 
00055   void readRecord2();
00056   void readRecord4();
00057   void readRecord7();
00058 
00059   int readPileNumber(int& nbNamedObjects, int& nbObjects);
00060   void read_PILE_SOUS_MAILLAGE(const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00061   void read_PILE_NODES_FIELD  (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00062   void read_PILE_TABLES       (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00063   void read_PILE_LREEL        (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00064   void read_PILE_LOGIQUES     (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00065   void read_PILE_FLOATS       (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00066   void read_PILE_INTEGERS     (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00067   void read_PILE_STRINGS      (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00068   void read_PILE_LMOTS        (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00069   void read_PILE_NOEUDS       (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00070   void read_PILE_COORDONNEES  (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00071   void read_PILE_MODL         (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00072   void read_PILE_FIELD        (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
00073 
00074   SauvUtilities::Group* getFieldSupport(const std::vector<SauvUtilities::Group*>& fieldSupports);
00075   void setFieldNames(const std::vector<SauvUtilities::DoubleField*>& fields,
00076                      const std::vector<std::string>& objectNames,
00077                      const std::vector<int>& nameIndices);
00078 
00079   bool isASCII() const                                   { return _fileReader->isASCII(); }
00080   bool isXRD() const                                     { return !isASCII(); }
00081   bool getNextLine (char* & line, bool raiseOEF = true ) { return _fileReader->getNextLine( line, raiseOEF ); }
00082   void initNameReading(int nbValues, int width = 8)      { _fileReader->initNameReading( nbValues, width ); }
00083   void initIntReading(int nbValues)                      { _fileReader->initIntReading( nbValues ); }
00084   void initDoubleReading(int nbValues)                   { _fileReader->initDoubleReading( nbValues ); }
00085   bool more() const                                      { return _fileReader->more(); }
00086   void next()                                            { _fileReader->next(); }
00087   int  index() const                                     { return _fileReader->index(); }
00088   int    getInt() const                                  { return _fileReader->getInt(); }
00089   int    getIntNext()                                    { int i = getInt(); next(); return i; }
00090   float  getFloat() const                                { return _fileReader->getFloat(); }
00091   double getDouble() const                               { return _fileReader->getDouble(); }
00092   std::string getName() const                            { return _fileReader->getName(); }
00093   std::string lineNb() const;
00094   
00095 
00096   std::set<int> _encounteredPiles;
00097 
00098   SauvUtilities::FileReader*      _fileReader;
00099   SauvUtilities::IntermediateMED* _iMed;
00100 };
00101 }
00102 #endif