Salome HOME
1f7fc08919a2ab46b1dacc1847099b806e0f513b
[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 (EDF R&D)
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 deepCpy):MEDCouplingStructuredMesh(other,deepCpy),_structure(other._structure)
41 {
42   if(deepCpy)
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 std::size_t 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 structure 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 const DataArrayDouble *MEDCouplingCurveLinearMesh::getDirectAccessOfCoordsArrIfInStructure() const
274 {
275   return _coords;
276 }
277
278 DataArrayDouble *MEDCouplingCurveLinearMesh::getCoords()
279 {
280   return _coords;
281 }
282
283 const DataArrayDouble *MEDCouplingCurveLinearMesh::getCoords() const
284 {
285   return _coords;
286 }
287
288 void MEDCouplingCurveLinearMesh::setCoords(const DataArrayDouble *coords)
289 {
290   if(coords!=(const DataArrayDouble *)_coords)
291     {
292       _coords=const_cast<DataArrayDouble *>(coords);
293       if(coords)
294         coords->incrRef();
295       declareAsNew();
296     }
297 }
298
299 void MEDCouplingCurveLinearMesh::setNodeGridStructure(const int *gridStructBg, const int *gridStructEnd)
300 {
301   std::size_t sz=std::distance(gridStructBg,gridStructEnd);
302   if(sz>=1 && sz<=3)
303     {
304       _structure.resize(0);
305       _structure.insert(_structure.end(),gridStructBg,gridStructEnd);
306     }
307   else
308     {
309       std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::setNodeGridStructure : size of input nodal grid structure (" << sz << ") should be in 1, 2 or 3 !";
310       throw INTERP_KERNEL::Exception(oss.str().c_str());
311     }
312 }
313
314 std::vector<int> MEDCouplingCurveLinearMesh::getNodeGridStructure() const
315 {
316   return _structure;
317 }
318
319 MEDCouplingStructuredMesh *MEDCouplingCurveLinearMesh::buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const
320 {
321   checkConsistencyLight();
322   int dim(getSpaceDimension());
323   std::vector<int> dims(getMeshDimension());
324   if(dim!=(int)cellPart.size())
325     {
326       std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !";
327       throw INTERP_KERNEL::Exception(oss.str().c_str());
328     }
329   std::vector< std::pair<int,int> > nodePartFormat(cellPart);
330   for(std::vector< std::pair<int,int> >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++)
331     (*it).second++;
332   MCAuto<DataArrayInt> tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat));
333   MCAuto<MEDCouplingCurveLinearMesh> ret(dynamic_cast<MEDCouplingCurveLinearMesh *>(deepCopy()));
334   const DataArrayDouble *coo(ret->getCoords());
335   if(coo)
336     {
337       MCAuto<DataArrayDouble> coo2(coo->selectByTupleIdSafe(tmp1->begin(),tmp1->end()));
338       ret->setCoords(coo2);
339     }
340   for(int i=0;i<dim;i++)
341     {
342       dims[i]=cellPart[i].second-cellPart[i].first+1;
343       if(dims[i]<1)
344         throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::buildStructuredSubPart : invalid input cellPart !");
345     }
346   ret->setNodeGridStructure(&dims[0],&dims[0]+dims.size());
347   return ret.retn();
348 }
349
350 void MEDCouplingCurveLinearMesh::getBoundingBox(double *bbox) const
351 {
352   if(!((const DataArrayDouble *)_coords))
353     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBoundingBox : Coordinates not set !");
354   _coords->getMinMaxPerComponent(bbox);
355 }
356
357 MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureField(bool isAbs) const
358 {
359   checkConsistencyLight();
360   int meshDim=getMeshDimension();
361   std::string name="MeasureOfMesh_"; name+=getName();
362   MCAuto<MEDCouplingFieldDouble> field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
363   field->setName(name); field->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(this)); field->synchronizeTimeWithMesh();
364   switch(meshDim)
365   {
366     case 3:
367       { getMeasureFieldMeshDim3(isAbs,field); return field.retn(); }
368     case 2:
369       { getMeasureFieldMeshDim2(isAbs,field); return field.retn(); }
370     case 1:
371       { getMeasureFieldMeshDim1(isAbs,field); return field.retn(); }
372     default:
373       throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureField : mesh dimension must be in [1,2,3] !");
374   }
375 }
376
377 /*!
378  * \param [in,out] f field fed with good values.
379  * \sa MEDCouplingCurveLinearMesh::getMeasureField
380  */
381 void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim1(bool isAbs, MEDCouplingFieldDouble *field) const
382 {
383   int nbnodes=getNumberOfNodes();
384   int spaceDim=getSpaceDimension();
385   MCAuto<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
386   if(nbnodes==0)
387     { arr->alloc(0,1); return; }
388   if(spaceDim==1)
389     {
390       arr->alloc(nbnodes-1,1);
391       std::transform(_coords->begin()+1,_coords->end(),_coords->begin(),arr->getPointer(),std::minus<double>());
392       if(isAbs)
393         arr->abs();
394     }
395   else
396     {
397       MCAuto<DataArrayDouble> tmp=DataArrayDouble::New(); tmp->alloc(nbnodes-1,spaceDim);
398       std::transform(_coords->begin()+spaceDim,_coords->end(),_coords->begin(),tmp->getPointer(),std::minus<double>());
399       MCAuto<DataArrayDouble> tmp2=tmp->magnitude(); field->setArray(tmp2);
400     }
401 }
402
403 /*!
404  * \param [in,out] f field fed with good values.
405  * \sa MEDCouplingCurveLinearMesh::getMeasureField
406  */
407 void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2(bool isAbs, MEDCouplingFieldDouble *field) const
408 {
409   int nbcells=getNumberOfCells();
410   int spaceDim=getSpaceDimension();
411   if(spaceDim!=2 && spaceDim!=3)
412     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2 : with meshDim 2 only space dimension 2 and 3 are possible !");
413   MCAuto<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
414   arr->alloc(nbcells,1);
415   double *pt=arr->getPointer();
416   const double *coords=_coords->begin();
417   int nX=_structure[0]-1;
418   int conn[4];
419   for(int i=0;i<nbcells;i++,pt++)
420     {
421       int cy=i/nX,cx=i-cy*nX;
422       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;
423       *pt=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(INTERP_KERNEL::NORM_QUAD4,conn,4,coords,spaceDim);
424     }
425   if(isAbs)
426     arr->abs();
427 }
428
429 /*!
430  * \param [in,out] f field fed with good values.
431  * \sa MEDCouplingCurveLinearMesh::getMeasureField
432  */
433 void MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3(bool isAbs, MEDCouplingFieldDouble *field) const
434 {
435   int nbcells=getNumberOfCells();
436   int spaceDim=getSpaceDimension();
437   if(spaceDim!=3)
438     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3 : with meshDim 3 only space dimension 3 is possible !");
439   MCAuto<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
440   arr->alloc(nbcells,1);
441   double *pt=arr->getPointer();
442   const double *coords=_coords->begin();
443   int nX=_structure[0]-1,nY=(_structure[0]-1)*(_structure[1]-1);
444   int nY1=_structure[0]*_structure[1];
445   int conn[8];
446   for(int i=0;i<nbcells;i++,pt++)
447     {
448       int cz=i/nY;
449       int cy=(i-cz*nY)/nX;
450       int cx=(i-cz*nY)-nX*cy;
451       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;
452       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;
453       *pt=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(INTERP_KERNEL::NORM_HEXA8,conn,8,coords,3);
454     }
455   if(isAbs)
456     arr->abs();
457 }
458
459 /*!
460  * not implemented yet !
461  */
462 MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureFieldOnNode(bool isAbs) const
463 {
464   throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldOnNode : not implemented yet !");
465 }
466
467 MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::buildOrthogonalField() const
468 {
469   if(getMeshDimension()!=2)
470     throw INTERP_KERNEL::Exception("Expected a cmesh with meshDim == 2 !");
471   MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
472   DataArrayDouble *array=DataArrayDouble::New();
473   int nbOfCells=getNumberOfCells();
474   array->alloc(nbOfCells,3);
475   double *vals=array->getPointer();
476   for(int i=0;i<nbOfCells;i++)
477     { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
478   ret->setArray(array);
479   array->decrRef();
480   ret->setMesh(this);
481   return ret;
482 }
483
484 /// @cond INTERNAL
485
486 namespace MEDCoupling
487 {
488   template<const int SPACEDIMM>
489   class DummyClsMCL
490   {
491   public:
492     static const int MY_SPACEDIM=SPACEDIMM;
493     static const int MY_MESHDIM=8;
494     typedef int MyConnType;
495     static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE;
496     // begin
497     // useless, but for windows compilation ...
498     const double* getCoordinatesPtr() const { return 0; }
499     const int* getConnectivityPtr() const { return 0; }
500     const int* getConnectivityIndexPtr() const { return 0; }
501     INTERP_KERNEL::NormalizedCellType getTypeOfElement(int) const { return (INTERP_KERNEL::NormalizedCellType)0; }
502     // end
503   };
504 }
505
506 /// @endcond
507
508 int MEDCouplingCurveLinearMesh::getCellContainingPoint(const double *pos, double eps) const
509 {
510   checkConsistencyLight();
511   int spaceDim=getSpaceDimension();
512   const double *coords=_coords->getConstPointer();
513   int nodeId=-1;
514   _coords->distanceToTuple(pos,pos+spaceDim,nodeId);
515   if(nodeId<0)
516     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCellContainingPoint : internal problem 1 !");
517   int conn[8];
518   int nbOfNodes=getNumberOfNodes();
519   if(nbOfNodes==1)
520     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCellContainingPoint : No cells in this !");
521   switch(getMeshDimension())
522   {
523     case 1:
524       if(spaceDim==1)
525         {
526           if(nodeId>0)
527             {
528               conn[0]=nodeId-1; conn[1]=nodeId;
529               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<1> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_SEG2,coords,conn,2,eps))
530                 return nodeId-1;
531             }
532           if(nodeId<nbOfNodes-1)
533             {
534               conn[0]=nodeId; conn[1]=nodeId+1;
535               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<1> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_SEG2,coords,conn,2,eps))
536                 return nodeId;
537             }
538         }
539     case 2:
540       if(spaceDim==2)
541         {
542           int ny=nodeId/_structure[0],nx=nodeId-ny*_structure[0];
543           if(nx>0 && ny>0)
544             {
545               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);
546               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<2> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_QUAD4,coords,conn,4,eps))
547                 return nx-1+(ny-1)*_structure[0];
548             }
549           if(nx<_structure[0]-1 && ny>0)
550             {
551               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);
552               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<2> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_QUAD4,coords,conn,4,eps))
553                 return nx+(ny-1)*_structure[0];
554             }
555           if(nx>0 && ny<_structure[1]-1)
556             {
557               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;
558               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<2> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_QUAD4,coords,conn,4,eps))
559                 return nx-1+ny*_structure[0];
560             }
561           if(nx<_structure[0]-1 && ny<_structure[1]-1)
562             {
563               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;
564               if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<2> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_QUAD4,coords,conn,4,eps))
565                 return nx+ny*_structure[0];
566             }
567         }
568     case 3:
569       {
570         if(spaceDim==3)
571           {
572             int nY=_structure[0]*_structure[1];
573             int nz=nodeId/_structure[1]; int ny=(nodeId-nz*nY)/_structure[0]; int nx=(nodeId-nz*nY)-_structure[0]*ny;
574             if(nx>0 && ny>0 && nz>0)
575               {
576                 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);
577                 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;
578                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
579                   return nx-1+(ny-1)*_structure[0]+(nz-1)*nY;
580               }
581             if(nx<_structure[0]-1 && ny>0 && nz>0)
582               {
583                 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);
584                 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;
585                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
586                   return nx+(ny-1)*_structure[0]+(nz-1)*nY;
587               }
588             if(nx>0 && ny<_structure[1]-1 && nz>0)
589               {
590                 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);
591                 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;
592                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
593                   return nx-1+ny*_structure[0]+(nz-1)*nY;
594               }
595             if(nx<_structure[0]-1 && ny<_structure[1]-1 && nz>0)
596               {
597                 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);
598                 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;
599                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
600                   return nx+ny*_structure[0]+(nz-1)*nY;
601               }
602             if(nx>0 && ny>0 && nz<_structure[2]-1)
603               {
604                 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);
605                 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;
606                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
607                   return nx-1+(ny-1)*_structure[0]+nz*nY;
608               }
609             if(nx<_structure[0]-1 && ny>0 && nz<_structure[2]-1)
610               {
611                 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);
612                 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;
613                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
614                   return nx+(ny-1)*_structure[0]+nz*nY;
615               }
616             if(nx>0 && ny<_structure[1]-1 && nz<_structure[2]-1)
617               {
618                 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);
619                 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;
620                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
621                   return nx-1+ny*_structure[0]+nz*nY;
622               }
623             if(nx<_structure[0]-1 && ny<_structure[1]-1 && nz<_structure[2]-1)
624               {
625                 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);
626                 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;
627                 if(INTERP_KERNEL::PointLocatorAlgos<DummyClsMCL<3> >::isElementContainsPoint(pos,INTERP_KERNEL::NORM_HEXA8,coords,conn,8,eps))
628                   return nx+ny*_structure[0]+nz*nY;
629               }
630           }
631       }
632     default:
633       throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getCellContainingPoint : mesh dimension managed are 1, 2 or 3 !");
634   }
635 }
636
637 void MEDCouplingCurveLinearMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
638 {
639   int ret(getCellContainingPoint(pos,eps));
640   elts.push_back(ret);
641 }
642
643 void MEDCouplingCurveLinearMesh::rotate(const double *center, const double *vector, double angle)
644 {
645   if(!((DataArrayDouble *)_coords))
646     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::rotate : no coordinates set !");
647   int spaceDim=getSpaceDimension();
648   int nbNodes=_coords->getNumberOfTuples();
649   double *coords=_coords->getPointer();
650   if(spaceDim==3)
651     DataArrayDouble::Rotate3DAlg(center,vector,angle,nbNodes,coords,coords);
652   else if(spaceDim==2)
653     DataArrayDouble::Rotate2DAlg(center,angle,nbNodes,coords,coords);
654   else
655     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::rotate : invalid space dim for rotation must be 2 or 3");
656   _coords->declareAsNew();
657   updateTime();
658 }
659
660 void MEDCouplingCurveLinearMesh::translate(const double *vector)
661 {
662   if(!vector)
663     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::translate : NULL input point !");
664   if(!((DataArrayDouble *)_coords))
665     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::translate : no coordinates set !");
666   double *coords=_coords->getPointer();
667   int nbNodes=getNumberOfNodes();
668   int dim=getSpaceDimension();
669   for(int i=0; i<nbNodes; i++)
670     for(int idim=0; idim<dim;idim++)
671       coords[i*dim+idim]+=vector[idim];
672   _coords->declareAsNew();
673   updateTime();
674 }
675
676 void MEDCouplingCurveLinearMesh::scale(const double *point, double factor)
677 {
678   if(!point)
679     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::scale : NULL input point !");
680   if(!((DataArrayDouble *)_coords))
681     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::scale : no coordinates set !");
682   double *coords=_coords->getPointer();
683   int nbNodes=_coords->getNumberOfTuples();
684   int dim=_coords->getNumberOfComponents();
685   for(int i=0;i<nbNodes;i++)
686     {
687       std::transform(coords+i*dim,coords+(i+1)*dim,point,coords+i*dim,std::minus<double>());
688       std::transform(coords+i*dim,coords+(i+1)*dim,coords+i*dim,std::bind2nd(std::multiplies<double>(),factor));
689       std::transform(coords+i*dim,coords+(i+1)*dim,point,coords+i*dim,std::plus<double>());
690     }
691   _coords->declareAsNew();
692   updateTime();
693 }
694
695 MEDCouplingMesh *MEDCouplingCurveLinearMesh::mergeMyselfWith(const MEDCouplingMesh *other) const
696 {
697   throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::mergeMyselfWith : not available for CurveLinear Mesh !");
698 }
699
700 DataArrayDouble *MEDCouplingCurveLinearMesh::getCoordinatesAndOwner() const
701 {
702   DataArrayDouble *ret=const_cast<DataArrayDouble *>((const DataArrayDouble *)_coords);
703   if(ret)
704     ret->incrRef();
705   return ret;
706 }
707
708 DataArrayDouble *MEDCouplingCurveLinearMesh::computeCellCenterOfMass() const
709 {
710   checkConsistencyLight();
711   MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
712   int spaceDim=getSpaceDimension();
713   int meshDim=getMeshDimension();
714   int nbOfCells=getNumberOfCells();
715   ret->alloc(nbOfCells,spaceDim);
716   ret->copyStringInfoFrom(*getCoords());
717   switch(meshDim)
718   {
719     case 3:
720       { getBarycenterAndOwnerMeshDim3(ret); return ret.retn(); }
721     case 2:
722       { getBarycenterAndOwnerMeshDim2(ret); return ret.retn(); }
723     case 1:
724       { getBarycenterAndOwnerMeshDim1(ret); return ret.retn(); }
725     default:
726       throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::computeCellCenterOfMass : mesh dimension must be in [1,2,3] !");
727   }
728 }
729
730 DataArrayDouble *MEDCouplingCurveLinearMesh::computeIsoBarycenterOfNodesPerCell() const
731 {
732   return MEDCouplingCurveLinearMesh::computeCellCenterOfMass();
733 }
734
735 /*!
736  * \param [in,out] bary Barycenter array fed with good values.
737  * \sa MEDCouplingCurveLinearMesh::computeCellCenterOfMass
738  */
739 void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim3(DataArrayDouble *bary) const
740 {
741   int nbOfCells=getNumberOfCells();
742   double *ptToFill=bary->getPointer();
743   const double *coor=_coords->getConstPointer();
744   if(getSpaceDimension()!=3)
745     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim3 : with meshDim 3 only space dimension 3 is possible !");
746   int nX=_structure[0]-1,nY=(_structure[0]-1)*(_structure[1]-1);
747   int nY1=_structure[0]*_structure[1];
748   int conn[8];
749   for(int i=0;i<nbOfCells;i++)
750     {
751       int cz=i/nY;
752       int cy=(i-cz*nY)/nX;
753       int cx=(i-cz*nY)-nX*cy;
754       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;
755       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;
756       INTERP_KERNEL::computeBarycenter2<int,INTERP_KERNEL::ALL_C_MODE>(INTERP_KERNEL::NORM_HEXA8,conn,8,coor,3,ptToFill);
757       ptToFill+=3;
758     }
759 }
760
761 /*!
762  * \param [in,out] bary Barycenter array fed with good values.
763  * \sa MEDCouplingCurveLinearMesh::computeCellCenterOfMass
764  */
765 void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim2(DataArrayDouble *bary) const
766 {
767   int nbcells=getNumberOfCells();
768   int spaceDim=getSpaceDimension();
769   double *ptToFill=bary->getPointer();
770   const double *coor=_coords->getConstPointer();
771   if(spaceDim!=2 && spaceDim!=3)
772     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim2 : with meshDim 2 only space dimension 2 and 3 are possible !");
773   int nX=_structure[0]-1;
774   int conn[4];
775   for(int i=0;i<nbcells;i++)
776     {
777       int cy=i/nX,cx=i-cy*nX;
778       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;
779       INTERP_KERNEL::computeBarycenter2<int,INTERP_KERNEL::ALL_C_MODE>(INTERP_KERNEL::NORM_QUAD4,conn,4,coor,spaceDim,ptToFill);
780       ptToFill+=spaceDim;
781     }
782 }
783
784 /*!
785  * \param [in,out] bary Barycenter array fed with good values.
786  * \sa MEDCouplingCurveLinearMesh::computeCellCenterOfMass
787  */
788 void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim1(DataArrayDouble *bary) const
789 {
790   int spaceDim=getSpaceDimension();
791   std::transform(_coords->begin()+spaceDim,_coords->end(),_coords->begin(),bary->getPointer(),std::plus<double>());
792   std::transform(bary->begin(),bary->end(),bary->getPointer(),std::bind2nd(std::multiplies<double>(),0.5));
793 }
794
795 void MEDCouplingCurveLinearMesh::renumberCells(const int *old2NewBg, bool check)
796 {
797   throw INTERP_KERNEL::Exception("Functionality of renumbering cell not available for CurveLinear Mesh !");
798 }
799
800 void MEDCouplingCurveLinearMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
801 {
802   int it,order;
803   double time=getTime(it,order);
804   tinyInfo.clear();
805   tinyInfoD.clear();
806   littleStrings.clear();
807   littleStrings.push_back(getName());
808   littleStrings.push_back(getDescription());
809   littleStrings.push_back(getTimeUnit());
810   //
811   std::vector<std::string> littleStrings2;
812   if((const DataArrayDouble *)_coords)
813     _coords->getTinySerializationStrInformation(littleStrings2);
814   littleStrings.insert(littleStrings.end(),littleStrings2.begin(),littleStrings2.end());
815   //
816   tinyInfo.push_back(it);
817   tinyInfo.push_back(order);
818   tinyInfo.push_back((int)_structure.size());
819   for(std::vector<int>::const_iterator itt=_structure.begin();itt!=_structure.end();itt++)
820     tinyInfo.push_back(*itt);
821   std::vector<int> tinyInfo2;
822   if((const DataArrayDouble *)_coords)
823     _coords->getTinySerializationIntInformation(tinyInfo2);
824   tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
825   //
826   tinyInfoD.push_back(time);
827 }
828
829 void MEDCouplingCurveLinearMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
830 {
831   a1->alloc(tinyInfo[2],1);
832   std::vector<int> tinyInfo2(tinyInfo.begin()+3+tinyInfo[2],tinyInfo.end());
833   a2->resizeForUnserialization(tinyInfo2);
834 }
835
836 void MEDCouplingCurveLinearMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
837 {
838   a1=DataArrayInt::New();
839   a1->alloc((int)_structure.size(),1);
840   int *ptr=a1->getPointer();
841   for(std::vector<int>::const_iterator it=_structure.begin();it!=_structure.end();it++,ptr++)
842     *ptr=(*it);
843   int sz=0;
844   if((const DataArrayDouble *)_coords)
845     if(_coords->isAllocated())
846       sz=_coords->getNbOfElems();
847   a2=DataArrayDouble::New();
848   a2->alloc(sz,1);
849   if(sz!=0 && (const DataArrayDouble *)_coords)
850     std::copy(_coords->begin(),_coords->end(),a2->getPointer());
851 }
852
853 void MEDCouplingCurveLinearMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
854                                                  const std::vector<std::string>& littleStrings)
855 {
856   setName(littleStrings[0]);
857   setDescription(littleStrings[1]);
858   setTimeUnit(littleStrings[2]);
859   setTime(tinyInfoD[0],tinyInfo[0],tinyInfo[1]);
860   int sz=tinyInfo[2];
861   _structure.resize(sz);
862   for(int i=0;i<sz;i++)
863     _structure[i]=tinyInfo[3+i];
864   if((int)tinyInfo.size()>sz+3)
865     {
866       _coords=DataArrayDouble::New();
867       std::vector<int> tinyInfo2(tinyInfo.begin()+3+sz,tinyInfo.end());
868       _coords->resizeForUnserialization(tinyInfo2);
869       std::copy(a2->begin(),a2->end(),_coords->getPointer());
870       std::vector<std::string> littleStrings2(littleStrings.begin()+3,littleStrings.end());
871       _coords->finishUnserialization(tinyInfo2,littleStrings2);
872     }
873 }
874
875 void MEDCouplingCurveLinearMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const
876 {
877   std::ostringstream extent;
878   int meshDim=(int)_structure.size();
879   if(meshDim<=0 || meshDim>3)
880     throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::writeVTKLL : meshDim invalid ! must be in [1,2,3] !");
881   for(int i=0;i<3;i++)
882     { int val=i<meshDim?_structure[i]-1:0; extent << "0 " <<  val << " "; }
883   ofs << "  <" << getVTKDataSetType() << " WholeExtent=\"" << extent.str() << "\">\n";
884   ofs << "    <Piece Extent=\"" << extent.str() << "\">\n";
885   ofs << "      <PointData>\n" << pointData << std::endl;
886   ofs << "      </PointData>\n";
887   ofs << "      <CellData>\n" << cellData << std::endl;
888   ofs << "      </CellData>\n";
889   ofs << "      <Points>\n";
890   if(getSpaceDimension()==3)
891     _coords->writeVTK(ofs,8,"Points",byteData);
892   else
893     {
894       MCAuto<DataArrayDouble> coo=_coords->changeNbOfComponents(3,0.);
895       coo->writeVTK(ofs,8,"Points",byteData);
896     }
897   ofs << "      </Points>\n";
898   ofs << "    </Piece>\n";
899   ofs << "  </" << getVTKDataSetType() << ">\n";
900 }
901
902 void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const
903 {
904   stream << "MEDCouplingCurveLinearMesh C++ instance at " << this << ". Name : \"" << getName() << "\".";
905   stream << " Nodal structure : [";
906   for(std::size_t i=0;i<_structure.size();i++)
907     {
908       char tmp='X'+i;
909       stream << " " << tmp << "=" << _structure[i];
910       if(i!=_structure.size()-1)
911         stream << ", ";
912     }
913   stream << " ].";
914   const DataArrayDouble *coo(_coords);
915   if(!coo)
916     { stream << std::endl << "No coordinates set !"; return ; }
917   if(!coo->isAllocated())
918     { stream << std::endl << "Coordinates set but not allocated !"; return ; }
919   int nbOfCompo(coo->getNumberOfComponents());
920   int nbOfCompoExp(-1);
921   try
922     {
923       nbOfCompoExp=getSpaceDimension();
924     }
925   catch(INTERP_KERNEL::Exception& e)
926     {
927     }
928   if(nbOfCompo!=nbOfCompoExp)
929     { stream << std::endl << "Coordinates set and allocated but mismatch number of components !"; return ; }
930   stream << std::endl << "Coordinates ( number of tuples = " << coo->getNumberOfTuples() << " ) : ";
931   coo->reprQuickOverviewData(stream,200);
932 }
933
934 std::string MEDCouplingCurveLinearMesh::getVTKFileExtension() const
935 {
936   return std::string("vts");
937 }
938
939 std::string MEDCouplingCurveLinearMesh::getVTKDataSetType() const
940 {
941   return std::string("StructuredGrid");
942 }