Salome HOME
Merge from V6_main (04/10/2012)
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingDefinitionTime.hxx
1 // Copyright (C) 2007-2012  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 __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__
23
24 #include "MEDCouplingRefCountObject.hxx"
25 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
26
27 #include "InterpKernelException.hxx"
28
29 #include <vector>
30 #include <sstream>
31
32 namespace ParaMEDMEM
33 {
34   class MEDCouplingFieldDouble;
35
36   class MEDCOUPLING_EXPORT MEDCouplingDefinitionTimeSlice : public RefCountObject
37   {
38   public:
39     static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception);
40     static MEDCouplingDefinitionTimeSlice *New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& tiD) throw(INTERP_KERNEL::Exception);
41     int getArrayId() const { return _array_id; }
42     virtual MEDCouplingDefinitionTimeSlice *copy() const = 0;
43     virtual bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
44     virtual void getHotSpotsTime(std::vector<double>& ret) const = 0;
45     virtual void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) = 0;
46     virtual bool isContaining(double tmp, double eps) const = 0;
47     virtual int getStartId() const;
48     virtual int getEndId() const;
49     virtual void appendRepr(std::ostream& stream) const;
50     virtual double getStartTime() const = 0;
51     virtual double getEndTime() const = 0;
52     virtual void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const = 0;
53     virtual TypeOfTimeDiscretization getTimeType() const = 0;
54     bool isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
55     bool isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
56     bool isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
57     bool isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
58   protected:
59     MEDCouplingDefinitionTimeSlice() { }
60     MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
61   protected:
62     int _mesh_id;
63     int _array_id;
64     int _field_id;
65   };
66
67   class MEDCouplingDefinitionTimeSliceInst : public MEDCouplingDefinitionTimeSlice
68   {
69   public:
70     static MEDCouplingDefinitionTimeSliceInst *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
71     MEDCouplingDefinitionTimeSlice *copy() const;
72     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
73     void getHotSpotsTime(std::vector<double>& ret) const;
74     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
75     bool isContaining(double tmp, double eps) const;
76     void appendRepr(std::ostream& stream) const;
77     double getStartTime() const;
78     double getEndTime() const;
79     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
80     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
81     TypeOfTimeDiscretization getTimeType() const;
82   public:
83     MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
84   protected:
85     MEDCouplingDefinitionTimeSliceInst() { }
86   protected:
87     double _instant;
88   };
89
90   class MEDCouplingDefinitionTimeSliceCstOnTI : public  MEDCouplingDefinitionTimeSlice
91   {
92   public:
93     static MEDCouplingDefinitionTimeSliceCstOnTI *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
94     MEDCouplingDefinitionTimeSlice *copy() const;
95     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
96     void getHotSpotsTime(std::vector<double>& ret) const;
97     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
98     bool isContaining(double tmp, double eps) const;
99     void appendRepr(std::ostream& stream) const;
100     double getStartTime() const;
101     double getEndTime() const;
102     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
103     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
104     TypeOfTimeDiscretization getTimeType() const;
105   public:
106     MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
107   protected:
108     MEDCouplingDefinitionTimeSliceCstOnTI() { }
109   protected:
110     double _start;
111     double _end;
112   };
113   
114   class MEDCouplingDefinitionTimeSliceLT : public MEDCouplingDefinitionTimeSlice
115   {
116   public:
117     static MEDCouplingDefinitionTimeSliceLT *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
118     MEDCouplingDefinitionTimeSlice *copy() const;
119     bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
120     void getHotSpotsTime(std::vector<double>& ret) const;
121     void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
122     bool isContaining(double tmp, double eps) const;
123     void appendRepr(std::ostream& stream) const;
124     double getStartTime() const;
125     double getEndTime() const;
126     int getEndId() const;
127     void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
128     void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
129     TypeOfTimeDiscretization getTimeType() const;
130   public:
131     MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception);
132   protected:
133     MEDCouplingDefinitionTimeSliceLT() { }
134   protected:
135     int _array_id_end;
136     double _start;
137     double _end;
138   };
139
140   class MEDCOUPLING_EXPORT MEDCouplingDefinitionTime
141   {
142   public:
143     MEDCouplingDefinitionTime();
144     MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& arrRefs) throw(INTERP_KERNEL::Exception);
145     void assign(const MEDCouplingDefinitionTime& other);
146     bool isEqual(const MEDCouplingDefinitionTime& other) const;
147     double getTimeResolution() const { return _eps; }
148     void getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
149     void getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
150     void getIdsOnTime(double tm, std::vector<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception);
151     std::vector<double> getHotSpotsTime() const;
152     void appendRepr(std::ostream& stream) const;
153   public:
154     void getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const;
155     void unserialize(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
156   private:
157     double _eps;
158     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> > _slices;
159     static const double EPS_DFT;
160   };
161 }
162
163 #endif