Salome HOME
Merge from V6_main 12/04/2013
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingCurveLinearMesh.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 "MEDCouplingCurveLinearMesh.hxx"
22 #include "MEDCouplingPointSet.hxx"
23 #include "MEDCouplingMemArray.hxx"
24 #include "MEDCouplingFieldDouble.hxx"
25
26 #include "VolSurfUser.txx"
27 #include "PointLocatorAlgos.txx"
28
29 #include <functional>
30 #include <algorithm>
31 #include <sstream>
32 #include <numeric>
33
34 using namespace ParaMEDMEM;
35
36 MEDCouplingCurveLinearMesh::MEDCouplingCurveLinearMesh():_coords(0),_structure(0)
37 {
38 }
39
40 MEDCouplingCurveLinearMesh::MEDCouplingCurveLinearMesh(const MEDCouplingCurveLinearMesh& other, bool deepCopy):MEDCouplingStructuredMesh(other,deepCopy),_structure(other._structure)
41 {
42   if(deepCopy)
43     {
44       if((const DataArrayDouble *)other._coords)
45         _coords=other._coords->deepCpy();
46     }
47   else
48     _coords=other._coords;
49 }
50
51 MEDCouplingCurveLinearMesh::~MEDCouplingCurveLinearMesh()
52 {
53 }
54
55 MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::New()
56 {
57   return new MEDCouplingCurveLinearMesh;
58 }
59
60 MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::New(const char *meshName)
61 {
62   MEDCouplingCurveLinearMesh *ret=new MEDCouplingCurveLinearMesh;
63   ret->setName(meshName);
64   return ret;
65 }
66
67 MEDCouplingMesh *MEDCouplingCurveLinearMesh::deepCpy() const
68 {
69   return clone(true);
70 }
71
72 MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::clone(bool recDeepCpy) const
73 {
74   return new MEDCouplingCurveLinearMesh(*this,recDeepCpy);
75 }
76
77 void MEDCouplingCurveLinearMesh::updateTime() const
78 {
79   if((const DataArrayDouble *)_coords)
80     updateTimeWith(*_coords);
81 }
82
83 std::size_t MEDCouplingCurveLinearMesh::getHeapMemorySize() const
84 {
85   std::size_t ret=0;
86   ret+=_structure.capacity()*sizeof(int);
87   if((const DataArrayDouble *)_coords)
88     ret+=_coords->getHeapMemorySize();
89   return MEDCouplingStructuredMesh::getHeapMemorySize()+ret;
90 }
91
92 /*!
93  * This method copyies all tiny strings from other (name and components name).
94  * @throw if other and this have not same mesh type.
95  */
96 void MEDCouplingCurveLinearMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception)
97
98   const MEDCouplingCurveLinearMesh *otherC=dynamic_cast<const MEDCouplingCurveLinearMesh *>(other);
99   if(!otherC)
100     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::copyTinyStringsFrom : meshes have not same type !");
101   MEDCouplingStructuredMesh::copyTinyStringsFrom(other);
102   if((DataArrayDouble *)_coords && (const DataArrayDouble *)otherC->_coords)
103     _coords->copyStringInfoFrom(*otherC->_coords);
104 }
105
106 bool MEDCouplingCurveLinearMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
107 {
108   if(!other)
109     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::isEqualIfNotWhy : input other pointer is null !");
110   const MEDCouplingCurveLinearMesh *otherC=dynamic_cast<const MEDCouplingCurveLinearMesh *>(other);
111   if(!otherC)
112     {
113       reason="mesh given in input is not castable in MEDCouplingCurveLinearMesh !";
114       return false;
115     }
116   if(!MEDCouplingStructuredMesh::isEqualIfNotWhy(other,prec,reason))
117     return false;
118   std::ostringstream oss; oss.precision(15);
119   if(((const DataArrayDouble *)_coords && ((const DataArrayDouble *)otherC->_coords)==0) || (((const DataArrayDouble *)_coords)==0 && (const DataArrayDouble *)otherC->_coords))
120     {
121       oss << "Only one CurveLinearMesh between the two this and other has its coordinates defined !";
122       reason=oss.str();
123       return false;
124     }
125   if((const DataArrayDouble *)_coords)
126     {
127       if(!_coords->isEqualIfNotWhy(*(otherC->_coords),prec,reason))
128         {
129           oss << "Coordinates DataArrayDouble of differ :";
130           reason.insert(0,oss.str());
131           return false;
132         }
133       if(_structure!=otherC->_structure)
134         { reason="CurveLinearMesh structures differ !"; return false; }
135     }
136   return true;
137 }
138
139 bool MEDCouplingCurveLinearMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const
140 {
141   const MEDCouplingCurveLinearMesh *otherC=dynamic_cast<const MEDCouplingCurveLinearMesh *>(other);
142   if(!otherC)
143     return false;
144   if(((const DataArrayDouble *)_coords && ((const DataArrayDouble *)otherC->_coords)==0) || (((const DataArrayDouble *)_coords)==0 && (const DataArrayDouble *)otherC->_coords))
145     return false;
146   if((const DataArrayDouble *)_coords)
147     {
148       if(!_coords->isEqualWithoutConsideringStr(*(otherC->_coords),prec))
149         return false;
150       if(_structure!=otherC->_structure)
151         return false;
152     }
153   return true;
154 }
155
156 void MEDCouplingCurveLinearMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
157                                             DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception)
158 {
159   if(!isEqualWithoutConsideringStr(other,prec))
160     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkDeepEquivalWith : Meshes are not the same !");
161 }
162
163 /*!
164  * Nothing is done here (except to check that the other is a ParaMEDMEM::MEDCouplingCurveLinearMesh instance too).
165  * The user intend that the nodes are the same, so by construction of ParaMEDMEM::MEDCouplingCurveLinearMesh, 'this' and 'other' are the same !
166  */
167 void MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
168                                                        DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception)
169 {
170   const MEDCouplingCurveLinearMesh *otherC=dynamic_cast<const MEDCouplingCurveLinearMesh *>(other);
171   if(!otherC)
172     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith : other is NOT a cartesian mesh ! Impossible to check equivalence !");
173 }
174
175 void MEDCouplingCurveLinearMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
176 {
177   std::size_t sz=_structure.size(),i=0,nbOfNodes=1;
178   if(sz<1)
179     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkCoherency : structure should have a lgth of size 1 at least !");
180   for(std::vector<int>::const_iterator it=_structure.begin();it!=_structure.end();it++,i++)
181     {
182       if((*it)<1)
183         { std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::checkCoherency : At pos #" << i << " of structure value is " << *it << "should be >= 1 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
184       nbOfNodes*=*it;
185     }
186   if(!((const DataArrayDouble *)_coords))
187     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkCoherency : the array is not set !");
188   if(!_coords->isAllocated())
189     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkCoherency : the array is not allocated !");
190   if(_coords->getNumberOfComponents()<1)
191     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkCoherency : the array should have >= 1 components !");
192   if(_coords->getNumberOfTuples()!=(int)nbOfNodes)
193     {
194       std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::checkCoherency : structure said that number of nodes should be equal to " << nbOfNodes << " but number of tuples in array is equal to " << _coords->getNumberOfTuples() << " !";
195       throw INTERP_KERNEL::Exception(oss.str().c_str());
196     }
197 }
198
199 void MEDCouplingCurveLinearMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
200 {
201   checkCoherency();
202 }
203
204 void MEDCouplingCurveLinearMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception)
205 {
206   checkCoherency1(eps);
207 }
208
209 int MEDCouplingCurveLinearMesh::getNumberOfCells() const
210 {
211   checkCoherency();
212   std::size_t nbOfCells=1,i=0;
213   for(std::vector<int>::const_iterator it=_structure.begin();it!=_structure.end();it++,i++)
214     nbOfCells*=(*it)-1;
215   return (int)nbOfCells;
216 }
217
218 int MEDCouplingCurveLinearMesh::getNumberOfNodes() const
219 {
220   checkCoherency();
221   std::size_t nbOfNodes=1;
222   for(std::vector<int>::const_iterator it=_structure.begin();it!=_structure.end();it++)
223     nbOfNodes*=(*it);
224   return (int)nbOfNodes;
225 }
226
227 void MEDCouplingCurveLinearMesh::getSplitCellValues(int *res) const
228 {
229   int meshDim=getMeshDimension();
230   for(int l=0;l<meshDim;l++)
231     {
232       int val=1;
233       for(int p=0;p<meshDim-l-1;p++)
234         val*=_structure[p]-1;
235       res[meshDim-l-1]=val;
236     }
237 }
238
239 void MEDCouplingCurveLinearMesh::getSplitNodeValues(int *res) const
240 {
241   int meshDim=getMeshDimension();
242   for(int l=0;l<meshDim;l++)
243     {
244       int val=1;
245       for(int p=0;p<meshDim-l-1;p++)
246         val*=_structure[p];
247       res[meshDim-l-1]=val;
248     }
249 }
250
251 void MEDCouplingCurveLinearMesh::getNodeGridStructure(int *res) const
252 {
253   std::copy(_structure.begin(),_structure.end(),res);
254 }
255
256 int MEDCouplingCurveLinearMesh::getSpaceDimension() const
257 {
258   if(!((const DataArrayDouble *)_coords))
259     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getSpaceDimension : no array set ! impossible to deduce a space dimension !");
260   return _coords->getNumberOfComponents();
261 }
262
263 int MEDCouplingCurveLinearMesh::getMeshDimension() const
264 {
265   return (int)_structure.size();
266 }
267
268 void MEDCouplingCurveLinearMesh::getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const throw(INTERP_KERNEL::Exception)
269 {
270   if(!((const DataArrayDouble *)_coords))
271     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCoordinatesOfNode : Coordinates not set !");
272   int nbOfCompo=_coords->getNumberOfComponents();
273   if(nodeId>=0 && nodeId<_coords->getNumberOfTuples())
274     coo.insert(coo.end(),_coords->begin()+nodeId*nbOfCompo,_coords->begin()+(nodeId+1)*nbOfCompo);
275   else
276     { std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::getCoordinatesOfNode : nodeId has to be in [0," << _coords->getNumberOfTuples() << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
277 }
278
279 std::string MEDCouplingCurveLinearMesh::simpleRepr() const
280 {
281   std::ostringstream ret;
282   ret << "Curve linear mesh with name : \"" << getName() << "\"\n";
283   ret << "Description of mesh : \"" << getDescription() << "\"\n";
284   int tmpp1,tmpp2;
285   double tt=getTime(tmpp1,tmpp2);
286   ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
287   ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
288   ret << "The nodal stucture of curve linear mesh is : [";
289   std::copy(_structure.begin(),_structure.end(),std::ostream_iterator<int>(ret,",")); ret << "]\n";
290   ret << "The coords array is this : ";
291   if((const DataArrayDouble *)_coords)
292     _coords->reprZipWithoutNameStream(ret);
293   else
294     ret << "no array specified !";
295   return ret.str();
296 }
297
298 std::string MEDCouplingCurveLinearMesh::advancedRepr() const
299 {
300   return simpleRepr();
301 }
302
303 DataArrayDouble *MEDCouplingCurveLinearMesh::getCoords() throw(INTERP_KERNEL::Exception)
304 {
305   return _coords;
306 }
307
308 const DataArrayDouble *MEDCouplingCurveLinearMesh::getCoords() const throw(INTERP_KERNEL::Exception)
309 {
310   return _coords;
311 }
312
313 void MEDCouplingCurveLinearMesh::setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
314 {
315   if(coords!=(const DataArrayDouble *)_coords)
316     {
317       _coords=const_cast<DataArrayDouble *>(coords);
318       if(coords)
319         coords->incrRef();
320       declareAsNew();
321     }
322 }
323
324 void MEDCouplingCurveLinearMesh::setNodeGridStructure(const int *gridStructBg, const int *gridStructEnd) throw(INTERP_KERNEL::Exception)
325 {
326   std::size_t sz=std::distance(gridStructBg,gridStructEnd);
327   if(sz>=1 && sz<=3)
328     {
329       _structure.resize(0);
330       _structure.insert(_structure.end(),gridStructBg,gridStructEnd);
331     }
332   else
333     {
334       std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::setNodeGridStructure : size of input nodal grid structure (" << sz << ") should be in 1, 2 or 3 !";
335       throw INTERP_KERNEL::Exception(oss.str().c_str());
336     }
337 }
338
339 std::vector<int> MEDCouplingCurveLinearMesh::getNodeGridStructure() const throw(INTERP_KERNEL::Exception)
340 {
341   return _structure;
342 }
343
344 void MEDCouplingCurveLinearMesh::getBoundingBox(double *bbox) const
345 {
346   if(!((const DataArrayDouble *)_coords))
347     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBoundingBox : Coordinates not set !");
348   _coords->getMinMaxPerComponent(bbox);
349 }
350
351 MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureField(bool isAbs) const
352 {
353   checkCoherency();
354   int meshDim=getMeshDimension();
355   std::string name="MeasureOfMesh_"; name+=getName();
356   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
357   field->setName(name.c_str()); field->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(this)); field->synchronizeTimeWithMesh();
358   switch(meshDim)
359     {
360     case 3:
361       { getMeasureFieldMeshDim3(isAbs,field); return field.retn(); }
362     case 2:
363       { getMeasureFieldMeshDim2(isAbs,field); return field.retn(); }
364     case 1:
365       { getMeasureFieldMeshDim1(isAbs,field); return field.retn(); }
366     default:
367       throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureField : mesh dimension must be in [1,2,3] !");
368     }
369 }
370
371 /*!
372  * \param [in,out] f field feeded with good values.
373  * \sa MEDCouplingCurveLinearMesh::getMeasureField
374  */
375 void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim1(bool isAbs, MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
376 {
377   int nbnodes=getNumberOfNodes();
378   int spaceDim=getSpaceDimension();
379   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
380   if(nbnodes==0)
381     { arr->alloc(0,1); return; }
382   if(spaceDim==1)
383     {
384       arr->alloc(nbnodes-1,1);
385       std::transform(_coords->begin()+1,_coords->end(),_coords->begin(),arr->getPointer(),std::minus<double>());
386       if(isAbs)
387         arr->abs();
388     }
389   else
390     {
391       MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=DataArrayDouble::New(); tmp->alloc(nbnodes-1,spaceDim);
392       std::transform(_coords->begin()+spaceDim,_coords->end(),_coords->begin(),tmp->getPointer(),std::minus<double>());
393       MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=tmp->magnitude(); field->setArray(tmp2);
394     }
395 }
396
397 /*!
398  * \param [in,out] f field feeded with good values.
399  * \sa MEDCouplingCurveLinearMesh::getMeasureField
400  */
401 void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2(bool isAbs, MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
402 {
403   int nbcells=getNumberOfCells();
404   int spaceDim=getSpaceDimension();
405   if(spaceDim!=2 && spaceDim!=3)
406     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2 : with meshDim 2 only space dimension 2 and 3 are possible !");
407   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
408   arr->alloc(nbcells,1);
409   double *pt=arr->getPointer();
410   const double *coords=_coords->begin();
411   int nX=_structure[0]-1;
412   int conn[4];
413   for(int i=0;i<nbcells;i++,pt++)
414     {
415       int cy=i/nX,cx=i-cy*nX;
416       conn[0]=cy*(nX+1)+cx; conn[1]=(cy+1)*(nX+1)+cx; conn[2]=(cy+1)*(nX+1)+1+cx; conn[3]=cy*(nX+1)+cx+1;
417       *pt=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(INTERP_KERNEL::NORM_QUAD4,conn,4,coords,spaceDim);
418     }
419   if(isAbs)
420     arr->abs();
421 }
422
423 /*!
424  * \param [in,out] f field feeded with good values.
425  * \sa MEDCouplingCurveLinearMesh::getMeasureField
426  */
427 void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3(bool isAbs, MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
428 {
429   int nbcells=getNumberOfCells();
430   int spaceDim=getSpaceDimension();
431   if(spaceDim!=3)
432     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3 : with meshDim 3 only space dimension 3 is possible !");
433   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
434   arr->alloc(nbcells,1);
435   double *pt=arr->getPointer();
436   const double *coords=_coords->begin();
437   int nX=_structure[0]-1,nY=(_structure[0]-1)*(_structure[1]-1);
438   int nY1=_structure[0]*_structure[1];
439   int conn[8];
440   for(int i=0;i<nbcells;i++,pt++)
441     {
442       int cz=i/nY;
443       int cy=(i-cz*nY)/nX;
444       int cx=(i-cz*nY)-nX*cy;
445       conn[0]=cz*nY1+cy*(nX+1)+cx; conn[1]=cz*nY1+(cy+1)*(nX+1)+cx; conn[2]=cz*nY1+(cy+1)*(nX+1)+1+cx; conn[3]=cz*nY1+cy*(nX+1)+cx+1;
446       conn[4]=(cz+1)*nY1+cy*(nX+1)+cx; conn[5]=(cz+1)*nY1+(cy+1)*(nX+1)+cx; conn[6]=(cz+1)*nY1+(cy+1)*(nX+1)+1+cx; conn[7]=(cz+1)*nY1+cy*(nX+1)+cx+1;
447       *pt=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(INTERP_KERNEL::NORM_HEXA8,conn,8,coords,3);
448     }
449   if(isAbs)
450     arr->abs();
451 }
452
453 /*!
454  * not implemented yet !
455  */
456 MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureFieldOnNode(bool isAbs) const
457 {
458   throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldOnNode : not implemented yet !");
459 }
460
461 MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::buildOrthogonalField() const
462 {
463   if(getMeshDimension()!=2)
464     throw INTERP_KERNEL::Exception("Expected a cmesh with meshDim == 2 !");
465   MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
466   DataArrayDouble *array=DataArrayDouble::New();
467   int nbOfCells=getNumberOfCells();
468   array->alloc(nbOfCells,3);
469   double *vals=array->getPointer();
470   for(int i=0;i<nbOfCells;i++)
471     { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
472   ret->setArray(array);
473   array->decrRef();
474   ret->setMesh(this);
475   return ret;
476 }
477
478 /// @cond INTERNAL
479
480 namespace ParaMEDMEM
481 {
482   template<const int SPACEDIMM>
483   class DummyClsMCL
484   {
485   public:
486     static const int MY_SPACEDIM=SPACEDIMM;
487     static const int MY_MESHDIM=8;
488     typedef int MyConnType;
489     static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE;
490     // begin
491     // useless, but for windows compilation ...
492     const double* getCoordinatesPtr() const { return 0; }
493     const int* getConnectivityPtr() const { return 0; }
494     const int* getConnectivityIndexPtr() const { return 0; }
495     INTERP_KERNEL::NormalizedCellType getTypeOfElement(int) const { return (INTERP_KERNEL::NormalizedCellType)0; }
496     // end
497   };
498 }
499
500 /// @endcond
501
502 int MEDCouplingCurveLinearMesh::getCellContainingPoint(const double *pos, double eps) const
503 {
504   checkCoherency();
505   int spaceDim=getSpaceDimension();
506   const double *coords=_coords->getConstPointer();
507   int nodeId=-1;
508   _coords->distanceToTuple(pos,pos+spaceDim,nodeId);
509   if(nodeId<0)
510     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCellContainingPoint : internal problem 1 !");
511   int conn[8];
512   int nbOfNodes=getNumberOfNodes();
513   if(nbOfNodes==1)
514     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCellContainingPoint : No cells in this !");
515   switch(getMeshDimension())
516     {
517     case 1:
518       if(spaceDim==1)
519         {
520           if(nodeId>0)
521             {
522               conn[0]=nodeId-1; conn[1]=nodeId;
523               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<1> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_SEG2,coords,conn,2,eps))
524                 return nodeId-1;
525             }
526           if(nodeId<nbOfNodes-1)
527             {
528               conn[0]=nodeId; conn[1]=nodeId+1;
529               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<1> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_SEG2,coords,conn,2,eps))
530                 return nodeId;
531             }
532         }
533     case 2:
534       if(spaceDim==2)
535         {
536           int ny=nodeId/_structure[0],nx=nodeId-ny*_structure[0];
537           if(nx>0 && ny>0)
538             {
539               conn[0]=nx-1+_structure[0]*(ny-1); conn[1]=nx-1+_structure[0]*ny; conn[2]=nx+_structure[0]*ny; conn[3]=nx+_structure[0]*(ny-1);
540               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<2> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_QUAD4,coords,conn,4,eps))
541                 return nx-1+(ny-1)*_structure[0];
542             }
543           if(nx<_structure[0]-1 && ny>0)
544             {
545               conn[0]=nx+_structure[0]*(ny-1); conn[1]=nx+_structure[0]*ny; conn[2]=nx+1+_structure[0]*ny; conn[3]=nx+1+_structure[0]*(ny-1);
546               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<2> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_QUAD4,coords,conn,4,eps))
547                 return nx+(ny-1)*_structure[0];
548             }
549           if(nx>0 && ny<_structure[1]-1)
550             {
551               conn[0]=nx-1+_structure[0]*ny; conn[1]=nx-1+_structure[0]*(ny+1); conn[2]=nx+_structure[0]*(ny+1); conn[3]=nx+_structure[0]*ny;
552               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<2> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_QUAD4,coords,conn,4,eps))
553                 return nx-1+ny*_structure[0];
554             }
555           if(nx<_structure[0]-1 && ny<_structure[1]-1)
556             {
557               conn[0]=nx+_structure[0]*ny; conn[1]=nx+_structure[0]*(ny+1); conn[2]=nx+1+_structure[0]*(ny+1); conn[3]=nx+1+_structure[0]*ny;
558               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<2> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_QUAD4,coords,conn,4,eps))
559                 return nx+ny*_structure[0];
560             }
561         }
562     case 3:
563       {
564         if(spaceDim==3)
565           {
566             int nY=_structure[0]*_structure[1];
567             int nz=nodeId/_structure[1]; int ny=(nodeId-nz*nY)/_structure[0]; int nx=(nodeId-nz*nY)-_structure[0]*ny;
568             if(nx>0 && ny>0 && nz>0)
569               {
570                 conn[0]=nx-1+_structure[0]*(ny-1)+nY*(nz-1); conn[1]=nx-1+_structure[2]*ny+nY*(nz-1); conn[2]=nx+_structure[2]*ny+nY*(nz-1); conn[3]=nx+_structure[0]*(ny-1)+nY*(nz-1);
571                 conn[4]=nx-1+_structure[0]*(ny-1)+nY*nz; conn[5]=nx-1+_structure[0]*ny+nY*nz; conn[6]=nx+_structure[0]*ny+nY*nz; conn[7]=nx+_structure[0]*(ny-1)+nY*nz;
572                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
573                   return nx-1+(ny-1)*_structure[0]+(nz-1)*nY;
574               }
575             if(nx<_structure[0]-1 && ny>0 && nz>0)
576               {
577                 conn[0]=nx+_structure[0]*(ny-1)+nY*(nz-1); conn[1]=nx+_structure[0]*ny+nY*(nz-1); conn[2]=nx+1+_structure[0]*ny+nY*(nz-1); conn[3]=nx+1+_structure[0]*(ny-1)+nY*(nz-1);
578                 conn[4]=nx+_structure[0]*(ny-1)+nY*nz; conn[5]=nx+_structure[0]*ny+nY*nz; conn[6]=nx+1+_structure[0]*ny+nY*nz; conn[7]=nx+1+_structure[0]*(ny-1)+nY*nz;
579                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
580                   return nx+(ny-1)*_structure[0]+(nz-1)*nY;
581               }
582             if(nx>0 && ny<_structure[1]-1 && nz>0)
583               {
584                 conn[0]=nx-1+_structure[0]*ny+nY*(nz-1); conn[1]=nx-1+_structure[0]*(ny+1)+nY*(nz-1); conn[2]=nx+_structure[0]*(ny+1)+nY*(nz-1); conn[3]=nx+_structure[0]*ny+nY*(nz-1);
585                 conn[4]=nx-1+_structure[0]*ny+nY*nz; conn[5]=nx-1+_structure[0]*(ny+1)+nY*nz; conn[6]=nx+_structure[0]*(ny+1)+nY*nz; conn[7]=nx+_structure[0]*ny+nY*nz;
586                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
587                   return nx-1+ny*_structure[0]+(nz-1)*nY;
588               }
589             if(nx<_structure[0]-1 && ny<_structure[1]-1 && nz>0)
590               {
591                 conn[0]=nx+_structure[0]*ny+nY*(nz-1); conn[1]=nx+_structure[0]*(ny+1)+nY*(nz-1); conn[2]=nx+1+_structure[0]*(ny+1)+nY*(nz-1); conn[3]=nx+1+_structure[0]*ny+nY*(nz-1);
592                 conn[4]=nx+_structure[0]*ny+nY*nz; conn[5]=nx+_structure[0]*(ny+1)+nY*nz; conn[6]=nx+1+_structure[0]*(ny+1)+nY*nz; conn[7]=nx+1+_structure[0]*ny+nY*nz;
593                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
594                   return nx+ny*_structure[0]+(nz-1)*nY;
595               }
596             if(nx>0 && ny>0 && nz<_structure[2]-1)
597               {
598                 conn[0]=nx-1+_structure[0]*(ny-1)+nY*(nz-1); conn[1]=nx-1+_structure[2]*ny+nY*(nz-1); conn[2]=nx+_structure[2]*ny+nY*(nz-1); conn[3]=nx+_structure[0]*(ny-1)+nY*(nz-1);
599                 conn[4]=nx-1+_structure[0]*(ny-1)+nY*nz; conn[5]=nx-1+_structure[0]*ny+nY*nz; conn[6]=nx+_structure[0]*ny+nY*nz; conn[7]=nx+_structure[0]*(ny-1)+nY*nz;
600                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
601                   return nx-1+(ny-1)*_structure[0]+nz*nY;
602               }
603             if(nx<_structure[0]-1 && ny>0 && nz<_structure[2]-1)
604               {
605                 conn[0]=nx+_structure[0]*(ny-1)+nY*(nz-1); conn[1]=nx+_structure[0]*ny+nY*(nz-1); conn[2]=nx+1+_structure[0]*ny+nY*(nz-1); conn[3]=nx+1+_structure[0]*(ny-1)+nY*(nz-1);
606                 conn[4]=nx+_structure[0]*(ny-1)+nY*nz; conn[5]=nx+_structure[0]*ny+nY*nz; conn[6]=nx+1+_structure[0]*ny+nY*nz; conn[7]=nx+1+_structure[0]*(ny-1)+nY*nz;
607                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
608                   return nx+(ny-1)*_structure[0]+nz*nY;
609               }
610             if(nx>0 && ny<_structure[1]-1 && nz<_structure[2]-1)
611               {
612                 conn[0]=nx-1+_structure[0]*ny+nY*(nz-1); conn[1]=nx-1+_structure[0]*(ny+1)+nY*(nz-1); conn[2]=nx+_structure[0]*(ny+1)+nY*(nz-1); conn[3]=nx+_structure[0]*ny+nY*(nz-1);
613                 conn[4]=nx-1+_structure[0]*ny+nY*nz; conn[5]=nx-1+_structure[0]*(ny+1)+nY*nz; conn[6]=nx+_structure[0]*(ny+1)+nY*nz; conn[7]=nx+_structure[0]*ny+nY*nz;
614                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
615                   return nx-1+ny*_structure[0]+nz*nY;
616               }
617             if(nx<_structure[0]-1 && ny<_structure[1]-1 && nz<_structure[2]-1)
618               {
619                 conn[0]=nx+_structure[0]*ny+nY*(nz-1); conn[1]=nx+_structure[0]*(ny+1)+nY*(nz-1); conn[2]=nx+1+_structure[0]*(ny+1)+nY*(nz-1); conn[3]=nx+1+_structure[0]*ny+nY*(nz-1);
620                 conn[4]=nx+_structure[0]*ny+nY*nz; conn[5]=nx+_structure[0]*(ny+1)+nY*nz; conn[6]=nx+1+_structure[0]*(ny+1)+nY*nz; conn[7]=nx+1+_structure[0]*ny+nY*nz;
621                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
622                   return nx+ny*_structure[0]+nz*nY;
623               }
624           }
625       }
626     default:
627       throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCellContainingPoint : mesh dimension managed are 1, 2 or 3 !");
628     }
629 }
630
631 void MEDCouplingCurveLinearMesh::rotate(const double *center, const double *vector, double angle)
632 {
633   if(!((DataArrayDouble *)_coords))
634     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::rotate : no coordinates set !");
635   int spaceDim=getSpaceDimension();
636   int nbNodes=_coords->getNumberOfTuples();
637   double *coords=_coords->getPointer();
638   if(spaceDim==3)
639     MEDCouplingPointSet::Rotate3DAlg(center,vector,angle,nbNodes,coords);
640   else if(spaceDim==2)
641     MEDCouplingPointSet::Rotate2DAlg(center,angle,nbNodes,coords);
642   else
643     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::rotate : invalid space dim for rotation must be 2 or 3");
644   _coords->declareAsNew();
645   updateTime();
646 }
647
648 void MEDCouplingCurveLinearMesh::translate(const double *vector)
649 {
650   if(!vector)
651     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::translate : NULL input point !");
652   if(!((DataArrayDouble *)_coords))
653     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::translate : no coordinates set !");
654   double *coords=_coords->getPointer();
655   int nbNodes=getNumberOfNodes();
656   int dim=getSpaceDimension();
657   for(int i=0; i<nbNodes; i++)
658     for(int idim=0; idim<dim;idim++)
659       coords[i*dim+idim]+=vector[idim];
660   _coords->declareAsNew();
661   updateTime();
662 }
663
664 void MEDCouplingCurveLinearMesh::scale(const double *point, double factor)
665 {
666   if(!point)
667     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::scale : NULL input point !");
668   if(!((DataArrayDouble *)_coords))
669     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::scale : no coordinates set !");
670   double *coords=_coords->getPointer();
671   int nbNodes=_coords->getNumberOfTuples();
672   int dim=_coords->getNumberOfComponents();
673   for(int i=0;i<nbNodes;i++)
674     {
675       std::transform(coords+i*dim,coords+(i+1)*dim,point,coords+i*dim,std::minus<double>());
676       std::transform(coords+i*dim,coords+(i+1)*dim,coords+i*dim,std::bind2nd(std::multiplies<double>(),factor));
677       std::transform(coords+i*dim,coords+(i+1)*dim,point,coords+i*dim,std::plus<double>());
678     }
679   _coords->declareAsNew();
680   updateTime();
681 }
682
683 MEDCouplingMesh *MEDCouplingCurveLinearMesh::mergeMyselfWith(const MEDCouplingMesh *other) const
684 {
685   throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::mergeMyselfWith : not available for CurveLinear Mesh !");
686 }
687
688 DataArrayDouble *MEDCouplingCurveLinearMesh::getCoordinatesAndOwner() const
689 {
690   DataArrayDouble *ret=const_cast<DataArrayDouble *>((const DataArrayDouble *)_coords);
691   if(ret)
692     ret->incrRef();
693   return ret;
694 }
695
696 DataArrayDouble *MEDCouplingCurveLinearMesh::getBarycenterAndOwner() const
697 {
698   checkCoherency();
699   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
700   int spaceDim=getSpaceDimension();
701   int meshDim=getMeshDimension();
702   int nbOfCells=getNumberOfCells();
703   ret->alloc(nbOfCells,spaceDim);
704   ret->copyStringInfoFrom(*getCoords());
705   switch(meshDim)
706     {
707     case 3:
708       { getBarycenterAndOwnerMeshDim3(ret); return ret.retn(); }
709     case 2:
710       { getBarycenterAndOwnerMeshDim2(ret); return ret.retn(); }
711     case 1:
712       { getBarycenterAndOwnerMeshDim1(ret); return ret.retn(); }
713     default:
714       throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBarycenterAndOwner : mesh dimension must be in [1,2,3] !");
715     }
716 }
717
718 DataArrayDouble *MEDCouplingCurveLinearMesh::computeIsoBarycenterOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
719 {
720   return MEDCouplingCurveLinearMesh::getBarycenterAndOwner();
721 }
722
723 /*!
724  * \param [in,out] bary Barycenter array feeded with good values.
725  * \sa MEDCouplingCurveLinearMesh::getBarycenterAndOwner
726  */
727 void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim3(DataArrayDouble *bary) const
728 {
729   int nbOfCells=getNumberOfCells();
730   double *ptToFill=bary->getPointer();
731   const double *coor=_coords->getConstPointer();
732   if(getSpaceDimension()!=3)
733     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim3 : with meshDim 3 only space dimension 3 is possible !");
734   int nX=_structure[0]-1,nY=(_structure[0]-1)*(_structure[1]-1);
735   int nY1=_structure[0]*_structure[1];
736   int conn[8];
737   for(int i=0;i<nbOfCells;i++)
738     {
739       int cz=i/nY;
740       int cy=(i-cz*nY)/nX;
741       int cx=(i-cz*nY)-nX*cy;
742       conn[0]=cz*nY1+cy*(nX+1)+cx+1; conn[1]=cz*nY1+cy*(nX+1)+cx; conn[2]=cz*nY1+(cy+1)*(nX+1)+cx; conn[3]=cz*nY1+(cy+1)*(nX+1)+1+cx;
743       conn[4]=(cz+1)*nY1+cy*(nX+1)+cx+1; conn[5]=(cz+1)*nY1+cy*(nX+1)+cx; conn[6]=(cz+1)*nY1+(cy+1)*(nX+1)+cx; conn[7]=(cz+1)*nY1+(cy+1)*(nX+1)+1+cx;
744       INTERP_KERNEL::computeBarycenter2<int,INTERP_KERNEL::ALL_C_MODE>(INTERP_KERNEL::NORM_HEXA8,conn,8,coor,3,ptToFill);
745       ptToFill+=3;
746     }
747 }
748
749 /*!
750  * \param [in,out] bary Barycenter array feeded with good values.
751  * \sa MEDCouplingCurveLinearMesh::getBarycenterAndOwner
752  */
753 void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim2(DataArrayDouble *bary) const
754 {
755   int nbcells=getNumberOfCells();
756   int spaceDim=getSpaceDimension();
757   double *ptToFill=bary->getPointer();
758   const double *coor=_coords->getConstPointer();
759   if(spaceDim!=2 && spaceDim!=3)
760     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim2 : with meshDim 2 only space dimension 2 and 3 are possible !");
761   int nX=_structure[0]-1;
762   int conn[4];
763   for(int i=0;i<nbcells;i++)
764     {
765       int cy=i/nX,cx=i-cy*nX;
766       conn[0]=cy*(nX+1)+cx; conn[1]=(cy+1)*(nX+1)+cx; conn[2]=(cy+1)*(nX+1)+1+cx; conn[3]=cy*(nX+1)+cx+1;
767       INTERP_KERNEL::computeBarycenter2<int,INTERP_KERNEL::ALL_C_MODE>(INTERP_KERNEL::NORM_QUAD4,conn,4,coor,spaceDim,ptToFill);
768       ptToFill+=spaceDim;
769     }
770 }
771
772 /*!
773  * \param [in,out] bary Barycenter array feeded with good values.
774  * \sa MEDCouplingCurveLinearMesh::getBarycenterAndOwner
775  */
776 void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim1(DataArrayDouble *bary) const
777 {
778   int spaceDim=getSpaceDimension();
779   std::transform(_coords->begin()+spaceDim,_coords->end(),_coords->begin(),bary->getPointer(),std::plus<double>());
780   std::transform(bary->begin(),bary->end(),bary->getPointer(),std::bind2nd(std::multiplies<double>(),0.5));
781 }
782
783 void MEDCouplingCurveLinearMesh::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
784 {
785   throw INTERP_KERNEL::Exception("Functionnality of renumbering cell not available for CurveLinear Mesh !");
786 }
787
788 void MEDCouplingCurveLinearMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
789 {
790   int it,order;
791   double time=getTime(it,order);
792   tinyInfo.clear();
793   tinyInfoD.clear();
794   littleStrings.clear();
795   littleStrings.push_back(getName());
796   littleStrings.push_back(getDescription());
797   littleStrings.push_back(getTimeUnit());
798   //
799   std::vector<std::string> littleStrings2;
800   if((const DataArrayDouble *)_coords)
801     _coords->getTinySerializationStrInformation(littleStrings2);
802   littleStrings.insert(littleStrings.end(),littleStrings2.begin(),littleStrings2.end());
803   //
804   tinyInfo.push_back(it);
805   tinyInfo.push_back(order);
806   tinyInfo.push_back((int)_structure.size());
807   for(std::vector<int>::const_iterator itt=_structure.begin();itt!=_structure.end();itt++)
808     tinyInfo.push_back(*itt);
809   std::vector<int> tinyInfo2;
810   if((const DataArrayDouble *)_coords)
811     _coords->getTinySerializationIntInformation(tinyInfo2);
812   tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
813   //
814   tinyInfoD.push_back(time);
815 }
816
817 void MEDCouplingCurveLinearMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
818 {
819   a1->alloc(tinyInfo[2],1);
820   std::vector<int> tinyInfo2(tinyInfo.begin()+3+tinyInfo[2],tinyInfo.end());
821   a2->resizeForUnserialization(tinyInfo2);
822 }
823
824 void MEDCouplingCurveLinearMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
825 {
826   a1=DataArrayInt::New();
827   a1->alloc((int)_structure.size(),1);
828   int *ptr=a1->getPointer();
829   for(std::vector<int>::const_iterator it=_structure.begin();it!=_structure.end();it++,ptr++)
830     *ptr=(*it);
831   int sz=0;
832   if((const DataArrayDouble *)_coords)
833     if(_coords->isAllocated())
834       sz=_coords->getNbOfElems();
835   a2=DataArrayDouble::New();
836   a2->alloc(sz,1);
837   if(sz!=0 && (const DataArrayDouble *)_coords)
838     std::copy(_coords->begin(),_coords->end(),a2->getPointer());
839 }
840
841 void MEDCouplingCurveLinearMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
842                                                  const std::vector<std::string>& littleStrings)
843 {
844   setName(littleStrings[0].c_str());
845   setDescription(littleStrings[1].c_str());
846   setTimeUnit(littleStrings[2].c_str());
847   setTime(tinyInfoD[0],tinyInfo[0],tinyInfo[1]);
848   int sz=tinyInfo[2];
849   _structure.resize(sz);
850   for(int i=0;i<sz;i++)
851     _structure[i]=tinyInfo[3+i];
852   if((int)tinyInfo.size()>sz+3)
853     {
854       _coords=DataArrayDouble::New();
855       std::vector<int> tinyInfo2(tinyInfo.begin()+3+sz,tinyInfo.end());
856       _coords->resizeForUnserialization(tinyInfo2);
857       std::copy(a2->begin(),a2->end(),_coords->getPointer());
858       std::vector<std::string> littleStrings2(littleStrings.begin()+3,littleStrings.end());
859       _coords->finishUnserialization(tinyInfo2,littleStrings2);
860     }
861 }
862
863 void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception)
864 {
865   std::ostringstream extent;
866   int meshDim=(int)_structure.size();
867   if(meshDim<=0 || meshDim>3)
868     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::writeVTKLL : meshDim invalid ! must be in [1,2,3] !");
869   for(int i=0;i<3;i++)
870     { int val=i<meshDim?_structure[i]-1:0; extent << "0 " <<  val << " "; }
871   ofs << "  <" << getVTKDataSetType() << " WholeExtent=\"" << extent.str() << "\">\n";
872   ofs << "    <Piece Extent=\"" << extent.str() << "\">\n";
873   ofs << "      <PointData>\n" << pointData << std::endl;
874   ofs << "      </PointData>\n";
875   ofs << "      <CellData>\n" << cellData << std::endl;
876   ofs << "      </CellData>\n";
877   ofs << "      <Points>\n";
878   if(getSpaceDimension()==3)
879     _coords->writeVTK(ofs,8,"Points");
880   else
881     {
882       MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo=_coords->changeNbOfComponents(3,0.);
883       coo->writeVTK(ofs,8,"Points");
884     }
885   ofs << "      </Points>\n";
886   ofs << "    </Piece>\n";
887   ofs << "  </" << getVTKDataSetType() << ">\n";
888 }
889
890 void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
891 {
892   stream << "MEDCouplingCurveLinearMesh C++ instance at " << this << ". Name : \"" << getName() << "\".";
893   stream << "Nodal structure : [";
894   for(std::size_t i=0;i<_structure.size();i++)
895     {
896       char tmp='X'+i;
897       stream << " " << tmp << "=" << _structure[i];
898       if(i!=_structure.size()-1)
899         stream << ", ";
900     }
901   stream << " ].";
902   const DataArrayDouble *coo(_coords);
903   if(!coo)
904     { stream << std::endl << "No coordinates set !"; return ; }
905   if(!coo->isAllocated())
906     { stream << std::endl << "Coordinates set but not allocated !"; return ; }
907   int nbOfCompo=coo->getNumberOfComponents();
908   if(nbOfCompo!=(int)_structure.size())
909     { stream << std::endl << "Coordinates set and allocated but mismatch number of components !"; return ; }
910   stream << std::endl << "Coordinates ( number of tuples = " << coo->getNumberOfTuples() << " ) : ";
911   coo->reprQuickOverviewData(stream,200);
912 }
913
914 std::string MEDCouplingCurveLinearMesh::getVTKDataSetType() const throw(INTERP_KERNEL::Exception)
915 {
916   return std::string("StructuredGrid");
917 }