From a7c87361b787a7de84fe99ee89291b145374c07c Mon Sep 17 00:00:00 2001 From: emv Date: Wed, 6 Nov 2019 09:32:25 +0300 Subject: [PATCH] LOT1 Update: Change API to use size_t for components and mcIdType for tuples - Provide interfaces to make SWIG work - Use std::size_t for Components and mcIdType for Tuples --- src/MEDCoupling/MEDCoupling1GTUMesh.cxx | 2 +- .../MEDCouplingFieldDiscretization.cxx | 2 +- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 20 +- src/MEDCoupling/MEDCouplingFieldDouble.hxx | 10 +- src/MEDCoupling/MEDCouplingMemArray.cxx | 392 ++++++------ src/MEDCoupling/MEDCouplingMemArray.hxx | 135 ++-- src/MEDCoupling/MEDCouplingMemArray.txx | 576 +++++++++--------- src/MEDCoupling/MEDCouplingMemArrayChar.cxx | 20 +- src/MEDCoupling/MEDCouplingMemArrayFloat.cxx | 4 +- src/MEDCoupling/MEDCouplingSkyLineArray.cxx | 2 +- .../MEDCouplingTimeDiscretization.cxx | 18 +- .../MEDCouplingTimeDiscretization.hxx | 8 +- .../MEDCouplingUMesh_intersection.cxx | 4 +- .../Test/MEDCouplingBasicsTest3.cxx | 6 +- src/MEDLoader/MEDFileFieldOverView.cxx | 2 +- 15 files changed, 640 insertions(+), 561 deletions(-) diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index 19d0dfa6e..1c43f1f12 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -1753,7 +1753,7 @@ MEDCouplingCMesh *MEDCoupling1SGTUMesh::structurizeMe(DataArrayInt *& cellPerm, MCAuto cm(MEDCouplingCMesh::New()); for(int i=0;i tmp(1,i); + std::vector tmp(1,i); MCAuto elt(static_cast(getCoords()->keepSelectedComponents(tmp))); elt=elt->getDifferentValues(eps); elt->sort(true); diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index 525987d3c..cc790410d 100755 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -2678,7 +2678,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGaussNE::getMeasureField(c // std::set types=mesh->getAllGeoTypes(); MCAuto nbOfNodesPerCell=mesh->computeNbOfNodesPerCell(); - int nbTuples=nbOfNodesPerCell->accumulate(0); + int nbTuples=nbOfNodesPerCell->accumulate((std::size_t)0); nbOfNodesPerCell->computeOffsetsFull(); MCAuto arr=DataArrayDouble::New(); arr->alloc(nbTuples,1); ret->setArray(arr); diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 506b04fe2..ae95a9636 100755 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -701,7 +701,7 @@ void MEDCouplingFieldDouble::getWeightedAverageValue(double *res, bool isWAbs) c if(getArray()==0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::getWeightedAverageValue : no default array defined !"); MCAuto w=buildMeasureField(isWAbs); - double deno=w->getArray()->accumulate(0); + double deno=w->getArray()->accumulate((std::size_t)0); MCAuto arr=getArray()->deepCopy(); arr->multiplyEqual(w->getArray()); arr->accumulate(res); @@ -1497,7 +1497,7 @@ std::size_t MEDCouplingFieldDouble::getNumberOfComponents() const * \throw If the spatial discretization is not fully defined. * \sa MEDCouplingField::getNumberOfTuplesExpected */ -std::size_t MEDCouplingFieldDouble::getNumberOfTuples() const +mcIdType MEDCouplingFieldDouble::getNumberOfTuples() const { if(!_mesh) throw INTERP_KERNEL::Exception("Impossible to retrieve number of tuples because no mesh specified !"); @@ -2284,7 +2284,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxPerTuple() const * \param [in] dftValue - value assigned to new values added to \a this field. * \throw If \a this is not allocated. */ -void MEDCouplingFieldDouble::changeNbOfComponents(int newNbOfComp, double dftValue) +void MEDCouplingFieldDouble::changeNbOfComponents(std::size_t newNbOfComp, double dftValue) { timeDiscr()->changeNbOfComponents(newNbOfComp,dftValue); } @@ -2301,7 +2301,7 @@ void MEDCouplingFieldDouble::changeNbOfComponents(int newNbOfComp, double dftVal * \throw If a component index (\a i) is not valid: * \a i < 0 || \a i >= \a this->getNumberOfComponents(). */ -MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector& compoIds) const +MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector& compoIds) const { if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform keepSelectedComponents !"); @@ -2312,6 +2312,12 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std ret->setMesh(getMesh()); return ret.retn(); } +MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector& compoIds) const +{ + std::vector ids (compoIds.size()); + std::copy(compoIds.begin(), compoIds.end(), ids.begin()); + return keepSelectedComponents(ids); +} /*! @@ -2325,7 +2331,11 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std * \throw If \a compoIds.size() != \a a->getNumberOfComponents(). * \throw If \a compoIds[i] < 0 or \a compoIds[i] > \a this->getNumberOfComponents(). */ -void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds) +void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds) +{ + timeDiscr()->setSelectedComponents(f->timeDiscr(),compoIds); +} +void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds) { timeDiscr()->setSelectedComponents(f->timeDiscr(),compoIds); } diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 1ed1a122f..016a33842 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -90,7 +90,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func); MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func); MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const; - MEDCOUPLING_EXPORT std::size_t getNumberOfTuples() const; + MEDCOUPLING_EXPORT mcIdType getNumberOfTuples() const; MEDCOUPLING_EXPORT std::size_t getNumberOfValues() const; MEDCOUPLING_EXPORT void updateTime() const; MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; @@ -116,9 +116,11 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingFieldDouble *deviator() const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *magnitude() const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *maxPerTuple() const; - MEDCOUPLING_EXPORT void changeNbOfComponents(int newNbOfComp, double dftValue=0.); - MEDCOUPLING_EXPORT MEDCouplingFieldDouble *keepSelectedComponents(const std::vector& compoIds) const; - MEDCOUPLING_EXPORT void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds); + MEDCOUPLING_EXPORT void changeNbOfComponents(std::size_t newNbOfComp, double dftValue=0.); + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *keepSelectedComponents(const std::vector& compoIds) const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *keepSelectedComponents(const std::vector& compoIds) const; + MEDCOUPLING_EXPORT void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds); + MEDCOUPLING_EXPORT void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds); MEDCOUPLING_EXPORT void sortPerTuple(bool asc); MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *MergeFields(const std::vector& a); diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index d48a98c29..dd84f89fb 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -191,33 +191,47 @@ void DataArray::copyStringInfoFrom(const DataArray& other) _info_on_compo=other._info_on_compo; } -void DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds) +void DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds) { - mcIdType nbOfCompoOth=ToIdType(other.getNumberOfComponents()); - mcIdType newNbOfCompo=ToIdType(compoIds.size()); - for(mcIdType i=0;i ids (compoIds.size()); + std::copy(compoIds.begin(), compoIds.end(), ids.begin()); + copyPartOfStringInfoFrom(other, ids); +} + +void DataArray::copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds) +{ + std::size_t nbOfCompoOth=other.getNumberOfComponents(); + std::size_t newNbOfCompo=compoIds.size(); + for(std::size_t i=0;i=nbOfCompoOth || compoIds[i]<0) { std::ostringstream oss; oss << "Specified component id is out of range (" << compoIds[i] << ") compared with nb of actual components (" << nbOfCompoOth << ")"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - for(mcIdType i=0;i& compoIds, const DataArray& other) +void DataArray::copyPartOfStringInfoFrom2(const std::vector& compoIds, const DataArray& other) +{ + std::vector ids (compoIds.size()); + std::copy(compoIds.begin(), compoIds.end(), ids.begin()); + copyPartOfStringInfoFrom2(ids, other); +} + +void DataArray::copyPartOfStringInfoFrom2(const std::vector& compoIds, const DataArray& other) { if(compoIds.size()!=other.getNumberOfComponents()) throw INTERP_KERNEL::Exception("Given compoIds has not the same size as number of components of given array !"); - mcIdType partOfCompoToSet=ToIdType(compoIds.size()); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - for(mcIdType i=0;i=nbOfCompo || compoIds[i]<0) { std::ostringstream oss; oss << "Specified component id is out of range (" << compoIds[i] << ") compared with nb of actual components (" << nbOfCompo << ")"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - for(mcIdType i=0;i DataArray::getUnitsOnComponent() const * \return std::string - a string containing the information on \a i-th component. * \throw If \a i is not a valid component index. */ -std::string DataArray::getInfoOnComponent(int i) const +std::string DataArray::getInfoOnComponent(std::size_t i) const { - if(i<(int)_info_on_compo.size() && i>=0) + if(i<_info_on_compo.size()) return _info_on_compo[i]; else { @@ -377,9 +391,9 @@ std::string DataArray::getInfoOnComponent(int i) const * \return std::string - a string containing the var information, or the full info. * \throw If \a i is not a valid component index. */ -std::string DataArray::getVarOnComponent(int i) const +std::string DataArray::getVarOnComponent(std::size_t i) const { - if(i<(int)_info_on_compo.size() && i>=0) + if(i<_info_on_compo.size()) { return GetVarNameFromInfo(_info_on_compo[i]); } @@ -402,9 +416,9 @@ std::string DataArray::getVarOnComponent(int i) const * \return std::string - a string containing the unit information, if any, or "". * \throw If \a i is not a valid component index. */ -std::string DataArray::getUnitOnComponent(int i) const +std::string DataArray::getUnitOnComponent(std::size_t i) const { - if(i<(int)_info_on_compo.size() && i>=0) + if(i<_info_on_compo.size()) { return GetUnitFromInfo(_info_on_compo[i]); } @@ -543,9 +557,9 @@ DataArray *DataArray::Aggregate(const std::vector& arrs) * \param [in] info - the string containing the information. * \throw If \a i is not a valid component index. */ -void DataArray::setInfoOnComponent(int i, const std::string& info) +void DataArray::setInfoOnComponent(std::size_t i, const std::string& info) { - if(i<(int)_info_on_compo.size() && i>=0) + if(i<_info_on_compo.size()) _info_on_compo[i]=info; else { @@ -581,18 +595,18 @@ void DataArray::setInfoAndChangeNbOfCompo(const std::vector& info) _info_on_compo=info; } -void DataArray::checkNbOfTuples(int nbOfTuples, const std::string& msg) const +void DataArray::checkNbOfTuples(mcIdType nbOfTuples, const std::string& msg) const { - if((int)getNumberOfTuples()!=nbOfTuples) + if(getNumberOfTuples()!=nbOfTuples) { std::ostringstream oss; oss << msg << " : mismatch number of tuples : expected " << nbOfTuples << " having " << getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } } -void DataArray::checkNbOfComps(int nbOfCompo, const std::string& msg) const +void DataArray::checkNbOfComps(std::size_t nbOfCompo, const std::string& msg) const { - if((int)getNumberOfComponents()!=nbOfCompo) + if (getNumberOfComponents()!=nbOfCompo) { std::ostringstream oss; oss << msg << " : mismatch number of components : expected " << nbOfCompo << " having " << getNumberOfComponents() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -622,7 +636,7 @@ void DataArray::checkNbOfTuplesAndComp(const DataArray& other, const std::string } } -void DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const +void DataArray::checkNbOfTuplesAndComp(mcIdType nbOfTuples, std::size_t nbOfCompo, const std::string& msg) const { checkNbOfTuples(nbOfTuples,msg); checkNbOfComps(nbOfCompo,msg); @@ -858,7 +872,7 @@ bool DataArrayDouble::isMonotonic(bool increasing, double eps) const checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::isMonotonic : only supported with 'this' array with ONE component !"); - mcIdType nbOfElements=ToIdType(getNumberOfTuples()); + mcIdType nbOfElements(getNumberOfTuples()); const double *ptr=getConstPointer(); if(nbOfElements==0) return true; @@ -925,8 +939,8 @@ void DataArrayDouble::writeVTK(std::ostream& ofs, int indent, const std::string& void DataArrayDouble::reprCppStream(const std::string& varName, std::ostream& stream) const { - mcIdType nbTuples=ToIdType(getNumberOfTuples()); - mcIdType nbComp=ToIdType(getNumberOfComponents()); + mcIdType nbTuples=getNumberOfTuples(); + std::size_t nbComp=getNumberOfComponents(); const double *data(getConstPointer()); stream.precision(17); stream << "DataArrayDouble *" << varName << "=DataArrayDouble::New();" << std::endl; @@ -954,7 +968,7 @@ void DataArrayDouble::reprQuickOverview(std::ostream& stream) const std::size_t nbOfCompo(_info_on_compo.size()); if(nbOfCompo>=1) { - std::size_t nbOfTuples(getNumberOfTuples()); + mcIdType nbOfTuples(getNumberOfTuples()); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR); } @@ -968,8 +982,8 @@ void DataArrayDouble::reprQuickOverview(std::ostream& stream) const void DataArrayDouble::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const double *data=begin(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); - mcIdType nbOfCompo=ToIdType(_info_on_compo.size()); + mcIdType nbOfTuples(getNumberOfTuples()); + std::size_t nbOfCompo(_info_on_compo.size()); std::ostringstream oss2; oss2 << "["; oss2.precision(17); std::string oss2Str(oss2.str()); @@ -979,7 +993,7 @@ void DataArrayDouble::reprQuickOverviewData(std::ostream& stream, std::size_t ma if(nbOfCompo>1) { oss2 << "("; - for(mcIdType j=0;j a=DataArrayDouble::Aggregate(this,other); DataArrayInt *c=0,*ci=0; - a->findCommonTuples(prec,ToIdType(getNumberOfTuples()),c,ci); + a->findCommonTuples(prec,getNumberOfTuples(),c,ci); MCAuto cSafe(c),ciSafe(ci); int newNbOfTuples=-1; - MCAuto ids=DataArrayInt::ConvertIndexArrayToO2N(ToIdType(a->getNumberOfTuples()),c->begin(),ci->begin(),ci->end(),newNbOfTuples); - MCAuto ret1=ids->selectByTupleIdSafeSlice(ToIdType(getNumberOfTuples()),ToIdType(a->getNumberOfTuples()),1); + MCAuto ids=DataArrayInt::ConvertIndexArrayToO2N(a->getNumberOfTuples(),c->begin(),ci->begin(),ci->end(),newNbOfTuples); + MCAuto ret1=ids->selectByTupleIdSafeSlice(getNumberOfTuples(),a->getNumberOfTuples(),1); tupleIds=ret1.retn(); - return newNbOfTuples==ToIdType(getNumberOfTuples()); + return newNbOfTuples==getNumberOfTuples(); } /*! @@ -1106,11 +1120,11 @@ bool DataArrayDouble::areIncludedInMe(const DataArrayDouble *other, double prec, void DataArrayDouble::findCommonTuples(double prec, int limitTupleId, DataArrayInt *&comm, DataArrayInt *&commIndex) const { checkAllocated(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); + std::size_t nbOfCompo=getNumberOfComponents(); if ((nbOfCompo<1) || (nbOfCompo>4)) //test before work throw INTERP_KERNEL::Exception("DataArrayDouble::findCommonTuples : Unexpected spacedim of coords. Must be 1, 2, 3 or 4."); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples(getNumberOfTuples()); // MCAuto c(DataArrayInt::New()),cI(DataArrayInt::New()); c->alloc(0,1); cI->pushBackSilent(0); switch(nbOfCompo) @@ -1147,15 +1161,15 @@ void DataArrayDouble::findCommonTuples(double prec, int limitTupleId, DataArrayI double DataArrayDouble::minimalDistanceTo(const DataArrayDouble *other, int& thisTupleId, int& otherTupleId) const { MCAuto part1=findClosestTupleId(other); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - mcIdType otherNbTuples=ToIdType(other->getNumberOfTuples()); + std::size_t nbOfCompo=getNumberOfComponents(); + mcIdType otherNbTuples=other->getNumberOfTuples(); const double *thisPt(begin()),*otherPt(other->begin()); const int *part1Pt(part1->begin()); double ret=std::numeric_limits::max(); for(mcIdType i=0;igetNumberOfComponents() << "! Should be equal !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbOfTuples=ToIdType(other->getNumberOfTuples()); - mcIdType thisNbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples(other->getNumberOfTuples()); + mcIdType thisNbOfTuples(getNumberOfTuples()); MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfTuples,1); double bounds[6]; getMinMaxPerComponent(bounds); @@ -1195,7 +1209,7 @@ DataArrayInt *DataArrayDouble::findClosestTupleId(const DataArrayDouble *other) double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2])),zDelta(fabs(bounds[5]-bounds[4])); double delta=std::max(xDelta,yDelta); delta=std::max(delta,zDelta); double characSize=pow((delta*delta*delta)/((double)thisNbOfTuples),1./3.); - BBTreePts<3,int> myTree(begin(),0,0,ToIdType(getNumberOfTuples()),characSize*1e-12); + BBTreePts<3,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12); FindClosestTupleIdAlg<3>(myTree,3.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer()); break; } @@ -1204,14 +1218,14 @@ DataArrayInt *DataArrayDouble::findClosestTupleId(const DataArrayDouble *other) double xDelta(fabs(bounds[1]-bounds[0])),yDelta(fabs(bounds[3]-bounds[2])); double delta=std::max(xDelta,yDelta); double characSize=sqrt(delta/(double)thisNbOfTuples); - BBTreePts<2,int> myTree(begin(),0,0,ToIdType(getNumberOfTuples()),characSize*1e-12); + BBTreePts<2,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12); FindClosestTupleIdAlg<2>(myTree,2.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer()); break; } case 1: { double characSize=fabs(bounds[1]-bounds[0])/thisNbOfTuples; - BBTreePts<1,int> myTree(begin(),0,0,ToIdType(getNumberOfTuples()),characSize*1e-12); + BBTreePts<1,int> myTree(begin(),0,0,getNumberOfTuples(),characSize*1e-12); FindClosestTupleIdAlg<1>(myTree,1.*characSize*characSize,other->begin(),nbOfTuples,begin(),thisNbOfTuples,ret->getPointer()); break; } @@ -1239,7 +1253,8 @@ DataArrayInt *DataArrayDouble::computeNbOfInteractionsWith(const DataArrayDouble throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : input array is NULL !"); if(!isAllocated() || !otherBBoxFrmt->isAllocated()) throw INTERP_KERNEL::Exception("DataArrayDouble::computeNbOfInteractionsWith : this and input array must be allocated !"); - std::size_t nbOfComp(getNumberOfComponents()),nbOfTuples(getNumberOfTuples()); + std::size_t nbOfComp(getNumberOfComponents()); + mcIdType nbOfTuples(getNumberOfTuples()); if(nbOfComp!=otherBBoxFrmt->getNumberOfComponents()) { std::ostringstream oss; oss << "DataArrayDouble::computeNbOfInteractionsWith : this number of components (" << nbOfComp << ") must be equal to the number of components of input array (" << otherBBoxFrmt->getNumberOfComponents() << ") !"; @@ -1257,22 +1272,22 @@ DataArrayInt *DataArrayDouble::computeNbOfInteractionsWith(const DataArrayDouble { case 3: { - BBTree<3,int> bbt(otherBBoxFrmt->begin(),0,0,ToIdType(otherBBoxFrmt->getNumberOfTuples()),eps); - for(std::size_t i=0;i bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps); + for(mcIdType i=0;i bbt(otherBBoxFrmt->begin(),0,0,ToIdType(otherBBoxFrmt->getNumberOfTuples()),eps); - for(std::size_t i=0;i bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps); + for(mcIdType i=0;i bbt(otherBBoxFrmt->begin(),0,0,ToIdType(otherBBoxFrmt->getNumberOfTuples()),eps); - for(std::size_t i=0;i bbt(otherBBoxFrmt->begin(),0,0,otherBBoxFrmt->getNumberOfTuples(),eps); + for(mcIdType i=0;i c(c0),cI(cI0); int newNbOfTuples=-1; - MCAuto o2n=DataArrayInt::ConvertIndexArrayToO2N(ToIdType(getNumberOfTuples()),c0->begin(),cI0->begin(),cI0->end(),newNbOfTuples); + MCAuto o2n=DataArrayInt::ConvertIndexArrayToO2N(getNumberOfTuples(),c0->begin(),cI0->begin(),cI0->end(),newNbOfTuples); return renumberAndReduce(o2n->getConstPointer(),newNbOfTuples); } @@ -1329,22 +1344,27 @@ DataArrayDouble *DataArrayDouble::getDifferentValues(double prec, int limitTuple * \ref py_mcdataarraydouble_setselectedcomponents "Here is a Python example". * \endif */ -void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds) +void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds) { if(!a) throw INTERP_KERNEL::Exception("DataArrayDouble::setSelectedComponents : input DataArrayDouble is NULL !"); checkAllocated(); copyPartOfStringInfoFrom2(compoIds,*a); std::size_t partOfCompoSz=compoIds.size(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(std::min(getNumberOfTuples(),a->getNumberOfTuples())); + std::size_t nbOfCompo=getNumberOfComponents(); + mcIdType nbOfTuples=std::min(getNumberOfTuples(),a->getNumberOfTuples()); const double *ac=a->getConstPointer(); double *nc=getPointer(); for(mcIdType i=0;i& compoIds) +{ + std::vector ids (compoIds.size()); + std::copy(compoIds.begin(), compoIds.end(), ids.begin()); + setSelectedComponents (a, ids); +} /*! * Checks if 0.0 value is present in \a this array. If it is the case, an exception * is thrown. @@ -1374,17 +1394,17 @@ void DataArrayDouble::checkNoNullValues() const void DataArrayDouble::getMinMaxPerComponent(double *bounds) const { checkAllocated(); - mcIdType dim=ToIdType(getNumberOfComponents()); - for (mcIdType idim=0; idim::max(); bounds[idim*2+1]=-std::numeric_limits::max(); } const double *ptr=getConstPointer(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); for(mcIdType i=0;iptr[i*dim+idim]) { @@ -1411,14 +1431,14 @@ DataArrayDouble *DataArrayDouble::computeBBoxPerTuple(double epsilon) const { checkAllocated(); const double *dataPtr=getConstPointer(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); + std::size_t nbOfCompo=getNumberOfComponents(); + mcIdType nbTuples=getNumberOfTuples(); MCAuto bbox=DataArrayDouble::New(); bbox->alloc(nbTuples,2*nbOfCompo); double *bboxPtr=bbox->getPointer(); for(mcIdType i=0;icheckAllocated(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - mcIdType otherNbOfCompo=ToIdType(other->getNumberOfComponents()); + std::size_t nbOfCompo=getNumberOfComponents(); + std::size_t otherNbOfCompo=other->getNumberOfComponents(); if(nbOfCompo!=otherNbOfCompo) throw INTERP_KERNEL::Exception("DataArrayDouble::computeTupleIdsNearTuples : number of components should be equal between this and other !"); - mcIdType nbOfTuplesOther=ToIdType(other->getNumberOfTuples()); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuplesOther=other->getNumberOfTuples(); + mcIdType nbOfTuples=getNumberOfTuples(); MCAuto cArr(DataArrayInt::New()),cIArr(DataArrayInt::New()); cArr->alloc(0,1); cIArr->pushBackSilent(0); switch(nbOfCompo) { @@ -1493,10 +1513,10 @@ void DataArrayDouble::computeTupleIdsNearTuples(const DataArrayDouble *other, do void DataArrayDouble::recenterForMaxPrecision(double eps) { checkAllocated(); - mcIdType dim=ToIdType(getNumberOfComponents()); + std::size_t dim=getNumberOfComponents(); std::vector bounds(2*dim); getMinMaxPerComponent(&bounds[0]); - for(mcIdType i=0;i 0 !"); const double *vals=getConstPointer(); @@ -1634,12 +1654,12 @@ double DataArrayDouble::normMax() const void DataArrayDouble::normMaxPerComponent(double * res) const { checkAllocated(); - std::size_t nbOfTuples(getNumberOfTuples()); - mcIdType nbOfCompos=ToIdType(getNumberOfComponents()); + mcIdType nbOfTuples(getNumberOfTuples()); + std::size_t nbOfCompos(getNumberOfComponents()); std::fill(res, res+nbOfCompos, -1.0); const double *pt(getConstPointer()); - for(std::size_t i=0;ires[j]) @@ -1682,8 +1702,8 @@ void DataArrayDouble::accumulate(double *res) const { checkAllocated(); const double *ptr=getConstPointer(); - mcIdType nbTuple=ToIdType(getNumberOfTuples()); - mcIdType nbComps=ToIdType(getNumberOfComponents()); + mcIdType nbTuple(getNumberOfTuples()); + std::size_t nbComps(getNumberOfComponents()); std::fill(res,res+nbComps,0.); for(mcIdType i=0;i()); @@ -1706,9 +1726,9 @@ void DataArrayDouble::accumulate(double *res) const double DataArrayDouble::distanceToTuple(const double *tupleBg, const double *tupleEnd, int& tupleId) const { checkAllocated(); - mcIdType nbTuple=ToIdType(getNumberOfTuples()); - mcIdType nbComps=ToIdType(getNumberOfComponents()); - if(nbComps!=(int)std::distance(tupleBg,tupleEnd)) + mcIdType nbTuple(getNumberOfTuples()); + std::size_t nbComps(getNumberOfComponents()); + if(nbComps!=std::distance(tupleBg,tupleEnd)) { std::ostringstream oss; oss << "DataArrayDouble::distanceToTuple : size of input tuple is " << std::distance(tupleBg,tupleEnd) << " should be equal to the number of components in this : " << nbComps << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } if(nbTuple==0) throw INTERP_KERNEL::Exception("DataArrayDouble::distanceToTuple : no tuple in this ! No distance to compute !"); @@ -1718,7 +1738,7 @@ double DataArrayDouble::distanceToTuple(const double *tupleBg, const double *tup for(mcIdType i=0;i=ret0) continue; @@ -1736,13 +1756,13 @@ double DataArrayDouble::distanceToTuple(const double *tupleBg, const double *tup * \throw If \a the condition ( 0 <= \a compId < \a this->getNumberOfComponents() ) is * not respected. */ -double DataArrayDouble::accumulate(int compId) const +double DataArrayDouble::accumulate(std::size_t compId) const { checkAllocated(); const double *ptr=getConstPointer(); - mcIdType nbTuple=ToIdType(getNumberOfTuples()); - mcIdType nbComps=ToIdType(getNumberOfComponents()); - if(compId<0 || compId>=nbComps) + mcIdType nbTuple(getNumberOfTuples()); + std::size_t nbComps(getNumberOfComponents()); + if(compId>=nbComps) throw INTERP_KERNEL::Exception("DataArrayDouble::accumulate : Invalid compId specified : No such nb of components !"); double ret=0.; for(mcIdType i=0;i DataArrayDouble::cumSum() const { checkAllocated(); checkNbOfComps(1,"DataArrayDouble::cumSum : this is expected to be single component"); - mcIdType nbOfTuple=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuple(getNumberOfTuples()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTuple+1,1); double *ptr(ret->getPointer()); ptr[0]=0.; @@ -1848,12 +1868,12 @@ DataArrayDouble *DataArrayDouble::fromPolarToCart() const std::size_t nbOfComp(getNumberOfComponents()); if(nbOfComp!=2) throw INTERP_KERNEL::Exception("DataArrayDouble::fromPolarToCart : must be an array with exactly 2 components !"); - std::size_t nbOfTuple(getNumberOfTuples()); + mcIdType nbOfTuple(getNumberOfTuples()); DataArrayDouble *ret(DataArrayDouble::New()); ret->alloc(nbOfTuple,2); double *w(ret->getPointer()); const double *wIn(getConstPointer()); - for(std::size_t i=0;ialloc(getNumberOfTuples(),3); double *w(ret->getPointer()); const double *wIn(getConstPointer()); - for(std::size_t i=0;ialloc(getNumberOfTuples(),3); double *w(ret->getPointer()); const double *wIn(getConstPointer()); - for(std::size_t i=0;i ret(DataArrayDouble::New()); checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()),nbTuples(getNumberOfTuples()); + std::size_t nbOfComp(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); if(nbOfComp!=2) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToPolar : must be an array with exactly 2 components !"); ret->alloc(nbTuples,2); double *retPtr(ret->getPointer()); const double *ptr(begin()); - for(std::size_t i=0;i ret(DataArrayDouble::New()); checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()),nbTuples(getNumberOfTuples()); + std::size_t nbOfComp(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCyl : must be an array with exactly 3 components !"); ret->alloc(nbTuples,3); double *retPtr(ret->getPointer()); const double *ptr(begin()); - for(std::size_t i=0;i ret(DataArrayDouble::New()); checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()),nbTuples(getNumberOfTuples()); + std::size_t nbOfComp(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToSpher : must be an array with exactly 3 components !"); ret->alloc(nbTuples,3); double *retPtr(ret->getPointer()); const double *ptr(begin()); - for(std::size_t i=0;i ret(DataArrayDouble::New()); checkAllocated(); coords->checkAllocated(); - std::size_t nbOfComp(getNumberOfComponents()),nbTuples(getNumberOfTuples()); + std::size_t nbOfComp(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::fromCartToCylGiven : must be an array with exactly 3 components !"); if(coords->getNumberOfComponents()!=3) @@ -2071,7 +2095,7 @@ DataArrayDouble *DataArrayDouble::fromCartToCylGiven(const DataArrayDouble *coor double Ur[3],Uteta[3],Uz[3],*retPtr(ret->getPointer()); const double *coo(coords->begin()),*vectField(begin()); std::transform(vect,vect+3,Uz,std::bind2nd(std::multiplies(),1./magOfVect)); - for(std::size_t i=0;i()); Uteta[0]=Uz[1]*Ur[2]-Uz[2]*Ur[1]; Uteta[1]=Uz[2]*Ur[0]-Uz[0]*Ur[2]; Uteta[2]=Uz[0]*Ur[1]-Uz[1]*Ur[0]; @@ -2102,11 +2126,11 @@ DataArrayDouble *DataArrayDouble::doublyContractedProduct() const if(nbOfComp!=6) throw INTERP_KERNEL::Exception("DataArrayDouble::doublyContractedProduct : must be an array with exactly 6 components !"); DataArrayDouble *ret=DataArrayDouble::New(); - std::size_t nbOfTuple=getNumberOfTuples(); + mcIdType nbOfTuple=getNumberOfTuples(); ret->alloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); - for(std::size_t i=0;ialloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); switch(getNumberOfComponents()) { case 6: - for(std::size_t i=0;ialloc(nbOfTuple,3); const double *src=getConstPointer(); double *dest=ret->getPointer(); - for(std::size_t i=0;ialloc(nbOfTuple,9); const double *src=getConstPointer(); double *dest=ret->getPointer(); - for(std::size_t i=0;ialloc(nbOfTuple,nbOfComp); const double *src=getConstPointer(); double *dest=ret->getPointer(); if(nbOfComp==6) - for(std::size_t i=0;ialloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); if(nbOfComp==6) - for(std::size_t i=0;ialloc(nbOfTuple,6); const double *src=getConstPointer(); double *dest=ret->getPointer(); - for(std::size_t i=0;ialloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); - for(std::size_t i=0;i ret=DataArrayDouble::New(); - mcIdType nbOfTuple=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuple(getNumberOfTuples()); ret->alloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret->getPointer(); @@ -2399,10 +2423,10 @@ DataArrayDouble *DataArrayDouble::maxPerTuple() const DataArrayDouble *DataArrayDouble::maxPerTupleWithCompoId(DataArrayInt* &compoIdOfMaxPerTuple) const { checkAllocated(); - mcIdType nbOfComp=ToIdType(getNumberOfComponents()); + std::size_t nbOfComp(getNumberOfComponents()); MCAuto ret0=DataArrayDouble::New(); MCAuto ret1=DataArrayInt::New(); - mcIdType nbOfTuple=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuple=getNumberOfTuples(); ret0->alloc(nbOfTuple,1); ret1->alloc(nbOfTuple,1); const double *src=getConstPointer(); double *dest=ret0->getPointer(); int *dest1=ret1->getPointer(); @@ -2433,8 +2457,8 @@ DataArrayDouble *DataArrayDouble::maxPerTupleWithCompoId(DataArrayInt* &compoIdO DataArrayDouble *DataArrayDouble::buildEuclidianDistanceDenseMatrix() const { checkAllocated(); - mcIdType nbOfComp=ToIdType(getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + std::size_t nbOfComp(getNumberOfComponents()); + mcIdType nbOfTuples(getNumberOfTuples()); const double *inData=getConstPointer(); MCAuto ret=DataArrayDouble::New(); ret->alloc(nbOfTuples*nbOfTuples,1); @@ -2445,7 +2469,7 @@ DataArrayDouble *DataArrayDouble::buildEuclidianDistanceDenseMatrix() const for(mcIdType j=i+1;jcheckAllocated(); - mcIdType nbOfComp=ToIdType(getNumberOfComponents()); - mcIdType otherNbOfComp=ToIdType(other->getNumberOfComponents()); + std::size_t nbOfComp(getNumberOfComponents()); + std::size_t otherNbOfComp(other->getNumberOfComponents()); if(nbOfComp!=otherNbOfComp) { std::ostringstream oss; oss << "DataArrayDouble::buildEuclidianDistanceDenseMatrixWith : this nb of compo=" << nbOfComp << " and other nb of compo=" << otherNbOfComp << ". It should match !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); - mcIdType otherNbOfTuples=ToIdType(other->getNumberOfTuples()); + mcIdType nbOfTuples(getNumberOfTuples()); + mcIdType otherNbOfTuples(other->getNumberOfTuples()); const double *inData=getConstPointer(); const double *inDataOther=other->getConstPointer(); MCAuto ret=DataArrayDouble::New(); @@ -2496,7 +2520,7 @@ DataArrayDouble *DataArrayDouble::buildEuclidianDistanceDenseMatrixWith(const Da for(mcIdType j=0;jalloc(nbOfTuples,nbOfComp); const double *ptr=getConstPointer(); double *ptrToFill=newArr->getPointer(); @@ -2736,11 +2760,11 @@ DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const std::string& fun */ DataArrayDouble *DataArrayDouble::applyFunc(const std::string& func, bool isSafe) const { - mcIdType nbOfComp=ToIdType(getNumberOfComponents()); + std::size_t nbOfComp(getNumberOfComponents()); if(nbOfComp<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::applyFunc : output number of component must be > 0 !"); checkAllocated(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples(getNumberOfTuples()); MCAuto newArr(DataArrayDouble::New()); newArr->alloc(nbOfTuples,nbOfComp); INTERP_KERNEL::ExprParser expr(func); @@ -2771,7 +2795,7 @@ DataArrayDouble *DataArrayDouble::applyFunc(const std::string& func, bool isSafe { for(mcIdType i=0;i 0 !"); checkAllocated(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples(getNumberOfTuples()); INTERP_KERNEL::ExprParser expr(func); expr.parse(); std::set vars; @@ -2856,7 +2880,7 @@ void DataArrayDouble::applyFuncOnThis(const std::string& func, bool isSafe) { for(mcIdType i=0;i 0 !"); std::vector varsOrder2(varsOrder); - mcIdType oldNbOfComp=ToIdType(getNumberOfComponents()); - for(int i=(int)varsOrder.size();i vars; expr.getTrueSetOfVars(vars); - if((int)vars.size()>oldNbOfComp) + if(vars.size()>oldNbOfComp) { std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are "; oss << vars.size() << " variables : "; @@ -2958,7 +2982,7 @@ DataArrayDouble *DataArrayDouble::applyFuncNamedCompo(int nbOfComp, const std::v std::vector stck; for(int iComp=0;iCompgetPointer()+iComp; @@ -3007,7 +3031,7 @@ void DataArrayDouble::applyFuncFast32(const std::string& func) // double *ptr=getPointer(); std::size_t nbOfComp=getNumberOfComponents(); - std::size_t nbOfTuples=getNumberOfTuples(); + mcIdType nbOfTuples=getNumberOfTuples(); std::size_t nbOfElems=nbOfTuples*nbOfComp; for(std::size_t i=0;i DataArrayDouble::symmetry3DPlane(const double point[3], checkAllocated(); if(getNumberOfComponents()!=3) throw INTERP_KERNEL::Exception("DataArrayDouble::symmetry3DPlane : this is excepted to have 3 components !"); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); + mcIdType nbTuples(getNumberOfTuples()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbTuples,3); Symmetry3DPlane(point,normalVector,nbTuples,begin(),ret->getPointer()); @@ -3076,7 +3100,7 @@ DataArrayInt *DataArrayDouble::findIdsInRange(double vmin, double vmax) const throw INTERP_KERNEL::Exception("DataArrayDouble::findIdsInRange : this must have exactly one component !"); const double *cptr(begin()); MCAuto ret(DataArrayInt::New()); ret->alloc(0,1); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples(getNumberOfTuples()); for(mcIdType i=0;i=vmin && *cptr<=vmax) ret->pushBackSilent(i); @@ -3102,7 +3126,7 @@ DataArrayInt *DataArrayDouble::findIdsNotInRange(double vmin, double vmax) const throw INTERP_KERNEL::Exception("DataArrayDouble::findIdsNotInRange : this must have exactly one component !"); const double *cptr(begin()); MCAuto ret(DataArrayInt::New()); ret->alloc(0,1); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples(getNumberOfTuples()); for(mcIdType i=0;ivmax) ret->pushBackSilent(i); @@ -3155,7 +3179,7 @@ DataArrayDouble *DataArrayDouble::Aggregate(const std::vector::const_iterator it=a.begin(); std::size_t nbOfComp((*it)->getNumberOfComponents()); - std::size_t nbt=(*it++)->getNumberOfTuples(); + mcIdType nbt=(*it++)->getNumberOfTuples(); for(int i=1;it!=a.end();it++,i++) { if((*it)->getNumberOfComponents()!=nbOfComp) @@ -3196,7 +3220,7 @@ DataArrayDouble *DataArrayDouble::Dot(const DataArrayDouble *a1, const DataArray std::size_t nbOfComp(a1->getNumberOfComponents()); if(nbOfComp!=a2->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Nb of components mismatch for array Dot !"); - std::size_t nbOfTuple(a1->getNumberOfTuples()); + mcIdType nbOfTuple(a1->getNumberOfTuples()); if(nbOfTuple!=a2->getNumberOfTuples()) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Dot !"); DataArrayDouble *ret=DataArrayDouble::New(); @@ -3241,14 +3265,14 @@ DataArrayDouble *DataArrayDouble::CrossProduct(const DataArrayDouble *a1, const throw INTERP_KERNEL::Exception("Nb of components mismatch for array crossProduct !"); if(nbOfComp!=3) throw INTERP_KERNEL::Exception("Nb of components must be equal to 3 for array crossProduct !"); - std::size_t nbOfTuple(a1->getNumberOfTuples()); + mcIdType nbOfTuple(a1->getNumberOfTuples()); if(nbOfTuple!=a2->getNumberOfTuples()) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array crossProduct !"); DataArrayDouble *ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,3); double *retPtr=ret->getPointer(); const double *a1Ptr(a1->begin()),*a2Ptr(a2->begin()); - for(std::size_t i=0;igetNumberOfComponents()); if(nbOfComp!=a2->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Nb of components mismatch for array Max !"); - std::size_t nbOfTuple(a1->getNumberOfTuples()); + mcIdType nbOfTuple(a1->getNumberOfTuples()); if(nbOfTuple!=a2->getNumberOfTuples()) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Max !"); MCAuto ret(DataArrayDouble::New()); @@ -3312,7 +3336,7 @@ DataArrayDouble *DataArrayDouble::Min(const DataArrayDouble *a1, const DataArray std::size_t nbOfComp(a1->getNumberOfComponents()); if(nbOfComp!=a2->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Nb of components mismatch for array min !"); - std::size_t nbOfTuple(a1->getNumberOfTuples()); + mcIdType nbOfTuple(a1->getNumberOfTuples()); if(nbOfTuple!=a2->getNumberOfTuples()) throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array min !"); MCAuto ret(DataArrayDouble::New()); @@ -3344,8 +3368,8 @@ DataArrayDouble *DataArrayDouble::Pow(const DataArrayDouble *a1, const DataArray { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DataArrayDouble::Pow : at least one of input instances is null !"); - std::size_t nbOfTuple=a1->getNumberOfTuples(); - std::size_t nbOfTuple2=a2->getNumberOfTuples(); + mcIdType nbOfTuple=a1->getNumberOfTuples(); + mcIdType nbOfTuple2=a2->getNumberOfTuples(); std::size_t nbOfComp=a1->getNumberOfComponents(); std::size_t nbOfComp2=a2->getNumberOfComponents(); if(nbOfTuple!=nbOfTuple2) @@ -3355,7 +3379,7 @@ DataArrayDouble *DataArrayDouble::Pow(const DataArrayDouble *a1, const DataArray MCAuto ret=DataArrayDouble::New(); ret->alloc(nbOfTuple,1); const double *ptr1(a1->begin()),*ptr2(a2->begin()); double *ptr=ret->getPointer(); - for(std::size_t i=0;i=0) { @@ -3383,8 +3407,8 @@ void DataArrayDouble::powEqual(const DataArrayDouble *other) { if(!other) throw INTERP_KERNEL::Exception("DataArrayDouble::powEqual : input instance is null !"); - std::size_t nbOfTuple=getNumberOfTuples(); - std::size_t nbOfTuple2=other->getNumberOfTuples(); + mcIdType nbOfTuple=getNumberOfTuples(); + mcIdType nbOfTuple2=other->getNumberOfTuples(); std::size_t nbOfComp=getNumberOfComponents(); std::size_t nbOfComp2=other->getNumberOfComponents(); if(nbOfTuple!=nbOfTuple2) @@ -3393,7 +3417,7 @@ void DataArrayDouble::powEqual(const DataArrayDouble *other) throw INTERP_KERNEL::Exception("DataArrayDouble::powEqual : number of components of both arrays must be equal to 1 !"); double *ptr=getPointer(); const double *ptrc=other->begin(); - for(std::size_t i=0;i=0) *ptr=pow(*ptr,*ptrc); @@ -3419,10 +3443,10 @@ std::vector DataArrayDouble::toVectorOfBool(double eps) const checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::toVectorOfBool : must be applied on single component array !"); - std::size_t nbt(getNumberOfTuples()); + mcIdType nbt(getNumberOfTuples()); std::vector ret(nbt); const double *pt(begin()); - for(std::size_t i=0;i& tinyI tinyInfo.resize(2); if(isAllocated()) { - tinyInfo[0]=ToIdType(getNumberOfTuples()); + tinyInfo[0]=getNumberOfTuples(); tinyInfo[1]=ToIdType(getNumberOfComponents()); } else @@ -3464,10 +3488,10 @@ void DataArrayDouble::getTinySerializationStrInformation(std::vector& tinyInfoI, c setName(tinyInfoS[0]); if(isAllocated()) { - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - for(mcIdType i=0;i(pt,nbOfComp) +DataArrayDoubleTuple::DataArrayDoubleTuple(double *pt, std::size_t nbOfComp):DataArrayTuple(pt,nbOfComp) { } @@ -3656,7 +3680,7 @@ double DataArrayDoubleTuple::doubleValue() const * This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or * \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem. */ -DataArrayDouble *DataArrayDoubleTuple::buildDADouble(int nbOfTuples, int nbOfCompo) const +DataArrayDouble *DataArrayDoubleTuple::buildDADouble(std::size_t nbOfTuples, std::size_t nbOfCompo) const { return this->buildDA(nbOfTuples,nbOfCompo); } @@ -3681,7 +3705,7 @@ DataArrayInt32Iterator::DataArrayInt32Iterator(DataArrayInt32 *da):DataArrayIter { } -DataArrayInt32Tuple::DataArrayInt32Tuple(Int32 *pt, mcIdType nbOfComp):DataArrayTuple(pt,nbOfComp) +DataArrayInt32Tuple::DataArrayInt32Tuple(Int32 *pt, std::size_t nbOfComp):DataArrayTuple(pt,nbOfComp) { } @@ -3705,7 +3729,7 @@ Int32 DataArrayInt32Tuple::intValue() const * This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or * \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem. */ -DataArrayInt32 *DataArrayInt32Tuple::buildDAInt(mcIdType nbOfTuples, mcIdType nbOfCompo) const +DataArrayInt32 *DataArrayInt32Tuple::buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const { return this->buildDA(nbOfTuples,nbOfCompo); } @@ -3720,7 +3744,7 @@ DataArrayInt64Iterator::DataArrayInt64Iterator(DataArrayInt64 *da):DataArrayIter { } -DataArrayInt64Tuple::DataArrayInt64Tuple(Int64 *pt, mcIdType nbOfComp):DataArrayTuple(pt,nbOfComp) +DataArrayInt64Tuple::DataArrayInt64Tuple(Int64 *pt, std::size_t nbOfComp):DataArrayTuple(pt,nbOfComp) { } @@ -3738,7 +3762,7 @@ Int64 DataArrayInt64Tuple::intValue() const return this->zeValue(); } -DataArrayInt64 *DataArrayInt64Tuple::buildDAInt(mcIdType nbOfTuples, mcIdType nbOfCompo) const +DataArrayInt64 *DataArrayInt64Tuple::buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const { return this->buildDA(nbOfTuples,nbOfCompo); } diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 145ca3fa9..deac51b63 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -87,10 +87,10 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void reprZip(int sl, std::ostream& stream) const; MEDCOUPLING_EXPORT void reprNotTooLong(int sl, std::ostream& stream) const; MEDCOUPLING_EXPORT void fillWithValue(const T& val); - MEDCOUPLING_EXPORT T *fromNoInterlace(int nbOfComp) const; - MEDCOUPLING_EXPORT T *toNoInterlace(int nbOfComp) const; + MEDCOUPLING_EXPORT T *fromNoInterlace(std::size_t nbOfComp) const; + MEDCOUPLING_EXPORT T *toNoInterlace(std::size_t nbOfComp) const; MEDCOUPLING_EXPORT void sort(bool asc); - MEDCOUPLING_EXPORT void reverse(int nbOfComp); + MEDCOUPLING_EXPORT void reverse(std::size_t nbOfComp); MEDCOUPLING_EXPORT void alloc(std::size_t nbOfElements); MEDCOUPLING_EXPORT void reserve(std::size_t newNbOfElements); MEDCOUPLING_EXPORT void reAlloc(std::size_t newNbOfElements); @@ -135,8 +135,10 @@ namespace MEDCoupling MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; MEDCOUPLING_EXPORT void setName(const std::string& name); MEDCOUPLING_EXPORT void copyStringInfoFrom(const DataArray& other); - MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds); - MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector& compoIds, const DataArray& other); + MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds); + MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom(const DataArray& other, const std::vector& compoIds); + MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector& compoIds, const DataArray& other); + MEDCOUPLING_EXPORT void copyPartOfStringInfoFrom2(const std::vector& compoIds, const DataArray& other); MEDCOUPLING_EXPORT bool areInfoEqualsIfNotWhy(const DataArray& other, std::string& reason) const; MEDCOUPLING_EXPORT bool areInfoEquals(const DataArray& other) const; MEDCOUPLING_EXPORT std::string cppRepr(const std::string& varName) const; @@ -147,10 +149,10 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void setInfoAndChangeNbOfCompo(const std::vector& info); MEDCOUPLING_EXPORT std::vector getVarsOnComponent() const; MEDCOUPLING_EXPORT std::vector getUnitsOnComponent() const; - MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const; - MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const; - MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const; - MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const std::string& info); + MEDCOUPLING_EXPORT std::string getInfoOnComponent(std::size_t i) const; + MEDCOUPLING_EXPORT std::string getVarOnComponent(std::size_t i) const; + MEDCOUPLING_EXPORT std::string getUnitOnComponent(std::size_t i) const; + MEDCOUPLING_EXPORT void setInfoOnComponent(std::size_t i, const std::string& info); MEDCOUPLING_EXPORT std::size_t getNumberOfComponents() const { return _info_on_compo.size(); } MEDCOUPLING_EXPORT void setPartOfValuesBase3(const DataArray *aBase, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true); MEDCOUPLING_EXPORT virtual void *getVoidStarPointer() = 0; @@ -159,7 +161,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual bool isAllocated() const = 0; MEDCOUPLING_EXPORT virtual void checkAllocated() const = 0; MEDCOUPLING_EXPORT virtual void desallocate() = 0; - MEDCOUPLING_EXPORT virtual std::size_t getNumberOfTuples() const = 0; + MEDCOUPLING_EXPORT virtual mcIdType getNumberOfTuples() const = 0; MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const = 0; MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const = 0; MEDCOUPLING_EXPORT virtual void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1) = 0; @@ -169,18 +171,19 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt32 *tuplesSelec) = 0; MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValuesSlice(int tupleIdStart, const DataArray *aBase, int bg, int end2, int step) = 0; MEDCOUPLING_EXPORT virtual DataArray *selectByTupleRanges(const std::vector >& ranges) const = 0; - MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector& compoIds) const = 0; + MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector& compoIds) const = 0; + MEDCOUPLING_EXPORT virtual DataArray *keepSelectedComponents(const std::vector& compoIds) const = 0; MEDCOUPLING_EXPORT virtual DataArray *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const = 0; MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const = 0; MEDCOUPLING_EXPORT virtual DataArray *selectByTupleIdSafeSlice(int bg, int end2, int step) const = 0; - MEDCOUPLING_EXPORT virtual void rearrange(int newNbOfCompo) = 0; + MEDCOUPLING_EXPORT virtual void rearrange(std::size_t newNbOfCompo) = 0; MEDCOUPLING_EXPORT virtual void circularPermutation(int nbOfShift=1) = 0; MEDCOUPLING_EXPORT virtual void circularPermutationPerTuple(int nbOfShift=1) = 0; MEDCOUPLING_EXPORT virtual void reversePerTuple() = 0; - MEDCOUPLING_EXPORT void checkNbOfTuples(int nbOfTuples, const std::string& msg) const; - MEDCOUPLING_EXPORT void checkNbOfComps(int nbOfCompo, const std::string& msg) const; + MEDCOUPLING_EXPORT void checkNbOfTuples(mcIdType nbOfTuples, const std::string& msg) const; + MEDCOUPLING_EXPORT void checkNbOfComps(std::size_t nbOfCompo, const std::string& msg) const; MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const std::string& msg) const; - MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const std::string& msg) const; + MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(mcIdType nbOfTuples, std::size_t nbOfCompo, const std::string& msg) const; MEDCOUPLING_EXPORT void checkNbOfElems(std::size_t nbOfElems, const std::string& msg) const; MEDCOUPLING_EXPORT static void GetSlice(int start, int stop, int step, int sliceId, int nbOfSlices, int& startSlice, int& stopSlice); MEDCOUPLING_EXPORT static int GetNumberOfItemGivenBES(int begin, int end, int step, const std::string& msg); @@ -228,7 +231,7 @@ namespace MEDCoupling std::size_t getHeapMemorySizeWithoutChildren() const; MEDCOUPLING_EXPORT void updateTime() const { } // - MEDCOUPLING_EXPORT std::size_t getNumberOfTuples() const { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); } + MEDCOUPLING_EXPORT mcIdType getNumberOfTuples() const { return ToIdType(_info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents()); } MEDCOUPLING_EXPORT std::size_t getNbOfElems() const { return _mem.getNbOfElem(); } MEDCOUPLING_EXPORT bool empty() const; MEDCOUPLING_EXPORT void *getVoidStarPointer() { return getPointer(); } @@ -238,19 +241,19 @@ namespace MEDCoupling MEDCOUPLING_EXPORT T *rwBegin() { return getPointer(); } MEDCOUPLING_EXPORT T *rwEnd() { return getPointer()+getNbOfElems(); } MEDCOUPLING_EXPORT void alloc(std::size_t nbOfTuple, std::size_t nbOfCompo=1); - MEDCOUPLING_EXPORT void useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); - MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo); - MEDCOUPLING_EXPORT T getIJSafe(int tupleId, int compoId) const; - MEDCOUPLING_EXPORT T getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; } - MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); } - MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } + MEDCOUPLING_EXPORT void useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfTuple, std::size_t nbOfCompo); + MEDCOUPLING_EXPORT void useExternalArrayWithRWAccess(const T *array, std::size_t nbOfTuple, std::size_t nbOfCompo); + MEDCOUPLING_EXPORT T getIJSafe(std::size_t tupleId, std::size_t compoId) const; + MEDCOUPLING_EXPORT T getIJ(std::size_t tupleId, std::size_t compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; } + MEDCOUPLING_EXPORT void setIJ(std::size_t tupleId, std::size_t compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); } + MEDCOUPLING_EXPORT void setIJSilent(std::size_t tupleId, std::size_t compoId, T newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; } MEDCOUPLING_EXPORT T *getPointer() { return _mem.getPointer(); declareAsNew(); } MEDCOUPLING_EXPORT void pack() const; MEDCOUPLING_EXPORT bool isAllocated() const override; MEDCOUPLING_EXPORT void checkAllocated() const; MEDCOUPLING_EXPORT void desallocate(); MEDCOUPLING_EXPORT void reserve(std::size_t nbOfElems); - MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo); + MEDCOUPLING_EXPORT void rearrange(std::size_t newNbOfCompo); MEDCOUPLING_EXPORT void transpose(); MEDCOUPLING_EXPORT void pushBackSilent(T val); MEDCOUPLING_EXPORT void pushBackValsSilent(const T *valsBg, const T *valsEnd); @@ -269,7 +272,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT typename Traits::ArrayType *renumber(const int *old2New) const; MEDCOUPLING_EXPORT typename Traits::ArrayType *renumberR(const int *new2Old) const; MEDCOUPLING_EXPORT typename Traits::ArrayType *renumberAndReduce(const int *old2New, int newNbOfTuple) const; - MEDCOUPLING_EXPORT typename Traits::ArrayType *changeNbOfComponents(int newNbOfComp, T dftValue) const; + MEDCOUPLING_EXPORT typename Traits::ArrayType *changeNbOfComponents(std::size_t newNbOfComp, T dftValue) const; MEDCOUPLING_EXPORT typename Traits::ArrayType *subArray(int tupleIdBg, int tupleIdEnd=-1) const; MEDCOUPLING_EXPORT MCAuto::ArrayTypeCh> selectPartDef(const PartDefinition* pd) const; MEDCOUPLING_EXPORT void circularPermutation(int nbOfShift=1); @@ -305,7 +308,8 @@ namespace MEDCoupling typename Traits::ArrayType *mySelectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const; typename Traits::ArrayType *mySelectByTupleId(const DataArrayIdType& di) const; typename Traits::ArrayType *mySelectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const; - typename Traits::ArrayType *myKeepSelectedComponents(const std::vector& compoIds) const; + typename Traits::ArrayType *myKeepSelectedComponents(const std::vector& compoIds) const; + typename Traits::ArrayType *myKeepSelectedComponents(const std::vector& compoIds) const; typename Traits::ArrayType *mySelectByTupleIdSafeSlice(int bg, int end2, int step) const; typename Traits::ArrayType *mySelectByTupleRanges(const std::vector >& ranges) const; protected: @@ -319,7 +323,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MCAuto convertToDblArr() const; MEDCOUPLING_EXPORT MCAuto convertToIntArr() const; MEDCOUPLING_EXPORT MCAuto convertToFloatArr() const; - MEDCOUPLING_EXPORT void applyLin(T a, T b, int compoId); + MEDCOUPLING_EXPORT void applyLin(T a, T b, std::size_t compoId); MEDCOUPLING_EXPORT void applyLin(T a, T b); MEDCOUPLING_EXPORT typename Traits::ArrayType *negate() const; MEDCOUPLING_EXPORT void addEqual(const typename Traits::ArrayType *other); @@ -386,7 +390,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayFloat *deepCopy() const; MEDCOUPLING_EXPORT DataArrayFloat *buildNewEmptyInstance() const { return DataArrayFloat::New(); } MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplateFP::mySelectByTupleRanges(ranges); } - MEDCOUPLING_EXPORT DataArrayFloat *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayFloat *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayFloat *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayFloat *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP::mySelectByTupleIdSafeSlice(bg,end2,step); } @@ -427,7 +432,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplateFP::myKeepSelectedComponents(compoIds); } MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplateFP::mySelectByTupleIdSafeSlice(bg,end2,step); } MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplateFP::mySelectByTupleRanges(ranges); } MEDCOUPLING_EXPORT bool areIncludedInMe(const DataArrayDouble *other, double prec, DataArrayInt32 *&tupleIds) const; @@ -436,7 +442,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayDouble *getDifferentValues(double prec, int limitTupleId=-1) const; MEDCOUPLING_EXPORT DataArrayInt32 *findClosestTupleId(const DataArrayDouble *other) const; MEDCOUPLING_EXPORT DataArrayInt32 *computeNbOfInteractionsWith(const DataArrayDouble *otherBBoxFrmt, double eps) const; - MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds); + MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds); + MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds); MEDCOUPLING_EXPORT DataArrayDoubleIterator *iterator(); MEDCOUPLING_EXPORT void checkNoNullValues() const; MEDCOUPLING_EXPORT void getMinMaxPerComponent(double *bounds) const; @@ -452,7 +459,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void normMaxPerComponent(double * res) const; MEDCOUPLING_EXPORT double normMin() const; MEDCOUPLING_EXPORT void accumulate(double *res) const; - MEDCOUPLING_EXPORT double accumulate(int compId) const; + MEDCOUPLING_EXPORT double accumulate(std::size_t compId) const; MEDCOUPLING_EXPORT DataArrayDouble *accumulatePerChunck(const int *bgOfIndex, const int *endOfIndex) const; MEDCOUPLING_EXPORT MCAuto cumSum() const; MEDCOUPLING_EXPORT double distanceToTuple(const double *tupleBg, const double *tupleEnd, int& tupleId) const; @@ -572,6 +579,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool isUniform(T val) const; MEDCOUPLING_EXPORT T checkUniformAndGuess() const; MEDCOUPLING_EXPORT bool hasUniqueValues() const; + MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayType *a, const std::vector& compoIds); MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayType *a, const std::vector& compoIds); MEDCOUPLING_EXPORT DataArrayIdType *findIdsNotEqual(T val) const; MEDCOUPLING_EXPORT DataArrayIdType *findIdsEqualTuple(const T *tupleBg, const T *tupleEnd) const; @@ -587,7 +595,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool presenceOfValue(T value) const; MEDCOUPLING_EXPORT bool presenceOfValue(const std::vector& vals) const; MEDCOUPLING_EXPORT void accumulate(T *res) const; - MEDCOUPLING_EXPORT T accumulate(mcIdType compId) const; + MEDCOUPLING_EXPORT T accumulate(std::size_t compId) const; MEDCOUPLING_EXPORT DataArrayType *accumulatePerChunck(const mcIdType *bgOfIndex, const mcIdType *endOfIndex) const; MEDCOUPLING_EXPORT void getMinMaxValues(T& minValue, T& maxValue) const; MEDCOUPLING_EXPORT void applyInv(T numerator); @@ -695,7 +703,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - MEDCOUPLING_EXPORT DataArrayInt32 *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayInt32 *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayInt32 *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } MEDCOUPLING_EXPORT DataArrayInt32 *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplate::mySelectByTupleRanges(ranges); } public: @@ -715,7 +724,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - MEDCOUPLING_EXPORT DataArrayInt64 *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayInt64 *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayInt64 *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } MEDCOUPLING_EXPORT DataArrayInt64 *selectByTupleRanges(const std::vector >& ranges) const { return DataArrayTemplate::mySelectByTupleRanges(ranges); } public: @@ -738,7 +748,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("DataArrayInt::findIdsAdv : this must have exactly one component !"); const T *cptr(this->begin()); MCAuto ret(DataArrayInt::New()); ret->alloc(0,1); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples=this->getNumberOfTuples(); for(mcIdType i=0;ipushBackSilent(i); @@ -759,7 +769,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const mcIdType *new2OldBg, const mcIdType *new2OldEnd) const { return this->mySelectByTupleId(new2OldBg,new2OldEnd); } MEDCOUPLING_EXPORT DataArrayChar *selectByTupleId(const DataArrayIdType& di) const { return this->mySelectByTupleId(di); } MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate::mySelectByTupleIdSafe(new2OldBg,new2OldEnd); } - MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } + MEDCOUPLING_EXPORT DataArrayChar *keepSelectedComponents(const std::vector& compoIds) const { return DataArrayTemplate::myKeepSelectedComponents(compoIds); } MEDCOUPLING_EXPORT DataArrayChar *selectByTupleIdSafeSlice(int bg, int end2, int step) const { return DataArrayTemplate::mySelectByTupleIdSafeSlice(bg,end2,step); } MEDCOUPLING_EXPORT bool isUniform(char val) const; MEDCOUPLING_EXPORT void meldWith(const DataArrayChar *other); @@ -855,7 +866,7 @@ namespace MEDCoupling typename Traits::ArrayType *_da; T *_pt; mcIdType _tuple_id; - mcIdType _nb_comp; + std::size_t _nb_comp; mcIdType _nb_tuple; }; @@ -863,17 +874,17 @@ namespace MEDCoupling class DataArrayTuple { public: - MEDCOUPLING_EXPORT DataArrayTuple(T *pt, mcIdType nbOfComp); + MEDCOUPLING_EXPORT DataArrayTuple(T *pt, std::size_t nbOfComp); //MEDCOUPLING_EXPORT std::string repr() const; - MEDCOUPLING_EXPORT mcIdType getNumberOfCompo() const { return _nb_of_compo; } + MEDCOUPLING_EXPORT std::size_t getNumberOfCompo() const { return _nb_of_compo; } MEDCOUPLING_EXPORT const T *getConstPointer() const { return _pt; } MEDCOUPLING_EXPORT T *getPointer() { return _pt; } - MEDCOUPLING_EXPORT typename Traits::ArrayType *buildDA(mcIdType nbOfTuples, mcIdType nbOfCompo) const; + MEDCOUPLING_EXPORT typename Traits::ArrayType *buildDA(std::size_t nbOfTuples, std::size_t nbOfCompo) const; protected: T zeValue() const; protected: T *_pt; - mcIdType _nb_of_compo; + std::size_t _nb_of_compo; }; class DataArrayDoubleTuple; @@ -888,10 +899,10 @@ namespace MEDCoupling class DataArrayDoubleTuple : public DataArrayTuple { public: - MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, mcIdType nbOfComp); + MEDCOUPLING_EXPORT DataArrayDoubleTuple(double *pt, std::size_t nbOfComp); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT double doubleValue() const; - MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(mcIdType nbOfTuples, mcIdType nbOfCompo) const; + MEDCOUPLING_EXPORT DataArrayDouble *buildDADouble(std::size_t nbOfTuples, std::size_t nbOfCompo) const; }; class DataArrayFloatTuple; @@ -906,10 +917,10 @@ namespace MEDCoupling class DataArrayFloatTuple : public DataArrayTuple { public: - MEDCOUPLING_EXPORT DataArrayFloatTuple(float *pt, mcIdType nbOfComp); + MEDCOUPLING_EXPORT DataArrayFloatTuple(float *pt, std::size_t nbOfComp); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT float floatValue() const; - MEDCOUPLING_EXPORT DataArrayFloat *buildDAFloat(mcIdType nbOfTuples, mcIdType nbOfCompo) const; + MEDCOUPLING_EXPORT DataArrayFloat *buildDAFloat(std::size_t nbOfTuples, std::size_t nbOfCompo) const; }; class DataArrayInt32Iterator : public DataArrayIterator @@ -929,19 +940,19 @@ namespace MEDCoupling class DataArrayInt32Tuple : public DataArrayTuple { public: - MEDCOUPLING_EXPORT DataArrayInt32Tuple(Int32 *pt, mcIdType nbOfComp); + MEDCOUPLING_EXPORT DataArrayInt32Tuple(Int32 *pt, std::size_t nbOfComp); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT Int32 intValue() const; - MEDCOUPLING_EXPORT DataArrayInt32 *buildDAInt(mcIdType nbOfTuples, mcIdType nbOfCompo) const; + MEDCOUPLING_EXPORT DataArrayInt32 *buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const; }; class DataArrayInt64Tuple : public DataArrayTuple { public: - MEDCOUPLING_EXPORT DataArrayInt64Tuple(Int64 *pt, mcIdType nbOfComp); + MEDCOUPLING_EXPORT DataArrayInt64Tuple(Int64 *pt, std::size_t nbOfComp); MEDCOUPLING_EXPORT std::string repr() const; MEDCOUPLING_EXPORT Int64 intValue() const; - MEDCOUPLING_EXPORT DataArrayInt64 *buildDAInt(mcIdType nbOfTuples, mcIdType nbOfCompo) const; + MEDCOUPLING_EXPORT DataArrayInt64 *buildDAInt(std::size_t nbOfTuples, std::size_t nbOfCompo) const; }; typedef DataArrayInt32Tuple DataArrayIntTuple; @@ -957,24 +968,24 @@ namespace MEDCoupling private: DataArrayAsciiChar *_da; char *_pt; - int _tuple_id; - int _nb_comp; - int _nb_tuple; + mcIdType _tuple_id; + std::size_t _nb_comp; + mcIdType _nb_tuple; }; class DataArrayAsciiCharTuple { public: - MEDCOUPLING_EXPORT DataArrayAsciiCharTuple(char *pt, int nbOfComp); + MEDCOUPLING_EXPORT DataArrayAsciiCharTuple(char *pt, std::size_t nbOfComp); MEDCOUPLING_EXPORT std::string repr() const; - MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; } + MEDCOUPLING_EXPORT std::size_t getNumberOfCompo() const { return _nb_of_compo; } MEDCOUPLING_EXPORT const char *getConstPointer() const { return _pt; } MEDCOUPLING_EXPORT char *getPointer() { return _pt; } MEDCOUPLING_EXPORT char asciiCharValue() const; - MEDCOUPLING_EXPORT DataArrayAsciiChar *buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const; + MEDCOUPLING_EXPORT DataArrayAsciiChar *buildDAAsciiChar(std::size_t nbOfTuples, std::size_t nbOfCompo) const; private: char *_pt; - int _nb_of_compo; + std::size_t _nb_of_compo; }; class DataArrayByteTuple; @@ -988,24 +999,24 @@ namespace MEDCoupling private: DataArrayByte *_da; char *_pt; - int _tuple_id; - int _nb_comp; - int _nb_tuple; + mcIdType _tuple_id; + std::size_t _nb_comp; + mcIdType _nb_tuple; }; class DataArrayByteTuple { public: - MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, int nbOfComp); + MEDCOUPLING_EXPORT DataArrayByteTuple(char *pt, std::size_t nbOfComp); MEDCOUPLING_EXPORT std::string repr() const; - MEDCOUPLING_EXPORT int getNumberOfCompo() const { return _nb_of_compo; } + MEDCOUPLING_EXPORT std::size_t getNumberOfCompo() const { return _nb_of_compo; } MEDCOUPLING_EXPORT const char *getConstPointer() const { return _pt; } MEDCOUPLING_EXPORT char *getPointer() { return _pt; } MEDCOUPLING_EXPORT char byteValue() const; - MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(int nbOfTuples, int nbOfCompo) const; + MEDCOUPLING_EXPORT DataArrayByte *buildDAByte(std::size_t nbOfTuples, std::size_t nbOfCompo) const; private: char *_pt; - int _nb_of_compo; + std::size_t _nb_of_compo; }; } diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 5456c4cf2..5d3ee2f72 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -299,7 +299,7 @@ namespace MEDCoupling } template - T *MemArray::fromNoInterlace(int nbOfComp) const + T *MemArray::fromNoInterlace(std::size_t nbOfComp) const { if(nbOfComp<1) throw INTERP_KERNEL::Exception("MemArray::fromNoInterlace : number of components must be > 0 !"); @@ -308,13 +308,13 @@ namespace MEDCoupling T *ret=(T*)malloc(_nb_of_elem*sizeof(T)); T *w=ret; for(std::size_t i=0;i - T *MemArray::toNoInterlace(int nbOfComp) const + T *MemArray::toNoInterlace(std::size_t nbOfComp) const { if(nbOfComp<1) throw INTERP_KERNEL::Exception("MemArray::toNoInterlace : number of components must be > 0 !"); @@ -322,7 +322,7 @@ namespace MEDCoupling std::size_t nbOfTuples=_nb_of_elem/nbOfComp; T *ret=(T*)malloc(_nb_of_elem*sizeof(T)); T *w=ret; - for(int i=0;i - void MemArray::reverse(int nbOfComp) + void MemArray::reverse(std::size_t nbOfComp) { if(nbOfComp<1) throw INTERP_KERNEL::Exception("MemArray::reverse : only supported with 'this' array with ONE or more than ONE component !"); @@ -359,7 +359,7 @@ namespace MEDCoupling std::size_t nbOfTuples=_nb_of_elem/nbOfComp; for(std::size_t i=0;iincrRef(); if(_da->isAllocated()) { - _nb_comp=ToIdType(da->getNumberOfComponents()); - _nb_tuple=ToIdType(da->getNumberOfTuples()); + _nb_comp=da->getNumberOfComponents(); + _nb_tuple=da->getNumberOfTuples(); _pt=da->getPointer(); } } @@ -531,7 +531,7 @@ namespace MEDCoupling ////////////////////////////////// template - DataArrayTuple::DataArrayTuple(T *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) + DataArrayTuple::DataArrayTuple(T *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) { } @@ -544,7 +544,7 @@ namespace MEDCoupling } template - typename Traits::ArrayType *DataArrayTuple::buildDA(int nbOfTuples, int nbOfCompo) const + typename Traits::ArrayType *DataArrayTuple::buildDA(std::size_t nbOfTuples, std::size_t nbOfCompo) const { if((_nb_of_compo==nbOfCompo && nbOfTuples==1) || (_nb_of_compo==nbOfTuples && nbOfCompo==1)) { @@ -578,7 +578,7 @@ namespace MEDCoupling { checkAllocated(); std::size_t sz(getNumberOfComponents()); - std::size_t nbTuples(getNumberOfTuples()); + mcIdType nbTuples(getNumberOfTuples()); std::string name(getName()); std::vector compNames(getInfoOnComponents()); std::vector< MCAuto< typename Traits::ArrayTypeCh > > ret(sz); @@ -590,7 +590,7 @@ namespace MEDCoupling part->setName(name); part->setInfoOnComponent(0,compNames[i]); T *otherPt(part->getPointer()); - for(std::size_t j=0;j - void DataArrayTemplate::useArray(const T *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo) + void DataArrayTemplate::useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfTuple, std::size_t nbOfCompo) { _info_on_compo.resize(nbOfCompo); - _mem.useArray(array,ownership,type,(std::size_t)nbOfTuple*nbOfCompo); + _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo); declareAsNew(); } template - void DataArrayTemplate::useExternalArrayWithRWAccess(const T *array, int nbOfTuple, int nbOfCompo) + void DataArrayTemplate::useExternalArrayWithRWAccess(const T *array, std::size_t nbOfTuple, std::size_t nbOfCompo) { _info_on_compo.resize(nbOfCompo); - _mem.useExternalArrayWithRWAccess(array,(std::size_t)nbOfTuple*nbOfCompo); + _mem.useExternalArrayWithRWAccess(array,nbOfTuple*nbOfCompo); declareAsNew(); } @@ -662,15 +662,15 @@ namespace MEDCoupling * \throw If condition ( 0 <= compoId < this->getNumberOfComponents() ) is violated. */ template - T DataArrayTemplate::getIJSafe(int tupleId, int compoId) const + T DataArrayTemplate::getIJSafe(std::size_t tupleId, std::size_t compoId) const { checkAllocated(); - if(tupleId<0 || tupleId>=ToIdType(getNumberOfTuples())) + if(ToIdType(tupleId)>=getNumberOfTuples()) { std::ostringstream oss; oss << Traits::ArrayTypeName << "::getIJSafe : request for tupleId " << tupleId << " should be in [0," << getNumberOfTuples() << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - if(compoId<0 || compoId>=(int)getNumberOfComponents()) + if(compoId>=getNumberOfComponents()) { std::ostringstream oss; oss << Traits::ArrayTypeName << "::getIJSafe : request for compoId " << compoId << " should be in [0," << getNumberOfComponents() << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -836,7 +836,7 @@ namespace MEDCoupling { if(isAllocated()) { - if(nbOfTuple!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents()) + if(ToIdType(nbOfTuple)!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents()) alloc(nbOfTuple,nbOfCompo); } else @@ -865,7 +865,8 @@ namespace MEDCoupling void DataArrayTemplate::deepCopyFrom(const DataArrayTemplate& other) { other.checkAllocated(); - std::size_t nbOfTuples(other.getNumberOfTuples()),nbOfComp(other.getNumberOfComponents()); + mcIdType nbOfTuples(other.getNumberOfTuples()); + std::size_t nbOfComp(other.getNumberOfComponents()); allocIfNecessary(nbOfTuples,nbOfComp); std::size_t nbOfElems(nbOfTuples*nbOfComp); T *pt(getPointer()); @@ -884,7 +885,7 @@ namespace MEDCoupling void DataArrayTemplate::reverse() { checkAllocated(); - _mem.reverse(ToIdType(getNumberOfComponents())); + _mem.reverse(getNumberOfComponents()); declareAsNew(); } @@ -930,8 +931,8 @@ namespace MEDCoupling void DataArrayTemplate::renumberInPlace(const int *old2New) { checkAllocated(); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); + std::size_t nbOfCompo(getNumberOfComponents()); T *tmp(new T[nbTuples*nbOfCompo]); const T *iptr(begin()); for(int i=0;i::renumberInPlaceR(const int *new2Old) { checkAllocated(); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); + std::size_t nbOfCompo(getNumberOfComponents()); T *tmp(new T[nbTuples*nbOfCompo]); const T *iptr(begin()); for(mcIdType i=0;i::ArrayType *DataArrayTemplate::renumber(const int *old2New) const { checkAllocated(); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); + std::size_t nbOfCompo(getNumberOfComponents()); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); ret->alloc(nbTuples,nbOfCompo); @@ -1049,8 +1050,8 @@ namespace MEDCoupling typename Traits::ArrayType *DataArrayTemplate::renumberR(const int *new2Old) const { checkAllocated(); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); + std::size_t nbOfCompo(getNumberOfComponents()); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); ret->alloc(nbTuples,nbOfCompo); @@ -1080,8 +1081,8 @@ namespace MEDCoupling typename Traits::ArrayType *DataArrayTemplate::renumberAndReduce(const int *old2New, int newNbOfTuple) const { checkAllocated(); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); + std::size_t nbOfCompo(getNumberOfComponents()); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); ret->alloc(newNbOfTuple,nbOfCompo); @@ -1148,7 +1149,7 @@ namespace MEDCoupling { int a,b,c; spd->getSlice(a,b,c); - if(a==0 && b==(int)getNumberOfTuples() && c==1) + if(a==0 && b==getNumberOfTuples() && c==1) { DataArrayTemplate *directRet(const_cast *>(this)); directRet->incrRef(); @@ -1197,8 +1198,8 @@ namespace MEDCoupling checkAllocated(); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); - mcIdType nbComp=ToIdType(getNumberOfComponents()); - mcIdType oldNbOfTuples=ToIdType(getNumberOfTuples()); + std::size_t nbComp(getNumberOfComponents()); + mcIdType oldNbOfTuples(getNumberOfTuples()); ret->alloc((int)std::distance(new2OldBg,new2OldEnd),nbComp); ret->copyStringInfoFrom(*this); T *pt(ret->getPointer()); @@ -1228,7 +1229,7 @@ namespace MEDCoupling * \warning This method erases all (name and unit) component info set before! */ template - void DataArrayTemplate::rearrange(int newNbOfCompo) + void DataArrayTemplate::rearrange(std::size_t newNbOfCompo) { checkAllocated(); if(newNbOfCompo<1) @@ -1266,7 +1267,7 @@ namespace MEDCoupling void DataArrayTemplate::transpose() { checkAllocated(); - rearrange(ToIdType (getNumberOfTuples())); + rearrange(getNumberOfTuples()); } /*! @@ -1283,7 +1284,7 @@ namespace MEDCoupling * \throw If \a this is not allocated. */ template - typename Traits::ArrayType *DataArrayTemplate::changeNbOfComponents(int newNbOfComp, T dftValue) const + typename Traits::ArrayType *DataArrayTemplate::changeNbOfComponents(std::size_t newNbOfComp, T dftValue) const { checkAllocated(); MCAuto ret0(buildNewEmptyInstance()); @@ -1291,19 +1292,19 @@ namespace MEDCoupling ret->alloc(getNumberOfTuples(),newNbOfComp); const T *oldc(getConstPointer()); T *nc(ret->getPointer()); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); - mcIdType oldNbOfComp=ToIdType(getNumberOfComponents()); - mcIdType dim(std::min(oldNbOfComp,newNbOfComp)); + mcIdType nbOfTuples=getNumberOfTuples(); + std::size_t oldNbOfComp=getNumberOfComponents(); + std::size_t dim(std::min(oldNbOfComp,newNbOfComp)); for(mcIdType i=0;isetName(getName()); - for(mcIdType i=0;isetInfoOnComponent(i,getInfoOnComponent(i)); ret->setName(getName()); return ret.retn(); @@ -1327,20 +1328,20 @@ namespace MEDCoupling * \endif */ template - typename Traits::ArrayType *DataArrayTemplate::myKeepSelectedComponents(const std::vector& compoIds) const + typename Traits::ArrayType *DataArrayTemplate::myKeepSelectedComponents(const std::vector& compoIds) const { checkAllocated(); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); - std::size_t newNbOfCompo=ToIdType(compoIds.size()); - mcIdType oldNbOfCompo=ToIdType(getNumberOfComponents()); - for(std::vector::const_iterator it=compoIds.begin();it!=compoIds.end();it++) + std::size_t newNbOfCompo=compoIds.size(); + std::size_t oldNbOfCompo=getNumberOfComponents(); + for(std::vector::const_iterator it=compoIds.begin();it!=compoIds.end();it++) if((*it)<0 || (*it)>=oldNbOfCompo) { std::ostringstream oss; oss << Traits::ArrayTypeName << "::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples(getNumberOfTuples()); ret->alloc(nbOfTuples,newNbOfCompo); ret->copyPartOfStringInfoFrom(*this,compoIds); const T *oldc(getConstPointer()); @@ -1351,6 +1352,13 @@ namespace MEDCoupling return ret.retn(); } + template + typename Traits::ArrayType *DataArrayTemplate::myKeepSelectedComponents(const std::vector& compoIds) const + { + std::vector ids (compoIds.size()); + std::copy(compoIds.begin(), compoIds.end(), ids.begin()); + return myKeepSelectedComponents (ids); + } /*! * Returns a shorten copy of \a this array. The new DataArrayDouble contains all * tuples starting from the \a tupleIdBg-th tuple and including all tuples located before @@ -1370,7 +1378,7 @@ namespace MEDCoupling typename Traits::ArrayType *DataArrayTemplate::subArray(int tupleIdBg, int tupleIdEnd) const { checkAllocated(); - mcIdType nbt=ToIdType(getNumberOfTuples()); + mcIdType nbt=getNumberOfTuples(); if(tupleIdBg<0) { std::ostringstream oss; oss << Traits::ArrayTypeName << "::subArray : The tupleIdBg parameter must be greater than 0 !"; @@ -1392,7 +1400,7 @@ namespace MEDCoupling } else trueEnd=nbt; - mcIdType nbComp=ToIdType(getNumberOfComponents()); + std::size_t nbComp=getNumberOfComponents(); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); ret->alloc(trueEnd-tupleIdBg,nbComp); @@ -1422,7 +1430,7 @@ namespace MEDCoupling checkAllocated(); MCAuto ret0(buildNewEmptyInstance()); MCAuto< typename Traits::ArrayType > ret(DynamicCastSafe::ArrayType>(ret0)); - mcIdType nbComp=ToIdType(getNumberOfComponents()); + std::size_t nbComp(getNumberOfComponents()); std::ostringstream oss; oss << Traits::ArrayTypeName << "::selectByTupleIdSafeSlice : "; int newNbOfTuples(GetNumberOfItemGivenBESRelative(bg,end2,step,oss.str())); ret->alloc(newNbOfTuples,nbComp); @@ -1483,10 +1491,10 @@ namespace MEDCoupling a->checkAllocated(); int newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg)); int newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg)); - mcIdType nbComp=ToIdType(getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + std::size_t nbComp(getNumberOfComponents()); + mcIdType nbOfTuples(getNumberOfTuples()); DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value"); - DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value"); + DataArray::CheckValueInRangeEx(ToIdType(nbComp),bgComp,endComp,"invalid component value"); bool assignTech(true); if(a->getNbOfElems()==(std::size_t)newNbOfTuples*newNbOfComp) { @@ -1546,10 +1554,10 @@ namespace MEDCoupling checkAllocated(); int newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg)); int newNbOfComp(DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg)); - mcIdType nbComp=ToIdType(getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + std::size_t nbComp(getNumberOfComponents()); + mcIdType nbOfTuples(getNumberOfTuples()); DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value"); - DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value"); + DataArray::CheckValueInRangeEx(ToIdType(nbComp),bgComp,endComp,"invalid component value"); T *pt=getPointer()+bgTuples*nbComp+bgComp; for(mcIdType i=0;icheckAllocated(); - mcIdType nbComp=ToIdType(getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + std::size_t nbComp(getNumberOfComponents()); + mcIdType nbOfTuples(getNumberOfTuples()); for(const int *z=bgComp;z!=endComp;z++) - DataArray::CheckValueInRange(nbComp,*z,"invalid component id"); - int newNbOfTuples((int)std::distance(bgTuples,endTuples)); - int newNbOfComp((int)std::distance(bgComp,endComp)); + DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id"); + mcIdType newNbOfTuples(ToIdType(std::distance(bgTuples,endTuples))); + std::size_t newNbOfComp(std::distance(bgComp,endComp)); bool assignTech(true); - if(a->getNbOfElems()==(std::size_t)newNbOfTuples*newNbOfComp) + if(a->getNbOfElems()==newNbOfTuples*newNbOfComp) { if(strictCompoCompare) a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); @@ -1674,10 +1682,10 @@ namespace MEDCoupling void DataArrayTemplate::setPartOfValuesSimple2(T a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) { checkAllocated(); - mcIdType nbComp=ToIdType(getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + std::size_t nbComp=getNumberOfComponents(); + mcIdType nbOfTuples=getNumberOfTuples(); for(const int *z=bgComp;z!=endComp;z++) - DataArray::CheckValueInRange(nbComp,*z,"invalid component id"); + DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id"); T *pt(getPointer()); for(const int *w=bgTuples;w!=endTuples;w++) for(const int *z=bgComp;z!=endComp;z++) @@ -1741,13 +1749,13 @@ namespace MEDCoupling const char msg[]="DataArrayTemplate::setPartOfValues3"; checkAllocated(); a->checkAllocated(); - int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg); - mcIdType nbComp=ToIdType(getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); - DataArray::CheckValueInRangeEx(nbComp,bgComp,endComp,"invalid component value"); - int newNbOfTuples=(int)std::distance(bgTuples,endTuples); + std::size_t newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg); + std::size_t nbComp(getNumberOfComponents()); + mcIdType nbOfTuples(getNumberOfTuples()); + DataArray::CheckValueInRangeEx(ToIdType(nbComp),bgComp,endComp,"invalid component value"); + mcIdType newNbOfTuples=ToIdType(std::distance(bgTuples,endTuples)); bool assignTech=true; - if(a->getNbOfElems()==(std::size_t)newNbOfTuples*newNbOfComp) + if(a->getNbOfElems()==newNbOfTuples*newNbOfComp) { if(strictCompoCompare) a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); @@ -1762,7 +1770,7 @@ namespace MEDCoupling if(assignTech) { for(const int *w=bgTuples;w!=endTuples;w++) - for(int j=0;jcheckAllocated(); int newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg)); - int newNbOfComp((int)std::distance(bgComp,endComp)); - mcIdType nbComp=ToIdType(getNumberOfComponents()); + std::size_t newNbOfComp(std::distance(bgComp,endComp)); + std::size_t nbComp(getNumberOfComponents()); for(const int *z=bgComp;z!=endComp;z++) - DataArray::CheckValueInRange(nbComp,*z,"invalid component id"); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id"); + mcIdType nbOfTuples(getNumberOfTuples()); DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value"); bool assignTech(true); - if(a->getNbOfElems()==(std::size_t)newNbOfTuples*newNbOfComp) + if(a->getNbOfElems()==newNbOfTuples*newNbOfComp) { if(strictCompoCompare) a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg); @@ -1910,10 +1918,10 @@ namespace MEDCoupling const char msg[]="DataArrayTemplate::setPartOfValuesSimple4"; checkAllocated(); int newNbOfTuples(DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg)); - mcIdType nbComp=ToIdType(getNumberOfComponents()); + std::size_t nbComp(getNumberOfComponents()); for(const int *z=bgComp;z!=endComp;z++) - DataArray::CheckValueInRange(nbComp,*z,"invalid component id"); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + DataArray::CheckValueInRange(ToIdType(nbComp),*z,"invalid component id"); + mcIdType nbOfTuples(getNumberOfTuples()); DataArray::CheckValueInRangeEx(nbOfTuples,bgTuples,endTuples,"invalid tuple value"); T *pt=getPointer()+bgTuples*nbComp; for(int i=0;igetNumberOfComponents()!=2) throw INTERP_KERNEL::Exception("DataArrayTemplate::setPartOfValuesAdv : Expecting to have a tuple selector DataArrayInt instance with exactly 2 components !"); - mcIdType thisNt=ToIdType(getNumberOfTuples()); - mcIdType aNt=ToIdType(a->getNumberOfTuples()); + mcIdType thisNt(getNumberOfTuples()); + mcIdType aNt(a->getNumberOfTuples()); T *valsToSet(getPointer()); const T *valsSrc(a->getConstPointer()); for(const int *tuple=tuplesSelec->begin();tuple!=tuplesSelec->end();tuple+=2) @@ -2020,9 +2028,9 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : This and a do not have the same number of components !"); if(tuplesSelec->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : Expecting to have a tuple selector DataArrayInt instance with exactly 1 component !"); - mcIdType thisNt=ToIdType(getNumberOfTuples()); - mcIdType aNt=ToIdType(a->getNumberOfTuples()); - mcIdType nbOfTupleToWrite=ToIdType(tuplesSelec->getNumberOfTuples()); + mcIdType thisNt(getNumberOfTuples()); + mcIdType aNt(a->getNumberOfTuples()); + mcIdType nbOfTupleToWrite(tuplesSelec->getNumberOfTuples()); T *valsToSet(getPointer()+tupleIdStart*nbOfComp); if(tupleIdStart+nbOfTupleToWrite>thisNt) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValues : invalid number range of values to write !"); @@ -2085,8 +2093,8 @@ namespace MEDCoupling int nbOfTupleToWrite(DataArray::GetNumberOfItemGivenBES(bg,end2,step,msg)); if(nbOfComp!=a->getNumberOfComponents()) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValuesSlice : This and a do not have the same number of components !"); - mcIdType thisNt=ToIdType(getNumberOfTuples()); - mcIdType aNt=ToIdType(a->getNumberOfTuples()); + mcIdType thisNt(getNumberOfTuples()); + mcIdType aNt(a->getNumberOfTuples()); T *valsToSet(getPointer()+tupleIdStart*nbOfComp); if(tupleIdStart+nbOfTupleToWrite>thisNt) throw INTERP_KERNEL::Exception("DataArrayTemplate::setContigPartOfSelectedValuesSlice : invalid number range of values to write !"); @@ -2115,8 +2123,8 @@ namespace MEDCoupling typename Traits::ArrayType *DataArrayTemplate::mySelectByTupleRanges(const std::vector >& ranges) const { checkAllocated(); - mcIdType nbOfComp=ToIdType(getNumberOfComponents()); - mcIdType nbOfTuplesThis=ToIdType(getNumberOfTuples()); + std::size_t nbOfComp(getNumberOfComponents()); + mcIdType nbOfTuplesThis(getNumberOfTuples()); if(ranges.empty()) { MCAuto ret0(buildNewEmptyInstance()); @@ -2178,7 +2186,7 @@ namespace MEDCoupling checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayTemplate::front : number of components not equal to one !"); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); if(nbOfTuples<1) throw INTERP_KERNEL::Exception("DataArrayTemplate::front : number of tuples must be >= 1 !"); return *(getConstPointer()); @@ -2197,7 +2205,7 @@ namespace MEDCoupling checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayTemplate::back : number of components not equal to one !"); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); if(nbOfTuples<1) throw INTERP_KERNEL::Exception("DataArrayTemplate::back : number of tuples must be >= 1 !"); return *(getConstPointer()+nbOfTuples-1); @@ -2217,7 +2225,7 @@ namespace MEDCoupling checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before or call 'getMaxValueInArray' method !"); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); if(nbOfTuples<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !"); const T *vals(getConstPointer()); @@ -2254,13 +2262,13 @@ namespace MEDCoupling checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxAbsValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before or call 'getMaxValueInArray' method !"); - std::size_t nbTuples(this->getNumberOfTuples()); + mcIdType nbTuples(this->getNumberOfTuples()); if(nbTuples==0) throw INTERP_KERNEL::Exception("DataArrayTemplate::getMaxAbsValue : empty array !"); T ret((T)-1); tupleId=0; const T *pt(begin()); - for(std::size_t i=0;iret) @@ -2298,7 +2306,7 @@ namespace MEDCoupling checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before call 'getMinValueInArray' method !"); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); if(nbOfTuples<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : array exists but number of tuples must be > 0 !"); const T *vals(getConstPointer()); @@ -2325,8 +2333,8 @@ namespace MEDCoupling void DataArrayTemplate::circularPermutation(int nbOfShift) { checkAllocated(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); + std::size_t nbOfCompo(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); int effNbSh(EffectiveCircPerm(nbOfShift,nbTuples)); if(effNbSh==0) return ; @@ -2351,13 +2359,13 @@ namespace MEDCoupling void DataArrayTemplate::circularPermutationPerTuple(int nbOfShift) { checkAllocated(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); - int effNbSh(EffectiveCircPerm(nbOfShift,nbOfCompo)); + std::size_t nbOfCompo(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); + int effNbSh(EffectiveCircPerm(nbOfShift,ToIdType(nbOfCompo))); if(effNbSh==0) return ; T *work(getPointer()); - if(effNbSh buf(new T[effNbSh]); for(mcIdType i=0;i sts(nbOfCompo); - for(mcIdType i=0;i::reversePerTuple() { checkAllocated(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - mcIdType nbTuples=ToIdType(getNumberOfTuples()); + std::size_t nbOfCompo(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); if(nbOfCompo<=1) return ; T *work(getPointer()); @@ -2499,17 +2507,17 @@ namespace MEDCoupling * \throw If \a this is not allocated, or \a compoId is not in [0,\c this->getNumberOfComponents() ). */ template - void DataArrayTemplateClassic::applyLin(T a, T b, int compoId) + void DataArrayTemplateClassic::applyLin(T a, T b, std::size_t compoId) { this->checkAllocated(); - T *ptr(this->getPointer()+compoId); - mcIdType nbOfComp=ToIdType(this->getNumberOfComponents()); - mcIdType nbOfTuple=ToIdType(this->getNumberOfTuples()); - if(compoId<0 || compoId>=nbOfComp) + std::size_t nbOfComp=this->getNumberOfComponents(); + if(compoId>=nbOfComp) { std::ostringstream oss; oss << "DataArrayDouble::applyLin : The compoId requested (" << compoId << ") is not valid ! Must be in [0," << nbOfComp << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } + T *ptr(this->getPointer()+compoId); + mcIdType nbOfTuple=this->getNumberOfTuples(); for(mcIdType i=0;ideclareAsNew(); @@ -2546,8 +2554,8 @@ namespace MEDCoupling { this->checkAllocated(); MCAuto::ArrayType> newArr(Traits::ArrayType::New()); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); - mcIdType nbOfComp=ToIdType(this->getNumberOfComponents()); + mcIdType nbOfTuples(this->getNumberOfTuples()); + std::size_t nbOfComp(this->getNumberOfComponents()); newArr->alloc(nbOfTuples,nbOfComp); const T *cptr(this->begin()); std::transform(cptr,cptr+nbOfTuples*nbOfComp,newArr->getPointer(),std::negate()); @@ -2564,10 +2572,10 @@ namespace MEDCoupling const char *msg="Nb of tuples mismatch for DataArrayDouble::multiplyEqual !"; this->checkAllocated(); other->checkAllocated(); - mcIdType nbOfTuple=ToIdType(this->getNumberOfTuples()); - mcIdType nbOfTuple2=ToIdType(other->getNumberOfTuples()); - mcIdType nbOfComp=ToIdType(this->getNumberOfComponents()); - mcIdType nbOfComp2=ToIdType(other->getNumberOfComponents()); + mcIdType nbOfTuple(this->getNumberOfTuples()); + mcIdType nbOfTuple2(other->getNumberOfTuples()); + std::size_t nbOfComp(this->getNumberOfComponents()); + std::size_t nbOfComp2(other->getNumberOfComponents()); if(nbOfTuple==nbOfTuple2) { if(nbOfComp==nbOfComp2) @@ -2699,10 +2707,10 @@ namespace MEDCoupling { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DivSub : input DataArrayDouble instance is NULL !"); - mcIdType nbOfTuple1=ToIdType(a1->getNumberOfTuples()); - mcIdType nbOfTuple2=ToIdType(a2->getNumberOfTuples()); - mcIdType nbOfComp1=ToIdType(a1->getNumberOfComponents()); - mcIdType nbOfComp2=ToIdType(a2->getNumberOfComponents()); + mcIdType nbOfTuple1(a1->getNumberOfTuples()); + mcIdType nbOfTuple2(a2->getNumberOfTuples()); + std::size_t nbOfComp1(a1->getNumberOfComponents()); + std::size_t nbOfComp2(a2->getNumberOfComponents()); if(nbOfTuple2==nbOfTuple1) { if(nbOfComp1==nbOfComp2) @@ -2817,10 +2825,10 @@ namespace MEDCoupling { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DataArrayDouble::MulAdd : input DataArrayDouble instance is NULL !"); - mcIdType nbOfTuple=ToIdType(a1->getNumberOfTuples()); - mcIdType nbOfTuple2=ToIdType(a2->getNumberOfTuples()); - mcIdType nbOfComp=ToIdType(a1->getNumberOfComponents()); - mcIdType nbOfComp2=ToIdType(a2->getNumberOfComponents()); + mcIdType nbOfTuple(a1->getNumberOfTuples()); + mcIdType nbOfTuple2(a2->getNumberOfTuples()); + std::size_t nbOfComp(a1->getNumberOfComponents()); + std::size_t nbOfComp2(a2->getNumberOfComponents()); MCAuto::ArrayType> ret=0; if(nbOfTuple==nbOfTuple2) { @@ -2833,7 +2841,7 @@ namespace MEDCoupling } else { - mcIdType nbOfCompMin,nbOfCompMax; + std::size_t nbOfCompMin,nbOfCompMax; const typename Traits::ArrayType *aMin, *aMax; if(nbOfComp>nbOfComp2) { @@ -3106,31 +3114,31 @@ struct NotInRange for(it=a.begin();it!=a.end();it++) (*it)->checkAllocated(); it=a.begin(); - std::size_t nbOfTuples((*it)->getNumberOfTuples()); - std::vector nbc(a.size()); + mcIdType nbOfTuples((*it)->getNumberOfTuples()); + std::vector nbc(a.size()); std::vector pts(a.size()); - nbc[0]=ToIdType((*it)->getNumberOfComponents()); + nbc[0]=(*it)->getNumberOfComponents(); pts[0]=(*it++)->getConstPointer(); for(int i=1;it!=a.end();it++,i++) { if(nbOfTuples!=(*it)->getNumberOfTuples()) throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : mismatch of number of tuples !"); - nbc[i]=ToIdType((*it)->getNumberOfComponents()); + nbc[i]=(*it)->getNumberOfComponents(); pts[i]=(*it)->getConstPointer(); } - int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0); + std::size_t totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),(std::size_t)0); typename Traits::ArrayType *ret(Traits::ArrayType::New()); ret->alloc(nbOfTuples,totalNbOfComp); T *retPtr(ret->getPointer()); - for(std::size_t i=0;isetInfoOnComponent(k,a[i]->getInfoOnComponent(j)); return ret; } @@ -3150,9 +3158,9 @@ struct NotInRange { if(this->_mem.isNull()) throw INTERP_KERNEL::Exception("DataArrayDouble::fromNoInterlace : Not defined array !"); - T *tab(this->_mem.fromNoInterlace(ToIdType(this->getNumberOfComponents()))); + T *tab(this->_mem.fromNoInterlace(this->getNumberOfComponents())); MCAuto::ArrayType> ret(Traits::ArrayType::New()); - ret->useArray(tab,true,DeallocType::C_DEALLOC,ToIdType(this->getNumberOfTuples()),ToIdType(this->getNumberOfComponents())); + ret->useArray(tab,true,DeallocType::C_DEALLOC,this->getNumberOfTuples(),this->getNumberOfComponents()); return ret.retn(); } @@ -3171,9 +3179,9 @@ struct NotInRange { if(this->_mem.isNull()) throw INTERP_KERNEL::Exception("DataArrayDouble::toNoInterlace : Not defined array !"); - T *tab(this->_mem.toNoInterlace(ToIdType(this->getNumberOfComponents()))); + T *tab(this->_mem.toNoInterlace(this->getNumberOfComponents())); MCAuto::ArrayType> ret(Traits::ArrayType::New()); - ret->useArray(tab,true,DeallocType::C_DEALLOC,ToIdType(this->getNumberOfTuples()),ToIdType(this->getNumberOfComponents())); + ret->useArray(tab,true,DeallocType::C_DEALLOC,this->getNumberOfTuples(),this->getNumberOfComponents()); return ret.retn(); } @@ -3196,11 +3204,11 @@ struct NotInRange { this->checkAllocated(); other->checkAllocated(); - mcIdType nbOfTuples=ToIdType((this->getNumberOfTuples())); - if(nbOfTuples!=ToIdType(other->getNumberOfTuples())) + mcIdType nbOfTuples(this->getNumberOfTuples()); + if(nbOfTuples!=other->getNumberOfTuples()) throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !"); - mcIdType nbOfComp1=ToIdType(this->getNumberOfComponents()); - mcIdType nbOfComp2=ToIdType(other->getNumberOfComponents()); + std::size_t nbOfComp1=this->getNumberOfComponents(); + std::size_t nbOfComp2=other->getNumberOfComponents(); T *newArr=(T *)malloc((nbOfTuples*(nbOfComp1+nbOfComp2))*sizeof(T)); T *w=newArr; const T *inp1(this->begin()),*inp2(other->begin()); @@ -3210,8 +3218,8 @@ struct NotInRange w=std::copy(inp2,inp2+nbOfComp2,w); } this->useArray(newArr,true,DeallocType::C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2); - std::vector compIds(nbOfComp2); - for(int i=0;i compIds(nbOfComp2); + for(std::size_t i=0;icopyPartOfStringInfoFrom2(compIds,*other); } @@ -3231,7 +3239,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayDouble::duplicateEachTupleNTimes : this should have only one component !"); if(nbTimes<1) throw INTERP_KERNEL::Exception("DataArrayDouble::duplicateEachTupleNTimes : nb times should be >= 1 !"); - mcIdType nbTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbTuples=this->getNumberOfTuples(); const T *inPtr(this->begin()); MCAuto::ArrayType> ret(Traits::ArrayType::New()); ret->alloc(nbTimes*nbTuples,1); T *retPtr(ret->getPointer()); @@ -3289,7 +3297,7 @@ struct NotInRange { this->checkAllocated(); MCAuto::ArrayType> newArr(Traits::ArrayType::New()); - std::size_t nbOfTuples(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); std::size_t nbOfComp(this->getNumberOfComponents()); newArr->alloc(nbOfTuples,nbOfComp); std::transform(this->begin(),this->end(),newArr->getPointer(),std::ptr_fun(std::abs)); @@ -3324,12 +3332,13 @@ struct NotInRange typename Traits::ArrayType *DataArrayTemplateClassic::sumPerTuple() const { this->checkAllocated(); - std::size_t nbOfComp(this->getNumberOfComponents()),nbOfTuple(this->getNumberOfTuples()); + std::size_t nbOfComp(this->getNumberOfComponents()); + mcIdType nbOfTuple(this->getNumberOfTuples()); MCAuto::ArrayType> ret(Traits::ArrayType::New()); ret->alloc(nbOfTuple,1); const T *src(this->begin()); T *dest(ret->getPointer()); - for(std::size_t i=0;igetNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayDouble::iota : works only for arrays with only one component, you can call 'rearrange' method before !"); T *ptr(this->getPointer()); - std::size_t ntuples(this->getNumberOfTuples()); - for(std::size_t i=0;igetNumberOfTuples()); + for(mcIdType i=0;ideclareAsNew(); } @@ -3569,11 +3578,11 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleEqualTo : number of components of this should be equal to one !"); - std::size_t nbOfTuples(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); if(nbOfTuples!=vec.size()) throw INTERP_KERNEL::Exception("DataArrayInt::switchOnTupleEqualTo : number of tuples of this should be equal to size of input vector of bool !"); const T *pt(this->begin()); - for(std::size_t i=0;icheckAllocated(); if(this->getNumberOfComponents()!=1 || other.getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' have to have exactly ONE component !"); - mcIdType nbTuple=ToIdType(this->getNumberOfTuples()); + mcIdType nbTuple(this->getNumberOfTuples()); other.checkAllocated(); - if(nbTuple!=ToIdType(other.getNumberOfTuples())) + if(nbTuple!=other.getNumberOfTuples()) throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' must have the same number of tuple !"); MCAuto ret(DataArrayIdType::New()); ret->alloc(nbTuple,1); @@ -3676,7 +3685,7 @@ struct NotInRange if(this->getNumberOfComponents()!=1 || partOfThis.getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::indicesOfSubPart : this and input array must be one component array !"); this->checkAllocated(); partOfThis.checkAllocated(); - mcIdType thisNbTuples=ToIdType(this->getNumberOfTuples()),nbTuples=ToIdType(partOfThis.getNumberOfTuples()); + mcIdType thisNbTuples(this->getNumberOfTuples()),nbTuples(partOfThis.getNumberOfTuples()); const T *thisPt(this->begin()),*pt(partOfThis.begin()); MCAuto ret(DataArrayIdType::New()); ret->alloc(nbTuples,1); @@ -3839,8 +3848,8 @@ struct NotInRange template void DataArrayDiscrete::reprCppStream(const std::string& varName, std::ostream& stream) const { - mcIdType nbTuples=ToIdType(this->getNumberOfTuples()); - mcIdType nbComp=ToIdType(this->getNumberOfComponents()); + mcIdType nbTuples(this->getNumberOfTuples()); + std::size_t nbComp(this->getNumberOfComponents()); const T *data(this->getConstPointer()); stream << Traits::ArrayTypeName << " *" << varName << "=" << Traits::ArrayTypeName << "::New();" << std::endl; if(nbTuples*nbComp>=1) @@ -3868,7 +3877,7 @@ struct NotInRange std::size_t nbOfCompo(this->getNumberOfComponents()); if(nbOfCompo>=1) { - std::size_t nbOfTuples(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); stream << "Number of tuples : " << nbOfTuples << ". Number of components : " << nbOfCompo << "." << std::endl; reprQuickOverviewData(stream,MAX_NB_OF_BYTE_IN_REPR); } @@ -3883,7 +3892,8 @@ struct NotInRange void DataArrayDiscrete::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const T *data(this->begin()); - std::size_t nbOfTuples(this->getNumberOfTuples()),nbOfCompo(this->getNumberOfComponents()); + mcIdType nbOfTuples(this->getNumberOfTuples()); + std::size_t nbOfCompo(this->getNumberOfComponents()); std::ostringstream oss2; oss2 << "["; std::string oss2Str(oss2.str()); bool isFinished=true; @@ -3980,9 +3990,9 @@ struct NotInRange if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component, you can call 'rearrange' method before !"); mcIdType nbElemsIn=ToIdType(std::distance(indArrBg,indArrEnd)); - std::size_t nbOfTuples(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); T *pt(this->getPointer()); - for(std::size_t i=0;i=0 && *ptgetNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component, you can call 'rearrange' method before !"); const typename std::map& dat(m.data()); - std::size_t nbOfTuples(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); T *pt(this->getPointer()); - for(std::size_t i=0;i::const_iterator it(dat.find(*pt)); if(it!=dat.end()) @@ -4036,8 +4046,8 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqual : the array must have only one component, you can call 'rearrange' method before !"); const T *cptr(this->getConstPointer()); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); - std::size_t nbOfTuples(this->getNumberOfTuples()); - for(std::size_t i=0;igetNumberOfTuples()); + for(mcIdType i=0;ipushBackSilent(ToIdType(i)); return ret.retn(); @@ -4066,7 +4076,7 @@ struct NotInRange if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("Call transformWithIndArrR method on DataArrayInt with only one component, you can call 'rearrange' method before !"); mcIdType nbElemsIn=ToIdType(std::distance(indArrBg,indArrEnd)); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); const T *pt=this->getConstPointer(); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfTuples,1); @@ -4147,7 +4157,7 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("Call splitByValueRange method on DataArrayInt with only one component, you can call 'rearrange' method before !"); - std::size_t nbOfTuples=this->getNumberOfTuples(); + mcIdType nbOfTuples=this->getNumberOfTuples(); std::size_t nbOfCast=std::distance(arrBg,arrEnd); if(nbOfCast<2) throw INTERP_KERNEL::Exception("DataArrayInt::splitByValueRange : The input array giving the cast range values should be of size >=2 !"); @@ -4164,7 +4174,7 @@ struct NotInRange T *ret1Ptr=ret1->getPointer(); T *ret2Ptr=ret2->getPointer(); std::set castsDetected; - for(std::size_t i=0;i(), work[i])); std::size_t pos=std::distance(bg,res); @@ -4206,7 +4216,7 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::isRange : this must be single component array !"); - mcIdType nbTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbTuples(this->getNumberOfTuples()); if(nbTuples==0) { strt=0; sttoopp=0; stteepp=1; return true; } const T *pt(this->begin()); @@ -4262,7 +4272,7 @@ struct NotInRange { MCAuto ret(DataArrayIdType::New()); ret->alloc(newNbOfElem,1); - mcIdType nbOfOldNodes=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfOldNodes(this->getNumberOfTuples()); const T *old2New(this->begin()); mcIdType *pt(ret->getPointer()); for(mcIdType i=0;i!=nbOfOldNodes;i++) @@ -4308,7 +4318,7 @@ struct NotInRange const T *new2Old=this->getConstPointer(); mcIdType *pt=ret->getPointer(); std::fill(pt,pt+oldNbOfElem,-1); - mcIdType nbOfNewElems=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfNewElems(this->getNumberOfTuples()); for(mcIdType i=0;i ret=DataArrayIdType::New(); ret->alloc(newNbOfElem,1); - mcIdType nbOfOldNodes=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfOldNodes(this->getNumberOfTuples()); const T *old2New=this->getConstPointer(); mcIdType *pt=ret->getPointer(); for(mcIdType i=nbOfOldNodes-1;i>=0;i--) @@ -4376,7 +4386,7 @@ struct NotInRange MCAuto< MapKeyVal > ret(MapKeyVal::New()); std::map& m(ret->data()); const T *new2Old(this->begin()); - mcIdType nbOfNewElems=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfNewElems(this->getNumberOfTuples()); for(mcIdType i=0;i > ret(MapKeyVal::New()); std::map& m(ret->data()); const T *new2Old(this->begin()); - mcIdType nbOfNewElems=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfNewElems(this->getNumberOfTuples()); for(mcIdType i=0;icheckAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::checkAndPreparePermutation : number of components must == 1 !"); - mcIdType nbTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbTuples(this->getNumberOfTuples()); const T *pt=this->getConstPointer(); mcIdType *pt2=this->CheckAndPreparePermutation(pt,pt+nbTuples); DataArrayIdType *ret=DataArrayIdType::New(); @@ -4521,7 +4531,7 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::changeSurjectiveFormat : number of components must == 1 !"); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); const T *input=this->getConstPointer(); std::vector< std::vector > tmp(targetNb); for(mcIdType i=0;icheckAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::buildPermArrPerLevel : number of components must == 1 !"); - std::size_t nbOfTuples=this->getNumberOfTuples(); + mcIdType nbOfTuples=this->getNumberOfTuples(); const T *pt=this->getConstPointer(); std::map m; MCAuto ret=DataArrayIdType::New(); ret->alloc(nbOfTuples,1); mcIdType *opt=ret->getPointer(); - for(std::size_t i=0;i::iterator it=m.find(val); @@ -4603,7 +4613,7 @@ struct NotInRange } pt=this->getConstPointer(); opt=ret->getPointer(); - for(std::size_t i=0;icheckAllocated(); if(this->getNumberOfComponents()!=1) return false; - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); if(nbOfTuples!=sizeExpected) return false; const T *pt=this->getConstPointer(); @@ -4696,9 +4706,9 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::hasOnlyUniqueValues: must be applied on DataArrayInt with only one component, you can call 'rearrange' method before !"); - std::size_t nbOfTuples(this->getNumberOfTuples()); + std::size_t nbOfElements(this->getNumberOfTuples()); std::set s(this->begin(),this->end()); // in C++11, should use unordered_set (O(1) complexity) - if (s.size() != nbOfTuples) + if (s.size() != nbOfElements) return false; return true; } @@ -4720,7 +4730,7 @@ struct NotInRange * \endif */ template - void DataArrayDiscrete::setSelectedComponents(const DataArrayType *a, const std::vector& compoIds) + void DataArrayDiscrete::setSelectedComponents(const DataArrayType *a, const std::vector& compoIds) { if(!a) throw INTERP_KERNEL::Exception("DataArrayInt::setSelectedComponents : input DataArrayInt is NULL !"); @@ -4728,14 +4738,21 @@ struct NotInRange a->checkAllocated(); this->copyPartOfStringInfoFrom2(compoIds,*a); std::size_t partOfCompoSz=compoIds.size(); - mcIdType nbOfCompo=ToIdType(this->getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(std::min(this->getNumberOfTuples(),a->getNumberOfTuples())); + std::size_t nbOfCompo = this->getNumberOfComponents(); + mcIdType nbOfTuples=std::min(this->getNumberOfTuples(),a->getNumberOfTuples()); const T *ac=a->getConstPointer(); T *nc=this->getPointer(); for(mcIdType i=0;i + void DataArrayDiscrete::setSelectedComponents(const DataArrayType *a, const std::vector& compoIds) + { + std::vector ids (compoIds.size()); + std::copy(compoIds.begin(), compoIds.end(), ids.begin()); + setSelectedComponents (a, ids); + } /*! * Creates a new DataArrayInt containing IDs (indices) of tuples holding value \b not @@ -4755,7 +4772,7 @@ struct NotInRange const T *cptr(this->getConstPointer()); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); for(mcIdType i=0;ipushBackSilent(i); @@ -4778,9 +4795,9 @@ struct NotInRange template DataArrayIdType *DataArrayDiscrete::findIdsEqualTuple(const T *tupleBg, const T *tupleEnd) const { - mcIdType nbOfCompoExp=ToIdType(std::distance(tupleBg,tupleEnd)); + std::size_t nbOfCompoExp=std::distance(tupleBg,tupleEnd); this->checkAllocated(); - if(ToIdType(this->getNumberOfComponents())!=nbOfCompoExp) + if(this->getNumberOfComponents()!=nbOfCompoExp) { std::ostringstream oss; oss << "DataArrayInt::findIdsEqualTuple : mismatch of number of components. Input tuple has " << nbOfCompoExp << " whereas this array has " << this->getNumberOfComponents() << " components !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -4795,9 +4812,9 @@ struct NotInRange work=std::search(work,end2,tupleBg,tupleEnd); if(work!=end2) { - mcIdType pos=ToIdType(std::distance(bg,work)); + std::ptrdiff_t pos=std::distance(bg,work); if(pos%nbOfCompoExp==0) - ret->pushBackSilent(pos/nbOfCompoExp); + ret->pushBackSilent(ToIdType(pos/nbOfCompoExp)); work++; } } @@ -4821,7 +4838,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::findIdsEqualList : the array must have only one component, you can call 'rearrange' method before !"); std::set vals2(valsBg,valsEnd); const T *cptr(this->getConstPointer()); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); for(mcIdType i=0;i vals2(valsBg,valsEnd); const T *cptr=this->getConstPointer(); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); MCAuto ret(DataArrayIdType::New()); ret->alloc(0,1); for(mcIdType i=0;igetNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !"); const T *cptr=this->getConstPointer(); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); const T *ret=std::find(cptr,cptr+nbOfTuples,value); if(ret!=cptr+nbOfTuples) return ToIdType(std::distance(cptr,ret)); @@ -4888,7 +4905,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !"); std::set vals2(vals.begin(),vals.end()); const T *cptr=this->getConstPointer(); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); for(const T *w=cptr;w!=cptr+nbOfTuples;w++) if(vals2.find(*w)!=vals2.end()) return ToIdType(std::distance(cptr,w)); @@ -4911,10 +4928,10 @@ struct NotInRange mcIdType DataArrayDiscrete::findIdFirstEqualTuple(const std::vector& tupl) const { this->checkAllocated(); - mcIdType nbOfCompo=ToIdType(this->getNumberOfComponents()); + std::size_t nbOfCompo(this->getNumberOfComponents()); if(nbOfCompo==0) throw INTERP_KERNEL::Exception("DataArrayInt::findIdFirstEqualTuple : 0 components in 'this' !"); - if(nbOfCompo!=ToIdType(tupl.size())) + if(nbOfCompo!=tupl.size()) { std::ostringstream oss; oss << "DataArrayInt::findIdFirstEqualTuple : 'this' contains " << nbOfCompo << " components and searching for a tuple of length " << tupl.size() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -5005,8 +5022,8 @@ struct NotInRange if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::count : must be applied on DataArrayInt with only one component, you can call 'rearrange' method before !"); const T *vals=this->begin(); - std::size_t nbOfTuples=this->getNumberOfTuples(); - for(std::size_t i=0;igetNumberOfTuples(); + for(std::size_t i=0;icheckAllocated(); const T *ptr=this->getConstPointer(); - mcIdType nbTuple=ToIdType(this->getNumberOfTuples()); - mcIdType nbComps=ToIdType(this->getNumberOfComponents()); + mcIdType nbTuple(this->getNumberOfTuples()); + std::size_t nbComps(this->getNumberOfComponents()); std::fill(res,res+nbComps,0); for(mcIdType i=0;i()); } template - T DataArrayDiscrete::accumulate(mcIdType compId) const + T DataArrayDiscrete::accumulate(std::size_t compId) const { this->checkAllocated(); const T *ptr=this->getConstPointer(); - mcIdType nbTuple=ToIdType(this->getNumberOfTuples()); - mcIdType nbComps=ToIdType(this->getNumberOfComponents()); + mcIdType nbTuple(this->getNumberOfTuples()); + std::size_t nbComps(this->getNumberOfComponents()); if(compId<0 || compId>=nbComps) throw INTERP_KERNEL::Exception("DataArrayInt::accumulate : Invalid compId specified : No such nb of components !"); T ret=0; @@ -5109,8 +5126,8 @@ struct NotInRange if(!bgOfIndex || !endOfIndex) throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : input pointer NULL !"); this->checkAllocated(); - mcIdType nbCompo=ToIdType(this->getNumberOfComponents()); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + std::size_t nbCompo(this->getNumberOfComponents()); + mcIdType nbOfTuples(this->getNumberOfTuples()); mcIdType sz=ToIdType(std::distance(bgOfIndex,endOfIndex)); if(sz<1) throw INTERP_KERNEL::Exception("DataArrayInt::accumulatePerChunck : invalid size of input index array !"); @@ -5162,10 +5179,10 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::getMinMaxValues : must be applied on DataArrayInt with only one component !"); - std::size_t nbTuples(this->getNumberOfTuples()); + std::size_t nbElements(this->getNumberOfTuples()); const T *pt(this->begin()); minValue=std::numeric_limits::max(); maxValue=-std::numeric_limits::max(); - for(std::size_t i=0;icheckAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::checkAllIdsInRange : this must have exactly one component !"); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); bool ret=true; const T *cptr=this->getConstPointer(); for(mcIdType i=0;i tmp(nbOfElement); const T *pt=this->getConstPointer(); - std::size_t nbOfTuples=this->getNumberOfTuples(); - for(const T *w=pt;w!=pt+nbOfTuples;w++) + std::size_t nbOfElements=this->getNumberOfTuples(); + for(const T *w=pt;w!=pt+nbOfElements;w++) if(*w>=0 && *wgetNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed for other type !"); const T *pt=this->getConstPointer(); - std::size_t nbOfTuples=this->getNumberOfTuples(); - std::set s1(pt,pt+nbOfTuples); + std::size_t nbOfElements=this->getNumberOfTuples(); + std::set s1(pt,pt+nbOfElements); pt=other->getConstPointer(); - nbOfTuples=other->getNumberOfTuples(); - std::set s2(pt,pt+nbOfTuples); + nbOfElements=other->getNumberOfTuples(); + std::set s2(pt,pt+nbOfElements); std::vector r; std::set_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector >(r)); DataArrayType *ret=DataArrayType::New(); @@ -5565,11 +5582,11 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::buildUnique : only single component allowed !"); - std::size_t nbOfTuples=this->getNumberOfTuples(); + std::size_t nbOfElements=this->getNumberOfTuples(); MCAuto tmp=DataArrayType::New(); tmp->deepCopyFrom (*this); T *data=tmp->getPointer(); - T *last=std::unique(data,data+nbOfTuples); + T *last=std::unique(data,data+nbOfElements); MCAuto ret=DataArrayType::New(); ret->alloc(std::distance(data,last),1); std::copy(data,last,ret->getPointer()); @@ -5637,14 +5654,14 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : only single component allowed !"); - std::size_t nbOfTuples=this->getNumberOfTuples(); - if(nbOfTuples<2) + std::size_t nbOfElements=this->getNumberOfTuples(); + if(nbOfElements<2) throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : 1 tuple at least must be present in 'this' !"); const T *ptr=this->getConstPointer(); DataArrayType *ret=DataArrayType::New(); - ret->alloc(nbOfTuples-1,1); + ret->alloc(nbOfElements-1,1); T *out=ret->getPointer(); - std::transform(ptr+1,ptr+nbOfTuples,ptr,out,std::minus()); + std::transform(ptr+1,ptr+nbOfElements,ptr,out,std::minus()); return ret; } @@ -5671,13 +5688,13 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsets : only single component allowed !"); - std::size_t nbOfTuples=this->getNumberOfTuples(); - if(nbOfTuples==0) + std::size_t nbOfElements=this->getNumberOfTuples(); + if(nbOfElements==0) return ; T *work=this->getPointer(); T tmp=work[0]; work[0]=0; - for(std::size_t i=1;icheckAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsetsFull : only single component allowed !"); - std::size_t nbOfTuples=this->getNumberOfTuples(); - T *ret=(T *)malloc((nbOfTuples+1)*sizeof(T)); + std::size_t nbOfElements=this->getNumberOfTuples(); + T *ret=(T *)malloc((nbOfElements+1)*sizeof(T)); const T *work=this->getConstPointer(); ret[0]=0; - for(std::size_t i=0;iuseArray(ret,true,DeallocType::C_DEALLOC,ToIdType(nbOfTuples)+1,1); + this->useArray(ret,true,DeallocType::C_DEALLOC,nbOfElements+1,1); this->declareAsNew(); } @@ -5809,8 +5826,8 @@ struct NotInRange offsets->checkAllocated(); if(offsets->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : input array should have only single component !"); - mcIdType othNbTuples=ToIdType(offsets->getNumberOfTuples())-1; - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + mcIdType othNbTuples=offsets->getNumberOfTuples()-1; + mcIdType nbOfTuples=this->getNumberOfTuples(); T retNbOftuples=0; const T *work=this->getConstPointer(); const T *offPtr=offsets->getConstPointer(); @@ -5876,7 +5893,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : not allocated array !"); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : number of components is expected to be equal to one !"); - mcIdType nbOfTuples = ToIdType(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); if(nbOfTuples==0) throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr : number of tuples must be != 0 !"); const T *ids(this->begin()); @@ -5939,9 +5956,9 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::findRangeIdForEachTuple : this should have only one component !"); - mcIdType nbTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbTuples(this->getNumberOfTuples()); MCAuto ret=DataArrayIdType::New(); ret->alloc(nbTuples,1); - mcIdType nbOfRanges=ToIdType(ranges->getNumberOfTuples()); + mcIdType nbOfRanges(ranges->getNumberOfTuples()); const T *rangesPtr=ranges->getConstPointer(); mcIdType *retPtr=ret->getPointer(); const T *inPtr=this->getConstPointer(); @@ -5989,17 +6006,17 @@ struct NotInRange this->checkAllocated(); if(this->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayInt::findIdInRangeForEachTuple : this should have only one component !"); - std::size_t nbTuples=this->getNumberOfTuples(); + mcIdType nbTuples=this->getNumberOfTuples(); MCAuto ret=DataArrayType::New(); ret->alloc(nbTuples,1); - std::size_t nbOfRanges=ranges->getNumberOfTuples(); + mcIdType nbOfRanges=ranges->getNumberOfTuples(); const T *rangesPtr=ranges->getConstPointer(); T *retPtr=ret->getPointer(); const T *inPtr=this->getConstPointer(); - for(std::size_t i=0;i=rangesPtr[2*j] && valcheckAllocated(); if(this->getNumberOfComponents()!=2) throw INTERP_KERNEL::Exception("DataArrayInt::sortEachPairToMakeALinkedList : Only works on DataArrayInt instance with nb of components equal to 2 !"); - std::size_t nbOfTuples(this->getNumberOfTuples()); + mcIdType nbOfTuples(this->getNumberOfTuples()); if(nbOfTuples<=1) return ; T *conn(this->getPointer()); - for(std::size_t i=1;i1) { @@ -6091,7 +6108,7 @@ struct NotInRange { this->checkAllocated(); this->checkNbOfComps(2,"DataArrayInt::fromLinkedListOfPairToList : this is expected to have 2 components"); - mcIdType nbTuples=ToIdType(this->getNumberOfTuples()); + mcIdType nbTuples(this->getNumberOfTuples()); if(nbTuples<1) throw INTERP_KERNEL::Exception("DataArrayInt::fromLinkedListOfPairToList : no tuples in this ! Not a linked list !"); MCAuto ret(DataArrayType::New()); ret->alloc(nbTuples+1,1); @@ -6183,8 +6200,8 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::splitInBalancedSlices : this array should have number of components equal to one and must be allocated !"); if(nbOfSlices<=0) throw INTERP_KERNEL::Exception("DataArrayInt::splitInBalancedSlices : number of slices must be >= 1 !"); - T sum(this->accumulate(0)); - mcIdType nbOfTuples=ToIdType(this->getNumberOfTuples()); + T sum(this->accumulate((std::size_t)0)); + mcIdType nbOfTuples(this->getNumberOfTuples()); T sumPerSlc(sum/nbOfSlices); mcIdType pos(0); const T *w(this->begin()); @@ -6228,10 +6245,10 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::modulusEqual : input DataArrayInt instance is NULL !"); const char *msg="Nb of tuples mismatch for DataArrayInt::modulusEqual !"; this->checkAllocated(); other->checkAllocated(); - mcIdType nbOfTuple=ToIdType(this->getNumberOfTuples()); - mcIdType nbOfTuple2=ToIdType(other->getNumberOfTuples()); - mcIdType nbOfComp=ToIdType(this->getNumberOfComponents()); - mcIdType nbOfComp2=ToIdType(other->getNumberOfComponents()); + mcIdType nbOfTuple(this->getNumberOfTuples()); + mcIdType nbOfTuple2(other->getNumberOfTuples()); + std::size_t nbOfComp(this->getNumberOfComponents()); + std::size_t nbOfComp2(other->getNumberOfComponents()); if(nbOfTuple==nbOfTuple2) { if(nbOfComp==nbOfComp2) @@ -6279,8 +6296,8 @@ struct NotInRange { if(!other) throw INTERP_KERNEL::Exception("DataArrayInt::powEqual : input instance is null !"); - std::size_t nbOfTuple=this->getNumberOfTuples(); - std::size_t nbOfTuple2=other->getNumberOfTuples(); + mcIdType nbOfTuple=this->getNumberOfTuples(); + mcIdType nbOfTuple2=other->getNumberOfTuples(); std::size_t nbOfComp=this->getNumberOfComponents(); std::size_t nbOfComp2=other->getNumberOfComponents(); if(nbOfTuple!=nbOfTuple2) @@ -6289,7 +6306,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::powEqual : number of components of both arrays must be equal to 1 !"); T *ptr=this->getPointer(); const T *ptrc=other->begin(); - for(std::size_t i=0;i=0) { @@ -6318,7 +6335,7 @@ struct NotInRange tinyInfo.resize(2); if(this->isAllocated()) { - tinyInfo[0]=ToIdType(this->getNumberOfTuples()); + tinyInfo[0]=this->getNumberOfTuples(); tinyInfo[1]=ToIdType(this->getNumberOfComponents()); } else @@ -6337,10 +6354,10 @@ struct NotInRange { if(this->isAllocated()) { - mcIdType nbOfCompo=ToIdType(this->getNumberOfComponents()); + std::size_t nbOfCompo(this->getNumberOfComponents()); tinyInfo.resize(nbOfCompo+1); tinyInfo[0]=this->getName(); - for(mcIdType i=0;igetInfoOnComponent(i); } else @@ -6404,8 +6421,8 @@ struct NotInRange { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DataArrayInt::Pow : at least one of input instances is null !"); - std::size_t nbOfTuple=a1->getNumberOfTuples(); - std::size_t nbOfTuple2=a2->getNumberOfTuples(); + mcIdType nbOfTuple=a1->getNumberOfTuples(); + mcIdType nbOfTuple2=a2->getNumberOfTuples(); std::size_t nbOfComp=a1->getNumberOfComponents(); std::size_t nbOfComp2=a2->getNumberOfComponents(); if(nbOfTuple!=nbOfTuple2) @@ -6415,7 +6432,7 @@ struct NotInRange MCAuto ret=DataArrayType::New(); ret->alloc(nbOfTuple,1); const T *ptr1(a1->begin()),*ptr2(a2->begin()); T *ptr=ret->getPointer(); - for(std::size_t i=0;i=0) { @@ -6464,10 +6481,10 @@ struct NotInRange { if(!a1 || !a2) throw INTERP_KERNEL::Exception("DataArrayInt::Modulus : input DataArrayInt instance is NULL !"); - mcIdType nbOfTuple1=ToIdType(a1->getNumberOfTuples()); - mcIdType nbOfTuple2=ToIdType(a2->getNumberOfTuples()); - mcIdType nbOfComp1=ToIdType(a1->getNumberOfComponents()); - mcIdType nbOfComp2=ToIdType(a2->getNumberOfComponents()); + mcIdType nbOfTuple1(a1->getNumberOfTuples()); + mcIdType nbOfTuple2(a2->getNumberOfTuples()); + std::size_t nbOfComp1(a1->getNumberOfComponents()); + std::size_t nbOfComp2(a2->getNumberOfComponents()); if(nbOfTuple2==nbOfTuple1) { if(nbOfComp1==nbOfComp2) @@ -6557,7 +6574,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::FindPermutationFromFirstToSecond : the two arrays are not lying on same ids ! Impossible to find a permutation between the 2 arrays !"); MCAuto p1=ids1->checkAndPreparePermutation(); MCAuto p2=ids2->checkAndPreparePermutation(); - p2=p2->invertArrayO2N2N2O(ToIdType(p2->getNumberOfTuples())); + p2=p2->invertArrayO2N2N2O(p2->getNumberOfTuples()); p2=p2->selectByTupleIdSafe(p1->begin(),p1->end()); return p2.retn(); } @@ -6624,7 +6641,7 @@ struct NotInRange std::size_t nbOfComp(a1->getNumberOfComponents()); if(nbOfComp!=a2->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Nb of components mismatch for array Aggregation !"); - std::size_t nbOfTuple1(a1->getNumberOfTuples()),nbOfTuple2(a2->getNumberOfTuples()); + mcIdType nbOfTuple1(a1->getNumberOfTuples()),nbOfTuple2(a2->getNumberOfTuples()); MCAuto ret(DataArrayType::New()); ret->alloc(nbOfTuple1+nbOfTuple2-offsetA2,nbOfComp); T *pt=std::copy(a1->begin(),a1->end(),ret->getPointer()); @@ -6658,7 +6675,8 @@ struct NotInRange if(a.empty()) throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : input list must be NON EMPTY !"); typename std::vector::const_iterator it=a.begin(); - std::size_t nbOfComp((*it)->getNumberOfComponents()),nbt((*it++)->getNumberOfTuples()); + std::size_t nbOfComp((*it)->getNumberOfComponents()); + mcIdType nbt((*it++)->getNumberOfTuples()); for(;it!=a.end();it++) { if((*it)->getNumberOfComponents()!=nbOfComp) @@ -6696,7 +6714,7 @@ struct NotInRange std::ostringstream oss; oss << "DataArrayInt::AggregateIndexes : presence of a DataArrayInt instance with nb of compo != 1 at pos " << std::distance(arrs.begin(),it4) << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbTupl=ToIdType((*it4)->getNumberOfTuples()); + mcIdType nbTupl((*it4)->getNumberOfTuples()); if(nbTupl<1) { std::ostringstream oss; oss << "DataArrayInt::AggregateIndexes : presence of a DataArrayInt instance with nb of tuples < 1 at pos " << std::distance(arrs.begin(),it4) << " !"; @@ -6754,7 +6772,7 @@ struct NotInRange for(typename std::vector::const_iterator it=a.begin();it!=a.end();it++) { const T *pt=(*it)->getConstPointer(); - mcIdType nbOfTuples=ToIdType((*it)->getNumberOfTuples()); + mcIdType nbOfTuples((*it)->getNumberOfTuples()); r.insert(pt,pt+nbOfTuples); } DataArrayType *ret=DataArrayType::New(); @@ -6791,7 +6809,7 @@ struct NotInRange for(typename std::vector::const_iterator it=a.begin();it!=a.end();it++) { const T *pt=(*it)->getConstPointer(); - mcIdType nbOfTuples=ToIdType((*it)->getNumberOfTuples()); + mcIdType nbOfTuples((*it)->getNumberOfTuples()); std::set s1(pt,pt+nbOfTuples); if(it!=a.begin()) { @@ -6861,10 +6879,10 @@ struct NotInRange std::size_t sz=std::distance(idsOfSelectBg,idsOfSelectEnd); const T *arrInPtr=arrIn->begin(); const mcIdType *arrIndxPtr=arrIndxIn->begin(); - mcIdType nbOfGrps=ToIdType(arrIndxIn->getNumberOfTuples())-1; + mcIdType nbOfGrps=arrIndxIn->getNumberOfTuples()-1; if(nbOfGrps<0) throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArrays : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !"); - mcIdType maxSizeOfArr=ToIdType(arrIn->getNumberOfTuples()); + mcIdType maxSizeOfArr(arrIn->getNumberOfTuples()); MCAuto arro=DataArrayType::New(); MCAuto arrIo=DataArrayIdType::New(); arrIo->alloc(sz+1,1); @@ -6937,10 +6955,10 @@ struct NotInRange mcIdType sz=DataArray::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArraysSlice : Input slice "); const T *arrInPtr=arrIn->begin(); const mcIdType *arrIndxPtr=arrIndxIn->begin(); - mcIdType nbOfGrps=ToIdType(arrIndxIn->getNumberOfTuples())-1; + mcIdType nbOfGrps=arrIndxIn->getNumberOfTuples()-1; if(nbOfGrps<0) throw INTERP_KERNEL::Exception("DataArrayInt::ExtractFromIndexedArraysSlice : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !"); - mcIdType maxSizeOfArr=ToIdType(arrIn->getNumberOfTuples()); + mcIdType maxSizeOfArr(arrIn->getNumberOfTuples()); MCAuto arro=DataArrayType::New(); MCAuto arrIo=DataArrayIdType::New(); arrIo->alloc(sz+1,1); @@ -7011,7 +7029,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArrays : presence of null pointer in input parameter !"); MCAuto arro=DataArrayType::New(); MCAuto arrIo=DataArrayIdType::New(); - mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1; + mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; std::vector v(nbOfTuples,true); mcIdType offset=0; const mcIdType *arrIndxInPtr=arrIndxIn->begin(); @@ -7082,7 +7100,7 @@ struct NotInRange throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSlice : presence of null pointer in input parameter !"); MCAuto arro=DataArrayType::New(); MCAuto arrIo=DataArrayIdType::New(); - mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1; + mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; mcIdType offset=0; const mcIdType *arrIndxInPtr=arrIndxIn->begin(); const mcIdType *srcArrIndexPtr=srcArrIndex->begin(); @@ -7143,7 +7161,7 @@ struct NotInRange { if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0) throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdx : presence of null pointer in input parameter !"); - mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1; + mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; const mcIdType *arrIndxInPtr=arrIndxIn->begin(); const mcIdType *srcArrIndexPtr=srcArrIndex->begin(); T *arrInOutPtr=arrInOut->getPointer(); @@ -7189,7 +7207,7 @@ struct NotInRange { if(arrInOut==0 || arrIndxIn==0 || srcArr==0 || srcArrIndex==0) throw INTERP_KERNEL::Exception("DataArrayInt::SetPartOfIndexedArraysSameIdxSlice : presence of null pointer in input parameter !"); - mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1; + mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; const mcIdType *arrIndxInPtr=arrIndxIn->begin(); const mcIdType *srcArrIndexPtr=srcArrIndex->begin(); T *arrInOutPtr=arrInOut->getPointer(); @@ -7236,7 +7254,7 @@ struct NotInRange if(offsetForRemoval<0) throw INTERP_KERNEL::Exception("DataArrayInt::RemoveIdsFromIndexedArrays : offsetForRemoval should be >=0 !"); std::set s(idsToRemoveBg,idsToRemoveEnd); - mcIdType nbOfGrps=ToIdType(arrIndx->getNumberOfTuples())-1; + mcIdType nbOfGrps=arrIndx->getNumberOfTuples()-1; mcIdType *arrIPtr=arrIndx->getPointer(); *arrIPtr++=0; mcIdType previousArrI=0; diff --git a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx index f1ca474c8..9b77c6356 100755 --- a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx @@ -171,11 +171,11 @@ void DataArrayChar::meldWith(const DataArrayChar *other) throw INTERP_KERNEL::Exception("DataArrayChar::meldWith : DataArrayChar pointer in input is NULL !"); checkAllocated(); other->checkAllocated(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); - if(nbOfTuples!=ToIdType(other->getNumberOfTuples())) + mcIdType nbOfTuples=getNumberOfTuples(); + if(nbOfTuples!=other->getNumberOfTuples()) throw INTERP_KERNEL::Exception("DataArrayChar::meldWith : mismatch of number of tuples !"); - mcIdType nbOfComp1=ToIdType(getNumberOfComponents()); - mcIdType nbOfComp2=ToIdType(other->getNumberOfComponents()); + std::size_t nbOfComp1=getNumberOfComponents(); + std::size_t nbOfComp2=other->getNumberOfComponents(); char *newArr=(char *)malloc(nbOfTuples*(nbOfComp1+nbOfComp2)*sizeof(char)); char *w=newArr; const char *inp1=getConstPointer(); @@ -186,8 +186,8 @@ void DataArrayChar::meldWith(const DataArrayChar *other) w=std::copy(inp2,inp2+nbOfComp2,w); } useArray(newArr,true,DeallocType::C_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2); - std::vector compIds(nbOfComp2); - for(int i=0;i compIds(nbOfComp2); + for(std::size_t i=0;i_nb_of_elem and \bnbOfTuples==1 or * \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem. */ -DataArrayByte *DataArrayByteTuple::buildDAByte(int nbOfTuples, int nbOfCompo) const +DataArrayByte *DataArrayByteTuple::buildDAByte(std::size_t nbOfTuples, std::size_t nbOfCompo) const { if((_nb_of_compo==nbOfCompo && nbOfTuples==1) || (_nb_of_compo==nbOfTuples && nbOfCompo==1)) { @@ -1117,7 +1117,7 @@ DataArrayAsciiCharTuple *DataArrayAsciiCharIterator::nextt() return 0; } -DataArrayAsciiCharTuple::DataArrayAsciiCharTuple(char *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) +DataArrayAsciiCharTuple::DataArrayAsciiCharTuple(char *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) { } @@ -1141,7 +1141,7 @@ char DataArrayAsciiCharTuple::asciiCharValue() const * This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or * \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem. */ -DataArrayAsciiChar *DataArrayAsciiCharTuple::buildDAAsciiChar(int nbOfTuples, int nbOfCompo) const +DataArrayAsciiChar *DataArrayAsciiCharTuple::buildDAAsciiChar(std::size_t nbOfTuples, std::size_t nbOfCompo) const { if((_nb_of_compo==nbOfCompo && nbOfTuples==1) || (_nb_of_compo==nbOfTuples && nbOfCompo==1)) { diff --git a/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx b/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx index 58306751e..126287179 100644 --- a/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx @@ -140,7 +140,7 @@ DataArrayFloatIterator::DataArrayFloatIterator(DataArrayFloat *da):DataArrayIter { } -DataArrayFloatTuple::DataArrayFloatTuple(float *pt, int nbOfComp):DataArrayTuple(pt,nbOfComp) +DataArrayFloatTuple::DataArrayFloatTuple(float *pt, std::size_t nbOfComp):DataArrayTuple(pt,nbOfComp) { } @@ -164,7 +164,7 @@ float DataArrayFloatTuple::floatValue() const * This method throws an INTERP_KERNEL::Exception is it is impossible to match sizes of \b this that is too say \b nbOfCompo=this->_nb_of_elem and \bnbOfTuples==1 or * \b nbOfCompo=1 and \bnbOfTuples==this->_nb_of_elem. */ -DataArrayFloat *DataArrayFloatTuple::buildDAFloat(int nbOfTuples, int nbOfCompo) const +DataArrayFloat *DataArrayFloatTuple::buildDAFloat(std::size_t nbOfTuples, std::size_t nbOfCompo) const { return this->buildDA(nbOfTuples,nbOfCompo); } diff --git a/src/MEDCoupling/MEDCouplingSkyLineArray.cxx b/src/MEDCoupling/MEDCouplingSkyLineArray.cxx index 645ed8b69..f554f509d 100755 --- a/src/MEDCoupling/MEDCouplingSkyLineArray.cxx +++ b/src/MEDCoupling/MEDCouplingSkyLineArray.cxx @@ -143,7 +143,7 @@ void MEDCouplingSkyLineArray::convertToPolyhedronConn( MCAuto& c, cI->alloc(_super_index->getNbOfElems(),1); // same number of super packs as number of cells int * cIVecP(cI->getPointer()); MCAuto dsi = _index->deltaShiftIndex(); - int sz = dsi->accumulate(0) + ToIdType(dsi->getNbOfElems()); // think about it: one slot for the type, -1 at the end of each face of the cell + int sz = dsi->accumulate((std::size_t)0) + ToIdType(dsi->getNbOfElems()); // think about it: one slot for the type, -1 at the end of each face of the cell c->alloc(sz, 1); int * cVecP(c->getPointer()); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 2ebf3471e..86c7e27bd 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -343,7 +343,7 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() cons return ret; } -MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector& compoIds) const +MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector& compoIds) const { std::vector arrays; getArrays(arrays); @@ -361,8 +361,14 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedCompon ret->setArrays(arrays3,0); return ret; } +MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector& compoIds) const +{ + std::vector ids (compoIds.size()); + std::copy(compoIds.begin(), compoIds.end(), ids.begin()); + return keepSelectedComponents(ids); +} -void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector& compoIds) +void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector& compoIds) { std::vector arrays1,arrays2; getArrays(arrays1); @@ -377,8 +383,14 @@ void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeD throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondence are not defined symmetrically !"); } } +void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector& compoIds) +{ + std::vector ids (compoIds.size()); + std::copy(compoIds.begin(), compoIds.end(), ids.begin()); + setSelectedComponents (other, ids); +} -void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue) +void MEDCouplingTimeDiscretization::changeNbOfComponents(std::size_t newNbOfComp, double dftValue) { std::vector arrays; getArrays(arrays); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index 8e7379d97..a45f16ef9 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -190,9 +190,11 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *magnitude() const; MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *negate() const; MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *maxPerTuple() const; - MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *keepSelectedComponents(const std::vector& compoIds) const; - MEDCOUPLING_EXPORT virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector& compoIds); - MEDCOUPLING_EXPORT virtual void changeNbOfComponents(int newNbOfComp, double dftValue); + MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *keepSelectedComponents(const std::vector& compoIds) const; + MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *keepSelectedComponents(const std::vector& compoIds) const; + MEDCOUPLING_EXPORT virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector& compoIds); + MEDCOUPLING_EXPORT virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector& compoIds); + MEDCOUPLING_EXPORT virtual void changeNbOfComponents(std::size_t newNbOfComp, double dftValue); MEDCOUPLING_EXPORT virtual void sortPerTuple(bool asc); MEDCOUPLING_EXPORT virtual void setUniformValue(int nbOfTuple, int nbOfCompo, double value); MEDCOUPLING_EXPORT virtual void setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value); diff --git a/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx b/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx index 010b8b273..3bf04217e 100644 --- a/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx @@ -2364,7 +2364,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) // Localize faces in 2D thanks to barycenters MCAuto baryPart = mPartCand->computeCellCenterOfMass(); - vector compo; compo.push_back(2); + vector compo; compo.push_back(2); MCAuto baryPartZ = baryPart->keepSelectedComponents(compo); MCAuto idsGoodPlane = baryPartZ->findIdsInRange(-eps, +eps); if (!idsGoodPlane->getNumberOfTuples()) @@ -2549,7 +2549,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) // Eliminate all edges for which y or z is not null MCAuto baryPart = mPartCand->computeCellCenterOfMass(); - vector compo; compo.push_back(1); + vector compo; compo.push_back(1); MCAuto baryPartY = baryPart->keepSelectedComponents(compo); compo[0] = 2; MCAuto baryPartZ = baryPart->keepSelectedComponents(compo); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx index 17a201041..0708244e6 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest3.cxx @@ -765,7 +765,7 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent2() f1->checkConsistencyLight(); // const int arr2[6]={1,2,1,2,0,0}; - std::vector arr2V(arr2,arr2+6); + std::vector arr2V(arr2,arr2+6); MEDCouplingFieldDouble *f2=f1->keepSelectedComponents(arr2V); CPPUNIT_ASSERT(f2->getMesh()==f1->getMesh()); CPPUNIT_ASSERT(f2->getTimeDiscretization()==ONE_TIME); @@ -787,14 +787,14 @@ void MEDCouplingBasicsTest3::testKeepSetSelectedComponent2() CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f2->getIJ(0,i),1e-14); //setSelectedComponents const int arr3[2]={3,2}; - std::vector arr3V(arr3,arr3+2); + std::vector arr3V(arr3,arr3+2); MEDCouplingFieldDouble *f5=f1->keepSelectedComponents(arr3V); f5->setTime(6.7,8,9); f5->getArray()->setInfoOnComponent(0,"eeee"); f5->getArray()->setInfoOnComponent(1,"ffff"); f5->checkConsistencyLight(); const int arr4[2]={1,2}; - std::vector arr4V(arr4,arr4+2); + std::vector arr4V(arr4,arr4+2); f2->setSelectedComponents(f5,arr4V); CPPUNIT_ASSERT_EQUAL(6,(int)f2->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(5,(int)f2->getNumberOfTuples()); diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index 6064ef744..394309003 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -967,7 +967,7 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * { isPolyh=true; MCAuto tmp2(cur->computeEffectiveNbOfNodesPerCell()); - szD+=tmp2->accumulate(0)+curNbCells; + szD+=tmp2->accumulate((std::size_t)0)+curNbCells; szF+=2*curNbCells+cur->getNodalConnectivity()->getNumberOfTuples(); } } -- 2.39.2