X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingPartDefinition.cxx;h=55c3422d7ce47ece771391c64b0ccae69a528df5;hb=af8a6b836ed960509fcb2d719d7396c187dfbf2b;hp=7523d938ba7d7ae2b906f66f1e9de27ae252d3bc;hpb=8b310135e68f42ce8763be87bdf79dcea5782b6e;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingPartDefinition.cxx b/src/MEDCoupling/MEDCouplingPartDefinition.cxx index 7523d938b..55c3422d7 100644 --- a/src/MEDCoupling/MEDCouplingPartDefinition.cxx +++ b/src/MEDCoupling/MEDCouplingPartDefinition.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 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 @@ -20,29 +20,32 @@ #include "MEDCouplingPartDefinition.hxx" -using namespace ParaMEDMEM; +#include +#include -PartDefinition *PartDefinition::New(int start, int stop, int step) +using namespace MEDCoupling; + +PartDefinition *PartDefinition::New(mcIdType start, mcIdType stop, mcIdType step) { return SlicePartDefinition::New(start,stop,step); } -PartDefinition *PartDefinition::New(DataArrayInt *listOfIds) +PartDefinition *PartDefinition::New(DataArrayIdType *listOfIds) { return DataArrayPartDefinition::New(listOfIds); } -PartDefinition *PartDefinition::Unserialize(std::vector& tinyInt, std::vector< MEDCouplingAutoRefCountObjectPtr >& bigArraysI) +PartDefinition *PartDefinition::Unserialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) { if(tinyInt.empty()) { - MEDCouplingAutoRefCountObjectPtr ret(DataArrayPartDefinition::New(bigArraysI.back())); + MCAuto ret(DataArrayPartDefinition::New(bigArraysI.back())); bigArraysI.pop_back(); return ret.retn(); } else if(tinyInt.size()==3) { - MEDCouplingAutoRefCountObjectPtr ret(SlicePartDefinition::New(tinyInt[0],tinyInt[1],tinyInt[2])); + MCAuto ret(SlicePartDefinition::New(tinyInt[0],tinyInt[1],tinyInt[2])); tinyInt.erase(tinyInt.begin(),tinyInt.begin()+3); return ret.retn(); } @@ -54,7 +57,7 @@ PartDefinition::~PartDefinition() { } -DataArrayPartDefinition *DataArrayPartDefinition::New(DataArrayInt *listOfIds) +DataArrayPartDefinition *DataArrayPartDefinition::New(DataArrayIdType *listOfIds) { return new DataArrayPartDefinition(listOfIds); } @@ -72,7 +75,7 @@ bool DataArrayPartDefinition::isEqual(const PartDefinition *other, std::string& what="DataArrayPartDefinition::isEqual : other is not DataArrayPartDefinition !"; return false; } - const DataArrayInt *arr0(_arr),*arr1(otherC->_arr); + const DataArrayIdType *arr0(_arr),*arr1(otherC->_arr); if(!arr0 && !arr1) return true; if((arr0 && !arr1) || (!arr0 && arr1)) @@ -90,15 +93,15 @@ bool DataArrayPartDefinition::isEqual(const PartDefinition *other, std::string& return true; } -DataArrayPartDefinition *DataArrayPartDefinition::deepCpy() const +DataArrayPartDefinition *DataArrayPartDefinition::deepCopy() const { - const DataArrayInt *arr(_arr); + const DataArrayIdType *arr(_arr); if(!arr) - throw INTERP_KERNEL::Exception("DataArrayPartDefinition::deepCpy : array is null !"); - return DataArrayPartDefinition::New(const_cast(arr)); + throw INTERP_KERNEL::Exception("DataArrayPartDefinition::deepCopy : array is null !"); + return DataArrayPartDefinition::New(const_cast(arr)); } -int DataArrayPartDefinition::getNumberOfElems() const +mcIdType DataArrayPartDefinition::getNumberOfElems() const { checkInternalArrayOK(); return _arr->getNumberOfTuples(); @@ -121,7 +124,7 @@ PartDefinition *DataArrayPartDefinition::operator+(const PartDefinition& other) std::string DataArrayPartDefinition::getRepr() const { std::ostringstream oss; oss << "DataArray Part : "; - const DataArrayInt *arr(_arr); + const DataArrayIdType *arr(_arr); if(arr) arr->reprQuickOverview(oss); else @@ -137,28 +140,28 @@ PartDefinition *DataArrayPartDefinition::composeWith(const PartDefinition *other { if(!other) throw INTERP_KERNEL::Exception("DataArrayPartDefinition::composeWith : input PartDef must be not NULL !"); - checkCoherency(); - other->checkCoherency(); + checkConsistencyLight(); + other->checkConsistencyLight(); const SlicePartDefinition *spd(dynamic_cast(other)); if(spd) {//special case for optim - int a(0),b(0),c(0); + mcIdType a(0),b(0),c(0); spd->getSlice(a,b,c); if(c==1) { - MEDCouplingAutoRefCountObjectPtr arr(DataArrayInt::New()); + MCAuto arr(DataArrayIdType::New()); arr->alloc(_arr->getNumberOfTuples(),1); - std::transform(_arr->begin(),_arr->end(),arr->getPointer(),std::bind2nd(std::plus(),a)); + std::transform(_arr->begin(),_arr->end(),arr->getPointer(),std::bind2nd(std::plus(),a)); return DataArrayPartDefinition::New(arr); } } // - MEDCouplingAutoRefCountObjectPtr arr1(other->toDAI()); - MEDCouplingAutoRefCountObjectPtr arr2(arr1->selectByTupleIdSafe(_arr->begin(),_arr->end())); + MCAuto arr1(other->toDAI()); + MCAuto arr2(arr1->selectByTupleIdSafe(_arr->begin(),_arr->end())); return DataArrayPartDefinition::New(arr2); } -void DataArrayPartDefinition::checkCoherency() const +void DataArrayPartDefinition::checkConsistencyLight() const { CheckInternalArrayOK(_arr); } @@ -170,8 +173,8 @@ void DataArrayPartDefinition::checkCoherency() const */ PartDefinition *DataArrayPartDefinition::tryToSimplify() const { - checkCoherency(); - int a(0),b(0),c(0); + checkConsistencyLight(); + mcIdType a(0),b(0),c(0); if(_arr->isRange(a,b,c)) { return SlicePartDefinition::New(a,b,c); @@ -184,21 +187,21 @@ PartDefinition *DataArrayPartDefinition::tryToSimplify() const } } -void DataArrayPartDefinition::serialize(std::vector& tinyInt, std::vector< MEDCouplingAutoRefCountObjectPtr >& bigArraysI) const +void DataArrayPartDefinition::serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const { bigArraysI.push_back(_arr); } -DataArrayInt *DataArrayPartDefinition::toDAI() const +DataArrayIdType *DataArrayPartDefinition::toDAI() const { checkInternalArrayOK(); - const DataArrayInt *arr(_arr); - DataArrayInt *arr2(const_cast(arr)); + const DataArrayIdType *arr(_arr); + DataArrayIdType *arr2(const_cast(arr)); arr2->incrRef(); return arr2; } -DataArrayPartDefinition::DataArrayPartDefinition(DataArrayInt *listOfIds) +DataArrayPartDefinition::DataArrayPartDefinition(DataArrayIdType *listOfIds) { CheckInternalArrayOK(listOfIds); _arr=listOfIds; @@ -210,7 +213,7 @@ void DataArrayPartDefinition::checkInternalArrayOK() const CheckInternalArrayOK(_arr); } -void DataArrayPartDefinition::CheckInternalArrayOK(const DataArrayInt *listOfIds) +void DataArrayPartDefinition::CheckInternalArrayOK(const DataArrayIdType *listOfIds) { if(!listOfIds || !listOfIds->isAllocated() || listOfIds->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayPartDefinition::CheckInternalArrayOK : Input list must be not null allocated and with one components !"); @@ -218,7 +221,7 @@ void DataArrayPartDefinition::CheckInternalArrayOK(const DataArrayInt *listOfIds void DataArrayPartDefinition::updateTime() const { - if((const DataArrayInt *)_arr) + if((const DataArrayIdType *)_arr) updateTimeWith(*_arr); } @@ -229,22 +232,22 @@ std::size_t DataArrayPartDefinition::getHeapMemorySizeWithoutChildren() const std::vector DataArrayPartDefinition::getDirectChildrenWithNull() const { - std::vector ret(1,(const DataArrayInt *)_arr); + std::vector ret(1,(const DataArrayIdType *)_arr); return ret; } DataArrayPartDefinition *DataArrayPartDefinition::add1(const DataArrayPartDefinition *other) const { - MEDCouplingAutoRefCountObjectPtr a1(toDAI()),a2(other->toDAI()); - MEDCouplingAutoRefCountObjectPtr a3(DataArrayInt::Aggregate(a1,a2,0)); + MCAuto a1(toDAI()),a2(other->toDAI()); + MCAuto a3(DataArrayIdType::Aggregate(a1,a2,0)); a3->sort(); return DataArrayPartDefinition::New(a3); } DataArrayPartDefinition *DataArrayPartDefinition::add2(const SlicePartDefinition *other) const { - MEDCouplingAutoRefCountObjectPtr a1(toDAI()),a2(other->toDAI()); - MEDCouplingAutoRefCountObjectPtr a3(DataArrayInt::Aggregate(a1,a2,0)); + MCAuto a1(toDAI()),a2(other->toDAI()); + MCAuto a3(DataArrayIdType::Aggregate(a1,a2,0)); a3->sort(); return DataArrayPartDefinition::New(a3); } @@ -253,7 +256,7 @@ DataArrayPartDefinition::~DataArrayPartDefinition() { } -SlicePartDefinition *SlicePartDefinition::New(int start, int stop, int step) +SlicePartDefinition *SlicePartDefinition::New(mcIdType start, mcIdType stop, mcIdType step) { return new SlicePartDefinition(start,stop,step); } @@ -280,17 +283,17 @@ bool SlicePartDefinition::isEqual(const PartDefinition *other, std::string& what return true; } -SlicePartDefinition *SlicePartDefinition::deepCpy() const +SlicePartDefinition *SlicePartDefinition::deepCopy() const { return SlicePartDefinition::New(_start,_stop,_step); } -DataArrayInt *SlicePartDefinition::toDAI() const +DataArrayIdType *SlicePartDefinition::toDAI() const { - return DataArrayInt::Range(_start,_stop,_step); + return DataArrayIdType::Range(_start,_stop,_step); } -int SlicePartDefinition::getNumberOfElems() const +mcIdType SlicePartDefinition::getNumberOfElems() const { return DataArray::GetNumberOfItemGivenBES(_start,_stop,_step,"SlicePartDefinition::getNumberOfElems"); } @@ -317,17 +320,17 @@ PartDefinition *SlicePartDefinition::composeWith(const PartDefinition *other) co { if(!other) throw INTERP_KERNEL::Exception("SlicePartDefinition::composeWith : input PartDef must be not NULL !"); - checkCoherency(); - other->checkCoherency(); - MEDCouplingAutoRefCountObjectPtr arr(other->toDAI()); - MEDCouplingAutoRefCountObjectPtr arr1(arr->selectByTupleId2(_start,_stop,_step)); + checkConsistencyLight(); + other->checkConsistencyLight(); + MCAuto arr(other->toDAI()); + MCAuto arr1(arr->selectByTupleIdSafeSlice(_start,_stop,_step)); return DataArrayPartDefinition::New(arr1); } /*! * Do nothing it is not a bug. */ -void SlicePartDefinition::checkCoherency() const +void SlicePartDefinition::checkConsistencyLight() const { } @@ -343,7 +346,7 @@ PartDefinition *SlicePartDefinition::tryToSimplify() const return ret; } -void SlicePartDefinition::serialize(std::vector& tinyInt, std::vector< MEDCouplingAutoRefCountObjectPtr >& bigArraysI) const +void SlicePartDefinition::serialize(std::vector& tinyInt, std::vector< MCAuto >& bigArraysI) const { tinyInt.push_back(_start); tinyInt.push_back(_stop); @@ -357,20 +360,20 @@ std::string SlicePartDefinition::getRepr() const return oss.str(); } -int SlicePartDefinition::getEffectiveStop() const +mcIdType SlicePartDefinition::getEffectiveStop() const { - int nbElems(DataArray::GetNumberOfItemGivenBES(_start,_stop,_step,"SlicePartDefinition::getEffectiveStop")); + mcIdType nbElems(DataArray::GetNumberOfItemGivenBES(_start,_stop,_step,"SlicePartDefinition::getEffectiveStop")); return _start+nbElems*_step; } -void SlicePartDefinition::getSlice(int& start, int& stop, int& step) const +void SlicePartDefinition::getSlice(mcIdType& start, mcIdType& stop, mcIdType& step) const { start=_start; stop=_stop; step=_step; } -SlicePartDefinition::SlicePartDefinition(int start, int stop, int step):_start(start),_stop(stop),_step(step) +SlicePartDefinition::SlicePartDefinition(mcIdType start, mcIdType stop, mcIdType step):_start(start),_stop(stop),_step(step) { } @@ -393,8 +396,8 @@ std::vector SlicePartDefinition::getDirectChildrenWithN DataArrayPartDefinition *SlicePartDefinition::add1(const DataArrayPartDefinition *other) const { - MEDCouplingAutoRefCountObjectPtr a1(toDAI()),a2(other->toDAI()); - MEDCouplingAutoRefCountObjectPtr a3(DataArrayInt::Aggregate(a1,a2,0)); + MCAuto a1(toDAI()),a2(other->toDAI()); + MCAuto a3(DataArrayIdType::Aggregate(a1,a2,0)); a3->sort(); return DataArrayPartDefinition::New(a3); } @@ -407,8 +410,8 @@ PartDefinition *SlicePartDefinition::add2(const SlicePartDefinition *other) cons } else { - MEDCouplingAutoRefCountObjectPtr a1(toDAI()),a2(other->toDAI()); - MEDCouplingAutoRefCountObjectPtr a3(DataArrayInt::Aggregate(a1,a2,0)); + MCAuto a1(toDAI()),a2(other->toDAI()); + MCAuto a3(DataArrayIdType::Aggregate(a1,a2,0)); a3->sort(); return DataArrayPartDefinition::New(a3); }