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