X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingStructuredMesh.cxx;h=77fe4ffa2882ec6eacc4a03d2ba01a698ac90a2e;hb=009cf624f2bb7a09c1031af917bb9086fe520853;hp=1b7bd952bd70867716daa95f9dabaf00db98e5bd;hpb=ec0d2fa019c87f670675131f7ae89228664dc8d4;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx old mode 100644 new mode 100755 index 1b7bd952b..77fe4ffa2 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -27,13 +27,13 @@ #include -using namespace ParaMEDMEM; +using namespace MEDCoupling; MEDCouplingStructuredMesh::MEDCouplingStructuredMesh() { } -MEDCouplingStructuredMesh::MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool deepCopy):MEDCouplingMesh(other) +MEDCouplingStructuredMesh::MEDCouplingStructuredMesh(const MEDCouplingStructuredMesh& other, bool deepCpy):MEDCouplingMesh(other) { } @@ -56,7 +56,7 @@ bool MEDCouplingStructuredMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, do return MEDCouplingMesh::isEqualIfNotWhy(other,prec,reason); } -INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::getTypeOfCell(int cellId) const +INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::getTypeOfCell(mcIdType cellId) const { return GetGeoTypeGivenMeshDimension(getMeshDimension()); } @@ -85,19 +85,19 @@ std::set MEDCouplingStructuredMesh::getAllGeo return ret2; } -int MEDCouplingStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const +mcIdType MEDCouplingStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { - int ret=getNumberOfCells(); + mcIdType ret(getNumberOfCells()); if(type==getTypeOfCell(0)) return ret; - const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0))); std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getNumberOfCellsWithType : no specified type ! Type available is " << cm.getRepr() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } -DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const +DataArrayIdType *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayIdType::New(); if(getTypeOfCell(0)==type) { ret->alloc(getNumberOfCells(),1); @@ -108,23 +108,23 @@ DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::Normal return ret.retn(); } -DataArrayInt *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const +DataArrayIdType *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const { - int nbCells=getNumberOfCells(); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + std::size_t nbCells=getNumberOfCells(); + MCAuto ret=DataArrayIdType::New(); ret->alloc(nbCells,1); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); - ret->fillWithValue((int)cm.getNumberOfNodes()); + ret->fillWithValue(ToIdType(cm.getNumberOfNodes())); return ret.retn(); } -DataArrayInt *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const +DataArrayIdType *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const { - int nbCells=getNumberOfCells(); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + std::size_t nbCells=getNumberOfCells(); + MCAuto ret=DataArrayIdType::New(); ret->alloc(nbCells,1); const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); - ret->fillWithValue((int)cm.getNumberOfSons()); + ret->fillWithValue(ToIdType(cm.getNumberOfSons())); return ret.retn(); } @@ -133,20 +133,20 @@ DataArrayInt *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const * will be counted only once here whereas it will be counted several times in MEDCouplingMesh::computeNbOfNodesPerCell method. * Here for structured mesh it returns exactly as MEDCouplingStructuredMesh::computeNbOfNodesPerCell does. * - * \return DataArrayInt * - new object to be deallocated by the caller. + * \return DataArrayIdType * - new object to be deallocated by the caller. */ -DataArrayInt *MEDCouplingStructuredMesh::computeEffectiveNbOfNodesPerCell() const +DataArrayIdType *MEDCouplingStructuredMesh::computeEffectiveNbOfNodesPerCell() const { return computeNbOfNodesPerCell(); } -void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector& conn) const +void MEDCouplingStructuredMesh::getNodeIdsOfCell(mcIdType cellId, std::vector& conn) const { int meshDim=getMeshDimension(); - int tmpCell[3],tmpNode[3]; + mcIdType tmpCell[3],tmpNode[3]; getSplitCellValues(tmpCell); getSplitNodeValues(tmpNode); - int tmp2[3]; + mcIdType tmp2[3]; GetPosFromId(cellId,meshDim,tmpCell,tmp2); switch(meshDim) { @@ -173,9 +173,9 @@ void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector& c */ int MEDCouplingStructuredMesh::getMeshDimension() const { - std::vector ngs(getNodeGridStructure()); + std::vector ngs(getNodeGridStructure()); int ret(0),pos(0); - for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++,pos++) + for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++,pos++) { if(*it<=0) { @@ -195,11 +195,11 @@ int MEDCouplingStructuredMesh::getMeshDimension() const */ int MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct() const { - std::vector nodeStr(getNodeGridStructure()); + std::vector nodeStr(getNodeGridStructure()); int spd1(0),pos(0); - for(std::vector::const_iterator it=nodeStr.begin();it!=nodeStr.end();it++,pos++) + for(std::vector::const_iterator it=nodeStr.begin();it!=nodeStr.end();it++,pos++) { - int elt(*it); + mcIdType elt(*it); if(elt<=0) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct : At pos #" << pos << " value of node grid structure is " << *it << " ! must be >=1 !"; @@ -210,36 +210,36 @@ int MEDCouplingStructuredMesh::getSpaceDimensionOnNodeStruct() const return spd1; } -void MEDCouplingStructuredMesh::getSplitCellValues(int *res) const +void MEDCouplingStructuredMesh::getSplitCellValues(mcIdType *res) const { - std::vector strct(getCellGridStructure()); - std::vector ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct)); + std::vector strct(getCellGridStructure()); + std::vector ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct)); std::copy(ret.begin(),ret.end(),res); } -void MEDCouplingStructuredMesh::getSplitNodeValues(int *res) const +void MEDCouplingStructuredMesh::getSplitNodeValues(mcIdType *res) const { - std::vector strct(getNodeGridStructure()); - std::vector ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct)); + std::vector strct(getNodeGridStructure()); + std::vector ret(MEDCouplingStructuredMesh::GetSplitVectFromStruct(strct)); std::copy(ret.begin(),ret.end(),res); } /*! * This method returns the number of cells of unstructured sub level mesh, without building it. */ -int MEDCouplingStructuredMesh::getNumberOfCellsOfSubLevelMesh() const +mcIdType MEDCouplingStructuredMesh::getNumberOfCellsOfSubLevelMesh() const { - std::vector cgs(getCellGridStructure()); + std::vector cgs(getCellGridStructure()); return GetNumberOfCellsOfSubLevelMesh(cgs,getMeshDimension()); } /*! * See MEDCouplingUMesh::getDistributionOfTypes for more information */ -std::vector MEDCouplingStructuredMesh::getDistributionOfTypes() const +std::vector MEDCouplingStructuredMesh::getDistributionOfTypes() const { //only one type of cell - std::vector ret(3); + std::vector ret(3); ret[0]=getTypeOfCell(0); ret[1]=getNumberOfCells(); ret[2]=-1; //ret[3*k+2]==-1 because it has no sense here @@ -249,15 +249,15 @@ std::vector MEDCouplingStructuredMesh::getDistributionOfTypes() const /*! * This method tries to minimize at most the number of deep copy. * So if \a idsPerType is not empty it can be returned directly (without copy, but with ref count incremented) in return. - * + * * See MEDCouplingUMesh::checkTypeConsistencyAndContig for more information */ -DataArrayInt *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const +DataArrayIdType *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std::vector& code, const std::vector& idsPerType) const { - int nbOfCells=getNumberOfCells(); + mcIdType nbOfCells=getNumberOfCells(); if(code.size()!=3) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : invalid input code should be exactly of size 3 !"); - if(code[0]!=(int)getTypeOfCell(0)) + if(code[0]!=ToIdType(getTypeOfCell(0))) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : Mismatch of geometric type ! Asking for " << code[0] << " whereas the geometric type is \a this is " << getTypeOfCell(0) << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -275,28 +275,28 @@ DataArrayInt *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std if(code[2]!=0) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : single geo type mesh ! 0 or -1 is expected at pos #2 of input code !"); if(idsPerType.size()!=1) - throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : input code points to DataArrayInt #0 whereas the size of idsPerType is not equal to 1 !"); - const DataArrayInt *pfl=idsPerType[0]; + throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : input code points to DataArrayIdType #0 whereas the size of idsPerType is not equal to 1 !"); + const DataArrayIdType *pfl=idsPerType[0]; if(!pfl) - throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : the input code points to a NULL DataArrayInt at rank 0 !"); + throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : the input code points to a NULL DataArrayIdType at rank 0 !"); if(pfl->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::checkTypeConsistencyAndContig : input profile should have exactly one component !"); pfl->checkAllIdsInRange(0,nbOfCells); pfl->incrRef(); - return const_cast(pfl); + return const_cast(pfl); } /*! * This method is the opposite of MEDCouplingUMesh::checkTypeConsistencyAndContig method. Given a list of cells in \a profile it returns a list of sub-profiles sorted by geo type. * The result is put in the array \a idsPerType. In the returned parameter \a code, foreach i \a code[3*i+2] refers (if different from -1) to a location into the \a idsPerType. * This method has 1 input \a profile and 3 outputs \a code \a idsInPflPerType and \a idsPerType. - * + * * \param [out] code is a vector of size 3*n where n is the number of different geometric type in \a this \b reduced to the profile \a profile. \a code has exactly the same semantic than in MEDCouplingUMesh::checkTypeConsistencyAndContig method. * \param [out] idsInPflPerType is a vector of size of different geometric type in the subpart defined by \a profile of \a this ( equal to \a code.size()/3). For each i, * \a idsInPflPerType[i] stores the tuple ids in \a profile that correspond to the geometric type code[3*i+0] * \param [out] idsPerType is a vector of size of different sub profiles needed to be defined to represent the profile \a profile for a given geometric type. * This vector can be empty in case of all geometric type cells are fully covered in ascending in the given input \a profile. - * + * * \warning for performance reasons no deep copy will be performed, if \a profile can been used as this in output parameters \a idsInPflPerType and \a idsPerType. * * \throw if \a profile has not exactly one component. It throws too, if \a profile contains some values not in [0,getNumberOfCells()) or if \a this is not fully defined @@ -304,27 +304,27 @@ DataArrayInt *MEDCouplingStructuredMesh::checkTypeConsistencyAndContig(const std * \b Example1:
* - Before \a this has 3 cells \a profile contains [0,1,2] * - After \a code contains [NORM_...,nbCells,-1], \a idsInPflPerType [[0,1,2]] and \a idsPerType is empty
- * + * * \b Example2:
* - Before \a this has 3 cells \a profile contains [1,2] * - After \a code contains [NORM_...,nbCells,0], \a idsInPflPerType [[0,1]] and \a idsPerType is [[1,2]]
*/ -void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType) const +void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayIdType *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller) const { if(!profile || !profile->isAllocated()) 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 !"); - int nbTuples=profile->getNumberOfTuples(); - int nbOfCells=getNumberOfCells(); + mcIdType nbTuples(profile->getNumberOfTuples()); + mcIdType nbOfCells=getNumberOfCells(); code.resize(3); idsInPflPerType.resize(1); - code[0]=(int)getTypeOfCell(0); code[1]=nbOfCells; + code[0]=ToIdType(getTypeOfCell(0)); code[1]=nbOfCells; idsInPflPerType.resize(1); - if(profile->isIdentity() && nbTuples==nbOfCells) + if(smartPflKiller && profile->isIota(nbOfCells)) { code[2]=-1; - idsInPflPerType[0]=0; + idsInPflPerType[0]=profile->deepCopy(); idsPerType.clear(); return ; } @@ -332,14 +332,18 @@ void MEDCouplingStructuredMesh::splitProfilePerType(const DataArrayInt *profile, code[2]=0; profile->checkAllIdsInRange(0,nbOfCells); idsPerType.resize(1); - idsPerType[0]=profile->deepCpy(); - idsInPflPerType[0]=DataArrayInt::Range(0,nbTuples,1); + idsPerType[0]=profile->deepCopy(); + idsInPflPerType[0]=DataArrayIdType::Range(0,nbTuples,1); } /*! * Creates a new unstructured mesh (MEDCoupling1SGTUMesh) from \a this structured one. + * + * In the returned mesh, the nodes are ordered with the first axis varying first: (X0,Y0), (X1,Y0), ... (X0,Y1), (X1,Y1), ... + * and the cells are ordered with the same logic, i.e. in (i,j) notation: (0,0), (1,0), (2,0), ... (0,1), (1,1), ... + * * \return MEDCouplingUMesh * - a new instance of MEDCouplingUMesh. The caller is to - * delete this array using decrRef() as it is no more needed. + * delete this array using decrRef() as it is no more needed. * \throw If \a this->getMeshDimension() is not among [1,2,3]. */ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const @@ -347,11 +351,11 @@ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const int meshDim(getMeshDimension()),spaceDim(getSpaceDimensionOnNodeStruct()); if((meshDim<0 || meshDim>3) || (spaceDim<0 || spaceDim>3)) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::build1SGTUnstructured : meshdim and spacedim must be in [1,2,3] !"); - MEDCouplingAutoRefCountObjectPtr coords(getCoordinatesAndOwner()); - int ns[3]; + MCAuto coords(getCoordinatesAndOwner()); + mcIdType ns[3]; getNodeGridStructure(ns); - MEDCouplingAutoRefCountObjectPtr conn(Build1GTNodalConnectivity(ns,ns+spaceDim)); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim))); + MCAuto conn(Build1GTNodalConnectivity(ns,ns+spaceDim)); + MCAuto ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim))); ret->setNodalConnectivity(conn); ret->setCoords(coords); try { ret->copyTinyInfoFrom(this); } @@ -362,32 +366,36 @@ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTUnstructured() const /*! * This method returns the unstructured mesh (having single geometric type) of the sub level mesh of \a this. * This method is equivalent to computing MEDCouplingUMesh::buildDescendingConnectivity on the unstructurized \a this mesh. - * - * The caller is to delete the returned mesh using decrRef() as it is no more needed. + * + * The caller is to delete the returned mesh using decrRef() as it is no more needed. */ MEDCoupling1SGTUMesh *MEDCouplingStructuredMesh::build1SGTSubLevelMesh() const { int meshDim(getMeshDimension()); if(meshDim<1 || meshDim>3) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::build1SGTSubLevelMesh : meshdim must be in [2,3] !"); - MEDCouplingAutoRefCountObjectPtr coords(getCoordinatesAndOwner()); - int ns[3]; + MCAuto coords(getCoordinatesAndOwner()); + mcIdType ns[3]; getNodeGridStructure(ns); - MEDCouplingAutoRefCountObjectPtr conn(Build1GTNodalConnectivityOfSubLevelMesh(ns,ns+meshDim)); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim-1))); + MCAuto conn(Build1GTNodalConnectivityOfSubLevelMesh(ns,ns+meshDim)); + MCAuto ret(MEDCoupling1SGTUMesh::New(getName(),GetGeoTypeGivenMeshDimension(meshDim-1))); ret->setNodalConnectivity(conn); ret->setCoords(coords); return ret.retn(); } /*! * Creates a new unstructured mesh (MEDCouplingUMesh) from \a this structured one. + * + * In the returned mesh, the nodes are ordered with the first axis varying first: (X0,Y0), (X1,Y0), ... (X0,Y1), (X1,Y1), ... + * and the cells are ordered with the same logic, i.e. in (i,j) notation: (0,0), (1,0), (2,0), ... (0,1), (1,1), ... + * * \return MEDCouplingUMesh * - a new instance of MEDCouplingUMesh. The caller is to - * delete this array using decrRef() as it is no more needed. + * delete this array using decrRef() as it is no more needed. * \throw If \a this->getMeshDimension() is not among [1,2,3]. */ MEDCouplingUMesh *MEDCouplingStructuredMesh::buildUnstructured() const { - MEDCouplingAutoRefCountObjectPtr ret0(build1SGTUnstructured()); + MCAuto ret0(build1SGTUnstructured()); return ret0->buildUnstructured(); } @@ -399,44 +407,40 @@ MEDCouplingUMesh *MEDCouplingStructuredMesh::buildUnstructured() const * \param [in] end - specifies the end of the array \a start, so that * the last value of \a start is \a end[ -1 ]. * \return MEDCouplingMesh * - a new instance of MEDCouplingUMesh. The caller is to - * delete this mesh using decrRef() as it is no more needed. + * delete this mesh using decrRef() as it is no more needed. */ -MEDCouplingMesh *MEDCouplingStructuredMesh::buildPart(const int *start, const int *end) const +MEDCouplingMesh *MEDCouplingStructuredMesh::buildPart(const mcIdType *start, const mcIdType *end) const { - MEDCouplingUMesh *um=buildUnstructured(); - MEDCouplingMesh *ret=um->buildPart(start,end); - um->decrRef(); - return ret; + MCAuto um(buildUnstructured()); + return um->buildPart(start,end); } -MEDCouplingMesh *MEDCouplingStructuredMesh::buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const +MEDCouplingMesh *MEDCouplingStructuredMesh::buildPartAndReduceNodes(const mcIdType *start, const mcIdType *end, DataArrayIdType*& arr) const { - std::vector cgs(getCellGridStructure()); - std::vector< std::pair > cellPartFormat,nodePartFormat; + std::vector cgs(getCellGridStructure()); + std::vector< std::pair > cellPartFormat,nodePartFormat; if(IsPartStructured(start,end,cgs,cellPartFormat)) { - MEDCouplingAutoRefCountObjectPtr ret(buildStructuredSubPart(cellPartFormat)); + MCAuto ret(buildStructuredSubPart(cellPartFormat)); nodePartFormat=cellPartFormat; - for(std::vector< std::pair >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++) + for(std::vector< std::pair >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++) (*it).second++; - MEDCouplingAutoRefCountObjectPtr tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat)); - MEDCouplingAutoRefCountObjectPtr tmp2(DataArrayInt::New()); tmp2->alloc(getNumberOfNodes(),1); + MCAuto tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat)); + MCAuto tmp2(DataArrayIdType::New()); tmp2->alloc(getNumberOfNodes(),1); tmp2->fillWithValue(-1); - MEDCouplingAutoRefCountObjectPtr tmp3(DataArrayInt::New()); tmp3->alloc(tmp1->getNumberOfTuples(),1); tmp3->iota(0); + MCAuto tmp3(DataArrayIdType::New()); tmp3->alloc(tmp1->getNumberOfTuples(),1); tmp3->iota(0); tmp2->setPartOfValues3(tmp3,tmp1->begin(),tmp1->end(),0,1,1); arr=tmp2.retn(); return ret.retn(); } else { - MEDCouplingUMesh *um=buildUnstructured(); - MEDCouplingMesh *ret=um->buildPartAndReduceNodes(start,end,arr); - um->decrRef(); - return ret; + MCAuto um(buildUnstructured()); + return um->buildPartAndReduceNodes(start,end,arr); } } -DataArrayInt *MEDCouplingStructuredMesh::simplexize(int policy) +DataArrayIdType *MEDCouplingStructuredMesh::simplexize(int policy) { throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::simplexize : not available for Cartesian mesh !"); } @@ -453,22 +457,21 @@ MEDCouplingFieldDouble *MEDCouplingStructuredMesh::buildOrthogonalField() const { if(getMeshDimension()!=2) throw INTERP_KERNEL::Exception("Expected a MEDCouplingStructuredMesh with meshDim == 2 !"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); - DataArrayDouble *array=DataArrayDouble::New(); - int nbOfCells=getNumberOfCells(); + MCAuto ret(MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME)); + MCAuto array(DataArrayDouble::New()); + mcIdType nbOfCells=getNumberOfCells(); array->alloc(nbOfCells,3); - double *vals=array->getPointer(); - for(int i=0;igetPointer()); + for(mcIdType i=0;isetArray(array); - array->decrRef(); ret->setMesh(this); - return ret; + return ret.retn(); } -void MEDCouplingStructuredMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const +void MEDCouplingStructuredMesh::getReverseNodalConnectivity(DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) const { - std::vector ngs(getNodeGridStructure()); + std::vector ngs(getNodeGridStructure()); int dim(getSpaceDimension()); switch(dim) { @@ -483,18 +486,18 @@ void MEDCouplingStructuredMesh::getReverseNodalConnectivity(DataArrayInt *revNod } } -void MEDCouplingStructuredMesh::GetReverseNodalConnectivity1(const std::vector& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx) +void MEDCouplingStructuredMesh::GetReverseNodalConnectivity1(const std::vector& ngs, DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) { - int nbNodes(ngs[0]); + mcIdType nbNodes(ngs[0]); revNodalIndx->alloc(nbNodes+1,1); if(nbNodes==0) { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } if(nbNodes==1) { revNodal->alloc(1,1); revNodal->setIJ(0,0,0); revNodalIndx->setIJ(0,0,0); revNodalIndx->setIJ(1,0,1); return ; } revNodal->alloc(2*(nbNodes-1),1); - int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); + mcIdType *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); *rni++=0; *rni=1; *rn++=0; - for(int i=1;i& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx) +void MEDCouplingStructuredMesh::GetReverseNodalConnectivity2(const std::vector& ngs, DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) { - int nbNodesX(ngs[0]),nbNodesY(ngs[1]); - int nbNodes(nbNodesX*nbNodesY); + mcIdType nbNodesX(ngs[0]),nbNodesY(ngs[1]); + mcIdType nbNodes(nbNodesX*nbNodesY); if(nbNodesX==0 || nbNodesY==0) { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } if(nbNodesX==1 || nbNodesY==1) - { std::vector ngs2(1); ngs2[0]=std::max(nbNodesX,nbNodesY); return GetReverseNodalConnectivity1(ngs2,revNodal,revNodalIndx); } + { std::vector ngs2(1); ngs2[0]=std::max(nbNodesX,nbNodesY); return GetReverseNodalConnectivity1(ngs2,revNodal,revNodalIndx); } revNodalIndx->alloc(nbNodes+1,1); - int nbCellsX(nbNodesX-1),nbCellsY(nbNodesY-1); + mcIdType nbCellsX(nbNodesX-1),nbCellsY(nbNodesY-1); revNodal->alloc(4*(nbNodesX-2)*(nbNodesY-2)+2*2*(nbNodesX-2)+2*2*(nbNodesY-2)+4,1); - int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); + mcIdType *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); *rni++=0; *rni=1; *rn++=0; - for(int i=1;i& ngs, DataArrayInt *revNodal, DataArrayInt *revNodalIndx) +void MEDCouplingStructuredMesh::GetReverseNodalConnectivity3(const std::vector& ngs, DataArrayIdType *revNodal, DataArrayIdType *revNodalIndx) { - int nbNodesX(ngs[0]),nbNodesY(ngs[1]),nbNodesZ(ngs[2]); - int nbNodes(nbNodesX*nbNodesY*nbNodesZ); + mcIdType nbNodesX(ngs[0]),nbNodesY(ngs[1]),nbNodesZ(ngs[2]); + mcIdType nbNodes(nbNodesX*nbNodesY*nbNodesZ); if(nbNodesX==0 || nbNodesY==0 || nbNodesZ==0) { revNodal->alloc(0,1); revNodalIndx->setIJ(0,0,0); return ; } if(nbNodesX==1 || nbNodesY==1 || nbNodesZ==1) { - std::vector ngs2(2); - int pos(0); + std::vector ngs2(2); + mcIdType pos(0); bool pass(false); for(int i=0;i<3;i++) { @@ -572,21 +575,21 @@ void MEDCouplingStructuredMesh::GetReverseNodalConnectivity3(const std::vectoralloc(nbNodes+1,1); - int nbCellsX(nbNodesX-1),nbCellsY(nbNodesY-1),nbCellsZ(nbNodesZ-1); + mcIdType nbCellsX(nbNodesX-1),nbCellsY(nbNodesY-1),nbCellsZ(nbNodesZ-1); revNodal->alloc(8*(nbNodesX-2)*(nbNodesY-2)*(nbNodesZ-2)+4*(2*(nbNodesX-2)*(nbNodesY-2)+2*(nbNodesX-2)*(nbNodesZ-2)+2*(nbNodesY-2)*(nbNodesZ-2))+2*4*(nbNodesX-2)+2*4*(nbNodesY-2)+2*4*(nbNodesZ-2)+8,1); - int *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); + mcIdType *rn(revNodal->getPointer()),*rni(revNodalIndx->getPointer()); *rni=0; - for(int k=0;k=1 && j>=1 && i>=1) *rn++=off00+i-1; if(k>=1 && j>=1 && i conn(DataArrayInt::New()); + MCAuto conn(DataArrayIdType::New()); conn->alloc(1,1); conn->setIJ(0,0,0); return conn.retn(); } @@ -647,7 +650,7 @@ DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity(const int *no } } -DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh(const int *nodeStBg, const int *nodeStEnd) +DataArrayIdType *MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh(const mcIdType *nodeStBg, const mcIdType *nodeStEnd) { std::size_t dim(std::distance(nodeStBg,nodeStEnd)); switch(dim) @@ -663,46 +666,46 @@ DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivityOfSubLevelMesh /*! * This method returns the list of ids sorted ascendingly of entities that are in the corner in ghost zone. - * The ids are returned in a newly created DataArrayInt having a single component. + * The ids are returned in a newly created DataArrayIdType having a single component. * * \param [in] st - The structure \b without ghost cells. * \param [in] ghostLev - The size of the ghost zone (>=0) - * \return DataArrayInt * - The DataArray containing all the ids the caller is to deallocate. + * \return DataArrayIdType * - The DataArray containing all the ids the caller is to deallocate. */ -DataArrayInt *MEDCouplingStructuredMesh::ComputeCornersGhost(const std::vector& st, int ghostLev) +DataArrayIdType *MEDCouplingStructuredMesh::ComputeCornersGhost(const std::vector& st, mcIdType ghostLev) { if(ghostLev<0) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ComputeCornersGhost : ghost lev must be >= 0 !"); std::size_t dim(st.size()); - MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); + MCAuto ret(DataArrayIdType::New()); switch(dim) { case 1: { ret->alloc(2*ghostLev,1); - int *ptr(ret->getPointer()); - for(int i=0;igetPointer()); + for(mcIdType i=0;i= 0 !"); - for(int i=0;i= 0 !"); ret->alloc(4*ghostLev,1); - int *ptr(ret->getPointer()); - for(int i=0;igetPointer()); + for(mcIdType i=0;i= 0 !"); ret->alloc(8*ghostLev,1); - int *ptr(ret->getPointer()); - int zeOffsetZ((offsetX+2*ghostLev)*(offsetY+2*ghostLev)); - for(int i=0;igetPointer()); + mcIdType zeOffsetZ((offsetX+2*ghostLev)*(offsetY+2*ghostLev)); + for(mcIdType i=0;i=0;i--,j++) + mcIdType j(0),zeOffsetZ2(zeOffsetZ*(offsetZ+ghostLev)); + for(mcIdType i=ghostLev-1;i>=0;i--,j++) { *ptr++=i*(2*ghostLev+offsetX+1)+j*zeOffsetZ+zeOffsetZ2; *ptr++=offsetX+2*ghostLev-1+i*(2*ghostLev+offsetX-1)+j*zeOffsetZ+zeOffsetZ2; @@ -746,13 +749,13 @@ DataArrayInt *MEDCouplingStructuredMesh::ComputeCornersGhost(const std::vector >& partCompactFormat) +mcIdType MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(const std::vector< std::pair >& partCompactFormat) { - int ret(1); + mcIdType ret(1); std::size_t ii(0); - for(std::vector< std::pair >::const_iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,ii++) + for(std::vector< std::pair >::const_iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,ii++) { - int a((*it).first),b((*it).second); + mcIdType a((*it).first),b((*it).second); if(a<0 || b<0 || b-a<0) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt : invalid input at dimension " << ii << " !"; @@ -763,9 +766,9 @@ int MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt(const std:: return ret; } -int MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(const std::vector& st) +mcIdType MEDCouplingStructuredMesh::DeduceNumberOfGivenStructure(const std::vector& st) { - int ret(1); + mcIdType ret(1); bool isFetched(false); for(std::size_t i=0;i >& partCompactFormat, int& axisId, int& sizeOfRange) +void MEDCouplingStructuredMesh::FindTheWidestAxisOfGivenRangeInCompactFrmt(const std::vector< std::pair >& partCompactFormat, int& axisId, mcIdType& sizeOfRange) { - int dim((int)partCompactFormat.size()); - int ret(-1); + mcIdType dim(ToIdType(partCompactFormat.size())); + mcIdType ret(-1); for(int i=0;i& st, const std::vector& crit, std::vector& reducedCrit, std::vector< std::pair >& partCompactFormat) +mcIdType MEDCouplingStructuredMesh::FindMinimalPartOf(mcIdType minPatchLgth, const std::vector& st, const std::vector& crit, std::vector& reducedCrit, std::vector< std::pair >& partCompactFormat) { if(minPatchLgth<0) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::FindMinimalPartOf : the input minPatchLgth has to be >=0 !"); - if((int)crit.size()!=DeduceNumberOfGivenStructure(st)) + if(ToIdType(crit.size())!=DeduceNumberOfGivenStructure(st)) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::FindMinimalPartOf : size of vector of boolean is invalid regarding the declared structure !"); - int ret(-1); - switch((int)st.size()) + mcIdType ret(-1); + switch(st.size()) { case 1: { @@ -838,13 +841,13 @@ int MEDCouplingStructuredMesh::FindMinimalPartOf(int minPatchLgth, const std::ve default: throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::FindMinimalPartOf : only dimension 1, 2 and 3 are supported actually !"); } - std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(partCompactFormat)); - int i(0); - for(std::vector< std::pair >::iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,i++) + std::vector dims(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(partCompactFormat)); + mcIdType i(0); + for(std::vector< std::pair >::iterator it=partCompactFormat.begin();it!=partCompactFormat.end();it++,i++) { if(st[i] > MEDCouplingStructuredMesh::ComputeSignaturePerAxisOf(const std::vector& st, const std::vector& crit) +std::vector< std::vector > MEDCouplingStructuredMesh::ComputeSignaturePerAxisOf(const std::vector& st, const std::vector& crit) { - int dim((int)st.size()); - std::vector< std::vector > ret(dim); + std::size_t dim(st.size()); + std::vector< std::vector > ret(dim); switch(dim) { case 1: { - int nx(st[0]); + mcIdType nx(st[0]); ret[0].resize(nx); - std::vector& retX(ret[0]); - for(int i=0;i& retX(ret[0]); + for(mcIdType i=0;i& retX(ret[0]); - for(int i=0;i& retX(ret[0]); + for(mcIdType i=0;i& retY(ret[1]); - for(int j=0;j& retY(ret[1]); + for(mcIdType j=0;j > MEDCouplingStructuredMesh::ComputeSignaturePerAx } case 3: { - int nx(st[0]),ny(st[1]),nz(st[2]); + mcIdType nx(st[0]),ny(st[1]),nz(st[2]); ret[0].resize(nx); ret[1].resize(ny); ret[2].resize(nz); - std::vector& retX(ret[0]); - for(int i=0;i& retX(ret[0]); + for(mcIdType i=0;i& retY(ret[1]); - for(int j=0;j& retY(ret[1]); + for(mcIdType j=0;j& retZ(ret[2]); - for(int k=0;k& retZ(ret[2]); + for(mcIdType k=0;k > MEDCouplingStructuredMesh::ComputeSignaturePerAx return ret; } -DataArrayInt *MEDCouplingStructuredMesh::Build1GTNodalConnectivity1D(const int *nodeStBg) +DataArrayIdType *MEDCouplingStructuredMesh::Build1GTNodalConnectivity1D(const mcIdType *nodeStBg) { - int nbOfCells(*nodeStBg-1); - MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); + mcIdType nbOfCells=*nodeStBg-1; + MCAuto conn(DataArrayIdType::New()); conn->alloc(2*nbOfCells,1); - int *cp=conn->getPointer(); - for(int i=0;igetPointer(); + for(mcIdType i=0;i conn(DataArrayInt::New()); + mcIdType n1(nodeStBg[0]-1),n2(nodeStBg[1]-1); + MCAuto conn(DataArrayIdType::New()); conn->alloc(4*n1*n2,1); - int *cp=conn->getPointer(); - int pos=0; - for(int j=0;jgetPointer()); + std::size_t pos(0); + for(mcIdType j=0;j conn(DataArrayInt::New()); + mcIdType n1(nodeStBg[0]-1),n2(nodeStBg[1]-1),n3(nodeStBg[2]-1); + MCAuto conn(DataArrayIdType::New()); conn->alloc(8*n1*n2*n3,1); - int *cp=conn->getPointer(); - int pos=0; - for(int k=0;kgetPointer()); + std::size_t pos(0); + for(mcIdType k=0;k ngs(3); - int n0(nodeStBg[0]-1),n1(nodeStBg[1]-1),n2(nodeStBg[2]-1); ngs[0]=n0; ngs[1]=n1; ngs[2]=n2; - int off0(nodeStBg[0]),off1(nodeStBg[0]*nodeStBg[1]); - MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); + std::vector ngs(3); + mcIdType n0(nodeStBg[0]-1),n1(nodeStBg[1]-1),n2(nodeStBg[2]-1); ngs[0]=n0; ngs[1]=n1; ngs[2]=n2; + mcIdType off0(nodeStBg[0]),off1(nodeStBg[0]*nodeStBg[1]); + MCAuto conn(DataArrayIdType::New()); conn->alloc(4*GetNumberOfCellsOfSubLevelMesh(ngs,3)); - int *cp(conn->getPointer()); + mcIdType *cp(conn->getPointer()); //X - for(int i=0;i& st, const std::vector& crit, std::vector< std::pair >& partCompactFormat) +mcIdType MEDCouplingStructuredMesh::FindMinimalPartOf1D(const std::vector& st, const std::vector& crit, std::vector< std::pair >& partCompactFormat) { if(st.size()!=1) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::FindMinimalPartOf1D : the input size of st must be equal to 1 !"); - int nxMin(std::numeric_limits::max()),nxMax(-std::numeric_limits::max()); - int nx(st[0]),ret(0); - for(int i=0;i::max()),nxMax(-std::numeric_limits::max()); + mcIdType nx(st[0]),ret(0); + for(mcIdType i=0;i& st, c /*! * \sa MEDCouplingStructuredMesh::FindMinimalPartOf */ -int MEDCouplingStructuredMesh::FindMinimalPartOf2D(const std::vector& st, const std::vector& crit, std::vector< std::pair >& partCompactFormat) +mcIdType MEDCouplingStructuredMesh::FindMinimalPartOf2D(const std::vector& st, const std::vector& crit, std::vector< std::pair >& partCompactFormat) { if(st.size()!=2) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::FindMinimalPartOf2D : the input size of st must be equal to 2 !"); - int nxMin(std::numeric_limits::max()),nxMax(-std::numeric_limits::max()),nyMin(std::numeric_limits::max()),nyMax(-std::numeric_limits::max()); - int it(0),nx(st[0]),ny(st[1]); - int ret(0); - for(int i=0;i::max()),nxMax(-std::numeric_limits::max()),nyMin(std::numeric_limits::max()),nyMax(-std::numeric_limits::max()); + mcIdType it(0),nx(st[0]),ny(st[1]); + mcIdType ret(0); + for(mcIdType i=0;i& st, c /*! * \sa MEDCouplingStructuredMesh::FindMinimalPartOf */ -int MEDCouplingStructuredMesh::FindMinimalPartOf3D(const std::vector& st, const std::vector& crit, std::vector< std::pair >& partCompactFormat) +mcIdType MEDCouplingStructuredMesh::FindMinimalPartOf3D(const std::vector& st, const std::vector& crit, std::vector< std::pair >& partCompactFormat) { if(st.size()!=3) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::FindMinimalPartOf3D : the input size of st must be equal to 3 !"); - int nxMin(std::numeric_limits::max()),nxMax(-std::numeric_limits::max()),nyMin(std::numeric_limits::max()),nyMax(-std::numeric_limits::max()),nzMin(std::numeric_limits::max()),nzMax(-std::numeric_limits::max()); - int it(0),nx(st[0]),ny(st[1]),nz(st[2]); - int ret(0); - for(int i=0;i::max()),nxMax(-std::numeric_limits::max()),nyMin(std::numeric_limits::max()),nyMax(-std::numeric_limits::max()),nzMin(std::numeric_limits::max()),nzMax(-std::numeric_limits::max()); + mcIdType it(0),nx(st[0]),ny(st[1]),nz(st[2]); + mcIdType ret(0); + for(mcIdType i=0;i& st, c * std::distance( \a nodeStBg, \a nodeStEnd ) is equal to the space dimension. The returned value is equal to * the meshDimension (or the zipped spaceDimension). * - * \param [out] zipNodeSt - The zipped node strucutre - * \return int - the + * \param [out] zipNodeSt - The zipped node structure + * \return mcIdType - the */ -int MEDCouplingStructuredMesh::ZipNodeStructure(const int *nodeStBg, const int *nodeStEnd, int zipNodeSt[3]) +int MEDCouplingStructuredMesh::ZipNodeStructure(const mcIdType *nodeStBg, const mcIdType *nodeStEnd, mcIdType zipNodeSt[3]) { - int spaceDim((int)std::distance(nodeStBg,nodeStEnd)); + std::size_t spaceDim(std::distance(nodeStBg,nodeStEnd)); if(spaceDim>3 || spaceDim<1) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ZipNodeStructure : spaceDim must in [1,2,3] !"); zipNodeSt[0]=0; zipNodeSt[1]=0; zipNodeSt[2]=0; int zippedI(0); - for(int i=0;i ngs(2); - int n0(nodeStBg[0]-1),n1(nodeStBg[1]-1); ngs[0]=n0; ngs[1]=n1; - int off0(nodeStBg[0]); - MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); + std::vector ngs(2); + mcIdType n0(nodeStBg[0]-1),n1(nodeStBg[1]-1); ngs[0]=n0; ngs[1]=n1; + mcIdType off0(nodeStBg[0]); + MCAuto conn(DataArrayIdType::New()); conn->alloc(2*GetNumberOfCellsOfSubLevelMesh(ngs,2)); - int *cp(conn->getPointer()); + mcIdType *cp(conn->getPointer()); //X - for(int i=0;i()); + std::transform(tmp,tmp+meshDim,tmp2,tmp,std::multiplies()); return std::accumulate(tmp,tmp+meshDim,0); } @@ -1226,28 +1226,28 @@ int MEDCouplingStructuredMesh::getCellIdFromPos(int i, int j, int k) const * \param [in] i - a index of node coordinates array along X axis. * \param [in] j - a index of node coordinates array along Y axis. * \param [in] k - a index of node coordinates array along Z axis. - * \return int - a node id in \a this mesh. + * \return mcIdType - a node id in \a this mesh. */ -int MEDCouplingStructuredMesh::getNodeIdFromPos(int i, int j, int k) const +mcIdType MEDCouplingStructuredMesh::getNodeIdFromPos(mcIdType i, mcIdType j, mcIdType k) const { - int tmp[3]={i,j,k}; - int tmp2[3]; - int spaceDim(getSpaceDimension()); + mcIdType tmp[3]={i,j,k}; + mcIdType tmp2[3]; + mcIdType spaceDim(getSpaceDimension()); getSplitNodeValues(tmp2); - std::transform(tmp,tmp+spaceDim,tmp2,tmp,std::multiplies()); + std::transform(tmp,tmp+spaceDim,tmp2,tmp,std::multiplies()); return std::accumulate(tmp,tmp+spaceDim,0); } -int MEDCouplingStructuredMesh::getNumberOfCells() const +mcIdType MEDCouplingStructuredMesh::getNumberOfCells() const { - std::vector ngs(getNodeGridStructure()); - int ret(1); + std::vector ngs(getNodeGridStructure()); + mcIdType ret(1); bool isCatched(false); std::size_t ii(0); - for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++,ii++) + for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++,ii++) { - int elt(*it); + mcIdType elt(*it); if(elt<=0) { std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getNumberOfCells : at pos #" << ii << " the number of nodes in nodeStructure is " << *it << " ! Must be > 0 !"; @@ -1262,30 +1262,76 @@ int MEDCouplingStructuredMesh::getNumberOfCells() const return isCatched?ret:0; } -int MEDCouplingStructuredMesh::getNumberOfNodes() const +mcIdType MEDCouplingStructuredMesh::getNumberOfNodes() const { - std::vector ngs(getNodeGridStructure()); - int ret(1); - for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++) + std::vector ngs(getNodeGridStructure()); + mcIdType ret(1); + for(std::vector::const_iterator it=ngs.begin();it!=ngs.end();it++) ret*=*it; return ret; } -void MEDCouplingStructuredMesh::GetPosFromId(int nodeId, int meshDim, const int *split, int *res) +/*! + * This method returns for a cell which id is \a cellId the location (locX,locY,locZ) of this cell in \a this. + * + * \param [in] cellId ID of the cell + * \return - A vector of size this->getMeshDimension() + * \throw if \a cellId not in [ 0, this->getNumberOfCells() ) + */ +std::vector MEDCouplingStructuredMesh::getLocationFromCellId(mcIdType cellId) const +{ + int meshDim(getMeshDimension()); + std::vector ret(meshDim); + std::vector struc(getCellGridStructure()); + mcIdType nbCells(std::accumulate(struc.begin(),struc.end(),1,std::multiplies())); + if(cellId<0 || cellId>=nbCells) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getLocationFromCellId : Input cell id (" << cellId << ") is invalid ! Should be in [0," << nbCells << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + std::vector spt(GetSplitVectFromStruct(struc)); + GetPosFromId(cellId,meshDim,&spt[0],&ret[0]); + return ret; +} + +/*! + * This method returns for a node which id is \a nodeId the location (locX,locY,locZ) of this node in \a this. + * + * \param [in] nodeId ID of the node + * \return - A vector of size this->getSpaceDimension() + * \throw if \a cellId not in [ 0, this->getNumberOfNodes() ) + */ +std::vector MEDCouplingStructuredMesh::getLocationFromNodeId(mcIdType nodeId) const +{ + int spaceDim(getSpaceDimension()); + std::vector ret(spaceDim); + std::vector struc(getNodeGridStructure()); + mcIdType nbNodes(std::accumulate(struc.begin(),struc.end(),1,std::multiplies())); + if(nodeId<0 || nodeId>=nbNodes) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getLocationFromNodeId : Input node id (" << nodeId << ") is invalid ! Should be in [0," << nbNodes << ") !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + std::vector spt(GetSplitVectFromStruct(struc)); + GetPosFromId(nodeId,spaceDim,&spt[0],&ret[0]); + return ret; +} + +void MEDCouplingStructuredMesh::GetPosFromId(mcIdType eltId, int meshDim, const mcIdType *split, mcIdType *res) { - int work=nodeId; + mcIdType work(eltId); for(int i=meshDim-1;i>=0;i--) { - int pos=work/split[i]; + mcIdType pos=work/split[i]; work=work%split[i]; res[i]=pos; } } -std::vector MEDCouplingStructuredMesh::getCellGridStructure() const +std::vector MEDCouplingStructuredMesh::getCellGridStructure() const { - std::vector ret(getNodeGridStructure()); - std::transform(ret.begin(),ret.end(),ret.begin(),std::bind2nd(std::plus(),-1)); + std::vector ret(getNodeGridStructure()); + std::transform(ret.begin(),ret.end(),ret.begin(),std::bind(std::plus(),std::placeholders::_1,-1)); return ret; } @@ -1294,7 +1340,7 @@ std::vector MEDCouplingStructuredMesh::getCellGridStructure() const */ double MEDCouplingStructuredMesh::computeSquareness() const { - std::vector cgs(getCellGridStructure()); + std::vector cgs(getCellGridStructure()); if(cgs.empty()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::computeSquareness : empty mesh !"); std::size_t dim(cgs.size()); @@ -1302,7 +1348,7 @@ double MEDCouplingStructuredMesh::computeSquareness() const throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::computeSquareness : A segment cannot be square !"); if(dim<4) { - int minAx(cgs[0]),maxAx(cgs[0]); + mcIdType minAx(cgs[0]),maxAx(cgs[0]); for(std::size_t i=1;i MEDCouplingStructuredMesh::GetSplitVectFromStruct(const std::vector& strct) +std::vector MEDCouplingStructuredMesh::GetSplitVectFromStruct(const std::vector& strct) { - int spaceDim((int)strct.size()); - std::vector res(spaceDim); - for(int l=0;l res(spaceDim); + for(std::size_t l=0;l MEDCouplingStructuredMesh::GetSplitVectFromStruct(const std::ve * * \sa MEDCouplingStructuredMesh::BuildExplicitIdsFrom, MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt */ -bool MEDCouplingStructuredMesh::IsPartStructured(const int *startIds, const int *stopIds, const std::vector& st, std::vector< std::pair >& partCompactFormat) +bool MEDCouplingStructuredMesh::IsPartStructured(const mcIdType *startIds, const mcIdType *stopIds, const std::vector& st, std::vector< std::pair >& partCompactFormat) { int dim((int)st.size()); partCompactFormat.resize(dim); if(dim<1 || dim>3) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::isPartStructured : input structure must be of dimension in [1,2,3] !"); - std::vector tmp2(dim),tmp(dim),tmp3(dim),tmp4(dim); tmp2[0]=1; + std::vector tmp2(dim),tmp(dim),tmp3(dim),tmp4(dim); tmp2[0]=1; for(int i=1;i=st[i]) @@ -1373,20 +1419,20 @@ bool MEDCouplingStructuredMesh::IsPartStructured(const int *startIds, const int return false; szExp*=tmp4[i]; } - if(szExp!=(int)sz) + if(szExp!=ToIdType(sz)) return false; - const int *w(startIds); + const mcIdType *w(startIds); switch(dim) { case 3: { - for(int i=0;i MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(const std::vector< std::pair >& partCompactFormat) +std::vector MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(const std::vector< std::pair >& partCompactFormat) { - std::vector ret(partCompactFormat.size()); + std::vector ret(partCompactFormat.size()); for(std::size_t i=0;ipartCompactFormat[i].second) @@ -1450,10 +1496,10 @@ std::vector MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(const s * \throw if there is an axis in \a dims that is < 0. * \sa GetDimensionsFromCompactFrmt, ChangeReferenceFromGlobalOfCompactFrmt, ChangeReferenceToGlobalOfCompactFrmt */ -std::vector< std::pair > MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(const std::vector& dims) +std::vector< std::pair > MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(const std::vector& dims) { std::size_t sz(dims.size()); - std::vector< std::pair > ret(sz); + std::vector< std::pair > ret(sz); for(std::size_t i=0;i > MEDCouplingStructuredMesh::GetCompactFrmtFromD * * \sa AreRangesIntersect */ -std::vector< std::pair > MEDCouplingStructuredMesh::IntersectRanges(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) +std::vector< std::pair > MEDCouplingStructuredMesh::IntersectRanges(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) { std::size_t sz(r1.size()); if(sz!=r2.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::IntersectRanges : the two ranges must have the same dimension !"); - std::vector< std::pair > ret(sz); + std::vector< std::pair > ret(sz); for(std::size_t i=0;ir1[i].second) @@ -1507,7 +1553,7 @@ std::vector< std::pair > MEDCouplingStructuredMesh::IntersectRanges(con * * \sa IntersectRanges */ -bool MEDCouplingStructuredMesh::AreRangesIntersect(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) +bool MEDCouplingStructuredMesh::AreRangesIntersect(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) { std::size_t sz(r1.size()); if(sz!=r2.size()) @@ -1533,7 +1579,7 @@ bool MEDCouplingStructuredMesh::AreRangesIntersect(const std::vector< std::pair< } /*! - * This method is close to BuildExplicitIdsFrom except that instead of returning a DataArrayInt instance containing explicit ids it + * This method is close to BuildExplicitIdsFrom except that instead of returning a DataArrayIdType instance containing explicit ids it * enable elems in the vector of booleans (for performance reasons). As it is method for performance, this method is \b not * available in python. * @@ -1543,24 +1589,24 @@ bool MEDCouplingStructuredMesh::AreRangesIntersect(const std::vector< std::pair< * * \sa MEDCouplingStructuredMesh::BuildExplicitIdsFrom, ExtractFieldOfBoolFrom */ -void MEDCouplingStructuredMesh::SwitchOnIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat, std::vector& vectToSwitchOn) +void MEDCouplingStructuredMesh::SwitchOnIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat, std::vector& vectToSwitchOn) { if(st.size()!=partCompactFormat.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::SwitchOnIdsFrom : input arrays must have the same size !"); - if((int)vectToSwitchOn.size()!=DeduceNumberOfGivenStructure(st)) + if(ToIdType(vectToSwitchOn.size())!=DeduceNumberOfGivenStructure(st)) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::SwitchOnIdsFrom : invalid size of input vector of boolean regarding the structure !"); - std::vector dims(GetDimensionsFromCompactFrmt(partCompactFormat)); + std::vector dims(GetDimensionsFromCompactFrmt(partCompactFormat)); switch(st.size()) { case 3: { - for(int i=0;i& st, cons } case 2: { - for(int j=0;j& st, cons * * \sa MEDCouplingStructuredMesh::BuildExplicitIdsFrom, SwitchOnIdsFrom, ExtractFieldOfDoubleFrom */ -void MEDCouplingStructuredMesh::ExtractFieldOfBoolFrom(const std::vector& st, const std::vector& fieldOfBool, const std::vector< std::pair >& partCompactFormat, std::vector& fieldOut) +void MEDCouplingStructuredMesh::ExtractFieldOfBoolFrom(const std::vector& st, const std::vector& fieldOfBool, const std::vector< std::pair >& partCompactFormat, std::vector& fieldOut) { if(st.size()!=partCompactFormat.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfBoolFrom : input arrays must have the same size !"); - if((int)fieldOfBool.size()!=DeduceNumberOfGivenStructure(st)) + if(ToIdType(fieldOfBool.size())!=DeduceNumberOfGivenStructure(st)) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfBoolFrom : invalid size of input field of boolean regarding the structure !"); - std::vector dims(GetDimensionsFromCompactFrmt(partCompactFormat)); - int nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)); + std::vector dims(GetDimensionsFromCompactFrmt(partCompactFormat)); + mcIdType nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)); fieldOut.resize(nbOfTuplesOfOutField); - int it(0); + mcIdType it(0); switch(st.size()) { case 3: { - for(int i=0;i& s } case 2: { - for(int j=0;j& s * * \sa MEDCouplingStructuredMesh::BuildExplicitIdsFrom, SwitchOnIdsFrom, ExtractFieldOfBoolFrom */ -DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std::vector& st, const DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat) +DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std::vector& st, const DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat) { if(!fieldOfDbl || !fieldOfDbl->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom : input array of double is NULL or not allocated!"); @@ -1665,9 +1711,10 @@ DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std:: throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom : input arrays must have the same size !"); 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(fieldOfDbl->getNumberOfComponents()); - MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); ret->alloc(nbOfTuplesOfOutField,nbComp); + std::vector dims(GetDimensionsFromCompactFrmt(partCompactFormat)); + mcIdType nbOfTuplesOfOutField(DeduceNumberOfGivenStructure(dims)); + std::size_t nbComp(fieldOfDbl->getNumberOfComponents()); + MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfTuplesOfOutField,nbComp); ret->copyStringInfoFrom(*fieldOfDbl); double *ptRet(ret->getPointer()); const double *fieldOfDblPtr(fieldOfDbl->begin()); @@ -1675,13 +1722,13 @@ DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std:: { case 3: { - for(int i=0;i& st, DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat, const DataArrayDouble *other) +void MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(const std::vector& st, DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat, const DataArrayDouble *other) {//to be optimized - std::vector facts(st.size(),1.); + std::vector facts(st.size(),1); MEDCouplingIMesh::CondenseFineToCoarse(st,other,partCompactFormat,facts,fieldOfDbl); } @@ -1731,7 +1778,7 @@ void MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(const std::vector * * \sa ChangeReferenceToGlobalOfCompactFrmt, BuildExplicitIdsFrom, SwitchOnIdsFrom, ExtractFieldOfBoolFrom, ExtractFieldOfDoubleFrom */ -void MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(const std::vector< std::pair >& bigInAbs, const std::vector< std::pair >& partOfBigInAbs, std::vector< std::pair >& partOfBigRelativeToBig, bool check) +void MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(const std::vector< std::pair >& bigInAbs, const std::vector< std::pair >& partOfBigInAbs, std::vector< std::pair >& partOfBigRelativeToBig, bool check) { std::size_t dim(bigInAbs.size()); if(dim!=partOfBigInAbs.size()) @@ -1770,7 +1817,7 @@ void MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(const std * * \sa ChangeReferenceFromGlobalOfCompactFrmt */ -void MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(const std::vector< std::pair >& bigInAbs, const std::vector< std::pair >& partOfBigRelativeToBig, std::vector< std::pair >& partOfBigInAbs, bool check) +void MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(const std::vector< std::pair >& bigInAbs, const std::vector< std::pair >& partOfBigRelativeToBig, std::vector< std::pair >& partOfBigInAbs, bool check) { std::size_t dim(bigInAbs.size()); if(dim!=partOfBigRelativeToBig.size()) @@ -1809,12 +1856,12 @@ void MEDCouplingStructuredMesh::ChangeReferenceToGlobalOfCompactFrmt(const std:: * * \sa FindTranslationFrom */ -std::vector< std::pair > MEDCouplingStructuredMesh::TranslateCompactFrmt(const std::vector< std::pair >& part, const std::vector& translation) +std::vector< std::pair > MEDCouplingStructuredMesh::TranslateCompactFrmt(const std::vector< std::pair >& part, const std::vector& translation) { std::size_t sz(part.size()); if(translation.size()!=sz) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::TranslateCompactFrmt : the sizes are not equal !"); - std::vector< std::pair > ret(sz); + std::vector< std::pair > ret(sz); for(std::size_t i=0;i > MEDCouplingStructuredMesh::TranslateCompactFrm /*! * \sa TranslateCompactFrmt */ -std::vector MEDCouplingStructuredMesh::FindTranslationFrom(const std::vector< std::pair >& startingFrom, const std::vector< std::pair >& goingTo) +std::vector MEDCouplingStructuredMesh::FindTranslationFrom(const std::vector< std::pair >& startingFrom, const std::vector< std::pair >& goingTo) { std::size_t sz(startingFrom.size()); if(goingTo.size()!=sz) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::FindTranslationFrom : the sizes are not equal !"); - std::vector< int > ret(sz); + std::vector< mcIdType > ret(sz); for(std::size_t i=0;i MEDCouplingStructuredMesh::FindTranslationFrom(const std::vecto /*! * This method builds the explicit entity array from the structure in \a st and the range in \a partCompactFormat. - * If the range contains invalid values regarding sructure an exception will be thrown. + * If the range contains invalid values regarding structure an exception will be thrown. * - * \return DataArrayInt * - a new object. + * \return DataArrayIdType * - a new object. * \sa MEDCouplingStructuredMesh::IsPartStructured, MEDCouplingStructuredMesh::DeduceNumberOfGivenRangeInCompactFrmt, SwitchOnIdsFrom, ExtractFieldOfBoolFrom, ExtractFieldOfDoubleFrom, MultiplyPartOf */ -DataArrayInt *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat) +DataArrayIdType *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat) { if(st.size()!=partCompactFormat.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::BuildExplicitIdsFrom : input arrays must have the same size !"); - int nbOfItems(1); - std::vector dims(st.size()); + mcIdType nbOfItems(1); + std::vector dims(st.size()); for(std::size_t i=0;ist[i]) @@ -1863,20 +1910,20 @@ DataArrayInt *MEDCouplingStructuredMesh::BuildExplicitIdsFrom(const std::vector< dims[i]=partCompactFormat[i].second-partCompactFormat[i].first; nbOfItems*=dims[i]; } - MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); + MCAuto ret(DataArrayIdType::New()); ret->alloc(nbOfItems,1); - int *pt(ret->getPointer()); + mcIdType *pt(ret->getPointer()); switch(st.size()) { case 3: { - for(int i=0;i& st, const std::vector< std::pair >& part, double factor, DataArrayDouble *da) +void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, const std::vector< std::pair >& part, double factor, DataArrayDouble *da) { if(!da || !da->isAllocated()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::MultiplyPartOf : DataArrayDouble instance must be not NULL and allocated !"); if(st.size()!=part.size()) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::MultiplyPartOf : input arrays must have the same size !"); - std::vector dims(st.size()); + std::vector dims(st.size()); for(std::size_t i=0;ist[i]) @@ -1931,7 +1978,8 @@ 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(da->getNumberOfComponents()); + mcIdType 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() << " !"; @@ -1942,16 +1990,16 @@ void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, const { case 3: { - for(int i=0;i(),factor)); + mcIdType offset(part[0].first+k+b+a); + std::transform(pt+nbCompo*offset,pt+nbCompo*(offset+1),pt+nbCompo*offset,std::bind(std::multiplies(),std::placeholders::_1,factor)); } } } @@ -1959,23 +2007,23 @@ void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, const } case 2: { - for(int j=0;j(),factor)); + mcIdType offset(part[0].first+k+b); + std::transform(pt+nbCompo*offset,pt+nbCompo*(offset+1),pt+nbCompo*offset,std::bind(std::multiplies(),std::placeholders::_1,factor)); } } break; } case 1: { - for(int k=0;k(),factor)); + mcIdType offset(part[0].first+k); + std::transform(pt+nbCompo*offset,pt+nbCompo*(offset+1),pt+nbCompo*offset,std::bind(std::multiplies(),std::placeholders::_1,factor)); } break; } @@ -1991,14 +2039,14 @@ void MEDCouplingStructuredMesh::MultiplyPartOf(const std::vector& st, const * \param [in] part - the part in the structure ( \b without considering ghost cells) contained in grid whose structure is defined by \a st. * \param [in] ghostSize - \a ghostSize must be >= 0. * \param [in] factor - the factor, the tuples in \a da will be multiply by. - * \param [in,out] da - The DataArray in wich only tuples specified by \a part will be modified. + * \param [in,out] da - The DataArray in which only tuples specified by \a part will be modified. * * \sa MultiplyPartOf, PutInGhostFormat */ -void MEDCouplingStructuredMesh::MultiplyPartOfByGhost(const std::vector& st, const std::vector< std::pair >& part, int ghostSize, double factor, DataArrayDouble *da) +void MEDCouplingStructuredMesh::MultiplyPartOfByGhost(const std::vector& st, const std::vector< std::pair >& part, mcIdType ghostSize, double factor, DataArrayDouble *da) { - std::vector stWG; - std::vector< std::pair > partWG; + std::vector stWG; + std::vector< std::pair > partWG; PutInGhostFormat(ghostSize,st,part,stWG,partWG); MultiplyPartOf(stWG,partWG,factor,da); } @@ -2014,7 +2062,7 @@ void MEDCouplingStructuredMesh::MultiplyPartOfByGhost(const std::vector& st * * \sa MultiplyPartOf, PutInGhostFormat */ -void MEDCouplingStructuredMesh::PutInGhostFormat(int ghostSize, const std::vector& st, const std::vector< std::pair >& part, std::vector& stWithGhost, std::vector< std::pair >&partWithGhost) +void MEDCouplingStructuredMesh::PutInGhostFormat(mcIdType ghostSize, const std::vector& st, const std::vector< std::pair >& part, std::vector& stWithGhost, std::vector< std::pair >&partWithGhost) { if(ghostSize<0) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::PutInGhostFormat : ghost size must be >= 0 !"); @@ -2025,7 +2073,7 @@ void MEDCouplingStructuredMesh::PutInGhostFormat(int ghostSize, const std::vecto if(part[i].first<0 || part[i].first>part[i].second || part[i].second>st[i]) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::PutInGhostFormat : the specified part is invalid ! The begin must be >= 0 and <= end ! The end must be <= to the size at considered dimension !"); stWithGhost.resize(st.size()); - std::transform(st.begin(),st.end(),stWithGhost.begin(),std::bind2nd(std::plus(),2*ghostSize)); + std::transform(st.begin(),st.end(),stWithGhost.begin(),std::bind(std::plus(),std::placeholders::_1,2*ghostSize)); partWithGhost=part; ApplyGhostOnCompactFrmt(partWithGhost,ghostSize); } @@ -2034,7 +2082,7 @@ void MEDCouplingStructuredMesh::PutInGhostFormat(int ghostSize, const std::vecto * \param [in,out] partBeforeFact - the part of a image mesh in compact format that will be put in ghost reference. * \param [in] ghostSize - the ghost size of zone for all axis. */ -void MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(std::vector< std::pair >& partBeforeFact, int ghostSize) +void MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(std::vector< std::pair >& partBeforeFact, mcIdType ghostSize) { if(ghostSize<0) throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt : ghost size must be >= 0 !"); @@ -2046,12 +2094,12 @@ void MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(std::vector< std::pair& cgs, int mdim) +mcIdType MEDCouplingStructuredMesh::GetNumberOfCellsOfSubLevelMesh(const std::vector& cgs, int mdim) { - int ret(0); + mcIdType ret(0); for(int i=0;i