Salome HOME
Debug of RENUMBER test.
[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 MEDCouplingMesh;
36   class MEDFileMesh;
37   class MEDFileFieldGlobs;
38   class MEDFileFieldGlobsReal;
39   class MEDFileAnyTypeField1TS;
40   class MEDFileAnyTypeFieldMultiTS;
41
42   class MEDFileMeshStruct : public RefCountObject
43   {
44   public:
45     static MEDFileMeshStruct *New(const MEDFileMesh *mesh);
46     std::size_t getHeapMemorySize() const;
47     const MEDFileMesh *getTheMesh() const { return _mesh; }
48     int getNumberOfNodes() const { return _nb_nodes; }
49     int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
50     int getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
51     int getNumberOfLevs() const;
52     int getNumberOfGeoTypesInLev(int relativeLev) const throw(INTERP_KERNEL::Exception);
53   private:
54     MEDFileMeshStruct(const MEDFileMesh *mesh);
55   private:
56     const MEDFileMesh *_mesh;
57     std::string _name;
58     int _nb_nodes;
59     std::vector< std::vector<int> > _geo_types_distrib;
60   };
61
62   class MEDFileField1TSStructItem2 : public RefCountObject
63   {
64   public:
65     MEDFileField1TSStructItem2();
66     MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& pfl, const std::string& loc);
67     void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
68     void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
69     void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
70     //
71     std::size_t getHeapMemorySize() const;
72     //
73     INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
74     std::string getPflName() const;
75     //! warning this method also set _nb_of_entity attribute !
76     void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
77     bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
78     bool isCellSupportEqual(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
79     static MEDFileField1TSStructItem2 BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
80   private:
81     INTERP_KERNEL::NormalizedCellType _geo_type;
82     std::pair<int,int> _start_end;
83     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _pfl;
84     std::string _loc;
85     int _nb_of_entity;
86   };
87
88   class MEDFileField1TSStructItem : public RefCountObject
89   {
90   public:
91     MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
92     void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
93     bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
94     std::size_t getHeapMemorySize() const;
95     bool isEntityCell() const;
96     bool isComputed() const { return _computed; }
97     TypeOfField getType() const { return _type; }
98     std::size_t getNumberOfItems() const { return _items.size(); }
99     const MEDFileField1TSStructItem2& operator[](std::size_t i) const throw(INTERP_KERNEL::Exception);
100     //
101     bool isCellSupportEqual(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
102     MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception);
103     bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception);
104     bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception);
105     MEDCouplingMesh *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
106   private:
107     bool _computed;
108     TypeOfField _type;
109     std::vector< MEDFileField1TSStructItem2 > _items;
110   };
111
112   class MEDFileField1TSStruct : public RefCountObject
113   {
114   public:
115     static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception);
116     void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
117     std::size_t getHeapMemorySize() const;
118     bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception);
119     bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
120     bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
121     MEDCouplingMesh *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
122   private:
123     MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
124     static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
125     bool presenceOfCellDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
126     bool presenceOfPartialNodeDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
127   private:
128     std::vector<MEDFileField1TSStructItem> _already_checked;
129   };
130
131   class MEDFileFastCellSupportComparator : public RefCountObject
132   {
133   public:
134     static MEDFileFastCellSupportComparator *New(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
135     MEDCouplingMesh *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
136     bool isDataSetSupportEqualToThePreviousOne(int timeStepId) const throw(INTERP_KERNEL::Exception);
137     bool isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
138     bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
139     std::size_t getHeapMemorySize() const;
140   private:
141     MEDFileFastCellSupportComparator(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref);
142   private:
143     MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> _mesh_comp;
144     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> > _f1ts_cmps;
145   };
146 }
147
148 #endif