Salome HOME
533ae0ba451f801456050f6054fd36b1689a63f2
[modules/med.git] / src / MEDLoader / SauvReader.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File      : SauvReader.hxx
20 // Created   : Tue Aug 16 13:04:25 2011
21 // Author    : Edward AGAPOV (eap)
22 //
23 #ifndef __SAUVREADER_HXX__
24 #define __SAUVREADER_HXX__
25
26 #include "MEDLoaderDefines.hxx"
27 #include "InterpKernelException.hxx"
28 #include "SauvUtilities.hxx"
29 #include "MEDCouplingRefCountObject.hxx"
30
31 #include <vector>
32 #include <string>
33 #include <set>
34
35 namespace SauvUtilities
36 {
37   class FileReader;
38   struct IntermediateMED;
39   struct Group;
40   struct DoubleField;
41 }
42 namespace ParaMEDMEM
43 {
44   class MEDFileData;
45
46 class SauvReader : public ParaMEDMEM::RefCountObject
47 {
48  public:
49   MEDLOADER_EXPORT static SauvReader* New(const std::string& fileName);
50   MEDLOADER_EXPORT ParaMEDMEM::MEDFileData * loadInMEDFileDS();
51   MEDLOADER_EXPORT ~SauvReader();
52
53  private:
54   std::size_t getHeapMemorySizeWithoutChildren() const;
55   std::vector<const BigMemoryObject *> getDirectChildren() const;
56   void readRecord2();
57   void readRecord4();
58   void readRecord7();
59
60   int readPileNumber(int& nbNamedObjects, int& nbObjects);
61   void read_PILE_SOUS_MAILLAGE(const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
62   void read_PILE_NODES_FIELD  (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
63   void read_PILE_TABLES       (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
64   void read_PILE_LREEL        (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
65   void read_PILE_LOGIQUES     (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
66   void read_PILE_FLOATS       (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
67   void read_PILE_INTEGERS     (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
68   void read_PILE_STRINGS      (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
69   void read_PILE_LMOTS        (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
70   void read_PILE_NOEUDS       (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
71   void read_PILE_COORDONNEES  (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
72   void read_PILE_MODL         (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
73   void read_PILE_FIELD        (const int nbObjects, std::vector<std::string>& objectNames, std::vector<int>& nameIndices);
74
75   void setFieldSupport(const std::vector<SauvUtilities::Group*>& supports,
76                        SauvUtilities::DoubleField*               field);
77   void setFieldNames(const std::vector<SauvUtilities::DoubleField*>& fields,
78                      const std::vector<std::string>& objectNames,
79                      const std::vector<int>& nameIndices);
80
81   bool isASCII() const                                   { return _fileReader->isASCII(); }
82   bool isXRD() const                                     { return !isASCII(); }
83   bool getNextLine (char* & line, bool raiseOEF = true ) { return _fileReader->getNextLine( line, raiseOEF ); }
84   void initNameReading(int nbValues, int width = 8)      { _fileReader->initNameReading( nbValues, width ); }
85   void initIntReading(int nbValues)                      { _fileReader->initIntReading( nbValues ); }
86   void initDoubleReading(int nbValues)                   { _fileReader->initDoubleReading( nbValues ); }
87   bool more() const                                      { return _fileReader->more(); }
88   void next()                                            { _fileReader->next(); }
89   int  index() const                                     { return _fileReader->index(); }
90   int    getInt() const                                  { return _fileReader->getInt(); }
91   int    getIntNext()                                    { int i = getInt(); next(); return i; }
92   float  getFloat() const                                { return _fileReader->getFloat(); }
93   double getDouble() const                               { return _fileReader->getDouble(); }
94   std::string getName() const                            { return _fileReader->getName(); }
95   std::string lineNb() const;
96   
97
98   std::set<int> _encounteredPiles;
99
100   SauvUtilities::FileReader*      _fileReader;
101   SauvUtilities::IntermediateMED* _iMed;
102 };
103 }
104 #endif