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