]> SALOME platform Git repositories - modules/med.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Suppression of useless methods
[modules/med.git] / src / MEDLoader / MEDFileField.cxx
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 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25
26 #include "MEDCouplingFieldDouble.hxx"
27 #include "MEDCouplingFieldDiscretization.hxx"
28
29 #include "InterpKernelAutoPtr.hxx"
30 #include "CellModel.hxx"
31
32 #include <algorithm>
33 #include <iterator>
34
35 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
36 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
37 extern med_geometry_type typmainoeud[1];
38 extern med_geometry_type typmai3[32];
39
40 using namespace ParaMEDMEM;
41
42 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
43 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
44
45 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
46 {
47   return new MEDFileFieldLoc(fid,locName);
48 }
49
50 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
51 {
52   return new MEDFileFieldLoc(fid,id);
53 }
54
55 MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
56 {
57   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
58 }
59
60 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
61 {
62   med_geometry_type geotype;
63   med_geometry_type sectiongeotype;
64   int nsectionmeshcell;
65   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
66   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67   MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
68   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
69   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
70   _nb_node_per_cell=cm.getNumberOfNodes();
71   _ref_coo.resize(_dim*_nb_node_per_cell);
72   _gs_coo.resize(_dim*_nb_gauss_pt);
73   _w.resize(_nb_gauss_pt);
74   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
75 }
76
77 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
78 {
79   med_geometry_type geotype;
80   med_geometry_type sectiongeotype;
81   int nsectionmeshcell;
82   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
83   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
86   _name=locName;
87   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
88   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
89   _nb_node_per_cell=cm.getNumberOfNodes();
90   _ref_coo.resize(_dim*_nb_node_per_cell);
91   _gs_coo.resize(_dim*_nb_gauss_pt);
92   _w.resize(_nb_gauss_pt);
93   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
94 }
95
96 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
97                                  const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
98                                                                                                                                     _w(w)
99 {
100   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
101   _dim=cm.getDimension();
102   _nb_node_per_cell=cm.getNumberOfNodes();
103   _nb_gauss_pt=_w.size();
104 }
105
106 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
107 {
108   return new MEDFileFieldLoc(*this);
109 }
110
111 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
112 {
113   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
114 }
115
116 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
117 {
118   static const char OFF7[]="\n    ";
119   oss << "\"" << _name << "\"" << OFF7;
120   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
121   oss << "Dimension=" << _dim << OFF7;
122   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
123   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
124   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
125   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
126   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
127 }
128
129 void MEDFileFieldLoc::setName(const char *name)
130 {
131   _name=name;
132 }
133
134 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
135 {
136   if(_name!=other._name)
137     return false;
138   if(_dim!=other._dim)
139     return false;
140   if(_nb_gauss_pt!=other._nb_gauss_pt)
141     return false;
142   if(_nb_node_per_cell!=other._nb_node_per_cell)
143     return false;
144   if(_geo_type!=other._geo_type)
145     return false;
146   if(MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
147     return false;
148   if(MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
149     return false;
150   if(MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
151     return false;
152   
153   return true;
154 }
155
156 void MEDFileFieldLoc::writeLL(med_idt fid) const
157 {
158   MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
159 }
160
161 std::string MEDFileFieldLoc::repr() const
162 {
163   std::ostringstream oss; oss.precision(15);
164   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
165   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
166   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
167   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
168   oss << "\n  - Ref coords are : ";
169   int sz=_ref_coo.size();
170   if(sz%_dim==0)
171     {
172       int nbOfTuples=sz/_dim;
173       for(int i=0;i<nbOfTuples;i++)
174         {
175           oss << "(";
176           for(int j=0;j<_dim;j++)
177             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
178           oss << ") ";
179         }
180     }
181   else
182     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
183   oss << "\n  - Gauss coords in reference element : ";
184   sz=_gs_coo.size();
185   if(sz%_dim==0)
186     {
187       int nbOfTuples=sz/_dim;
188       for(int i=0;i<nbOfTuples;i++)
189         {
190           oss << "(";
191           for(int j=0;j<_dim;j++)
192             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
193           oss << ") ";
194         }
195     }
196   else
197     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
198   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
199   return oss.str();
200 }
201
202 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
203 {
204   _type=field->getTypeOfField();
205   _start=start;
206   switch(_type)
207     {
208     case ON_CELLS:
209       {
210         getArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
211         _end=_start+nbOfCells;
212         _nval=nbOfCells;
213         break;
214       }
215     case ON_GAUSS_NE:
216       {
217         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
218         const int *arrPtr=arr->getConstPointer();
219         getArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
220         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
221         _nval=nbOfCells;
222         break;
223       }
224     case ON_GAUSS_PT:
225       {
226         const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
227         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
228         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
229         if(!disc2)
230           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
231         const DataArrayInt *dai=disc2->getArrayOfDiscIds();
232         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
233         const int *dai2Ptr=dai2->getConstPointer();
234         int nbi=gsLoc.getWeights().size();
235         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
236         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
237         const int *da3Ptr=da3->getConstPointer();
238         if(da3->getNumberOfTuples()!=nbOfCells)
239           {//profile : for gauss even in NoProfile !!!
240             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
241             _profile=oss.str();
242             da3->setName(_profile.c_str());
243             glob.appendProfile(da3);
244           }
245         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
246         _nval=da3->getNbOfElems();
247         da4->alloc(_nval*nbi,1);
248         int *da4Ptr=da4->getPointer();
249         for(int i=0;i<_nval;i++)
250           {
251             int ref=dai2Ptr[offset+da3Ptr[i]];
252             for(int j=0;j<nbi;j++)
253               *da4Ptr++=ref+j;
254           }
255         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
256         _localization=oss2.str();
257         getArray()->setContigPartOfSelectedValues(_start,arrr,da4);
258         _end=_start+_nval*nbi;
259         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
260         break;
261       }
262     default:
263       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
264     }
265   start=_end;
266 }
267
268 /*!
269  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
270  * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
271  * \param [in] multiTypePfl is the end user profile specified in high level API
272  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
273  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
274  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
275  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
276  */
277 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
278 {
279   _profile.clear();
280   _type=field->getTypeOfField();
281   std::string pflName(multiTypePfl->getName());
282   std::ostringstream oss; oss << pflName;
283   if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); } else { oss << "_NODE"; }
284   if(locIds)
285     {
286       if(pflName.empty())
287         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
288       if(_type!=ON_GAUSS_PT)
289         {
290           locIds->setName(oss.str().c_str());
291           glob.appendProfile(locIds);
292           _profile=oss.str();
293         }
294     }
295   _start=start;
296   switch(_type)
297     {
298     case ON_NODES:
299       {
300          _nval=idsInPfl->getNumberOfTuples();
301          getArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
302          _end=_start+_nval;
303          break;
304       }
305     case ON_CELLS:
306       {
307         _nval=idsInPfl->getNumberOfTuples();
308         getArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
309         _end=_start+_nval;
310         break;
311       }
312     case ON_GAUSS_NE:
313       {
314         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
315         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
316         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
317         arr3->computeOffsets2();
318         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
319         int trueNval=tmp->getNumberOfTuples();
320         _nval=idsInPfl->getNumberOfTuples();
321         getArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
322         _end=_start+trueNval;
323         break;
324       }
325     case ON_GAUSS_PT:
326       {
327         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
328         if(!disc2)
329           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
330         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
331         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
332         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
333         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
334         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
335         //
336         MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
337         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
338         //
339         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
340         int trueNval=0;
341         for(const int *pt=da4->begin();pt!=da4->end();pt++)
342           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
343         tmp->alloc(trueNval,1);
344         int *tmpPtr=tmp->getPointer();
345         for(const int *pt=da4->begin();pt!=da4->end();pt++)
346           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
347             *tmpPtr++=j;
348         //
349         _nval=da4->getNumberOfTuples();
350         getArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
351         _end=_start+trueNval;
352         oss << "_loc_" << _loc_id;
353         if(locIds)
354           {
355             MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
356             da5->setName(oss.str().c_str());
357             glob.appendProfile(da5);
358             _profile=oss.str();
359           }
360         else
361           {
362             if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
363               {
364                 da3->setName(oss.str().c_str());
365                 glob.appendProfile(da3);
366                 _profile=oss.str();
367               }
368           }
369         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
370         _localization=oss2.str();
371         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
372         break;
373       }
374     default:
375       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
376     }
377   start=_end;
378 }
379
380 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
381 {
382   _start=start;
383   _nval=arrr->getNumberOfTuples();
384   getArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
385   _end=_start+_nval;
386   start=_end;
387 }
388
389 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
390 {
391   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
392 }
393
394 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
395 {
396   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
397 }
398
399 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
400 {
401   return new MEDFileFieldPerMeshPerTypePerDisc(other);
402 }
403
404 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
405 {
406   return _profile.capacity()+_localization.capacity()+5*sizeof(int);
407 }
408
409 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
410 {
411   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
412   ret->_father=father;
413   return ret.retn();
414 }
415
416 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
417 try:_type(atype),_father(fath)
418   {
419   }
420 catch(INTERP_KERNEL::Exception& e)
421 {
422   throw e;
423 }
424
425 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
426 {
427 }
428
429 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1)
430 {
431 }
432
433 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
434                                                                        _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
435 {
436 }
437
438 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
439 {
440   return _father;
441 }
442
443 void MEDFileFieldPerMeshPerTypePerDisc::prepareLoading(med_idt fid, int profileIt, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
444 {
445   INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
446   INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
447   std::string fieldName=nasc.getName();
448   std::string meshName=getMeshName();
449   int iteration=getIteration();
450   int order=getOrder();
451   TypeOfField type=getType();
452   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
453   int profilesize,nbi;
454   med_geometry_type mgeoti;
455   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
456   _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,profileIt,MED_COMPACT_PFLMODE,
457                                   pflname,&profilesize,locname,&nbi);
458   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
459   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
460   _start=start;
461   _end=start+_nval*nbi;
462   start=_end;
463   if(type==ON_CELLS && !_localization.empty())
464     {
465       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
466         setType(ON_GAUSS_PT);
467       else
468         {
469           setType(ON_GAUSS_NE);
470           _localization.clear();
471         }
472     }
473 }
474
475 void MEDFileFieldPerMeshPerTypePerDisc::finishLoading(med_idt fid, int profileIt, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
476 {
477   std::string fieldName=nasc.getName();
478   std::string meshName=getMeshName();
479   int iteration=getIteration();
480   int order=getOrder();
481   TypeOfField type=getType();
482   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
483   med_geometry_type mgeoti;
484   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
485   DataArray *arr=getArray();
486   DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
487   if(arrD)
488     {
489       double *startFeeding=arrD->getPointer()+_start*arrD->getNumberOfComponents();
490       MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
491                                  _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
492       return ;
493     }
494   DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
495   if(arrI)
496     {
497       int *startFeeding=arrI->getPointer()+_start*arrI->getNumberOfComponents();
498       MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
499                                  _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
500       return ;
501     }
502   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
503 }
504
505 /*!
506  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
507  */
508 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
509 {
510   int delta=_end-_start;
511   _start=newValueOfStart;
512   _end=_start+delta;
513 }
514
515 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
516 {
517   return _father->getIteration();
518 }
519
520 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
521 {
522   return _father->getOrder();
523 }
524
525 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
526 {
527   return _father->getTime();
528 }
529
530 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
531 {
532   return _father->getMeshName();
533 }
534
535 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
536 {
537   const char startLine[]="    ## ";
538   std::string startLine2(bkOffset,' ');
539   startLine2+=startLine;
540   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
541   oss << startLine2 << "Localization #" << id << "." << std::endl;
542   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
543   delete tmp;
544   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
545   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
546   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
547 }
548
549 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
550 {
551   return _type;
552 }
553
554 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
555 {
556   types.insert(_type);
557 }
558
559 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
560 {
561   _type=newType;
562 }
563
564 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
565 {
566   return _father->getGeoType();
567 }
568
569 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
570 {
571   return _father->getNumberOfComponents();
572 }
573
574 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
575 {
576   return _end-_start;
577 }
578
579 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getArray()
580 {
581   return _father->getArray();
582 }
583
584 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getArray() const
585 {
586   const MEDFileFieldPerMeshPerType *fath=_father;
587   return fath->getArray();
588 }
589
590 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
591 {
592   return _father->getInfo();
593 }
594
595 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
596 {
597   return _profile;
598 }
599
600 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
601 {
602   _profile=newPflName;
603 }
604
605 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
606 {
607   return _localization;
608 }
609
610 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
611 {
612   _localization=newLocName;
613 }
614
615 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
616 {
617   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
618     {
619       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
620         {
621           _profile=(*it2).second;
622           return;
623         }
624     }
625 }
626
627 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
628 {
629   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
630     {
631       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
632         {
633           _localization=(*it2).second;
634           return;
635         }
636     }
637 }
638
639 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
640 {
641   if(type!=_type)
642     return ;
643   dads.push_back(std::pair<int,int>(_start,_end));
644   geoTypes.push_back(getGeoType());
645   if(_profile.empty())
646     pfls.push_back(0);
647   else
648     {
649       pfls.push_back(glob->getProfile(_profile.c_str()));
650     }
651   if(_localization.empty())
652     locs.push_back(-1);
653   else
654     {
655       locs.push_back(glob->getLocalizationId(_localization.c_str()));
656     }
657 }
658
659 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
660 {
661   entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
662   startEntryId++;
663 }
664
665 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
666 {
667   TypeOfField type=getType();
668   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
669   med_geometry_type mgeoti;
670   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
671   const DataArray *arr=getArray();
672   if(!arr)
673     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
674   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
675   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
676   const unsigned char *locToWrite=0;
677   if(arrD)
678     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
679   else if(arrI)
680     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
681   else
682     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
683   MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
684                              MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
685                              locToWrite);
686 }
687
688 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
689 {
690   type=_type;
691   pfl=_profile;
692   loc=_localization;
693   dad.first=_start; dad.second=_end;
694 }
695
696 /*!
697  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
698  *             This code corresponds to the distribution of types in the corresponding mesh.
699  * \param [out] ptToFill memory zone where the output will be stored.
700  * \return the size of data pushed into output param \a ptToFill
701  */
702 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
703 {
704   _loc_id=offset;
705   std::ostringstream oss;
706   std::size_t nbOfType=codeOfMesh.size()/3;
707   int found=-1;
708   for(std::size_t i=0;i<nbOfType && found==-1;i++)
709     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
710       found=(int)i;
711   if(found==-1)
712     {
713       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
714       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
715       throw INTERP_KERNEL::Exception(oss.str().c_str());
716     }
717   int *work=ptToFill;
718   if(_profile.empty())
719     {
720       if(_nval!=codeOfMesh[3*found+1])
721         {
722           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
723           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
724           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
725           throw INTERP_KERNEL::Exception(oss.str().c_str());
726         }
727       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
728         *work++=ii;
729     }
730   else
731     {
732       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
733       if(pfl->getNumberOfTuples()!=_nval)
734         {
735           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
736           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
737           oss << _nval;
738           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
739           throw INTERP_KERNEL::Exception(oss.str().c_str());
740         }
741       int offset2=codeOfMesh[3*found+2];
742       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
743         {
744           if(*pflId<codeOfMesh[3*found+1])
745             *work++=offset2+*pflId;
746         }
747     }
748   return _nval;
749 }
750
751 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
752 {
753   for(int i=_start;i<_end;i++)
754     *ptToFill++=i;
755   return _end-_start;
756 }
757
758 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
759 {
760   switch(type)
761     {
762     case ON_CELLS:
763       return -2;
764     case ON_GAUSS_NE:
765       return -1;
766     case ON_GAUSS_PT:
767       return locId;
768     default:
769       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
770     }
771 }
772
773 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
774 {
775   int id=0;
776   std::map<std::pair<std::string,TypeOfField>,int> m;
777   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
778   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
779     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
780       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
781   ret.resize(id);
782   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
783     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
784   return ret;
785 }
786
787 /*!
788  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
789  * 
790  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
791  * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
792  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
793  * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
794  * \param [in,out] glob if necessary by the method, new profiles can be added to it
795  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
796  * \param [out] result All new entries will be appended on it.
797  * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
798  */
799 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
800                                                        const DataArrayInt *explicitIdsInMesh,
801                                                        const std::vector<int>& newCode,
802                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
803                                                        std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
804 {
805   if(entriesOnSameDisc.empty())
806     return false;
807   TypeOfField type=entriesOnSameDisc[0]->getType();
808   int szEntities=0,szTuples=0;
809   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
810     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
811   int nbi=szTuples/szEntities;
812   if(szTuples%szEntities!=0)
813     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
814   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
815   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
816   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
817   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
818   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
819   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
820   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
821   int id=0;
822   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
823     {
824       int startOfEltIdOfChunk=(*it)->_start;
825       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
826       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
827       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
828       //
829       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
830       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
831       //
832       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
833       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
834     }
835   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
836   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
837   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
838   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
839   //
840   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
841   //
842   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
843   arrPart->renumberInPlace(renumTupleIds->begin());
844   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
845   bool ret=false;
846   const int *idIt=diffVals->begin();
847   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
848   int offset2=0;
849   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
850     {
851       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
852       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
853       int nbEntityElts=subIds->getNumberOfTuples();
854       bool ret2;
855       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
856         NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
857                                     offset+offset2,
858                                     li,glob,ret2);
859       ret=ret || ret2;
860       result.push_back(eltToAdd);
861       offset2+=nbEntityElts*nbi;
862     }
863   ret=ret || li.empty();
864   return ret;
865 }
866
867 /*!
868  * \param [in] typeF type of field of new chunk
869  * \param [in] geoType the geometric type of the chunk
870  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
871  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
872  * \param [in] nbi number of integration points
873  * \param [in] offset The offset in the **global array of data**.
874  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
875  *                 to the new chunk to create.
876  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
877  * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
878  *              and corresponding entry erased from \a entriesOnSameDisc.
879  * \return a newly allocated chunk
880  */
881 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
882                                                                                                   bool isPfl, int nbi, int offset,
883                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
884                                                                                                   MEDFileFieldGlobsReal& glob,
885                                                                                                   bool &notInExisting) throw(INTERP_KERNEL::Exception)
886 {
887   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
888   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
889   for(;it!=entriesOnSameDisc.end();it++)
890     {
891       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
892         {
893           if(!isPfl)
894             {
895               if((*it)->_profile.empty())
896                 break;
897               else
898                 if(!(*it)->_profile.empty())
899                   {
900                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
901                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
902                       break;
903                   }
904             }
905         }
906     }
907   if(it==entriesOnSameDisc.end())
908     {
909       notInExisting=true;
910       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
911       ret->_type=typeF;
912       ret->_loc_id=(int)geoType;
913       ret->_nval=nbMeshEntities;
914       ret->_start=offset;
915       ret->_end=ret->_start+ret->_nval*nbi;
916       if(isPfl)
917         {
918           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
919           glob.appendProfile(idsOfMeshElt);
920           ret->_profile=idsOfMeshElt->getName();
921         }
922       //tony treatment of localization
923       return ret;
924     }
925   else
926     {
927       notInExisting=false;
928       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
929       ret->_loc_id=(int)geoType;
930       ret->setNewStart(offset);
931       entriesOnSameDisc.erase(it);
932       return ret;
933     }
934   
935 }
936
937 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
938 {
939   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
940 }
941
942 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
943 {
944   return new MEDFileFieldPerMeshPerType(fath,geoType);
945 }
946
947 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
948 {
949   std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
950   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
951     ret+=(*it)->getHeapMemorySize();
952   return ret;
953 }
954
955 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
956 {
957   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
958   ret->_father=father;
959   std::size_t i=0;
960   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
961     {
962       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
963         ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
964     }
965   return ret.retn();
966 }
967
968 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
969 {
970   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
971   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
972     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
973 }
974
975 /*!
976  * This method is the most general one. No optimization is done here.
977  * \param [in] multiTypePfl is the end user profile specified in high level API
978  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
979  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
980  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
981  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
982  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
983  */
984 void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
985 {
986   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
987   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
988     _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
989 }
990
991 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
992 {
993   _field_pm_pt_pd.resize(1);
994   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
995   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
996 }
997
998 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
999 {
1000   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1001   //
1002   _field_pm_pt_pd.resize(1);
1003   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1004   _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1005 }
1006
1007 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1008 {
1009   TypeOfField type=field->getTypeOfField();
1010   if(type!=ON_GAUSS_PT)
1011     {
1012       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1013       int sz=_field_pm_pt_pd.size();
1014       bool found=false;
1015       for(int j=0;j<sz && !found;j++)
1016         {
1017           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1018             {
1019               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1020               found=true;
1021             }
1022         }
1023       if(!found)
1024         {
1025           _field_pm_pt_pd.resize(sz+1);
1026           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1027         }
1028       std::vector<int> ret(1,0);
1029       return ret;
1030     }
1031   else
1032     {
1033       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1034       int sz2=ret2.size();
1035       std::vector<int> ret3(sz2);
1036       int k=0;
1037       for(int i=0;i<sz2;i++)
1038         {
1039           int sz=_field_pm_pt_pd.size();
1040           int locIdToFind=ret2[i];
1041           bool found=false;
1042           for(int j=0;j<sz && !found;j++)
1043             {
1044               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1045                 {
1046                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1047                   ret3[k++]=j;
1048                   found=true;
1049                 }
1050             }
1051           if(!found)
1052             {
1053               _field_pm_pt_pd.resize(sz+1);
1054               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1055               ret3[k++]=sz;
1056             }
1057         }
1058       return ret3;
1059     }
1060 }
1061
1062 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1063 {
1064   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1065   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1066   if(!disc2)
1067     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1068   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1069   if(!da)
1070     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1071   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1072   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1073   if(retTmp->presenceOfValue(-1))
1074     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1075   std::vector<int> ret(retTmp->begin(),retTmp->end());
1076   return ret;
1077 }
1078
1079 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1080 {
1081   TypeOfField type=field->getTypeOfField();
1082   if(type!=ON_GAUSS_PT)
1083     {
1084       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1085       int sz=_field_pm_pt_pd.size();
1086       bool found=false;
1087       for(int j=0;j<sz && !found;j++)
1088         {
1089           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1090             {
1091               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1092               found=true;
1093             }
1094         }
1095       if(!found)
1096         {
1097           _field_pm_pt_pd.resize(sz+1);
1098           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1099         }
1100       std::vector<int> ret(1,0);
1101       return ret;
1102     }
1103   else
1104     {
1105       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1106       int sz2=ret2.size();
1107       std::vector<int> ret3(sz2);
1108       int k=0;
1109       for(int i=0;i<sz2;i++)
1110         {
1111           int sz=_field_pm_pt_pd.size();
1112           int locIdToFind=ret2[i];
1113           bool found=false;
1114           for(int j=0;j<sz && !found;j++)
1115             {
1116               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1117                 {
1118                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1119                   ret3[k++]=j;
1120                   found=true;
1121                 }
1122             }
1123           if(!found)
1124             {
1125               _field_pm_pt_pd.resize(sz+1);
1126               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1127               ret3[k++]=sz;
1128             }
1129         }
1130       return ret3;
1131     }
1132 }
1133
1134 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1135 {
1136   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1137   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1138   if(!disc2)
1139     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1140   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1141   if(!da)
1142     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1143   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1144   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1145   if(retTmp->presenceOfValue(-1))
1146     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1147   std::vector<int> ret(retTmp->begin(),retTmp->end());
1148   return ret;
1149 }
1150
1151 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1152 {
1153   return _father;
1154 }
1155
1156 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1157 {
1158   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1159   int curDim=(int)cm.getDimension();
1160   dim=std::max(dim,curDim);
1161 }
1162
1163 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1164 {
1165   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1166     {
1167       (*it)->fillTypesOfFieldAvailable(types);
1168     }
1169 }
1170
1171 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
1172 {
1173   int sz=_field_pm_pt_pd.size();
1174   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1175   for(int i=0;i<sz;i++)
1176     {
1177       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1178     }
1179 }
1180
1181 int MEDFileFieldPerMeshPerType::getIteration() const
1182 {
1183   return _father->getIteration();
1184 }
1185
1186 int MEDFileFieldPerMeshPerType::getOrder() const
1187 {
1188   return _father->getOrder();
1189 }
1190
1191 double MEDFileFieldPerMeshPerType::getTime() const
1192 {
1193   return _father->getTime();
1194 }
1195
1196 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1197 {
1198   return _father->getMeshName();
1199 }
1200
1201 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1202 {
1203   const char startLine[]="  ## ";
1204   std::string startLine2(bkOffset,' ');
1205   std::string startLine3(startLine2);
1206   startLine3+=startLine;
1207   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1208     {
1209       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1210       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1211     }
1212   else
1213     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1214   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1215   int i=0;
1216   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1217     {
1218       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1219       if(cur)
1220         cur->simpleRepr(bkOffset,oss,i);
1221       else
1222         {
1223           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1224         }
1225     }
1226 }
1227
1228 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1229 {
1230   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1231     {
1232       globalSz+=(*it)->getNumberOfTuples();
1233     }
1234   nbOfEntries+=(int)_field_pm_pt_pd.size();
1235 }
1236
1237 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1238 {
1239   return _geo_type;
1240 }
1241
1242
1243 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1244 {
1245   return _father->getNumberOfComponents();
1246 }
1247
1248 DataArray *MEDFileFieldPerMeshPerType::getArray()
1249 {
1250   return _father->getArray();
1251 }
1252
1253 const DataArray *MEDFileFieldPerMeshPerType::getArray() const
1254 {
1255   const MEDFileFieldPerMesh *fath=_father;
1256   return fath->getArray();
1257 }
1258
1259 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1260 {
1261   return _father->getInfo();
1262 }
1263
1264 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1265 {
1266   std::vector<std::string> ret;
1267   std::set<std::string> ret2;
1268   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1269     {
1270       std::string tmp=(*it1)->getProfile();
1271       if(!tmp.empty())
1272         if(ret2.find(tmp)==ret2.end())
1273           {
1274             ret.push_back(tmp);
1275             ret2.insert(tmp);
1276           }
1277     }
1278   return ret;
1279 }
1280
1281 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1282 {
1283   std::vector<std::string> ret;
1284   std::set<std::string> ret2;
1285   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1286     {
1287       std::string tmp=(*it1)->getLocalization();
1288       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1289         if(ret2.find(tmp)==ret2.end())
1290           {
1291             ret.push_back(tmp);
1292             ret2.insert(tmp);
1293           }
1294     }
1295   return ret;
1296 }
1297
1298 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1299 {
1300   std::vector<std::string> ret;
1301   std::set<std::string> ret2;
1302   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1303     {
1304       std::string tmp=(*it1)->getProfile();
1305       if(!tmp.empty())
1306         ret.push_back(tmp);
1307     }
1308   return ret;
1309 }
1310
1311 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1312 {
1313   std::vector<std::string> ret;
1314   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1315     {
1316       std::string tmp=(*it1)->getLocalization();
1317       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1318         ret.push_back(tmp);
1319     }
1320   return ret;
1321 }
1322
1323 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1324 {
1325   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1326     (*it1)->changePflsRefsNamesGen(mapOfModif);
1327 }
1328
1329 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1330 {
1331   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1332     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1333 }
1334
1335 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1336 {
1337   if(_field_pm_pt_pd.empty())
1338     {
1339       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1340       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1341       throw INTERP_KERNEL::Exception(oss.str().c_str());
1342     }
1343   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1344     return _field_pm_pt_pd[locId];
1345   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1346   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1347   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1348   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1349   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1350 }
1351
1352 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1353 {
1354   if(_field_pm_pt_pd.empty())
1355     {
1356       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1357       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1358       throw INTERP_KERNEL::Exception(oss.str().c_str());
1359     }
1360   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1361     return _field_pm_pt_pd[locId];
1362   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1363   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1364   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1365   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1366   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1367 }
1368
1369 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1370 {
1371   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1372     {
1373       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1374       if(meshDim!=(int)cm.getDimension())
1375         return ;
1376     }
1377   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1378     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1379 }
1380
1381 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1382 {
1383   int i=0;
1384   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1385     {
1386       (*it)->fillValues(i,startEntryId,entries);
1387     }
1388 }
1389
1390 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1391 {
1392   _field_pm_pt_pd=leaves;
1393   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1394     (*it)->setFather(this);
1395 }
1396
1397 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1398 {
1399 }
1400
1401 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1402 {
1403   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1404   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1405   med_geometry_type mgeoti;
1406   med_entity_type menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1407   int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1408   _field_pm_pt_pd.resize(nbProfiles);
1409   for(int i=0;i<nbProfiles;i++)
1410     {
1411       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1412     }
1413 }
1414
1415 void MEDFileFieldPerMeshPerType::prepareLoading(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1416 {
1417   int pflId=0;
1418   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1419     {
1420       (*it)->prepareLoading(fid,pflId+1,start,nasc);//tony
1421     }
1422 }
1423
1424 void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1425 {
1426   int pflId=0;
1427   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,pflId++)
1428     {
1429       (*it)->finishLoading(fid,pflId+1,nasc);//tony
1430     }
1431 }
1432
1433 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1434 {
1435   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1436     {
1437       (*it)->copyOptionsFrom(*this);
1438       (*it)->writeLL(fid,nasc);
1439     }
1440 }
1441
1442 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1443 {
1444   switch(ikType)
1445     {
1446     case ON_CELLS:
1447       medfGeoType=typmai3[(int)ikGeoType];
1448       return MED_CELL;
1449     case ON_NODES:
1450       medfGeoType=MED_NONE;
1451       return MED_NODE;
1452     case ON_GAUSS_NE:
1453       medfGeoType=typmai3[(int)ikGeoType];
1454       return MED_NODE_ELEMENT;
1455     case ON_GAUSS_PT:
1456       medfGeoType=typmai3[(int)ikGeoType];
1457       return MED_CELL;
1458     default:
1459       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1460     }
1461   return MED_UNDEF_ENTITY_TYPE;
1462 }
1463
1464 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1465 {
1466   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1467 }
1468
1469 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1470 {
1471   return new MEDFileFieldPerMesh(fath,mesh);
1472 }
1473
1474 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1475 {
1476   std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1477   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1478     if((const MEDFileFieldPerMeshPerType *)*it)
1479       ret+=(*it)->getHeapMemorySize();
1480   return ret;
1481 }
1482
1483 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1484 {
1485   MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1486   ret->_father=father;
1487   std::size_t i=0;
1488   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1489     {
1490       if((const MEDFileFieldPerMeshPerType *)*it)
1491         ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1492     }
1493   return ret.retn();
1494 }
1495
1496 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1497 {
1498   std::string startLine(bkOffset,' ');
1499   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1500   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1501   int i=0;
1502   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1503     {
1504       const MEDFileFieldPerMeshPerType *cur=*it;
1505       if(cur)
1506         cur->simpleRepr(bkOffset,oss,i);
1507       else
1508         {
1509           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1510         }
1511     }
1512 }
1513
1514 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1515 {
1516   _mesh_name=mesh->getName();
1517   mesh->getTime(_mesh_iteration,_mesh_order);
1518 }
1519
1520 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1521 {
1522   int nbOfTypes=code.size()/3;
1523   int offset=0;
1524   for(int i=0;i<nbOfTypes;i++)
1525     {
1526       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1527       int nbOfCells=code[3*i+1];
1528       int pos=addNewEntryIfNecessary(type);
1529       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1530       offset+=nbOfCells;
1531     }
1532 }
1533
1534 /*!
1535  * This method is the most general one. No optimization is done here.
1536  * \param [in] multiTypePfl is the end user profile specified in high level API
1537  * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1538  * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1539  * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1540  * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1541  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1542  */
1543 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1544 {
1545   int nbOfTypes=code.size()/3;
1546   for(int i=0;i<nbOfTypes;i++)
1547     {
1548       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1549       int pos=addNewEntryIfNecessary(type);
1550       DataArrayInt *pfl=0;
1551       if(code[3*i+2]!=-1)
1552         pfl=idsPerType[code[3*i+2]];
1553       int nbOfTupes2=code2.size()/3;
1554       int found=0;
1555       for(;found<nbOfTupes2;found++)
1556         if(code[3*i]==code2[3*found])
1557           break;
1558       if(found==nbOfTupes2)
1559         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1560       _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1561     }
1562 }
1563
1564 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1565 {
1566   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1567   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1568 }
1569
1570 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1571 {
1572   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1573   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1574 }
1575
1576 void MEDFileFieldPerMesh::prepareLoading(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1577 {
1578   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1579     (*it)->prepareLoading(fid,start,nasc);
1580 }
1581
1582 void MEDFileFieldPerMesh::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1583 {
1584   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1585     (*it)->finishLoading(fid,nasc);
1586 }
1587
1588 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1589 {
1590   int nbOfTypes=_field_pm_pt.size();
1591   for(int i=0;i<nbOfTypes;i++)
1592     {
1593       _field_pm_pt[i]->copyOptionsFrom(*this);
1594       _field_pm_pt[i]->writeLL(fid,nasc);
1595     }
1596 }
1597
1598 void MEDFileFieldPerMesh::getDimension(int& dim) const
1599 {
1600   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1601     (*it)->getDimension(dim);
1602 }
1603
1604 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1605 {
1606   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1607     (*it)->fillTypesOfFieldAvailable(types);
1608 }
1609
1610 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const throw(INTERP_KERNEL::Exception)
1611 {
1612   int sz=_field_pm_pt.size();
1613   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1614   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1615   for(int i=0;i<sz;i++)
1616     {
1617       types[i]=_field_pm_pt[i]->getGeoType();
1618       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1619     }
1620   return ret;
1621 }
1622
1623 double MEDFileFieldPerMesh::getTime() const
1624 {
1625   int tmp1,tmp2;
1626   return _father->getTime(tmp1,tmp2);
1627 }
1628
1629 int MEDFileFieldPerMesh::getIteration() const
1630 {
1631   return _father->getIteration();
1632 }
1633
1634 int MEDFileFieldPerMesh::getOrder() const
1635 {
1636   return _father->getOrder();
1637 }
1638
1639 int MEDFileFieldPerMesh::getNumberOfComponents() const
1640 {
1641   return _father->getNumberOfComponents();
1642 }
1643
1644 DataArray *MEDFileFieldPerMesh::getArray()
1645 {
1646   if(!_father)
1647     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
1648   return _father->getOrCreateAndGetArray();
1649 }
1650
1651 const DataArray *MEDFileFieldPerMesh::getArray() const
1652 {
1653   if(!_father)
1654     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getArray : no father ! internal error !");
1655   return _father->getOrCreateAndGetArray();
1656 }
1657
1658 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1659 {
1660   return _father->getInfo();
1661 }
1662
1663 /*!
1664  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1665  * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
1666  * It returns 2 output vectors :
1667  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1668  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1669  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1670  */
1671 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
1672 {
1673   int notNullPflsSz=0;
1674   int nbOfArrs=geoTypes.size();
1675   for(int i=0;i<nbOfArrs;i++)
1676     if(pfls[i])
1677       notNullPflsSz++;
1678   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1679   int nbOfDiffGeoTypes=geoTypes3.size();
1680   code.resize(3*nbOfDiffGeoTypes);
1681   notNullPfls.resize(notNullPflsSz);
1682   notNullPflsSz=0;
1683   int j=0;
1684   for(int i=0;i<nbOfDiffGeoTypes;i++)
1685     {
1686       int startZone=j;
1687       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1688       std::vector<const DataArrayInt *> notNullTmp;
1689       if(pfls[j])
1690         notNullTmp.push_back(pfls[j]);
1691       j++;
1692       for(;j<nbOfArrs;j++)
1693         if(geoTypes[j]==refType)
1694           {
1695             if(pfls[j])
1696               notNullTmp.push_back(pfls[j]);
1697           }
1698         else
1699           break;
1700       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1701       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1702       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1703       code[3*i]=(int)refType;
1704       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1705       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1706       if(notNullTmp.empty())
1707         code[3*i+2]=-1;
1708       else
1709         {
1710           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1711           code[3*i+2]=notNullPflsSz++;
1712         }
1713     }
1714 }
1715
1716 /*!
1717  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1718  */
1719 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception)
1720 {
1721   int sz=dads.size();
1722   int ret=0;
1723   for(int i=0;i<sz;i++)
1724     {
1725       if(locs[i]==-1)
1726         {
1727           if(type!=ON_GAUSS_NE)
1728             ret+=dads[i].second-dads[i].first;
1729           else
1730             {
1731               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1732               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1733             }
1734         }
1735       else
1736         {
1737           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1738           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1739         }
1740     }
1741   return ret;
1742 }
1743
1744 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1745 {
1746   std::vector<std::string> ret;
1747   std::set<std::string> ret2;
1748   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1749     {
1750       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1751       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1752         if(ret2.find(*it2)==ret2.end())
1753           {
1754             ret.push_back(*it2);
1755             ret2.insert(*it2);
1756           }
1757     }
1758   return ret;
1759 }
1760
1761 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1762 {
1763   std::vector<std::string> ret;
1764   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1765     {
1766       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1767       ret.insert(ret.end(),tmp.begin(),tmp.end());
1768     }
1769   return ret;
1770 }
1771
1772 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1773 {
1774   std::vector<std::string> ret;
1775   std::set<std::string> ret2;
1776   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1777     {
1778       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1779       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1780         if(ret2.find(*it2)==ret2.end())
1781           {
1782             ret.push_back(*it2);
1783             ret2.insert(*it2);
1784           }
1785     }
1786   return ret;
1787 }
1788
1789 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1790 {
1791   std::vector<std::string> ret;
1792   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1793     {
1794       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1795       ret.insert(ret.end(),tmp.begin(),tmp.end());
1796     }
1797   return ret;
1798 }
1799
1800 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1801 {
1802   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1803     {
1804       if((*it).first==_mesh_name)
1805         {
1806           _mesh_name=(*it).second;
1807           return true;
1808         }
1809     }
1810   return false;
1811 }
1812
1813 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1814                                                       MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1815 {
1816   if(_mesh_name!=meshName)
1817     return false;
1818   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1819   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1820   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1821   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1822   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1823   getUndergroundDataArrayExt(entries);
1824   DataArray *arr0=getArray();//tony
1825   if(!arr0)
1826     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1827   DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1828   if(!arr0)
1829     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1830   int sz=0;
1831   if(!arr)
1832     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1833   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1834     {
1835       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1836         {
1837           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1838           sz+=(*it).second.second-(*it).second.first;
1839         }
1840       else
1841         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1842     }
1843   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1844   ////////////////////
1845   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1846   int *workI2=explicitIdsOldInMesh->getPointer();
1847   int sz1=0,sz2=0,sid=1;
1848   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1849   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1850   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1851     {
1852       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1853       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1854       int *workI=explicitIdsOldInArr->getPointer();
1855       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1856         {
1857           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1858           (*itL2)->setLocId(sz2);
1859           (*itL2)->_tmp_work1=(*itL2)->getStart();
1860           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1861         }
1862       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1863     }
1864   explicitIdsOldInMesh->reAlloc(sz2);
1865   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1866   ////////////////////
1867   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1868   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1869   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1870   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1871     {
1872       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1873       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1874       otherEntriesNew.back()->setLocId((*it)->getGeoType());
1875     }
1876   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1877   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1878   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1879     {
1880       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1881       int newStart=elt->getLocId();
1882       elt->setLocId((*it)->getGeoType());
1883       elt->setNewStart(newStart);
1884       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1885       entriesKeptNew.push_back(elt);
1886       entriesKeptNew2.push_back(elt);
1887     }
1888   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1889   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1890   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1891   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1892   bool ret=false;
1893   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1894     {
1895       sid=0;
1896       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1897         {
1898           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1899           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1900           }*/
1901       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1902                                                             glob,arr2,otherEntriesNew) || ret;
1903     }
1904   if(!ret)
1905     return false;
1906   // Assign new dispatching
1907   assignNewLeaves(otherEntriesNew);
1908   arr->cpyFrom(*arr2);
1909   return true;
1910 }
1911
1912 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1913 {
1914   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1915   for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1916     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1917   //
1918   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1919   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1920   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1921   for(;it1!=types.end();it1++,it2++)
1922     {
1923       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1924       elt->setLeaves((*it1).second);
1925       *it2=elt;
1926     }
1927   _field_pm_pt=fieldPmPt;
1928 }
1929
1930 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1931 {
1932   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1933     (*it)->changePflsRefsNamesGen(mapOfModif);
1934 }
1935
1936 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1937 {
1938   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1939     (*it)->changeLocsRefsNamesGen(mapOfModif);
1940 }
1941
1942 /*!
1943  * \param [in] mesh is the whole mesh
1944  */
1945 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1946 {
1947   if(_field_pm_pt.empty())
1948     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
1949   //
1950   std::vector< std::pair<int,int> > dads;
1951   std::vector<const DataArrayInt *> pfls;
1952   std::vector<DataArrayInt *> notNullPflsPerGeoType;
1953   std::vector<int> locs,code;
1954   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
1955   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1956     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
1957   // Sort by types
1958   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
1959   if(code.empty())
1960     {
1961       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
1962       throw INTERP_KERNEL::Exception(oss.str().c_str());
1963     }
1964   //
1965   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1966   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
1967   if(type!=ON_NODES)
1968     {
1969       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
1970       if(!arr)
1971         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
1972       else
1973         {
1974           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
1975           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
1976         }
1977     }
1978   else
1979     {
1980       if(code.size()!=3)
1981         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
1982       int nb=code[1];
1983       if(code[2]==-1)
1984         {
1985           if(nb!=mesh->getNumberOfNodes())
1986             {
1987               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
1988               oss << " nodes in mesh !";
1989               throw INTERP_KERNEL::Exception(oss.str().c_str());
1990             }
1991           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
1992         }
1993       else
1994         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
1995     }
1996 }
1997
1998 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1999 {
2000   if(_field_pm_pt.empty())
2001     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2002   //
2003   std::vector<std::pair<int,int> > dads;
2004   std::vector<const DataArrayInt *> pfls;
2005   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2006   std::vector<int> locs,code;
2007   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2008   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2009     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2010   // Sort by types
2011   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2012   if(code.empty())
2013     {
2014       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2015       throw INTERP_KERNEL::Exception(oss.str().c_str());
2016     }
2017   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2018   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2019   if(type!=ON_NODES)
2020     {
2021       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2022       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2023     }
2024   else
2025     {
2026       if(code.size()!=3)
2027         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2028       int nb=code[1];
2029       if(code[2]==-1)
2030         {
2031           if(nb!=mesh->getNumberOfNodes())
2032             {
2033               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2034               oss << " nodes in mesh !";
2035               throw INTERP_KERNEL::Exception(oss.str().c_str());
2036             }
2037         }
2038       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2039     }
2040   //
2041   return 0;
2042 }
2043
2044 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2045 {
2046   int globalSz=0;
2047   int nbOfEntries=0;
2048   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2049     {
2050       (*it)->getSizes(globalSz,nbOfEntries);
2051     }
2052   entries.resize(nbOfEntries);
2053   nbOfEntries=0;
2054   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2055     {
2056       (*it)->fillValues(nbOfEntries,entries);
2057     }
2058 }
2059
2060 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2061 {
2062   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2063     {
2064       if((*it)->getGeoType()==typ)
2065         return (*it)->getLeafGivenLocId(locId);
2066     }
2067   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2068   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2069   oss << "Possiblities are : ";
2070   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2071     {
2072       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2073       oss << "\"" << cm2.getRepr() << "\", ";
2074     }
2075   throw INTERP_KERNEL::Exception(oss.str().c_str());
2076 }
2077
2078 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2079 {
2080   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2081     {
2082       if((*it)->getGeoType()==typ)
2083         return (*it)->getLeafGivenLocId(locId);
2084     }
2085   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2086   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2087   oss << "Possiblities are : ";
2088   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2089     {
2090       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2091       oss << "\"" << cm2.getRepr() << "\", ";
2092     }
2093   throw INTERP_KERNEL::Exception(oss.str().c_str());
2094 }
2095
2096 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2097 {
2098   int i=0;
2099   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2100   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2101   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2102     {
2103       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2104       if(type==curType)
2105         return i;
2106       else
2107         {
2108           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2109           if(pos>pos2)
2110             it2=it+1;
2111         }
2112     }
2113   int ret=std::distance(_field_pm_pt.begin(),it2);
2114   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2115   return ret;
2116 }
2117
2118 /*!
2119  * 'dads' and 'locs' input parameters have the same number of elements
2120  * \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
2121  */
2122 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2123                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2124                                                          const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2125 {
2126   isPfl=false;
2127   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2128   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2129   MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
2130   const std::vector<std::string>& infos=getInfo();
2131   da->setInfoOnComponents(infos);
2132   da->setName("");
2133   if(type==ON_GAUSS_PT)
2134     {
2135       int offset=0;
2136       int nbOfArrs=dads.size();
2137       for(int i=0;i<nbOfArrs;i++)
2138         {
2139           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2140           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2141           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2142           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2143           di->alloc(nbOfElems,1);
2144           di->iota(offset);
2145           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2146           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2147           offset+=nbOfElems;
2148         }
2149     }
2150   arrOut=da;
2151   return ret.retn();
2152 }
2153
2154 /*!
2155  * This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES.
2156  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2157  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2158  * The order of cells in the returned field is those imposed by the profile.
2159  * \param [in] mesh is the global mesh.
2160  */
2161 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2162                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2163                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2164                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2165 {
2166   if(da->isIdentity())
2167     {
2168       int nbOfTuples=da->getNumberOfTuples();
2169       if(nbOfTuples==mesh->getNumberOfCells())
2170         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2171     }
2172   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2173   m2->setName(mesh->getName());
2174   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2175   isPfl=true;
2176   return ret.retn();
2177 }
2178
2179 /*!
2180  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2181  */
2182 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2183                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2184                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2185 {
2186   if(da->isIdentity())
2187     {
2188       int nbOfTuples=da->getNumberOfTuples();
2189       if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2190         return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2191     }
2192   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2193   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2194   if(meshu)
2195     {
2196       if(meshu->getNodalConnectivity()==0)
2197         {
2198           MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2199           int nb=da->getNbOfElems();
2200           const int *ptr=da->getConstPointer();
2201           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2202           meshuc->allocateCells(nb);
2203           for(int i=0;i<nb;i++)
2204             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2205           meshuc->finishInsertingCells();
2206           ret->setMesh(meshuc);
2207           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2208           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2209           disc->checkCoherencyBetween(meshuc,arrOut);
2210           return ret.retn();
2211         }
2212     }
2213   //
2214   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2215   isPfl=true;
2216   DataArrayInt *arr2=0;
2217   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2218   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2219   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2220   int nnodes=mesh2->getNumberOfNodes();
2221   if(nnodes==(int)da->getNbOfElems())
2222     {
2223       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2224       arrOut->renumberInPlace(da3->getConstPointer());
2225       mesh2->setName(mesh->getName());
2226       ret->setMesh(mesh2);
2227       return ret.retn();
2228     }
2229   else
2230     {
2231       std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
2232       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2233       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2234       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2235       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2236       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2237       throw INTERP_KERNEL::Exception(oss.str().c_str());
2238     }
2239   return 0;
2240 }
2241
2242 /*!
2243  * This method is the most light method of field retrieving.
2244  */
2245 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2246 {
2247   if(!pflIn)
2248     {
2249       pflOut=DataArrayInt::New();
2250       pflOut->alloc(nbOfElems,1);
2251       pflOut->iota(0);
2252     }
2253   else
2254     {
2255       pflOut=const_cast<DataArrayInt*>(pflIn);
2256       pflOut->incrRef();
2257     }
2258   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2259   MEDCouplingAutoRefCountObjectPtr<DataArray> da=getArray()->selectByTupleRanges(dads);
2260   const std::vector<std::string>& infos=getInfo();
2261   int nbOfComp=infos.size();
2262   for(int i=0;i<nbOfComp;i++)
2263     da->setInfoOnComponent(i,infos[i].c_str());
2264   safePfl->incrRef();
2265   return da.retn();
2266 }
2267
2268 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2269                                                                                                                                                                                                                  _mesh_csit(meshCsit),_father(fath)
2270 {
2271   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2272   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2273   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2274   for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2275     {
2276       int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL,typmai[i],_mesh_csit,meshName,pflName,locName);
2277       if(nbProfile>0)
2278         {
2279           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2280           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2281         }
2282       nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2283       if(nbProfile>0)
2284         {
2285           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_GAUSS_NE,typmai2[i],nasc));
2286           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2287         }
2288     }
2289   int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2290   if(nbProfile>0)
2291     {
2292       _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2293       _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2294     }
2295 }
2296
2297 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2298 {
2299   copyTinyInfoFrom(mesh);
2300 }
2301
2302 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2303 {
2304   if(id>=(int)_pfls.size())
2305     _pfls.resize(id+1);
2306   _pfls[id]=DataArrayInt::New();
2307   int lgth=MEDprofileSizeByName(fid,pflName);
2308   _pfls[id]->setName(pflName);
2309   _pfls[id]->alloc(lgth,1);
2310   MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2311   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2312 }
2313
2314 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2315 {
2316   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2317   int sz;
2318   MEDprofileInfo(fid,i+1,pflName,&sz);
2319   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2320   if(i>=(int)_pfls.size())
2321     _pfls.resize(i+1);
2322   _pfls[i]=DataArrayInt::New();
2323   _pfls[i]->alloc(sz,1);
2324   _pfls[i]->setName(pflCpp.c_str());
2325   MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2326   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2327 }
2328
2329 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2330 {
2331   int nbOfPfls=_pfls.size();
2332   for(int i=0;i<nbOfPfls;i++)
2333     {
2334       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2335       cpy->applyLin(1,1,0);
2336       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2337       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2338       MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2339     }
2340   //
2341   int nbOfLocs=_locs.size();
2342   for(int i=0;i<nbOfLocs;i++)
2343     _locs[i]->writeLL(fid);
2344 }
2345
2346 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2347 {
2348   std::vector<std::string> pfls=getPfls();
2349   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2350     {
2351       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2352       if(it2==pfls.end())
2353         {
2354           _pfls.push_back(*it);
2355         }
2356       else
2357         {
2358           int id=std::distance(pfls.begin(),it2);
2359           if(!(*it)->isEqual(*_pfls[id]))
2360             {
2361               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2362               throw INTERP_KERNEL::Exception(oss.str().c_str());
2363             }
2364         }
2365     }
2366   std::vector<std::string> locs=getLocs();
2367   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2368     {
2369       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2370       if(it2==locs.end())
2371         {
2372           _locs.push_back(*it);
2373         }
2374       else
2375         {
2376           int id=std::distance(locs.begin(),it2);
2377           if(!(*it)->isEqual(*_locs[id],eps))
2378             {
2379               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2380               throw INTERP_KERNEL::Exception(oss.str().c_str());
2381             }
2382         }
2383     }
2384 }
2385
2386 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2387 {
2388   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2389     getProfile((*it).c_str());
2390 }
2391
2392 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2393 {
2394   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2395     getLocalization((*it).c_str());
2396 }
2397
2398 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2399 {
2400   std::vector<std::string> profiles=real.getPflsReallyUsed();
2401   int sz=profiles.size();
2402   _pfls.resize(sz);
2403   for(int i=0;i<sz;i++)
2404     loadProfileInFile(fid,i,profiles[i].c_str());
2405   //
2406   std::vector<std::string> locs=real.getLocsReallyUsed();
2407   sz=locs.size();
2408   _locs.resize(sz);
2409   for(int i=0;i<sz;i++)
2410     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2411 }
2412
2413 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2414 {
2415   int nProfil=MEDnProfile(fid);
2416   for(int i=0;i<nProfil;i++)
2417     loadProfileInFile(fid,i);
2418   int sz=MEDnLocalization(fid);
2419   _locs.resize(sz);
2420   for(int i=0;i<sz;i++)
2421     {
2422       _locs[i]=MEDFileFieldLoc::New(fid,i);
2423     }
2424 }
2425
2426 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2427 {
2428   return new MEDFileFieldGlobs(fname);
2429 }
2430
2431 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2432 {
2433   return new MEDFileFieldGlobs;
2434 }
2435
2436 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2437 {
2438   std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2439   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2440     ret+=(*it)->getHeapMemorySize();
2441   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2442     ret+=(*it)->getHeapMemorySize();
2443   return ret;
2444 }
2445
2446 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2447 {
2448   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2449   std::size_t i=0;
2450   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2451     {
2452       if((const DataArrayInt *)*it)
2453         ret->_pfls[i]=(*it)->deepCpy();
2454     }
2455   i=0;
2456   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2457     {
2458       if((const MEDFileFieldLoc*)*it)
2459         ret->_locs[i]=(*it)->deepCpy();
2460     }
2461   return ret.retn();
2462 }
2463
2464 /*!
2465  * \throw if a profile in \a pfls in not in \a this.
2466  * \throw if a localization in \a locs in not in \a this.
2467  * \sa MEDFileFieldGlobs::deepCpyPart
2468  */
2469 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2470 {
2471   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2472   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2473     {
2474       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2475       if(!pfl)
2476         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2477       pfl->incrRef();
2478       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2479       ret->_pfls.push_back(pfl2);
2480     }
2481   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2482     {
2483       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2484       if(!loc)
2485         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2486       loc->incrRef();
2487       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2488       ret->_locs.push_back(loc2);
2489     }
2490   ret->setFileName(getFileName());
2491   return ret.retn();
2492 }
2493
2494 /*!
2495  * \throw if a profile in \a pfls in not in \a this.
2496  * \throw if a localization in \a locs in not in \a this.
2497  * \sa MEDFileFieldGlobs::shallowCpyPart
2498  */
2499 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2500 {
2501   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2502   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2503     {
2504       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2505       if(!pfl)
2506         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2507       ret->_pfls.push_back(pfl->deepCpy());
2508     }
2509   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2510     {
2511       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2512       if(!loc)
2513         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2514       ret->_locs.push_back(loc->deepCpy());
2515     }
2516   ret->setFileName(getFileName());
2517   return ret.retn();
2518 }
2519
2520 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2521 {
2522 }
2523
2524 MEDFileFieldGlobs::MEDFileFieldGlobs()
2525 {
2526 }
2527
2528 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2529 {
2530 }
2531
2532 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2533 {
2534   oss << "Profiles :\n";
2535   std::size_t n=_pfls.size();
2536   for(std::size_t i=0;i<n;i++)
2537     {
2538       oss << "  - #" << i << " ";
2539       const DataArrayInt *pfl=_pfls[i];
2540       if(pfl)
2541         oss << "\"" << pfl->getName() << "\"\n";
2542       else
2543         oss << "EMPTY !\n";
2544     }
2545   n=_locs.size();
2546   oss << "Localizations :\n";
2547   for(std::size_t i=0;i<n;i++)
2548     {
2549       oss << "  - #" << i << " ";
2550       const MEDFileFieldLoc *loc=_locs[i];
2551       if(loc)
2552         loc->simpleRepr(oss);
2553       else
2554         oss<< "EMPTY !\n";
2555     }
2556 }
2557
2558 void MEDFileFieldGlobs::setFileName(const char *fileName)
2559 {
2560   _file_name=fileName;
2561 }
2562
2563 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2564 {
2565   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2566     {
2567       DataArrayInt *elt(*it);
2568       if(elt)
2569         {
2570           std::string name(elt->getName());
2571           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2572             {
2573               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2574                 {
2575                   elt->setName((*it2).second.c_str());
2576                   return;
2577                 }
2578             }
2579         }
2580     }
2581 }
2582
2583 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2584 {
2585   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2586     {
2587       MEDFileFieldLoc *elt(*it);
2588       if(elt)
2589         {
2590           std::string name(elt->getName());
2591           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2592             {
2593               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2594                 {
2595                   elt->setName((*it2).second.c_str());
2596                   return;
2597                 }
2598             }
2599         }
2600     }
2601 }
2602
2603 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2604 {
2605   if(locId<0 || locId>=(int)_locs.size())
2606     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2607   return _locs[locId]->getNbOfGaussPtPerCell();
2608 }
2609
2610 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2611 {
2612   return getLocalizationFromId(getLocalizationId(locName));
2613 }
2614
2615 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2616 {
2617   if(locId<0 || locId>=(int)_locs.size())
2618     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2619   return *_locs[locId];
2620 }
2621
2622 namespace ParaMEDMEMImpl
2623 {
2624   class LocFinder
2625   {
2626   public:
2627     LocFinder(const char *loc):_loc(loc) { }
2628     bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2629   private:
2630     const char *_loc;
2631   };
2632
2633   class PflFinder
2634   {
2635   public:
2636     PflFinder(const std::string& pfl):_pfl(pfl) { }
2637     bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2638   private:
2639     const std::string& _pfl;
2640   };
2641 }
2642
2643 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2644 {
2645   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2646   if(it==_locs.end())
2647     {
2648       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2649       for(it=_locs.begin();it!=_locs.end();it++)
2650         oss << "\"" << (*it)->getName() << "\", ";
2651       throw INTERP_KERNEL::Exception(oss.str().c_str());
2652     }
2653   return std::distance(_locs.begin(),it);
2654 }
2655
2656 /*!
2657  * The returned value is never null.
2658  */
2659 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2660 {
2661   std::string pflNameCpp(pflName);
2662   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2663   if(it==_pfls.end())
2664     {
2665       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2666       for(it=_pfls.begin();it!=_pfls.end();it++)
2667         oss << "\"" << (*it)->getName() << "\", ";
2668       throw INTERP_KERNEL::Exception(oss.str().c_str());
2669     }
2670   return *it;
2671 }
2672
2673 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2674 {
2675   if(pflId<0 || pflId>=(int)_pfls.size())
2676     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2677   return _pfls[pflId];
2678 }
2679
2680 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2681 {
2682   if(locId<0 || locId>=(int)_locs.size())
2683     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2684   return *_locs[locId];
2685 }
2686
2687 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2688 {
2689   return getLocalizationFromId(getLocalizationId(locName));
2690 }
2691
2692 /*!
2693  * The returned value is never null.
2694  */
2695 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2696 {
2697   std::string pflNameCpp(pflName);
2698   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2699   if(it==_pfls.end())
2700     {
2701       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2702       for(it=_pfls.begin();it!=_pfls.end();it++)
2703         oss << "\"" << (*it)->getName() << "\", ";
2704       throw INTERP_KERNEL::Exception(oss.str().c_str());
2705     }
2706   return *it;
2707 }
2708
2709 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2710 {
2711   if(pflId<0 || pflId>=(int)_pfls.size())
2712     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2713   return _pfls[pflId];
2714 }
2715
2716 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2717 {
2718   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2719   int i=0;
2720   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2721     {
2722       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2723         newPfls.push_back(*it);
2724     }
2725   _pfls=newPfls;
2726 }
2727
2728 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2729 {
2730   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2731   int i=0;
2732   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2733     {
2734       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2735         newLocs.push_back(*it);
2736     }
2737   _locs=newLocs;
2738 }
2739
2740 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2741 {
2742   int sz=_pfls.size();
2743   std::vector<std::string> ret(sz);
2744   for(int i=0;i<sz;i++)
2745     ret[i]=_pfls[i]->getName();
2746   return ret;
2747 }
2748
2749 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2750 {
2751   int sz=_locs.size();
2752   std::vector<std::string> ret(sz);
2753   for(int i=0;i<sz;i++)
2754     ret[i]=_locs[i]->getName();
2755   return ret;
2756 }
2757
2758 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2759 {
2760   std::vector<std::string> v=getPfls();
2761   std::string s(pflName);
2762   return std::find(v.begin(),v.end(),s)!=v.end();
2763 }
2764
2765 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2766 {
2767   std::vector<std::string> v=getLocs();
2768   std::string s(locName);
2769   return std::find(v.begin(),v.end(),s)!=v.end();
2770 }
2771
2772 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2773 {
2774   std::map<int,std::vector<int> > m;
2775   int i=0;
2776   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2777     {
2778       const DataArrayInt *tmp=(*it);
2779       if(tmp)
2780         {
2781           m[tmp->getHashCode()].push_back(i);
2782         }
2783     }
2784   std::vector< std::vector<int> > ret;
2785   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2786     {
2787       if((*it2).second.size()>1)
2788         {
2789           std::vector<int> ret0;
2790           bool equalityOrNot=false;
2791           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2792             {
2793               std::vector<int>::const_iterator it4=it3; it4++;
2794               for(;it4!=(*it2).second.end();it4++)
2795                 {
2796                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2797                     {
2798                       if(!equalityOrNot)
2799                         ret0.push_back(*it3);
2800                       ret0.push_back(*it4);
2801                       equalityOrNot=true;
2802                     }
2803                 }
2804             }
2805           if(!ret0.empty())
2806             ret.push_back(ret0);
2807         }
2808     }
2809   return ret;
2810 }
2811
2812 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2813 {
2814   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2815 }
2816
2817 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2818 {
2819   std::string name(pfl->getName());
2820   if(name.empty())
2821     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2822   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2823     if(name==(*it)->getName())
2824       {
2825         if(!pfl->isEqual(*(*it)))
2826           {
2827             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2828             throw INTERP_KERNEL::Exception(oss.str().c_str());
2829           }
2830       }
2831   pfl->incrRef();
2832   _pfls.push_back(pfl);
2833 }
2834
2835 void MEDFileFieldGlobs::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
2836 {
2837   std::string name(locName);
2838   if(name.empty())
2839     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2840   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2841   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2842     if((*it)->isName(locName))
2843       {
2844         if(!(*it)->isEqual(*obj,1e-12))
2845           {
2846             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2847             throw INTERP_KERNEL::Exception(oss.str().c_str());
2848           }
2849       }
2850   _locs.push_back(obj);
2851 }
2852
2853 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2854 {
2855   std::vector<std::string> names=getPfls();
2856   return CreateNewNameNotIn("NewPfl_",names);
2857 }
2858
2859 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2860 {
2861   std::vector<std::string> names=getLocs();
2862   return CreateNewNameNotIn("NewLoc_",names);
2863 }
2864
2865 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2866 {
2867   for(std::size_t sz=0;sz<100000;sz++)
2868     {
2869       std::ostringstream tryName;
2870       tryName << prefix << sz;
2871       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2872         return tryName.str();
2873     }
2874   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2875 }
2876
2877 /*!
2878  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2879  *  \param [in] fname - the file name.
2880  */
2881 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2882 {
2883 }
2884
2885 /*!
2886  * Creates an empty MEDFileFieldGlobsReal.
2887  */
2888 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2889 {
2890 }
2891
2892 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2893 {
2894   std::size_t ret=0;
2895   if((const MEDFileFieldGlobs *)_globals)
2896     ret+=_globals->getHeapMemorySize();
2897   return ret;
2898 }
2899
2900 /*!
2901  * Returns a string describing profiles and Gauss points held in \a this.
2902  *  \return std::string - the description string.
2903  */
2904 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2905 {
2906   const MEDFileFieldGlobs *glob=_globals;
2907   std::ostringstream oss2; oss2 << glob;
2908   std::string stars(oss2.str().length(),'*');
2909   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
2910   if(glob)
2911     glob->simpleRepr(oss);
2912   else
2913     oss << "NO GLOBAL INFORMATION !\n";
2914 }
2915
2916 void MEDFileFieldGlobsReal::resetContent()
2917 {
2918   _globals=MEDFileFieldGlobs::New();
2919 }
2920
2921 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2922 {
2923 }
2924
2925 /*!
2926  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2927  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2928  */
2929 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2930 {
2931   _globals=other._globals;
2932 }
2933
2934 /*!
2935  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2936  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2937  */
2938 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2939 {
2940   const MEDFileFieldGlobs *otherg(other._globals);
2941   if(!otherg)
2942     return ;
2943   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2944 }
2945
2946 /*!
2947  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
2948  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2949  */
2950 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
2951 {
2952   const MEDFileFieldGlobs *otherg(other._globals);
2953   if(!otherg)
2954     return ;
2955   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
2956 }
2957
2958 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
2959 {
2960   _globals=other._globals;
2961   if((const MEDFileFieldGlobs *)_globals)
2962     _globals=other._globals->deepCpy();
2963 }
2964
2965 /*!
2966  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
2967  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
2968  *  \param [in] eps - a precision used to compare Gauss points with same name held by
2969  *         \a this and \a other MEDFileFieldGlobsReal.
2970  *  \throw If \a this and \a other hold profiles with equal names but different ids.
2971  *  \throw If  \a this and \a other hold different Gauss points with equal names.
2972  */
2973 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
2974 {
2975   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
2976   if(thisGlobals==otherGlobals)
2977     return ;
2978   if(!thisGlobals)
2979     {
2980       _globals=other._globals;
2981       return ;
2982     }
2983   _globals->appendGlobs(*other._globals,eps);
2984 }
2985
2986 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
2987 {
2988   checkGlobsPflsPartCoherency();
2989   checkGlobsLocsPartCoherency();
2990 }
2991
2992 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
2993 {
2994   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
2995 }
2996
2997 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
2998 {
2999   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3000 }
3001
3002 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3003 {
3004   contentNotNull()->loadProfileInFile(fid,id,pflName);
3005 }
3006
3007 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3008 {
3009   contentNotNull()->loadProfileInFile(fid,id);
3010 }
3011
3012 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3013 {
3014   contentNotNull()->loadGlobals(fid,*this);
3015 }
3016
3017 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3018 {
3019   contentNotNull()->loadAllGlobals(fid);
3020 }
3021
3022 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3023 {
3024   contentNotNull()->writeGlobals(fid,opt);
3025 }
3026
3027 /*!
3028  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3029  * or getPflsReallyUsedMulti().
3030  *  \return std::vector<std::string> - a sequence of names of all profiles.
3031  */
3032 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3033 {
3034   return contentNotNull()->getPfls();
3035 }
3036
3037 /*!
3038  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3039  * or getLocsReallyUsedMulti().
3040  *  \return std::vector<std::string> - a sequence of names of all localizations.
3041  */
3042 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3043 {
3044   return contentNotNull()->getLocs();
3045 }
3046
3047 /*!
3048  * Checks if the profile with a given name exists.
3049  *  \param [in] pflName - the profile name of interest.
3050  *  \return bool - \c true if the profile named \a pflName exists.
3051  */
3052 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3053 {
3054   return contentNotNull()->existsPfl(pflName);
3055 }
3056
3057 /*!
3058  * Checks if the localization with a given name exists.
3059  *  \param [in] locName - the localization name of interest.
3060  *  \return bool - \c true if the localization named \a locName exists.
3061  */
3062 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3063 {
3064   return contentNotNull()->existsLoc(locName);
3065 }
3066
3067 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3068 {
3069   return contentNotNull()->createNewNameOfPfl();
3070 }
3071
3072 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3073 {
3074   return contentNotNull()->createNewNameOfLoc();
3075 }
3076
3077 /*!
3078  * Sets the name of a MED file.
3079  *  \param [inout] fileName - the file name.
3080  */
3081 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3082 {
3083   contentNotNull()->setFileName(fileName);
3084 }
3085
3086 /*!
3087  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3088  * in the same order.
3089  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3090  *          Each item of this sequence is a vector containing ids of equal profiles.
3091  */
3092 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3093 {
3094   return contentNotNull()->whichAreEqualProfiles();
3095 }
3096
3097 /*!
3098  * Finds equal localizations.
3099  *  \param [in] eps - a precision used to compare real values of the localizations.
3100  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3101  *          Each item of this sequence is a vector containing ids of equal localizations.
3102  */
3103 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3104 {
3105   return contentNotNull()->whichAreEqualLocs(eps);
3106 }
3107
3108 /*!
3109  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3110  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3111  *        this sequence is a pair whose 
3112  *        - the first item is a vector of profile names to replace by the second item,
3113  *        - the second item is a profile name to replace every profile name of the first item.
3114  */
3115 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3116 {
3117   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3118 }
3119
3120 /*!
3121  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3122  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3123  *        this sequence is a pair whose 
3124  *        - the first item is a vector of localization names to replace by the second item,
3125  *        - the second item is a localization name to replace every localization name of the first item.
3126  */
3127 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3128 {
3129   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3130 }
3131
3132 /*!
3133  * Replaces references to some profiles (a reference is a profile name) by references
3134  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3135  * them-selves accordingly. <br>
3136  * This method is a generalization of changePflName().
3137  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3138  *        this sequence is a pair whose 
3139  *        - the first item is a vector of profile names to replace by the second item,
3140  *        - the second item is a profile name to replace every profile of the first item.
3141  * \sa changePflsRefsNamesGen()
3142  * \sa changePflName()
3143  */
3144 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3145 {
3146   changePflsRefsNamesGen(mapOfModif);
3147   changePflsNamesInStruct(mapOfModif);
3148 }
3149
3150 /*!
3151  * Replaces references to some localizations (a reference is a localization name) by references
3152  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3153  * them-selves accordingly. <br>
3154  * This method is a generalization of changeLocName().
3155  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3156  *        this sequence is a pair whose 
3157  *        - the first item is a vector of localization names to replace by the second item,
3158  *        - the second item is a localization name to replace every localization of the first item.
3159  * \sa changeLocsRefsNamesGen()
3160  * \sa changeLocName()
3161  */
3162 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3163 {
3164   changeLocsRefsNamesGen(mapOfModif);
3165   changeLocsNamesInStruct(mapOfModif);
3166 }
3167
3168 /*!
3169  * Renames the profile having a given name and updates references to this profile.
3170  *  \param [in] oldName - the name of the profile to rename.
3171  *  \param [in] newName - a new name of the profile.
3172  * \sa changePflsNames().
3173  */
3174 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3175 {
3176   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3177   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3178   mapOfModif[0]=p;
3179   changePflsNames(mapOfModif);
3180 }
3181
3182 /*!
3183  * Renames the localization having a given name and updates references to this localization.
3184  *  \param [in] oldName - the name of the localization to rename.
3185  *  \param [in] newName - a new name of the localization.
3186  * \sa changeLocsNames().
3187  */
3188 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3189 {
3190   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3191   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3192   mapOfModif[0]=p;
3193   changeLocsNames(mapOfModif);
3194 }
3195
3196 /*!
3197  * Removes duplicated profiles. Returns a map used to update references to removed 
3198  * profiles via changePflsRefsNamesGen().
3199  * Equal profiles are found using whichAreEqualProfiles().
3200  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3201  *          a sequence describing the performed replacements of profiles. Each element of
3202  *          this sequence is a pair whose
3203  *          - the first item is a vector of profile names replaced by the second item,
3204  *          - the second item is a profile name replacing every profile of the first item.
3205  */
3206 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3207 {
3208   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3209   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3210   int i=0;
3211   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3212     {
3213       std::vector< std::string > tmp((*it).size());
3214       int j=0;
3215       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3216         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3217       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3218       ret[i]=p;
3219       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3220       killProfileIds(tmp2);
3221     }
3222   changePflsRefsNamesGen(ret);
3223   return ret;
3224 }
3225
3226 /*!
3227  * Removes duplicated localizations. Returns a map used to update references to removed 
3228  * localizations via changeLocsRefsNamesGen().
3229  * Equal localizations are found using whichAreEqualLocs().
3230  *  \param [in] eps - a precision used to compare real values of the localizations.
3231  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3232  *          a sequence describing the performed replacements of localizations. Each element of
3233  *          this sequence is a pair whose
3234  *          - the first item is a vector of localization names replaced by the second item,
3235  *          - the second item is a localization name replacing every localization of the first item.
3236  */
3237 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3238 {
3239   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3240   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3241   int i=0;
3242   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3243     {
3244       std::vector< std::string > tmp((*it).size());
3245       int j=0;
3246       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3247         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3248       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3249       ret[i]=p;
3250       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3251       killLocalizationIds(tmp2);
3252     }
3253   changeLocsRefsNamesGen(ret);
3254   return ret;
3255 }
3256
3257 /*!
3258  * Returns number of Gauss points per cell in a given localization.
3259  *  \param [in] locId - an id of the localization of interest.
3260  *  \return int - the number of the Gauss points per cell.
3261  */
3262 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3263 {
3264   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3265 }
3266
3267 /*!
3268  * Returns an id of a localization by its name.
3269  *  \param [in] loc - the localization name of interest.
3270  *  \return int - the id of the localization.
3271  *  \throw If there is no a localization named \a loc.
3272  */
3273 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3274 {
3275   return contentNotNull()->getLocalizationId(loc);
3276 }
3277
3278 /*!
3279  * Returns the name of the MED file.
3280  *  \return const char * - the MED file name.
3281  */
3282 const char *MEDFileFieldGlobsReal::getFileName() const
3283 {
3284   return contentNotNull()->getFileName();
3285 }
3286
3287 std::string MEDFileFieldGlobsReal::getFileName2() const
3288 {
3289   return contentNotNull()->getFileName2();
3290 }
3291
3292 /*!
3293  * Returns a localization object by its name.
3294  *  \param [in] locName - the name of the localization of interest.
3295  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3296  *  \throw If there is no a localization named \a locName.
3297  */
3298 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3299 {
3300   return contentNotNull()->getLocalization(locName);
3301 }
3302
3303 /*!
3304  * Returns a localization object by its id.
3305  *  \param [in] locId - the id of the localization of interest.
3306  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3307  *  \throw If there is no a localization with id \a locId.
3308  */
3309 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3310 {
3311   return contentNotNull()->getLocalizationFromId(locId);
3312 }
3313
3314 /*!
3315  * Returns a profile array by its name.
3316  *  \param [in] pflName - the name of the profile of interest.
3317  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3318  *  \throw If there is no a profile named \a pflName.
3319  */
3320 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3321 {
3322   return contentNotNull()->getProfile(pflName);
3323 }
3324
3325 /*!
3326  * Returns a profile array by its id.
3327  *  \param [in] pflId - the id of the profile of interest.
3328  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3329  *  \throw If there is no a profile with id \a pflId.
3330  */
3331 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3332 {
3333   return contentNotNull()->getProfileFromId(pflId);
3334 }
3335
3336 /*!
3337  * Returns a localization object, apt for modification, by its id.
3338  *  \param [in] locId - the id of the localization of interest.
3339  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3340  *          having the id \a locId.
3341  *  \throw If there is no a localization with id \a locId.
3342  */
3343 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3344 {
3345   return contentNotNull()->getLocalizationFromId(locId);
3346 }
3347
3348 /*!
3349  * Returns a localization object, apt for modification, by its name.
3350  *  \param [in] locName - the name of the localization of interest.
3351  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3352  *          having the name \a locName.
3353  *  \throw If there is no a localization named \a locName.
3354  */
3355 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3356 {
3357   return contentNotNull()->getLocalization(locName);
3358 }
3359
3360 /*!
3361  * Returns a profile array, apt for modification, by its name.
3362  *  \param [in] pflName - the name of the profile of interest.
3363  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3364  *  \throw If there is no a profile named \a pflName.
3365  */
3366 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3367 {
3368   return contentNotNull()->getProfile(pflName);
3369 }
3370
3371 /*!
3372  * Returns a profile array, apt for modification, by its id.
3373  *  \param [in] pflId - the id of the profile of interest.
3374  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3375  *  \throw If there is no a profile with id \a pflId.
3376  */
3377 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3378 {
3379   return contentNotNull()->getProfileFromId(pflId);
3380 }
3381
3382 /*!
3383  * Removes profiles given by their ids. No data is updated to track this removal.
3384  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3385  */
3386 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3387 {
3388   contentNotNull()->killProfileIds(pflIds);
3389 }
3390
3391 /*!
3392  * Removes localizations given by their ids. No data is updated to track this removal.
3393  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3394  */
3395 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3396 {
3397   contentNotNull()->killLocalizationIds(locIds);
3398 }
3399
3400 /*!
3401  * Stores a profile array.
3402  *  \param [in] pfl - the profile array to store.
3403  *  \throw If the name of \a pfl is empty.
3404  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3405  *         different ids.
3406  */
3407 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3408 {
3409   contentNotNull()->appendProfile(pfl);
3410 }
3411
3412 /*!
3413  * Adds a new localization of Gauss points.
3414  *  \param [in] locName - the name of the new localization.
3415  *  \param [in] geoType - a geometrical type of the reference cell.
3416  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3417  *         must be \c nbOfNodesPerCell * \c dimOfType.
3418  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3419  *         must be  _wg_.size() * \c dimOfType.
3420  *  \param [in] w - the weights of Gauss points.
3421  *  \throw If \a locName is empty.
3422  *  \throw If a localization with the name \a locName already exists but is
3423  *         different form the new one.
3424  */
3425 void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
3426 {
3427   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3428 }
3429
3430 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3431 {
3432   MEDFileFieldGlobs *g(_globals);
3433   if(!g)
3434     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3435   return g;
3436 }
3437
3438 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3439 {
3440   const MEDFileFieldGlobs *g(_globals);
3441   if(!g)
3442     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3443   return g;
3444 }
3445
3446 //= MEDFileFieldNameScope
3447
3448 MEDFileFieldNameScope::MEDFileFieldNameScope()
3449 {
3450 }
3451
3452 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3453 {
3454 }
3455
3456 /*!
3457  * Returns the name of \a this field.
3458  *  \return std::string - a string containing the field name.
3459  */
3460 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3461 {
3462   return _name;
3463 }
3464
3465 /*!
3466  * Sets name of \a this field
3467  *  \param [in] name - the new field name.
3468  */
3469 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3470 {
3471   _name=fieldName;
3472 }
3473
3474 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3475 {
3476   return _dt_unit;
3477 }
3478
3479 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3480 {
3481   _dt_unit=dtUnit;
3482 }
3483
3484 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3485 {
3486   _name=other._name;
3487   _dt_unit=other._dt_unit;
3488 }
3489
3490 //= MEDFileAnyTypeField1TSWithoutSDA
3491
3492 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3493 {
3494   _field_per_mesh.resize(other._field_per_mesh.size());
3495   std::size_t i=0;
3496   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3497     {
3498       if((const MEDFileFieldPerMesh *)*it)
3499         _field_per_mesh[i]=(*it)->deepCpy(this);
3500     }
3501 }
3502
3503 /*!
3504  * Prints a string describing \a this field into a stream. This string is outputted 
3505  * by \c print Python command.
3506  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3507  *  \param [in,out] oss - the out stream.
3508  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3509  *          info id printed, else, not.
3510  */
3511 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3512 {
3513   std::string startOfLine(bkOffset,' ');
3514   oss << startOfLine << "Field ";
3515   if(bkOffset==0)
3516     oss << "[Type=" << getTypeStr() << "] ";
3517   oss << "on One time Step ";
3518   if(f1tsId>=0)
3519     oss << "(" << f1tsId << ") ";
3520   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3521   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3522   const DataArray *arr=getUndergroundDataArray();
3523   if(arr)
3524     {
3525       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3526       if(f1tsId<0)
3527         {
3528           oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
3529           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3530           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3531             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3532         }
3533       if(arr->isAllocated())
3534         {
3535           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3536         }
3537       else
3538         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3539     }
3540   else
3541     {
3542       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3543     }
3544   oss << startOfLine << "----------------------" << std::endl;
3545   if(!_field_per_mesh.empty())
3546     {
3547       int i=0;
3548       for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3549         {
3550           const MEDFileFieldPerMesh *cur=(*it2);
3551           if(cur)
3552             cur->simpleRepr(bkOffset,oss,i);
3553           else
3554             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3555         }
3556     }
3557   else
3558     {
3559       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3560     }
3561   oss << startOfLine << "----------------------" << std::endl;
3562 }
3563
3564 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3565 {
3566   const DataArray *arr(getUndergroundDataArray());
3567   if(!arr)
3568     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3569   int nbOfCompo=arr->getNumberOfComponents();
3570   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3571   for(int i=0;i<nbOfCompo;i++)
3572     {
3573       ret[i]=deepCpy();
3574       std::vector<int> v(1,i);
3575       MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3576       ret[i]->setArray(arr2);
3577     }
3578   return ret;
3579 }
3580
3581 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit)
3582 {
3583 }
3584
3585 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1)
3586 {
3587 }
3588
3589 /*!
3590  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3591  * empty. Returns -1 if this in on nodes.
3592  *  \return int - the dimension of \a this.
3593  */
3594 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3595 {
3596   int ret=-2;
3597   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3598     (*it)->getDimension(ret);
3599   return ret;
3600 }
3601
3602 /*!
3603  * Returns the mesh name.
3604  *  \return std::string - a string holding the mesh name.
3605  *  \throw If \c _field_per_mesh.empty()
3606  */
3607 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3608 {
3609   if(_field_per_mesh.empty())
3610     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3611   return _field_per_mesh[0]->getMeshName();
3612 }
3613
3614 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3615 {
3616   std::string oldName(getMeshName());
3617   std::vector< std::pair<std::string,std::string> > v(1);
3618   v[0].first=oldName; v[0].second=newMeshName;
3619   changeMeshNames(v);
3620 }
3621
3622 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3623 {
3624   bool ret=false;
3625   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3626     {
3627       MEDFileFieldPerMesh *cur(*it);
3628       if(cur)
3629         ret=cur->changeMeshNames(modifTab) || ret;
3630     }
3631   return ret;
3632 }
3633
3634 /*!
3635  * Returns the number of iteration of the state of underlying mesh.
3636  *  \return int - the iteration number.
3637  *  \throw If \c _field_per_mesh.empty()
3638  */
3639 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3640 {
3641   if(_field_per_mesh.empty())
3642     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3643   return _field_per_mesh[0]->getMeshIteration();
3644 }
3645
3646 /*!
3647  * Returns the order number of iteration of the state of underlying mesh.
3648  *  \return int - the order number.
3649  *  \throw If \c _field_per_mesh.empty()
3650  */
3651 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3652 {
3653   if(_field_per_mesh.empty())
3654     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3655   return _field_per_mesh[0]->getMeshOrder();
3656 }
3657
3658 /*!
3659  * Checks if \a this field is tagged by a given iteration number and a given
3660  * iteration order number.
3661  *  \param [in] iteration - the iteration number of interest.
3662  *  \param [in] order - the iteration order number of interest.
3663  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
3664  *          \a this->getOrder() == \a order.
3665  */
3666 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3667 {
3668   return iteration==_iteration && order==_order;
3669 }
3670
3671 /*!
3672  * Returns number of iteration and order number of iteration when
3673  * \a this field has been calculated.
3674  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
3675  *          order number.
3676  */
3677 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3678 {
3679   std::pair<int,int> p;
3680   fillIteration(p);
3681   return p;
3682 }
3683
3684 /*!
3685  * Returns number of iteration and order number of iteration when
3686  * \a this field has been calculated.
3687  *  \param [in,out] p - a pair returning the iteration number and the iteration
3688  *          order number.
3689  */
3690 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3691 {
3692   p.first=_iteration;
3693   p.second=_order;
3694 }
3695
3696 /*!
3697  * Returns all types of spatial discretization of \a this field.
3698  *  \param [in,out] types - a sequence of types of \a this field.
3699  */
3700 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3701 {
3702   std::set<TypeOfField> types2;
3703   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3704     {
3705       (*it)->fillTypesOfFieldAvailable(types2);
3706     }
3707   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3708   std::copy(types2.begin(),types2.end(),bi);
3709 }
3710
3711 /*!
3712  * Returns all types of spatial discretization of \a this field.
3713  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3714  *          of \a this field.
3715  */
3716 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3717 {
3718   std::vector<TypeOfField> ret;
3719   fillTypesOfFieldAvailable(ret);
3720   return ret;
3721 }
3722
3723 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3724 {
3725   std::vector<std::string> ret;
3726   std::set<std::string> ret2;
3727   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3728     {
3729       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3730       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3731         if(ret2.find(*it2)==ret2.end())
3732           {
3733             ret.push_back(*it2);
3734             ret2.insert(*it2);
3735           }
3736     }
3737   return ret;
3738 }
3739
3740 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3741 {
3742   std::vector<std::string> ret;
3743   std::set<std::string> ret2;
3744   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3745     {
3746       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3747       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3748         if(ret2.find(*it2)==ret2.end())
3749           {
3750             ret.push_back(*it2);
3751             ret2.insert(*it2);
3752           }
3753     }
3754   return ret;
3755 }
3756
3757 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3758 {
3759   std::vector<std::string> ret;
3760   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3761     {
3762       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3763       ret.insert(ret.end(),tmp.begin(),tmp.end());
3764     }
3765   return ret;
3766 }
3767
3768 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3769 {
3770   std::vector<std::string> ret;
3771   std::set<std::string> ret2;
3772   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3773     {
3774       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3775       ret.insert(ret.end(),tmp.begin(),tmp.end());
3776     }
3777   return ret;
3778 }
3779
3780 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3781 {
3782   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3783     (*it)->changePflsRefsNamesGen(mapOfModif);
3784 }
3785
3786 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3787 {
3788   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3789     (*it)->changeLocsRefsNamesGen(mapOfModif);
3790 }
3791
3792 /*!
3793  * Returns all attributes of parts of \a this field lying on a given mesh.
3794  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3795  * item of every of returned sequences refers to the _i_-th part of \a this field.
3796  * Thus all sequences returned by this method are of the same length equal to number
3797  * of different types of supporting entities.<br>
3798  * A field part can include sub-parts with several different spatial discretizations,
3799  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3800  * for example. Hence, some of the returned sequences contains nested sequences, and an item
3801  * of a nested sequence corresponds to a type of spatial discretization.<br>
3802  * This method allows for iteration over MEDFile DataStructure without any overhead.
3803  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3804  *          for the case with only one underlying mesh. (Actually, the number of meshes is
3805  *          not checked if \a mname == \c NULL).
3806  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3807  *          a field part is returned. 
3808  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3809  *          This sequence is of the same length as \a types. 
3810  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3811  *          discretization. A profile name can be empty.
3812  *          Length of this and of nested sequences is the same as that of \a typesF.
3813  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
3814  *          discretization. A localization name can be empty.
3815  *          Length of this and of nested sequences is the same as that of \a typesF.
3816  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3817  *          of ids of tuples within the data array, per each type of spatial
3818  *          discretization within one mesh entity type. 
3819  *          Length of this and of nested sequences is the same as that of \a typesF.
3820  *  \throw If no field is lying on \a mname.
3821  */
3822 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
3823 {
3824   int meshId=0;
3825   if(mname)
3826     meshId=getMeshIdFromMeshName(mname);
3827   else
3828     if(_field_per_mesh.empty())
3829       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3830   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3831 }
3832
3833 /*!
3834  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3835  * maximal absolute dimension and values returned via the out parameter \a levs are 
3836  * dimensions relative to the maximal absolute dimension. <br>
3837  * This method is designed for MEDFileField1TS instances that have a discretization
3838  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS", 
3839  * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT", 
3840  * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3841  * Only these 3 discretizations will be taken into account here. If \a this is
3842  * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3843  * This method is useful to make the link between the dimension of the underlying mesh
3844  * and the levels of \a this, because it is possible that the highest dimension of \a this
3845  * field is not equal to the dimension of the underlying mesh.
3846  * 
3847  * Let's consider the following case:
3848  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3849  * TETRA4, HEXA8, TRI3 and SEG2.
3850  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3851  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3852  *
3853  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3854  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3855  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3856  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3857  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3858  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3859  * For example<br>
3860  * to retrieve the highest level of
3861  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
3862  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3863  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3864  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3865  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3866  *          for the case with only one underlying mesh. (Actually, the number of meshes is
3867  *          not checked if \a mname == \c NULL).
3868  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3869  *          absolute one. They are in decreasing order. This sequence is cleared before
3870  *          filling it in.
3871  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
3872  *  \throw If no field is lying on \a mname.
3873  */
3874 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3875 {
3876   levs.clear();
3877   int meshId=getMeshIdFromMeshName(mname);
3878   std::vector<INTERP_KERNEL::NormalizedCellType> types;
3879   std::vector< std::vector<TypeOfField> > typesF;
3880   std::vector< std::vector<std::string> > pfls, locs;
3881   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3882   if(types.empty())
3883     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3884   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3885   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3886     return -1;
3887   st.erase(INTERP_KERNEL::NORM_ERROR);
3888   std::set<int> ret1;
3889   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3890     {
3891       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3892       ret1.insert((int)cm.getDimension());
3893     }
3894   int ret=*std::max_element(ret1.begin(),ret1.end());
3895   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3896   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3897   return ret;
3898 }
3899
3900 /*!
3901  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
3902  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
3903  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
3904  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3905  */
3906 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3907 {
3908   int mid=getMeshIdFromMeshName(mName);
3909   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3910 }
3911
3912 /*!
3913  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
3914  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
3915  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
3916  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3917  */
3918 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3919 {
3920   int mid=getMeshIdFromMeshName(mName);
3921   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3922 }
3923
3924 /*!
3925  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
3926  */
3927 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3928 {
3929   if(_field_per_mesh.empty())
3930     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3931   if(mName==0)
3932     return 0;
3933   std::string mName2(mName);
3934   int ret=0;
3935   std::vector<std::string> msg;
3936   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
3937     if(mName2==(*it)->getMeshName())
3938       return ret;
3939     else
3940       msg.push_back((*it)->getMeshName());
3941   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
3942   oss << "Possible meshes are : ";
3943   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
3944     oss << "\"" << (*it2) << "\" ";
3945   throw INTERP_KERNEL::Exception(oss.str().c_str());
3946 }
3947
3948 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
3949 {
3950   if(!mesh)
3951     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
3952   std::string tmp(mesh->getName());
3953   if(tmp.empty())
3954     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
3955   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
3956   int i=0;
3957   for(;it!=_field_per_mesh.end();it++,i++)
3958     {
3959       if((*it)->getMeshName()==tmp)
3960         return i;
3961     }
3962   int sz=_field_per_mesh.size();
3963   _field_per_mesh.resize(sz+1);
3964   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
3965   return sz;
3966 }
3967
3968 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
3969                                                             MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
3970 {
3971   bool ret=false;
3972   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3973     {
3974       MEDFileFieldPerMesh *fpm(*it);
3975       if(fpm)
3976         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
3977     }
3978   return ret;
3979 }
3980
3981 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
3982 {
3983   if(_field_per_mesh.empty())
3984     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
3985   if(_field_per_mesh.size()>1)
3986     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
3987   _field_per_mesh[0]->copyOptionsFrom(opts);
3988   _field_per_mesh[0]->writeLL(fid,nasc);
3989 }
3990
3991 void MEDFileAnyTypeField1TSWithoutSDA::finishLoading(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
3992 {
3993   med_int numdt,numit;
3994   med_float dt;
3995   med_int nmesh;
3996   med_bool localMesh;
3997   med_int meshnumdt,meshnumit;
3998   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3999   MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4000   MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4001   if(_iteration!=numdt || _order!=numit)
4002     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::finishLoading : unexpected exception internal error !");
4003   _field_per_mesh.resize(nmesh);
4004   for(int i=0;i<nmesh;i++)
4005     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4006   int start=0;
4007   for(int i=0;i<nmesh;i++)
4008     {
4009       _field_per_mesh[i]->prepareLoading(fid,start,nasc);
4010     }
4011   getOrCreateAndGetArray()->alloc(start,getNumberOfComponents());
4012   for(int i=0;i<nmesh;i++)
4013     {
4014       _field_per_mesh[i]->finishLoading(fid,nasc);
4015     }
4016 }
4017
4018 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4019 {
4020   std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4021   if(getUndergroundDataArray())
4022     ret+=getUndergroundDataArray()->getHeapMemorySize();
4023   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4024     ret+=(*it)->getHeapMemorySize();
4025   return ret;
4026 }
4027
4028 /*!
4029  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4030  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4031  * "Sort By Type"), if not, an exception is thrown. 
4032  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4033  *  \param [in] arr - the array of values.
4034  *  \param [in,out] glob - the global data where profiles and localization present in
4035  *          \a field, if any, are added.
4036  *  \throw If the name of \a field is empty.
4037  *  \throw If the data array of \a field is not set.
4038  *  \throw If \a this->_arr is already allocated but has different number of components
4039  *         than \a field.
4040  *  \throw If the underlying mesh of \a field has no name.
4041  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4042  */
4043 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4044 {
4045   const MEDCouplingMesh *mesh=field->getMesh();
4046   //
4047   TypeOfField type=field->getTypeOfField();
4048   std::vector<DataArrayInt *> dummy;
4049   int start=copyTinyInfoFrom(field,arr);
4050   int pos=addNewEntryIfNecessary(mesh);
4051   if(type!=ON_NODES)
4052     {
4053       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4054       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4055     }
4056   else
4057     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4058 }
4059
4060 /*!
4061  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4062  * of a given mesh are used as the support of the given field (a real support is not used). 
4063  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4064  * Order of underlying mesh entities of the given field specified by \a profile parameter
4065  * is not prescribed; this method permutes field values to have them sorted by element
4066  * type as required for writing to MED file. A new profile is added only if no equal
4067  * profile is missing. 
4068  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4069  *  \param [in] arrOfVals - the values of the field \a field used.
4070  *  \param [in] mesh - the supporting mesh of \a field.
4071  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4072  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4073  *  \param [in,out] glob - the global data where profiles and localization present in
4074  *          \a field, if any, are added.
4075  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4076  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4077  *  \throw If the data array of \a field is not set.
4078  *  \throw If \a this->_arr is already allocated but has different number of components
4079  *         than \a field.
4080  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4081  *  \sa setFieldNoProfileSBT()
4082  */
4083 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4084 {
4085   TypeOfField type=field->getTypeOfField();
4086   int start=copyTinyInfoFrom(field,arrOfVals);
4087   std::vector<DataArrayInt *> idsInPflPerType;
4088   std::vector<DataArrayInt *> idsPerType;
4089   std::vector<int> code,code2;
4090   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4091   if(type!=ON_NODES)
4092     {
4093       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4094       code2=m->getDistributionOfTypes();
4095       //
4096       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
4097       for(std::size_t i=0;i<idsInPflPerType.size();i++)
4098         idsInPflPerType2[i]=idsInPflPerType[i];
4099       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
4100       for(std::size_t i=0;i<idsPerType.size();i++)
4101         idsPerType2[i]=idsPerType[i];
4102       //
4103       int pos=addNewEntryIfNecessary(m);
4104       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4105     }
4106   else
4107     {
4108       int pos=addNewEntryIfNecessary(m);
4109       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4110     }
4111 }
4112
4113 /*!
4114  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4115  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4116  * larger by the size of \a field. Returns an id of the first not filled
4117  * tuple of \a this->_arr.
4118  *  \param [in] field - the field to copy the info on components and the name from.
4119  *  \return int - the id of first not initialized tuple of \a this->_arr.
4120  *  \throw If the name of \a field is empty.
4121  *  \throw If the data array of \a field is not set.
4122  *  \throw If \a this->_arr is already allocated but has different number of components
4123  *         than \a field.
4124  */
4125 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4126 {
4127   if(!field)
4128     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4129   std::string name(field->getName());
4130   setName(name.c_str());
4131   setDtUnit(field->getTimeUnit());
4132   if(name.empty())
4133     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4134   if(!arr)
4135     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4136   _dt=field->getTime(_iteration,_order);
4137   int nbOfComponents=arr->getNumberOfComponents();
4138   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4139   if(!getOrCreateAndGetArray()->isAllocated())
4140     {
4141       getOrCreateAndGetArray()->alloc(arr->getNumberOfTuples(),arr->getNumberOfComponents());
4142       return 0;
4143     }
4144   else
4145     {
4146       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4147       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4148       MEDCouplingAutoRefCountObjectPtr<DataArray> tmp=createNewEmptyDataArrayInstance();
4149       tmp->alloc(newNbOfTuples,nbOfComponents);
4150       tmp->copyStringInfoFrom(*getOrCreateAndGetArray());
4151       DataArray *arrr=getOrCreateAndGetArray();      
4152       tmp->setContigPartOfSelectedValues2(0,arrr,0,oldNbOfTuples,1);
4153       setArray(tmp);
4154       return oldNbOfTuples;
4155     }
4156 }
4157
4158 /*!
4159  * Returns number of components in \a this field
4160  *  \return int - the number of components.
4161  */
4162 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4163 {
4164   return getOrCreateAndGetArray()->getNumberOfComponents();
4165 }
4166
4167 /*!
4168  * Change info on components in \a this.
4169  * \throw If size of \a infos is not equal to the number of components already in \a this.
4170  */
4171 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4172 {
4173   DataArray *arr=getOrCreateAndGetArray();
4174   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4175 }
4176
4177 /*!
4178  * Returns info on components of \a this field.
4179  *  \return const std::vector<std::string>& - a sequence of strings each being an
4180  *          information on _i_-th component.
4181  */
4182 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4183 {
4184   const DataArray *arr=getOrCreateAndGetArray();
4185   return arr->getInfoOnComponents();
4186 }
4187
4188 /*!
4189  * Returns a mutable info on components of \a this field.
4190  *  \return std::vector<std::string>& - a sequence of strings each being an
4191  *          information on _i_-th component.
4192  */
4193 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4194 {
4195   DataArray *arr=getOrCreateAndGetArray();
4196   return arr->getInfoOnComponents();
4197 }
4198
4199 /*!
4200  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4201  *  \param [in] type - a spatial discretization of the new field.
4202  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4203  *  \param [in] mName - a name of the supporting mesh.
4204  *  \param [in] renumPol - specifies how to permute values of the result field according to
4205  *          the optional numbers of cells and nodes, if any. The valid values are
4206  *          - 0 - do not permute.
4207  *          - 1 - permute cells.
4208  *          - 2 - permute nodes.
4209  *          - 3 - permute cells and nodes.
4210  *
4211  *  \param [in] glob - the global data storing profiles and localization.
4212  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4213  *          caller is to delete this field using decrRef() as it is no more needed. 
4214  *  \throw If the MED file is not readable.
4215  *  \throw If there is no mesh named \a mName in the MED file.
4216  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4217  *  \throw If no field of \a this is lying on the mesh \a mName.
4218  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4219  */
4220 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4221 {
4222   MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4223   if(mName==0)
4224     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4225   else
4226     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4227   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4228 }
4229
4230 /*!
4231  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4232  *  \param [in] type - a spatial discretization of the new field.
4233  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4234  *  \param [in] renumPol - specifies how to permute values of the result field according to
4235  *          the optional numbers of cells and nodes, if any. The valid values are
4236  *          - 0 - do not permute.
4237  *          - 1 - permute cells.
4238  *          - 2 - permute nodes.
4239  *          - 3 - permute cells and nodes.
4240  *
4241  *  \param [in] glob - the global data storing profiles and localization.
4242  *  \param [in] mesh - the supporting mesh.
4243  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4244  *          caller is to delete this field using decrRef() as it is no more needed. 
4245  *  \throw If the MED file is not readable.
4246  *  \throw If no field of \a this is lying on \a mesh.
4247  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4248  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4249  */
4250 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4251 {
4252   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4253   const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4254   const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4255   if(meshDimRelToMax==1)
4256     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4257   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4258 }
4259
4260 /*!
4261  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4262  * given mesh. 
4263  *  \param [in] type - a spatial discretization of the new field.
4264  *  \param [in] mName - a name of the supporting mesh.
4265  *  \param [in] renumPol - specifies how to permute values of the result field according to
4266  *          the optional numbers of cells and nodes, if any. The valid values are
4267  *          - 0 - do not permute.
4268  *          - 1 - permute cells.
4269  *          - 2 - permute nodes.
4270  *          - 3 - permute cells and nodes.
4271  *
4272  *  \param [in] glob - the global data storing profiles and localization.
4273  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4274  *          caller is to delete this field using decrRef() as it is no more needed. 
4275  *  \throw If the MED file is not readable.
4276  *  \throw If there is no mesh named \a mName in the MED file.
4277  *  \throw If there are no mesh entities in the mesh.
4278  *  \throw If no field values of the given \a type are available.
4279  */
4280 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4281 {
4282    MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4283   if(mName==0)
4284     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4285   else
4286     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4287   int absDim=getDimension();
4288   int meshDimRelToMax=absDim-mm->getMeshDimension();
4289   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4290 }
4291
4292 /*!
4293  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4294  *  \param [in] type - a spatial discretization of the new field.
4295  *  \param [in] renumPol - specifies how to permute values of the result field according to
4296  *          the optional numbers of cells and nodes, if any. The valid values are
4297  *          - 0 - do not permute.
4298  *          - 1 - permute cells.
4299  *          - 2 - permute nodes.
4300  *          - 3 - permute cells and nodes.
4301  *
4302  *  \param [in] glob - the global data storing profiles and localization.
4303  *  \param [in] mesh - the supporting mesh.
4304  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
4305  *         field according to \a renumPol.
4306  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
4307  *         field according to \a renumPol.
4308  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4309  *          caller is to delete this field using decrRef() as it is no more needed. 
4310  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4311  *  \throw If no field of \a this is lying on \a mesh.
4312  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4313  */
4314 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4315 {
4316   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4317   int meshId=getMeshIdFromMeshName(mesh->getName());
4318   bool isPfl=false;
4319   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4320   switch(renumPol)
4321     {
4322     case 0:
4323       {
4324         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4325         return ret.retn();
4326       }
4327     case 3:
4328     case 1:
4329       {
4330         if(isPfl)
4331           throw INTERP_KERNEL::Exception(msg1);
4332         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4333         if(cellRenum)
4334           {
4335             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4336               {
4337                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4338                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4339                 throw INTERP_KERNEL::Exception(oss.str().c_str());
4340               }
4341             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4342             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4343             std::vector<DataArray *> arrOut2(1,arrOut);
4344             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4345             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4346             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4347           }
4348         if(renumPol==1)
4349           return ret.retn();
4350       }
4351     case 2:
4352       {
4353         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4354         if(isPfl)
4355           throw INTERP_KERNEL::Exception(msg1);
4356         if(nodeRenum)
4357           {
4358             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4359               {
4360                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4361                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4362                 throw INTERP_KERNEL::Exception(oss.str().c_str());
4363               }
4364             MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4365             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4366               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4367             ret->renumberNodes(nodeRenumSafe->getConstPointer());
4368           }
4369         return ret.retn();
4370       }
4371     default:
4372       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4373     }
4374 }
4375
4376 /*!
4377  * Returns values and a profile of the field of a given type lying on a given support.
4378  *  \param [in] type - a spatial discretization of the field.
4379  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4380  *  \param [in] mesh - the supporting mesh.
4381  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4382  *          field of interest lies on. If the field lies on all entities of the given
4383  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
4384  *          using decrRef() as it is no more needed.  
4385  *  \param [in] glob - the global data storing profiles and localization.
4386  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4387  *          field. The caller is to delete this array using decrRef() as it is no more needed.
4388  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4389  *  \throw If no field of \a this is lying on \a mesh.
4390  *  \throw If no field values of the given \a type are available.
4391  */
4392 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4393 {
4394   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4395   int meshId=getMeshIdFromMeshName(mesh->getName());
4396   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4397   ret->setName(nasc.getName().c_str());
4398   return ret.retn();
4399 }
4400
4401 //= MEDFileField1TSWithoutSDA
4402
4403 /*!
4404  * Throws if a given value is not a valid (non-extended) relative dimension.
4405  *  \param [in] meshDimRelToMax - the relative dimension value.
4406  *  \throw If \a meshDimRelToMax > 0.
4407  */
4408 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4409 {
4410   if(meshDimRelToMax>0)
4411     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4412 }
4413
4414 /*!
4415  * Checks if elements of a given mesh are in the order suitable for writing 
4416  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4417  * vector describing types of elements and their number.
4418  *  \param [in] mesh - the mesh to check.
4419  *  \return std::vector<int> - a vector holding for each element type (1) item of
4420  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
4421  *          These values are in full-interlace mode.
4422  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4423  */
4424 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4425 {
4426   if(!mesh)
4427     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4428   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4429   int nbOfTypes=geoTypes.size();
4430   std::vector<int> code(3*nbOfTypes);
4431   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4432   arr1->alloc(nbOfTypes,1);
4433   int *arrPtr=arr1->getPointer();
4434   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4435   for(int i=0;i<nbOfTypes;i++,it++)
4436     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4437   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4438   const int *arrPtr2=arr2->getConstPointer();
4439   int i=0;
4440   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4441     {
4442       int pos=arrPtr2[i];
4443       int nbCells=mesh->getNumberOfCellsWithType(*it);
4444       code[3*pos]=(int)(*it);
4445       code[3*pos+1]=nbCells;
4446       code[3*pos+2]=-1;//no profiles
4447     }
4448   std::vector<const DataArrayInt *> idsPerType;//no profiles
4449   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4450   if(da)
4451     {
4452       da->decrRef();
4453       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4454     }
4455   return code;
4456 }
4457
4458 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4459 {
4460   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4461 }
4462
4463 /*!
4464  * Returns all attributes and values of parts of \a this field lying on a given mesh.
4465  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4466  * item of every of returned sequences refers to the _i_-th part of \a this field.
4467  * Thus all sequences returned by this method are of the same length equal to number
4468  * of different types of supporting entities.<br>
4469  * A field part can include sub-parts with several different spatial discretizations,
4470  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4471  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4472  * of a nested sequence corresponds to a type of spatial discretization.<br>
4473  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4474  * The overhead is due to selecting values into new instances of DataArrayDouble.
4475  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4476  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4477  *          not checked if \a mname == \c NULL).
4478  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4479  *          a field part is returned. 
4480  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4481  *          A field part can include sub-parts with several different spatial discretizations,
4482  *          \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and 
4483  *          \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4484  *          This sequence is of the same length as \a types. 
4485  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4486  *          discretization. A profile name can be empty.
4487  *          Length of this and of nested sequences is the same as that of \a typesF.
4488  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4489  *          discretization. A localization name can be empty.
4490  *          Length of this and of nested sequences is the same as that of \a typesF.
4491  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4492  *          per each type of spatial discretization within one mesh entity type.
4493  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4494  *          Length of this and of nested sequences is the same as that of \a typesF.
4495  *  \throw If no field is lying on \a mname.
4496  */
4497 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
4498 {
4499   int meshId=0;
4500   if(mname)
4501     meshId=getMeshIdFromMeshName(mname);
4502   else
4503     if(_field_per_mesh.empty())
4504       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4505   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4506   int nbOfRet=ret0.size();
4507   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4508   for(int i=0;i<nbOfRet;i++)
4509     {
4510       const std::vector< std::pair<int,int> >& p=ret0[i];
4511       int nbOfRet1=p.size();
4512       ret[i].resize(nbOfRet1);
4513       for(int j=0;j<nbOfRet1;j++)
4514         {
4515           DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4516           ret[i][j]=tmp;
4517         }
4518     }
4519   return ret;
4520 }
4521
4522 /*!
4523  * Returns a pointer to the underground DataArrayDouble instance. So the
4524  * caller should not decrRef() it. This method allows for a direct access to the field
4525  * values. This method is quite unusable if there is more than a nodal field or a cell
4526  * field on single geometric cell type. 
4527  *  \return DataArrayDouble * - the pointer to the field values array.
4528  */
4529 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4530 {
4531   const DataArrayDouble *ret=_arr;
4532   if(ret)
4533     return const_cast<DataArrayDouble *>(ret);
4534   else
4535     return 0;
4536 }
4537
4538 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4539 {
4540   return TYPE_STR;
4541 }
4542
4543 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4544 {
4545   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4546   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4547   ret->deepCpyLeavesFrom(*this);
4548   const DataArrayDouble *arr(_arr);
4549   if(arr)
4550     {
4551       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4552       ret->setArray(arr2);
4553     }
4554   return ret.retn();
4555 }
4556
4557 /*!
4558  * Returns a pointer to the underground DataArrayDouble instance. So the
4559  * caller should not decrRef() it. This method allows for a direct access to the field
4560  * values. This method is quite unusable if there is more than a nodal field or a cell
4561  * field on single geometric cell type. 
4562  *  \return DataArrayDouble * - the pointer to the field values array.
4563  */
4564 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4565 {
4566   return getUndergroundDataArrayDouble();
4567 }
4568
4569 /*!
4570  * Returns a pointer to the underground DataArrayDouble instance and a
4571  * sequence describing parameters of a support of each part of \a this field. The
4572  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4573  * direct access to the field values. This method is intended for the field lying on one
4574  * mesh only.
4575  *  \param [in,out] entries - the sequence describing parameters of a support of each
4576  *         part of \a this field. Each item of this sequence consists of two parts. The
4577  *         first part describes a type of mesh entity and an id of discretization of a
4578  *         current field part. The second part describes a range of values [begin,end)
4579  *         within the returned array relating to the current field part.
4580  *  \return DataArrayDouble * - the pointer to the field values array.
4581  *  \throw If the number of underlying meshes is not equal to 1.
4582  *  \throw If no field values are available.
4583  *  \sa getUndergroundDataArray()
4584  */
4585 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4586 {
4587   if(_field_per_mesh.size()!=1)
4588     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4589   if(_field_per_mesh[0]==0)
4590     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4591   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4592   return getUndergroundDataArrayDouble();
4593 }
4594
4595 /*!
4596  * Returns a pointer to the underground DataArrayDouble instance and a
4597  * sequence describing parameters of a support of each part of \a this field. The
4598  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4599  * direct access to the field values. This method is intended for the field lying on one
4600  * mesh only.
4601  *  \param [in,out] entries - the sequence describing parameters of a support of each
4602  *         part of \a this field. Each item of this sequence consists of two parts. The
4603  *         first part describes a type of mesh entity and an id of discretization of a
4604  *         current field part. The second part describes a range of values [begin,end)
4605  *         within the returned array relating to the current field part.
4606  *  \return DataArrayDouble * - the pointer to the field values array.
4607  *  \throw If the number of underlying meshes is not equal to 1.
4608  *  \throw If no field values are available.
4609  *  \sa getUndergroundDataArray()
4610  */
4611 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4612 {
4613   return getUndergroundDataArrayDoubleExt(entries);
4614 }
4615
4616 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4617                                                      const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4618 {
4619   DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4620   arr->setInfoAndChangeNbOfCompo(infos);
4621 }
4622
4623 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4624 {
4625 }
4626
4627 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4628 {
4629   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4630   ret->deepCpyLeavesFrom(*this);
4631   return ret.retn();
4632 }
4633
4634 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4635 {
4636   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4637   if((const DataArrayDouble *)_arr)
4638     ret->_arr=_arr->deepCpy();
4639   return ret.retn();
4640 }
4641
4642 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4643 {
4644   if(!arr)
4645     _arr=0;
4646   DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4647   if(!arrC)
4648     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4649   arrC->incrRef();
4650   _arr=arrC;
4651 }
4652
4653 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4654 {
4655   return DataArrayDouble::New();
4656 }
4657
4658 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4659 {
4660   DataArrayDouble *ret=_arr;
4661   if(ret)
4662     return ret;
4663   _arr=DataArrayDouble::New();
4664   return _arr;
4665 }
4666
4667 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4668 {
4669   return getOrCreateAndGetArrayDouble();
4670 }
4671
4672 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4673 {
4674   const DataArrayDouble *ret=_arr;
4675   if(ret)
4676     return ret;
4677   DataArrayDouble *ret2=DataArrayDouble::New();
4678   const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4679   return ret2;
4680 }
4681
4682 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4683 {
4684   return getOrCreateAndGetArrayDouble();
4685 }
4686
4687 //= MEDFileIntField1TSWithoutSDA
4688
4689 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4690                                                                 const std::vector<std::string>& infos)
4691 {
4692   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4693 }
4694
4695 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4696 {
4697 }
4698
4699 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4700                                                            const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4701 {
4702   DataArrayInt *arr=getOrCreateAndGetArrayInt();
4703   arr->setInfoAndChangeNbOfCompo(infos);
4704 }
4705
4706 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4707 {
4708   return TYPE_STR;
4709 }
4710
4711 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4712 {
4713   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4714   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4715   ret->deepCpyLeavesFrom(*this);
4716   const DataArrayInt *arr(_arr);
4717   if(arr)
4718     {
4719       MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4720       ret->setArray(arr2);
4721     }
4722   return ret.retn();
4723 }
4724
4725 /*!
4726  * Returns a pointer to the underground DataArrayInt instance. So the
4727  * caller should not decrRef() it. This method allows for a direct access to the field
4728  * values. This method is quite unusable if there is more than a nodal field or a cell
4729  * field on single geometric cell type. 
4730  *  \return DataArrayInt * - the pointer to the field values array.
4731  */
4732 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4733 {
4734   return getUndergroundDataArrayInt();
4735 }
4736
4737 /*!
4738  * Returns a pointer to the underground DataArrayInt instance. So the
4739  * caller should not decrRef() it. This method allows for a direct access to the field
4740  * values. This method is quite unusable if there is more than a nodal field or a cell
4741  * field on single geometric cell type. 
4742  *  \return DataArrayInt * - the pointer to the field values array.
4743  */
4744 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4745 {
4746   const DataArrayInt *ret=_arr;
4747   if(ret)
4748     return const_cast<DataArrayInt *>(ret);
4749   else
4750     return 0;
4751 }
4752
4753 /*!
4754  * Returns a pointer to the underground DataArrayInt instance and a
4755  * sequence describing parameters of a support of each part of \a this field. The
4756  * caller should not decrRef() the returned DataArrayInt. This method allows for a
4757  * direct access to the field values. This method is intended for the field lying on one
4758  * mesh only.
4759  *  \param [in,out] entries - the sequence describing parameters of a support of each
4760  *         part of \a this field. Each item of this sequence consists of two parts. The
4761  *         first part describes a type of mesh entity and an id of discretization of a
4762  *         current field part. The second part describes a range of values [begin,end)
4763  *         within the returned array relating to the current field part.
4764  *  \return DataArrayInt * - the pointer to the field values array.
4765  *  \throw If the number of underlying meshes is not equal to 1.
4766  *  \throw If no field values are available.
4767  *  \sa getUndergroundDataArray()
4768  */
4769 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4770 {
4771   return getUndergroundDataArrayIntExt(entries);
4772 }
4773
4774 /*!
4775  * Returns a pointer to the underground DataArrayInt instance and a
4776  * sequence describing parameters of a support of each part of \a this field. The
4777  * caller should not decrRef() the returned DataArrayInt. This method allows for a
4778  * direct access to the field values. This method is intended for the field lying on one
4779  * mesh only.
4780  *  \param [in,out] entries - the sequence describing parameters of a support of each
4781  *         part of \a this field. Each item of this sequence consists of two parts. The
4782  *         first part describes a type of mesh entity and an id of discretization of a
4783  *         current field part. The second part describes a range of values [begin,end)
4784  *         within the returned array relating to the current field part.
4785  *  \return DataArrayInt * - the pointer to the field values array.
4786  *  \throw If the number of underlying meshes is not equal to 1.
4787  *  \throw If no field values are available.
4788  *  \sa getUndergroundDataArray()
4789  */
4790 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4791 {
4792   if(_field_per_mesh.size()!=1)
4793     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4794   if(_field_per_mesh[0]==0)
4795     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4796   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4797   return getUndergroundDataArrayInt();
4798 }
4799
4800 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4801 {
4802   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
4803   ret->deepCpyLeavesFrom(*this);
4804   return ret.retn();
4805 }
4806
4807 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4808 {
4809   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
4810   if((const DataArrayInt *)_arr)
4811     ret->_arr=_arr->deepCpy();
4812   return ret.retn();
4813 }
4814
4815 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4816 {
4817   if(!arr)
4818     _arr=0;
4819   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
4820   if(!arrC)
4821     throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
4822   arrC->incrRef();
4823   _arr=arrC;
4824 }
4825
4826 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4827 {
4828   return DataArrayInt::New();
4829 }
4830
4831 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
4832 {
4833   DataArrayInt *ret=_arr;
4834   if(ret)
4835     return ret;
4836   _arr=DataArrayInt::New();
4837   return _arr;
4838 }
4839
4840 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
4841 {
4842   return getOrCreateAndGetArrayInt();
4843 }
4844
4845 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
4846 {
4847   const DataArrayInt *ret=_arr;
4848   if(ret)
4849     return ret;
4850   DataArrayInt *ret2=DataArrayInt::New();
4851   const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
4852   return ret2;
4853 }
4854
4855 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
4856 {
4857   return getOrCreateAndGetArrayInt();
4858 }
4859
4860 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
4861 {
4862 }
4863
4864 //= MEDFileAnyTypeField1TS
4865
4866 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
4867 {
4868   med_field_type typcha;
4869   //
4870   std::vector<std::string> infos;
4871   std::string dtunit,fieldName;
4872   LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
4873   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4874   switch(typcha)
4875     {
4876     case MED_FLOAT64:
4877       {
4878         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4879         break;
4880       }
4881     case MED_INT32:
4882       {
4883         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4884         break;
4885       }
4886     default:
4887       {
4888         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
4889         throw INTERP_KERNEL::Exception(oss.str().c_str());
4890       }
4891     }
4892   ret->setDtUnit(dtunit.c_str());
4893   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4894   //
4895   med_int numdt,numit;
4896   med_float dt;
4897   MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
4898   ret->setTime(numdt,numit,dt);
4899   ret->_csit=1;
4900   ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4901   return ret.retn();
4902 }
4903
4904 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
4905 try:MEDFileFieldGlobsReal(fileName)
4906 {
4907   MEDFileUtilities::CheckFileForRead(fileName);
4908   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4909   _content=BuildContentFrom(fid,fileName);
4910   loadGlobals(fid);
4911 }
4912 catch(INTERP_KERNEL::Exception& e)
4913   {
4914     throw e;
4915   }
4916
4917 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4918 {
4919   med_field_type typcha;
4920   std::vector<std::string> infos;
4921   std::string dtunit;
4922   int iii=-1;
4923   int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
4924   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
4925   switch(typcha)
4926     {
4927     case MED_FLOAT64:
4928       {
4929         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4930         break;
4931       }
4932     case MED_INT32:
4933       {
4934         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
4935         break;
4936       }
4937     default:
4938       {
4939         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
4940         throw INTERP_KERNEL::Exception(oss.str().c_str());
4941       }
4942     }
4943   ret->setDtUnit(dtunit.c_str());
4944   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
4945   //
4946   if(nbSteps<1)
4947     {
4948       std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
4949       throw INTERP_KERNEL::Exception(oss.str().c_str());
4950     }
4951   //
4952   med_int numdt,numit;
4953   med_float dt;
4954   MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
4955   ret->setTime(numdt,numit,dt);
4956   ret->_csit=1;
4957   ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
4958   return ret.retn();
4959 }
4960
4961 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
4962 try:MEDFileFieldGlobsReal(fileName)
4963 {
4964   MEDFileUtilities::CheckFileForRead(fileName);
4965   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4966   _content=BuildContentFrom(fid,fileName,fieldName);
4967   loadGlobals(fid);
4968 }
4969 catch(INTERP_KERNEL::Exception& e)
4970   {
4971     throw e;
4972   }
4973
4974 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
4975 {
4976   if(!c)
4977     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
4978   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
4979     {
4980       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
4981       ret->setFileName(fileName);
4982       ret->_content=c; c->incrRef();
4983       return ret.retn();
4984     }
4985   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
4986     {
4987       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
4988       ret->setFileName(fileName);
4989       ret->_content=c; c->incrRef();
4990       return ret.retn();
4991     }
4992   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
4993 }
4994
4995 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
4996 {
4997   MEDFileUtilities::CheckFileForRead(fileName);
4998   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
4999   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName);
5000   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5001   ret->loadGlobals(fid);
5002   return ret.retn();
5003 }
5004
5005 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5006 {
5007   MEDFileUtilities::CheckFileForRead(fileName);
5008   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5009   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
5010   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5011   ret->loadGlobals(fid);
5012   return ret.retn();
5013 }
5014
5015 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5016 {
5017   MEDFileUtilities::CheckFileForRead(fileName);
5018   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5019   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order);
5020   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5021   ret->loadGlobals(fid);
5022   return ret.retn();
5023 }
5024
5025 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5026 {
5027   med_field_type typcha;
5028   std::vector<std::string> infos;
5029   std::string dtunit;
5030   int iii=-1;
5031   int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5032   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5033   switch(typcha)
5034     {
5035     case MED_FLOAT64:
5036       {
5037         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5038         break;
5039       }
5040     case MED_INT32:
5041       {
5042         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5043         break;
5044       }
5045     default:
5046       {
5047         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5048         throw INTERP_KERNEL::Exception(oss.str().c_str());
5049       }
5050     }
5051   ret->setDtUnit(dtunit.c_str());
5052   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5053   //
5054   bool found=false;
5055   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5056   for(int i=0;i<nbOfStep2 && !found;i++)
5057     {
5058       med_int numdt,numit;
5059       med_float dt;
5060       MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5061       if(numdt==iteration && numit==order)
5062         {
5063           found=true;
5064           ret->_csit=i+1;
5065         }
5066       else
5067         dtits[i]=std::pair<int,int>(numdt,numit);
5068     }
5069   if(!found)
5070     {
5071       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5072       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5073         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5074       throw INTERP_KERNEL::Exception(oss.str().c_str());
5075     }
5076   ret->finishLoading(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5077   return ret.retn();
5078 }
5079
5080 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5081 try:MEDFileFieldGlobsReal(fileName)
5082 {
5083   MEDFileUtilities::CheckFileForRead(fileName);
5084   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5085   _content=BuildContentFrom(fid,fileName,fieldName,iteration,order);
5086   loadGlobals(fid);
5087 }
5088 catch(INTERP_KERNEL::Exception& e)
5089   {
5090     throw e;
5091   }
5092
5093 /*!
5094  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5095  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5096  *
5097  * \warning this is a shallow copy constructor
5098  */
5099 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5100 {
5101   if(!shallowCopyOfContent)
5102     {
5103       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5104       otherPtr->incrRef();
5105       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5106     }
5107   else
5108     {
5109       _content=other.shallowCpy();
5110     }
5111 }
5112
5113 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5114 {
5115   if(checkFieldId)
5116     {
5117       int nbFields=MEDnField(fid);
5118       if(fieldIdCFormat>=nbFields)
5119         {
5120           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5121           throw INTERP_KERNEL::Exception(oss.str().c_str());
5122         }
5123     }
5124   int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5125   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5126   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5127   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5128   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5129   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5130   med_bool localMesh;
5131   int nbOfStep;
5132   MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5133   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5134   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5135   infos.clear(); infos.resize(ncomp);
5136   for(int j=0;j<ncomp;j++)
5137     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5138   return nbOfStep;
5139 }
5140
5141 /*!
5142  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5143  * 
5144  * \param [out]
5145  * \return in case of success the number of time steps available for the field with name \a fieldName.
5146  */
5147 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5148 {
5149   int nbFields=MEDnField(fid);
5150   bool found=false;
5151   std::vector<std::string> fns(nbFields);
5152   int nbOfStep2=-1;
5153   for(int i=0;i<nbFields && !found;i++)
5154     {
5155       std::string tmp;
5156       nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5157       fns[i]=tmp;
5158       found=(tmp==fieldName);
5159       if(found)
5160         posCFormat=i;
5161     }
5162   if(!found)
5163     {
5164       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5165       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5166         oss << "\"" << *it << "\" ";
5167       throw INTERP_KERNEL::Exception(oss.str().c_str());
5168     }
5169   return nbOfStep2;
5170 }
5171
5172 /*!
5173  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5174  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5175  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5176  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5177  * to keep a valid instance.
5178  * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
5179  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5180  * If \b newPflName already exists and that \b forceRenameOnGlob is false (the default) an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newPflName.
5181  *
5182  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5183  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5184  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5185  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5186  * \param [in] newLocName is the new localization name.
5187  * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug.
5188  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5189  */
5190 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5191 {
5192   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5193   std::string oldPflName=disc->getProfile();
5194   std::vector<std::string> vv=getPflsReallyUsedMulti();
5195   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5196   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5197     {
5198       disc->setProfile(newPflName);
5199       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5200       pfl->setName(newPflName);
5201     }
5202   else
5203     {
5204       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5205       throw INTERP_KERNEL::Exception(oss.str().c_str());
5206     }
5207 }
5208
5209 /*!
5210  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5211  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5212  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5213  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5214  * to keep a valid instance.
5215  * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
5216  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5217  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5218  * If \b newLocName already exists an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newLocName.
5219  *
5220  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5221  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5222  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5223  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5224  * \param [in] newLocName is the new localization name.
5225  * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug.
5226  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5227  */
5228 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5229 {
5230   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5231   std::string oldLocName=disc->getLocalization();
5232   std::vector<std::string> vv=getLocsReallyUsedMulti();
5233   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5234   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5235     {
5236       disc->setLocalization(newLocName);
5237       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5238       loc.setName(newLocName);
5239     }
5240   else
5241     {
5242       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5243       throw INTERP_KERNEL::Exception(oss.str().c_str());
5244     }
5245 }
5246
5247 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5248 {
5249   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5250   if(!ret)
5251     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5252   return ret;
5253 }
5254
5255 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5256 {
5257   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5258   if(!ret)
5259     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5260   return ret;
5261 }
5262
5263 /*!
5264  * Writes \a this field into a MED file specified by its name.
5265  *  \param [in] fileName - the MED file name.
5266  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5267  * - 2 - erase; an existing file is removed.
5268  * - 1 - append; same data should not be present in an existing file.
5269  * - 0 - overwrite; same data present in an existing file is overwritten.
5270  *  \throw If the field name is not set.
5271  *  \throw If no field data is set.
5272  *  \throw If \a mode == 1 and the same data is present in an existing file.
5273  */
5274 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5275 {
5276   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5277   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5278   writeLL(fid);
5279 }
5280
5281 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5282 {
5283   int nbComp=getNumberOfComponents();
5284   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5285   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5286   for(int i=0;i<nbComp;i++)
5287     {
5288       std::string info=getInfo()[i];
5289       std::string c,u;
5290       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5291       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5292       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5293     }
5294   if(getName().empty())
5295     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5296   MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5297   writeGlobals(fid,*this);
5298   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5299 }
5300
5301 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5302 {
5303   std::size_t ret=0;
5304   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5305     ret+=_content->getHeapMemorySize();
5306   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5307 }
5308
5309 /*!
5310  * Returns a string describing \a this field. This string is outputted 
5311  * by \c print Python command.
5312  */
5313 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5314 {
5315   std::ostringstream oss;
5316   contentNotNullBase()->simpleRepr(0,oss,-1);
5317   simpleReprGlobs(oss);
5318   return oss.str();
5319 }
5320
5321 /*!
5322  * This method returns all profiles whose name is non empty used.
5323  * \b WARNING If profile is used several times it will be reported \b only \b once.
5324  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5325  */
5326 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5327 {
5328   return contentNotNullBase()->getPflsReallyUsed2();
5329 }
5330
5331 /*!
5332  * This method returns all localizations whose name is non empty used.
5333  * \b WARNING If localization is used several times it will be reported \b only \b once.
5334  */
5335 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5336 {
5337   return contentNotNullBase()->getLocsReallyUsed2();
5338 }
5339
5340 /*!
5341  * This method returns all profiles whose name is non empty used.
5342  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5343  */
5344 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5345 {
5346   return contentNotNullBase()->getPflsReallyUsedMulti2();
5347 }
5348
5349 /*!
5350  * This method returns all localizations whose name is non empty used.
5351  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5352  */
5353 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5354 {
5355   return contentNotNullBase()->getLocsReallyUsedMulti2();
5356 }
5357
5358 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5359 {
5360   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5361 }
5362
5363 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5364 {
5365   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5366 }
5367
5368 int MEDFileAnyTypeField1TS::getDimension() const
5369 {
5370   return contentNotNullBase()->getDimension();
5371 }
5372
5373 int MEDFileAnyTypeField1TS::getIteration() const
5374 {
5375   return contentNotNullBase()->getIteration();
5376 }
5377
5378 int MEDFileAnyTypeField1TS::getOrder() const
5379 {
5380   return contentNotNullBase()->getOrder();
5381 }
5382
5383 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5384 {
5385   return contentNotNullBase()->getTime(iteration,order);
5386 }
5387
5388 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5389 {
5390   contentNotNullBase()->setTime(iteration,order,val);
5391 }
5392
5393 std::string MEDFileAnyTypeField1TS::getName() const
5394 {
5395   return contentNotNullBase()->getName();
5396 }
5397
5398 void MEDFileAnyTypeField1TS::setName(const char *name)
5399 {
5400   contentNotNullBase()->setName(name);
5401 }
5402
5403 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5404 {
5405   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5406 }
5407
5408 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5409 {
5410   return contentNotNullBase()->getDtUnit();
5411 }
5412
5413 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5414 {
5415   contentNotNullBase()->setDtUnit(dtUnit);
5416 }
5417
5418 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5419 {
5420   return contentNotNullBase()->getMeshName();
5421 }
5422
5423 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5424 {
5425   contentNotNullBase()->setMeshName(newMeshName);
5426 }
5427
5428 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5429 {
5430   return contentNotNullBase()->changeMeshNames(modifTab);
5431 }
5432
5433 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5434 {
5435   return contentNotNullBase()->getMeshIteration();
5436 }
5437
5438 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5439 {
5440   return contentNotNullBase()->getMeshOrder();
5441 }
5442
5443 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5444 {
5445   return contentNotNullBase()->getNumberOfComponents();
5446 }
5447
5448 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5449 {
5450   return contentNotNullBase()->isDealingTS(iteration,order);
5451 }
5452
5453 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5454 {
5455   return contentNotNullBase()->getDtIt();
5456 }
5457
5458 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5459 {
5460   contentNotNullBase()->fillIteration(p);
5461 }
5462
5463 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5464 {
5465   contentNotNullBase()->fillTypesOfFieldAvailable(types);
5466 }
5467
5468 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5469 {
5470   contentNotNullBase()->setInfo(infos);
5471 }
5472
5473 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5474 {
5475   return contentNotNullBase()->getInfo();
5476 }
5477 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5478 {
5479   return contentNotNullBase()->getInfo();
5480 }
5481
5482 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5483 {
5484   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5485 }
5486
5487 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5488 {
5489   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5490 }
5491
5492 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5493 {
5494   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5495 }
5496
5497 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5498 {
5499   return contentNotNullBase()->getTypesOfFieldAvailable();
5500 }
5501
5502 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5503                                                                                        std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5504 {
5505   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5506 }
5507
5508 /*!
5509  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5510  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5511  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5512  */
5513 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5514 {
5515   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5516   if(!content)
5517     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5518   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5519   std::size_t sz(contentsSplit.size());
5520   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5521   for(std::size_t i=0;i<sz;i++)
5522     {
5523       ret[i]=shallowCpy();
5524       ret[i]->_content=contentsSplit[i];
5525     }
5526   return ret;
5527 }
5528
5529 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5530 {
5531   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5532   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5533     ret->_content=_content->deepCpy();
5534   ret->deepCpyGlobs(*this);
5535   return ret.retn();
5536 }
5537
5538 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5539 {
5540   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5541 }
5542
5543 //= MEDFileField1TS
5544
5545 /*!
5546  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
5547  * the first field that has been read from a specified MED file.
5548  *  \param [in] fileName - the name of the MED file to read.
5549  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5550  *          is to delete this field using decrRef() as it is no more needed.
5551  *  \throw If reading the file fails.
5552  */
5553 MEDFileField1TS *MEDFileField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5554 {
5555   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName);
5556   ret->contentNotNull();
5557   return ret.retn();
5558 }
5559
5560 /*!
5561  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
5562  * a given field that has been read from a specified MED file.
5563  *  \param [in] fileName - the name of the MED file to read.
5564  *  \param [in] fieldName - the name of the field to read.
5565  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5566  *          is to delete this field using decrRef() as it is no more needed.
5567  *  \throw If reading the file fails.
5568  *  \throw If there is no field named \a fieldName in the file.
5569  */
5570 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5571 {
5572   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName);
5573   ret->contentNotNull();
5574   return ret.retn();
5575 }
5576
5577 /*!
5578  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
5579  * a given field that has been read from a specified MED file.
5580  *  \param [in] fileName - the name of the MED file to read.
5581  *  \param [in] fieldName - the name of the field to read.
5582  *  \param [in] iteration - the iteration number of a required time step.
5583  *  \param [in] order - the iteration order number of required time step.
5584  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5585  *          is to delete this field using decrRef() as it is no more needed.
5586  *  \throw If reading the file fails.
5587  *  \throw If there is no field named \a fieldName in the file.
5588  *  \throw If the required time step is missing from the file.
5589  */
5590 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5591 {
5592   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order);
5593   ret->contentNotNull();
5594   return ret.retn();
5595 }
5596
5597 /*!
5598  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5599  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5600  *
5601  * Returns a new instance of MEDFileField1TS holding either a shallow copy
5602  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5603  * \warning this is a shallow copy constructor
5604  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5605  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5606  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5607  *          is to delete this field using decrRef() as it is no more needed.
5608  */
5609 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5610 {
5611   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5612   ret->contentNotNull();
5613   return ret.retn();
5614 }
5615
5616 /*!
5617  * Returns a new empty instance of MEDFileField1TS.
5618  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5619  *          is to delete this field using decrRef() as it is no more needed.
5620  */
5621 MEDFileField1TS *MEDFileField1TS::New()
5622 {
5623   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5624   ret->contentNotNull();
5625   return ret.retn();
5626 }
5627
5628 /*!
5629  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5630  * following the given input policy.
5631  *
5632  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5633  *                            By default (true) the globals are deeply copied.
5634  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5635  */
5636 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5637 {
5638   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5639   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5640   if(content)
5641     {
5642       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5643       if(!contc)
5644         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5645       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5646       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5647     }
5648   else
5649     ret=MEDFileIntField1TS::New();
5650   if(deepCpyGlobs)
5651     ret->deepCpyGlobs(*this);
5652   else
5653     ret->shallowCpyGlobs(*this);
5654   return ret.retn();
5655 }
5656
5657 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5658 {
5659   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5660   if(!pt)
5661     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5662   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5663   if(!ret)
5664     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
5665   return ret;
5666 }
5667
5668 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5669 {
5670   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5671   if(!pt)
5672     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5673   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5674   if(!ret)
5675     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
5676   return ret;
5677 }
5678
5679 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5680 {
5681   if(!f)
5682     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5683   if(!((DataArray*)arr))
5684     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5685   DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5686   if(!arrOutC)
5687     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5688   f->setArray(arrOutC);
5689 }
5690
5691 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5692 {
5693   if(!((DataArray*)arr))
5694     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5695   DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5696   if(!arrOutC)
5697     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5698   arrOutC->incrRef();
5699   return arrOutC;
5700 }
5701
5702 MEDFileField1TS::MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
5703 try:MEDFileAnyTypeField1TS(fileName)
5704 {
5705 }
5706 catch(INTERP_KERNEL::Exception& e)
5707   { throw e; }
5708
5709 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
5710 try:MEDFileAnyTypeField1TS(fileName,fieldName)
5711 {
5712 }
5713 catch(INTERP_KERNEL::Exception& e)
5714   { throw e; }
5715
5716 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
5717 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
5718 {
5719 }
5720 catch(INTERP_KERNEL::Exception& e)
5721   { throw e; }
5722
5723 /*!
5724  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5725  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5726  *
5727  * \warning this is a shallow copy constructor
5728  */
5729 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5730 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
5731 {
5732 }
5733 catch(INTERP_KERNEL::Exception& e)
5734   { throw e; }
5735
5736 MEDFileField1TS::MEDFileField1TS()
5737 {
5738   _content=new MEDFileField1TSWithoutSDA;
5739 }
5740
5741 /*!
5742  * Returns a new MEDCouplingFieldDouble of a given type lying on
5743  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
5744  * has not been constructed via file reading, an exception is thrown.
5745  * For more info, see \ref AdvMEDLoaderAPIFieldRW
5746  *  \param [in] type - a spatial discretization of interest.
5747  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5748  *  \param [in] renumPol - specifies how to permute values of the result field according to
5749  *          the optional numbers of cells and nodes, if any. The valid values are
5750  *          - 0 - do not permute.
5751  *          - 1 - permute cells.
5752  *          - 2 - permute nodes.
5753  *          - 3 - permute cells and nodes.
5754  *
5755  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5756  *          caller is to delete this field using decrRef() as it is no more needed. 
5757  *  \throw If \a this field has not been constructed via file reading.
5758  *  \throw If the MED file is not readable.
5759  *  \throw If there is no mesh in the MED file.
5760  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5761  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5762  *  \sa getFieldOnMeshAtLevel()
5763  */
5764 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5765 {
5766   if(getFileName2().empty())
5767     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5768   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5769   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
5770   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5771   return ret.retn();
5772 }
5773
5774 /*!
5775  * Returns a new MEDCouplingFieldDouble of a given type lying on
5776  * the top level cells of the first mesh in MED file. If \a this field 
5777  * has not been constructed via file reading, an exception is thrown.
5778  * For more info, see \ref AdvMEDLoaderAPIFieldRW
5779  *  \param [in] type - a spatial discretization of interest.
5780  *  \param [in] renumPol - specifies how to permute values of the result field according to
5781  *          the optional numbers of cells and nodes, if any. The valid values are
5782  *          - 0 - do not permute.
5783  *          - 1 - permute cells.
5784  *          - 2 - permute nodes.
5785  *          - 3 - permute cells and nodes.
5786  *
5787  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5788  *          caller is to delete this field using decrRef() as it is no more needed. 
5789  *  \throw If \a this field has not been constructed via file reading.
5790  *  \throw If the MED file is not readable.
5791  *  \throw If there is no mesh in the MED file.
5792  *  \throw If no field values of the given \a type.
5793  *  \throw If no field values lying on the top level support.
5794  *  \sa getFieldAtLevel()
5795  */
5796 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
5797 {
5798   if(getFileName2().empty())
5799     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
5800   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5801   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
5802   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5803   return ret.retn();
5804 }
5805
5806 /*!
5807  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
5808  * For more info, see \ref AdvMEDLoaderAPIFieldRW
5809  *  \param [in] type - a spatial discretization of the new field.
5810  *  \param [in] mesh - the supporting mesh.
5811  *  \param [in] renumPol - specifies how to permute values of the result field according to
5812  *          the optional numbers of cells and nodes, if any. The valid values are
5813  *          - 0 - do not permute.
5814  *          - 1 - permute cells.
5815  *          - 2 - permute nodes.
5816  *          - 3 - permute cells and nodes.
5817  *
5818  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5819  *          caller is to delete this field using decrRef() as it is no more needed. 
5820  *  \throw If no field of \a this is lying on \a mesh.
5821  *  \throw If the mesh is empty.
5822  *  \throw If no field values of the given \a type are available.
5823  *  \sa getFieldAtLevel()
5824  *  \sa getFieldOnMeshAtLevel() 
5825  */
5826 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5827 {
5828   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5829   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
5830   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5831   return ret.retn();
5832 }
5833
5834 /*!
5835  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5836  * For more info, see \ref AdvMEDLoaderAPIFieldRW
5837  *  \param [in] type - a spatial discretization of interest.
5838  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5839  *  \param [in] mesh - the supporting mesh.
5840  *  \param [in] renumPol - specifies how to permute values of the result field according to
5841  *          the optional numbers of cells and nodes, if any. The valid values are
5842  *          - 0 - do not permute.
5843  *          - 1 - permute cells.
5844  *          - 2 - permute nodes.
5845  *          - 3 - permute cells and nodes.
5846  *
5847  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5848  *          caller is to delete this field using decrRef() as it is no more needed. 
5849  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5850  *  \throw If no field of \a this is lying on \a mesh.
5851  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5852  *  \sa getFieldAtLevel()
5853  *  \sa getFieldOnMeshAtLevel() 
5854  */
5855 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
5856 {
5857   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5858   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
5859   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5860   return ret.retn();
5861 }
5862
5863 /*!
5864  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
5865  * This method is called "Old" because in MED3 norm a field has only one meshName
5866  * attached, so this method is for readers of MED2 files. If \a this field 
5867  * has not been constructed via file reading, an exception is thrown.
5868  * For more info, see \ref AdvMEDLoaderAPIFieldRW
5869  *  \param [in] type - a spatial discretization of interest.
5870  *  \param [in] mName - a name of the supporting mesh.
5871  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5872  *  \param [in] renumPol - specifies how to permute values of the result field according to
5873  *          the optional numbers of cells and nodes, if any. The valid values are
5874  *          - 0 - do not permute.
5875  *          - 1 - permute cells.
5876  *          - 2 - permute nodes.
5877  *          - 3 - permute cells and nodes.
5878  *
5879  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5880  *          caller is to delete this field using decrRef() as it is no more needed. 
5881  *  \throw If the MED file is not readable.
5882  *  \throw If there is no mesh named \a mName in the MED file.
5883  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5884  *  \throw If \a this field has not been constructed via file reading.
5885  *  \throw If no field of \a this is lying on the mesh named \a mName.
5886  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5887  *  \sa getFieldAtLevel()
5888  */
5889 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
5890 {
5891   if(getFileName2().empty())
5892     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
5893   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
5894   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
5895   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
5896   return ret.retn();
5897 }
5898
5899 /*!
5900  * Returns values and a profile of the field of a given type lying on a given support.
5901  * For more info, see \ref AdvMEDLoaderAPIFieldRW
5902  *  \param [in] type - a spatial discretization of the field.
5903  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5904  *  \param [in] mesh - the supporting mesh.
5905  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5906  *          field of interest lies on. If the field lies on all entities of the given
5907  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5908  *          using decrRef() as it is no more needed.  
5909  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5910  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5911  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5912  *  \throw If no field of \a this is lying on \a mesh.
5913  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5914  */
5915 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
5916 {
5917   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
5918   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
5919 }
5920
5921 /*!
5922  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5923  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5924  * "Sort By Type"), if not, an exception is thrown. 
5925  * For more info, see \ref AdvMEDLoaderAPIFieldRW
5926  *  \param [in] field - the field to add to \a this.
5927  *  \throw If the name of \a field is empty.
5928  *  \throw If the data array of \a field is not set.
5929  *  \throw If the data array is already allocated but has different number of components
5930  *         than \a field.
5931  *  \throw If the underlying mesh of \a field has no name.
5932  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5933  */
5934 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
5935 {
5936   setFileName("");
5937   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
5938 }
5939
5940 /*!
5941  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5942  * of a given mesh are used as the support of the given field (a real support is not used). 
5943  * Elements of the given mesh must be sorted suitable for writing to MED file.
5944  * Order of underlying mesh entities of the given field specified by \a profile parameter
5945  * is not prescribed; this method permutes field values to have them sorted by element
5946  * type as required for writing to MED file. A new profile is added only if no equal
5947  * profile is missing.
5948  * For more info, see \ref AdvMEDLoaderAPIFieldRW
5949  *  \param [in] field - the field to add to \a this.
5950  *  \param [in] mesh - the supporting mesh of \a field.
5951  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5952  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
5953  *  \throw If either \a field or \a mesh or \a profile has an empty name.
5954  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5955  *  \throw If the data array of \a field is not set.
5956  *  \throw If the data array of \a this is already allocated but has different number of
5957  *         components than \a field.
5958  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5959  *  \sa setFieldNoProfileSBT()
5960  */
5961 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
5962 {
5963   setFileName("");
5964   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
5965 }
5966
5967 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
5968 {
5969   return new MEDFileField1TS(*this);
5970 }
5971
5972 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
5973 {
5974   return contentNotNull()->getUndergroundDataArrayDouble();
5975 }
5976
5977 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
5978 {
5979   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
5980 }
5981
5982 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5983                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5984 {
5985   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
5986 }
5987
5988 //= MEDFileIntField1TS
5989
5990 MEDFileIntField1TS *MEDFileIntField1TS::New()
5991 {
5992   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
5993   ret->contentNotNull();
5994   return ret.retn();
5995 }
5996
5997 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
5998 {
5999   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName);
6000   ret->contentNotNull();
6001   return ret.retn();
6002 }
6003
6004 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
6005 {
6006   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName);
6007   ret->contentNotNull();
6008   return ret.retn();
6009 }
6010
6011 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
6012 {
6013   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order);
6014   ret->contentNotNull();
6015   return ret.retn();
6016 }
6017
6018 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6019 {
6020   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6021   ret->contentNotNull();
6022   return ret.retn();
6023 }
6024
6025 MEDFileIntField1TS::MEDFileIntField1TS()
6026 {
6027   _content=new MEDFileIntField1TSWithoutSDA;
6028 }
6029
6030 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName) throw(INTERP_KERNEL::Exception)
6031 try:MEDFileAnyTypeField1TS(fileName)
6032 {
6033 }
6034 catch(INTERP_KERNEL::Exception& e)
6035   { throw e; }
6036
6037 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
6038 try:MEDFileAnyTypeField1TS(fileName,fieldName)
6039 {
6040 }
6041 catch(INTERP_KERNEL::Exception& e)
6042   { throw e; }
6043
6044 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
6045 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order)
6046 {
6047 }
6048 catch(INTERP_KERNEL::Exception& e)
6049   { throw e; }
6050
6051 /*!
6052  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6053  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6054  *
6055  * \warning this is a shallow copy constructor
6056  */
6057 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6058 {
6059 }
6060
6061 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6062 {
6063   return new MEDFileIntField1TS(*this);
6064 }
6065
6066 /*!
6067  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6068  * following the given input policy.
6069  *
6070  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6071  *                            By default (true) the globals are deeply copied.
6072  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6073  */
6074 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6075 {
6076   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6077   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6078   if(content)
6079     {
6080       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6081       if(!contc)
6082         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6083       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6084       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6085     }
6086   else
6087     ret=MEDFileField1TS::New();
6088   if(deepCpyGlobs)
6089     ret->deepCpyGlobs(*this);
6090   else
6091     ret->shallowCpyGlobs(*this);
6092   return ret.retn();
6093 }
6094
6095 /*!
6096  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6097  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6098  * "Sort By Type"), if not, an exception is thrown. 
6099  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6100  *  \param [in] field - the field to add to \a this. The field double values are ignored.
6101  *  \param [in] arrOfVals - the values of the field \a field used.
6102  *  \throw If the name of \a field is empty.
6103  *  \throw If the data array of \a field is not set.
6104  *  \throw If the data array is already allocated but has different number of components
6105  *         than \a field.
6106  *  \throw If the underlying mesh of \a field has no name.
6107  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6108  */
6109 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6110 {
6111   setFileName("");
6112   contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6113 }
6114
6115 /*!
6116  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
6117  * of a given mesh are used as the support of the given field (a real support is not used). 
6118  * Elements of the given mesh must be sorted suitable for writing to MED file.
6119  * Order of underlying mesh entities of the given field specified by \a profile parameter
6120  * is not prescribed; this method permutes field values to have them sorted by element
6121  * type as required for writing to MED file. A new profile is added only if no equal
6122  * profile is missing.
6123  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6124  *  \param [in] field - the field to add to \a this. The field double values are ignored.
6125  *  \param [in] arrOfVals - the values of the field \a field used.
6126  *  \param [in] mesh - the supporting mesh of \a field.
6127  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
6128  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6129  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6130  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6131  *  \throw If the data array of \a field is not set.
6132  *  \throw If the data array of \a this is already allocated but has different number of
6133  *         components than \a field.
6134  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6135  *  \sa setFieldNoProfileSBT()
6136  */
6137 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6138 {
6139   setFileName("");
6140   contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6141 }
6142
6143 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6144 {
6145   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6146   if(!pt)
6147     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6148   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6149   if(!ret)
6150     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
6151   return ret;
6152 }
6153
6154 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6155 {
6156   if(getFileName2().empty())
6157     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6158   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6159   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6160   DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6161   if(!arrOutC)
6162     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6163   arrOut=arrOutC;
6164   return ret.retn();
6165 }
6166
6167 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6168 {
6169   if(!((DataArray *)arr))
6170     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6171   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6172   if(!arrC)
6173     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6174   arrC->incrRef();
6175   return arrC;
6176 }
6177
6178 /*!
6179  * Returns a new MEDCouplingFieldDouble of a given type lying on
6180  * the top level cells of the first mesh in MED file. If \a this field 
6181  * has not been constructed via file reading, an exception is thrown.
6182  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6183  *  \param [in] type - a spatial discretization of interest.
6184  *  \param [out] arrOut - the DataArrayInt containing values of field.
6185  *  \param [in] renumPol - specifies how to permute values of the result field according to
6186  *          the optional numbers of cells and nodes, if any. The valid values are
6187  *          - 0 - do not permute.
6188  *          - 1 - permute cells.
6189  *          - 2 - permute nodes.
6190  *          - 3 - permute cells and nodes.
6191  *
6192  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6193  *          caller is to delete this field using decrRef() as it is no more needed. 
6194  *  \throw If \a this field has not been constructed via file reading.
6195  *  \throw If the MED file is not readable.
6196  *  \throw If there is no mesh in the MED file.
6197  *  \throw If no field values of the given \a type.
6198  *  \throw If no field values lying on the top level support.
6199  *  \sa getFieldAtLevel()
6200  */
6201 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6202 {
6203   if(getFileName2().empty())
6204     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6205   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6206   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6207   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6208   return ret.retn();
6209 }
6210
6211 /*!
6212  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6213  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6214  *  \param [in] type - a spatial discretization of the new field.
6215  *  \param [in] mesh - the supporting mesh.
6216  *  \param [out] arrOut - the DataArrayInt containing values of field.
6217  *  \param [in] renumPol - specifies how to permute values of the result field according to
6218  *          the optional numbers of cells and nodes, if any. The valid values are
6219  *          - 0 - do not permute.
6220  *          - 1 - permute cells.
6221  *          - 2 - permute nodes.
6222  *          - 3 - permute cells and nodes.
6223  *
6224  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6225  *          caller is to delete this field using decrRef() as it is no more needed. 
6226  *  \throw If no field of \a this is lying on \a mesh.
6227  *  \throw If the mesh is empty.
6228  *  \throw If no field values of the given \a type are available.
6229  *  \sa getFieldAtLevel()
6230  *  \sa getFieldOnMeshAtLevel() 
6231  */
6232 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6233 {
6234   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6235   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6236   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6237   return ret.retn();
6238 }
6239
6240 /*!
6241  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6242  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6243  *  \param [in] type - a spatial discretization of interest.
6244  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6245  *  \param [out] arrOut - the DataArrayInt containing values of field.
6246  *  \param [in] mesh - the supporting mesh.
6247  *  \param [in] renumPol - specifies how to permute values of the result field according to
6248  *          the optional numbers of cells and nodes, if any. The valid values are
6249  *          - 0 - do not permute.
6250  *          - 1 - permute cells.
6251  *          - 2 - permute nodes.
6252  *          - 3 - permute cells and nodes.
6253  *
6254  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6255  *          caller is to delete this field using decrRef() as it is no more needed. 
6256  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6257  *  \throw If no field of \a this is lying on \a mesh.
6258  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6259  *  \sa getFieldAtLevel()
6260  *  \sa getFieldOnMeshAtLevel() 
6261  */
6262 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6263 {
6264   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6265   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6266   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6267   return ret.retn();
6268 }
6269
6270 /*!
6271  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6272  * This method is called "Old" because in MED3 norm a field has only one meshName
6273  * attached, so this method is for readers of MED2 files. If \a this field 
6274  * has not been constructed via file reading, an exception is thrown.
6275  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6276  *  \param [in] type - a spatial discretization of interest.
6277  *  \param [in] mName - a name of the supporting mesh.
6278  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6279  *  \param [out] arrOut - the DataArrayInt containing values of field.
6280  *  \param [in] renumPol - specifies how to permute values of the result field according to
6281  *          the optional numbers of cells and nodes, if any. The valid values are
6282  *          - 0 - do not permute.
6283  *          - 1 - permute cells.
6284  *          - 2 - permute nodes.
6285  *          - 3 - permute cells and nodes.
6286  *
6287  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6288  *          caller is to delete this field using decrRef() as it is no more needed. 
6289  *  \throw If the MED file is not readable.
6290  *  \throw If there is no mesh named \a mName in the MED file.
6291  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6292  *  \throw If \a this field has not been constructed via file reading.
6293  *  \throw If no field of \a this is lying on the mesh named \a mName.
6294  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6295  *  \sa getFieldAtLevel()
6296  */
6297 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6298 {
6299   if(getFileName2().empty())
6300     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6301   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6302   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6303   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6304   return ret.retn();
6305 }
6306
6307 /*!
6308  * Returns values and a profile of the field of a given type lying on a given support.
6309  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6310  *  \param [in] type - a spatial discretization of the field.
6311  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6312  *  \param [in] mesh - the supporting mesh.
6313  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6314  *          field of interest lies on. If the field lies on all entities of the given
6315  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6316  *          using decrRef() as it is no more needed.  
6317  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6318  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6319  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6320  *  \throw If no field of \a this is lying on \a mesh.
6321  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6322  */
6323 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6324 {
6325   MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6326   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6327 }
6328
6329 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6330 {
6331   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6332   if(!pt)
6333     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6334   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6335   if(!ret)
6336     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is not null but it is not of type int32 ! Reason is maybe that the read field has not the type INT32 !");
6337   return ret;
6338 }
6339
6340 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6341 {
6342   return contentNotNull()->getUndergroundDataArrayInt();
6343 }
6344
6345 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6346
6347 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6348 {
6349 }
6350
6351 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6352 {
6353 }
6354
6355 /*!
6356  * \param [in] fieldId field id in C mode
6357  */
6358 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
6359 {
6360   med_field_type typcha;
6361   std::string dtunitOut;
6362   int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6363   setDtUnit(dtunitOut.c_str());
6364   finishLoading(fid,nbOfStep,typcha);
6365 }
6366
6367 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
6368 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6369 {
6370   setDtUnit(dtunit.c_str());
6371   finishLoading(fid,nbOfStep,fieldTyp);
6372 }
6373 catch(INTERP_KERNEL::Exception& e)
6374 {
6375   throw e;
6376 }
6377
6378 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6379 {
6380   std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6381   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6382     ret+=(*it).capacity();
6383   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6384     if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6385       ret+=(*it)->getHeapMemorySize();
6386   return ret;
6387 }
6388
6389 /*!
6390  * If one of the id in [ \a startIds , \a endIds ) points to a null element, there is not throw. Simply, this empty element is added as if it were not
6391  * NULL.
6392  */
6393 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6394 {
6395   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6396   ret->setInfo(_infos);
6397   int sz=(int)_time_steps.size();
6398   for(const int *id=startIds;id!=endIds;id++)
6399     {
6400       if(*id>=0 && *id<sz)
6401         {
6402           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6403           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6404           if(tse)
6405             {
6406               tse->incrRef();
6407               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6408             }
6409           ret->pushBackTimeStep(tse2);
6410         }
6411       else
6412         {
6413           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6414           oss << " ! Should be in [0," << sz << ") !";
6415           throw INTERP_KERNEL::Exception(oss.str().c_str());
6416         }
6417     }
6418   if(ret->getNumberOfTS()>0)
6419     ret->synchronizeNameScope();
6420   ret->copyNameScope(*this);
6421   return ret.retn();
6422 }
6423
6424 /*!
6425  * If one of the id in the input range points to a null element, there is not throw. Simply, this empty element is added as if it were not
6426  * NULL.
6427  */
6428 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6429 {
6430   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6431   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6432   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6433   ret->setInfo(_infos);
6434   int sz=(int)_time_steps.size();
6435   int j=bg;
6436   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6437     {
6438       if(j>=0 && j<sz)
6439         {
6440           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6441           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6442           if(tse)
6443             {
6444               tse->incrRef();
6445               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6446             }
6447           ret->pushBackTimeStep(tse2);
6448         }
6449       else
6450         {
6451           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6452           oss << " ! Should be in [0," << sz << ") !";
6453           throw INTERP_KERNEL::Exception(oss.str().c_str());
6454         }
6455     }
6456   if(ret->getNumberOfTS()>0)
6457     ret->synchronizeNameScope();
6458   ret->copyNameScope(*this);
6459   return ret.retn();
6460 }
6461
6462 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6463 {
6464   int id=0;
6465   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6466   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6467     {
6468       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6469       if(!cur)
6470         continue;
6471       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6472       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6473         ids->pushBackSilent(id);
6474     }
6475   return buildFromTimeStepIds(ids->begin(),ids->end());
6476 }
6477
6478 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6479 {
6480   int id=0;
6481   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6482   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6483     {
6484       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6485       if(!cur)
6486         continue;
6487       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6488       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6489         ids->pushBackSilent(id);
6490     }
6491   return buildFromTimeStepIds(ids->begin(),ids->end());
6492 }
6493
6494 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6495 {
6496   return _infos;
6497 }
6498
6499 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6500 {
6501   _infos=info;
6502 }
6503
6504 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6505 {
6506   int ret=0;
6507   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6508     {
6509       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6510       if(pt->isDealingTS(iteration,order))
6511         return ret;
6512     }
6513   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6514   std::vector< std::pair<int,int> > vp=getIterations();
6515   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6516     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6517   throw INTERP_KERNEL::Exception(oss.str().c_str());
6518 }
6519
6520 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6521 {
6522   return *_time_steps[getTimeStepPos(iteration,order)];
6523 }
6524
6525 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6526 {
6527   return *_time_steps[getTimeStepPos(iteration,order)];
6528 }
6529
6530 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6531 {
6532   if(_time_steps.empty())
6533     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6534   return _time_steps[0]->getMeshName();
6535 }
6536
6537 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6538 {
6539   std::string oldName(getMeshName());
6540   std::vector< std::pair<std::string,std::string> > v(1);
6541   v[0].first=oldName; v[0].second=newMeshName;
6542   changeMeshNames(v);
6543 }
6544
6545 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6546 {
6547   bool ret=false;
6548   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6549     {
6550       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6551       if(cur)
6552         ret=cur->changeMeshNames(modifTab) || ret;
6553     }
6554   return ret;
6555 }
6556
6557 /*!
6558  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6559  */
6560 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6561 {
6562   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6563 }
6564
6565 /*!
6566  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6567  */
6568 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6569 {
6570   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6571 }
6572
6573 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6574                                                                 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6575 {
6576   bool ret=false;
6577   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6578     {
6579       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6580       if(f1ts)
6581         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6582     }
6583   return ret;
6584 }
6585
6586 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6587 {
6588   std::string startLine(bkOffset,' ');
6589   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6590   if(fmtsId>=0)
6591     oss << " (" << fmtsId << ")";
6592   oss << " has the following name: \"" << _name << "\"." << std::endl;
6593   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6594   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6595     {
6596       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
6597     }
6598   int i=0;
6599   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6600     {
6601       std::string chapter(17,'0'+i);
6602       oss << startLine << chapter << std::endl;
6603       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6604       if(cur)
6605         cur->simpleRepr(bkOffset+2,oss,i);
6606       else
6607         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
6608       oss << startLine << chapter << std::endl;
6609     }
6610 }
6611
6612 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6613 {
6614   std::size_t sz=_time_steps.size();
6615   std::vector< std::pair<int,int> > ret(sz);
6616   ret1.resize(sz);
6617   for(std::size_t i=0;i<sz;i++)
6618     {
6619       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6620       if(f1ts)
6621         {
6622           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6623         }
6624       else
6625         {
6626           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6627           throw INTERP_KERNEL::Exception(oss.str().c_str());
6628         }
6629     }
6630   return ret;
6631 }
6632
6633 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6634 {
6635   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6636   if(!tse2)
6637     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6638   checkCoherencyOfType(tse2);
6639   if(_time_steps.empty())
6640     {
6641       setName(tse2->getName().c_str());
6642       setInfo(tse2->getInfo());
6643     }
6644   checkThatComponentsMatch(tse2->getInfo());
6645   _time_steps.push_back(tse);
6646 }
6647
6648 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6649 {
6650   std::size_t nbOfCompo=_infos.size();
6651   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6652     {
6653       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6654       if(cur)
6655         {
6656           if((cur->getInfo()).size()!=nbOfCompo)
6657             {
6658               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6659               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6660               throw INTERP_KERNEL::Exception(oss.str().c_str());
6661             }
6662           cur->copyNameScope(*this);
6663         }
6664     }
6665 }
6666
6667 void MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading(med_idt fid, int nbPdt, med_field_type fieldTyp) throw(INTERP_KERNEL::Exception)
6668 {
6669   _time_steps.resize(nbPdt);
6670   for(int i=0;i<nbPdt;i++)
6671     {
6672       std::vector< std::pair<int,int> > ts;
6673       med_int numdt=0,numo=0;
6674       med_int meshIt=0,meshOrder=0;
6675       med_float dt=0.0;
6676       MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6677       switch(fieldTyp)
6678         {
6679         case MED_FLOAT64:
6680           {
6681             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6682             break;
6683           }
6684         case MED_INT32:
6685           {
6686             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6687             break;
6688           }
6689         default:
6690           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::finishLoading : managed field type are : FLOAT64, INT32 !");
6691         }
6692       _time_steps[i]->finishLoading(fid,*this);
6693     }
6694 }
6695
6696 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6697 {
6698   if(_time_steps.empty())
6699     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6700   checkThatNbOfCompoOfTSMatchThis();
6701   std::vector<std::string> infos(getInfo());
6702   int nbComp=infos.size();
6703   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6704   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6705   for(int i=0;i<nbComp;i++)
6706     {
6707       std::string info=infos[i];
6708       std::string c,u;
6709       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6710       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6711       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
6712     }
6713   if(_name.empty())
6714     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
6715   MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
6716   int nbOfTS=_time_steps.size();
6717   for(int i=0;i<nbOfTS;i++)
6718     _time_steps[i]->writeLL(fid,opts,*this);
6719 }
6720
6721 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
6722 {
6723   return _time_steps.size();
6724 }
6725
6726 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
6727 {
6728   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
6729   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6730     {
6731       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
6732       if(tmp)
6733         newTS.push_back(*it);
6734     }
6735   _time_steps=newTS;
6736 }
6737
6738 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
6739 {
6740   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6741   int maxId=(int)_time_steps.size();
6742   int ii=0;
6743   std::set<int> idsToDel;
6744   for(const int *id=startIds;id!=endIds;id++,ii++)
6745     {
6746       if(*id>=0 && *id<maxId)
6747         {
6748           idsToDel.insert(*id);
6749         }
6750       else
6751         {
6752           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
6753           throw INTERP_KERNEL::Exception(oss.str().c_str());
6754         }
6755     }
6756   for(int iii=0;iii<maxId;iii++)
6757     if(idsToDel.find(iii)==idsToDel.end())
6758       newTS.push_back(_time_steps[iii]);
6759   _time_steps=newTS;
6760 }
6761
6762 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
6763 {
6764   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
6765   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6766   if(nbOfEntriesToKill==0)
6767     return ;
6768   std::size_t sz=_time_steps.size();
6769   std::vector<bool> b(sz,true);
6770   int j=bg;
6771   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
6772     b[j]=false;
6773   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
6774   for(std::size_t i=0;i<sz;i++)
6775     if(b[i])
6776       newTS.push_back(_time_steps[i]);
6777   _time_steps=newTS;
6778 }
6779
6780 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6781 {
6782   int ret=0;
6783   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
6784   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6785     {
6786       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6787       if(tmp)
6788         {
6789           int it2,ord;
6790           tmp->getTime(it2,ord);
6791           if(it2==iteration && order==ord)
6792             return ret;
6793           else
6794             oss << "(" << it2 << ","  << ord << "), ";
6795         }
6796     }
6797   throw INTERP_KERNEL::Exception(oss.str().c_str());
6798 }
6799
6800 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
6801 {
6802   int ret=0;
6803   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
6804   oss.precision(15);
6805   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6806     {
6807       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
6808       if(tmp)
6809         {
6810           int it2,ord;
6811           double ti=tmp->getTime(it2,ord);
6812           if(fabs(time-ti)<eps)
6813             return ret;
6814           else
6815             oss << ti << ", ";
6816         }
6817     }
6818   throw INTERP_KERNEL::Exception(oss.str().c_str());
6819 }
6820
6821 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
6822 {
6823   int lgth=_time_steps.size();
6824   std::vector< std::pair<int,int> > ret(lgth);
6825   for(int i=0;i<lgth;i++)
6826     _time_steps[i]->fillIteration(ret[i]);
6827   return ret;
6828 }
6829
6830 /*!
6831  * This method has 3 inputs 'iteration' 'order' 'mname'. 'mname' can be null if the user is the general case where there is only one meshName lying on 'this'
6832  * This method returns two things.
6833  * - The absolute dimension of 'this' in first parameter. 
6834  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
6835  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
6836  *
6837  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
6838  * Only these 3 discretizations will be taken into account here.
6839  *
6840  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
6841  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
6842  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
6843  *
6844  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
6845  * It is possible (even if it is not common) that the highest level in 'this' were not equal to the meshDimension of the underlying mesh in 'this'.
6846  * 
6847  * Let's consider the typical following case :
6848  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
6849  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
6850  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
6851  *   TETRA4 and SEG2
6852  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
6853  *
6854  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
6855  * 
6856  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
6857  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
6858  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
6859  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
6860  */
6861 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
6862 {
6863   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
6864 }
6865
6866 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
6867 {
6868   if(pos<0 || pos>=(int)_time_steps.size())
6869     {
6870       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6871       throw INTERP_KERNEL::Exception(oss.str().c_str());
6872     }
6873   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6874   if(item==0)
6875     {
6876       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6877       oss << "\nTry to use following method eraseEmptyTS !";
6878       throw INTERP_KERNEL::Exception(oss.str().c_str());
6879     }
6880   return item;
6881 }
6882
6883 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
6884 {
6885   if(pos<0 || pos>=(int)_time_steps.size())
6886     {
6887       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
6888       throw INTERP_KERNEL::Exception(oss.str().c_str());
6889     }
6890   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
6891   if(item==0)
6892     {
6893       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
6894       oss << "\nTry to use following method eraseEmptyTS !";
6895       throw INTERP_KERNEL::Exception(oss.str().c_str());
6896     }
6897   return item;
6898 }
6899
6900 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
6901 {
6902   std::vector<std::string> ret;
6903   std::set<std::string> ret2;
6904   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6905     {
6906       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
6907       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6908         if(ret2.find(*it2)==ret2.end())
6909           {
6910             ret.push_back(*it2);
6911             ret2.insert(*it2);
6912           }
6913     }
6914   return ret;
6915 }
6916
6917 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
6918 {
6919   std::vector<std::string> ret;
6920   std::set<std::string> ret2;
6921   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6922     {
6923       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
6924       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
6925         if(ret2.find(*it2)==ret2.end())
6926           {
6927             ret.push_back(*it2);
6928             ret2.insert(*it2);
6929           }
6930     }
6931   return ret;
6932 }
6933
6934 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
6935 {
6936   std::vector<std::string> ret;
6937   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6938     {
6939       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
6940       ret.insert(ret.end(),tmp.begin(),tmp.end());
6941     }
6942   return ret;
6943 }
6944
6945 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
6946 {
6947   std::vector<std::string> ret;
6948   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6949     {
6950       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
6951       ret.insert(ret.end(),tmp.begin(),tmp.end());
6952     }
6953   return ret;
6954 }
6955
6956 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
6957 {
6958   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6959     (*it)->changePflsRefsNamesGen2(mapOfModif);
6960 }
6961
6962 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
6963 {
6964   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6965     (*it)->changeLocsRefsNamesGen2(mapOfModif);
6966 }
6967
6968 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
6969 {
6970   int lgth=_time_steps.size();
6971   std::vector< std::vector<TypeOfField> > ret(lgth);
6972   for(int i=0;i<lgth;i++)
6973     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
6974   return ret;
6975 }
6976
6977 /*!
6978  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
6979  */
6980 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6981 {
6982   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
6983 }
6984
6985 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
6986 {
6987   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
6988   std::size_t i=0;
6989   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6990     {
6991       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
6992         ret->_time_steps[i]=(*it)->deepCpy();
6993     }
6994   return ret.retn();
6995 }
6996
6997 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
6998 {
6999   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7000   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7001   std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7002   for(std::size_t i=0;i<sz;i++)
7003     {
7004       ret[i]=shallowCpy();
7005       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7006     }
7007   for(std::size_t i=0;i<sz2;i++)
7008     {
7009       std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7010       if(ret1.size()!=sz)
7011         {
7012           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7013           throw INTERP_KERNEL::Exception(oss.str().c_str());
7014         }
7015       ts[i]=ret1;
7016     }
7017   for(std::size_t i=0;i<sz;i++)
7018     for(std::size_t j=0;j<sz2;j++)
7019       ret[i]->_time_steps[j]=ts[j][i];
7020   return ret;
7021 }
7022
7023 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7024 {
7025   _name=field->getName();
7026   if(_name.empty())
7027     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7028   if(!arr)
7029     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7030   _infos=arr->getInfoOnComponents();
7031 }
7032
7033 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7034 {
7035   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7036   if(_name!=field->getName())
7037     {
7038       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7039       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7040       throw INTERP_KERNEL::Exception(oss.str().c_str());
7041     }
7042   if(!arr)
7043     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7044   checkThatComponentsMatch(arr->getInfoOnComponents());
7045 }
7046
7047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7048 {
7049   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7050   if(getInfo().size()!=compos.size())
7051     {
7052       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7053       oss << " number of components of element to append (" << compos.size() << ") !";
7054       throw INTERP_KERNEL::Exception(oss.str().c_str());
7055     }
7056   if(_infos!=compos)
7057     {
7058       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7059       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7060       oss << " But compo in input fields are : ";
7061       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7062       oss << " !";
7063       throw INTERP_KERNEL::Exception(oss.str().c_str());
7064     }
7065 }
7066
7067 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7068 {
7069   std::size_t sz=_infos.size();
7070   int j=0;
7071   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7072     {
7073       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7074       if(elt)
7075         if(elt->getInfo().size()!=sz)
7076           {
7077             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7078             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7079             throw INTERP_KERNEL::Exception(oss.str().c_str());
7080           }
7081     }
7082 }
7083
7084 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7085 {
7086   if(!field)
7087     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7088   if(!_time_steps.empty())
7089     checkCoherencyOfTinyInfo(field,arr);
7090   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7091   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7092   objC->setFieldNoProfileSBT(field,arr,glob,*this);
7093   copyTinyInfoFrom(field,arr);
7094   _time_steps.push_back(obj);
7095 }
7096
7097 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7098 {
7099   if(!field)
7100     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7101   if(!_time_steps.empty())
7102     checkCoherencyOfTinyInfo(field,arr);
7103   MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7104   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7105   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7106   copyTinyInfoFrom(field,arr);
7107   _time_steps.push_back(obj);
7108 }
7109
7110 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7111 {
7112   int sz=(int)_time_steps.size();
7113   if(i<0 || i>=sz)
7114     {
7115       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7116       throw INTERP_KERNEL::Exception(oss.str().c_str());
7117     }
7118   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7119   if(tsPtr)
7120     {
7121       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7122         {
7123           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
7124           throw INTERP_KERNEL::Exception(oss.str().c_str());
7125         }
7126     }
7127   _time_steps[i]=ts;
7128 }
7129
7130 //= MEDFileFieldMultiTSWithoutSDA
7131
7132 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7133 {
7134   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
7135 }
7136
7137 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7138 {
7139 }
7140
7141 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7142 {
7143 }
7144
7145 /*!
7146  * \param [in] fieldId field id in C mode
7147  */
7148 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
7149 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
7150 {
7151 }
7152 catch(INTERP_KERNEL::Exception& e)
7153   { throw e; }
7154
7155 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7156 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
7157 {
7158 }
7159 catch(INTERP_KERNEL::Exception& e)
7160 { throw e; }
7161
7162 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7163 {
7164   return new MEDFileField1TSWithoutSDA;
7165 }
7166
7167 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7168 {
7169   if(!f1ts)
7170     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7171   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7172   if(!f1tsC)
7173     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7174 }
7175
7176 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7177 {
7178   return MEDFileField1TSWithoutSDA::TYPE_STR;
7179 }
7180
7181 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7182 {
7183   return new MEDFileFieldMultiTSWithoutSDA(*this);
7184 }
7185
7186 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7187 {
7188   return new MEDFileFieldMultiTSWithoutSDA;
7189 }
7190
7191 /*!
7192  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7193  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7194  */
7195 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
7196 {
7197   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7198   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7199   if(!myF1TSC)
7200     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7201   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7202 }
7203
7204 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7205 {
7206   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7207   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7208   int i=0;
7209   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7210     {
7211       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7212       if(eltToConv)
7213         {
7214           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7215           if(!eltToConvC)
7216             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7217           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7218           ret->setIteration(i,elt);
7219         }
7220     }
7221   return ret.retn();
7222 }
7223
7224 //= MEDFileAnyTypeFieldMultiTS
7225
7226 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7227 {
7228 }
7229
7230 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
7231 try:MEDFileFieldGlobsReal(fileName)
7232 {
7233   MEDFileUtilities::CheckFileForRead(fileName);
7234   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7235   _content=BuildContentFrom(fid,fileName);
7236   loadGlobals(fid);
7237 }
7238 catch(INTERP_KERNEL::Exception& e)
7239   {
7240     throw e;
7241   }
7242
7243 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7244 {
7245   med_field_type typcha;
7246   std::vector<std::string> infos;
7247   std::string dtunit;
7248   int i=-1;
7249   MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7250   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7251   switch(typcha)
7252     {
7253     case MED_FLOAT64:
7254       {
7255         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i);
7256         break;
7257       }
7258     case MED_INT32:
7259       {
7260         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i);
7261         break;
7262       }
7263     default:
7264       {
7265         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
7266         throw INTERP_KERNEL::Exception(oss.str().c_str());
7267       }
7268     }
7269   ret->setDtUnit(dtunit.c_str());
7270   return ret.retn();
7271 }
7272
7273 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName) throw(INTERP_KERNEL::Exception)
7274 {
7275   med_field_type typcha;
7276   //
7277   std::vector<std::string> infos;
7278   std::string dtunit,fieldName;
7279   MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7280   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7281   switch(typcha)
7282     {
7283     case MED_FLOAT64:
7284       {
7285         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0);
7286         break;
7287       }
7288     case MED_INT32:
7289       {
7290         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0);
7291         break;
7292       }
7293     default:
7294       {
7295         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
7296         throw INTERP_KERNEL::Exception(oss.str().c_str());
7297       }
7298     }
7299   ret->setDtUnit(dtunit.c_str());
7300   return ret.retn();
7301 }
7302
7303 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7304 {
7305   if(!c)
7306     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7307   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7308     {
7309       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7310       ret->setFileName(fileName);
7311       ret->_content=c;  c->incrRef();
7312       return ret.retn();
7313     }
7314   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7315     {
7316       MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7317       ret->setFileName(fileName);
7318       ret->_content=c;  c->incrRef();
7319       return ret.retn();
7320     }
7321   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7322 }
7323
7324 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7325 try:MEDFileFieldGlobsReal(fileName)
7326 {
7327   MEDFileUtilities::CheckFileForRead(fileName);
7328   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7329   _content=BuildContentFrom(fid,fileName,fieldName);
7330   loadGlobals(fid);
7331 }
7332 catch(INTERP_KERNEL::Exception& e)
7333   {
7334     throw e;
7335   }
7336
7337 //= MEDFileIntFieldMultiTSWithoutSDA
7338
7339 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7340 {
7341   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit);
7342 }
7343
7344 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7345 {
7346 }
7347
7348 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7349 {
7350 }
7351
7352 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit) throw(INTERP_KERNEL::Exception)
7353 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit)
7354 {
7355 }
7356 catch(INTERP_KERNEL::Exception& e)
7357 { throw e; }
7358
7359 /*!
7360  * \param [in] fieldId field id in C mode
7361  */
7362 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception)
7363 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId)
7364 {
7365 }
7366 catch(INTERP_KERNEL::Exception& e)
7367   { throw e; }
7368
7369 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7370 {
7371   return new MEDFileIntField1TSWithoutSDA;
7372 }
7373
7374 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7375 {
7376   if(!f1ts)
7377     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7378   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7379   if(!f1tsC)
7380     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7381 }
7382
7383 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7384 {
7385   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7386 }
7387
7388 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7389 {
7390   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7391 }
7392
7393 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7394 {
7395   return new MEDFileIntFieldMultiTSWithoutSDA;
7396 }
7397
7398 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7399 {
7400   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7401   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7402   int i=0;
7403   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7404     {
7405       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7406       if(eltToConv)
7407         {
7408           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7409           if(!eltToConvC)
7410             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7411           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7412           ret->setIteration(i,elt);
7413         }
7414     }
7415   return ret.retn();
7416 }
7417
7418 //= MEDFileAnyTypeFieldMultiTS
7419
7420 /*!
7421  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7422  * that has been read from a specified MED file.
7423  *  \param [in] fileName - the name of the MED file to read.
7424  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7425  *          is to delete this field using decrRef() as it is no more needed.
7426  *  \throw If reading the file fails.
7427  */
7428 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
7429 {
7430   MEDFileUtilities::CheckFileForRead(fileName);
7431   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7432   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName);
7433   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7434   ret->loadGlobals(fid);
7435   return ret.retn();
7436 }
7437
7438 /*!
7439  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7440  * that has been read from a specified MED file.
7441  *  \param [in] fileName - the name of the MED file to read.
7442  *  \param [in] fieldName - the name of the field to read.
7443  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7444  *          is to delete this field using decrRef() as it is no more needed.
7445  *  \throw If reading the file fails.
7446  *  \throw If there is no field named \a fieldName in the file.
7447  */
7448 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7449 {
7450   MEDFileUtilities::CheckFileForRead(fileName);
7451   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7452   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName);
7453   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7454   ret->loadGlobals(fid);
7455   return ret.retn();
7456 }
7457
7458 /*!
7459  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7460  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7461  *
7462  * \warning this is a shallow copy constructor
7463  */
7464 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7465 {
7466   if(!shallowCopyOfContent)
7467     {
7468       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7469       otherPtr->incrRef();
7470       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7471     }
7472   else
7473     {
7474       _content=other.shallowCpy();
7475     }
7476 }
7477
7478 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7479 {
7480   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7481   if(!ret)
7482     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7483   return ret;
7484 }
7485
7486 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7487 {
7488   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7489   if(!ret)
7490     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7491   return ret;
7492 }
7493
7494 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7495 {
7496   return contentNotNullBase()->getPflsReallyUsed2();
7497 }
7498
7499 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7500 {
7501   return contentNotNullBase()->getLocsReallyUsed2();
7502 }
7503
7504 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7505 {
7506   return contentNotNullBase()->getPflsReallyUsedMulti2();
7507 }
7508
7509 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7510 {
7511   return contentNotNullBase()->getLocsReallyUsedMulti2();
7512 }
7513
7514 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7515 {
7516   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7517 }
7518
7519 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7520 {
7521   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7522 }
7523
7524 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7525 {
7526   return contentNotNullBase()->getNumberOfTS();
7527 }
7528
7529 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7530 {
7531   contentNotNullBase()->eraseEmptyTS();
7532 }
7533
7534 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7535 {
7536   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7537 }
7538
7539 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7540 {
7541   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7542 }
7543
7544 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7545 {
7546   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7547   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7548   ret->_content=c;
7549   return ret.retn();
7550 }
7551
7552 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7553 {
7554   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7555   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7556   ret->_content=c;
7557   return ret.retn();
7558 }
7559
7560 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7561 {
7562   return contentNotNullBase()->getIterations();
7563 }
7564
7565 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7566 {
7567   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7568     pushBackTimeStep(*it);
7569 }
7570
7571 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7572 {
7573   if(!f1ts)
7574     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7575   checkCoherencyOfType(f1ts);
7576   f1ts->incrRef();
7577   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7578   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7579   c->incrRef();
7580   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7581   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7582     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7583   _content->pushBackTimeStep(cSafe);
7584   appendGlobs(*f1ts,1e-12);
7585 }
7586
7587 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7588 {
7589   contentNotNullBase()->synchronizeNameScope();
7590 }
7591
7592 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7593 {
7594   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7595 }
7596
7597 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7598 {
7599   return contentNotNullBase()->getPosGivenTime(time,eps);
7600 }
7601
7602 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7603 {
7604   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7605 }
7606
7607 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7608 {
7609   return contentNotNullBase()->getTypesOfFieldAvailable();
7610 }
7611
7612 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
7613 {
7614   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7615 }
7616
7617 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7618 {
7619   return contentNotNullBase()->getName();
7620 }
7621
7622 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7623 {
7624   contentNotNullBase()->setName(name);
7625 }
7626
7627 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
7628 {
7629   return contentNotNullBase()->getDtUnit();
7630 }
7631
7632 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
7633 {
7634   contentNotNullBase()->setDtUnit(dtUnit);
7635 }
7636
7637 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7638 {
7639   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
7640 }
7641
7642 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
7643 {
7644   return contentNotNullBase()->getTimeSteps(ret1);
7645 }
7646
7647 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
7648 {
7649   return contentNotNullBase()->getMeshName();
7650 }
7651
7652 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
7653 {
7654   contentNotNullBase()->setMeshName(newMeshName);
7655 }
7656
7657 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
7658 {
7659   return contentNotNullBase()->changeMeshNames(modifTab);
7660 }
7661
7662 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
7663 {
7664   return contentNotNullBase()->getInfo();
7665 }
7666
7667 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
7668 {
7669   return contentNotNullBase()->setInfo(info);
7670 }
7671
7672 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
7673 {
7674   const std::vector<std::string> ret=getInfo();
7675   return (int)ret.size();
7676 }
7677
7678 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
7679 {
7680   writeGlobals(fid,*this);
7681   contentNotNullBase()->writeLL(fid,*this);
7682 }
7683
7684 /*!
7685  * Writes \a this field into a MED file specified by its name.
7686  *  \param [in] fileName - the MED file name.
7687  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
7688  * - 2 - erase; an existing file is removed.
7689  * - 1 - append; same data should not be present in an existing file.
7690  * - 0 - overwrite; same data present in an existing file is overwritten.
7691  *  \throw If the field name is not set.
7692  *  \throw If no field data is set.
7693  *  \throw If \a mode == 1 and the same data is present in an existing file.
7694  */
7695 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
7696 {
7697   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
7698   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
7699   writeLL(fid);
7700 }
7701
7702 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
7703 {
7704   std::ostringstream oss;
7705   contentNotNullBase()->simpleRepr(0,oss,-1);
7706   simpleReprGlobs(oss);
7707   return oss.str();
7708 }
7709
7710 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
7711 {
7712   std::size_t ret=0;
7713   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
7714     ret+=_content->getHeapMemorySize();
7715   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
7716 }
7717
7718 /*!
7719  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
7720  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
7721  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
7722  */
7723 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
7724 {
7725   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7726   if(!content)
7727     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
7728   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
7729   std::size_t sz(contentsSplit.size());
7730   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
7731   for(std::size_t i=0;i<sz;i++)
7732     {
7733       ret[i]=shallowCpy();
7734       ret[i]->_content=contentsSplit[i];
7735     }
7736   return ret;
7737 }
7738
7739 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
7740 {
7741   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7742   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
7743     ret->_content=_content->deepCpy();
7744   ret->deepCpyGlobs(*this);
7745   return ret.retn();
7746 }
7747
7748 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
7749 {
7750   return _content;
7751 }
7752
7753 /*!
7754  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7755  *  \param [in] iteration - the iteration number of a required time step.
7756  *  \param [in] order - the iteration order number of required time step.
7757  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
7758  *          delete this field using decrRef() as it is no more needed.
7759  *  \throw If there is no required time step in \a this field.
7760  */
7761 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7762 {
7763   int pos=getPosOfTimeStep(iteration,order);
7764   return getTimeStepAtPos(pos);
7765 }
7766
7767 /*!
7768  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
7769  *  \param [in] time - the time of the time step of interest.
7770  *  \param [in] eps - a precision used to compare time values.
7771  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7772  *          delete this field using decrRef() as it is no more needed.
7773  *  \throw If there is no required time step in \a this field.
7774  */
7775 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7776 {
7777   int pos=getPosGivenTime(time,eps);
7778   return getTimeStepAtPos(pos);
7779 }
7780
7781 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
7782 {
7783   return new MEDFileAnyTypeFieldMultiTSIterator(this);
7784 }
7785
7786 //= MEDFileFieldMultiTS
7787
7788 /*!
7789  * Returns a new empty instance of MEDFileFieldMultiTS.
7790  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7791  *          is to delete this field using decrRef() as it is no more needed.
7792  */
7793 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
7794 {
7795   return new MEDFileFieldMultiTS;
7796 }
7797
7798 /*!
7799  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
7800  * that has been read from a specified MED file.
7801  *  \param [in] fileName - the name of the MED file to read.
7802  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7803  *          is to delete this field using decrRef() as it is no more needed.
7804  *  \throw If reading the file fails.
7805  */
7806 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
7807 {
7808   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName);
7809   ret->contentNotNull();//to check that content type matches with \a this type.
7810   return ret.retn();
7811 }
7812
7813 /*!
7814  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
7815  * that has been read from a specified MED file.
7816  *  \param [in] fileName - the name of the MED file to read.
7817  *  \param [in] fieldName - the name of the field to read.
7818  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7819  *          is to delete this field using decrRef() as it is no more needed.
7820  *  \throw If reading the file fails.
7821  *  \throw If there is no field named \a fieldName in the file.
7822  */
7823 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
7824 {
7825   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName);
7826   ret->contentNotNull();//to check that content type matches with \a this type.
7827   return ret.retn();
7828 }
7829
7830 /*!
7831  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7832  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7833  *
7834  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
7835  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
7836  * \warning this is a shallow copy constructor
7837  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
7838  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
7839  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
7840  *          is to delete this field using decrRef() as it is no more needed.
7841  */
7842 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7843 {
7844   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
7845 }
7846
7847 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
7848 {
7849   return new MEDFileFieldMultiTS(*this);
7850 }
7851
7852 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
7853 {
7854   if(!f1ts)
7855     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7856   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
7857   if(!f1tsC)
7858     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7859 }
7860
7861 /*!
7862  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
7863  * following the given input policy.
7864  *
7865  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7866  *                            By default (true) the globals are deeply copied.
7867  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
7868  */
7869 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
7870 {
7871   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
7872   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
7873   if(content)
7874     {
7875       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
7876       if(!contc)
7877         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
7878       MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
7879       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
7880     }
7881   else
7882     ret=MEDFileIntFieldMultiTS::New();
7883   if(deepCpyGlobs)
7884     ret->deepCpyGlobs(*this);
7885   else
7886     ret->shallowCpyGlobs(*this);
7887   return ret.retn();
7888 }
7889
7890 /*!
7891  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
7892  *  \param [in] pos - a time step id.
7893  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
7894  *          delete this field using decrRef() as it is no more needed.
7895  *  \throw If \a pos is not a valid time step id.
7896  */
7897 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
7898 {
7899   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
7900   if(!item)
7901     {
7902       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
7903       throw INTERP_KERNEL::Exception(oss.str().c_str());
7904     }
7905   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
7906   if(itemC)
7907     {
7908       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
7909       ret->shallowCpyGlobs(*this);
7910       return ret.retn();
7911     }
7912   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
7913   throw INTERP_KERNEL::Exception(oss.str().c_str());
7914 }
7915
7916 /*!
7917  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7918  * mesh entities of a given dimension of the first mesh in MED file.
7919  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7920  *  \param [in] type - a spatial discretization of interest.
7921  *  \param [in] iteration - the iteration number of a required time step.
7922  *  \param [in] order - the iteration order number of required time step.
7923  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7924  *  \param [in] renumPol - specifies how to permute values of the result field according to
7925  *          the optional numbers of cells and nodes, if any. The valid values are
7926  *          - 0 - do not permute.
7927  *          - 1 - permute cells.
7928  *          - 2 - permute nodes.
7929  *          - 3 - permute cells and nodes.
7930  *
7931  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7932  *          caller is to delete this field using decrRef() as it is no more needed. 
7933  *  \throw If the MED file is not readable.
7934  *  \throw If there is no mesh in the MED file.
7935  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7936  *  \throw If no field values of the required parameters are available.
7937  */
7938 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
7939 {
7940   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7941   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7942   if(!myF1TSC)
7943     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
7944   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7945   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
7946   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7947   return ret.retn();
7948 }
7949
7950 /*!
7951  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7952  * the top level cells of the first mesh in MED file.
7953  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7954  *  \param [in] type - a spatial discretization of interest.
7955  *  \param [in] iteration - the iteration number of a required time step.
7956  *  \param [in] order - the iteration order number of required time step.
7957  *  \param [in] renumPol - specifies how to permute values of the result field according to
7958  *          the optional numbers of cells and nodes, if any. The valid values are
7959  *          - 0 - do not permute.
7960  *          - 1 - permute cells.
7961  *          - 2 - permute nodes.
7962  *          - 3 - permute cells and nodes.
7963  *
7964  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7965  *          caller is to delete this field using decrRef() as it is no more needed. 
7966  *  \throw If the MED file is not readable.
7967  *  \throw If there is no mesh in the MED file.
7968  *  \throw If no field values of the required parameters are available.
7969  */
7970 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
7971 {
7972   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
7973   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7974   if(!myF1TSC)
7975     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
7976   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
7977   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
7978   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7979   return ret.retn();
7980 }
7981
7982 /*!
7983  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
7984  * a given support.
7985  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7986  *  \param [in] type - a spatial discretization of interest.
7987  *  \param [in] iteration - the iteration number of a required time step.
7988  *  \param [in] order - the iteration order number of required time step.
7989  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7990  *  \param [in] mesh - the supporting mesh.
7991  *  \param [in] renumPol - specifies how to permute values of the result field according to
7992  *          the optional numbers of cells and nodes, if any. The valid values are
7993  *          - 0 - do not permute.
7994  *          - 1 - permute cells.
7995  *          - 2 - permute nodes.
7996  *          - 3 - permute cells and nodes.
7997  *
7998  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7999  *          caller is to delete this field using decrRef() as it is no more needed. 
8000  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8001  *  \throw If no field of \a this is lying on \a mesh.
8002  *  \throw If no field values of the required parameters are available.
8003  */
8004 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8005 {
8006   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8007   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8008   if(!myF1TSC)
8009     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8010   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8011   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8012   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8013   return ret.retn();
8014 }
8015
8016 /*!
8017  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8018  * given support. 
8019  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8020  *  \param [in] type - a spatial discretization of the new field.
8021  *  \param [in] iteration - the iteration number of a required time step.
8022  *  \param [in] order - the iteration order number of required time step.
8023  *  \param [in] mesh - the supporting mesh.
8024  *  \param [in] renumPol - specifies how to permute values of the result field according to
8025  *          the optional numbers of cells and nodes, if any. The valid values are
8026  *          - 0 - do not permute.
8027  *          - 1 - permute cells.
8028  *          - 2 - permute nodes.
8029  *          - 3 - permute cells and nodes.
8030  *
8031  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8032  *          caller is to delete this field using decrRef() as it is no more needed. 
8033  *  \throw If no field of \a this is lying on \a mesh.
8034  *  \throw If no field values of the required parameters are available.
8035  */
8036 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8037 {
8038   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8039   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8040   if(!myF1TSC)
8041     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8042   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8043   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8044   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8045   return ret.retn();
8046 }
8047
8048 /*!
8049  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8050  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8051  * This method is useful for MED2 file format when field on different mesh was autorized.
8052  */
8053 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8054 {
8055   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8056   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8057   if(!myF1TSC)
8058     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8059   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8060   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8061   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8062   return ret.retn();
8063 }
8064
8065 /*!
8066  * Returns values and a profile of the field of a given type, of a given time step,
8067  * lying on a given support.
8068  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8069  *  \param [in] type - a spatial discretization of the field.
8070  *  \param [in] iteration - the iteration number of a required time step.
8071  *  \param [in] order - the iteration order number of required time step.
8072  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8073  *  \param [in] mesh - the supporting mesh.
8074  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8075  *          field of interest lies on. If the field lies on all entities of the given
8076  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
8077  *          using decrRef() as it is no more needed.  
8078  *  \param [in] glob - the global data storing profiles and localization.
8079  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8080  *          field. The caller is to delete this array using decrRef() as it is no more needed.
8081  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8082  *  \throw If no field of \a this is lying on \a mesh.
8083  *  \throw If no field values of the required parameters are available.
8084  */
8085 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8086 {
8087   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8088   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8089   if(!myF1TSC)
8090     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8091   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8092   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8093 }
8094
8095 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8096 {
8097   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8098   if(!pt)
8099     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8100   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8101   if(!ret)
8102     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
8103   return ret;
8104 }
8105
8106  MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8107 {
8108   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8109   if(!pt)
8110     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8111   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8112   if(!ret)
8113     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
8114   return ret;
8115 }
8116
8117 /*!
8118  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8119  * the given field is checked if its elements are sorted suitable for writing to MED file
8120  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
8121  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8122  *  \param [in] field - the field to add to \a this.
8123  *  \throw If the name of \a field is empty.
8124  *  \throw If the data array of \a field is not set.
8125  *  \throw If existing time steps have different name or number of components than \a field.
8126  *  \throw If the underlying mesh of \a field has no name.
8127  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8128  */
8129 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8130 {
8131   const DataArrayDouble *arr=0;
8132   if(field)
8133     arr=field->getArray();
8134   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8135 }
8136
8137 /*!
8138  * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8139  * a given dimension of a given mesh are used as the support of the given field.
8140  * Elements of the given mesh must be sorted suitable for writing to MED file. 
8141  * Order of underlying mesh entities of the given field specified by \a profile parameter
8142  * is not prescribed; this method permutes field values to have them sorted by element
8143  * type as required for writing to MED file.  
8144  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8145  *  \param [in] field - the field to add to \a this.
8146  *  \param [in] mesh - the supporting mesh of \a field.
8147  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8148  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
8149  *  \throw If either \a field or \a mesh or \a profile has an empty name.
8150  *  \throw If existing time steps have different name or number of components than \a field.
8151  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8152  *  \throw If the data array of \a field is not set.
8153  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8154  */
8155 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8156 {
8157   const DataArrayDouble *arr=0;
8158   if(field)
8159     arr=field->getArray();
8160   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8161 }
8162
8163 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8164 {
8165   _content=new MEDFileFieldMultiTSWithoutSDA;
8166 }
8167
8168 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
8169 try:MEDFileAnyTypeFieldMultiTS(fileName)
8170 {
8171 }
8172 catch(INTERP_KERNEL::Exception& e)
8173   { throw e; }
8174
8175 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8176 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
8177 {
8178 }
8179 catch(INTERP_KERNEL::Exception& e)
8180   { throw e; }
8181
8182 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8183 {
8184 }
8185
8186 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
8187 {
8188   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8189 }
8190
8191 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8192 {
8193   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8194 }
8195
8196 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
8197 {
8198   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8199 }
8200
8201 //= MEDFileAnyTypeFieldMultiTSIterator
8202
8203 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8204 {
8205   if(fmts)
8206     {
8207       fmts->incrRef();
8208       _nb_iter=fmts->getNumberOfTS();
8209     }
8210 }
8211
8212 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
8213 {
8214 }
8215
8216 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8217 {
8218   if(_iter_id<_nb_iter)
8219     {
8220       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8221       if(fmts)
8222         return fmts->getTimeStepAtPos(_iter_id++);
8223       else
8224         return 0;
8225     }
8226   else
8227     return 0;
8228 }
8229
8230 //= MEDFileIntFieldMultiTS
8231
8232 /*!
8233  * Returns a new empty instance of MEDFileFieldMultiTS.
8234  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8235  *          is to delete this field using decrRef() as it is no more needed.
8236  */
8237 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8238 {
8239   return new MEDFileIntFieldMultiTS;
8240 }
8241
8242 /*!
8243  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8244  * that has been read from a specified MED file.
8245  *  \param [in] fileName - the name of the MED file to read.
8246  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8247  *          is to delete this field using decrRef() as it is no more needed.
8248  *  \throw If reading the file fails.
8249  */
8250 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
8251 {
8252   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName);
8253   ret->contentNotNull();//to check that content type matches with \a this type.
8254   return ret.retn();
8255 }
8256
8257 /*!
8258  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8259  * that has been read from a specified MED file.
8260  *  \param [in] fileName - the name of the MED file to read.
8261  *  \param [in] fieldName - the name of the field to read.
8262  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8263  *          is to delete this field using decrRef() as it is no more needed.
8264  *  \throw If reading the file fails.
8265  *  \throw If there is no field named \a fieldName in the file.
8266  */
8267 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8268 {
8269   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName);
8270   ret->contentNotNull();//to check that content type matches with \a this type.
8271   return ret.retn();
8272 }
8273
8274 /*!
8275  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8276  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8277  *
8278  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8279  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8280  * \warning this is a shallow copy constructor
8281  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8282  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8283  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8284  *          is to delete this field using decrRef() as it is no more needed.
8285  */
8286 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8287 {
8288   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8289 }
8290
8291 /*!
8292  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8293  * following the given input policy.
8294  *
8295  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8296  *                            By default (true) the globals are deeply copied.
8297  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8298  */
8299 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8300 {
8301   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8302   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8303   if(content)
8304     {
8305       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8306       if(!contc)
8307         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8308       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8309       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8310     }
8311   else
8312     ret=MEDFileFieldMultiTS::New();
8313   if(deepCpyGlobs)
8314     ret->deepCpyGlobs(*this);
8315   else
8316     ret->shallowCpyGlobs(*this);
8317   return ret.retn();
8318 }
8319
8320 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8321 {
8322   return new MEDFileIntFieldMultiTS(*this);
8323 }
8324
8325 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8326 {
8327   if(!f1ts)
8328     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8329   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8330   if(!f1tsC)
8331     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8332 }
8333
8334 /*!
8335  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8336  * mesh entities of a given dimension of the first mesh in MED file.
8337  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8338  *  \param [in] type - a spatial discretization of interest.
8339  *  \param [in] iteration - the iteration number of a required time step.
8340  *  \param [in] order - the iteration order number of required time step.
8341  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8342  *  \param [out] arrOut - the DataArrayInt containing values of field.
8343  *  \param [in] renumPol - specifies how to permute values of the result field according to
8344  *          the optional numbers of cells and nodes, if any. The valid values are
8345  *          - 0 - do not permute.
8346  *          - 1 - permute cells.
8347  *          - 2 - permute nodes.
8348  *          - 3 - permute cells and nodes.
8349  *
8350  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8351  *          caller is to delete this field using decrRef() as it is no more needed. 
8352  *  \throw If the MED file is not readable.
8353  *  \throw If there is no mesh in the MED file.
8354  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8355  *  \throw If no field values of the required parameters are available.
8356  */
8357 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8358 {
8359   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8360   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8361   if(!myF1TSC)
8362     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
8363   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8364   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
8365   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8366   return ret.retn();
8367 }
8368
8369 /*!
8370  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8371  * the top level cells of the first mesh in MED file.
8372  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8373  *  \param [in] type - a spatial discretization of interest.
8374  *  \param [in] iteration - the iteration number of a required time step.
8375  *  \param [in] order - the iteration order number of required time step.
8376  *  \param [out] arrOut - the DataArrayInt containing values of field.
8377  *  \param [in] renumPol - specifies how to permute values of the result field according to
8378  *          the optional numbers of cells and nodes, if any. The valid values are
8379  *          - 0 - do not permute.
8380  *          - 1 - permute cells.
8381  *          - 2 - permute nodes.
8382  *          - 3 - permute cells and nodes.
8383  *
8384  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8385  *          caller is to delete this field using decrRef() as it is no more needed. 
8386  *  \throw If the MED file is not readable.
8387  *  \throw If there is no mesh in the MED file.
8388  *  \throw If no field values of the required parameters are available.
8389  */
8390 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8391 {
8392   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8393   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8394   if(!myF1TSC)
8395     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
8396   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8397   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
8398   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8399   return ret.retn();
8400 }
8401
8402 /*!
8403  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8404  * a given support.
8405  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8406  *  \param [in] type - a spatial discretization of interest.
8407  *  \param [in] iteration - the iteration number of a required time step.
8408  *  \param [in] order - the iteration order number of required time step.
8409  *  \param [out] arrOut - the DataArrayInt containing values of field.
8410  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8411  *  \param [in] mesh - the supporting mesh.
8412  *  \param [in] renumPol - specifies how to permute values of the result field according to
8413  *          the optional numbers of cells and nodes, if any. The valid values are
8414  *          - 0 - do not permute.
8415  *          - 1 - permute cells.
8416  *          - 2 - permute nodes.
8417  *          - 3 - permute cells and nodes.
8418  *
8419  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8420  *          caller is to delete this field using decrRef() as it is no more needed. 
8421  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8422  *  \throw If no field of \a this is lying on \a mesh.
8423  *  \throw If no field values of the required parameters are available.
8424  */
8425 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8426 {
8427   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8428   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8429   if(!myF1TSC)
8430     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8431   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8432   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
8433   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8434   return ret.retn();
8435 }
8436
8437 /*!
8438  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8439  * given support. 
8440  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8441  *  \param [in] type - a spatial discretization of the new field.
8442  *  \param [in] iteration - the iteration number of a required time step.
8443  *  \param [in] order - the iteration order number of required time step.
8444  *  \param [in] mesh - the supporting mesh.
8445  *  \param [out] arrOut - the DataArrayInt containing values of field.
8446  *  \param [in] renumPol - specifies how to permute values of the result field according to
8447  *          the optional numbers of cells and nodes, if any. The valid values are
8448  *          - 0 - do not permute.
8449  *          - 1 - permute cells.
8450  *          - 2 - permute nodes.
8451  *          - 3 - permute cells and nodes.
8452  *
8453  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8454  *          caller is to delete this field using decrRef() as it is no more needed. 
8455  *  \throw If no field of \a this is lying on \a mesh.
8456  *  \throw If no field values of the required parameters are available.
8457  */
8458 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8459 {
8460   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8461   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8462   if(!myF1TSC)
8463     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8464   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8465   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
8466   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8467   return ret.retn();
8468 }
8469
8470 /*!
8471  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
8472  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8473  * This method is useful for MED2 file format when field on different mesh was autorized.
8474  */
8475 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8476 {
8477   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8478   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8479   if(!myF1TSC)
8480     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
8481   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
8482   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
8483   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
8484   return ret.retn();
8485 }
8486
8487 /*!
8488  * Returns values and a profile of the field of a given type, of a given time step,
8489  * lying on a given support.
8490  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8491  *  \param [in] type - a spatial discretization of the field.
8492  *  \param [in] iteration - the iteration number of a required time step.
8493  *  \param [in] order - the iteration order number of required time step.
8494  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8495  *  \param [in] mesh - the supporting mesh.
8496  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8497  *          field of interest lies on. If the field lies on all entities of the given
8498  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
8499  *          using decrRef() as it is no more needed.  
8500  *  \param [in] glob - the global data storing profiles and localization.
8501  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
8502  *          field. The caller is to delete this array using decrRef() as it is no more needed.
8503  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8504  *  \throw If no field of \a this is lying on \a mesh.
8505  *  \throw If no field values of the required parameters are available.
8506  */
8507 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8508 {
8509   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8510   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8511   if(!myF1TSC)
8512     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
8513   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8514   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
8515 }
8516
8517 /*!
8518  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
8519  *  \param [in] pos - a time step id.
8520  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
8521  *          delete this field using decrRef() as it is no more needed.
8522  *  \throw If \a pos is not a valid time step id.
8523  */
8524 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8525 {
8526   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8527   if(!item)
8528     {
8529       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8530       throw INTERP_KERNEL::Exception(oss.str().c_str());
8531     }
8532   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
8533   if(itemC)
8534     {
8535       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
8536       ret->shallowCpyGlobs(*this);
8537       return ret.retn();
8538     }
8539   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
8540   throw INTERP_KERNEL::Exception(oss.str().c_str());
8541 }
8542
8543 /*!
8544  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8545  * the given field is checked if its elements are sorted suitable for writing to MED file
8546  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
8547  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8548  *  \param [in] field - the field to add to \a this.
8549  *  \throw If the name of \a field is empty.
8550  *  \throw If the data array of \a field is not set.
8551  *  \throw If existing time steps have different name or number of components than \a field.
8552  *  \throw If the underlying mesh of \a field has no name.
8553  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8554  */
8555 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
8556 {
8557   contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
8558 }
8559
8560 /*!
8561  * Adds a MEDCouplingFieldDouble to \a this as another time step. Specified entities of
8562  * a given dimension of a given mesh are used as the support of the given field.
8563  * Elements of the given mesh must be sorted suitable for writing to MED file. 
8564  * Order of underlying mesh entities of the given field specified by \a profile parameter
8565  * is not prescribed; this method permutes field values to have them sorted by element
8566  * type as required for writing to MED file.  
8567  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8568  *  \param [in] field - the field to add to \a this.
8569  *  \param [in] mesh - the supporting mesh of \a field.
8570  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
8571  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
8572  *  \throw If either \a field or \a mesh or \a profile has an empty name.
8573  *  \throw If existing time steps have different name or number of components than \a field.
8574  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8575  *  \throw If the data array of \a field is not set.
8576  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8577  */
8578 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8579 {
8580   contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
8581 }
8582
8583 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8584 {
8585   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8586   if(!pt)
8587     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
8588   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8589   if(!ret)
8590     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
8591   return ret;
8592 }
8593
8594  MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8595 {
8596   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8597   if(!pt)
8598     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
8599   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
8600   if(!ret)
8601     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is not null but it is not of type int ! Reason is maybe that the read field has not the type INT32 !");
8602   return ret;
8603 }
8604
8605 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
8606 {
8607   _content=new MEDFileIntFieldMultiTSWithoutSDA;
8608 }
8609
8610 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8611 {
8612 }
8613
8614 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
8615 try:MEDFileAnyTypeFieldMultiTS(fileName)
8616 {
8617 }
8618 catch(INTERP_KERNEL::Exception& e)
8619   { throw e; }
8620
8621 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
8622 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName)
8623 {
8624 }
8625 catch(INTERP_KERNEL::Exception& e)
8626   { throw e; }
8627
8628 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8629 {
8630   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8631 }
8632
8633 //= MEDFileFields
8634
8635 MEDFileFields *MEDFileFields::New()
8636 {
8637   return new MEDFileFields;
8638 }
8639
8640 MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
8641 {
8642   return new MEDFileFields(fileName);
8643 }
8644
8645 std::size_t MEDFileFields::getHeapMemorySize() const
8646 {
8647   std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
8648   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8649     if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
8650       ret+=(*it)->getHeapMemorySize();
8651   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8652 }
8653
8654 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
8655 {
8656   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
8657   std::size_t i=0;
8658   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8659     {
8660       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8661         ret->_fields[i]=(*it)->deepCpy();
8662     }
8663   ret->deepCpyGlobs(*this);
8664   return ret.retn();
8665 }
8666
8667 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
8668 {
8669   return new MEDFileFields(*this);
8670 }
8671
8672 /*!
8673  * This method scans for all fields in \a this which time steps ids are common. Time step are discriminated by the pair of integer (iteration,order) whatever
8674  * the double time value. If all returned time steps are \b exactly those for all fields in \a this output parameter \a areThereSomeForgottenTS will be set to false.
8675  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
8676  *
8677  * \param [out] areThereSomeForgottenTS - indicates to the caller if there is some time steps in \a this that are not present for all fields in \a this.
8678  * \return the sorted list of time steps (specified with a pair of integer iteration first and order second) present for all fields in \a this.
8679  * 
8680  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
8681  */
8682 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
8683 {
8684   std::set< std::pair<int,int> > s;
8685   bool firstShot=true;
8686   areThereSomeForgottenTS=false;
8687   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8688     {
8689       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
8690         continue;
8691       std::vector< std::pair<int,int> > v=(*it)->getIterations();
8692       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
8693       if(firstShot)
8694         { s=s1; firstShot=false; }
8695       else
8696         {
8697           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
8698           if(s!=s2)
8699             areThereSomeForgottenTS=true;
8700           s=s2;
8701         }
8702     }
8703   std::vector< std::pair<int,int> > ret;
8704   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
8705   return ret;
8706 }
8707
8708 int MEDFileFields::getNumberOfFields() const
8709 {
8710   return _fields.size();
8711 }
8712
8713 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
8714 {
8715   std::vector<std::string> ret(_fields.size());
8716   int i=0;
8717   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8718     {
8719       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
8720       if(f)
8721         {
8722           ret[i]=f->getName();
8723         }
8724       else
8725         {
8726           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
8727           throw INTERP_KERNEL::Exception(oss.str().c_str());
8728         }
8729     }
8730   return ret;
8731 }
8732
8733 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
8734 {
8735   std::vector<std::string> ret;
8736   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8737     {
8738       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
8739       if(cur)
8740         ret.push_back(cur->getMeshName());
8741     }
8742   return ret;
8743 }
8744
8745 std::string MEDFileFields::simpleRepr() const
8746 {
8747   std::ostringstream oss;
8748   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
8749   simpleRepr(0,oss);
8750   return oss.str();
8751 }
8752
8753 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
8754 {
8755   int nbOfFields=getNumberOfFields();
8756   std::string startLine(bkOffset,' ');
8757   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
8758   int i=0;
8759   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8760     {
8761       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8762       if(cur)
8763         {
8764           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
8765         }
8766       else
8767         {
8768           oss << startLine << "  - not defined !" << std::endl;
8769         }
8770     }
8771   i=0;
8772   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8773     {
8774       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
8775       std::string chapter(17,'0'+i);
8776       oss << startLine << chapter << std::endl;
8777       if(cur)
8778         {
8779           cur->simpleRepr(bkOffset+2,oss,i);
8780         }
8781       else
8782         {
8783           oss << startLine << "  - not defined !" << std::endl;
8784         }
8785       oss << startLine << chapter << std::endl;
8786     }
8787   simpleReprGlobs(oss);
8788 }
8789
8790 MEDFileFields::MEDFileFields()
8791 {
8792 }
8793
8794 MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
8795 try:MEDFileFieldGlobsReal(fileName)
8796   {
8797     MEDFileUtilities::CheckFileForRead(fileName);
8798     MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
8799     int nbFields=MEDnField(fid);
8800     _fields.resize(nbFields);
8801     med_field_type typcha;
8802     for(int i=0;i<nbFields;i++)
8803       {
8804         std::vector<std::string> infos;
8805         std::string fieldName,dtunit;
8806         int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
8807         switch(typcha)
8808           {
8809           case MED_FLOAT64:
8810             {
8811               _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
8812               break;
8813             }
8814           case MED_INT32:
8815             {
8816               _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit);
8817               break;
8818             }
8819           default:
8820             {
8821               std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8822               throw INTERP_KERNEL::Exception(oss.str().c_str());
8823             }
8824           }
8825       }
8826     loadAllGlobals(fid);
8827   }
8828 catch(INTERP_KERNEL::Exception& e)
8829   {
8830     throw e;
8831   }
8832
8833 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8834 {
8835   int i=0;
8836   writeGlobals(fid,*this);
8837   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
8838     {
8839       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
8840       if(!elt)
8841         {
8842           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
8843           throw INTERP_KERNEL::Exception(oss.str().c_str());
8844         }
8845       elt->writeLL(fid,*this);
8846     }
8847 }
8848
8849 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8850 {
8851   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8852   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8853   writeLL(fid);
8854 }
8855
8856 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
8857 {
8858   std::vector<std::string> ret;
8859   std::set<std::string> ret2;
8860   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8861     {
8862       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8863       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8864         if(ret2.find(*it2)==ret2.end())
8865           {
8866             ret.push_back(*it2);
8867             ret2.insert(*it2);
8868           }
8869     }
8870   return ret;
8871 }
8872
8873 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
8874 {
8875   std::vector<std::string> ret;
8876   std::set<std::string> ret2;
8877   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8878     {
8879       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8880       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8881         if(ret2.find(*it2)==ret2.end())
8882           {
8883             ret.push_back(*it2);
8884             ret2.insert(*it2);
8885           }
8886     }
8887   return ret;
8888 }
8889
8890 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
8891 {
8892   std::vector<std::string> ret;
8893   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8894     {
8895       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8896       ret.insert(ret.end(),tmp.begin(),tmp.end());
8897     }
8898   return ret;
8899 }
8900
8901 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
8902 {
8903   std::vector<std::string> ret;
8904   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
8905     {
8906       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8907       ret.insert(ret.end(),tmp.begin(),tmp.end());
8908     }
8909   return ret;
8910 }
8911
8912 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8913 {
8914   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8915     (*it)->changePflsRefsNamesGen2(mapOfModif);
8916 }
8917
8918 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
8919 {
8920   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
8921     (*it)->changeLocsRefsNamesGen2(mapOfModif);
8922 }
8923
8924 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
8925 {
8926   _fields.resize(newSize);
8927 }
8928
8929 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
8930 {
8931   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
8932     pushField(*it);
8933 }
8934
8935 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8936 {
8937   if(!field)
8938     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
8939   _fields.push_back(field->getContent());
8940   appendGlobs(*field,1e-12);
8941 }
8942
8943 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
8944 {
8945   if(!field)
8946     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
8947   if(i>=(int)_fields.size())
8948     _fields.resize(i+1);
8949   _fields[i]=field->getContent();
8950   appendGlobs(*field,1e-12);
8951 }
8952
8953 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
8954 {
8955   destroyFieldsAtPos(&i,&i+1);
8956 }
8957
8958 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
8959 {
8960   std::vector<bool> b(_fields.size(),true);
8961   for(const int *i=startIds;i!=endIds;i++)
8962     {
8963       if(*i<0 || *i>=(int)_fields.size())
8964         {
8965           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
8966           throw INTERP_KERNEL::Exception(oss.str().c_str());
8967         }
8968       b[*i]=false;
8969     }
8970   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
8971   std::size_t j=0;
8972   for(std::size_t i=0;i<_fields.size();i++)
8973     if(b[i])
8974       fields[j++]=_fields[i];
8975   _fields=fields;
8976 }
8977
8978 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
8979 {
8980   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
8981   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8982   std::vector<bool> b(_fields.size(),true);
8983   int k=bg;
8984   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
8985     {
8986       if(k<0 || k>=(int)_fields.size())
8987         {
8988           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
8989           throw INTERP_KERNEL::Exception(oss.str().c_str());
8990         }
8991       b[k]=false;
8992     }
8993   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
8994   std::size_t j=0;
8995   for(std::size_t i=0;i<_fields.size();i++)
8996     if(b[i])
8997       fields[j++]=_fields[i];
8998   _fields=fields;
8999 }
9000
9001 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9002 {
9003   bool ret=false;
9004   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9005     {
9006       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9007       if(cur)
9008         ret=cur->changeMeshNames(modifTab) || ret;
9009     }
9010   return ret;
9011 }
9012
9013 /*!
9014  * \param [in] meshName the name of the mesh that will be renumbered.
9015  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9016  *             This code corresponds to the distribution of types in the corresponding mesh.
9017  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9018  * \param [in] renumO2N the old to new renumber array.
9019  * \return If true a renumbering has been performed. The structure in \a this has been modified. If false, nothing has been done: it is typically the case if \a meshName is not refered by any 
9020  *         field in \a this.
9021  */
9022 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9023 {
9024   bool ret=false;
9025   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9026     {
9027       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9028       if(fmts)
9029         {
9030           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9031         }
9032     }
9033   return ret;
9034 }
9035
9036 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9037 {
9038   if(i<0 || i>=(int)_fields.size())
9039     {
9040       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9041       throw INTERP_KERNEL::Exception(oss.str().c_str());
9042     }
9043   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9044   if(!fmts)
9045     return 0;
9046   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9047   const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9048   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9049   if(fmtsC)
9050     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9051   else if(fmtsC2)
9052     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9053   else
9054     {
9055       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9056       throw INTERP_KERNEL::Exception(oss.str().c_str());
9057     }
9058   ret->shallowCpyGlobs(*this);
9059   return ret.retn();
9060 }
9061
9062 /*!
9063  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9064  * This method is accessible in python using __getitem__ with a list in input.
9065  * \return a new object that the caller should deal with.
9066  */
9067 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9068 {
9069   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9070   std::size_t sz=std::distance(startIds,endIds);
9071   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9072   int j=0;
9073   for(const int *i=startIds;i!=endIds;i++,j++)
9074     {
9075       if(*i<0 || *i>=(int)_fields.size())
9076         {
9077           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9078           throw INTERP_KERNEL::Exception(oss.str().c_str());
9079         }
9080       fields[j]=_fields[*i];
9081     }
9082   ret->_fields=fields;
9083   return ret.retn();
9084 }
9085
9086 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9087 {
9088   return getFieldAtPos(getPosFromFieldName(fieldName));
9089 }
9090
9091 /*!
9092  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9093  * This method can be seen as a filter applied on \a this, that returns an object containing
9094  * reduced the list of fields compared to those in \a this. The returned object is a new object but the object on which it lies are only
9095  * shallow copied from \a this.
9096  * 
9097  * \param [in] meshName - the name of the mesh on w
9098  * \return a new object that the caller should deal with.
9099  */
9100 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9101 {
9102   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9103   ret->shallowCpyOnlyUsedGlobs(*this);
9104   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9105     {
9106       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9107       if(!cur)
9108         continue;
9109       if(cur->getMeshName()==meshName)
9110         {
9111           cur->incrRef();
9112           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9113           ret->_fields.push_back(cur2);
9114         }
9115     }
9116   return ret.retn();
9117 }
9118
9119 /*!
9120  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9121  * Input time steps are specified using a pair of integer (iteration, order).
9122  * This method can be seen as a filter applied on \a this, that returns an object containing the same number of fields than those in \a this,
9123  * but for each multitimestep only the time steps in \a timeSteps are kept.
9124  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9125  * 
9126  * The returned object points to shallow copy of elements in \a this.
9127  * 
9128  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9129  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9130  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9131  */
9132 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9133 {
9134   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9135   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9136     {
9137       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9138       if(!cur)
9139         continue;
9140       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9141       ret->_fields.push_back(elt);
9142     }
9143   ret->shallowCpyOnlyUsedGlobs(*this);
9144   return ret.retn();
9145 }
9146
9147 /*!
9148  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9149  */
9150 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9151 {
9152   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9153   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9154     {
9155       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9156       if(!cur)
9157         continue;
9158       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9159       if(elt->getNumberOfTS()!=0)
9160         ret->_fields.push_back(elt);
9161     }
9162   ret->shallowCpyOnlyUsedGlobs(*this);
9163   return ret.retn();
9164 }
9165
9166 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9167 {
9168   return new MEDFileFieldsIterator(this);
9169 }
9170
9171 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9172 {
9173   std::string tmp(fieldName);
9174   std::vector<std::string> poss;
9175   for(std::size_t i=0;i<_fields.size();i++)
9176     {
9177       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9178       if(f)
9179         {
9180           std::string fname(f->getName());
9181           if(tmp==fname)
9182             return i;
9183           else
9184             poss.push_back(fname);
9185         }
9186     }
9187   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9188   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9189   oss << " !";
9190   throw INTERP_KERNEL::Exception(oss.str().c_str());
9191 }
9192
9193 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9194 {
9195   if(fs)
9196     {
9197       fs->incrRef();
9198       _nb_iter=fs->getNumberOfFields();
9199     }
9200 }
9201
9202 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
9203 {
9204 }
9205
9206 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9207 {
9208   if(_iter_id<_nb_iter)
9209     {
9210       MEDFileFields *fs(_fs);
9211       if(fs)
9212         return fs->getFieldAtPos(_iter_id++);
9213       else
9214         return 0;
9215     }
9216   else
9217     return 0;
9218 }