1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #include "MEDFileEquivalence.hxx"
22 #include "MEDFileSafeCaller.txx"
23 #include "MEDCouplingMemArray.hxx"
24 #include "MEDLoaderBase.hxx"
25 #include "MEDFileMesh.hxx"
26 #include "InterpKernelAutoPtr.hxx"
28 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
29 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
30 extern med_geometry_type typmai3[34];
31 extern med_geometry_type typmainoeud[1];
33 using namespace ParaMEDMEM;
35 MEDFileEquivalencePair *MEDFileEquivalencePair::Load(MEDFileEquivalences *father, med_idt fid, const std::string& name, const std::string &desc)
38 throw INTERP_KERNEL::Exception("MEDFileEquivalencePair::Load : father is NULL ! Should not !");
39 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> ret(new MEDFileEquivalencePair(father,name,desc));
44 void MEDFileEquivalencePair::write(med_idt fid) const
46 std::string meshName(getFather()->getMeshName());
47 INTERP_KERNEL::AutoPtr<char> meshName2(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
48 INTERP_KERNEL::AutoPtr<char> name(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
49 INTERP_KERNEL::AutoPtr<char> desc(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
50 MEDLoaderBase::safeStrCpy(meshName.c_str(),MED_NAME_SIZE,meshName2,getFather()->getMesh()->getTooLongStrPolicy());
51 MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,name,getFather()->getMesh()->getTooLongStrPolicy());
52 MEDLoaderBase::safeStrCpy(_description.c_str(),MED_COMMENT_SIZE,desc,getFather()->getMesh()->getTooLongStrPolicy());
53 MEDFILESAFECALLERWR0(MEDequivalenceCr,(fid,meshName2,name,desc));
54 const MEDFileEquivalenceCell *cell(_cell);
57 const MEDFileEquivalenceNode *node(_node);
62 const MEDFileMesh *MEDFileEquivalencePair::getMesh() const
64 return getFather()->getMesh();
67 MEDFileMesh *MEDFileEquivalencePair::getMesh()
69 return getFather()->getMesh();
72 MEDFileEquivalencePair *MEDFileEquivalencePair::deepCpy(MEDFileEquivalences *father) const
74 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> ret(new MEDFileEquivalencePair(father,_name,_description));
75 const MEDFileEquivalenceCell *cell(_cell);
77 ret->_cell=cell->deepCpy(const_cast<MEDFileEquivalencePair *>(this));
78 const MEDFileEquivalenceNode *node(_node);
80 ret->_node=node->deepCpy(const_cast<MEDFileEquivalencePair *>(this));
84 bool MEDFileEquivalencePair::isEqual(const MEDFileEquivalencePair *other, std::string& what) const
86 if(_name!=other->_name)
88 std::ostringstream oss; oss << "Names differs : " << _name << " != " << other->_name << " !";
92 if(_description!=other->_description)
94 std::ostringstream oss; oss << "Description differs : " << _description << " != " << other->_description << " !";
98 const MEDFileEquivalenceCell *c1(_cell),*c2(other->_cell);
99 if((c1 && !c2) || (!c1 && c2))
101 std::ostringstream oss; oss << "Cell def of Equiv " << _name << " are defined for this and not for other (or reversely) !";
106 if(!c1->isEqual(c2,what))
108 const MEDFileEquivalenceNode *n1(_node),*n2(other->_node);
109 if((n1 && !n2) || (!n1 && n2))
111 std::ostringstream oss; oss << "Node def of Equiv " << _name << " are defined for this and not for other (or reversely) !";
116 if(!n1->isEqual(n2,what))
121 void MEDFileEquivalencePair::getRepr(std::ostream& oss) const
123 const MEDFileEquivalenceNode *node(_node);
124 const MEDFileEquivalenceCell *cell(_cell);
125 oss << std::endl << " name of equivalence : " << _name << std::endl;
126 oss << " description of equivalence : " << _description << std::endl;
129 oss << "None" << std::endl;
134 oss << "None" << std::endl;
139 MEDFileEquivalencePair *MEDFileEquivalencePair::New(MEDFileEquivalences *father, const std::string& name)
141 return new MEDFileEquivalencePair(father,name,std::string());
144 std::vector<const BigMemoryObject *> MEDFileEquivalencePair::getDirectChildrenWithNull() const
146 std::vector<const BigMemoryObject *> ret(2);
147 ret[0]=_cell; ret[1]=_node;
151 void MEDFileEquivalencePair::setArray(int meshDimRelToMaxExt, DataArrayInt *da)
153 if(meshDimRelToMaxExt>1)
154 throw INTERP_KERNEL::Exception("MEDFileEquivalencePair::setArray : meshDimRelToMaxExt must be in [1,0,-1,-2,-3] at most !");
155 if(meshDimRelToMaxExt==1)
157 MEDFileEquivalenceNode *node(_node);
160 _node=new MEDFileEquivalenceNode(this,0);
167 MEDFileEquivalenceCell *cell(_cell);
170 _cell=new MEDFileEquivalenceCell(this);
173 cell->setArray(meshDimRelToMaxExt,da);
178 * The returned pointer is a borrowed pointer.
180 MEDFileEquivalenceCell *MEDFileEquivalencePair::initCell()
182 _cell=new MEDFileEquivalenceCell(this);
187 * The returned pointer is a borrowed pointer.
189 MEDFileEquivalenceNode *MEDFileEquivalencePair::initNode()
191 _node=new MEDFileEquivalenceNode(this,0);
195 std::size_t MEDFileEquivalencePair::getHeapMemorySizeWithoutChildren() const
200 void MEDFileEquivalencePair::load(med_idt fid)
202 std::string meshName(_father->getMeshName());
204 _father->getDtIt(dt,it);
206 MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceSize,(fid,meshName.c_str(),_name.c_str(),dt,it,MED_NODE,MED_NONE,&ncor));
209 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da(DataArrayInt::New());
211 MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceRd,(fid,meshName.c_str(),_name.c_str(),dt,it,MED_NODE,MED_NONE,da->getPointer()));
214 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceNode> node(new MEDFileEquivalenceNode(this,da));
217 _cell=MEDFileEquivalenceCell::Load(fid,this);
220 std::vector<const BigMemoryObject *> MEDFileEquivalences::getDirectChildrenWithNull() const
222 std::size_t sz(_equ.size());
223 std::vector<const BigMemoryObject *> ret(sz);
224 for(std::size_t i=0;i<sz;i++)
229 std::size_t MEDFileEquivalences::getHeapMemorySizeWithoutChildren() const
231 return sizeof(MEDFileEquivalences)+_equ.capacity()*sizeof(MEDFileEquivalencePair);
234 void MEDFileEquivalences::getDtIt(int &dt, int &it) const
236 dt=_owner->getIteration(); it=_owner->getOrder();
239 std::string MEDFileEquivalences::getMeshName() const
241 return _owner->getName();
244 void MEDFileEquivalences::pushEquivalence(MEDFileEquivalencePair *elt)
246 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> elta(elt);
249 _equ.push_back(elta);
252 MEDFileEquivalencePair *MEDFileEquivalences::getEquivalence(int i)
257 std::ostringstream oss; oss << "MEDFileEquivalences::getEquivalence : invalid id ! Must be in [0," << sz << ") !";
258 throw INTERP_KERNEL::Exception(oss.str().c_str());
263 MEDFileEquivalencePair *MEDFileEquivalences::getEquivalenceWithName(const std::string& name)
265 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::iterator it=_equ.begin();it!=_equ.end();it++)
267 MEDFileEquivalencePair *elt(*it);
270 if(elt->getName()==name)
274 std::ostringstream oss; oss << "MEDFileEquivalences::getEquivalenceWithName : no equivalence with name \"" << name << "\" ! Must be in [ ";
275 std::vector<std::string> eqs(getEquivalenceNames());
276 std::copy(eqs.begin(),eqs.end(),std::ostream_iterator<std::string>(oss,", "));
278 throw INTERP_KERNEL::Exception(oss.str().c_str());
281 int MEDFileEquivalences::size() const
286 std::vector<std::string> MEDFileEquivalences::getEquivalenceNames() const
288 std::vector<std::string> ret;
289 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++)
291 const MEDFileEquivalencePair *elt(*it);
294 ret.push_back(elt->getName());
300 MEDFileEquivalencePair *MEDFileEquivalences::appendEmptyEquivalenceWithName(const std::string& name)
302 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> elt(MEDFileEquivalencePair::New(this,name));
307 MEDFileEquivalences *MEDFileEquivalences::deepCpy(MEDFileMesh *owner) const
309 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalences> ret(new MEDFileEquivalences(owner));
310 ret->deepCpyFrom(*this);
314 bool MEDFileEquivalences::isEqual(const MEDFileEquivalences *other, std::string& what) const
316 std::size_t sz(_equ.size());
317 if(sz!=other->_equ.size())
319 what="Equivalences differs : not same number !";
322 for(std::size_t i=0;i<sz;i++)
324 const MEDFileEquivalencePair *thisp(_equ[i]),*otherp(other->_equ[i]);
325 if(!thisp && !otherp)
329 if(!thisp->isEqual(otherp,what))
331 std::ostringstream oss; oss << "At Eq #" << i << " there is a difference !";
338 std::ostringstream oss; oss << "At Eq #" << i << " defined in this not is other (or reversely) !";
345 void MEDFileEquivalences::getRepr(std::ostream& oss) const
348 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++,ii++)
350 const MEDFileEquivalencePair *elt(*it);
351 oss << "Equivalence #" << ii << " : " ;
355 oss << "None" << std::endl;
359 void MEDFileEquivalences::killEquivalenceWithName(const std::string& name)
361 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::iterator it(_equ.begin());
362 for(;it!=_equ.end();it++)
364 const MEDFileEquivalencePair *elt(*it);
365 if(elt && elt->getName()==name)
370 std::ostringstream oss; oss << "MEDFileEquivalences::killEquivalenceWithName : Equivalence with name \"" << name << "\" not found !";
371 throw INTERP_KERNEL::Exception(oss.str().c_str());
376 void MEDFileEquivalences::killEquivalenceAt(int i)
381 std::ostringstream oss; oss << "MEDFileEquivalences::killEquivalenceAt : Id must be in [0," << sz << ") !";
382 throw INTERP_KERNEL::Exception(oss.str().c_str());
384 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::iterator it(_equ.begin());
385 for(int j=0;j<i;it++,j++);
389 void MEDFileEquivalences::clear()
394 void MEDFileEquivalences::write(med_idt fid) const
396 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++)
398 const MEDFileEquivalencePair *elt(*it);
404 int MEDFileEquivalences::PresenceOfEquivalences(med_idt fid, const std::string& meshName)
406 med_int nequ(MEDnEquivalence(fid,meshName.c_str()));
410 MEDFileEquivalences *MEDFileEquivalences::Load(med_idt fid, int nbOfEq, MEDFileMesh *owner)
412 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalences> ret(new MEDFileEquivalences(owner));
414 throw INTERP_KERNEL::Exception("MEDFileEquivalences::Load : owner is NULL !");
415 std::string meshName(owner->getName());
416 for(int i=0;i<nbOfEq;i++)
418 INTERP_KERNEL::AutoPtr<char> equ(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
419 INTERP_KERNEL::AutoPtr<char> desc(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
420 int nstep,nocstpncor;
421 MEDFILESAFECALLERRD0(MEDequivalenceInfo,(fid,meshName.c_str(),i+1,equ,desc,&nstep,&nocstpncor));
422 std::string eqName(MEDLoaderBase::buildStringFromFortran(equ,MED_NAME_SIZE)),eqDescName(MEDLoaderBase::buildStringFromFortran(desc,MED_COMMENT_SIZE));
423 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> eqv(MEDFileEquivalencePair::Load(ret,fid,eqName,eqDescName));
424 ret->pushEquivalence(eqv);
429 void MEDFileEquivalences::CheckDataArray(const DataArrayInt *data)
433 data->checkAllocated();
434 if(data->getNumberOfComponents()!=2)
436 std::ostringstream oss; oss << "MEDFileEquivalences::CheckDataArray : Input DataArray must have 2 components !";
437 throw INTERP_KERNEL::Exception(oss.str().c_str());
441 void MEDFileEquivalences::deepCpyFrom(const MEDFileEquivalences& other)
443 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::const_iterator it=other._equ.begin();it!=other._equ.end();it++)
445 const MEDFileEquivalencePair *elt(*it);
446 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> eltCpy;
449 eltCpy=elt->deepCpy(this);
451 _equ.push_back(eltCpy);
455 MEDFileEquivalenceBase::MEDFileEquivalenceBase(MEDFileEquivalencePair *father):_father(father)
459 MEDFileEquivalenceData::MEDFileEquivalenceData(MEDFileEquivalencePair *owner, DataArrayInt *data):MEDFileEquivalenceBase(owner),_data(data)
465 void MEDFileEquivalenceData::setArray(DataArrayInt *data)
467 MEDFileEquivalences::CheckDataArray(data);
473 std::vector<const BigMemoryObject *> MEDFileEquivalenceData::getDirectChildrenWithNull() const
475 std::vector<const BigMemoryObject *> ret(1);
480 bool MEDFileEquivalenceData::isEqual(const MEDFileEquivalenceData *other, std::string& what) const
482 const DataArrayInt *d1(_data),*d2(other->_data);
483 if((!d1 && d2) || (d1 && !d2))
485 what="Data array is defined in this not in other (or reversely) !";
490 if(!d1->isEqualIfNotWhy(*d2,what))
496 void MEDFileEquivalenceData::writeLL(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const
499 const DataArrayInt *da(getArray());
502 MEDFileEquivalences::CheckDataArray(da);
503 const MEDFileMesh *mesh(getFather()->getMesh());
505 mesh->getTime(dt,it);
506 std::string meshName(mesh->getName());
507 std::string equName(getFather()->getName());
508 INTERP_KERNEL::AutoPtr<char> meshName2(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
509 INTERP_KERNEL::AutoPtr<char> name(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
510 MEDLoaderBase::safeStrCpy(meshName.c_str(),MED_NAME_SIZE,meshName2,getFather()->getMesh()->getTooLongStrPolicy());
511 MEDLoaderBase::safeStrCpy(equName.c_str(),MED_NAME_SIZE,name,getFather()->getMesh()->getTooLongStrPolicy());
512 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2(da->deepCpy()); da2->rearrange(1); da2->applyLin(1,1); da2->rearrange(2);
513 MEDFILESAFECALLERWR0(MEDequivalenceCorrespondenceWr,(fid,meshName2,name,dt,it,medtype,medgt,da2->getNumberOfTuples(),da2->begin()));
516 std::size_t MEDFileEquivalenceCellType::getHeapMemorySizeWithoutChildren() const
518 return sizeof(MEDFileEquivalenceCellType);
521 MEDFileEquivalenceCellType *MEDFileEquivalenceCellType::deepCpy(MEDFileEquivalencePair *owner) const
523 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
525 da=getArray()->deepCpy();
526 return new MEDFileEquivalenceCellType(owner,_type,da);
529 bool MEDFileEquivalenceCellType::isEqual(const MEDFileEquivalenceCellType *other, std::string& what) const
531 if(_type!=other->_type)
533 what="Geo types differs !";
536 return MEDFileEquivalenceData::isEqual(other,what);
539 void MEDFileEquivalenceCellType::getRepr(std::ostream& oss) const
541 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_type));
542 const DataArrayInt *da(getArray());
543 oss << cm.getRepr() << ":";
545 oss << da->getNumberOfTuples() << " tuples";
547 oss << "no dataarray";
551 void MEDFileEquivalenceCellType::write(med_idt fid) const
553 writeLL(fid,MED_CELL,typmai3[_type]);
556 std::vector<const BigMemoryObject *> MEDFileEquivalenceCell::getDirectChildrenWithNull() const
558 std::size_t sz(_types.size());
559 std::vector<const BigMemoryObject *> ret(sz);
560 for(std::size_t i=0;i<sz;i++)
565 std::size_t MEDFileEquivalenceCell::getHeapMemorySizeWithoutChildren() const
567 return sizeof(MEDFileEquivalenceCell)+_types.capacity()*sizeof(MEDFileEquivalenceCellType);
570 MEDFileEquivalenceCell *MEDFileEquivalenceCell::Load(med_idt fid, MEDFileEquivalencePair *owner)
572 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCell> ret(new MEDFileEquivalenceCell(owner));
580 void MEDFileEquivalenceCell::write(med_idt fid) const
582 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
584 const MEDFileEquivalenceCellType *ct(*it);
590 MEDFileEquivalenceCell *MEDFileEquivalenceCell::deepCpy(MEDFileEquivalencePair *owner) const
592 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCell> ret(new MEDFileEquivalenceCell(owner));
593 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
595 const MEDFileEquivalenceCellType *elt(*it);
596 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> eltCpy;
598 eltCpy=elt->deepCpy(owner);
599 ret->_types.push_back(eltCpy);
604 bool MEDFileEquivalenceCell::isEqual(const MEDFileEquivalenceCell *other, std::string& what) const
606 std::size_t sz(_types.size());
607 if(sz!=other->_types.size())
609 std::ostringstream oss; oss << "Nb of geo types differs : " << sz << " != " << other->_types.size();
613 for(std::size_t i=0;i<sz;i++)
615 const MEDFileEquivalenceCellType *ct1(_types[i]),*ct2(other->_types[i]);
616 if((ct1 && !ct2) || (!ct1 && ct2))
618 std::ostringstream oss; oss << "At gt #" << i << " this is defined not other (or reversely !)";
624 if(!ct1->isEqual(ct2,what))
626 std::ostringstream oss; oss << "At gt #" << i << " of Eq " << getFather()->getName() << " it differs !";
635 void MEDFileEquivalenceCell::getRepr(std::ostream& oss) const
637 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
639 const MEDFileEquivalenceCellType *elt(*it);
645 DataArrayInt *MEDFileEquivalenceCell::getArray(INTERP_KERNEL::NormalizedCellType type)
647 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::iterator it=_types.begin();it!=_types.end();it++)
649 MEDFileEquivalenceCellType *elt(*it);
650 if(elt && elt->getType()==type)
651 return elt->getArray();
653 std::ostringstream oss; oss << "MEDFileEquivalenceCell::getArray : In Equivalence \"" << getFather()->getName() << "\" the geotype " << type << " is not available !";
654 throw INTERP_KERNEL::Exception(oss.str().c_str());
657 void MEDFileEquivalenceCell::setArray(int meshDimRelToMax, DataArrayInt *da)
661 MEDFileEquivalences::CheckDataArray(da);
662 MEDFileMesh *mm(getMesh());
663 int totalNbOfCells(mm->getNumberOfCellsAtLevel(meshDimRelToMax));
665 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(da->deepCpy()); tmp->rearrange(1);
667 tmp->getMinMaxValues(minv,maxv);
668 if((minv<0 || minv>=totalNbOfCells) || (maxv<0 || maxv>=totalNbOfCells))
670 std::ostringstream oss; oss << "MEDFileEquivalenceCell::setArray : Input 2 component DataArray has incorrect values ! all values must be in [0," << totalNbOfCells << ") !";
671 throw INTERP_KERNEL::Exception(oss.str().c_str());
674 std::vector<INTERP_KERNEL::NormalizedCellType> gts(mm->getGeoTypesAtLevel(meshDimRelToMax));
675 int startId(0),endId;
676 std::vector<int> compS(1,0);
677 for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it=gts.begin();it!=gts.end();it++)
679 endId=startId+mm->getNumberOfCellsWithType(*it);
680 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da0(da->keepSelectedComponents(compS));
681 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids(da0->getIdsInRange(startId,endId));
682 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da1(da->selectByTupleIdSafe(ids->begin(),ids->end()));
683 da1->applyLin(1,-startId);
684 setArrayForType(*it,da1);
689 void MEDFileEquivalenceCell::setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da)
691 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::iterator it=_types.begin();it!=_types.end();it++)
693 MEDFileEquivalenceCellType *elt(*it);
694 if(elt && elt->getType()==type)
700 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> newElt(new MEDFileEquivalenceCellType(getFather(),type,da));
701 _types.push_back(newElt);
704 std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileEquivalenceCell::getTypes() const
706 std::vector<INTERP_KERNEL::NormalizedCellType> ret;
707 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
709 const MEDFileEquivalenceCellType *elt(*it);
711 ret.push_back(elt->getType());
716 void MEDFileEquivalenceCell::load(med_idt fid)
718 std::string meshName(getFather()->getFather()->getMeshName()),name(getName());
720 getFather()->getFather()->getDtIt(dt,it);
721 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
724 MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceSize,(fid,meshName.c_str(),name.c_str(),dt,it,MED_CELL,typmai[i],&ncor));
727 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da(DataArrayInt::New());
729 MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceRd,(fid,meshName.c_str(),name.c_str(),dt,it,MED_CELL,typmai[i],da->getPointer()));
732 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> ct(new MEDFileEquivalenceCellType(getFather(),typmai2[i],da));
733 _types.push_back(ct);
738 std::size_t MEDFileEquivalenceNode::getHeapMemorySizeWithoutChildren() const
740 return sizeof(MEDFileEquivalenceNode);
743 void MEDFileEquivalenceNode::write(med_idt fid) const
745 writeLL(fid,MED_NODE,MED_NONE);
748 MEDFileEquivalenceNode *MEDFileEquivalenceNode::deepCpy(MEDFileEquivalencePair *owner) const
750 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
752 da=getArray()->deepCpy();
753 MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceNode> ret(new MEDFileEquivalenceNode(owner,da));
757 bool MEDFileEquivalenceNode::isEqual(const MEDFileEquivalenceNode *other, std::string& what) const
759 return MEDFileEquivalenceData::isEqual(other,what);
762 void MEDFileEquivalenceNode::getRepr(std::ostream& oss) const
764 const DataArrayInt *da(getArray());
766 oss << " No dataarray defined !" << std::endl;
768 oss << da->getNumberOfTuples() << " tuples in node equivalence." << std::endl;