X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileEquivalence.cxx;h=e991003414abcc6ca91e1794adff3de741a78283;hb=7f53ba0ad6eebec56c2936b923ac3ae728f41074;hp=5f9ff6de4fb168bb089d267b595cd6d47bfa4ee5;hpb=8f82f89e0b819c02023d86dc86f8a18e24f645b6;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileEquivalence.cxx b/src/MEDLoader/MEDFileEquivalence.cxx index 5f9ff6de4..e99100341 100644 --- a/src/MEDLoader/MEDFileEquivalence.cxx +++ b/src/MEDLoader/MEDFileEquivalence.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -30,13 +30,13 @@ extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO]; extern med_geometry_type typmai3[34]; extern med_geometry_type typmainoeud[1]; -using namespace ParaMEDMEM; +using namespace MEDCoupling; MEDFileEquivalencePair *MEDFileEquivalencePair::Load(MEDFileEquivalences *father, med_idt fid, const std::string& name, const std::string &desc) { if(!father) throw INTERP_KERNEL::Exception("MEDFileEquivalencePair::Load : father is NULL ! Should not !"); - MEDCouplingAutoRefCountObjectPtr ret(new MEDFileEquivalencePair(father,name,desc)); + MCAuto ret(new MEDFileEquivalencePair(father,name,desc)); ret->load(fid); return ret.retn(); } @@ -69,15 +69,15 @@ MEDFileMesh *MEDFileEquivalencePair::getMesh() return getFather()->getMesh(); } -MEDFileEquivalencePair *MEDFileEquivalencePair::deepCpy(MEDFileEquivalences *father) const +MEDFileEquivalencePair *MEDFileEquivalencePair::deepCopy(MEDFileEquivalences *father) const { - MEDCouplingAutoRefCountObjectPtr ret(new MEDFileEquivalencePair(father,_name,_description)); + MCAuto ret(new MEDFileEquivalencePair(father,_name,_description)); const MEDFileEquivalenceCell *cell(_cell); if(cell) - ret->_cell=cell->deepCpy(const_cast(this)); + ret->_cell=cell->deepCopy(const_cast(this)); const MEDFileEquivalenceNode *node(_node); if(node) - ret->_node=node->deepCpy(const_cast(this)); + ret->_node=node->deepCopy(const_cast(this)); return ret.retn(); } @@ -206,12 +206,12 @@ void MEDFileEquivalencePair::load(med_idt fid) MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceSize,(fid,meshName.c_str(),_name.c_str(),dt,it,MED_NODE,MED_NONE,&ncor)); if(ncor>0) { - MEDCouplingAutoRefCountObjectPtr da(DataArrayInt::New()); + MCAuto da(DataArrayInt::New()); da->alloc(ncor*2); MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceRd,(fid,meshName.c_str(),_name.c_str(),dt,it,MED_NODE,MED_NONE,da->getPointer())); da->applyLin(1,-1); da->rearrange(2); - MEDCouplingAutoRefCountObjectPtr node(new MEDFileEquivalenceNode(this,da)); + MCAuto node(new MEDFileEquivalenceNode(this,da)); _node=node; } _cell=MEDFileEquivalenceCell::Load(fid,this); @@ -243,7 +243,7 @@ std::string MEDFileEquivalences::getMeshName() const void MEDFileEquivalences::pushEquivalence(MEDFileEquivalencePair *elt) { - MEDCouplingAutoRefCountObjectPtr elta(elt); + MCAuto elta(elt); if(elt) elt->incrRef(); _equ.push_back(elta); @@ -262,7 +262,7 @@ MEDFileEquivalencePair *MEDFileEquivalences::getEquivalence(int i) MEDFileEquivalencePair *MEDFileEquivalences::getEquivalenceWithName(const std::string& name) { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_equ.begin();it!=_equ.end();it++) + for(std::vector< MCAuto >::iterator it=_equ.begin();it!=_equ.end();it++) { MEDFileEquivalencePair *elt(*it); if(elt) @@ -286,7 +286,7 @@ int MEDFileEquivalences::size() const std::vector MEDFileEquivalences::getEquivalenceNames() const { std::vector ret; - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_equ.begin();it!=_equ.end();it++) + for(std::vector< MCAuto >::const_iterator it=_equ.begin();it!=_equ.end();it++) { const MEDFileEquivalencePair *elt(*it); if(elt) @@ -299,14 +299,14 @@ std::vector MEDFileEquivalences::getEquivalenceNames() const MEDFileEquivalencePair *MEDFileEquivalences::appendEmptyEquivalenceWithName(const std::string& name) { - MEDCouplingAutoRefCountObjectPtr elt(MEDFileEquivalencePair::New(this,name)); + MCAuto elt(MEDFileEquivalencePair::New(this,name)); _equ.push_back(elt); return elt; } -MEDFileEquivalences *MEDFileEquivalences::deepCpy(MEDFileMesh *owner) const +MEDFileEquivalences *MEDFileEquivalences::deepCopy(MEDFileMesh *owner) const { - MEDCouplingAutoRefCountObjectPtr ret(new MEDFileEquivalences(owner)); + MCAuto ret(new MEDFileEquivalences(owner)); ret->deepCpyFrom(*this); return ret.retn(); } @@ -340,12 +340,13 @@ bool MEDFileEquivalences::isEqual(const MEDFileEquivalences *other, std::string& return false; } } + return true; } void MEDFileEquivalences::getRepr(std::ostream& oss) const { std::size_t ii(0); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_equ.begin();it!=_equ.end();it++,ii++) + for(std::vector< MCAuto >::const_iterator it=_equ.begin();it!=_equ.end();it++,ii++) { const MEDFileEquivalencePair *elt(*it); oss << "Equivalence #" << ii << " : " ; @@ -358,7 +359,7 @@ void MEDFileEquivalences::getRepr(std::ostream& oss) const void MEDFileEquivalences::killEquivalenceWithName(const std::string& name) { - std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it(_equ.begin()); + std::vector< MCAuto >::iterator it(_equ.begin()); for(;it!=_equ.end();it++) { const MEDFileEquivalencePair *elt(*it); @@ -381,7 +382,7 @@ void MEDFileEquivalences::killEquivalenceAt(int i) std::ostringstream oss; oss << "MEDFileEquivalences::killEquivalenceAt : Id must be in [0," << sz << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it(_equ.begin()); + std::vector< MCAuto >::iterator it(_equ.begin()); for(int j=0;j >::const_iterator it=_equ.begin();it!=_equ.end();it++) + for(std::vector< MCAuto >::const_iterator it=_equ.begin();it!=_equ.end();it++) { const MEDFileEquivalencePair *elt(*it); if(elt) @@ -409,7 +410,7 @@ int MEDFileEquivalences::PresenceOfEquivalences(med_idt fid, const std::string& MEDFileEquivalences *MEDFileEquivalences::Load(med_idt fid, int nbOfEq, MEDFileMesh *owner) { - MEDCouplingAutoRefCountObjectPtr ret(new MEDFileEquivalences(owner)); + MCAuto ret(new MEDFileEquivalences(owner)); if(!owner) throw INTERP_KERNEL::Exception("MEDFileEquivalences::Load : owner is NULL !"); std::string meshName(owner->getName()); @@ -420,7 +421,7 @@ MEDFileEquivalences *MEDFileEquivalences::Load(med_idt fid, int nbOfEq, MEDFileM int nstep,nocstpncor; MEDFILESAFECALLERRD0(MEDequivalenceInfo,(fid,meshName.c_str(),i+1,equ,desc,&nstep,&nocstpncor)); std::string eqName(MEDLoaderBase::buildStringFromFortran(equ,MED_NAME_SIZE)),eqDescName(MEDLoaderBase::buildStringFromFortran(desc,MED_COMMENT_SIZE)); - MEDCouplingAutoRefCountObjectPtr eqv(MEDFileEquivalencePair::Load(ret,fid,eqName,eqDescName)); + MCAuto eqv(MEDFileEquivalencePair::Load(ret,fid,eqName,eqDescName)); ret->pushEquivalence(eqv); } return ret.retn(); @@ -440,13 +441,13 @@ void MEDFileEquivalences::CheckDataArray(const DataArrayInt *data) void MEDFileEquivalences::deepCpyFrom(const MEDFileEquivalences& other) { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=other._equ.begin();it!=other._equ.end();it++) + for(std::vector< MCAuto >::const_iterator it=other._equ.begin();it!=other._equ.end();it++) { const MEDFileEquivalencePair *elt(*it); - MEDCouplingAutoRefCountObjectPtr eltCpy; + MCAuto eltCpy; if(elt) { - eltCpy=elt->deepCpy(this); + eltCpy=elt->deepCopy(this); } _equ.push_back(eltCpy); } @@ -509,7 +510,7 @@ void MEDFileEquivalenceData::writeLL(med_idt fid, med_entity_type medtype, med_g INTERP_KERNEL::AutoPtr name(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); MEDLoaderBase::safeStrCpy(meshName.c_str(),MED_NAME_SIZE,meshName2,getFather()->getMesh()->getTooLongStrPolicy()); MEDLoaderBase::safeStrCpy(equName.c_str(),MED_NAME_SIZE,name,getFather()->getMesh()->getTooLongStrPolicy()); - MEDCouplingAutoRefCountObjectPtr da2(da->deepCpy()); da2->rearrange(1); da2->applyLin(1,1); da2->rearrange(2); + MCAuto da2(da->deepCopy()); da2->rearrange(1); da2->applyLin(1,1); da2->rearrange(2); MEDFILESAFECALLERWR0(MEDequivalenceCorrespondenceWr,(fid,meshName2,name,dt,it,medtype,medgt,da2->getNumberOfTuples(),da2->begin())); } @@ -518,11 +519,11 @@ std::size_t MEDFileEquivalenceCellType::getHeapMemorySizeWithoutChildren() const return sizeof(MEDFileEquivalenceCellType); } -MEDFileEquivalenceCellType *MEDFileEquivalenceCellType::deepCpy(MEDFileEquivalencePair *owner) const +MEDFileEquivalenceCellType *MEDFileEquivalenceCellType::deepCopy(MEDFileEquivalencePair *owner) const { - MEDCouplingAutoRefCountObjectPtr da; + MCAuto da; if(getArray()) - da=getArray()->deepCpy(); + da=getArray()->deepCopy(); return new MEDFileEquivalenceCellType(owner,_type,da); } @@ -569,7 +570,7 @@ std::size_t MEDFileEquivalenceCell::getHeapMemorySizeWithoutChildren() const MEDFileEquivalenceCell *MEDFileEquivalenceCell::Load(med_idt fid, MEDFileEquivalencePair *owner) { - MEDCouplingAutoRefCountObjectPtr ret(new MEDFileEquivalenceCell(owner)); + MCAuto ret(new MEDFileEquivalenceCell(owner)); ret->load(fid); if(ret->size()>0) return ret.retn(); @@ -579,7 +580,7 @@ MEDFileEquivalenceCell *MEDFileEquivalenceCell::Load(med_idt fid, MEDFileEquival void MEDFileEquivalenceCell::write(med_idt fid) const { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_types.begin();it!=_types.end();it++) + for(std::vector< MCAuto >::const_iterator it=_types.begin();it!=_types.end();it++) { const MEDFileEquivalenceCellType *ct(*it); if(ct) @@ -587,15 +588,15 @@ void MEDFileEquivalenceCell::write(med_idt fid) const } } -MEDFileEquivalenceCell *MEDFileEquivalenceCell::deepCpy(MEDFileEquivalencePair *owner) const +MEDFileEquivalenceCell *MEDFileEquivalenceCell::deepCopy(MEDFileEquivalencePair *owner) const { - MEDCouplingAutoRefCountObjectPtr ret(new MEDFileEquivalenceCell(owner)); - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_types.begin();it!=_types.end();it++) + MCAuto ret(new MEDFileEquivalenceCell(owner)); + for(std::vector< MCAuto >::const_iterator it=_types.begin();it!=_types.end();it++) { const MEDFileEquivalenceCellType *elt(*it); - MEDCouplingAutoRefCountObjectPtr eltCpy; + MCAuto eltCpy; if(elt) - eltCpy=elt->deepCpy(owner); + eltCpy=elt->deepCopy(owner); ret->_types.push_back(eltCpy); } return ret.retn(); @@ -634,7 +635,7 @@ bool MEDFileEquivalenceCell::isEqual(const MEDFileEquivalenceCell *other, std::s void MEDFileEquivalenceCell::getRepr(std::ostream& oss) const { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_types.begin();it!=_types.end();it++) + for(std::vector< MCAuto >::const_iterator it=_types.begin();it!=_types.end();it++) { const MEDFileEquivalenceCellType *elt(*it); if(elt) @@ -644,7 +645,7 @@ void MEDFileEquivalenceCell::getRepr(std::ostream& oss) const DataArrayInt *MEDFileEquivalenceCell::getArray(INTERP_KERNEL::NormalizedCellType type) { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_types.begin();it!=_types.end();it++) + for(std::vector< MCAuto >::iterator it=_types.begin();it!=_types.end();it++) { MEDFileEquivalenceCellType *elt(*it); if(elt && elt->getType()==type) @@ -662,7 +663,7 @@ void MEDFileEquivalenceCell::setArray(int meshDimRelToMax, DataArrayInt *da) MEDFileMesh *mm(getMesh()); int totalNbOfCells(mm->getNumberOfCellsAtLevel(meshDimRelToMax)); // - MEDCouplingAutoRefCountObjectPtr tmp(da->deepCpy()); tmp->rearrange(1); + MCAuto tmp(da->deepCopy()); tmp->rearrange(1); int maxv,minv; tmp->getMinMaxValues(minv,maxv); if((minv<0 || minv>=totalNbOfCells) || (maxv<0 || maxv>=totalNbOfCells)) @@ -677,9 +678,9 @@ void MEDFileEquivalenceCell::setArray(int meshDimRelToMax, DataArrayInt *da) for(std::vector::const_iterator it=gts.begin();it!=gts.end();it++) { endId=startId+mm->getNumberOfCellsWithType(*it); - MEDCouplingAutoRefCountObjectPtr da0(da->keepSelectedComponents(compS)); - MEDCouplingAutoRefCountObjectPtr ids(da0->getIdsInRange(startId,endId)); - MEDCouplingAutoRefCountObjectPtr da1(da->selectByTupleIdSafe(ids->begin(),ids->end())); + MCAuto da0(da->keepSelectedComponents(compS)); + MCAuto ids(da0->findIdsInRange(startId,endId)); + MCAuto da1(da->selectByTupleIdSafe(ids->begin(),ids->end())); da1->applyLin(1,-startId); setArrayForType(*it,da1); startId=endId; @@ -688,7 +689,7 @@ void MEDFileEquivalenceCell::setArray(int meshDimRelToMax, DataArrayInt *da) void MEDFileEquivalenceCell::setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da) { - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_types.begin();it!=_types.end();it++) + for(std::vector< MCAuto >::iterator it=_types.begin();it!=_types.end();it++) { MEDFileEquivalenceCellType *elt(*it); if(elt && elt->getType()==type) @@ -697,14 +698,14 @@ void MEDFileEquivalenceCell::setArrayForType(INTERP_KERNEL::NormalizedCellType t return ; } } - MEDCouplingAutoRefCountObjectPtr newElt(new MEDFileEquivalenceCellType(getFather(),type,da)); + MCAuto newElt(new MEDFileEquivalenceCellType(getFather(),type,da)); _types.push_back(newElt); } std::vector MEDFileEquivalenceCell::getTypes() const { std::vector ret; - for(std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_types.begin();it!=_types.end();it++) + for(std::vector< MCAuto >::const_iterator it=_types.begin();it!=_types.end();it++) { const MEDFileEquivalenceCellType *elt(*it); if(elt) @@ -724,12 +725,12 @@ void MEDFileEquivalenceCell::load(med_idt fid) MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceSize,(fid,meshName.c_str(),name.c_str(),dt,it,MED_CELL,typmai[i],&ncor)); if(ncor>0) { - MEDCouplingAutoRefCountObjectPtr da(DataArrayInt::New()); + MCAuto da(DataArrayInt::New()); da->alloc(ncor*2); MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceRd,(fid,meshName.c_str(),name.c_str(),dt,it,MED_CELL,typmai[i],da->getPointer())); da->applyLin(1,-1); da->rearrange(2); - MEDCouplingAutoRefCountObjectPtr ct(new MEDFileEquivalenceCellType(getFather(),typmai2[i],da)); + MCAuto ct(new MEDFileEquivalenceCellType(getFather(),typmai2[i],da)); _types.push_back(ct); } } @@ -745,12 +746,12 @@ void MEDFileEquivalenceNode::write(med_idt fid) const writeLL(fid,MED_NODE,MED_NONE); } -MEDFileEquivalenceNode *MEDFileEquivalenceNode::deepCpy(MEDFileEquivalencePair *owner) const +MEDFileEquivalenceNode *MEDFileEquivalenceNode::deepCopy(MEDFileEquivalencePair *owner) const { - MEDCouplingAutoRefCountObjectPtr da; + MCAuto da; if(getArray()) - da=getArray()->deepCpy(); - MEDCouplingAutoRefCountObjectPtr ret(new MEDFileEquivalenceNode(owner,da)); + da=getArray()->deepCopy(); + MCAuto ret(new MEDFileEquivalenceNode(owner,da)); return ret.retn(); }