Back to index

salome-med  6.5.0
MEDCouplingDefinitionTime.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDCouplingDefinitionTime.hxx"
00021 #include "MEDCouplingFieldDouble.hxx"
00022 
00023 #include <cmath>
00024 
00025 using namespace ParaMEDMEM;
00026 
00027 const double MEDCouplingDefinitionTime::EPS_DFT=1e-15;
00028 
00029 MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception)
00030 {
00031   static const char msg[]="TimeSlice::New : mismatch of arrays number of a fieldDouble and its policy !!! Internal error !!!";
00032   if(!f)
00033     throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice::New : empty field !");
00034   switch(f->getTimeDiscretization())
00035     {
00036     case ONE_TIME:
00037       {
00038         if(arrId.size()!=1)
00039           throw INTERP_KERNEL::Exception(msg);
00040         return new MEDCouplingDefinitionTimeSliceInst(f,meshId,arrId[0],fieldId);
00041       }
00042     case CONST_ON_TIME_INTERVAL:
00043       {
00044         if(arrId.size()!=1)
00045           throw INTERP_KERNEL::Exception(msg);
00046         return new MEDCouplingDefinitionTimeSliceCstOnTI(f,meshId,arrId[0],fieldId);
00047       }
00048     case LINEAR_TIME:
00049       {
00050         if(arrId.size()!=2)
00051           throw INTERP_KERNEL::Exception(msg);
00052         return new MEDCouplingDefinitionTimeSliceLT(f,meshId,arrId[0],arrId[1],fieldId);
00053       }
00054     case NO_TIME:
00055       throw INTERP_KERNEL::Exception("Invalide time discretization ! NO_TIME ! Impossible to build a definition time slice !");
00056     default:
00057       throw INTERP_KERNEL::Exception("Invalide time discretization : Not recognized !");
00058     }
00059 }
00060 
00061 MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& tiD) throw(INTERP_KERNEL::Exception)
00062 {
00063   switch(type)
00064     {
00065     case ONE_TIME:
00066       return MEDCouplingDefinitionTimeSliceInst::New(tiI,tiD);
00067     case CONST_ON_TIME_INTERVAL:
00068       return MEDCouplingDefinitionTimeSliceCstOnTI::New(tiI,tiD);
00069     case LINEAR_TIME:
00070       return MEDCouplingDefinitionTimeSliceLT::New(tiI,tiD);
00071     default:
00072       throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice::New : unrecognized time discretization type !");
00073     }
00074 }
00075 
00076 bool MEDCouplingDefinitionTimeSlice::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
00077 {
00078   if(_mesh_id!=other._mesh_id)
00079     return false;
00080   if(_array_id!=other._array_id)
00081     return false;
00082   if(_field_id!=other._field_id)
00083     return false;
00084   return true;
00085 }
00086 
00087 int MEDCouplingDefinitionTimeSlice::getStartId() const
00088 {
00089   return _array_id;
00090 }
00091 
00092 int MEDCouplingDefinitionTimeSlice::getEndId() const
00093 {
00094   return _array_id;
00095 }
00096 
00097 void MEDCouplingDefinitionTimeSlice::appendRepr(std::ostream& stream) const
00098 {
00099   stream << " *** MeshId : " << _mesh_id << " ArrayId : " << _array_id;
00100 }
00101 
00102 MEDCouplingDefinitionTimeSlice::MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):_mesh_id(meshId),_array_id(arrId),_field_id(fieldId)
00103 {
00104   int tmp1,tmp2;
00105   double t1=f->getStartTime(tmp1,tmp2);
00106   double t2=f->getEndTime(tmp1,tmp2);
00107   if(t2<t1)
00108     throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice : End time strictly before Start time ...");
00109 }
00110 
00111 bool MEDCouplingDefinitionTimeSlice::isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
00112 {
00113   double t1=getStartTime();
00114   double t2=getEndTime();
00115   double o1=other->getStartTime();
00116   double o2=other->getEndTime();
00117   return o1>t1-eps && o2<t2+eps;
00118 }
00119 
00120 bool MEDCouplingDefinitionTimeSlice::isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
00121 {
00122   double t1=getStartTime();
00123   double t2=getEndTime();
00124   double o1=other->getStartTime();
00125   double o2=other->getEndTime();
00126   return (o1<t1+eps && o2<t1+eps) || (o1>t2-eps && o2>t2-eps);
00127 }
00128 
00129 bool MEDCouplingDefinitionTimeSlice::isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
00130 {
00131   double t2=getEndTime();
00132   double o1=other->getStartTime();
00133   double o2=other->getEndTime();
00134   return (o1>t2-eps && o2>t2-eps);
00135 }
00136 
00137 bool MEDCouplingDefinitionTimeSlice::isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
00138 {
00139   double t1=getStartTime();
00140   double o1=other->getStartTime();
00141   double o2=other->getEndTime();
00142   return (o1<t1+eps && o2<t1+eps);
00143 }
00144 
00145 MEDCouplingDefinitionTimeSliceInst *MEDCouplingDefinitionTimeSliceInst::New(const std::vector<int>& tiI, const std::vector<double>& tiD)
00146 {
00147   MEDCouplingDefinitionTimeSliceInst *ret=new MEDCouplingDefinitionTimeSliceInst;
00148   ret->unserialize(tiI,tiD);
00149   return ret;
00150 }
00151 
00152 void MEDCouplingDefinitionTimeSliceInst::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const
00153 {
00154   tiI.resize(3);
00155   tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id;
00156   tiD.resize(1);
00157   tiD[0]=_instant;
00158 }
00159 
00160 void MEDCouplingDefinitionTimeSliceInst::unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD)
00161 {
00162   _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2];
00163   _instant=tiD[0];
00164 }
00165 
00166 TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceInst::getTimeType() const
00167 {
00168   return ONE_TIME;
00169 }
00170 
00171 MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceInst::copy() const
00172 {
00173   return new MEDCouplingDefinitionTimeSliceInst(*this);
00174 }
00175 
00176 bool MEDCouplingDefinitionTimeSliceInst::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
00177 {
00178   if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps))
00179     return false;
00180   const MEDCouplingDefinitionTimeSliceInst *otherC=dynamic_cast<const MEDCouplingDefinitionTimeSliceInst *>(&other);
00181   if(!otherC)
00182     return false;
00183   return fabs(otherC->_instant-_instant)<eps;
00184 }
00185 
00186 void MEDCouplingDefinitionTimeSliceInst::getHotSpotsTime(std::vector<double>& ret) const
00187 {
00188   ret.resize(1);
00189   ret[0]=_instant;
00190 }
00191 
00192 void MEDCouplingDefinitionTimeSliceInst::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
00193 {
00194   meshId=_mesh_id;
00195   arrId=_array_id;
00196   arrIdInField=0;
00197   fieldId=_field_id;
00198 }
00199 
00200 bool MEDCouplingDefinitionTimeSliceInst::isContaining(double tmp, double eps) const
00201 {
00202   return fabs(tmp-_instant)<eps;
00203 }
00204 
00205 void MEDCouplingDefinitionTimeSliceInst::appendRepr(std::ostream& stream) const
00206 {
00207   stream << "single point " << _instant;
00208   MEDCouplingDefinitionTimeSlice::appendRepr(stream);
00209 }
00210 
00211 double MEDCouplingDefinitionTimeSliceInst::getStartTime() const
00212 {
00213   return _instant;
00214 }
00215 
00216 double MEDCouplingDefinitionTimeSliceInst::getEndTime() const
00217 {
00218   return _instant;
00219 }
00220 
00221 MEDCouplingDefinitionTimeSliceInst::MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId)
00222 {
00223   int tmp1,tmp2;
00224   double t1=f->getStartTime(tmp1,tmp2);
00225   double t2=f->getEndTime(tmp1,tmp2);
00226   double eps=f->getTimeTolerance();
00227   if(fabs(t1-t2)>eps)
00228     throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSliceInst : times differs in this");
00229   _instant=t1;
00230 }
00231 
00232 MEDCouplingDefinitionTimeSliceCstOnTI *MEDCouplingDefinitionTimeSliceCstOnTI::New(const std::vector<int>& tiI, const std::vector<double>& tiD)
00233 {
00234   MEDCouplingDefinitionTimeSliceCstOnTI *ret=new MEDCouplingDefinitionTimeSliceCstOnTI;
00235   ret->unserialize(tiI,tiD);
00236   return ret;
00237 }
00238 
00239 MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceCstOnTI::copy() const
00240 {
00241   return new MEDCouplingDefinitionTimeSliceCstOnTI(*this);
00242 }
00243 
00244 bool MEDCouplingDefinitionTimeSliceCstOnTI::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
00245 {
00246   if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps))
00247     return false;
00248   const MEDCouplingDefinitionTimeSliceCstOnTI *otherC=dynamic_cast<const MEDCouplingDefinitionTimeSliceCstOnTI *>(&other);
00249   if(!otherC)
00250     return false;
00251   if(fabs(otherC->_start-_start)>eps)
00252     return false;
00253   return fabs(otherC->_end-_end)<eps;
00254 }
00255 
00256 void MEDCouplingDefinitionTimeSliceCstOnTI::getHotSpotsTime(std::vector<double>& ret) const
00257 {
00258   ret.resize(1);
00259   ret[0]=(_start+_end)/2.;
00260 }
00261 
00262 void MEDCouplingDefinitionTimeSliceCstOnTI::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
00263 {
00264   meshId=_mesh_id;
00265   arrId=_array_id;
00266   arrIdInField=0;
00267   fieldId=_field_id;
00268 }
00269 
00270 bool MEDCouplingDefinitionTimeSliceCstOnTI::isContaining(double tmp, double eps) const
00271 {
00272   return _start-eps<tmp && _end+eps>tmp;
00273 }
00274 
00275 void MEDCouplingDefinitionTimeSliceCstOnTI::appendRepr(std::ostream& stream) const
00276 {
00277   stream << "Constant on time interval [" << _start << "," << _end << "]";
00278   MEDCouplingDefinitionTimeSlice::appendRepr(stream);
00279 }
00280 
00281 double MEDCouplingDefinitionTimeSliceCstOnTI::getStartTime() const
00282 {
00283   return _start;
00284 }
00285 
00286 double MEDCouplingDefinitionTimeSliceCstOnTI::getEndTime() const
00287 {
00288   return _end;
00289 }
00290 
00291 void MEDCouplingDefinitionTimeSliceCstOnTI::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const
00292 {
00293   tiI.resize(3);
00294   tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id;
00295   tiD.resize(2);
00296   tiD[0]=_start; tiD[1]=_end;
00297 }
00298 
00299 void MEDCouplingDefinitionTimeSliceCstOnTI::unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD)
00300 {
00301   _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2];
00302   _start=tiD[0]; _end=tiD[1];
00303 }
00304 
00305 TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceCstOnTI::getTimeType() const
00306 {
00307   return CONST_ON_TIME_INTERVAL;
00308 }
00309 
00310 MEDCouplingDefinitionTimeSliceCstOnTI::MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId)
00311 {
00312   int tmp1,tmp2;
00313   double t1=f->getStartTime(tmp1,tmp2);
00314   double t2=f->getEndTime(tmp1,tmp2);
00315   _start=t1;
00316   _end=t2;
00317 }
00318 
00319 MEDCouplingDefinitionTimeSliceLT *MEDCouplingDefinitionTimeSliceLT::New(const std::vector<int>& tiI, const std::vector<double>& tiD)
00320 {
00321   MEDCouplingDefinitionTimeSliceLT *ret=new MEDCouplingDefinitionTimeSliceLT;
00322   ret->unserialize(tiI,tiD);
00323   return ret;
00324 }
00325 
00326 MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceLT::copy() const
00327 {
00328   return new MEDCouplingDefinitionTimeSliceLT(*this);
00329 }
00330 
00331 bool MEDCouplingDefinitionTimeSliceLT::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
00332 {
00333   if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps))
00334     return false;
00335   const MEDCouplingDefinitionTimeSliceLT *otherC=dynamic_cast<const MEDCouplingDefinitionTimeSliceLT *>(&other);
00336   if(!otherC)
00337     return false;
00338   if(_array_id_end!=otherC->_array_id_end)
00339     return false;
00340   if(fabs(otherC->_start-_start)>eps)
00341     return false;
00342   return fabs(otherC->_end-_end)<eps;
00343 }
00344 
00345 void MEDCouplingDefinitionTimeSliceLT::getHotSpotsTime(std::vector<double>& ret) const
00346 {
00347   ret.resize(2);
00348   ret[0]=_start;
00349   ret[1]=_end;
00350 }
00351 
00352 void MEDCouplingDefinitionTimeSliceLT::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
00353 {
00354   if(fabs(tm-_start)<eps)
00355     {
00356       meshId=_mesh_id;
00357       arrId=_array_id;
00358       arrIdInField=0;
00359       fieldId=_field_id;
00360       return ;
00361     }
00362   if(fabs(tm-_end)<eps)
00363     {
00364       meshId=_mesh_id;
00365       arrId=_array_id_end;
00366       arrIdInField=1;
00367       fieldId=_field_id;
00368       return ;
00369     }
00370   throw INTERP_KERNEL::Exception("LinearTime request not in boundary of this ! use hot spots !");
00371 }
00372 
00373 bool MEDCouplingDefinitionTimeSliceLT::isContaining(double tmp, double eps) const
00374 {
00375   return _start-eps<tmp && _end+eps>tmp;
00376 }
00377 
00378 void MEDCouplingDefinitionTimeSliceLT::appendRepr(std::ostream& stream) const
00379 {
00380   stream << "Linear on time interval [" << _start << "," << _end << "]";
00381   MEDCouplingDefinitionTimeSlice::appendRepr(stream);
00382   stream << " EndArrayId : " << _array_id_end;
00383 }
00384 
00385 double MEDCouplingDefinitionTimeSliceLT::getStartTime() const
00386 {
00387   return _start;
00388 }
00389 
00390 double MEDCouplingDefinitionTimeSliceLT::getEndTime() const
00391 {
00392   return _end;
00393 }
00394 
00395 int MEDCouplingDefinitionTimeSliceLT::getEndId() const
00396 {
00397   return _array_id_end;
00398 }
00399 
00400 void MEDCouplingDefinitionTimeSliceLT::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const
00401 {
00402   tiI.resize(4);
00403   tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id; tiI[3]=_array_id_end;
00404   tiD.resize(2);
00405   tiD[0]=_start; tiD[1]=_end;
00406 }
00407 
00408 void MEDCouplingDefinitionTimeSliceLT::unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD)
00409 {
00410   _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2]; _array_id_end=tiI[3];
00411   _start=tiD[0]; _end=tiD[1];
00412 }
00413 
00414 TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceLT::getTimeType() const
00415 {
00416   return LINEAR_TIME;
00417 }
00418 
00419 MEDCouplingDefinitionTimeSliceLT::MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId),_array_id_end(arr2Id)
00420 {
00421   int tmp1,tmp2;
00422   double t1=f->getStartTime(tmp1,tmp2);
00423   double t2=f->getEndTime(tmp1,tmp2);
00424   _start=t1;
00425   _end=t2;
00426 }
00427 
00428 MEDCouplingDefinitionTime::MEDCouplingDefinitionTime():_eps(EPS_DFT)
00429 {
00430 }
00431 
00432 MEDCouplingDefinitionTime::MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& arrRefs) throw(INTERP_KERNEL::Exception)
00433 {
00434   std::size_t sz=fs.size();
00435   if(sz!=arrRefs.size())
00436     throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : internal error ! should never happen !");
00437   _slices.resize(sz);
00438   for(std::size_t i=0;i<sz;i++)
00439     {
00440       if(arrRefs.empty())
00441         throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : A field is null in list impossible to build a time definition !");
00442       _slices[i]=MEDCouplingDefinitionTimeSlice::New(fs[i],meshRefs[i],arrRefs[i],(int)i);
00443     }
00444   if(sz<=1)
00445     return ;
00446   const MEDCouplingDefinitionTimeSlice *ref=_slices[0];
00447   _eps=fs[0]->getTimeTolerance();
00448   for(std::size_t i=1;i<sz;i++)
00449     {
00450       if(!ref->isAfterMe(_slices[i],_eps))
00451         throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructors : the sequences of fields does NOT defines a stricly ascendant monotonic time sequence !");
00452       // double t1=ref->getEndTime();
00453       // double t2=_slices[i]->getStartTime();
00454       // if(fabs(t1-t2)<_eps)
00455       //   if(ref->getEndId() != _slices[i]->getStartId())
00456       //     throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : 2 slices refers to the same time and underlying arrays differs !");
00457       ref=_slices[i];
00458     }
00459 }
00460 
00461 void MEDCouplingDefinitionTime::assign(const MEDCouplingDefinitionTime& other)
00462 {
00463   std::size_t sz=other._slices.size();
00464   _slices.resize(sz);
00465   for(std::size_t i=0;i<sz;i++)
00466     _slices[i]=other._slices[i]->copy();
00467 }
00468 
00469 bool MEDCouplingDefinitionTime::isEqual(const MEDCouplingDefinitionTime& other) const
00470 {
00471   std::size_t sz=_slices.size();
00472   if(sz!=other._slices.size())
00473     return false;
00474   for(std::size_t i=0;i<sz;i++)
00475     if(!_slices[i]->isEqual(*other._slices[i],_eps))
00476       return false;
00477   return true;
00478 }
00479 
00480 void MEDCouplingDefinitionTime::getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
00481 {
00482   std::vector<int> meshIds;
00483   std::vector<int> arrIds;
00484   std::vector<int> arrIdsInField;
00485   std::vector<int> fieldIds;
00486   getIdsOnTime(tm,meshIds,arrIds,arrIdsInField,fieldIds);
00487   meshId=meshIds.back();
00488   arrId=arrIds.back();
00489   arrIdInField=arrIdsInField.back();
00490   fieldId=fieldIds.back();
00491 }
00492 
00493 void MEDCouplingDefinitionTime::getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
00494 {
00495   std::vector<int> meshIds;
00496   std::vector<int> arrIds;
00497   std::vector<int> arrIdsInField;
00498   std::vector<int> fieldIds;
00499   getIdsOnTime(tm,meshIds,arrIds,arrIdsInField,fieldIds);
00500   meshId=meshIds.front();
00501   arrId=arrIds.front();
00502   arrIdInField=arrIdsInField.front();
00503   fieldId=fieldIds.front();
00504 }
00505 
00506 void MEDCouplingDefinitionTime::getIdsOnTime(double tm, std::vector<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception)
00507 {
00508   std::vector<int> ids;
00509   int id=0;
00510   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++,id++)
00511     if((*it)->isContaining(tm,_eps))
00512       ids.push_back(id);
00513   if(ids.empty())
00514     throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime::getIdsOnTime : No matching slice for such time !");
00515   std::size_t sz=ids.size();
00516   if(sz>2)
00517     throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime::getIdsOnTime : Too many slices match this time !");
00518   //
00519   meshIds.resize(sz);
00520   arrIds.resize(sz);
00521   arrIdsInField.resize(sz);
00522   fieldIds.resize(sz);
00523   for(std::size_t i=0;i<sz;i++)
00524     _slices[ids[i]]->getIdsOnTime(tm,_eps,meshIds[i],arrIds[i],arrIdsInField[i],fieldIds[i]);
00525 }
00526 
00527 std::vector<double> MEDCouplingDefinitionTime::getHotSpotsTime() const
00528 {
00529   std::vector<double> ret;
00530   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++)
00531     {
00532       std::vector<double> tmp;
00533       (*it)->getHotSpotsTime(tmp);
00534       if(!ret.empty())
00535         {
00536           if(fabs(ret.back()-tmp.front())>_eps)
00537             ret.insert(ret.end(),tmp.begin(),tmp.end());
00538           else
00539             ret.insert(ret.end(),tmp.begin()+1,tmp.end());
00540         }
00541       else
00542         ret.insert(ret.end(),tmp.begin(),tmp.end());
00543     }
00544   return ret;
00545 }
00546 
00547 void MEDCouplingDefinitionTime::appendRepr(std::ostream& stream) const
00548 {
00549   stream << "Time definition :\n";
00550   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++)
00551     {
00552       stream << " - ";
00553       (*it)->appendRepr(stream);
00554       stream << std::endl;
00555     }
00556 }
00557 
00558 void MEDCouplingDefinitionTime::getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const
00559 {
00560   int sz=(int)_slices.size();
00561   tinyInfoD.resize(1);
00562   tinyInfoD[0]=_eps;
00563   tinyInfoI.resize(3*sz+2);
00564   tinyInfoI[0]=sz;
00565   std::vector<int> coreData;
00566   for(int i=0;i<sz;i++)
00567     {
00568       std::vector<int> tmp1;
00569       std::vector<double> tmp2;
00570       tinyInfoI[i+2]=(int)_slices[i]->getTimeType();
00571       _slices[i]->getTinySerializationInformation(tmp1,tmp2);
00572       tinyInfoI[i+sz+2]=(int)tmp1.size();
00573       tinyInfoI[i+2*sz+2]=(int)tmp2.size();
00574       coreData.insert(coreData.end(),tmp1.begin(),tmp1.end());
00575       tinyInfoD.insert(tinyInfoD.end(),tmp2.begin(),tmp2.end());
00576     }
00577   tinyInfoI[1]=(int)coreData.size();
00578   tinyInfoI.insert(tinyInfoI.end(),coreData.begin(),coreData.end());
00579 }
00580 
00581 void MEDCouplingDefinitionTime::unserialize(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
00582 {
00583   int sz=tinyInfoI[0];
00584   _slices.resize(sz);
00585   _eps=tinyInfoD[0];
00586   int offset1=0;
00587   int offset2=1;
00588   for(int i=0;i<sz;i++)
00589     {
00590       TypeOfTimeDiscretization ty=(TypeOfTimeDiscretization) tinyInfoI[i+2];  
00591       int sz1=tinyInfoI[i+sz+2];
00592       int sz2=tinyInfoI[i+2*sz+2];
00593       std::vector<int> tmp1(tinyInfoI.begin()+3*sz+2+offset1,tinyInfoI.begin()+3*sz+2+offset1+sz1);
00594       std::vector<double> tmp2(tinyInfoD.begin()+offset2,tinyInfoD.begin()+offset2+sz2);
00595       MEDCouplingDefinitionTimeSlice *pt=MEDCouplingDefinitionTimeSlice::New(ty,tmp1,tmp2);
00596       _slices[i]=pt;
00597       offset1+=sz1;
00598       offset2+=sz2;
00599     }
00600 }
00601