From: emv Date: Wed, 6 Nov 2019 06:32:25 +0000 (+0300) Subject: LOT1 Update: Change API to use size_t for components and mcIdType for tuples X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c7a07375b5f13757576930ad7d6a2f50bafe9d4c;p=tools%2Fmedcoupling.git LOT1 Update: Change API to use size_t for components and mcIdType for tuples - Provide interfaces to make SWIG work - duplicating methods can be easily identified by *cast_to_remove* method. These methods has to be removed after SWIG update. - Change API to use *std::size_t* for Components and *mcIdType* for Tuples in DataArray* classes. - Using correct type for Components and Tuples across MEDCoupling module. --- diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index 19d0dfa6e..0f8504d96 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -184,7 +184,7 @@ void MEDCoupling1GTUMesh::splitProfilePerType(const DataArrayInt *profile, std:: throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::splitProfilePerType : input profile is NULL !"); if(profile->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::splitProfilePerType : input profile should have exactly one component !"); - mcIdType nbTuples=ToIdType(profile->getNumberOfTuples()),nbOfCells=ToIdType(getNumberOfCells()); + mcIdType nbTuples=profile->getNumberOfTuples(),nbOfCells=ToIdType(getNumberOfCells()); code.resize(3); idsInPflPerType.resize(1); code[0]=(int)getCellModelEnum(); code[1]=nbTuples; idsInPflPerType.resize(1); @@ -679,7 +679,7 @@ void MEDCoupling1SGTUMesh::checkConsistency(double eps) const { checkConsistencyLight(); const DataArrayInt *c1(_conn); - mcIdType nbOfTuples=ToIdType(c1->getNumberOfTuples()); + mcIdType nbOfTuples(c1->getNumberOfTuples()); mcIdType nbOfNodesPerCell=ToIdType(_cm->getNumberOfNodes()); if(nbOfTuples%nbOfNodesPerCell!=0) { @@ -1149,7 +1149,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshes(std::vector > bb(sz); std::vector< const MEDCoupling1SGTUMesh * > aa(sz); - int spaceDim=-3; + mcIdType spaceDim=-3; for(std::size_t i=0;i 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); @@ -1865,7 +1865,7 @@ DataArrayInt *MEDCoupling1SGTUMesh::sortHexa8EachOther() quadsTmp->findCommonCells(3,0,cc,cci); ccSafe=cc; cciSafe=cci; const int *ccPtr(ccSafe->begin()); - mcIdType nbOfPair=ToIdType(cci->getNumberOfTuples())-1; + mcIdType nbOfPair=cci->getNumberOfTuples()-1; for(int i=0;isetIJ(i+1,0,ToIdType(cArr->getNumberOfTuples())); + ciArr->setIJ(i+1,0,cArr->getNumberOfTuples()); } ret->setNodalConnectivity(cArr,ciArr); return ret.retn(); @@ -2063,7 +2063,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh2D() const } std::vector zePolyg(MEDCoupling1DGTUMesh::BuildAPolygonFromParts(polyg)); cArr->insertAtTheEnd(zePolyg.begin(),zePolyg.end()); - ciArr->setIJ(i+1,0,ToIdType(cArr->getNumberOfTuples())); + ciArr->setIJ(i+1,0,cArr->getNumberOfTuples()); } ret->setNodalConnectivity(cArr,ciArr); return ret.retn(); @@ -2368,7 +2368,7 @@ void MEDCoupling1DGTUMesh::checkConsistencyOfConnectivity() const else throw INTERP_KERNEL::Exception("Nodal connectivity array not defined !"); // - mcIdType sz2=ToIdType(_conn->getNumberOfTuples()); + mcIdType sz2(_conn->getNumberOfTuples()); c1=_conn_indx; if(c1) { @@ -2424,7 +2424,7 @@ void MEDCoupling1DGTUMesh::checkConsistency(double eps) const if(!c2->isMonotonic(true)) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::checkConsistency : the nodal connectivity index is expected to be increasing monotinic !"); // - mcIdType nbOfTuples=ToIdType(c1->getNumberOfTuples()); + mcIdType nbOfTuples(c1->getNumberOfTuples()); int nbOfNodes=getNumberOfNodes(); const int *w(c1->begin()); for(int i=0;ideltaShiftIndex(); // for polyhedrons - mcIdType nbOfCells=ToIdType(_conn_indx->getNumberOfTuples())-1; + mcIdType nbOfCells=_conn_indx->getNumberOfTuples()-1; MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfCells,1); int *retPtr=ret->getPointer(); @@ -2488,7 +2488,7 @@ DataArrayInt *MEDCoupling1DGTUMesh::computeNbOfFacesPerCell() const return ret.retn(); } // for polyhedrons - mcIdType nbOfCells=ToIdType(_conn_indx->getNumberOfTuples())-1; + mcIdType nbOfCells=_conn_indx->getNumberOfTuples()-1; MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfCells,1); int *retPtr=ret->getPointer(); @@ -2509,7 +2509,7 @@ DataArrayInt *MEDCoupling1DGTUMesh::computeEffectiveNbOfNodesPerCell() const { checkConsistencyLight(); _conn_indx->checkMonotonic(true); - mcIdType nbOfCells=ToIdType(_conn_indx->getNumberOfTuples())-1; + mcIdType nbOfCells=_conn_indx->getNumberOfTuples()-1; MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfCells,1); int *retPtr(ret->getPointer()); @@ -3154,9 +3154,9 @@ void MEDCoupling1DGTUMesh::renumberNodesWithOffsetInConn(int offset) { getNumberOfCells();//only to check that all is well defined. // - std::size_t nbOfTuples(_conn->getNumberOfTuples()); + mcIdType nbOfTuples(_conn->getNumberOfTuples()); int *pt(_conn->getPointer()); - for(std::size_t i=0;igetNumberOfTuples())); + mcIdType nbElemsIn(getNumberOfNodes()),nbOfTuples(_conn->getNumberOfTuples()); int *pt(_conn->getPointer()); for(int i=0;i > bb(sz); std::vector< const MEDCoupling1DGTUMesh * > aa(sz); - int spaceDim=-3; + mcIdType spaceDim=-3; for(std::size_t i=0;i::const_iterator it=nodalConns.begin();it!=nodalConns.end();it++) { if(!(*it)) @@ -3699,7 +3699,7 @@ DataArrayInt *MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds(const std: int i=0; for(std::vector::const_iterator it=nodalConns.begin();it!=nodalConns.end();it++,i++) { - int curNbt=ToIdType((*it)->getNumberOfTuples()); + mcIdType curNbt=(*it)->getNumberOfTuples(); const int *inPt=(*it)->begin(); int offset=offsetInNodeIdsPerElt[i]; for(int j=0;jgetPointer()); - mcIdType nbElt=ToIdType(_conn->getNumberOfTuples()); + mcIdType nbElt(_conn->getNumberOfTuples()); int *endPtr(begPtr+nbElt); for(int *it=begPtr;it!=endPtr;it++) { @@ -51,7 +51,7 @@ void MEDCoupling::MEDCoupling1DGTUMesh::renumberNodesInConnT(const MAPCLS& newNo { getNumberOfCells();//only to check that all is well defined. // - mcIdType nbOfTuples=ToIdType(_conn->getNumberOfTuples()); + mcIdType nbOfTuples(_conn->getNumberOfTuples()); int *pt(_conn->getPointer()); for(int i=0;i MEDCouplingCMesh::getNodeGridStructure() const { if(!_x_array->isAllocated() || _x_array->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingCMesh::getNodeGridStructure : X array exits but it is not allocated or with nb of components equal to one !"); - ret.push_back(ToIdType(_x_array->getNumberOfTuples())); + ret.push_back(_x_array->getNumberOfTuples()); } else isOK=false; @@ -313,7 +313,7 @@ std::vector MEDCouplingCMesh::getNodeGridStructure() const throw INTERP_KERNEL::Exception("MEDCouplingCMesh::getNodeGridStructure : Y array exits but it is not allocated or with nb of components equal to one !"); if(!isOK) throw INTERP_KERNEL::Exception(MSG); - ret.push_back(ToIdType(_y_array->getNumberOfTuples())); + ret.push_back(_y_array->getNumberOfTuples()); } else isOK=false; @@ -323,7 +323,7 @@ std::vector MEDCouplingCMesh::getNodeGridStructure() const throw INTERP_KERNEL::Exception("MEDCouplingCMesh::getNodeGridStructure : Z array exits but it is not allocated or with nb of components equal to one !"); if(!isOK) throw INTERP_KERNEL::Exception(MSG); - ret.push_back(ToIdType(_z_array->getNumberOfTuples())); + ret.push_back(_z_array->getNumberOfTuples()); } return ret; } @@ -790,7 +790,7 @@ void MEDCouplingCMesh::getTinySerializationInformation(std::vector& tiny std::string st; if(thisArr[i]) { - val=ToIdType(thisArr[i]->getNumberOfTuples()); + val=thisArr[i]->getNumberOfTuples(); st=thisArr[i]->getInfoOnComponent(0); } tinyInfo.push_back(val); @@ -820,7 +820,7 @@ void MEDCouplingCMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const for(int i=0;i<3;i++) { if(thisArr[i]) - sz+=ToIdType(thisArr[i]->getNumberOfTuples()); + sz+=thisArr[i]->getNumberOfTuples(); } a2=DataArrayDouble::New(); a2->alloc(sz,1); @@ -904,10 +904,10 @@ void MEDCouplingCMesh::reprQuickOverview(std::ostream& stream) const stream2[i] << "set but not allocated."; else { - mcIdType nbCompo=ToIdType(thisArr[i]->getNumberOfComponents()); + std::size_t nbCompo=thisArr[i]->getNumberOfComponents(); if(nbCompo==1) { - mcIdType nbTuples=ToIdType(thisArr[i]->getNumberOfTuples()); + mcIdType nbTuples=thisArr[i]->getNumberOfTuples(); if(nbTuples<1) { stream2[i] << "set and allocated - WARNING number of elements < 1 !"; nbOfCells=-1; nbOfNodes=-1; } else diff --git a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx index 3f68ec54f..de19c7da4 100755 --- a/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCurveLinearMesh.cxx @@ -193,7 +193,7 @@ void MEDCouplingCurveLinearMesh::checkConsistencyLight() const throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkConsistencyLight : the array is not allocated !"); if(_coords->getNumberOfComponents()<1) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkConsistencyLight : the array should have >= 1 components !"); - if(_coords->getNumberOfTuples()!=nbOfNodes) + if(_coords->getNumberOfTuples()!=ToIdType(nbOfNodes)) { std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::checkConsistencyLight : structure said that number of nodes should be equal to " << nbOfNodes << " but number of tuples in array is equal to " << _coords->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -239,8 +239,8 @@ void MEDCouplingCurveLinearMesh::getCoordinatesOfNode(int nodeId, std::vectorgetNumberOfComponents()); - if(nodeId>=0 && nodeId<(ToIdType(_coords->getNumberOfTuples()))) + std::size_t nbOfCompo=_coords->getNumberOfComponents(); + if(nodeId>=0 && nodeId<_coords->getNumberOfTuples()) coo.insert(coo.end(),_coords->begin()+nodeId*nbOfCompo,_coords->begin()+(nodeId+1)*nbOfCompo); else { std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::getCoordinatesOfNode : nodeId has to be in [0," << _coords->getNumberOfTuples() << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } @@ -645,7 +645,7 @@ void MEDCouplingCurveLinearMesh::rotate(const double *center, const double *vect if(!((DataArrayDouble *)_coords)) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::rotate : no coordinates set !"); int spaceDim=getSpaceDimension(); - mcIdType nbNodes=ToIdType(_coords->getNumberOfTuples()); + mcIdType nbNodes(_coords->getNumberOfTuples()); double *coords=_coords->getPointer(); if(spaceDim==3) DataArrayDouble::Rotate3DAlg(center,vector,angle,nbNodes,coords,coords); @@ -680,8 +680,8 @@ void MEDCouplingCurveLinearMesh::scale(const double *point, double factor) if(!((DataArrayDouble *)_coords)) throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::scale : no coordinates set !"); double *coords=_coords->getPointer(); - mcIdType nbNodes=ToIdType(_coords->getNumberOfTuples()); - mcIdType dim=ToIdType(_coords->getNumberOfComponents()); + mcIdType nbNodes(_coords->getNumberOfTuples()); + std::size_t dim(_coords->getNumberOfComponents()); for(int i=0;i()); @@ -917,7 +917,7 @@ void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const { stream << std::endl << "No coordinates set !"; return ; } if(!coo->isAllocated()) { stream << std::endl << "Coordinates set but not allocated !"; return ; } - mcIdType nbOfCompo=ToIdType(coo->getNumberOfComponents()); + std::size_t nbOfCompo(coo->getNumberOfComponents()); int nbOfCompoExp(-1); try { @@ -926,7 +926,7 @@ void MEDCouplingCurveLinearMesh::reprQuickOverview(std::ostream& stream) const catch(INTERP_KERNEL::Exception&) { } - if(nbOfCompo!=nbOfCompoExp) + if(ToIdType(nbOfCompo)!=nbOfCompoExp) { stream << std::endl << "Coordinates set and allocated but mismatch number of components !"; return ; } stream << std::endl << "Coordinates ( number of tuples = " << coo->getNumberOfTuples() << " ) : "; coo->reprQuickOverviewData(stream,200); diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index 525987d3c..9810f0584 100755 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -235,7 +235,7 @@ std::vector MEDCouplingFieldDiscretization::getDirectCh void MEDCouplingFieldDiscretization::normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, double *res) const { MCAuto vol=getMeasureField(mesh,true); - mcIdType nbOfCompo=ToIdType(arr->getNumberOfComponents()); + std::size_t nbOfCompo=arr->getNumberOfComponents(); int nbOfElems=getNumberOfTuples(mesh); std::fill(res,res+nbOfCompo,0.); const double *arrPtr=arr->getConstPointer(); @@ -244,7 +244,7 @@ void MEDCouplingFieldDiscretization::normL1(const MEDCouplingMesh *mesh, const D for(int i=0;i vol=getMeasureField(mesh,true); - mcIdType nbOfCompo=ToIdType(arr->getNumberOfComponents()); + std::size_t nbOfCompo=arr->getNumberOfComponents(); int nbOfElems=getNumberOfTuples(mesh); std::fill(res,res+nbOfCompo,0.); const double *arrPtr=arr->getConstPointer(); @@ -268,7 +268,7 @@ void MEDCouplingFieldDiscretization::normL2(const MEDCouplingMesh *mesh, const D for(int i=0;i vol=getMeasureField(mesh,isWAbs); - std::size_t nbOfCompo(arr->getNumberOfComponents()),nbOfElems(getNumberOfTuples(mesh)); + std::size_t nbOfCompo(arr->getNumberOfComponents()); + mcIdType nbOfElems(getNumberOfTuples(mesh)); if(nbOfElems!=arr->getNumberOfTuples()) { std::ostringstream oss; oss << "MEDCouplingFieldDiscretization::integral : field is not correct ! number of tuples in array is " << arr->getNumberOfTuples(); @@ -298,7 +299,7 @@ void MEDCouplingFieldDiscretization::integral(const MEDCouplingMesh *mesh, const std::fill(res,res+nbOfCompo,0.); const double *arrPtr(arr->begin()),*volPtr(vol->getArray()->begin()); INTERP_KERNEL::AutoPtr tmp=new double[nbOfCompo]; - for(std::size_t i=0;i(),volPtr[i])); std::transform((double *)tmp,(double *)tmp+nbOfCompo,res,res,std::plus()); @@ -428,8 +429,8 @@ void MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr(double eps, cons { if(!arr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr : input array is NULL !"); - mcIdType oldNbOfElems=ToIdType(arr->getNumberOfTuples()); - mcIdType nbOfComp=ToIdType(arr->getNumberOfComponents()); + mcIdType oldNbOfElems=arr->getNumberOfTuples(); + std::size_t nbOfComp=arr->getNumberOfComponents(); int newNbOfTuples=newNbOfEntity; MCAuto arrCpy=arr->deepCopy(); const double *ptSrc=arrCpy->getConstPointer(); @@ -464,7 +465,7 @@ void MEDCouplingFieldDiscretization::RenumberEntitiesFromO2NArr(double eps, cons void MEDCouplingFieldDiscretization::RenumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const std::string& msg) { - mcIdType nbOfComp=ToIdType(arr->getNumberOfComponents()); + std::size_t nbOfComp=arr->getNumberOfComponents(); MCAuto arrCpy=arr->deepCopy(); const double *ptSrc=arrCpy->getConstPointer(); arr->reAlloc(new2OldSz); @@ -646,7 +647,7 @@ void MEDCouplingFieldDiscretizationP0::checkCoherencyBetween(const MEDCouplingMe { if(!mesh || !da) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationP0::checkCoherencyBetween : NULL input mesh or DataArray !"); - if(mesh->getNumberOfCells()!=da->getNumberOfTuples()) + if(ToIdType(mesh->getNumberOfCells())!=da->getNumberOfTuples()) { std::ostringstream message; message << "Field on cells invalid because there are " << mesh->getNumberOfCells(); @@ -689,7 +690,7 @@ DataArrayDouble *MEDCouplingFieldDiscretizationP0::getValueOnMulti(const DataArr mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,eltsArr,eltsIndexArr); const int *elts(eltsArr->begin()),*eltsIndex(eltsIndexArr->begin()); int spaceDim=mesh->getSpaceDimension(); - mcIdType nbOfComponents=ToIdType(arr->getNumberOfComponents()); + std::size_t nbOfComponents=arr->getNumberOfComponents(); MCAuto ret=DataArrayDouble::New(); ret->alloc(nbOfPoints,nbOfComponents); double *ptToFill=ret->getPointer(); @@ -1061,7 +1062,7 @@ void MEDCouplingFieldDiscretizationP1::getValueInCell(const MEDCouplingMesh *mes INTERP_KERNEL::AutoPtr tmp=new double[nbOfNodes]; INTERP_KERNEL::NormalizedCellType ct(mesh->getTypeOfCell(cellId)); INTERP_KERNEL::barycentric_coords(ct,vec,loc,tmp); - mcIdType sz=ToIdType(arr->getNumberOfComponents()); + std::size_t sz=arr->getNumberOfComponents(); INTERP_KERNEL::AutoPtr tmp2=new double[sz]; std::fill(res,res+sz,0.); for(std::size_t i=0;igetCellsContainingPoints(loc,nbOfPoints,_precision,eltsArr,eltsIndexArr); const int *elts(eltsArr->begin()),*eltsIndex(eltsIndexArr->begin()); int spaceDim=mesh->getSpaceDimension(); - mcIdType nbOfComponents=ToIdType(arr->getNumberOfComponents()); + std::size_t nbOfComponents=arr->getNumberOfComponents(); MCAuto ret=DataArrayDouble::New(); ret->alloc(nbOfPoints,nbOfComponents); double *ptToFill=ret->getPointer(); @@ -1218,7 +1219,7 @@ bool MEDCouplingFieldDiscretizationPerCell::isEqualWithoutConsideringStr(const M */ void MEDCouplingFieldDiscretizationPerCell::renumberCells(const int *old2NewBg, bool check) { - mcIdType nbCells=ToIdType(_discr_per_cell->getNumberOfTuples()); + mcIdType nbCells=_discr_per_cell->getNumberOfTuples(); const int *array=old2NewBg; if(check) array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells); @@ -1424,7 +1425,7 @@ int MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode( throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getNumberOfTuplesExpectedRegardingCode : invalid input code !"); int nbOfSplit=(int)idsPerType.size(); int nbOfTypes=(int)code.size()/3; - std::size_t ret(0); + mcIdType ret(0); for(int i=0;igetConstPointer(); - mcIdType nbOfTuples=ToIdType(_discr_per_cell->getNumberOfTuples()); + mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); mcIdType maxSz=ToIdType(_loc.size()); for(const int *w=dcPtr;w!=dcPtr+nbOfTuples;w++) { @@ -1491,7 +1492,7 @@ DataArrayInt *MEDCouplingFieldDiscretizationGauss::getOffsetArr(const MEDCouplin { if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getOffsetArr : NULL input mesh !"); - std::size_t nbOfTuples(mesh->getNumberOfCells()); + mcIdType nbOfTuples=ToIdType(mesh->getNumberOfCells()); MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfTuples+1,1); int *retPtr(ret->getPointer()); @@ -1500,7 +1501,7 @@ DataArrayInt *MEDCouplingFieldDiscretizationGauss::getOffsetArr(const MEDCouplin throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::getOffsetArr : mismatch between the mesh and the discretization ids array length !"); int maxPossible=(int)_loc.size(); retPtr[0]=0; - for(std::size_t i=0;i=0 && *startgetNumberOfCells()); - mcIdType nbOfCells=ToIdType(_discr_per_cell->getNumberOfTuples()); + mcIdType nbOfCells=_discr_per_cell->getNumberOfTuples(); int nbOfTuples=getNumberOfTuples(0); const int *dcPtr=_discr_per_cell->getConstPointer(); int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace. @@ -1609,7 +1610,7 @@ void MEDCouplingFieldDiscretizationGauss::getTinySerializationIntInformation(std { int val=-1; if(_discr_per_cell) - val=ToIdType(_discr_per_cell->getNumberOfTuples()); + val=_discr_per_cell->getNumberOfTuples(); tinyInfo.push_back(val); tinyInfo.push_back((int)_loc.size()); if(_loc.empty()) @@ -1708,7 +1709,7 @@ void MEDCouplingFieldDiscretizationGauss::checkCoherencyBetween(const MEDCouplin throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - std::size_t nbOfTuples(getNumberOfTuples(mesh)); + mcIdType nbOfTuples(getNumberOfTuples(mesh)); if(nbOfTuples!=da->getNumberOfTuples()) { std::ostringstream oss; oss << "Invalid number of tuples in the array : expecting " << nbOfTuples << " having " << da->getNumberOfTuples() << " !"; @@ -1811,7 +1812,7 @@ MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshDataRange(cons throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildSubMeshDataRange : no discretization array set !"); di=0; beginOut=0; endOut=0; stepOut=stepCellIds; const char msg[]="MEDCouplingFieldDiscretizationGauss::buildSubMeshDataRange : cell #"; - mcIdType nbOfTuples=ToIdType(_discr_per_cell->getNumberOfTuples()); + mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); const int *w=_discr_per_cell->begin(); int nbMaxOfLocId=(int)_loc.size(); for(int i=0;i nbOfNodesPerCell=buildNbOfGaussPointPerCellField();//check of _discr_per_cell not NULL pointer std::size_t nbOfCells(mesh->getNumberOfCells()); - if(_discr_per_cell->getNumberOfTuples()!=nbOfCells) + if(_discr_per_cell->getNumberOfTuples()!=ToIdType(nbOfCells)) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::computeTupleIdsToSelectFromCellIds : mismatch of nb of tuples of cell ids array and number of cells !"); nbOfNodesPerCell->computeOffsetsFull(); MCAuto sel=DataArrayInt::New(); sel->useArray(startCellIds,false,DeallocType::CPP_DEALLOC,(int)std::distance(startCellIds,endCellIds),1); @@ -2046,7 +2047,7 @@ void MEDCouplingFieldDiscretizationGauss::getCellIdsHavingGaussLocalization(int { if(locId<0 || locId>=(int)_loc.size()) throw INTERP_KERNEL::Exception("Invalid locId given : must be in range [0:getNbOfGaussLocalization()) !"); - mcIdType nbOfTuples=ToIdType(_discr_per_cell->getNumberOfTuples()); + mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); const int *ptr=_discr_per_cell->getConstPointer(); for(int i=0;igetNumberOfTuples()); + mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); MCAuto ret=DataArrayInt::New(); const int *w=_discr_per_cell->begin(); ret->alloc(nbOfTuples,1); @@ -2122,7 +2123,7 @@ void MEDCouplingFieldDiscretizationGauss::reprQuickOverview(std::ostream& stream void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations() { const int *start=_discr_per_cell->begin(); - mcIdType nbOfTuples=ToIdType(_discr_per_cell->getNumberOfTuples()); + mcIdType nbOfTuples=_discr_per_cell->getNumberOfTuples(); INTERP_KERNEL::AutoPtr tmp=new int[_loc.size()]; std::fill((int *)tmp,(int *)tmp+_loc.size(),-2); for(const int *w=start;w!=start+nbOfTuples;w++) @@ -2357,7 +2358,7 @@ void MEDCouplingFieldDiscretizationGaussNE::integral(const MEDCouplingMesh *mesh { if(!mesh || !arr) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGaussNE::integral : input mesh or array is null !"); - mcIdType nbOfCompo=ToIdType(arr->getNumberOfComponents()); + std::size_t nbOfCompo=arr->getNumberOfComponents(); std::fill(res,res+nbOfCompo,0.); // MCAuto vol=mesh->getMeasureField(isWAbs); @@ -2375,10 +2376,10 @@ void MEDCouplingFieldDiscretizationGaussNE::integral(const MEDCouplingMesh *mesh MCAuto ids=mesh->giveCellsWithType(*it); MCAuto ids2=ids->buildExplicitArrByRanges(nbOfNodesPerCell); const int *ptIds2=ids2->begin(),*ptIds=ids->begin(); - mcIdType nbOfCellsWithCurGeoType=ToIdType(ids->getNumberOfTuples()); + mcIdType nbOfCellsWithCurGeoType=ids->getNumberOfTuples(); for(int i=0;igetNumberOfTuples()) { std::ostringstream oss; oss << "Invalid number of tuples in the array : expecting " << nbOfTuples << " !"; @@ -2678,7 +2679,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); @@ -2693,7 +2694,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationGaussNE::getMeasureField(c MCAuto ids=mesh->giveCellsWithType(*it); MCAuto ids2=ids->buildExplicitArrByRanges(nbOfNodesPerCell); const int *ptIds2=ids2->begin(),*ptIds=ids->begin(); - mcIdType nbOfCellsWithCurGeoType=ToIdType(ids->getNumberOfTuples()); + mcIdType nbOfCellsWithCurGeoType=ids->getNumberOfTuples(); for(int i=0;iisAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::getValueOnMulti : input array is null or not allocated !"); mcIdType nbOfRows=ToIdType(getNumberOfMeshPlaces(mesh)); - if(ToIdType(arr->getNumberOfTuples())!=nbOfRows) + if(arr->getNumberOfTuples()!=nbOfRows) { std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationKriging::getValueOnMulti : input array does not have correct number of tuples ! Excepted " << nbOfRows << " having " << arr->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - int nbCols(-1),nbCompo(ToIdType(arr->getNumberOfComponents())); + int nbCols(-1); + std::size_t nbCompo=arr->getNumberOfComponents(); MCAuto m(computeEvaluationMatrixOnGivenPts(mesh,loc,nbOfTargetPoints,nbCols)); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTargetPoints,nbCompo); - INTERP_KERNEL::matrixProduct(m->begin(),nbOfTargetPoints,nbCols,arr->begin(),nbOfRows,nbCompo,ret->getPointer()); + INTERP_KERNEL::matrixProduct(m->begin(),nbOfTargetPoints,nbCols,arr->begin(),nbOfRows,ToIdType(nbCompo),ret->getPointer()); return ret.retn(); } @@ -2909,7 +2911,8 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::computeEvaluationMatrixO MCAuto matrixInv(computeInverseMatrix(mesh,isDrift,nbRows)); // MCAuto coords=getLocalizationOfDiscValues(mesh); - mcIdType nbOfPts(ToIdType(coords->getNumberOfTuples())),dimension(ToIdType(coords->getNumberOfComponents())); + mcIdType nbOfPts(coords->getNumberOfTuples()); + std::size_t dimension(coords->getNumberOfComponents()); MCAuto locArr=DataArrayDouble::New(); locArr->useArray(loc,false,DeallocType::CPP_DEALLOC,nbOfTargetPoints,dimension); nbCols=nbOfPts; @@ -2968,7 +2971,7 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::computeMatrix(const MEDC if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::computeMatrix : NULL input mesh !"); MCAuto coords(getLocalizationOfDiscValues(mesh)); - mcIdType nbOfPts=ToIdType(coords->getNumberOfTuples()); + mcIdType nbOfPts(coords->getNumberOfTuples()); MCAuto matrix(coords->buildEuclidianDistanceDenseMatrix()); operateOnDenseMatrix(mesh->getSpaceDimension(),nbOfPts*nbOfPts,matrix->getPointer()); // Drift @@ -2994,7 +2997,7 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::computeVectorOfCoefficie MCAuto KnewiK(DataArrayDouble::New()); KnewiK->alloc(nbRows*1,1); MCAuto arr2(PerformDriftOfVec(arr,isDrift)); - INTERP_KERNEL::matrixProduct(matrixInv->getConstPointer(),nbRows,nbRows,arr2->getConstPointer(),ToIdType(arr2->getNumberOfTuples()),1,KnewiK->getPointer()); + INTERP_KERNEL::matrixProduct(matrixInv->getConstPointer(),nbRows,nbRows,arr2->getConstPointer(),arr2->getNumberOfTuples(),1,KnewiK->getPointer()); return KnewiK.retn(); } @@ -3062,8 +3065,9 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::PerformDriftRect(const D throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::PerformDriftRect : invalid input dense matrix ! Must be allocated not NULL and with exactly one component !"); if(!arr || !arr->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::PerformDriftRect : invalid input array of coordiantes ! Must be allocated and not NULL !"); - mcIdType spaceDimension=ToIdType(arr->getNumberOfComponents()),nbOfPts=ToIdType(arr->getNumberOfTuples()),nbOfEltInMatrx=ToIdType(matr->getNumberOfTuples()); - delta=spaceDimension+1; + std::size_t spaceDimension(arr->getNumberOfComponents()); + mcIdType nbOfPts(arr->getNumberOfTuples()),nbOfEltInMatrx(matr->getNumberOfTuples()); + delta=ToIdType(spaceDimension)+1; int nbOfCols(nbOfEltInMatrx/nbOfPts); if(nbOfEltInMatrx%nbOfPts!=0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::PerformDriftRect : size of input dense matrix and input arrays mismatch ! NbOfElems in matrix % nb of tuples in array must be equal to 0 !"); @@ -3109,10 +3113,10 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::PerformDriftOfVec(const */ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::performDrift(const DataArrayDouble *matr, const DataArrayDouble *arr, int& delta) const { - mcIdType spaceDimension=ToIdType(arr->getNumberOfComponents()); - delta=spaceDimension+1; - mcIdType szOfMatrix=ToIdType(arr->getNumberOfTuples()); - if(szOfMatrix*szOfMatrix!=ToIdType(matr->getNumberOfTuples())) + std::size_t spaceDimension(arr->getNumberOfComponents()); + delta=ToIdType(spaceDimension)+1; + mcIdType szOfMatrix(arr->getNumberOfTuples()); + if(szOfMatrix*szOfMatrix!=matr->getNumberOfTuples()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationKriging::performDrift : invalid size"); MCAuto ret=DataArrayDouble::New(); ret->alloc((szOfMatrix+delta)*(szOfMatrix+delta),1); @@ -3131,7 +3135,7 @@ DataArrayDouble *MEDCouplingFieldDiscretizationKriging::performDrift(const DataA std::fill(destWork,destWork+spaceDimension+1,0.); destWork+=spaceDimension+1; MCAuto arrNoI=arr->toNoInterlace(); srcWork2=arrNoI->getConstPointer(); - for(mcIdType i=0;i > outArrsSafe(sz); std::vector outArrs(sz); for(std::size_t j=0;jgetNumberOfComponents()); + std::size_t nbCompo(arrs[j]->getNumberOfComponents()); outArrsSafe[j]=DataArrayDouble::New(); outArrsSafe[j]->alloc(nbCells,nbCompo); outArrsSafe[j]->copyStringInfoFrom(*arrs[j]); outArrs[j]=outArrsSafe[j]; @@ -701,11 +701,11 @@ 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); - mcIdType nCompo = ToIdType(getArray()->getNumberOfComponents()); + std::size_t nCompo = getArray()->getNumberOfComponents(); std::transform(res,res+nCompo,res,std::bind2nd(std::multiplies(),1./deno)); } @@ -724,8 +724,8 @@ void MEDCouplingFieldDouble::getWeightedAverageValue(double *res, bool isWAbs) c */ double MEDCouplingFieldDouble::getWeightedAverageValue(int compId, bool isWAbs) const { - mcIdType nbComps=ToIdType(getArray()->getNumberOfComponents()); - if(compId<0 || compId>=nbComps) + std::size_t nbComps=getArray()->getNumberOfComponents(); + if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::getWeightedAverageValue : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; throw INTERP_KERNEL::Exception(oss.str()); @@ -752,8 +752,8 @@ double MEDCouplingFieldDouble::normL1(int compId) const throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL1 !"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform normL1 !"); - mcIdType nbComps=ToIdType(getArray()->getNumberOfComponents()); - if(compId<0 || compId>=nbComps) + std::size_t nbComps=getArray()->getNumberOfComponents(); + if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::normL1 : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; throw INTERP_KERNEL::Exception(oss.str()); @@ -799,8 +799,8 @@ double MEDCouplingFieldDouble::normL2(int compId) const throw INTERP_KERNEL::Exception("No mesh underlying this field to perform normL2"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform normL2 !"); - mcIdType nbComps=ToIdType(getArray()->getNumberOfComponents()); - if(compId<0 || compId>=nbComps) + std::size_t nbComps=getArray()->getNumberOfComponents(); + if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::normL2 : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; throw INTERP_KERNEL::Exception(oss.str()); @@ -843,8 +843,8 @@ double MEDCouplingFieldDouble::normMax(int compId) const { if(getArray()==0) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::normMax : no default array defined !"); - mcIdType nbComps=ToIdType(getArray()->getNumberOfComponents()); - if(compId<0 || compId>=nbComps) + std::size_t nbComps=getArray()->getNumberOfComponents(); + if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::normMax : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; throw INTERP_KERNEL::Exception(oss.str()); @@ -891,8 +891,8 @@ double MEDCouplingFieldDouble::integral(int compId, bool isWAbs) const throw INTERP_KERNEL::Exception("No mesh underlying this field to perform integral"); if(_type.isNull()) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform integral !"); - mcIdType nbComps=ToIdType(getArray()->getNumberOfComponents()); - if(compId<0 || compId>=nbComps) + std::size_t nbComps=getArray()->getNumberOfComponents(); + if(compId<0 || compId>=ToIdType(nbComps)) { std::ostringstream oss; oss << "MEDCouplingFieldDouble::integral : Invalid compId specified : No such nb of components ! Should be in [0," << nbComps << ") !"; throw INTERP_KERNEL::Exception(oss.str()); @@ -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,13 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std ret->setMesh(getMesh()); return ret.retn(); } +MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std::vector& compoIds) const +{ + // The method has to be removed as duplicate after SWIG update + std::vector ids (compoIds.size()); + cast_to_remove (compoIds, ids); + return keepSelectedComponents(ids); +} /*! @@ -2325,8 +2332,13 @@ 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) { + // The method has to be removed as duplicate after SWIG update timeDiscr()->setSelectedComponents(f->timeDiscr(),compoIds); } @@ -2915,7 +2927,7 @@ MCAuto MEDCouplingFieldDouble::voronoizeGen(const Voroni inpMeshBase=fieldToWO->getMesh(); inpMesh=inpMeshBase->buildUnstructured(); } - mcIdType nbCells=ToIdType(inpMesh->getNumberOfCells()); + std::size_t nbCells(inpMesh->getNumberOfCells()); const MEDCouplingFieldDiscretization *disc(fieldToWO->getDiscretization()); const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast(disc)); if(!disc2) 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/MEDCouplingFieldT.txx b/src/MEDCoupling/MEDCouplingFieldT.txx index f1cda9917..91c3d15de 100644 --- a/src/MEDCoupling/MEDCouplingFieldT.txx +++ b/src/MEDCoupling/MEDCouplingFieldT.txx @@ -368,10 +368,10 @@ namespace MEDCoupling { if(getArray()->isAllocated()) { - mcIdType nbOfCompo=ToIdType(getArray()->getNumberOfComponents()); + std::size_t nbOfCompo=getArray()->getNumberOfComponents(); ret << Traits::FieldTypeName << " default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n"; ret << Traits::FieldTypeName << " default array has following info on components : "; - for(mcIdType i=0;igetInfoOnComponent(i) << "\" "; ret << "\n"; } diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx index f67a4ee74..bb9b404a6 100644 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx +++ b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx @@ -216,7 +216,7 @@ MCAuto MEDCouplingGaussLocalization::localizePtsInRefCooForEach const double *coords(mesh->getCoords()->begin()); const int *connI(mesh->getNodalConnectivityIndex()->begin()),*conn(mesh->getNodalConnectivity()->begin()); // - mcIdType nbPts=ToIdType(ptsInRefCoo->getNumberOfTuples()); + mcIdType nbPts(ptsInRefCoo->getNumberOfTuples()); INTERP_KERNEL::NormalizedCellType typ(getType()); int dim(INTERP_KERNEL::CellModel::GetCellModel(typ).getDimension()),outDim(mesh->getSpaceDimension()); MCAuto ret(DataArrayDouble::New()); diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx index ec7587ef1..c712301a9 100755 --- a/src/MEDCoupling/MEDCouplingIMesh.cxx +++ b/src/MEDCoupling/MEDCouplingIMesh.cxx @@ -289,17 +289,17 @@ void MEDCouplingIMesh::CondenseFineToCoarse(const std::vector& coarseSt, co throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the parameters 1 or 3 are NULL or not allocated !"); std::size_t meshDim(coarseSt.size()); mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); - mcIdType nbCompo=ToIdType(fineDA->getNumberOfComponents()); - if(ToIdType(coarseDA->getNumberOfComponents())!=nbCompo) + std::size_t nbCompo=fineDA->getNumberOfComponents(); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarse : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); - if(ToIdType(coarseDA->getNumberOfTuples())!=nbOfTuplesInCoarseExp) + if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarse : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbTuplesFine=ToIdType(fineDA->getNumberOfTuples()); + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()); if(nbOfTuplesInFineExp==0) { if(nbTuplesFine==0) @@ -420,12 +420,12 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); std::size_t meshDim(coarseSt.size()); mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - mcIdType nbCompo=ToIdType(fineDA->getNumberOfComponents()); - if(ToIdType(coarseDA->getNumberOfComponents())!=nbCompo) + std::size_t nbCompo(fineDA->getNumberOfComponents()); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::CondenseFineToCoarseGhost : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); - if(ToIdType(coarseDA->getNumberOfTuples())!=nbOfTuplesInCoarseExp) + if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarseGhost : Expecting " << nbOfTuplesInCoarseExp << " tuples in coarse DataArray having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -434,8 +434,8 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - mcIdType nbTuplesFine(ToIdType(fineDA->getNumberOfTuples())),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); - if(ToIdType(fineDA->getNumberOfTuples())!=nbTuplesFineExp) + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); + if(fineDA->getNumberOfTuples()!=nbTuplesFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::CondenseFineToCoarseGhost : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -550,17 +550,17 @@ void MEDCouplingIMesh::SpreadCoarseToFine(const DataArrayDouble *coarseDA, const throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the parameters 1 or 3 are NULL or not allocated !"); std::size_t meshDim(coarseSt.size()); mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseSt)),nbOfTuplesInFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(fineLocInCoarse)); - mcIdType nbCompo=ToIdType(fineDA->getNumberOfComponents()); - if(ToIdType(coarseDA->getNumberOfComponents())!=nbCompo) + std::size_t nbCompo=fineDA->getNumberOfComponents(); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); - if(ToIdType(coarseDA->getNumberOfTuples())!=nbOfTuplesInCoarseExp) + if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFine : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - mcIdType nbTuplesFine=ToIdType(fineDA->getNumberOfTuples()); + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()); if(nbTuplesFine%nbOfTuplesInFineExp!=0) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFine : Invalid nb of tuples in fine DataArray regarding its structure !"); int fact(std::accumulate(facts.begin(),facts.end(),1,std::multiplies())); @@ -657,12 +657,12 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, std::vector coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); std::size_t meshDim(coarseSt.size()); mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - mcIdType nbCompo=ToIdType(fineDA->getNumberOfComponents()); - if(ToIdType(coarseDA->getNumberOfComponents())!=nbCompo) + std::size_t nbCompo=fineDA->getNumberOfComponents(); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhost : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); - if(ToIdType(coarseDA->getNumberOfTuples())!=nbOfTuplesInCoarseExp) + if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFineGhost : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -671,8 +671,8 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - mcIdType nbTuplesFine=ToIdType(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); - if(ToIdType(fineDA->getNumberOfTuples())!=nbTuplesFineExp) + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); + if(fineDA->getNumberOfTuples()!=nbTuplesFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFineGhost : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -703,7 +703,7 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, } case 2: { - SpreadCoarseToFineGhost2D(inPtr,outPtr,nbCompo,coarseSt,fineLocInCoarse,facts,ghostSize); + SpreadCoarseToFineGhost2D(inPtr,outPtr,ToIdType(nbCompo),coarseSt,fineLocInCoarse,facts,ghostSize); break; } case 3: @@ -713,13 +713,13 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhost(const DataArrayDouble *coarseDA, int nxyWgCoarse((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize)),nxyWgFine((dims[0]*fact0+2*ghostSize)*(dims[1]*fact1+2*ghostSize)); int offset((fineLocInCoarse[2].first+ghostSize-1)*nxyWgCoarse);//offset is always >=0 thanks to the fact that ghostSize>=1 ! for(int i=0;i coarseStG(coarseSt.size()); std::transform(coarseSt.begin(),coarseSt.end(),coarseStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); std::size_t meshDim(coarseSt.size()); mcIdType nbOfTuplesInCoarseExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(coarseStG)); - mcIdType nbCompo=ToIdType(fineDA->getNumberOfComponents()); - if(ToIdType(coarseDA->getNumberOfComponents())!=nbCompo) + std:size_t nbCompo=fineDA->getNumberOfComponents(); + if(coarseDA->getNumberOfComponents()!=nbCompo) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the number of components of fine DA and coarse one mismatches !"); if(meshDim!=fineLocInCoarse.size() || meshDim!=facts.size()) throw INTERP_KERNEL::Exception("MEDCouplingIMesh::SpreadCoarseToFineGhostZone : the size of fineLocInCoarse (4th param) and facts (5th param) must be equal to the sier of coarseSt (2nd param) !"); - if(ToIdType(coarseDA->getNumberOfTuples())!=nbOfTuplesInCoarseExp) + if(coarseDA->getNumberOfTuples()!=nbOfTuplesInCoarseExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFineGhostZone : Expecting " << nbOfTuplesInCoarseExp << " tuples having " << coarseDA->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -764,8 +764,8 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse std::vector fineStG(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(fineLocInCoarse)); std::transform(fineStG.begin(),fineStG.end(),facts.begin(),fineStG.begin(),std::multiplies()); std::transform(fineStG.begin(),fineStG.end(),fineStG.begin(),std::bind2nd(std::plus(),2*ghostSize)); - mcIdType nbTuplesFine=ToIdType(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); - if(ToIdType(fineDA->getNumberOfTuples())!=nbTuplesFineExp) + mcIdType nbTuplesFine(fineDA->getNumberOfTuples()),nbTuplesFineExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(fineStG)); + if(fineDA->getNumberOfTuples()!=nbTuplesFineExp) { std::ostringstream oss; oss << "MEDCouplingIMesh::SpreadCoarseToFineGhostZone : Expecting " << nbTuplesFineExp << " tuples in fine DataArray having " << nbTuplesFine << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -790,7 +790,7 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse } case 2: { - SpreadCoarseToFineGhostZone2D(inPtr,outPtr,nbCompo,coarseSt,fineLocInCoarse,facts,ghostSize); + SpreadCoarseToFineGhostZone2D(inPtr,outPtr,ToIdType(nbCompo),coarseSt,fineLocInCoarse,facts,ghostSize); break; } case 3: @@ -799,13 +799,13 @@ void MEDCouplingIMesh::SpreadCoarseToFineGhostZone(const DataArrayDouble *coarse int nxyWgCoarse((coarseSt[0]+2*ghostSize)*(coarseSt[1]+2*ghostSize)),nxyWgFine((dims[0]*fact0+2*ghostSize)*(dims[1]*fact1+2*ghostSize)); int offset((fineLocInCoarse[2].first+ghostSize-1)*nxyWgCoarse);//offset is always >=0 thanks to the fact that ghostSize>=1 ! for(int i=0;i tmp(_mesh2D->giveCellsWithType(revExtTyp)); mcIdType nbOfLevs=ToIdType(_mesh1D->getNumberOfCells()); mcIdType nbOfCells2D=ToIdType(_mesh2D->getNumberOfCells()); - mcIdType nbOfTuples=ToIdType(tmp->getNumberOfTuples()); + mcIdType nbOfTuples(tmp->getNumberOfTuples()); ret->alloc(nbOfLevs*nbOfTuples,1); int *pt(ret->getPointer()); for(int i=0;icheckAllocated(); if(vec->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DenseMatrix::MatVecMult : input vector must have only one component !"); - if(ToIdType(vec->getNumberOfTuples())!=mat->getNumberOfCols()) + if(vec->getNumberOfTuples()!=mat->getNumberOfCols()) throw INTERP_KERNEL::Exception("DenseMatrix::MatVecMult : Number of columns of this must be equal to number of tuples of vec !"); MCAuto ret(DataArrayDouble::New()); ret->alloc(mat->getNumberOfRows(),1); - INTERP_KERNEL::matrixProduct(mat->getData()->begin(),mat->getNumberOfRows(),mat->getNumberOfCols(),vec->begin(),ToIdType(vec->getNumberOfTuples()),1,ret->getPointer()); + INTERP_KERNEL::matrixProduct(mat->getData()->begin(),mat->getNumberOfRows(),mat->getNumberOfCols(),vec->begin(),vec->getNumberOfTuples(),1,ret->getPointer()); return ret.retn(); } @@ -238,7 +238,7 @@ DenseMatrix *DenseMatrix::Multiply(const DenseMatrix *a1, const DataArrayDouble throw INTERP_KERNEL::Exception("DenseMatrix::Multiply #2 : input matrices must be not NULL and a2 allocated !"); if(a2->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DenseMatrix::Multiply #2 : The 2nd member must have exactly one component !"); - MCAuto a2Bis(DenseMatrix::New(const_cast(a2),ToIdType(a2->getNumberOfTuples()),1)); + MCAuto a2Bis(DenseMatrix::New(const_cast(a2),a2->getNumberOfTuples(),1)); return DenseMatrix::Multiply(a1,a2Bis); } diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index d48a98c29..db6cea670 100755 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -191,33 +191,49 @@ 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()); + cast_to_remove(compoIds, ids); + 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) +{ + // The method has to be removed as duplicate after SWIG update + std::vector ids (compoIds.size()); + cast_to_remove (compoIds, ids); + 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 +393,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 +418,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 +559,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 +597,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 +638,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 +874,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 +941,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 +970,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 +984,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 +995,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 +1122,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 +1163,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 +1211,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 +1220,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 +1255,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 +1274,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 +1346,28 @@ 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) +{ + // The method has to be removed as duplicate after SWIG update + std::vector ids (compoIds.size()); + cast_to_remove(compoIds, ids); + 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 +1397,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 +1434,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 +1516,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 +1657,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 +1705,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 +1729,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::size_t)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 +1741,7 @@ double DataArrayDouble::distanceToTuple(const double *tupleBg, const double *tup for(mcIdType i=0;i=ret0) continue; @@ -1736,13 +1759,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 +1871,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 +2098,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 +2129,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 +2426,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 +2460,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 +2472,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 +2523,7 @@ DataArrayDouble *DataArrayDouble::buildEuclidianDistanceDenseMatrixWith(const Da for(mcIdType j=0;jalloc(nbOfTuples,nbOfComp); const double *ptr=getConstPointer(); double *ptrToFill=newArr->getPointer(); @@ -2706,7 +2733,7 @@ DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, FunctionToEvaluate fun * \throw If \a this is not allocated. * \throw If computing \a func fails. */ -DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const std::string& func, bool isSafe) const +DataArrayDouble *DataArrayDouble::applyFunc(std::size_t nbOfComp, const std::string& func, bool isSafe) const { INTERP_KERNEL::ExprParser expr(func); expr.parse(); @@ -2736,11 +2763,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 +2798,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 +2883,7 @@ void DataArrayDouble::applyFuncOnThis(const std::string& func, bool isSafe) { for(mcIdType i=0;igetInfoOnComponent(). * \throw If computing \a func fails. */ -DataArrayDouble *DataArrayDouble::applyFuncCompo(int nbOfComp, const std::string& func, bool isSafe) const +DataArrayDouble *DataArrayDouble::applyFuncCompo(std::size_t nbOfComp, const std::string& func, bool isSafe) const { return applyFuncNamedCompo(nbOfComp,getVarsOnComponent(),func,isSafe); } @@ -2930,21 +2957,21 @@ DataArrayDouble *DataArrayDouble::applyFuncCompo(int nbOfComp, const std::string * \throw If \a func contains vars not in \a varsOrder. * \throw If computing \a func fails. */ -DataArrayDouble *DataArrayDouble::applyFuncNamedCompo(int nbOfComp, const std::vector& varsOrder, const std::string& func, bool isSafe) const +DataArrayDouble *DataArrayDouble::applyFuncNamedCompo(std::size_t nbOfComp, const std::vector& varsOrder, const std::string& func, bool isSafe) const { if(nbOfComp<=0) throw INTERP_KERNEL::Exception("DataArrayDouble::applyFuncNamedCompo : output number of component must be > 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 : "; @@ -2956,9 +2983,9 @@ DataArrayDouble *DataArrayDouble::applyFuncNamedCompo(int nbOfComp, const std::v INTERP_KERNEL::AutoPtr buff(new double[oldNbOfComp]); double *buffPtr(buff),*ptrToFill; std::vector stck; - for(int iComp=0;iCompgetPointer()+iComp; @@ -3007,7 +3034,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 +3103,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 +3129,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 +3182,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,14 +3223,14 @@ 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(); ret->alloc(nbOfTuple,1); double *retPtr=ret->getPointer(); const double *a1Ptr=a1->begin(),*a2Ptr(a2->begin()); - for(std::size_t i=0;igetNumberOfTuples()); + 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 +3339,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 +3371,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 +3382,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 +3410,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 +3420,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 +3446,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 +3491,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) { } @@ -3639,7 +3666,7 @@ DataArrayDoubleTuple::DataArrayDoubleTuple(double *pt, int nbOfComp):DataArrayTu std::string DataArrayDoubleTuple::repr() const { std::ostringstream oss; oss.precision(17); oss << "("; - for(int i=0;i<_nb_of_compo-1;i++) + for(std::size_t i=0;i<_nb_of_compo-1;i++) oss << _pt[i] << ", "; oss << _pt[_nb_of_compo-1] << ")"; return oss.str(); @@ -3656,7 +3683,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,14 +3708,14 @@ 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) { } std::string DataArrayInt32Tuple::repr() const { std::ostringstream oss; oss << "("; - for(mcIdType i=0;i<_nb_of_compo-1;i++) + for(std::size_t i=0;i<_nb_of_compo-1;i++) oss << _pt[i] << ", "; oss << _pt[_nb_of_compo-1] << ")"; return oss.str(); @@ -3705,7 +3732,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,14 +3747,14 @@ 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) { } std::string DataArrayInt64Tuple::repr() const { std::ostringstream oss; oss << "("; - for(mcIdType i=0;i<_nb_of_compo-1;i++) + for(std::size_t i=0;i<_nb_of_compo-1;i++) oss << _pt[i] << ", "; oss << _pt[_nb_of_compo-1] << ")"; return oss.str(); @@ -3738,7 +3765,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..93a5c1f12 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; @@ -481,12 +488,12 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void applyInv(double numerator); MEDCOUPLING_EXPORT void applyPow(double val); MEDCOUPLING_EXPORT void applyRPow(double val); - MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const; - MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const std::string& func, bool isSafe=true) const; + MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(std::size_t nbOfComp, FunctionToEvaluate func) const; + MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(std::size_t nbOfComp, const std::string& func, bool isSafe=true) const; MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const std::string& func, bool isSafe=true) const; MEDCOUPLING_EXPORT void applyFuncOnThis(const std::string& func, bool isSafe=true); - MEDCOUPLING_EXPORT DataArrayDouble *applyFuncCompo(int nbOfComp, const std::string& func, bool isSafe=true) const; - MEDCOUPLING_EXPORT DataArrayDouble *applyFuncNamedCompo(int nbOfComp, const std::vector& varsOrder, const std::string& func, bool isSafe=true) const; + MEDCOUPLING_EXPORT DataArrayDouble *applyFuncCompo(std::size_t nbOfComp, const std::string& func, bool isSafe=true) const; + MEDCOUPLING_EXPORT DataArrayDouble *applyFuncNamedCompo(std::size_t nbOfComp, const std::vector& varsOrder, const std::string& func, bool isSafe=true) const; MEDCOUPLING_EXPORT void applyFuncFast32(const std::string& func); MEDCOUPLING_EXPORT void applyFuncFast64(const std::string& func); MEDCOUPLING_EXPORT MCAuto symmetry3DPlane(const double point[3], const double normalVector[3]) 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..4f0001f46 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,14 @@ namespace MEDCoupling return ret.retn(); } + template + typename Traits::ArrayType *DataArrayTemplate::myKeepSelectedComponents(const std::vector& compoIds) const + { + // The method has to be removed as duplicate after SWIG update + std::vector ids (compoIds.size()); + cast_to_remove(compoIds, ids); + 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 +1379,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 +1401,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 +1431,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 +1492,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 +1555,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 +1683,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 +1750,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 +1771,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 +1919,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 +2029,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 +2094,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 +2124,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 +2187,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 +2206,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 +2226,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 +2263,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 +2307,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 +2334,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 +2360,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 +2508,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 +2555,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 +2573,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 +2708,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 +2826,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 +2842,7 @@ namespace MEDCoupling } else { - mcIdType nbOfCompMin,nbOfCompMax; + std::size_t nbOfCompMin,nbOfCompMax; const typename Traits::ArrayType *aMin, *aMax; if(nbOfComp>nbOfComp2) { @@ -3106,31 +3115,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 +3159,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 +3180,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 +3205,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 +3219,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 +3240,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 +3298,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 +3333,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 +3579,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()); - if(nbOfTuples!=vec.size()) + mcIdType nbOfTuples(this->getNumberOfTuples()); + if(nbOfTuples!=ToIdType(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 +3686,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 +3849,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 +3878,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,11 +3893,12 @@ 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; - for(std::size_t i=0;i1) { @@ -3980,9 +3991,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 +4047,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 +4077,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 +4158,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 +4175,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 +4217,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 +4273,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 +4319,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 +4387,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 +4532,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 +4614,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 +4707,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 +4731,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 +4739,22 @@ 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) + { + // The method has to be removed as duplicate after SWIG update + std::vector ids (compoIds.size()); + cast_to_remove(compoIds, ids); + setSelectedComponents (a, ids); + } /*! * Creates a new DataArrayInt containing IDs (indices) of tuples holding value \b not @@ -4755,7 +4774,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 +4797,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 +4814,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 +4840,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 +4907,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 +4930,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 +5024,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 +5128,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 +5181,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 +5584,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 +5656,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 +5690,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 +5828,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 +5895,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 +5958,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 +6008,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 +6110,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 +6202,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 +6247,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 +6298,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 +6308,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 +6337,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 +6356,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 +6423,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 +6434,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 +6483,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 +6576,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 +6643,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 +6677,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 +6716,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 +6774,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 +6811,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 +6881,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 +6957,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 +7031,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 +7102,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 +7163,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 +7209,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 +7256,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; @@ -7255,7 +7275,7 @@ struct NotInRange previousArrI=*arrIPtr; *arrIPtr=ToIdType(arrOut.size()); } - if(arr->getNumberOfTuples()==arrOut.size()) + if(arr->getNumberOfTuples()==ToIdType(arrOut.size())) return false; arr->alloc(arrOut.size(),1); std::copy(arrOut.begin(),arrOut.end(),arr->getPointer()); diff --git a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx index f1ca474c8..fb0cf3d0e 100755 --- a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx @@ -142,7 +142,7 @@ bool DataArrayChar::isUniform(char val) const checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayChar::isUniform : must be applied on DataArrayChar with only one component, you can call 'rearrange' method before !"); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); const char *w=getConstPointer(); const char *end2=w+nbOfTuples; for(;w!=end2;w++) @@ -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 ret(DataArrayInt::New()); ret->alloc(0,1); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); for(int i=0;ipushBackSilent(i); @@ -231,7 +231,7 @@ DataArrayInt *DataArrayChar::findIdsNotEqual(char val) const throw INTERP_KERNEL::Exception("DataArrayChar::findIdsNotEqual : the array must have only one component, you can call 'rearrange' method before !"); const char *cptr=getConstPointer(); MCAuto ret(DataArrayInt::New()); ret->alloc(0,1); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); for(int i=0;ipushBackSilent(i); @@ -247,8 +247,7 @@ DataArrayInt *DataArrayChar::findIdsNotEqual(char val) const int DataArrayChar::findIdSequence(const std::vector& vals) const { checkAllocated(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); - if(nbOfCompo!=1) + if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayChar::findIdSequence : works only for DataArrayChar instance with one component !"); const char *cptr=getConstPointer(); std::size_t nbOfVals=getNbOfElems(); @@ -273,10 +272,10 @@ int DataArrayChar::findIdSequence(const std::vector& vals) const int DataArrayChar::findIdFirstEqualTuple(const std::vector& tupl) const { checkAllocated(); - mcIdType nbOfCompo=ToIdType(getNumberOfComponents()); + std::size_t nbOfCompo=getNumberOfComponents(); if(nbOfCompo==0) throw INTERP_KERNEL::Exception("DataArrayChar::findIdFirstEqualTuple : 0 components in 'this' !"); - if(nbOfCompo!=(int)tupl.size()) + if(nbOfCompo!=tupl.size()) { std::ostringstream oss; oss << "DataArrayChar::findIdFirstEqualTuple : 'this' contains " << nbOfCompo << " components and searching for a tuple of length " << tupl.size() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -291,7 +290,7 @@ int DataArrayChar::findIdFirstEqualTuple(const std::vector& tupl) const if(std::distance(cptr,work)%nbOfCompo!=0) work++; else - return ToIdType(std::distance(cptr,work))/nbOfCompo; + return ToIdType(std::distance(cptr,work)/nbOfCompo); } } return -1; @@ -346,7 +345,7 @@ int DataArrayChar::findIdFirstEqual(char value) const if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayChar::presenceOfValue : the array must have only one component, you can call 'rearrange' method before !"); const char *cptr=getConstPointer(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); const char *ret=std::find(cptr,cptr+nbOfTuples,value); if(ret!=cptr+nbOfTuples) return ToIdType(std::distance(cptr,ret)); @@ -366,7 +365,7 @@ int DataArrayChar::findIdFirstEqual(const std::vector& vals) const 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 char *cptr=getConstPointer(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); for(const char *w=cptr;w!=cptr+nbOfTuples;w++) if(vals2.find(*w)!=vals2.end()) return ToIdType(std::distance(cptr,w)); @@ -389,7 +388,7 @@ DataArrayInt *DataArrayChar::findIdsInRange(char vmin, char vmax) const throw INTERP_KERNEL::Exception("DataArrayChar::findIdsInRange : this must have exactly one component !"); const char *cptr=getConstPointer(); MCAuto ret=DataArrayInt::New(); ret->alloc(0,1); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); + mcIdType nbOfTuples=getNumberOfTuples(); for(int i=0;i=vmin && *cptrpushBackSilent(i); @@ -444,7 +443,7 @@ DataArrayChar *DataArrayChar::Aggregate(const std::vector throw INTERP_KERNEL::Exception("DataArrayChar::Aggregate : input list must be NON EMPTY !"); 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) @@ -510,23 +509,23 @@ DataArrayChar *DataArrayChar::Meld(const std::vector& arr 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(std::size_t i=1;it!=a.end();it++,i++) { if(nbOfTuples!=(*it)->getNumberOfTuples()) throw INTERP_KERNEL::Exception("DataArrayChar::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); DataArrayChar *ret=a[0]->buildEmptySpecializedDAChar(); ret->alloc(nbOfTuples,totalNbOfComp); char *retPtr=ret->getPointer(); - for(std::size_t i=0;i& arr } int k=0; for(int i=0;i<(int)a.size();i++) - for(int j=0;jsetInfoOnComponent(k,a[i]->getInfoOnComponent(j)); return ret; } @@ -625,8 +624,8 @@ void DataArrayByte::reprWithoutNameStream(std::ostream& stream) const if(_mem.reprHeader(ToIdType(getNumberOfComponents()),stream)) { const char *data=begin(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); - mcIdType nbCompo=ToIdType(getNumberOfComponents()); + mcIdType nbOfTuples=getNumberOfTuples(); + std::size_t nbCompo=getNumberOfComponents(); for(int i=0;i=1) @@ -671,7 +671,7 @@ void DataArrayByte::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); } @@ -685,8 +685,8 @@ void DataArrayByte::reprQuickOverview(std::ostream& stream) const void DataArrayByte::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const char *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 << "["; std::string oss2Str(oss2.str()); bool isFinished=true; @@ -695,7 +695,7 @@ void DataArrayByte::reprQuickOverviewData(std::ostream& stream, std::size_t maxN if(nbOfCompo>1) { oss2 << "("; - for(int j=0;j DataArrayByte::toVectorOfBool() const checkAllocated(); if(getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("DataArrayByte::toVectorOfBool : this method can be used only if this has one component !"); - mcIdType nbt=ToIdType(getNumberOfTuples()); + mcIdType nbt(getNumberOfTuples()); std::vector ret(nbt,false); const char *pt(begin()); for(int 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(); } } @@ -777,14 +777,14 @@ DataArrayByteTuple *DataArrayByteIterator::nextt() return 0; } -DataArrayByteTuple::DataArrayByteTuple(char *pt, int nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) +DataArrayByteTuple::DataArrayByteTuple(char *pt, std::size_t nbOfComp):_pt(pt),_nb_of_compo(nbOfComp) { } std::string DataArrayByteTuple::repr() const { std::ostringstream oss; oss << "("; - for(int i=0;i<_nb_of_compo-1;i++) + for(std::size_t i=0;i<_nb_of_compo-1;i++) oss << (int)_pt[i] << ", "; oss << _pt[_nb_of_compo-1] << ")"; return oss.str(); @@ -803,7 +803,7 @@ char DataArrayByteTuple::byteValue() 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. */ -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)) { @@ -977,8 +977,8 @@ void DataArrayAsciiChar::reprWithoutNameStream(std::ostream& stream) const if(_mem.reprHeader(ToIdType(getNumberOfComponents()),stream)) { const char *data=begin(); - mcIdType nbOfTuples=ToIdType(getNumberOfTuples()); - mcIdType nbCompo=ToIdType(getNumberOfComponents()); + mcIdType nbOfTuples=getNumberOfTuples(); + std::size_t nbCompo=getNumberOfComponents(); for(int i=0;i=1) @@ -1022,7 +1023,7 @@ void DataArrayAsciiChar::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); } @@ -1036,27 +1037,27 @@ void DataArrayAsciiChar::reprQuickOverview(std::ostream& stream) const void DataArrayAsciiChar::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const char *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 << "["; std::string oss2Str(oss2.str()); bool isFinished=true; for(int 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(); } } @@ -1117,7 +1118,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 +1142,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..3e454f0ff 100644 --- a/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayFloat.cxx @@ -40,7 +40,8 @@ DataArrayFloat *DataArrayFloat::deepCopy() const void DataArrayFloat::reprCppStream(const std::string& varName, std::ostream& stream) const { - mcIdType nbTuples=ToIdType(getNumberOfTuples()),nbComp=ToIdType(getNumberOfComponents()); + mcIdType nbTuples(getNumberOfTuples()); + std::size_t nbComp(getNumberOfComponents()); const float *data(begin()); stream.precision(7); stream << "DataArrayFloat *" << varName << "=DataArrayFloat::New();" << std::endl; @@ -65,7 +66,7 @@ void DataArrayFloat::reprQuickOverview(std::ostream& stream) const int nbOfCompo=(int)_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); } @@ -79,8 +80,8 @@ void DataArrayFloat::reprQuickOverview(std::ostream& stream) const void DataArrayFloat::reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const { const float *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(7); std::string oss2Str(oss2.str()); @@ -90,7 +91,7 @@ void DataArrayFloat::reprQuickOverviewData(std::ostream& stream, std::size_t max if(nbOfCompo>1) { oss2 << "("; - for(int j=0;j(pt,nbOfComp) +DataArrayFloatTuple::DataArrayFloatTuple(float *pt, std::size_t nbOfComp):DataArrayTuple(pt,nbOfComp) { } std::string DataArrayFloatTuple::repr() const { std::ostringstream oss; oss.precision(7); oss << "("; - for(int i=0;i<_nb_of_compo-1;i++) + for(std::size_t i=0;i<_nb_of_compo-1;i++) oss << _pt[i] << ", "; oss << _pt[_nb_of_compo-1] << ")"; return oss.str(); @@ -164,7 +165,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/MEDCouplingMesh.cxx b/src/MEDCoupling/MEDCouplingMesh.cxx index 3ef945c25..299bd38f2 100755 --- a/src/MEDCoupling/MEDCouplingMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMesh.cxx @@ -658,7 +658,7 @@ void MEDCouplingMesh::getCellsContainingPoints(const double *pos, int nbOfPoints std::vector ret; getCellsContainingPoint(work,eps,ret); elts->insertAtTheEnd(ret.begin(),ret.end()); - eltsIndexPtr[i+1]=ToIdType(elts->getNumberOfTuples()); + eltsIndexPtr[i+1]=elts->getNumberOfTuples(); } } diff --git a/src/MEDCoupling/MEDCouplingPartDefinition.cxx b/src/MEDCoupling/MEDCouplingPartDefinition.cxx index 1b631d935..ce270590a 100644 --- a/src/MEDCoupling/MEDCouplingPartDefinition.cxx +++ b/src/MEDCoupling/MEDCouplingPartDefinition.cxx @@ -104,7 +104,7 @@ DataArrayPartDefinition *DataArrayPartDefinition::deepCopy() const int DataArrayPartDefinition::getNumberOfElems() const { checkInternalArrayOK(); - return ToIdType(_arr->getNumberOfTuples()); + return _arr->getNumberOfTuples(); } PartDefinition *DataArrayPartDefinition::operator+(const PartDefinition& other) const diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index d8762c9cd..951358aaf 100755 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -55,7 +55,7 @@ MEDCouplingPointSet::~MEDCouplingPointSet() int MEDCouplingPointSet::getNumberOfNodes() const { if(_coords) - return ToIdType(_coords->getNumberOfTuples()); + return _coords->getNumberOfTuples(); else throw INTERP_KERNEL::Exception("Unable to get number of nodes because no coordinates specified !"); } @@ -501,7 +501,7 @@ double MEDCouplingPointSet::getCaracteristicDimension() const if(!_coords) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getCaracteristicDimension : Coordinates not set !"); const double *coords=_coords->getConstPointer(); - mcIdType nbOfValues=ToIdType(_coords->getNbOfElems()); + std::size_t nbOfValues=_coords->getNbOfElems(); return std::abs(*std::max_element(coords,coords+nbOfValues,MEDCouplingCompAbs())); } @@ -1438,7 +1438,7 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int mcIdType nbCells=ToIdType(getNumberOfCells()); if (nbCells != ToIdType(other->getNumberOfCells())) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !"); - mcIdType dan=ToIdType(da->getNumberOfTuples()); + mcIdType dan(da->getNumberOfTuples()); if (dan) { MCAuto da1(DataArrayInt::New()),da2(DataArrayInt::New()); @@ -1450,8 +1450,8 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !"); } MCAuto cellCor2=da->selectByTupleIdSafeSlice(nbCells,ToIdType(da->getNbOfElems()),1); - nodeCor=nodeCor2->isIota(ToIdType(nodeCor2->getNumberOfTuples()))?0:nodeCor2.retn(); - cellCor=cellCor2->isIota(ToIdType(cellCor2->getNumberOfTuples()))?0:cellCor2.retn(); + nodeCor=nodeCor2->isIota(nodeCor2->getNumberOfTuples())?0:nodeCor2.retn(); + cellCor=cellCor2->isIota(cellCor2->getNumberOfTuples())?0:cellCor2.retn(); } /*! @@ -1495,7 +1495,7 @@ void MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : some cells in other are not in this !"); } MCAuto cellCor2=da->selectByTupleIdSafeSlice(ToIdType(getNumberOfCells()),ToIdType(da->getNbOfElems()),1); - cellCor=cellCor2->isIota(ToIdType(cellCor2->getNumberOfTuples()))?0:cellCor2.retn(); + cellCor=cellCor2->isIota(cellCor2->getNumberOfTuples())?0:cellCor2.retn(); } void MEDCouplingPointSet::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const diff --git a/src/MEDCoupling/MEDCouplingRemapper.cxx b/src/MEDCoupling/MEDCouplingRemapper.cxx index 7cf6cf73b..2318f4890 100755 --- a/src/MEDCoupling/MEDCouplingRemapper.cxx +++ b/src/MEDCoupling/MEDCouplingRemapper.cxx @@ -245,11 +245,11 @@ void MEDCouplingRemapper::reverseTransfer(MEDCouplingFieldDouble *srcField, cons throw INTERP_KERNEL::Exception(oss.str().c_str()); } DataArrayDouble *array(srcField->getArray()); - mcIdType trgNbOfCompo=ToIdType(targetField->getNumberOfComponents()); + std::size_t trgNbOfCompo=targetField->getNumberOfComponents(); if(array) { srcField->checkConsistencyLight(); - if(trgNbOfCompo!=srcField->getNumberOfTuplesExpected()) + if(trgNbOfCompo!=(std::size_t)srcField->getNumberOfTuplesExpected()) throw INTERP_KERNEL::Exception("Number of components mismatch !"); } else @@ -261,7 +261,7 @@ void MEDCouplingRemapper::reverseTransfer(MEDCouplingFieldDouble *srcField, cons computeDeno(srcField->getNature(),srcField,targetField); double *resPointer(srcField->getArray()->getPointer()); const double *inputPointer=targetField->getArray()->getConstPointer(); - computeReverseProduct(inputPointer,trgNbOfCompo,dftValue,resPointer); + computeReverseProduct(inputPointer,ToIdType(trgNbOfCompo),dftValue,resPointer); } /*! @@ -881,7 +881,7 @@ int MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss() MCAuto srcLoc=_src_ft->getLocalizationOfDiscr(); const double *srcLocPtr=srcLoc->begin(); MCAuto eltsArr,eltsIndexArr; - mcIdType trgNbOfGaussPts=ToIdType(trgLoc->getNumberOfTuples()); + mcIdType trgNbOfGaussPts=trgLoc->getNumberOfTuples(); _matrix.resize(trgNbOfGaussPts); _src_ft->getMesh()->getCellsContainingPointsLinearPartOnlyOnNonDynType(trgLoc->begin(),trgNbOfGaussPts,getPrecision(),eltsArr,eltsIndexArr); const int *elts(eltsArr->begin()),*eltsIndex(eltsIndexArr->begin()); @@ -904,7 +904,7 @@ int MEDCouplingRemapper::prepareNotInterpKernelOnlyGaussGauss() } _matrix[*trgId][srcEntry]=1.; } - if(ToIdType(ids0->getNumberOfTuples())!=trgNbOfGaussPts) + if(ids0->getNumberOfTuples()!=trgNbOfGaussPts) { MCAuto orphanTrgIds=nbOfSrcCellsShTrgPts->findIdsEqual(0); MCAuto orphanTrg=trgLoc->selectByTupleId(orphanTrgIds->begin(),orphanTrgIds->end()); @@ -1074,11 +1074,11 @@ void MEDCouplingRemapper::transferUnderground(const MEDCouplingFieldDouble *srcF throw INTERP_KERNEL::Exception(oss.str().c_str()); } DataArrayDouble *array(targetField->getArray()); - mcIdType srcNbOfCompo=ToIdType(srcField->getNumberOfComponents()); + std::size_t srcNbOfCompo(srcField->getNumberOfComponents()); if(array) { targetField->checkConsistencyLight(); - if(srcNbOfCompo!=ToIdType(targetField->getNumberOfComponents())) + if(srcNbOfCompo!=targetField->getNumberOfComponents()) throw INTERP_KERNEL::Exception("Number of components mismatch !"); } else @@ -1092,7 +1092,7 @@ void MEDCouplingRemapper::transferUnderground(const MEDCouplingFieldDouble *srcF computeDeno(srcField->getNature(),srcField,targetField); double *resPointer(targetField->getArray()->getPointer()); const double *inputPointer(srcField->getArray()->getConstPointer()); - computeProduct(inputPointer,srcNbOfCompo,isDftVal,dftValue,resPointer); + computeProduct(inputPointer,ToIdType(srcNbOfCompo),isDftVal,dftValue,resPointer); } void MEDCouplingRemapper::computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) 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/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index b9e75be70..0f5387686 100755 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -316,7 +316,7 @@ void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::splitProfilePerType : input profile is NULL or not allocated !"); if(profile->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::splitProfilePerType : input profile should have exactly one component !"); - mcIdType nbTuples=ToIdType(profile->getNumberOfTuples()); + mcIdType nbTuples(profile->getNumberOfTuples()); mcIdType nbOfCells=ToIdType(getNumberOfCells()); code.resize(3); idsInPflPerType.resize(1); code[0]=(int)getTypeOfCell(0); code[1]=nbOfCells; @@ -328,7 +328,7 @@ void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, idsPerType.clear(); return ; } - code[1]=ToIdType(profile->getNumberOfTuples()); + code[1]=profile->getNumberOfTuples(); code[2]=0; profile->checkAllIdsInRange(0,nbOfCells); idsPerType.resize(1); @@ -1709,10 +1709,11 @@ DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std:: throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom : input array of double is NULL or not allocated!"); if(st.size()!=partCompactFormat.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom : input arrays must have the same size !"); - if(ToIdType(fieldOfDbl->getNumberOfTuples())!=DeduceNumberOfGivenStructure(st)) + if(fieldOfDbl->getNumberOfTuples()!=DeduceNumberOfGivenStructure(st)) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom : invalid size of input array of double regarding the structure !"); std::vector dims(GetDimensionsFromCompactFrmt(partCompactFormat)); - int nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)),nbComp(ToIdType(fieldOfDbl->getNumberOfComponents())); + int nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)); + std::size_t nbComp(fieldOfDbl->getNumberOfComponents()); MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTuplesOfOutField,nbComp); ret->copyStringInfoFrom(*fieldOfDbl); double *ptRet(ret->getPointer()); @@ -1977,8 +1978,9 @@ void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, const throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::MultiplyPartOf : invalid input range 3 !"); dims[i]=part[i].second-part[i].first; } - int nbOfTuplesExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(st)),nbCompo(ToIdType(da->getNumberOfComponents())); - if(ToIdType(da->getNumberOfTuples())!=nbOfTuplesExp) + int nbOfTuplesExp(MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(st)); + std::size_t nbCompo(da->getNumberOfComponents()); + if(da->getNumberOfTuples()!=nbOfTuplesExp) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::MultiplyPartOf : invalid nb of tuples ! Expected " << nbOfTuplesExp << " having " << da->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 2ebf3471e..98373fdd9 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,15 @@ MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedCompon ret->setArrays(arrays3,0); return ret; } +MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector& compoIds) const +{ + // The method has to be removed as duplicate after SWIG update + std::vector ids (compoIds.size()); + cast_to_remove(compoIds, ids); + 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 +384,15 @@ 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) +{ + // The method has to be removed as duplicate after SWIG update + std::vector ids (compoIds.size()); + cast_to_remove (compoIds, ids); + setSelectedComponents (other, ids); +} -void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue) +void MEDCouplingTimeDiscretization::changeNbOfComponents(std::size_t newNbOfComp, double dftValue) { std::vector arrays; getArrays(arrays); @@ -2238,7 +2252,7 @@ void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vectorgetNumberOfTuples())); + tinyInfo.push_back(_end_array->getNumberOfTuples()); tinyInfo.push_back(ToIdType(_end_array->getNumberOfComponents())); } else @@ -2257,10 +2271,10 @@ void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector& tinyInfo) const { - mcIdType nbOfCompo=ToIdType(_array->getNumberOfComponents()); - for(int i=0;igetNumberOfComponents(); + for(std::size_t i=0;igetInfoOnComponent(i)); - for(int i=0;igetInfoOnComponent(i)); } @@ -2494,7 +2508,7 @@ void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value _array->getTuple(eltId,value); else throw INTERP_KERNEL::Exception("No start array existing."); - mcIdType nbComp=ToIdType(_array->getNumberOfComponents()); + std::size_t nbComp=_array->getNumberOfComponents(); std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies(),alpha)); std::vector tmp(nbComp); if(_end_array) 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/MEDCouplingTimeDiscretization.txx b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx index 9a29ca398..ced70b7ad 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx @@ -229,7 +229,7 @@ namespace MEDCoupling { if(_array) { - tinyInfo.push_back(ToIdType(_array->getNumberOfTuples())); + tinyInfo.push_back(_array->getNumberOfTuples()); tinyInfo.push_back(ToIdType(_array->getNumberOfComponents())); } else @@ -248,8 +248,8 @@ namespace MEDCoupling template void MEDCouplingTimeDiscretizationTemplate::getTinySerializationStrInformation(std::vector& tinyInfo) const { - mcIdType nbOfCompo=ToIdType(_array->getNumberOfComponents()); - for(int i=0;igetNumberOfComponents()); + for(std::size_t i=0;igetInfoOnComponent(i)); } @@ -292,8 +292,8 @@ namespace MEDCoupling void MEDCouplingTimeDiscretizationTemplate::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) { _time_tolerance=tinyInfoD[0]; - mcIdType nbOfCompo=ToIdType(_array->getNumberOfComponents()); - for(int i=0;igetNumberOfComponents(); + for(std::size_t i=0;isetInfoOnComponent(i,tinyInfoS[i]); } diff --git a/src/MEDCoupling/MEDCouplingTraits.hxx b/src/MEDCoupling/MEDCouplingTraits.hxx index 5d550b55e..1976a38cf 100644 --- a/src/MEDCoupling/MEDCouplingTraits.hxx +++ b/src/MEDCoupling/MEDCouplingTraits.hxx @@ -23,9 +23,16 @@ #include "MEDCoupling.hxx" #include "MCType.hxx" +#include namespace MEDCoupling { + inline void cast_to_remove (const std::vector& in, std::vector& out) + { + out.resize (in.size()); + std::copy (in.begin(), in.end(), out.begin()); + } + template struct MEDCOUPLING_EXPORT Traits { diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 0f2d3f486..fec373339 100755 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -808,7 +808,7 @@ void MEDCouplingUMesh::computeCellNeighborhoodFromNodesOne(const DataArrayInt *n s.insert(ne+nei[*it],ne+nei[*it+1]); s.erase(i); cellNeigh->insertAtTheEnd(s.begin(),s.end()); - cellNeighIndex->pushBackSilent(ToIdType(cellNeigh->getNumberOfTuples())); + cellNeighIndex->pushBackSilent(cellNeigh->getNumberOfTuples()); } } @@ -842,7 +842,7 @@ void MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(const DataArrayInt *desc, cons const int *revDescPtr=revDesc->begin(); const int *revDescIPtr=revDescIndx->begin(); // - mcIdType nbCells=ToIdType(descIndx->getNumberOfTuples())-1; + mcIdType nbCells=descIndx->getNumberOfTuples()-1; MCAuto out0=DataArrayInt::New(); MCAuto out1=DataArrayInt::New(); out1->alloc(nbCells+1,1); int *out1Ptr=out1->getPointer(); @@ -856,7 +856,7 @@ void MEDCouplingUMesh::ComputeNeighborsOfCellsAdv(const DataArrayInt *desc, cons s.erase(i); out0->insertAtTheEnd(s.begin(),s.end()); } - *out1Ptr=ToIdType(out0->getNumberOfTuples()); + *out1Ptr=out0->getNumberOfTuples(); } neighbors=out0.retn(); neighborsIndx=out1.retn(); @@ -1326,7 +1326,7 @@ void MEDCouplingUMesh::simplifyPolyhedra(double eps) } else connNew->insertAtTheEnd(conn+index[i],conn+index[i+1]); - *connINewPtr=ToIdType(connNew->getNumberOfTuples()); + *connINewPtr=connNew->getNumberOfTuples(); } if(changed) setConnectivity(connNew,connINew,false); @@ -1721,7 +1721,7 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const D DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) { MCAuto commonCells=DataArrayInt::New(),commonCellsI=DataArrayInt::New(); commonCells->alloc(0,1); - mcIdType nbOfCells=ToIdType(nodalI->getNumberOfTuples())-1; + mcIdType nbOfCells=nodalI->getNumberOfTuples()-1; commonCellsI->reserve(1); commonCellsI->pushBackSilent(0); const int *revNodalPtr=revNodal->getConstPointer(),*revNodalIPtr=revNodalI->getConstPointer(); const int *connPtr=nodal->getConstPointer(),*connIPtr=nodalI->getConstPointer(); @@ -1753,7 +1753,7 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const D if(AreCellsEqualInPool(v2,compType,connPtr,connIPtr,commonCells)) { int pos=commonCellsI->back(); - commonCellsI->pushBackSilent(ToIdType(commonCells->getNumberOfTuples())); + commonCellsI->pushBackSilent(commonCells->getNumberOfTuples()); for(const int *it=commonCells->begin()+pos;it!=commonCells->end();it++) isFetched[*it]=true; } @@ -1786,7 +1786,7 @@ void MEDCouplingUMesh::FindCommonCellsAlg(int compType, int startCellId, const D if(AreCellsEqualInPool(v2,compType,connPtr,connIPtr,commonCells)) { int pos=commonCellsI->back(); - commonCellsI->pushBackSilent(ToIdType(commonCells->getNumberOfTuples())); + commonCellsI->pushBackSilent(commonCells->getNumberOfTuples()); for(const int *it=commonCells->begin()+pos;it!=commonCells->end();it++) isFetched[*it]=true; } @@ -1866,8 +1866,8 @@ bool MEDCouplingUMesh::areCellsIncludedInPolicy7(const MEDCouplingUMesh *other, arr2->alloc(otherNbCells,1); arr2->fillWithZero(); int *arr2Ptr=arr2->getPointer(); - mcIdType nbOfCommon=ToIdType(commonCellsI->getNumberOfTuples())-1; - for(int i=0;igetNumberOfTuples()-1; + for(mcIdType i=0;igetPointer(); cnt < connexCheck->getNumberOfTuples(); ptr++, cnt++) hitCells->setIJ(*ptr,0,1); // Connex zone WITH the crack (to identify cells lying on either part of the crack) @@ -2418,7 +2418,7 @@ void MEDCouplingUMesh::findNodesToDuplicate(const MEDCouplingUMesh& otherDimM1On if (nIter >= nIterMax) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findNodesToDuplicate(): internal error - too many iterations."); - DAInt cellsToModifyConn1_torenum=cellsToModifyConn0_torenum->buildComplement(ToIdType(neighI00->getNumberOfTuples())-1); + DAInt cellsToModifyConn1_torenum=cellsToModifyConn0_torenum->buildComplement(neighI00->getNumberOfTuples()-1); cellsToModifyConn0_torenum->transformWithIndArr(cellsAroundGroup->begin(),cellsAroundGroup->end()); cellsToModifyConn1_torenum->transformWithIndArr(cellsAroundGroup->begin(),cellsAroundGroup->end()); // @@ -3646,7 +3646,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3DSurf(const double *origin, const if(cut3DSurf[i].first!=-2) { conn->pushBackSilent((int)INTERP_KERNEL::NORM_SEG2); conn->pushBackSilent(cut3DSurf[i].first); conn->pushBackSilent(cut3DSurf[i].second); - connI->pushBackSilent(ToIdType(conn->getNumberOfTuples())); + connI->pushBackSilent(conn->getNumberOfTuples()); cellIds2->pushBackSilent(i); } else @@ -3657,7 +3657,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3DSurf(const double *origin, const for(int j=0;jpushBackSilent((int)INTERP_KERNEL::NORM_SEG2); conn->pushBackSilent(nodal[offset+j]); conn->pushBackSilent(nodal[offset+(j+1)%nbOfEdges]); - connI->pushBackSilent(ToIdType(conn->getNumberOfTuples())); + connI->pushBackSilent(conn->getNumberOfTuples()); cellIds2->pushBackSilent(cellId3DSurf); } } @@ -3720,7 +3720,7 @@ MCAuto MEDCouplingUMesh::clipSingle3DCellByPlane(const double { conn->pushBackSilent((int)INTERP_KERNEL::NORM_POLYGON); conn->insertAtTheEnd(res[i].begin(),res[i].end()); - connI->pushBackSilent(ToIdType(conn->getNumberOfTuples())); + connI->pushBackSilent(conn->getNumberOfTuples()); } MCAuto ret(MEDCouplingUMesh::New("",2)); ret->setCoords(mDesc1->getCoords()); @@ -3778,9 +3778,9 @@ MCAuto MEDCouplingUMesh::clipSingle3DCellByPlane(const double } } conn2->insertAtTheEnd(cell0.begin(),cell0.end()); - conn2I->pushBackSilent(ToIdType(conn2->getNumberOfTuples())); + conn2I->pushBackSilent(conn2->getNumberOfTuples()); conn2->insertAtTheEnd(cell1.begin(),cell1.end()); - conn2I->pushBackSilent(ToIdType(conn2->getNumberOfTuples())); + conn2I->pushBackSilent(conn2->getNumberOfTuples()); ret2->setConnectivity(conn2,conn2I,true); ret2->checkConsistencyLight(); ret2->orientCorrectlyPolyhedrons(); @@ -3820,7 +3820,7 @@ DataArrayInt *MEDCouplingUMesh::getCellIdsCrossingPlane(const double *origin, co MCAuto coo=_coords->deepCopy(); double normm2(sqrt(vec2[0]*vec2[0]+vec2[1]*vec2[1]+vec2[2]*vec2[2])); if(normm2/normm>1e-6) - DataArrayDouble::Rotate3DAlg(origin,vec2,angle,ToIdType(coo->getNumberOfTuples()),coo->getPointer(),coo->getPointer()); + DataArrayDouble::Rotate3DAlg(origin,vec2,angle,coo->getNumberOfTuples(),coo->getPointer(),coo->getPointer()); MCAuto mw=clone(false);//false -> shallow copy mw->setCoords(coo); mw->getBoundingBox(bbox); @@ -3979,7 +3979,7 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, mcIdType nbCells=ToIdType(getNumberOfCells()); if(nbCells==0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : no cells in this !"); - mcIdType nbOfPts=ToIdType(pts->getNumberOfTuples()); + mcIdType nbOfPts=pts->getNumberOfTuples(); MCAuto ret0=DataArrayDouble::New(); ret0->alloc(nbOfPts,1); MCAuto ret1=DataArrayInt::New(); ret1->alloc(nbOfPts,1); const int *nc=_nodal_connec->begin(),*ncI=_nodal_connec_index->begin(); const double *coords=_coords->begin(); @@ -4233,11 +4233,11 @@ DataArrayInt *MEDCouplingUMesh::convexEnvelop2D() isChanged->alloc(0,1); for(int i=0;igetNumberOfTuples()); + mcIdType pos=nodalConnecOut->getNumberOfTuples(); if(BuildConvexEnvelopOf2DCellJarvis(coords,nodalConnecIn+nodalConnecIndexIn[i],nodalConnecIn+nodalConnecIndexIn[i+1],nodalConnecOut)) isChanged->pushBackSilent(i); types.insert((INTERP_KERNEL::NormalizedCellType)nodalConnecOut->getIJ(pos,0)); - workIndexOut[1]=ToIdType(nodalConnecOut->getNumberOfTuples()); + workIndexOut[1]=nodalConnecOut->getNumberOfTuples(); } if(isChanged->empty()) return 0; @@ -4716,7 +4716,7 @@ DataArrayInt *MEDCouplingUMesh::convertDegeneratedCellsAndRemoveFlatOnes() } if(newPos!=initMeshLgth) _nodal_connec->reAlloc(newPos); - const mcIdType nCellDel=ToIdType(ret->getNumberOfTuples()); + const mcIdType nCellDel=ret->getNumberOfTuples(); if (nCellDel) _nodal_connec_index->reAlloc(nbOfCells-nCellDel+1); computeTypes(); @@ -5417,7 +5417,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::computeDiameterField() const ret->setMesh(this); std::set types; ComputeAllTypesInternal(types,_nodal_connec,_nodal_connec_index); - mcIdType spaceDim(ToIdType(getSpaceDimension())),nbCells(ToIdType(getNumberOfCells())); + mcIdType spaceDim(getSpaceDimension()),nbCells(ToIdType(getNumberOfCells())); MCAuto arr(DataArrayDouble::New()); arr->alloc(nbCells,1); for(std::set::const_iterator it=types.begin();it!=types.end();it++) @@ -5819,7 +5819,7 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec MCAuto tmp1=rankInsideCast; MCAuto tmp2=castsPresent; // - mcIdType nbOfCastsFinal=ToIdType(castsPresent->getNumberOfTuples()); + mcIdType nbOfCastsFinal=castsPresent->getNumberOfTuples(); code.resize(3*nbOfCastsFinal); std::vector< MCAuto > idsInPflPerType2; std::vector< MCAuto > idsPerType2; @@ -5829,7 +5829,7 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec MCAuto tmp3=castArr->findIdsEqual(castId); idsInPflPerType2.push_back(tmp3); code[3*i]=(int)types[castId]; - code[3*i+1]=ToIdType(tmp3->getNumberOfTuples()); + code[3*i+1]=tmp3->getNumberOfTuples(); MCAuto tmp4=rankInsideCast->selectByTupleId(tmp3->begin(),tmp3->begin()+tmp3->getNumberOfTuples()); if(!smartPflKiller || !tmp4->isIota(typeRangeVals[castId+1]-typeRangeVals[castId])) { @@ -6210,7 +6210,7 @@ void MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh(DataArrayInt if(_types.size()!=1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh : current mesh does not contain exactly one geometric type !"); mcIdType nbCells=ToIdType(getNumberOfCells()), - lgth=ToIdType(_nodal_connec->getNumberOfTuples()); + lgth=_nodal_connec->getNumberOfTuples(); if(lgth c(DataArrayInt::New()),ci(DataArrayInt::New()); @@ -6685,7 +6685,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::Build0DMeshFromCoords(DataArrayDouble *da) if(name.empty()) ret->setName("Mesh"); ret->setCoords(da); - mcIdType nbOfTuples=ToIdType(da->getNumberOfTuples()); + mcIdType nbOfTuples(da->getNumberOfTuples()); MCAuto c(DataArrayInt::New()),cI(DataArrayInt::New()); c->alloc(2*nbOfTuples,1); cI->alloc(nbOfTuples+1,1); @@ -7018,7 +7018,7 @@ void MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(const std::vectorfindCommonTuples(eps,-1,comm,commI); MCAuto tmp1(comm),tmp2(commI); - mcIdType oldNbOfNodes=ToIdType(coo->getNumberOfTuples()); + mcIdType oldNbOfNodes=coo->getNumberOfTuples(); int newNbOfNodes; MCAuto o2n=DataArrayInt::ConvertIndexArrayToO2N(oldNbOfNodes,comm->begin(),commI->begin(),commI->end(),newNbOfNodes); if(oldNbOfNodes==newNbOfNodes) @@ -7189,12 +7189,12 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble if (comm1->findIdFirstEqual(i) < 0) { comm1->pushBackSilent(i); - commI1->pushBackSilent(mcIdType(comm1->getNumberOfTuples())); + commI1->pushBackSilent(comm1->getNumberOfTuples()); } MCAuto comm1Auto(comm1),commI1Auto(commI1); const int *comm1Ptr=comm1->begin(); const int *commI1Ptr=commI1->begin(); - mcIdType nbOfGrps1=ToIdType(commI1Auto->getNumberOfTuples())-1; + mcIdType nbOfGrps1=commI1Auto->getNumberOfTuples()-1; res->pushBackSilent((int)INTERP_KERNEL::NORM_POLYHED); // for(int i=0;ifindIdFirstEqual(j) < 0) { comm2->pushBackSilent(j); - commI2->pushBackSilent(ToIdType(comm2->getNumberOfTuples())); + commI2->pushBackSilent(comm2->getNumberOfTuples()); } MCAuto comm2Auto(comm2),commI2Auto(commI2); const int *comm2Ptr=comm2->begin(); const int *commI2Ptr=commI2->begin(); - mcIdType nbOfGrps2=ToIdType(commI2Auto->getNumberOfTuples())-1; + mcIdType nbOfGrps2=commI2Auto->getNumberOfTuples()-1; for(int j=0;jisAllocated()) { stream << std::endl << "Nodal connectivity set but not allocated !"; return ; } - mcIdType lgth=ToIdType(_nodal_connec_index->getNumberOfTuples()); - mcIdType cpt=ToIdType(_nodal_connec_index->getNumberOfComponents()); + mcIdType lgth=_nodal_connec_index->getNumberOfTuples(); + std::size_t cpt=_nodal_connec_index->getNumberOfComponents(); if(cpt!=1 || lgth<1) return ; stream << std::endl << "Number of cells : " << lgth-1 << "."; @@ -7886,7 +7886,7 @@ DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(const int *se nbOfDepthPeelingPerformed=0; if(!arrIndxIn) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed : arrIndxIn input pointer is NULL !"); - mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1; + mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; if(nbOfTuples<=0) { DataArrayInt *ret=DataArrayInt::New(); ret->alloc(0,1); @@ -7938,7 +7938,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSpreadZonesWithPoly : meshdimension supported are [2,3] ! Not implemented yet for others !"); } - ret->insertNextCell((INTERP_KERNEL::NormalizedCellType)cell->getIJSafe(0,0),ToIdType(cell->getNumberOfTuples())-1,cell->begin()+1); + ret->insertNextCell((INTERP_KERNEL::NormalizedCellType)cell->getIJSafe(0,0),cell->getNumberOfTuples()-1,cell->begin()+1); } // ret->finishInsertingCells(); @@ -7963,7 +7963,7 @@ std::vector MEDCouplingUMesh::PartitionBySpreadZone(const DataAr if(!arrIn || !arrIndxIn) throw INTERP_KERNEL::Exception("PartitionBySpreadZone : null input pointers !"); arrIn->checkAllocated(); arrIndxIn->checkAllocated(); - mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples()); + mcIdType nbOfTuples(arrIndxIn->getNumberOfTuples()); if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1 || nbOfTuples<1) throw INTERP_KERNEL::Exception("PartitionBySpreadZone : invalid arrays in input !"); int nbOfCellsCur(nbOfTuples-1); @@ -8068,7 +8068,7 @@ MEDCoupling1SGTUMesh *MEDCouplingUMesh::tetrahedrize(int policy, DataArrayInt *& if(!addPts->empty()) { addPts->rearrange(3); - nbOfAdditionalPoints=ToIdType(addPts->getNumberOfTuples()); + nbOfAdditionalPoints=addPts->getNumberOfTuples(); addPts=DataArrayDouble::Aggregate(getCoords(),addPts); ret0->setCoords(addPts); } diff --git a/src/MEDCoupling/MEDCouplingUMesh_internal.cxx b/src/MEDCoupling/MEDCouplingUMesh_internal.cxx index 510b75556..a47ecc255 100755 --- a/src/MEDCoupling/MEDCouplingUMesh_internal.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh_internal.cxx @@ -395,7 +395,7 @@ void MEDCouplingUMesh::tessellate2DCurveInternal(double eps) newConnIPtr[1]=newConnIPtr[0]+3; } } - if(addCoo.empty() && newConn.size()==_nodal_connec->getNumberOfTuples())//nothing happens during tessellation : no update needed + if(addCoo.empty() && ToIdType(newConn.size())==_nodal_connec->getNumberOfTuples())//nothing happens during tessellation : no update needed return ; _types=types; DataArrayInt::SetArrayIn(newConnI,_nodal_connec_index); @@ -1094,7 +1094,7 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D1(DataArrayInt *& const int *cPtr=_nodal_connec->begin(); const int *icPtr=_nodal_connec_index->begin(); int lastVal=0; - mcIdType offset=ToIdType(coordsTmpSafe->getNumberOfTuples()); + mcIdType offset=coordsTmpSafe->getNumberOfTuples(); for(int i=0;ipushBackValsSilent(cPtr+icPtr[0]+1,cPtr+icPtr[1]); for(const int *d=descPtr+descIPtr[0];d!=descPtr+descIPtr[1];d++) newConn->pushBackSilent(c1DPtr[c1DIPtr[*d]+3]); - newConn->pushBackSilent(offset+ToIdType(ret->getNumberOfTuples())); + newConn->pushBackSilent(offset+ret->getNumberOfTuples()); lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0])+1; newConnI->pushBackSilent(lastVal); ret->pushBackSilent(i); @@ -1163,7 +1163,7 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayInt *& const int *cPtr=_nodal_connec->begin(); const int *icPtr=_nodal_connec_index->begin(); int lastVal=0; - mcIdType offset=ToIdType(coordsTmpSafe->getNumberOfTuples()); + mcIdType offset=coordsTmpSafe->getNumberOfTuples(); for(int i=0;igetNumberOfTuples()); + mcIdType tmpPos=newConn->getNumberOfTuples(); newConn->pushBackSilent(nodeId2); ret2D->pushBackSilent(nodeId2); ret1D->pushBackSilent(tmpPos); } - newConn->pushBackSilent(offset+ToIdType(ret->getNumberOfTuples())); + newConn->pushBackSilent(offset+ret->getNumberOfTuples()); lastVal+=(icPtr[1]-icPtr[0])+(descIPtr[1]-descIPtr[0])+(desc2IPtr[1]-desc2IPtr[0])+1; newConnI->pushBackSilent(lastVal); ret->pushBackSilent(i); @@ -1201,7 +1201,7 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayInt *& } } MCAuto diffRet2D=ret2D->getDifferentValues(); - MCAuto o2nRet2D=diffRet2D->invertArrayN2O2O2N(ToIdType(coordsTmp2Safe->getNumberOfTuples())); + MCAuto o2nRet2D=diffRet2D->invertArrayN2O2O2N(coordsTmp2Safe->getNumberOfTuples()); coordsTmp2Safe=coordsTmp2Safe->selectByTupleId(diffRet2D->begin(),diffRet2D->end()); MCAuto tmp=bary->selectByTupleIdSafe(ret->begin(),ret->end()); std::vector v(3); v[0]=coordsTmpSafe; v[1]=coordsTmp2Safe; v[2]=tmp; @@ -1209,7 +1209,7 @@ DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayInt *& const int *cI(newConnI->begin()); for(const int *elt=ret1D->begin();elt!=ret1D->end();elt++) c[*elt]=o2nRet2D->getIJ(c[*elt],0)+offset; - offset=ToIdType(coordsTmp2Safe->getNumberOfTuples()); + offset=coordsTmp2Safe->getNumberOfTuples(); for(const int *elt=ret->begin();elt!=ret->end();elt++) c[cI[(*elt)+1]-1]+=offset; coords=DataArrayDouble::Aggregate(v); conn=newConn.retn(); connI=newConnI.retn(); @@ -1440,7 +1440,7 @@ DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg(std::vecto nbOfDepthPeelingPerformed=0; if(!seedBg || !seedEnd || !arrIn || !arrIndxIn) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg : some input pointer is NULL !"); - mcIdType nbOfTuples=ToIdType(arrIndxIn->getNumberOfTuples())-1; + mcIdType nbOfTuples=arrIndxIn->getNumberOfTuples()-1; std::vector fetched2(nbOfTuples,false); int i=0; for(const int *seedElt=seedBg;seedElt!=seedEnd;seedElt++,i++) @@ -1737,7 +1737,7 @@ void MEDCouplingUMesh::assemblyForSplitFrom3DSurf(const std::vector< std::pair3) { nodalRes->insertAtTheEnd(conn.begin(),conn.end()); - nodalResIndx->pushBackSilent(ToIdType(nodalRes->getNumberOfTuples())); + nodalResIndx->pushBackSilent(nodalRes->getNumberOfTuples()); cellIds->pushBackSilent(i); } } diff --git a/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx b/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx index 010b8b273..6f18e0051 100644 --- a/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx @@ -89,7 +89,7 @@ void EnterTheResultOf2DCellFirst(const INTERP_KERNEL::Edge *e, int start, int st { if(stp-start>1) { - mcIdType tmp2(0),tmp3(ToIdType(appendedCoords->getNumberOfTuples())/2); + mcIdType tmp2(0),tmp3(appendedCoords->getNumberOfTuples()/2); InternalAddPointOriented(e,-1,coords,tmp[1],tmp[2],*appendedCoords,tmp2); middles.push_back(tmp3+offset); } @@ -106,7 +106,7 @@ void EnterTheResultOf2DCellMiddle(const INTERP_KERNEL::Edge *e, int start, int s { if(stp-start>1) { - mcIdType tmp2(0),tmp3(ToIdType(appendedCoords->getNumberOfTuples())/2); + mcIdType tmp2(0),tmp3(appendedCoords->getNumberOfTuples()/2); InternalAddPointOriented(e,-1,coords,tmpSrt,tmpEnd,*appendedCoords,tmp2); middles.push_back(tmp3+offset); } @@ -123,7 +123,7 @@ void EnterTheResultOf2DCellEnd(const INTERP_KERNEL::Edge *e, int start, int stp, if(stp-start>1) // if we are covering more than one segment we need to create a new mid point { mcIdType tmpSrt(connBg[start]),tmpEnd(connBg[stp % nbOfEdges]); // % to handle last seg. - mcIdType tmp2(0),tmp3(ToIdType(appendedCoords->getNumberOfTuples())/2); + mcIdType tmp2(0),tmp3(appendedCoords->getNumberOfTuples()/2); InternalAddPointOriented(e,-1,coords,tmpSrt,tmpEnd,*appendedCoords,tmp2); middles.push_back(tmp3+offset); } @@ -567,8 +567,8 @@ MEDCouplingUMesh *BuildMesh1DCutFrom(const MEDCouplingUMesh *mesh1D, const std:: const DataArrayDouble *coo2(mesh1D->getCoords()); const int *c(mesh1D->getNodalConnectivity()->begin()),*ci(mesh1D->getNodalConnectivityIndex()->begin()); const double *coo2Ptr(coo2->begin()); - mcIdType offset1=ToIdType(coords1->getNumberOfTuples()); - mcIdType offset2=(offset1+ToIdType(coo2->getNumberOfTuples())); + mcIdType offset1(coords1->getNumberOfTuples()); + mcIdType offset2(offset1+coo2->getNumberOfTuples()); mcIdType offset3(offset2+ToIdType(addCoo.size())/2); std::vector addCooQuad; MCAuto cOut(DataArrayInt::New()),ciOut(DataArrayInt::New()); cOut->alloc(0,1); ciOut->alloc(1,1); ciOut->setIJ(0,0,0); @@ -668,7 +668,7 @@ MEDCouplingUMesh *BuildRefined2DCellQuadratic(const DataArrayDouble *coords, con std::vector allEdges,centers; const double *coordsPtr(coords->begin()); MCAuto addCoo(DataArrayDouble::New()); addCoo->alloc(0,1); - mcIdType offset=ToIdType(coords->getNumberOfTuples()); + mcIdType offset(coords->getNumberOfTuples()); for(const int *it2(descBg);it2!=descEnd;it2++,ii++) { INTERP_KERNEL::NormalizedCellType typeOfSon; @@ -1296,7 +1296,7 @@ void MEDCouplingUMesh::Intersect1DMeshes(const MEDCouplingUMesh *m1Desc, const M colinear2.resize(nDescCell2); subDiv2.resize(nDescCell2); BBTree myTree(bbox2,0,0,ToIdType(m2Desc->getNumberOfCells()),-eps); - BBTreePts treeNodes2(m2Desc->getCoords()->begin(),0,0,ToIdType(m2Desc->getCoords()->getNumberOfTuples()),eps); + BBTreePts treeNodes2(m2Desc->getCoords()->begin(),0,0,m2Desc->getCoords()->getNumberOfTuples(),eps); std::vector candidates1(1); int offset1(m1Desc->getNumberOfNodes()); @@ -1568,7 +1568,7 @@ void MEDCouplingUMesh::split2DCellsLinear(const DataArrayInt *desc, const DataAr { checkConnectivityFullyDefined(); mcIdType ncells=ToIdType(getNumberOfCells()); - mcIdType lgthToReach(getNodalConnectivityArrayLen()+ToIdType(subNodesInSeg->getNumberOfTuples())); + mcIdType lgthToReach(getNodalConnectivityArrayLen()+subNodesInSeg->getNumberOfTuples()); MCAuto c(DataArrayInt::New()); c->alloc((std::size_t)lgthToReach); const int *subPtr(subNodesInSeg->begin()),*subIPtr(subNodesInSegI->begin()),*descPtr(desc->begin()),*descIPtr(descI->begin()),*oldConn(getNodalConnectivity()->begin()); int *cPtr(c->getPointer()),*ciPtr(getNodalConnectivityIndex()->getPointer()); @@ -1606,7 +1606,7 @@ int MEDCouplingUMesh::split2DCellsQuadratic(const DataArrayInt *desc, const Data { checkConsistencyLight(); mcIdType ncells=ToIdType(getNumberOfCells()); - mcIdType lgthToReach(getNodalConnectivityArrayLen()+2*ToIdType(subNodesInSeg->getNumberOfTuples())); + mcIdType lgthToReach(getNodalConnectivityArrayLen()+2*subNodesInSeg->getNumberOfTuples()); mcIdType nodesCnt(getNumberOfNodes()); MCAuto c(DataArrayInt::New()); c->alloc((std::size_t)lgthToReach); MCAuto addCoo(DataArrayDouble::New()); addCoo->alloc(0,1); @@ -1656,7 +1656,7 @@ int MEDCouplingUMesh::split2DCellsQuadratic(const DataArrayInt *desc, const Data addCoo->rearrange(2); MCAuto coo(DataArrayDouble::Aggregate(getCoords(),addCoo));//info are copied from getCoords() by using Aggregate setCoords(coo); - return ToIdType(addCoo->getNumberOfTuples()); + return addCoo->getNumberOfTuples(); } @@ -1833,12 +1833,12 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, MCAuto ret1NonCol(static_cast(ret1->buildPartOfMySelf(idsInRet1NotColinear->begin(),idsInRet1NotColinear->end()))); MCAuto baryRet1(ret1NonCol->computeCellCenterOfMass()); MCAuto elts,eltsIndex; - mesh2D->getCellsContainingPoints(baryRet1->begin(),ToIdType(baryRet1->getNumberOfTuples()),eps,elts,eltsIndex); + mesh2D->getCellsContainingPoints(baryRet1->begin(),baryRet1->getNumberOfTuples(),eps,elts,eltsIndex); MCAuto eltsIndex2(DataArrayInt::New()); eltsIndex2->alloc(0,1); if (eltsIndex->getNumberOfTuples() > 1) eltsIndex2 = eltsIndex->deltaShiftIndex(); MCAuto eltsIndex3(eltsIndex2->findIdsEqual(1)); - if(eltsIndex2->count(0)+eltsIndex3->getNumberOfTuples()!=ret1NonCol->getNumberOfCells()) + if(eltsIndex2->count(0)+eltsIndex3->getNumberOfTuples()!=ToIdType(ret1NonCol->getNumberOfCells())) throw INTERP_KERNEL::Exception("Intersect2DMeshWith1DLine : internal error 1 !"); MCAuto cellsToBeModified(elts->buildUnique()); MCAuto untouchedCells(cellsToBeModified->buildComplement(ToIdType(mesh2D->getNumberOfCells()))); @@ -1861,7 +1861,7 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, outMesh2DSplit.push_back(BuildRefined2DCell(ret1->getCoords(),mesh2D,*it,dptr+diptr[*it],dptr+diptr[*it+1],intersectEdge1)); ret1->setCoords(outMesh2DSplit.back()->getCoords()); } - mcIdType offset(ToIdType(ret2->getNumberOfTuples())); + mcIdType offset(ret2->getNumberOfTuples()); ret2->pushBackValsSilent(fewModifiedCells->begin(),fewModifiedCells->end()); MCAuto partOfRet3(DataArrayInt::New()); partOfRet3->alloc(2*idsInRet1Colinear->getNumberOfTuples(),1); partOfRet3->fillWithValue(std::numeric_limits::max()); partOfRet3->rearrange(2); @@ -1906,7 +1906,7 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, MCAuto idsNonColPerCell2(idsInRet1NotColinear->selectByTupleId(idsNonColPerCell->begin(),idsNonColPerCell->end())); MCAuto partOfMesh1CuttingCur2DCell(static_cast(ret1NonCol->buildPartOfMySelf(idsNonColPerCell->begin(),idsNonColPerCell->end()))); MCAuto partOfRet3; - MCAuto splitOfOneCell(BuildMesh2DCutFrom(eps,*it,m1Desc,partOfMesh1CuttingCur2DCell,dd1->begin()+dd2->getIJ(*it,0),dd1->begin()+dd2->getIJ((*it)+1,0),intersectEdge1,ToIdType(ret2->getNumberOfTuples()),partOfRet3)); + MCAuto splitOfOneCell(BuildMesh2DCutFrom(eps,*it,m1Desc,partOfMesh1CuttingCur2DCell,dd1->begin()+dd2->getIJ(*it,0),dd1->begin()+dd2->getIJ((*it)+1,0),intersectEdge1,ret2->getNumberOfTuples(),partOfRet3)); ret3->setPartOfValues3(partOfRet3,idsNonColPerCell2->begin(),idsNonColPerCell2->end(),0,2,1,true); outMesh2DSplit.push_back(splitOfOneCell); for(std::size_t i=0;igetNumberOfCells();i++) @@ -2150,7 +2150,7 @@ DataArrayInt *MEDCouplingUMesh::internalColinearize2D(double eps, bool stayConfo { if(Colinearize2DCell(coords,cptr+ciptr[0],cptr+ciptr[1],nbOfNodes,forbiddenPoints, /*out*/ newc,appendedCoords)) ret->pushBackSilent(i); - newciptr[1]=ToIdType(newc->getNumberOfTuples()); + newciptr[1]=newc->getNumberOfTuples(); } // if(ret->empty()) @@ -2320,7 +2320,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) // Sort faces by decreasing surface: vector< pair > S; - for(mcIdType i=0;i < ToIdType(surfs->getNumberOfTuples());i++) + for(mcIdType i=0;i < surfs->getNumberOfTuples();i++) { pair p = make_pair(surfs->begin()[i], i); S.push_back(p); @@ -2357,14 +2357,14 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) MCAuto mPartCand(mDesc->buildPartOfMySelf(&cands2[0], &cands2[0]+cands2.size(), false)); // false=zipCoords is called double * cooPartRef(mPartRef->_coords->getPointer()); double * cooPartCand(mPartCand->_coords->getPointer()); - for (std::size_t ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++) + for (mcIdType ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++) rotation.transform_vector(cooPartRef+SPACEDIM*ii); - for (std::size_t ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++) + for (mcIdType ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++) rotation.transform_vector(cooPartCand+SPACEDIM*ii); // 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()) @@ -2376,7 +2376,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) MCAuto baryPartXY = baryPart->keepSelectedComponents(compo); mPartRef->changeSpaceDimension(2,0.0); MCAuto cc(DataArrayInt::New()), ccI(DataArrayInt::New()); - mPartRef->getCellsContainingPoints(baryPartXY->begin(), ToIdType(baryPartXY->getNumberOfTuples()), eps, cc, ccI); + mPartRef->getCellsContainingPoints(baryPartXY->begin(), baryPartXY->getNumberOfTuples(), eps, cc, ccI); if (!cc->getNumberOfTuples()) continue; @@ -2487,7 +2487,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) // Sort edges by decreasing length: vector > S; - for(mcIdType i=0;i < ToIdType(lens->getNumberOfTuples());i++) + for(mcIdType i=0;i < lens->getNumberOfTuples();i++) { pair p = make_pair(lens->getIJ(i, 0), i); S.push_back(p); @@ -2541,15 +2541,15 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) MCAuto nodeMapInv = nodeMap->invertArrayO2N2N2O(nbElemsNotM1); double * cooPartRef(mPartRef->_coords->getPointer()); double * cooPartCand(mPartCand->_coords->getPointer()); - for (std::size_t ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++) + for (mcIdType ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++) rotation.transform_vector(cooPartRef+SPACEDIM*ii); - for (std::size_t ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++) + for (mcIdType ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++) rotation.transform_vector(cooPartCand+SPACEDIM*ii); // 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/MEDCouplingVoronoi.cxx b/src/MEDCoupling/MEDCouplingVoronoi.cxx index 37deab6a6..442be5edb 100755 --- a/src/MEDCoupling/MEDCouplingVoronoi.cxx +++ b/src/MEDCoupling/MEDCouplingVoronoi.cxx @@ -126,7 +126,7 @@ MCAuto MergeVorCells2D(MEDCouplingUMesh *p, double eps, bool i MCAuto m(MEDCouplingUMesh::New("",2)); m->setCoords(skinOfRes2->getCoords()); m->allocateCells(); - m->insertNextCell(INTERP_KERNEL::NORM_POLYGON,ToIdType(vdi[0]->getNumberOfTuples()),vdi[0]->begin()); + m->insertNextCell(INTERP_KERNEL::NORM_POLYGON,vdi[0]->getNumberOfTuples(),vdi[0]->begin()); return m; } @@ -223,7 +223,7 @@ MCAuto MergeVorCells3D(const std::vector< MCAutoallocateCells(); std::vector conn; int jj(0); - for(int i=0;igetNumberOfTuples())-1;i++,jj++) + for(mcIdType i=0;igetNumberOfTuples()-1;i++,jj++) { if(jj!=0) conn.push_back(-1); @@ -241,7 +241,7 @@ MCAuto MergeVorCells3D(const std::vector< MCAuto tmp(skinOfRes->buildPartOfMySelf(remain->begin(),remain->end(),true)); const int *cPtr(tmp->getNodalConnectivity()->begin()),*ciPtr(tmp->getNodalConnectivityIndex()->begin()); - for(std::size_t i=0;igetNumberOfTuples();i++,jj++) + for(mcIdType i=0;igetNumberOfTuples();i++,jj++) { if(jj!=0) conn.push_back(-1); @@ -292,7 +292,7 @@ MCAuto MEDCoupling::Voronizer1D::doIt(const MEDCouplingUMesh * throw INTERP_KERNEL::Exception("Voronoize1D : spacedim must be equal to 1 and meshdim also equal to 1 !"); if(m->getNumberOfCells()!=1) throw INTERP_KERNEL::Exception("Voronoize1D : mesh is expected to have only one cell !"); - mcIdType nbPts=ToIdType(points->getNumberOfTuples()); + mcIdType nbPts(points->getNumberOfTuples()); if(nbPts<1) throw INTERP_KERNEL::Exception("Voronoize1D : at least one point expected !"); std::vector bbox(4); @@ -373,7 +373,7 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * throw INTERP_KERNEL::Exception("Voronoize2D : spacedim must be equal to 2 and meshdim also equal to 2 !"); if(m->getNumberOfCells()!=1) throw INTERP_KERNEL::Exception("Voronoize2D : mesh is expected to have only one cell !"); - mcIdType nbPts=ToIdType(points->getNumberOfTuples()); + mcIdType nbPts(points->getNumberOfTuples()); if(nbPts<1) throw INTERP_KERNEL::Exception("Voronoize2D : at least one point expected !"); std::vector bbox(4); @@ -440,7 +440,7 @@ MCAuto MEDCoupling::Voronizer2D::doIt(const MEDCouplingUMesh * newCoords=a->getCoords()->selectByTupleId(tmp->begin(),tmp->end()); } const double *cPtr(newCoords->begin()); - for(std::size_t j=0;jgetNumberOfTuples();j++,cPtr+=2) + for(mcIdType j=0;jgetNumberOfTuples();j++,cPtr+=2) { std::set zeCandidates; { @@ -487,7 +487,7 @@ MCAuto MEDCoupling::Voronizer3D::doIt(const MEDCouplingUMesh * throw INTERP_KERNEL::Exception("Voronoize3D : spacedim must be equal to 3 and meshdim also equal to 3 !"); if(m->getNumberOfCells()!=1) throw INTERP_KERNEL::Exception("Voronoize3D : mesh is expected to have only one cell !"); - mcIdType nbPts=ToIdType(points->getNumberOfTuples()); + mcIdType nbPts(points->getNumberOfTuples()); if(nbPts<1) throw INTERP_KERNEL::Exception("Voronoize3D : at least one point expected !"); std::vector< MCAuto > l0(1,MCAuto(m->deepCopy())); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index cd7ca7559..ea9e88da3 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -636,7 +636,6 @@ void MEDCouplingBasicsTest2::testRenumberCellsForFields() MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); f->setMesh(m); DataArrayDouble *arr=DataArrayDouble::New(); - arr->alloc(m->getNumberOfCells(),3); f->setArray(arr); arr->decrRef(); 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(); } }