Salome HOME
cd063f43e5d60a2ed00fdd0147707d5976512919
[tools/medcoupling.git] / src / MEDLoader / MEDFileFieldOverView.hxx
1 // Copyright (C) 2007-2013  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.
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 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __MEDFILEFIELDOVERVIEW_HXX__
22 #define __MEDFILEFIELDOVERVIEW_HXX__
23
24 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
25 #include "MEDCouplingRefCountObject.hxx"
26
27 #include "NormalizedUnstructuredMesh.hxx"
28 #include "InterpKernelException.hxx"
29
30 #include <vector>
31
32 namespace ParaMEDMEM
33 {
34   class DataArrayInt;
35   class MEDFileMesh;
36   class MEDFileFieldGlobs;
37   class MEDFileAnyTypeField1TS;
38   class MEDFileAnyTypeFieldMultiTS;
39
40   class MEDFileMeshStruct : public RefCountObject
41   {
42   public:
43     static MEDFileMeshStruct *New(const MEDFileMesh *mesh);
44     std::size_t getHeapMemorySize() const;
45     int getNumberOfNodes() const { return _nb_nodes; }
46     int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
47   private:
48     MEDFileMeshStruct(const MEDFileMesh *mesh);
49   private:
50     const MEDFileMesh *_mesh;
51     std::string _name;
52     int _nb_nodes;
53     std::vector< std::vector<int> > _geo_types_distrib;
54   };
55
56   class MEDFileField1TSStructItem2
57   {
58   public:
59     MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& pfl, const std::string& loc);
60     void checkWithMeshStructForCells(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
61     void checkWithMeshStructForGaussNE(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
62     void checkWithMeshStructForGaussPT(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
63     //
64     INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
65     //! warning this method also set _nb_of_entity attribute !
66     void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
67     bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
68   private:
69     INTERP_KERNEL::NormalizedCellType _geo_type;
70     std::pair<int,int> _start_end;
71     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _pfl;
72     std::string _loc;
73     int _nb_of_entity;
74   };
75
76   class MEDFileField1TSStructItem
77   {
78   public:
79     MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
80     void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
81     bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
82     bool isEntityCell() const;
83     //
84     MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception);
85   private:
86     TypeOfField _type;
87     std::vector< MEDFileField1TSStructItem2 > _items;
88   };
89
90   class MEDFileField1TSStruct : public RefCountObject
91   {
92   public:
93     static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref) throw(INTERP_KERNEL::Exception);
94     void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
95     std::size_t getHeapMemorySize() const;
96     bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other) throw(INTERP_KERNEL::Exception);
97     bool isSupportSameAs(const MEDFileAnyTypeField1TS *other) throw(INTERP_KERNEL::Exception);
98   private:
99     MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref);
100     static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref);
101   private:
102     std::vector<MEDFileField1TSStructItem> _already_checked;
103   };
104
105   class MEDFileFastCellSupportComparator : public RefCountObject
106   {
107   public:
108     static MEDFileFastCellSupportComparator *New(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
109     bool isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
110     std::size_t getHeapMemorySize() const;
111   private:
112     MEDFileFastCellSupportComparator(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref);
113   private:
114     MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> _mesh_comp;
115     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> > _f1ts_cmps;
116   };
117 }
118
119 #endif