Salome HOME
New constructor for ExtrudedMeshes taking 3D MEDCouplingCMesh instance
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingMappedExtrudedMesh.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 "MEDCouplingMappedExtrudedMesh.hxx"
22 #include "MEDCouplingUMesh.hxx"
23 #include "MEDCouplingCMesh.hxx"
24 #include "MEDCouplingMemArray.hxx"
25 #include "MEDCouplingFieldDouble.hxx"
26 #include "MCAuto.hxx"
27 #include "CellModel.hxx"
28
29 #include "InterpolationUtils.hxx"
30
31 #include <limits>
32 #include <algorithm>
33 #include <functional>
34 #include <iterator>
35 #include <sstream>
36 #include <cmath>
37 #include <list>
38 #include <set>
39
40 using namespace MEDCoupling;
41
42 /*!
43  * Build an extruded mesh instance from 3D and 2D unstructured mesh lying on the \b same \b coords.
44  * @param mesh3D 3D unstructured mesh.
45  * @param mesh2D 2D unstructured mesh lying on the same coordinates than mesh3D. \b Warning mesh2D is \b not \b const
46  * because the mesh is aggregated and potentially modified by rotate or translate method.
47  * @param cell2DId Id of cell in mesh2D mesh where the computation of 1D mesh will be done.
48  */
49 MEDCouplingMappedExtrudedMesh *MEDCouplingMappedExtrudedMesh::New(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, int cell2DId)
50 {
51   return new MEDCouplingMappedExtrudedMesh(mesh3D,mesh2D,cell2DId);
52 }
53
54 MEDCouplingMappedExtrudedMesh *MEDCouplingMappedExtrudedMesh::New(const MEDCouplingCMesh *mesh3D)
55 {
56   return new MEDCouplingMappedExtrudedMesh(mesh3D);
57 }
58
59 /*!
60  * This constructor is here only for unserialisation process.
61  * This constructor is normally completely useless for end user.
62  */
63 MEDCouplingMappedExtrudedMesh *MEDCouplingMappedExtrudedMesh::New()
64 {
65   return new MEDCouplingMappedExtrudedMesh;
66 }
67
68 MEDCouplingMeshType MEDCouplingMappedExtrudedMesh::getType() const
69 {
70   return EXTRUDED;
71 }
72
73 std::size_t MEDCouplingMappedExtrudedMesh::getHeapMemorySizeWithoutChildren() const
74 {
75   return MEDCouplingMesh::getHeapMemorySizeWithoutChildren();
76 }
77
78 std::vector<const BigMemoryObject *> MEDCouplingMappedExtrudedMesh::getDirectChildrenWithNull() const
79 {
80   std::vector<const BigMemoryObject *> ret;
81   ret.push_back(_mesh2D);
82   ret.push_back(_mesh1D);
83   ret.push_back(_mesh3D_ids);
84   return ret;
85 }
86
87 /*!
88  * This method copyies all tiny strings from other (name and components name).
89  * @throw if other and this have not same mesh type.
90  */
91 void MEDCouplingMappedExtrudedMesh::copyTinyStringsFrom(const MEDCouplingMesh *other)
92 {
93   const MEDCouplingMappedExtrudedMesh *otherC=dynamic_cast<const MEDCouplingMappedExtrudedMesh *>(other);
94   if(!otherC)
95     throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::copyTinyStringsFrom : meshes have not same type !");
96   MEDCouplingMesh::copyTinyStringsFrom(other);
97   _mesh2D->copyTinyStringsFrom(otherC->_mesh2D);
98   _mesh1D->copyTinyStringsFrom(otherC->_mesh1D);
99 }
100
101 MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, int cell2DId)
102 try:_mesh2D(const_cast<MEDCouplingUMesh *>(mesh2D)),_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(0),_cell_2D_id(cell2DId)
103 {
104   if(_mesh2D.isNotNull())
105     _mesh2D->incrRef();
106   computeExtrusion(mesh3D);
107   setName(mesh3D->getName()); setDescription(mesh3D->getDescription());
108 }
109 catch(INTERP_KERNEL::Exception& e)
110 {
111     throw e;
112 }
113
114 MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingCMesh *mesh3D):_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(0),_cell_2D_id(0)
115 {
116   if(!mesh3D)
117     throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh contrct : null input pointer !");
118   if(mesh3D->getMeshDimension()!=3)
119     throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh contrct : input cart mesh must have dimension equal to 3 !");
120   MCAuto<MEDCouplingUMesh> umesh3D(mesh3D->buildUnstructured());
121   MCAuto<MEDCouplingCMesh> cmesh2D(MEDCouplingCMesh::New()); cmesh2D->setName(mesh3D->getName());
122   cmesh2D->setCoords(mesh3D->getCoordsAt(0),mesh3D->getCoordsAt(1));
123   _mesh2D=cmesh2D->buildUnstructured();
124   _mesh2D->setCoords(umesh3D->getCoords());
125   computeExtrusion(umesh3D);
126   setName(mesh3D->getName()); setDescription(mesh3D->getDescription());
127 }
128
129 MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh():_mesh2D(0),_mesh1D(0),_mesh3D_ids(0),_cell_2D_id(-1)
130 {
131 }
132
133 MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingMappedExtrudedMesh& other, bool deepCopy):MEDCouplingMesh(other),_cell_2D_id(other._cell_2D_id)
134 {
135   if(deepCopy)
136     {
137       _mesh2D=other._mesh2D->clone(true);
138       _mesh1D=other._mesh1D->clone(true);
139       _mesh3D_ids=other._mesh3D_ids->deepCopy();
140     }
141   else
142     {
143       _mesh2D=other._mesh2D;
144       _mesh1D=other._mesh1D;
145       _mesh3D_ids=other._mesh3D_ids;
146     }
147 }
148
149 int MEDCouplingMappedExtrudedMesh::getNumberOfCells() const
150 {
151   return _mesh2D->getNumberOfCells()*_mesh1D->getNumberOfCells();
152 }
153
154 int MEDCouplingMappedExtrudedMesh::getNumberOfNodes() const
155 {
156   return _mesh2D->getNumberOfNodes();
157 }
158
159 int MEDCouplingMappedExtrudedMesh::getSpaceDimension() const
160 {
161   return 3;
162 }
163
164 int MEDCouplingMappedExtrudedMesh::getMeshDimension() const
165 {
166   return 3;
167 }
168
169 MEDCouplingMappedExtrudedMesh *MEDCouplingMappedExtrudedMesh::deepCopy() const
170 {
171   return clone(true);
172 }
173
174 MEDCouplingMappedExtrudedMesh *MEDCouplingMappedExtrudedMesh::clone(bool recDeepCpy) const
175 {
176   return new MEDCouplingMappedExtrudedMesh(*this,recDeepCpy);
177 }
178
179 bool MEDCouplingMappedExtrudedMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const
180 {
181   if(!other)
182     throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::isEqualIfNotWhy : input other pointer is null !");
183   const MEDCouplingMappedExtrudedMesh *otherC=dynamic_cast<const MEDCouplingMappedExtrudedMesh *>(other);
184   std::ostringstream oss;
185   if(!otherC)
186     {
187       reason="mesh given in input is not castable in MEDCouplingMappedExtrudedMesh !";
188       return false;
189     }
190   if(!MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason))
191     return false;
192   if(!_mesh2D->isEqualIfNotWhy(otherC->_mesh2D,prec,reason))
193     {
194       reason.insert(0,"Mesh2D unstructured meshes differ : ");
195       return false;
196     }
197   if(!_mesh1D->isEqualIfNotWhy(otherC->_mesh1D,prec,reason))
198     {
199       reason.insert(0,"Mesh1D unstructured meshes differ : ");
200       return false;
201     }
202   if(!_mesh3D_ids->isEqualIfNotWhy(*otherC->_mesh3D_ids,reason))
203     {
204       reason.insert(0,"Mesh3D ids DataArrayInt instances differ : ");
205       return false;
206     }
207   if(_cell_2D_id!=otherC->_cell_2D_id)
208     {
209       oss << "Cell 2D id of the two extruded mesh differ : this = " << _cell_2D_id << " other = " <<  otherC->_cell_2D_id;
210       reason=oss.str();
211       return false;
212     }
213   return true;
214 }
215
216 bool MEDCouplingMappedExtrudedMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const
217 {
218   const MEDCouplingMappedExtrudedMesh *otherC=dynamic_cast<const MEDCouplingMappedExtrudedMesh *>(other);
219   if(!otherC)
220     return false;
221   if(!_mesh2D->isEqualWithoutConsideringStr(otherC->_mesh2D,prec))
222     return false;
223   if(!_mesh1D->isEqualWithoutConsideringStr(otherC->_mesh1D,prec))
224     return false;
225   if(!_mesh3D_ids->isEqualWithoutConsideringStr(*otherC->_mesh3D_ids))
226     return false;
227   if(_cell_2D_id!=otherC->_cell_2D_id)
228     return false;
229   return true;
230 }
231
232 void MEDCouplingMappedExtrudedMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
233                                                    DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const
234 {
235   throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::checkDeepEquivalWith : not implemented yet !");
236 }
237
238 void MEDCouplingMappedExtrudedMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
239                                                               DataArrayInt *&cellCor) const
240 {
241   throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::checkDeepEquivalOnSameNodesWith : not implemented yet !");
242 }
243
244 INTERP_KERNEL::NormalizedCellType MEDCouplingMappedExtrudedMesh::getTypeOfCell(int cellId) const
245 {
246   const int *ids(_mesh3D_ids->begin());
247   int nbOf3DCells(_mesh3D_ids->getNumberOfTuples());
248   const int *where(std::find(ids,ids+nbOf3DCells,cellId));
249   if(where==ids+nbOf3DCells)
250     throw INTERP_KERNEL::Exception("Invalid cellId specified >= getNumberOfCells() !");
251   int nbOfCells2D(_mesh2D->getNumberOfCells());
252   int locId(((int)std::distance(ids,where))%nbOfCells2D);
253   INTERP_KERNEL::NormalizedCellType tmp(_mesh2D->getTypeOfCell(locId));
254   return INTERP_KERNEL::CellModel::GetCellModel(tmp).getExtrudedType();
255 }
256
257 std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingMappedExtrudedMesh::getAllGeoTypes() const
258 {
259   std::set<INTERP_KERNEL::NormalizedCellType> ret2D(_mesh2D->getAllGeoTypes());
260   std::set<INTERP_KERNEL::NormalizedCellType> ret;
261   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=ret2D.begin();it!=ret2D.end();it++)
262     ret.insert(INTERP_KERNEL::CellModel::GetCellModel(*it).getExtrudedType());
263   return ret;
264 }
265
266 DataArrayInt *MEDCouplingMappedExtrudedMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
267 {
268   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(type));
269   INTERP_KERNEL::NormalizedCellType revExtTyp(cm.getReverseExtrudedType());
270   MCAuto<DataArrayInt> ret(DataArrayInt::New());
271   if(revExtTyp==INTERP_KERNEL::NORM_ERROR)
272     {
273       ret->alloc(0,1);
274       return ret.retn();
275     }
276   MCAuto<DataArrayInt> tmp(_mesh2D->giveCellsWithType(revExtTyp));
277   int nbOfLevs(_mesh1D->getNumberOfCells());
278   int nbOfCells2D(_mesh2D->getNumberOfCells());
279   int nbOfTuples(tmp->getNumberOfTuples());
280   ret->alloc(nbOfLevs*nbOfTuples,1);
281   int *pt(ret->getPointer());
282   for(int i=0;i<nbOfLevs;i++,pt+=nbOfTuples)
283     std::transform(tmp->begin(),tmp->end(),pt,std::bind2nd(std::plus<int>(),i*nbOfCells2D));
284   MCAuto<DataArrayInt> ret2(ret->renumberR(_mesh3D_ids->begin()));
285   ret2->sort();
286   return ret2.retn();
287 }
288
289 DataArrayInt *MEDCouplingMappedExtrudedMesh::computeNbOfNodesPerCell() const
290 {
291   MCAuto<DataArrayInt> ret2D(_mesh2D->computeNbOfNodesPerCell());
292   int nbOfLevs(_mesh1D->getNumberOfCells());
293   int nbOfCells2D(_mesh2D->getNumberOfCells());
294   MCAuto<DataArrayInt> ret3D(DataArrayInt::New()); ret3D->alloc(nbOfLevs*nbOfCells2D,1);
295   int *pt(ret3D->getPointer());
296   for(int i=0;i<nbOfLevs;i++,pt+=nbOfCells2D)
297     std::copy(ret2D->begin(),ret2D->end(),pt);
298   ret3D->applyLin(2,0,0);
299   return ret3D->renumberR(_mesh3D_ids->begin());
300 }
301
302 DataArrayInt *MEDCouplingMappedExtrudedMesh::computeNbOfFacesPerCell() const
303 {
304   MCAuto<DataArrayInt> ret2D(_mesh2D->computeNbOfNodesPerCell());
305   int nbOfLevs(_mesh1D->getNumberOfCells());
306   int nbOfCells2D(_mesh2D->getNumberOfCells());
307   MCAuto<DataArrayInt> ret3D(DataArrayInt::New()); ret3D->alloc(nbOfLevs*nbOfCells2D,1);
308   int *pt(ret3D->getPointer());
309   for(int i=0;i<nbOfLevs;i++,pt+=nbOfCells2D)
310     std::copy(ret2D->begin(),ret2D->end(),pt);
311   ret3D->applyLin(2,2,0);
312   return ret3D->renumberR(_mesh3D_ids->begin());
313 }
314
315 DataArrayInt *MEDCouplingMappedExtrudedMesh::computeEffectiveNbOfNodesPerCell() const
316 {
317   return computeNbOfNodesPerCell();
318 }
319
320 int MEDCouplingMappedExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
321 {
322   int ret(0);
323   int nbOfCells2D(_mesh2D->getNumberOfCells());
324   for(int i=0;i<nbOfCells2D;i++)
325     {
326       INTERP_KERNEL::NormalizedCellType t(_mesh2D->getTypeOfCell(i));
327       if(INTERP_KERNEL::CellModel::GetCellModel(t).getExtrudedType()==type)
328         ret++;
329     }
330   return ret*_mesh1D->getNumberOfCells();
331 }
332
333 void MEDCouplingMappedExtrudedMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
334 {
335   int nbOfCells2D(_mesh2D->getNumberOfCells());
336   int nbOfNodes2D(_mesh2D->getNumberOfNodes());
337   int locId(cellId%nbOfCells2D);
338   int lev(cellId/nbOfCells2D);
339   std::vector<int> tmp,tmp2;
340   _mesh2D->getNodeIdsOfCell(locId,tmp);
341   tmp2=tmp;
342   std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::plus<int>(),nbOfNodes2D*lev));
343   std::transform(tmp2.begin(),tmp2.end(),tmp2.begin(),std::bind2nd(std::plus<int>(),nbOfNodes2D*(lev+1)));
344   conn.insert(conn.end(),tmp.begin(),tmp.end());
345   conn.insert(conn.end(),tmp2.begin(),tmp2.end());
346 }
347
348 void MEDCouplingMappedExtrudedMesh::getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const
349 {
350   int nbOfNodes2D(_mesh2D->getNumberOfNodes());
351   int locId(nodeId%nbOfNodes2D);
352   int lev(nodeId/nbOfNodes2D);
353   std::vector<double> tmp,tmp2;
354   _mesh2D->getCoordinatesOfNode(locId,tmp);
355   tmp2=tmp;
356   int spaceDim(_mesh1D->getSpaceDimension());
357   const double *z(_mesh1D->getCoords()->begin());
358   std::transform(tmp.begin(),tmp.end(),z+lev*spaceDim,tmp.begin(),std::plus<double>());
359   std::transform(tmp2.begin(),tmp2.end(),z+(lev+1)*spaceDim,tmp2.begin(),std::plus<double>());
360   coo.insert(coo.end(),tmp.begin(),tmp.end());
361   coo.insert(coo.end(),tmp2.begin(),tmp2.end());
362 }
363
364 std::string MEDCouplingMappedExtrudedMesh::simpleRepr() const
365 {
366   std::ostringstream ret;
367   ret << "3D Extruded mesh from a 2D Surf Mesh with name : \"" << getName() << "\"\n";
368   ret << "Description of mesh : \"" << getDescription() << "\"\n";
369   int tmpp1,tmpp2;
370   double tt=getTime(tmpp1,tmpp2);
371   ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
372   ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
373   ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n";
374   ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n";
375   ret << "1D Mesh info : _____________________\n\n\n";
376   ret << _mesh1D->simpleRepr();
377   ret << "\n\n\n2D Mesh info : _____________________\n\n\n" << _mesh2D->simpleRepr() << "\n\n\n";
378   return ret.str();
379 }
380
381 std::string MEDCouplingMappedExtrudedMesh::advancedRepr() const
382 {
383   std::ostringstream ret;
384   ret << "3D Extruded mesh from a 2D Surf Mesh with name : \"" << getName() << "\"\n";
385   ret << "Description of mesh : \"" << getDescription() << "\"\n";
386   int tmpp1,tmpp2;
387   double tt=getTime(tmpp1,tmpp2);
388   ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n";
389   ret << "Iteration : " << tmpp1  << " Order : " << tmpp2 << "\n";
390   ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n";
391   ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n";
392   ret << "1D Mesh info : _____________________\n\n\n";
393   ret << _mesh1D->advancedRepr();
394   ret << "\n\n\n2D Mesh info : _____________________\n\n\n" << _mesh2D->advancedRepr() << "\n\n\n";
395   ret << "3D cell ids per level :\n";
396   return ret.str();
397 }
398
399 void MEDCouplingMappedExtrudedMesh::checkConsistencyLight() const
400 {
401 }
402
403 void MEDCouplingMappedExtrudedMesh::checkConsistency(double eps) const
404 {
405   checkConsistencyLight();
406 }
407
408 void MEDCouplingMappedExtrudedMesh::getBoundingBox(double *bbox) const
409 {
410   double bbox2D[6];
411   _mesh2D->getBoundingBox(bbox2D);
412   const double *nodes1D(_mesh1D->getCoords()->begin());
413   int nbOfNodes1D(_mesh1D->getNumberOfNodes());
414   double bbox1DMin[3],bbox1DMax[3],tmp[3];
415   std::fill(bbox1DMin,bbox1DMin+3,std::numeric_limits<double>::max());
416   std::fill(bbox1DMax,bbox1DMax+3,-(std::numeric_limits<double>::max()));
417   for(int i=0;i<nbOfNodes1D;i++)
418     {
419       std::transform(nodes1D+3*i,nodes1D+3*(i+1),bbox1DMin,bbox1DMin,static_cast<const double& (*)(const double&, const double&)>(std::min<double>));
420       std::transform(nodes1D+3*i,nodes1D+3*(i+1),bbox1DMax,bbox1DMax,static_cast<const double& (*)(const double&, const double&)>(std::max<double>));
421     }
422   std::transform(bbox1DMax,bbox1DMax+3,bbox1DMin,tmp,std::minus<double>());
423   int id=(int)std::distance(tmp,std::max_element(tmp,tmp+3));
424   bbox[0]=bbox1DMin[0]; bbox[1]=bbox1DMax[0];
425   bbox[2]=bbox1DMin[1]; bbox[3]=bbox1DMax[1];
426   bbox[4]=bbox1DMin[2]; bbox[5]=bbox1DMax[2];
427   bbox[2*id+1]+=tmp[id];
428 }
429
430 void MEDCouplingMappedExtrudedMesh::updateTime() const
431 {
432   if(_mesh2D.isNotNull())
433     updateTimeWith(*_mesh2D);
434   if(_mesh1D.isNotNull())
435     updateTimeWith(*_mesh1D);
436 }
437
438 void MEDCouplingMappedExtrudedMesh::renumberCells(const int *old2NewBg, bool check)
439 {
440   throw INTERP_KERNEL::Exception("Functionnality of renumbering cells unavailable for ExtrudedMesh");
441 }
442
443 MEDCouplingUMesh *MEDCouplingMappedExtrudedMesh::build3DUnstructuredMesh() const
444 {
445   MCAuto<MEDCouplingUMesh> mesh2DZC(_mesh2D->deepCopyConnectivityOnly());
446   mesh2DZC->zipCoords();
447   MCAuto<MEDCouplingUMesh> ret(mesh2DZC->buildExtrudedMesh(_mesh1D,0));
448   const int *renum(_mesh3D_ids->begin());
449   ret->renumberCells(renum,false);
450   ret->setName(getName());
451   return ret.retn();
452 }
453
454 MEDCouplingUMesh *MEDCouplingMappedExtrudedMesh::buildUnstructured() const
455 {
456   return build3DUnstructuredMesh();
457 }
458
459 MEDCouplingFieldDouble *MEDCouplingMappedExtrudedMesh::getMeasureField(bool) const
460 {
461   std::string name="MeasureOfMesh_";
462   name+=getName();
463   MCAuto<MEDCouplingFieldDouble> ret2D(_mesh2D->getMeasureField(true)),ret1D(_mesh1D->getMeasureField(true));
464   const double *ret2DPtr(ret2D->getArray()->begin());
465   const double *ret1DPtr(ret1D->getArray()->begin());
466   int nbOf2DCells(_mesh2D->getNumberOfCells()),nbOf1DCells(_mesh1D->getNumberOfCells()),nbOf3DCells(nbOf2DCells*nbOf1DCells);
467   const int *renum(_mesh3D_ids->begin());
468   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME));
469   ret->setMesh(this);
470   ret->synchronizeTimeWithMesh();
471   MCAuto<DataArrayDouble> da(DataArrayDouble::New());
472   da->alloc(nbOf3DCells,1);
473   double *retPtr(da->getPointer());
474   for(int i=0;i<nbOf1DCells;i++)
475     for(int j=0;j<nbOf2DCells;j++)
476       retPtr[renum[i*nbOf2DCells+j]]=ret2DPtr[j]*ret1DPtr[i];
477   ret->setArray(da);
478   ret->setName(name);
479   return ret.retn();
480 }
481
482 MEDCouplingFieldDouble *MEDCouplingMappedExtrudedMesh::getMeasureFieldOnNode(bool isAbs) const
483 {
484   //not implemented yet
485   return 0;
486 }
487
488 MEDCouplingFieldDouble *MEDCouplingMappedExtrudedMesh::buildOrthogonalField() const
489 {
490   throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::buildOrthogonalField : This method has no sense for MEDCouplingMappedExtrudedMesh that is 3D !");
491 }
492
493 int MEDCouplingMappedExtrudedMesh::getCellContainingPoint(const double *pos, double eps) const
494 {
495   throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::getCellContainingPoint : not implemented yet !");
496 }
497
498 MEDCouplingMappedExtrudedMesh::~MEDCouplingMappedExtrudedMesh()
499 {
500 }
501
502 void MEDCouplingMappedExtrudedMesh::computeExtrusion(const MEDCouplingUMesh *mesh3D)
503 {
504   const char errMsg1[]="2D mesh is empty unable to compute extrusion !";
505   const char errMsg2[]="Coords between 2D and 3D meshes are not the same ! Try MEDCouplingPointSet::tryToShareSameCoords method";
506   const char errMsg3[]="No chance to find extrusion pattern in mesh3D,mesh2D couple because nbCells3D%nbCells2D!=0 !";
507   if(_mesh2D.isNull() || mesh3D==0)
508     throw INTERP_KERNEL::Exception(errMsg1);
509   if(_mesh2D->getCoords()!=mesh3D->getCoords())
510     throw INTERP_KERNEL::Exception(errMsg2);
511   if(mesh3D->getNumberOfCells()%_mesh2D->getNumberOfCells()!=0)
512     throw INTERP_KERNEL::Exception(errMsg3);
513   if(_mesh3D_ids.isNull())
514     _mesh3D_ids=DataArrayInt::New();
515   if(_mesh1D.isNull())
516     _mesh1D=MEDCouplingUMesh::New();
517   computeExtrusionAlg(mesh3D);
518 }
519
520 void MEDCouplingMappedExtrudedMesh::build1DExtrusion(int idIn3DDesc, int newId, int nbOf1DLev, MEDCouplingUMesh *subMesh,
521                                                const int *desc3D, const int *descIndx3D,
522                                                const int *revDesc3D, const int *revDescIndx3D,
523                                                bool computeMesh1D)
524 {
525   int nbOf2DCells(_mesh2D->getNumberOfCells());
526   int start(revDescIndx3D[idIn3DDesc]);
527   int end(revDescIndx3D[idIn3DDesc+1]);
528   if(end-start!=1)
529     {
530       std::ostringstream ost; ost << "Invalid bases 2D mesh specified : 2D cell # " <<  idIn3DDesc;
531       ost << " shared by more than 1 3D cell !!!";
532       throw INTERP_KERNEL::Exception(ost.str().c_str());
533     }
534   int current3DCell(revDesc3D[start]);
535   int current2DCell(idIn3DDesc);
536   int *mesh3DIDs(_mesh3D_ids->getPointer());
537   mesh3DIDs[newId]=current3DCell;
538   const int *conn2D(subMesh->getNodalConnectivity()->begin());
539   const int *conn2DIndx(subMesh->getNodalConnectivityIndex()->begin());
540   for(int i=1;i<nbOf1DLev;i++)
541     {
542       std::vector<int> conn(conn2D+conn2DIndx[current2DCell]+1,conn2D+conn2DIndx[current2DCell+1]);
543       std::sort(conn.begin(),conn.end());
544       if(computeMesh1D)
545         computeBaryCenterOfFace(conn,i-1);
546       current2DCell=findOppositeFaceOf(current2DCell,current3DCell,conn,
547           desc3D,descIndx3D,conn2D,conn2DIndx);
548       start=revDescIndx3D[current2DCell];
549       end=revDescIndx3D[current2DCell+1];
550       if(end-start!=2)
551         {
552           std::ostringstream ost; ost << "Expecting to have 2 3D cells attached to 2D cell " << current2DCell << "!";
553           ost << " : Impossible or call tryToShareSameCoords method !";
554           throw INTERP_KERNEL::Exception(ost.str().c_str());
555         }
556       if(revDesc3D[start]!=current3DCell)
557         current3DCell=revDesc3D[start];
558       else
559         current3DCell=revDesc3D[start+1];
560       mesh3DIDs[i*nbOf2DCells+newId]=current3DCell;
561     }
562   if(computeMesh1D)
563     {
564       std::vector<int> conn(conn2D+conn2DIndx[current2DCell]+1,conn2D+conn2DIndx[current2DCell+1]);
565       std::sort(conn.begin(),conn.end());
566       computeBaryCenterOfFace(conn,nbOf1DLev-1);
567       current2DCell=findOppositeFaceOf(current2DCell,current3DCell,conn,
568           desc3D,descIndx3D,conn2D,conn2DIndx);
569       conn.clear();
570       conn.insert(conn.end(),conn2D+conn2DIndx[current2DCell]+1,conn2D+conn2DIndx[current2DCell+1]);
571       std::sort(conn.begin(),conn.end());
572       computeBaryCenterOfFace(conn,nbOf1DLev);
573     }
574 }
575
576 int MEDCouplingMappedExtrudedMesh::findOppositeFaceOf(int current2DCell, int current3DCell, const std::vector<int>& connSorted,
577                                                 const int *desc3D, const int *descIndx3D,
578                                                 const int *conn2D, const int *conn2DIndx)
579 {
580   int start(descIndx3D[current3DCell]);
581   int end(descIndx3D[current3DCell+1]);
582   bool found=false;
583   for(const int *candidate2D=desc3D+start;candidate2D!=desc3D+end && !found;candidate2D++)
584     {
585       if(*candidate2D!=current2DCell)
586         {
587           std::vector<int> conn2(conn2D+conn2DIndx[*candidate2D]+1,conn2D+conn2DIndx[*candidate2D+1]);
588           std::sort(conn2.begin(),conn2.end());
589           std::list<int> intersect;
590           std::set_intersection(connSorted.begin(),connSorted.end(),conn2.begin(),conn2.end(),
591                                 std::insert_iterator< std::list<int> >(intersect,intersect.begin()));
592           if(intersect.empty())
593             return *candidate2D;
594         }
595     }
596   std::ostringstream ost; ost << "Impossible to find an opposite 2D face of face # " <<  current2DCell;
597   ost << " in 3D cell # " << current3DCell << " : Impossible or call tryToShareSameCoords method !";
598   throw INTERP_KERNEL::Exception(ost.str().c_str());
599 }
600
601 void MEDCouplingMappedExtrudedMesh::computeBaryCenterOfFace(const std::vector<int>& nodalConnec, int lev1DId)
602 {
603   double *zoneToUpdate(_mesh1D->getCoords()->getPointer()+lev1DId*3);
604   std::fill(zoneToUpdate,zoneToUpdate+3,0.);
605   const double *coords(_mesh2D->getCoords()->begin());
606   for(std::vector<int>::const_iterator iter=nodalConnec.begin();iter!=nodalConnec.end();iter++)
607     std::transform(zoneToUpdate,zoneToUpdate+3,coords+3*(*iter),zoneToUpdate,std::plus<double>());
608   std::transform(zoneToUpdate,zoneToUpdate+3,zoneToUpdate,std::bind2nd(std::multiplies<double>(),(double)(1./(int)nodalConnec.size())));
609 }
610
611 int MEDCouplingMappedExtrudedMesh::FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr)
612 {
613   std::vector<int>::const_iterator iter=nodalConnec.begin();
614   std::set<int> s1(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]);
615   iter++;
616   for(;iter!=nodalConnec.end();iter++)
617     {
618       std::set<int> s2(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]);
619       std::set<int> s3;
620       std::set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),std::insert_iterator< std::set<int> >(s3,s3.end()));
621       s1=s3;
622     }
623   if(s1.size()==1)
624     return *(s1.begin());
625   std::ostringstream ostr;
626   ostr << "Cell with nodal connec : ";
627   std::copy(nodalConnec.begin(),nodalConnec.end(),std::ostream_iterator<int>(ostr," "));
628   ostr << " is not part of mesh";
629   throw INTERP_KERNEL::Exception(ostr.str().c_str());
630 }
631
632 /*!
633  * This method is callable on 1Dmeshes (meshDim==1 && spaceDim==3) returned by MEDCouplingMappedExtrudedMesh::getMesh1D typically.
634  * These 1Dmeshes (meshDim==1 && spaceDim==3) have a special semantic because these meshes do not specify a static location but a translation along a path.
635  * This method checks that 'm1' and 'm2' are compatible, if not an exception is thrown. In case these meshes ('m1' and 'm2') are compatible 2 corresponding meshes
636  * are created ('m1r' and 'm2r') that can be used for interpolation.
637  * @param m1 input mesh with meshDim==1 and spaceDim==3
638  * @param m2 input mesh with meshDim==1 and spaceDim==3
639  * @param eps tolerance acceptable to determine compatibility
640  * @param m1r output mesh with ref count equal to 1 with meshDim==1 and spaceDim==1
641  * @param m2r output mesh with ref count equal to 1 with meshDim==1 and spaceDim==1
642  * @param v is the output normalized vector of the common direction of 'm1' and 'm2'  
643  * @throw in case that m1 and m2 are not compatible each other.
644  */
645 void MEDCouplingMappedExtrudedMesh::Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
646                                               MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v)
647 {
648   if(m1->getSpaceDimension()!=3 || m1->getSpaceDimension()!=3)
649     throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for Projec1D !");
650   m1r=m1->clone(true);
651   m2r=m2->clone(true);
652   m1r->changeSpaceDimension(1);
653   m2r->changeSpaceDimension(1);
654   std::vector<int> c;
655   std::vector<double> ref,ref2;
656   m1->getNodeIdsOfCell(0,c);
657   m1->getCoordinatesOfNode(c[0],ref);
658   m1->getCoordinatesOfNode(c[1],ref2);
659   std::transform(ref2.begin(),ref2.end(),ref.begin(),v,std::minus<double>());
660   double n=INTERP_KERNEL::norm<3>(v);
661   std::transform(v,v+3,v,std::bind2nd(std::multiplies<double>(),1/n));
662   m1->project1D(&ref[0],v,eps,m1r->getCoords()->getPointer());
663   m2->project1D(&ref[0],v,eps,m2r->getCoords()->getPointer());
664 }
665
666 void MEDCouplingMappedExtrudedMesh::rotate(const double *center, const double *vector, double angle)
667 {
668   _mesh2D->rotate(center,vector,angle);
669   _mesh1D->rotate(center,vector,angle);
670 }
671
672 void MEDCouplingMappedExtrudedMesh::translate(const double *vector)
673 {
674   _mesh2D->translate(vector);
675   _mesh1D->translate(vector);
676 }
677
678 void MEDCouplingMappedExtrudedMesh::scale(const double *point, double factor)
679 {
680   _mesh2D->scale(point,factor);
681   _mesh1D->scale(point,factor);
682 }
683
684 std::vector<int> MEDCouplingMappedExtrudedMesh::getDistributionOfTypes() const
685 {
686   throw INTERP_KERNEL::Exception("Not implemented yet !");
687 }
688
689 DataArrayInt *MEDCouplingMappedExtrudedMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const
690 {
691   throw INTERP_KERNEL::Exception("Not implemented yet !");
692 }
693
694 void MEDCouplingMappedExtrudedMesh::splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const
695 {
696   throw INTERP_KERNEL::Exception("Not implemented yet !");
697 }
698
699 MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::buildPart(const int *start, const int *end) const
700 {
701   // not implemented yet !
702   return 0;
703 }
704
705 MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const
706 {
707   // not implemented yet !
708   return 0;
709 }
710
711 DataArrayInt *MEDCouplingMappedExtrudedMesh::simplexize(int policy)
712 {
713   throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::simplexize : unavailable for such a type of mesh : Extruded !");
714 }
715
716 MEDCouplingMesh *MEDCouplingMappedExtrudedMesh::mergeMyselfWith(const MEDCouplingMesh *other) const
717 {
718   // not implemented yet !
719   return 0;
720 }
721
722 DataArrayDouble *MEDCouplingMappedExtrudedMesh::getCoordinatesAndOwner() const
723 {
724   const DataArrayDouble *arr2D(_mesh2D->getCoords());
725   const DataArrayDouble *arr1D(_mesh1D->getCoords());
726   MCAuto<DataArrayDouble> ret(DataArrayDouble::New());
727   ret->alloc(getNumberOfNodes(),3);
728   int nbOf1DLev(_mesh1D->getNumberOfNodes());
729   int nbOf2DNodes(_mesh2D->getNumberOfNodes());
730   const double *ptSrc(arr2D->begin());
731   double *pt(ret->getPointer());
732   std::copy(ptSrc,ptSrc+3*nbOf2DNodes,pt);
733   for(int i=1;i<nbOf1DLev;i++)
734     {
735       std::copy(ptSrc,ptSrc+3*nbOf2DNodes,pt+3*i*nbOf2DNodes);
736       double vec[3];
737       std::copy(arr1D->begin()+3*i,arr1D->begin()+3*(i+1),vec);
738       std::transform(arr1D->begin()+3*(i-1),arr1D->begin()+3*i,vec,vec,std::minus<double>());
739       for(int j=0;j<nbOf2DNodes;j++)
740         std::transform(vec,vec+3,pt+3*(i*nbOf2DNodes+j),pt+3*(i*nbOf2DNodes+j),std::plus<double>());
741     }
742   return ret.retn();
743 }
744
745 DataArrayDouble *MEDCouplingMappedExtrudedMesh::computeCellCenterOfMass() const
746 {
747   throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::computeCellCenterOfMass : not yet implemented !");
748 }
749
750 DataArrayDouble *MEDCouplingMappedExtrudedMesh::computeIsoBarycenterOfNodesPerCell() const
751 {
752   throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::computeIsoBarycenterOfNodesPerCell: not yet implemented !");
753 }
754
755 void MEDCouplingMappedExtrudedMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
756 {
757   MCAuto<MEDCouplingUMesh> m(buildUnstructured());
758   m->getReverseNodalConnectivity(revNodal,revNodalIndx);
759 }
760
761 void MEDCouplingMappedExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D)
762 {
763   _mesh3D_ids->alloc(mesh3D->getNumberOfCells(),1);
764   int nbOf1DLev(mesh3D->getNumberOfCells()/_mesh2D->getNumberOfCells());
765   _mesh1D->setMeshDimension(1);
766   _mesh1D->allocateCells(nbOf1DLev);
767   int tmpConn[2];
768   for(int i=0;i<nbOf1DLev;i++)
769     {
770       tmpConn[0]=i;
771       tmpConn[1]=i+1;
772       _mesh1D->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,tmpConn);
773     }
774   _mesh1D->finishInsertingCells();
775   DataArrayDouble *myCoords=DataArrayDouble::New();
776   myCoords->alloc(nbOf1DLev+1,3);
777   _mesh1D->setCoords(myCoords);
778   myCoords->decrRef();
779   MCAuto<DataArrayInt> desc(DataArrayInt::New()),descIndx(DataArrayInt::New()),revDesc(DataArrayInt::New()),revDescIndx(DataArrayInt::New());
780   MCAuto<MEDCouplingUMesh> subMesh(mesh3D->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx));
781   MCAuto<DataArrayInt> revNodal2D(DataArrayInt::New()),revNodalIndx2D(DataArrayInt::New());
782   subMesh->getReverseNodalConnectivity(revNodal2D,revNodalIndx2D);
783   const int *nodal2D(_mesh2D->getNodalConnectivity()->begin());
784   const int *nodal2DIndx(_mesh2D->getNodalConnectivityIndex()->begin());
785   const int *revNodal2DPtr(revNodal2D->begin());
786   const int *revNodalIndx2DPtr(revNodalIndx2D->begin());
787   const int *descP(desc->begin()),*descIndxP(descIndx->begin()),*revDescP(revDesc->begin()),*revDescIndxP(revDescIndx->begin());
788   //
789   int nbOf2DCells(_mesh2D->getNumberOfCells());
790   for(int i=0;i<nbOf2DCells;i++)
791     {
792       int idInSubMesh;
793       std::vector<int> nodalConnec(nodal2D+nodal2DIndx[i]+1,nodal2D+nodal2DIndx[i+1]);
794       try
795       {
796           idInSubMesh=FindCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr);
797       }
798       catch(INTERP_KERNEL::Exception& e)
799       {
800           std::ostringstream ostr; ostr << "mesh2D cell # " << i << " is not part of any cell of 3D mesh !\n";
801           ostr << e.what();
802           throw INTERP_KERNEL::Exception(ostr.str().c_str());
803       }
804       build1DExtrusion(idInSubMesh,i,nbOf1DLev,subMesh,descP,descIndxP,revDescP,revDescIndxP,i==_cell_2D_id);
805     }
806 }
807
808 void MEDCouplingMappedExtrudedMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
809 {
810   std::vector<int> tinyInfo1;
811   std::vector<std::string> ls1;
812   std::vector<double> ls3;
813   _mesh2D->getTinySerializationInformation(ls3,tinyInfo1,ls1);
814   std::vector<int> tinyInfo2;
815   std::vector<std::string> ls2;
816   std::vector<double> ls4;
817   _mesh1D->getTinySerializationInformation(ls4,tinyInfo2,ls2);
818   tinyInfo.clear(); littleStrings.clear();
819   tinyInfo.insert(tinyInfo.end(),tinyInfo1.begin(),tinyInfo1.end());
820   littleStrings.insert(littleStrings.end(),ls1.begin(),ls1.end());
821   tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
822   littleStrings.insert(littleStrings.end(),ls2.begin(),ls2.end());
823   tinyInfo.push_back(_cell_2D_id);
824   tinyInfo.push_back((int)tinyInfo1.size());
825   tinyInfo.push_back(_mesh3D_ids->getNbOfElems());
826   littleStrings.push_back(getName());
827   littleStrings.push_back(getDescription());
828 }
829
830 void MEDCouplingMappedExtrudedMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
831 {
832   std::size_t sz=tinyInfo.size();
833   int sz1=tinyInfo[sz-2];
834   std::vector<int> ti1(tinyInfo.begin(),tinyInfo.begin()+sz1);
835   std::vector<int> ti2(tinyInfo.begin()+sz1,tinyInfo.end()-3);
836   MEDCouplingUMesh *um=MEDCouplingUMesh::New();
837   DataArrayInt *a1tmp=DataArrayInt::New();
838   DataArrayDouble *a2tmp=DataArrayDouble::New();
839   int la1=0,la2=0;
840   std::vector<std::string> ls1,ls2;
841   um->resizeForUnserialization(ti1,a1tmp,a2tmp,ls1);
842   la1+=a1tmp->getNbOfElems(); la2+=a2tmp->getNbOfElems();
843   a1tmp->decrRef(); a2tmp->decrRef();
844   a1tmp=DataArrayInt::New(); a2tmp=DataArrayDouble::New();
845   um->resizeForUnserialization(ti2,a1tmp,a2tmp,ls2);
846   la1+=a1tmp->getNbOfElems(); la2+=a2tmp->getNbOfElems();
847   a1tmp->decrRef(); a2tmp->decrRef();
848   um->decrRef();
849   //
850   a1->alloc(la1+tinyInfo[sz-1],1);
851   a2->alloc(la2,1);
852   littleStrings.resize(ls1.size()+ls2.size()+2);
853 }
854
855 void MEDCouplingMappedExtrudedMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
856 {
857   a1=DataArrayInt::New(); a2=DataArrayDouble::New();
858   DataArrayInt *a1_1=0,*a1_2=0;
859   DataArrayDouble *a2_1=0,*a2_2=0;
860   _mesh2D->serialize(a1_1,a2_1);
861   _mesh1D->serialize(a1_2,a2_2);
862   a1->alloc(a1_1->getNbOfElems()+a1_2->getNbOfElems()+_mesh3D_ids->getNbOfElems(),1);
863   int *ptri=a1->getPointer();
864   ptri=std::copy(a1_1->begin(),a1_1->begin()+a1_1->getNbOfElems(),ptri);
865   a1_1->decrRef();
866   ptri=std::copy(a1_2->begin(),a1_2->begin()+a1_2->getNbOfElems(),ptri);
867   a1_2->decrRef();
868   std::copy(_mesh3D_ids->begin(),_mesh3D_ids->begin()+_mesh3D_ids->getNbOfElems(),ptri);
869   a2->alloc(a2_1->getNbOfElems()+a2_2->getNbOfElems(),1);
870   double *ptrd=a2->getPointer();
871   ptrd=std::copy(a2_1->begin(),a2_1->begin()+a2_1->getNbOfElems(),ptrd);
872   a2_1->decrRef();
873   std::copy(a2_2->begin(),a2_2->begin()+a2_2->getNbOfElems(),ptrd);
874   a2_2->decrRef();
875 }
876
877 void MEDCouplingMappedExtrudedMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
878 {
879   setName(littleStrings[littleStrings.size()-2]);
880   setDescription(littleStrings.back());
881   std::size_t sz=tinyInfo.size();
882   int sz1=tinyInfo[sz-2];
883   _cell_2D_id=tinyInfo[sz-3];
884   std::vector<int> ti1(tinyInfo.begin(),tinyInfo.begin()+sz1);
885   std::vector<int> ti2(tinyInfo.begin()+sz1,tinyInfo.end()-3);
886   DataArrayInt *a1tmp=DataArrayInt::New();
887   DataArrayDouble *a2tmp=DataArrayDouble::New();
888   const int *a1Ptr=a1->begin();
889   const double *a2Ptr=a2->begin();
890   _mesh2D=MEDCouplingUMesh::New();
891   std::vector<std::string> ls1,ls2;
892   _mesh2D->resizeForUnserialization(ti1,a1tmp,a2tmp,ls1);
893   std::copy(a2Ptr,a2Ptr+a2tmp->getNbOfElems(),a2tmp->getPointer());
894   std::copy(a1Ptr,a1Ptr+a1tmp->getNbOfElems(),a1tmp->getPointer());
895   a2Ptr+=a2tmp->getNbOfElems();
896   a1Ptr+=a1tmp->getNbOfElems();
897   ls2.insert(ls2.end(),littleStrings.begin(),littleStrings.begin()+ls1.size());
898   std::vector<double> d1(1);
899   _mesh2D->unserialization(d1,ti1,a1tmp,a2tmp,ls2);
900   a1tmp->decrRef(); a2tmp->decrRef();
901   //
902   ls2.clear();
903   ls2.insert(ls2.end(),littleStrings.begin()+ls1.size(),littleStrings.end()-2);
904   _mesh1D=MEDCouplingUMesh::New();
905   a1tmp=DataArrayInt::New(); a2tmp=DataArrayDouble::New();
906   _mesh1D->resizeForUnserialization(ti2,a1tmp,a2tmp,ls1);
907   std::copy(a2Ptr,a2Ptr+a2tmp->getNbOfElems(),a2tmp->getPointer());
908   std::copy(a1Ptr,a1Ptr+a1tmp->getNbOfElems(),a1tmp->getPointer());
909   a1Ptr+=a1tmp->getNbOfElems();
910   _mesh1D->unserialization(d1,ti2,a1tmp,a2tmp,ls2);
911   a1tmp->decrRef(); a2tmp->decrRef();
912   //
913   _mesh3D_ids=DataArrayInt::New();
914   int szIds=(int)std::distance(a1Ptr,a1->begin()+a1->getNbOfElems());
915   _mesh3D_ids->alloc(szIds,1);
916   std::copy(a1Ptr,a1Ptr+szIds,_mesh3D_ids->getPointer());
917 }
918
919 void MEDCouplingMappedExtrudedMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const
920 {
921   MCAuto<MEDCouplingUMesh> m=buildUnstructured();
922   m->writeVTKLL(ofs,cellData,pointData,byteData);
923 }
924
925 void MEDCouplingMappedExtrudedMesh::reprQuickOverview(std::ostream& stream) const
926 {
927   stream << "MEDCouplingMappedExtrudedMesh C++ instance at " << this << ". Name : \"" << getName() << "\".";
928 }
929
930 std::string MEDCouplingMappedExtrudedMesh::getVTKFileExtension() const
931 {
932   return _mesh2D->getVTKFileExtension();
933 }
934
935 std::string MEDCouplingMappedExtrudedMesh::getVTKDataSetType() const
936 {
937   return _mesh2D->getVTKDataSetType();
938 }