]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileFieldOverView.hxx
Salome HOME
On the highway to MEDReader
[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 #include "MEDCoupling1GTUMesh.hxx"
27
28 #include "NormalizedUnstructuredMesh.hxx"
29 #include "InterpKernelException.hxx"
30
31 #include <vector>
32
33 namespace ParaMEDMEM
34 {
35   class DataArrayInt;
36   class MEDCouplingMesh;
37   class MEDFileMesh;
38   class MEDFileUMesh;
39   class MEDFileCMesh;
40   class MEDFileCurveLinearMesh;
41   class MEDFileFieldGlobs;
42   class MEDFileFieldGlobsReal;
43   class MEDFileAnyTypeField1TS;
44   class MEDFileAnyTypeFieldMultiTS;
45
46   class MEDFileMeshStruct : public RefCountObject
47   {
48   public:
49     static MEDFileMeshStruct *New(const MEDFileMesh *mesh);
50     std::size_t getHeapMemorySize() const;
51     const MEDFileMesh *getTheMesh() const { return _mesh; }
52     int getNumberOfNodes() const { return _nb_nodes; }
53     int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
54     int getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
55     int getNumberOfLevs() const;
56     int getNumberOfGeoTypesInLev(int relativeLev) const throw(INTERP_KERNEL::Exception);
57   private:
58     MEDFileMeshStruct(const MEDFileMesh *mesh);
59   private:
60     const MEDFileMesh *_mesh;
61     std::string _name;
62     int _nb_nodes;
63     std::vector< std::vector<int> > _geo_types_distrib;
64   }; 
65
66   class MEDMeshMultiLev : public RefCountObject
67   {
68   public:
69     std::size_t getHeapMemorySize() const;
70   public:
71     static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
72     static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
73     void setNodeReduction(const DataArrayInt *nr);
74   protected:
75     MEDMeshMultiLev();
76     MEDMeshMultiLev(const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
77     protected:
78     std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
79     std::vector< INTERP_KERNEL::NormalizedCellType > _geo_types;
80     std::vector<int> _nb_entities;
81     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _node_reduction;
82   };
83
84   class MEDUMeshMultiLev : public MEDMeshMultiLev
85   {
86   public:
87     static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
88     static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
89   private:
90     MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs);
91     MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
92   private:
93     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > _parts;
94   };
95
96   class MEDCMeshMultiLev : public MEDMeshMultiLev
97   {
98   public:
99     static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
100     static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
101   private:
102     MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs);
103     MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
104   private:
105     std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _coords;
106   };
107
108   class MEDCurveLinearMeshMultiLev : public MEDMeshMultiLev
109   {
110   public:
111     static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
112     static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls , const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
113   private:
114     MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
115     MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
116   private:
117     MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
118     std::vector<int> _structure;
119   };
120
121   class MEDFileField1TSStructItem2 : public RefCountObject
122   {
123   public:
124     MEDFileField1TSStructItem2();
125     MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& pfl, const std::string& loc);
126     void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
127     void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
128     void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
129     //
130     std::size_t getHeapMemorySize() const;
131     //
132     const DataArrayInt *getPfl(const MEDFileFieldGlobsReal *globs) const;
133     INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
134     std::string getPflName() const;
135     //! warning this method also set _nb_of_entity attribute !
136     void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
137     bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
138     bool isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
139     bool isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
140     static MEDFileField1TSStructItem2 BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
141   public:
142     static const char NEWLY_CREATED_PFL_NAME[];
143   private:
144     INTERP_KERNEL::NormalizedCellType _geo_type;
145     std::pair<int,int> _start_end;
146     MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _pfl;
147     std::string _loc;
148     int _nb_of_entity;
149   };
150
151   class MEDFileField1TSStructItem : public RefCountObject
152   {
153   public:
154     MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
155     void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
156     bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
157     std::size_t getHeapMemorySize() const;
158     bool isEntityCell() const;
159     bool isComputed() const { return _computed; }
160     TypeOfField getType() const { return _type; }
161     std::size_t getNumberOfItems() const { return _items.size(); }
162     const MEDFileField1TSStructItem2& operator[](std::size_t i) const throw(INTERP_KERNEL::Exception);
163     //
164     bool isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
165     bool isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
166     MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception);
167     bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception);
168     bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception);
169     MEDMeshMultiLev *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
170   private:
171     bool _computed;
172     TypeOfField _type;
173     std::vector< MEDFileField1TSStructItem2 > _items;
174   };
175
176   class MEDFileField1TSStruct : public RefCountObject
177   {
178   public:
179     static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception);
180     void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception);
181     std::size_t getHeapMemorySize() const;
182     bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception);
183     bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
184     bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
185     MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
186     bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
187   private:
188     MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
189     static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
190     bool presenceOfCellDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
191     bool presenceOfPartialNodeDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
192   private:
193     std::vector<MEDFileField1TSStructItem> _already_checked;
194   };
195
196   class MEDFileFastCellSupportComparator : public RefCountObject
197   {
198   public:
199     static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
200     MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
201     bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
202     bool isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
203     bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
204     std::size_t getHeapMemorySize() const;
205   private:
206     MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
207   private:
208     MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> _mesh_comp;
209     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> > _f1ts_cmps;
210   };
211 }
212
213 #endif