-// 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
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<MEDFileEquivalencePair> ret(new MEDFileEquivalencePair(father,name,desc));
+ MCAuto<MEDFileEquivalencePair> ret(new MEDFileEquivalencePair(father,name,desc));
ret->load(fid);
return ret.retn();
}
-void MEDFileEquivalencePair::write(med_idt fid) const
+void MEDFileEquivalencePair::writeLL(med_idt fid) const
{
std::string meshName(getFather()->getMeshName());
INTERP_KERNEL::AutoPtr<char> meshName2(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
MEDFILESAFECALLERWR0(MEDequivalenceCr,(fid,meshName2,name,desc));
const MEDFileEquivalenceCell *cell(_cell);
if(cell)
- cell->write(fid);
+ cell->writeLL(fid);
const MEDFileEquivalenceNode *node(_node);
if(node)
- node->write(fid);
+ node->writeLL(fid);
}
const MEDFileMesh *MEDFileEquivalencePair::getMesh() const
return getFather()->getMesh();
}
-MEDFileEquivalencePair *MEDFileEquivalencePair::deepCpy(MEDFileEquivalences *father) const
+MEDFileEquivalencePair *MEDFileEquivalencePair::deepCopy(MEDFileEquivalences *father) const
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> ret(new MEDFileEquivalencePair(father,_name,_description));
+ MCAuto<MEDFileEquivalencePair> ret(new MEDFileEquivalencePair(father,_name,_description));
const MEDFileEquivalenceCell *cell(_cell);
if(cell)
- ret->_cell=cell->deepCpy(const_cast<MEDFileEquivalencePair *>(this));
+ ret->_cell=cell->deepCopy(const_cast<MEDFileEquivalencePair *>(this));
const MEDFileEquivalenceNode *node(_node);
if(node)
- ret->_node=node->deepCpy(const_cast<MEDFileEquivalencePair *>(this));
+ ret->_node=node->deepCopy(const_cast<MEDFileEquivalencePair *>(this));
return ret.retn();
}
MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceSize,(fid,meshName.c_str(),_name.c_str(),dt,it,MED_NODE,MED_NONE,&ncor));
if(ncor>0)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da(DataArrayInt::New());
+ MCAuto<DataArrayInt> 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<MEDFileEquivalenceNode> node(new MEDFileEquivalenceNode(this,da));
+ MCAuto<MEDFileEquivalenceNode> node(new MEDFileEquivalenceNode(this,da));
_node=node;
}
_cell=MEDFileEquivalenceCell::Load(fid,this);
void MEDFileEquivalences::pushEquivalence(MEDFileEquivalencePair *elt)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> elta(elt);
+ MCAuto<MEDFileEquivalencePair> elta(elt);
if(elt)
elt->incrRef();
_equ.push_back(elta);
MEDFileEquivalencePair *MEDFileEquivalences::getEquivalenceWithName(const std::string& name)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::iterator it=_equ.begin();it!=_equ.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalencePair> >::iterator it=_equ.begin();it!=_equ.end();it++)
{
MEDFileEquivalencePair *elt(*it);
if(elt)
std::vector<std::string> MEDFileEquivalences::getEquivalenceNames() const
{
std::vector<std::string> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++)
{
const MEDFileEquivalencePair *elt(*it);
if(elt)
MEDFileEquivalencePair *MEDFileEquivalences::appendEmptyEquivalenceWithName(const std::string& name)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> elt(MEDFileEquivalencePair::New(this,name));
+ MCAuto<MEDFileEquivalencePair> elt(MEDFileEquivalencePair::New(this,name));
_equ.push_back(elt);
return elt;
}
-MEDFileEquivalences *MEDFileEquivalences::deepCpy(MEDFileMesh *owner) const
+MEDFileEquivalences *MEDFileEquivalences::deepCopy(MEDFileMesh *owner) const
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalences> ret(new MEDFileEquivalences(owner));
+ MCAuto<MEDFileEquivalences> ret(new MEDFileEquivalences(owner));
ret->deepCpyFrom(*this);
return ret.retn();
}
return false;
}
}
+ return true;
}
void MEDFileEquivalences::getRepr(std::ostream& oss) const
{
std::size_t ii(0);
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++,ii++)
+ for(std::vector< MCAuto<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++,ii++)
{
const MEDFileEquivalencePair *elt(*it);
oss << "Equivalence #" << ii << " : " ;
void MEDFileEquivalences::killEquivalenceWithName(const std::string& name)
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::iterator it(_equ.begin());
+ std::vector< MCAuto<MEDFileEquivalencePair> >::iterator it(_equ.begin());
for(;it!=_equ.end();it++)
{
const MEDFileEquivalencePair *elt(*it);
std::ostringstream oss; oss << "MEDFileEquivalences::killEquivalenceAt : Id must be in [0," << sz << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::iterator it(_equ.begin());
+ std::vector< MCAuto<MEDFileEquivalencePair> >::iterator it(_equ.begin());
for(int j=0;j<i;it++,j++);
_equ.erase(it);
}
_equ.clear();
}
-void MEDFileEquivalences::write(med_idt fid) const
+void MEDFileEquivalences::writeLL(med_idt fid) const
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalencePair> >::const_iterator it=_equ.begin();it!=_equ.end();it++)
{
const MEDFileEquivalencePair *elt(*it);
if(elt)
- elt->write(fid);
+ elt->writeLL(fid);
}
}
MEDFileEquivalences *MEDFileEquivalences::Load(med_idt fid, int nbOfEq, MEDFileMesh *owner)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalences> ret(new MEDFileEquivalences(owner));
+ MCAuto<MEDFileEquivalences> ret(new MEDFileEquivalences(owner));
if(!owner)
throw INTERP_KERNEL::Exception("MEDFileEquivalences::Load : owner is NULL !");
std::string meshName(owner->getName());
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<MEDFileEquivalencePair> eqv(MEDFileEquivalencePair::Load(ret,fid,eqName,eqDescName));
+ MCAuto<MEDFileEquivalencePair> eqv(MEDFileEquivalencePair::Load(ret,fid,eqName,eqDescName));
ret->pushEquivalence(eqv);
}
return ret.retn();
void MEDFileEquivalences::deepCpyFrom(const MEDFileEquivalences& other)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> >::const_iterator it=other._equ.begin();it!=other._equ.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalencePair> >::const_iterator it=other._equ.begin();it!=other._equ.end();it++)
{
const MEDFileEquivalencePair *elt(*it);
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalencePair> eltCpy;
+ MCAuto<MEDFileEquivalencePair> eltCpy;
if(elt)
{
- eltCpy=elt->deepCpy(this);
+ eltCpy=elt->deepCopy(this);
}
_equ.push_back(eltCpy);
}
return true;
}
-void MEDFileEquivalenceData::writeLL(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const
+void MEDFileEquivalenceData::writeAdvanced(med_idt fid, med_entity_type medtype, med_geometry_type medgt) const
{
const DataArrayInt *da(getArray());
INTERP_KERNEL::AutoPtr<char> 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<DataArrayInt> da2(da->deepCpy()); da2->rearrange(1); da2->applyLin(1,1); da2->rearrange(2);
+ MCAuto<DataArrayInt> 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()));
}
return sizeof(MEDFileEquivalenceCellType);
}
-MEDFileEquivalenceCellType *MEDFileEquivalenceCellType::deepCpy(MEDFileEquivalencePair *owner) const
+MEDFileEquivalenceCellType *MEDFileEquivalenceCellType::deepCopy(MEDFileEquivalencePair *owner) const
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
+ MCAuto<DataArrayInt> da;
if(getArray())
- da=getArray()->deepCpy();
+ da=getArray()->deepCopy();
return new MEDFileEquivalenceCellType(owner,_type,da);
}
oss << ",";
}
-void MEDFileEquivalenceCellType::write(med_idt fid) const
+void MEDFileEquivalenceCellType::writeLL(med_idt fid) const
{
- writeLL(fid,MED_CELL,typmai3[_type]);
+ writeAdvanced(fid,MED_CELL,typmai3[_type]);
}
std::vector<const BigMemoryObject *> MEDFileEquivalenceCell::getDirectChildrenWithNull() const
MEDFileEquivalenceCell *MEDFileEquivalenceCell::Load(med_idt fid, MEDFileEquivalencePair *owner)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCell> ret(new MEDFileEquivalenceCell(owner));
+ MCAuto<MEDFileEquivalenceCell> ret(new MEDFileEquivalenceCell(owner));
ret->load(fid);
if(ret->size()>0)
return ret.retn();
return 0;
}
-void MEDFileEquivalenceCell::write(med_idt fid) const
+void MEDFileEquivalenceCell::writeLL(med_idt fid) const
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
{
const MEDFileEquivalenceCellType *ct(*it);
if(ct)
- ct->write(fid);
+ ct->writeLL(fid);
}
}
-MEDFileEquivalenceCell *MEDFileEquivalenceCell::deepCpy(MEDFileEquivalencePair *owner) const
+MEDFileEquivalenceCell *MEDFileEquivalenceCell::deepCopy(MEDFileEquivalencePair *owner) const
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCell> ret(new MEDFileEquivalenceCell(owner));
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
+ MCAuto<MEDFileEquivalenceCell> ret(new MEDFileEquivalenceCell(owner));
+ for(std::vector< MCAuto<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
{
const MEDFileEquivalenceCellType *elt(*it);
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> eltCpy;
+ MCAuto<MEDFileEquivalenceCellType> eltCpy;
if(elt)
- eltCpy=elt->deepCpy(owner);
+ eltCpy=elt->deepCopy(owner);
ret->_types.push_back(eltCpy);
}
return ret.retn();
void MEDFileEquivalenceCell::getRepr(std::ostream& oss) const
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
{
const MEDFileEquivalenceCellType *elt(*it);
if(elt)
DataArrayInt *MEDFileEquivalenceCell::getArray(INTERP_KERNEL::NormalizedCellType type)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::iterator it=_types.begin();it!=_types.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalenceCellType> >::iterator it=_types.begin();it!=_types.end();it++)
{
MEDFileEquivalenceCellType *elt(*it);
if(elt && elt->getType()==type)
MEDFileMesh *mm(getMesh());
int totalNbOfCells(mm->getNumberOfCellsAtLevel(meshDimRelToMax));
//
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp(da->deepCpy()); tmp->rearrange(1);
+ MCAuto<DataArrayInt> tmp(da->deepCopy()); tmp->rearrange(1);
int maxv,minv;
tmp->getMinMaxValues(minv,maxv);
if((minv<0 || minv>=totalNbOfCells) || (maxv<0 || maxv>=totalNbOfCells))
for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it=gts.begin();it!=gts.end();it++)
{
endId=startId+mm->getNumberOfCellsWithType(*it);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da0(da->keepSelectedComponents(compS));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids(da0->getIdsInRange(startId,endId));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da1(da->selectByTupleIdSafe(ids->begin(),ids->end()));
+ MCAuto<DataArrayInt> da0(da->keepSelectedComponents(compS));
+ MCAuto<DataArrayInt> ids(da0->findIdsInRange(startId,endId));
+ MCAuto<DataArrayInt> da1(da->selectByTupleIdSafe(ids->begin(),ids->end()));
da1->applyLin(1,-startId);
setArrayForType(*it,da1);
startId=endId;
void MEDFileEquivalenceCell::setArrayForType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::iterator it=_types.begin();it!=_types.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalenceCellType> >::iterator it=_types.begin();it!=_types.end();it++)
{
MEDFileEquivalenceCellType *elt(*it);
if(elt && elt->getType()==type)
return ;
}
}
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> newElt(new MEDFileEquivalenceCellType(getFather(),type,da));
+ MCAuto<MEDFileEquivalenceCellType> newElt(new MEDFileEquivalenceCellType(getFather(),type,da));
_types.push_back(newElt);
}
std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileEquivalenceCell::getTypes() const
{
std::vector<INTERP_KERNEL::NormalizedCellType> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
+ for(std::vector< MCAuto<MEDFileEquivalenceCellType> >::const_iterator it=_types.begin();it!=_types.end();it++)
{
const MEDFileEquivalenceCellType *elt(*it);
if(elt)
MEDFILESAFECALLERRD0(MEDequivalenceCorrespondenceSize,(fid,meshName.c_str(),name.c_str(),dt,it,MED_CELL,typmai[i],&ncor));
if(ncor>0)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da(DataArrayInt::New());
+ MCAuto<DataArrayInt> 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<MEDFileEquivalenceCellType> ct(new MEDFileEquivalenceCellType(getFather(),typmai2[i],da));
+ MCAuto<MEDFileEquivalenceCellType> ct(new MEDFileEquivalenceCellType(getFather(),typmai2[i],da));
_types.push_back(ct);
}
}
return sizeof(MEDFileEquivalenceNode);
}
-void MEDFileEquivalenceNode::write(med_idt fid) const
+void MEDFileEquivalenceNode::writeLL(med_idt fid) const
{
- writeLL(fid,MED_NODE,MED_NONE);
+ writeAdvanced(fid,MED_NODE,MED_NONE);
}
-MEDFileEquivalenceNode *MEDFileEquivalenceNode::deepCpy(MEDFileEquivalencePair *owner) const
+MEDFileEquivalenceNode *MEDFileEquivalenceNode::deepCopy(MEDFileEquivalencePair *owner) const
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
+ MCAuto<DataArrayInt> da;
if(getArray())
- da=getArray()->deepCpy();
- MEDCouplingAutoRefCountObjectPtr<MEDFileEquivalenceNode> ret(new MEDFileEquivalenceNode(owner,da));
+ da=getArray()->deepCopy();
+ MCAuto<MEDFileEquivalenceNode> ret(new MEDFileEquivalenceNode(owner,da));
return ret.retn();
}