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