From 8de05faeebdd2a851021362e57d87fc1e8792c0a Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 7 Feb 2017 13:57:43 +0100 Subject: [PATCH] FieldDouble::convertQuadraticToLinear --- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 45 +++ src/MEDCoupling/MEDCouplingFieldDouble.hxx | 1 + src/MEDCoupling/MEDCouplingUMesh.cxx | 348 +++++++++--------- .../MEDCouplingBasicsTest5.py | 56 +++ src/MEDCoupling_Swig/MEDCouplingCommon.i | 7 + 5 files changed, 282 insertions(+), 175 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 4a1d54ba2..e5b4a4711 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -2224,6 +2224,51 @@ MCAuto MEDCouplingFieldDouble::voronoize(double eps) con return voronoizeGen(vor,eps); } +/*! + * \sa MEDCouplingUMesh::convertQuadraticCellsToLinear + */ +MCAuto MEDCouplingFieldDouble::convertQuadraticCellsToLinear() const +{ + checkConsistencyLight(); + switch(getTypeOfField()) + { + case ON_NODES: + { + const MEDCouplingMesh *mesh(getMesh()); + if(!mesh) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::convertQuadraticCellsToLinear : null mesh !"); + MCAuto umesh(mesh->buildUnstructured()); + umesh=umesh->clone(false); + umesh->convertQuadraticCellsToLinear(); + MCAuto o2n(umesh->zipCoordsTraducer()); + MCAuto n2o(o2n->invertArrayO2N2N2O(umesh->getNumberOfNodes())); + MCAuto arr(getArray()->selectByTupleIdSafe(n2o->begin(),n2o->end())); + MCAuto ret(MEDCouplingFieldDouble::New(ON_NODES)); + ret->setArray(arr); + ret->setMesh(umesh); + ret->copyAllTinyAttrFrom(this); + return ret; + } + case ON_CELLS: + { + const MEDCouplingMesh *mesh(getMesh()); + if(!mesh) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::convertQuadraticCellsToLinear : null mesh !"); + MCAuto umesh(mesh->buildUnstructured()); + umesh=umesh->clone(false); + umesh->convertQuadraticCellsToLinear(); + umesh->zipCoords(); + MCAuto ret(MEDCouplingFieldDouble::New(ON_CELLS)); + ret->setArray(const_cast(getArray())); + ret->setMesh(umesh); + ret->copyAllTinyAttrFrom(this); + return ret; + } + default: + throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::convertQuadraticCellsToLinear : Only available for fields on nodes !"); + } +} + /*! * This is expected to be a 3 components vector field on nodes (if not an exception will be thrown). \a this is also expected to lie on a MEDCouplingPointSet mesh. * Finaly \a this is also expected to be consistent. diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 05602afff..d096f9864 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -116,6 +116,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT MEDCouplingFieldDouble *extractSlice3D(const double *origin, const double *vec, double eps) const; MEDCOUPLING_EXPORT bool simplexize(int policy); MEDCOUPLING_EXPORT MCAuto voronoize(double eps) const; + MEDCOUPLING_EXPORT MCAuto convertQuadraticCellsToLinear() const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *computeVectorFieldCyl(const double center[3], const double vect[3]) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *doublyContractedProduct() const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *determinant() const; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 809c39496..40318b00b 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -5216,9 +5216,9 @@ bool MEDCouplingUMesh::isPresenceOfQuadratic() const void MEDCouplingUMesh::convertQuadraticCellsToLinear() { checkFullyDefined(); - int nbOfCells=getNumberOfCells(); + int nbOfCells(getNumberOfCells()); int delta=0; - const int *iciptr=_nodal_connec_index->getConstPointer(); + const int *iciptr=_nodal_connec_index->begin(); for(int i=0;i newConn=DataArrayInt::New(); - MCAuto newConnI=DataArrayInt::New(); - const int *icptr=_nodal_connec->getConstPointer(); + MCAuto newConn(DataArrayInt::New()),newConnI(DataArrayInt::New()); + const int *icptr(_nodal_connec->begin()); newConn->alloc(getNodalConnectivityArrayLen()-delta,1); newConnI->alloc(nbOfCells+1,1); - int *ocptr=newConn->getPointer(); - int *ociptr=newConnI->getPointer(); + int *ocptr(newConn->getPointer()),*ociptr(newConnI->getPointer()); *ociptr=0; _types.clear(); for(int i=0;i ret=DataArrayInt::New(); ret->alloc(0,1); int nbOfCells=getNumberOfCells(); int nbOfNodes=getNumberOfNodes(); - const int *cPtr=_nodal_connec->getConstPointer(); - const int *icPtr=_nodal_connec_index->getConstPointer(); + const int *cPtr=_nodal_connec->begin(); + const int *icPtr=_nodal_connec_index->begin(); int lastVal=0,offset=nbOfNodes; for(int i=0;ibegin(); const int *c1DIPtr=conn1DI->begin(); int nbOfCells=getNumberOfCells(); - const int *cPtr=_nodal_connec->getConstPointer(); - const int *icPtr=_nodal_connec_index->getConstPointer(); + const int *cPtr=_nodal_connec->begin(); + const int *icPtr=_nodal_connec_index->begin(); int lastVal=0; for(int i=0;ibegin(); const int *c1DIPtr=conn1DI->begin(); int nbOfCells=getNumberOfCells(); - const int *cPtr=_nodal_connec->getConstPointer(); - const int *icPtr=_nodal_connec_index->getConstPointer(); + const int *cPtr=_nodal_connec->begin(); + const int *icPtr=_nodal_connec_index->begin(); int lastVal=0,offset=coordsTmpSafe->getNumberOfTuples(); for(int i=0;i conn2DSafe(conn2D),conn2DISafe(conn2DI); const int *c1DPtr=conn1D->begin(),*c1DIPtr=conn1DI->begin(),*c2DPtr=conn2D->begin(),*c2DIPtr=conn2DI->begin(); int nbOfCells=getNumberOfCells(); - const int *cPtr=_nodal_connec->getConstPointer(); - const int *icPtr=_nodal_connec_index->getConstPointer(); + const int *cPtr=_nodal_connec->begin(); + const int *icPtr=_nodal_connec_index->begin(); int lastVal=0,offset=coordsTmpSafe->getNumberOfTuples(); for(int i=0;i3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::areOnlySimplexCells : only available with meshes having a meshdim 1, 2 or 3 !"); int nbCells=getNumberOfCells(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); for(int i=0;igetPointer(); int *ptI=newConnI->getPointer(); ptI[0]=0; - const int *oldc=_nodal_connec->getConstPointer(); - const int *ci=_nodal_connec_index->getConstPointer(); + const int *oldc=_nodal_connec->begin(); + const int *ci=_nodal_connec_index->begin(); for(int i=0;igetPointer(); int *ptI=newConnI->getPointer(); ptI[0]=0; - const int *oldc=_nodal_connec->getConstPointer(); - const int *ci=_nodal_connec_index->getConstPointer(); + const int *oldc=_nodal_connec->begin(); + const int *ci=_nodal_connec_index->begin(); for(int i=0;igetPointer(); int *ptI=newConnI->getPointer(); ptI[0]=0; - const int *oldc=_nodal_connec->getConstPointer(); - const int *ci=_nodal_connec_index->getConstPointer(); + const int *oldc=_nodal_connec->begin(); + const int *ci=_nodal_connec_index->begin(); for(int i=0;igetPointer(); int *ptI=newConnI->getPointer(); ptI[0]=0; - const int *oldc=_nodal_connec->getConstPointer(); - const int *ci=_nodal_connec_index->getConstPointer(); + const int *oldc=_nodal_connec->begin(); + const int *ci=_nodal_connec_index->begin(); for(int i=0;i mDesc(buildDescendingConnectivity2(desc1,descIndx1,revDesc1,revDescIndx1)); revDesc1=0; revDescIndx1=0; mDesc->tessellate2D(eps); - subDivide2DMesh(mDesc->_nodal_connec->getConstPointer(),mDesc->_nodal_connec_index->getConstPointer(),desc1->getConstPointer(),descIndx1->getConstPointer()); + subDivide2DMesh(mDesc->_nodal_connec->begin(),mDesc->_nodal_connec_index->begin(),desc1->begin(),descIndx1->begin()); setCoords(mDesc->getCoords()); } @@ -6003,9 +6001,9 @@ void MEDCouplingUMesh::tessellate2DCurveInternal(double eps) INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=1.e-10; int nbCells=getNumberOfCells(); int nbNodes=getNumberOfNodes(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coords=_coords->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); + const double *coords=_coords->begin(); std::vector addCoo; std::vector newConn;//no direct DataArrayInt because interface with Geometric2D MCAuto newConnI(DataArrayInt::New()); @@ -6209,9 +6207,9 @@ void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool po if(getMeshDimension()!=2 || getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("Invalid mesh to apply are2DCellsNotCorrectlyOriented on it : must be meshDim==2 and spaceDim==3 !"); int nbOfCells=getNumberOfCells(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); + const double *coordsPtr=_coords->begin(); for(int i=0;igetPointer()); - const int *connI(_nodal_connec_index->getConstPointer()); - const double *coordsPtr(_coords->getConstPointer()); + const int *connI(_nodal_connec_index->begin()); + const double *coordsPtr(_coords->begin()); bool isModified(false); for(int i=0;igetPointer()); - const int *connI(_nodal_connec_index->getConstPointer()); + const int *connI(_nodal_connec_index->begin()); if(mdim==2) {//2D for(int i=0;i& cell if(getMeshDimension()!=3 || getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("Invalid mesh to apply arePolyhedronsNotCorrectlyOriented on it : must be meshDim==3 and spaceDim==3 !"); int nbOfCells=getNumberOfCells(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); + const double *coordsPtr=_coords->begin(); for(int i=0;igetPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); + const int *connI=_nodal_connec_index->begin(); + const double *coordsPtr=_coords->begin(); for(int i=0;igetPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=getCoords()->getConstPointer(); + const int *connI=_nodal_connec_index->begin(); + const double *coo=getCoords()->begin(); MCAuto cells(DataArrayInt::New()); cells->alloc(0,1); for(int i=0;igetPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); + const int *connI=_nodal_connec_index->begin(); + const double *coordsPtr=_coords->begin(); MCAuto ret=DataArrayInt::New(); ret->alloc(0,1); for(int i=0;igetConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coordsPtr=_coords->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); + const double *coordsPtr=_coords->begin(); INTERP_KERNEL::areaVectorOfPolygon(conn+1,connI[1]-connI[0]-1,coordsPtr,vec); std::copy(coordsPtr+3*conn[1],coordsPtr+3*conn[1]+3,pos); } @@ -6551,9 +6549,9 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=_coords->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); + const double *coo=_coords->begin(); double tmp[12]; for(int i=0;ialloc(nbOfCells,1); double *pt=arr->getPointer(); ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=_coords->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); + const double *coo=_coords->begin(); double tmp[12]; for(int i=0;ialloc(nbOfCells,1); double *pt=arr->getPointer(); ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=_coords->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); + const double *coo=_coords->begin(); double tmp[12]; for(int i=0;ialloc(nbOfCells,1); double *pt=arr->getPointer(); ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const double *coo=_coords->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); + const double *coo=_coords->begin(); double tmp[12]; for(int i=0;i::max(); bbox[2*i+1]=-std::numeric_limits::max(); } - const double *coordsPtr(_coords->getConstPointer()); - const int *conn(_nodal_connec->getConstPointer()),*connI(_nodal_connec_index->getConstPointer()); + const double *coordsPtr(_coords->begin()); + const int *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin()); for(int i=0;i ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); double *bbox(ret->getPointer()); - const double *coords(_coords->getConstPointer()); - const int *conn(_nodal_connec->getConstPointer()),*connI(_nodal_connec_index->getConstPointer()); + const double *coords(_coords->begin()); + const int *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin()); for(int i=0;i ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); double *bbox(ret->getPointer()); - const double *coords(_coords->getConstPointer()); - const int *conn(_nodal_connec->getConstPointer()),*connI(_nodal_connec_index->getConstPointer()); + const double *coords(_coords->begin()); + const int *conn(_nodal_connec->begin()),*connI(_nodal_connec_index->begin()); for(int i=0;i MEDCouplingUMesh::getDistributionOfTypes() const { checkConnectivityFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); const int *work=connI; int nbOfCells=getNumberOfCells(); std::size_t n=getAllGeoTypes().size(); @@ -7109,8 +7107,8 @@ DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector< MCAuto ret=DataArrayInt::New(); ret->alloc(nb,1); int *retPtr=ret->getPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); - const int *conn=_nodal_connec->getConstPointer(); + const int *connI=_nodal_connec_index->begin(); + const int *conn=_nodal_connec->begin(); int nbOfCells=getNumberOfCells(); const int *i=connI; int kk=0; @@ -7185,8 +7183,8 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec if(profile->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : input profile should have exactly one component !"); checkConnectivityFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); int nbOfCells=getNumberOfCells(); std::vector types; std::vector typeRangeVals(1); @@ -7219,7 +7217,7 @@ void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vec idsInPflPerType2.push_back(tmp3); code[3*i]=(int)types[castId]; code[3*i+1]=tmp3->getNumberOfTuples(); - MCAuto tmp4=rankInsideCast->selectByTupleId(tmp3->getConstPointer(),tmp3->getConstPointer()+tmp3->getNumberOfTuples()); + MCAuto tmp4=rankInsideCast->selectByTupleId(tmp3->begin(),tmp3->begin()+tmp3->getNumberOfTuples()); if(!tmp4->isIota(typeRangeVals[castId+1]-typeRangeVals[castId])) { tmp4->copyStringInfoFrom(*profile); @@ -7267,10 +7265,10 @@ MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1 MCAuto tmp1=DataArrayInt::New(); MCAuto ret1=buildDescendingConnectivity(desc,descIndx,tmp0,tmp1); MCAuto ret0=ret1->sortCellsInMEDFileFrmt(); - desc->transformWithIndArr(ret0->getConstPointer(),ret0->getConstPointer()+ret0->getNbOfElems()); + desc->transformWithIndArr(ret0->begin(),ret0->begin()+ret0->getNbOfElems()); MCAuto tmp=MEDCouplingUMesh::New(); tmp->setConnectivity(tmp0,tmp1); - tmp->renumberCells(ret0->getConstPointer(),false); + tmp->renumberCells(ret0->begin(),false); revDesc=tmp->getNodalConnectivity(); revDescIndx=tmp->getNodalConnectivityIndex(); DataArrayInt *ret=0; @@ -7304,7 +7302,7 @@ DataArrayInt *MEDCouplingUMesh::sortCellsInMEDFileFrmt() { checkConnectivityFullyDefined(); MCAuto ret=getRenumArrForMEDFileFrmt(); - renumberCells(ret->getConstPointer(),false); + renumberCells(ret->begin(),false); return ret.retn(); } @@ -7315,8 +7313,8 @@ DataArrayInt *MEDCouplingUMesh::sortCellsInMEDFileFrmt() bool MEDCouplingUMesh::checkConsecutiveCellTypes() const { checkFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); int nbOfCells=getNumberOfCells(); std::set types; for(const int *i=connI;i!=connI+nbOfCells;) @@ -7350,8 +7348,8 @@ bool MEDCouplingUMesh::checkConsecutiveCellTypesForMEDFileFrmt() const bool MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const { checkFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); int nbOfCells=getNumberOfCells(); if(nbOfCells==0) return true; @@ -7392,8 +7390,8 @@ DataArrayInt *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::Norma { checkConnectivityFullyDefined(); int nbOfCells=getNumberOfCells(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); MCAuto tmpa=DataArrayInt::New(); MCAuto tmpb=DataArrayInt::New(); tmpa->alloc(nbOfCells,1); @@ -7460,8 +7458,8 @@ DataArrayInt *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes() { checkFullyDefined(); computeTypes(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); int nbOfCells=getNumberOfCells(); std::vector types; for(const int *i=connI;i!=connI+nbOfCells && (types.size()!=_types.size());) @@ -7494,8 +7492,8 @@ DataArrayInt *MEDCouplingUMesh::rearrange2ConsecutiveCellTypes() std::vector MEDCouplingUMesh::splitByType() const { checkConnectivityFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); int nbOfCells=getNumberOfCells(); std::vector ret; for(const int *i=connI;i!=connI+nbOfCells;) @@ -7686,8 +7684,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(cons for(std::size_t i=0;igetIJ(i,0)]=m1ssm[i]; MCAuto ret0=MEDCouplingUMesh::MergeUMeshesOnSameCoords(m1ssmfinal); - szOfCellGrpOfSameType=ret1->renumber(renum->getConstPointer()); - idInMsOfCellGrpOfSameType=ret2->renumber(renum->getConstPointer()); + szOfCellGrpOfSameType=ret1->renumber(renum->begin()); + idInMsOfCellGrpOfSameType=ret2->renumber(renum->begin()); return ret0.retn(); } @@ -7698,8 +7696,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(cons DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const { checkFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connIndex=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connIndex=_nodal_connec_index->begin(); MCAuto ret(DataArrayInt::New()); ret->alloc(0,1); for(const int *w=begin;w!=end;w++) if((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]==type) @@ -7714,8 +7712,8 @@ DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellT DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *da) const { checkFullyDefined(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const int *conn=_nodal_connec->begin(); + const int *connI=_nodal_connec_index->begin(); int nbOfCells=getNumberOfCells(); std::set types(getAllGeoTypes()); int *tmp=new int[nbOfCells]; @@ -7730,7 +7728,7 @@ DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *d ret->alloc(da->getNumberOfTuples(),da->getNumberOfComponents()); ret->copyStringInfoFrom(*da); int *retPtr=ret->getPointer(); - const int *daPtr=da->getConstPointer(); + const int *daPtr=da->begin(); int nbOfElems=da->getNbOfElems(); for(int k=0;k MEDCouplingUMesh::getQuadraticStatus() const { int ncell=getNumberOfCells(); std::vector ret(ncell); - const int *cI=getNodalConnectivityIndex()->getConstPointer(); - const int *c=getNodalConnectivity()->getConstPointer(); + const int *cI=getNodalConnectivityIndex()->begin(); + const int *c=getNodalConnectivity()->begin(); for(int i=0;ialloc(nbOfCells,spaceDim); ret->copyStringInfoFrom(*getCoords()); double *ptToFill=ret->getPointer(); - const int *nodal=_nodal_connec->getConstPointer(); - const int *nodalI=_nodal_connec_index->getConstPointer(); - const double *coor=_coords->getConstPointer(); + const int *nodal=_nodal_connec->begin(); + const int *nodalI=_nodal_connec_index->begin(); + const double *coor=_coords->begin(); for(int i=0;ialloc(nbOfCells,spaceDim); double *ptToFill=ret->getPointer(); - const int *nodal=_nodal_connec->getConstPointer(); - const int *nodalI=_nodal_connec_index->getConstPointer(); - const double *coor=_coords->getConstPointer(); + const int *nodal=_nodal_connec->begin(); + const int *nodalI=_nodal_connec_index->begin(); + const double *coor=_coords->begin(); for(int i=0;ialloc(nbOfTuple,spaceDim); double *ptToFill=ret->getPointer(); double *tmp=new double[spaceDim]; - const int *nodal=_nodal_connec->getConstPointer(); - const int *nodalI=_nodal_connec_index->getConstPointer(); - const double *coor=_coords->getConstPointer(); + const int *nodal=_nodal_connec->begin(); + const int *nodalI=_nodal_connec_index->begin(); + const double *coor=_coords->begin(); for(const int *w=begin;w!=end;w++) { INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[*w]]; @@ -8134,8 +8132,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(const std::vectorgetNumberOfCells(); - const int *curCI=(*it)->_nodal_connec_index->getConstPointer(); - const int *curC=(*it)->_nodal_connec->getConstPointer(); + const int *curCI=(*it)->_nodal_connec_index->begin(); + const int *curC=(*it)->_nodal_connec->begin(); cIPtr=std::transform(curCI+1,curCI+curNbOfCell+1,cIPtr,std::bind2nd(std::plus(),offset)); for(int j=0;jgetNodalConnectivity()->getConstPointer(); - const int *index=(*iter)->getNodalConnectivityIndex()->getConstPointer(); + const int *nod=(*iter)->getNodalConnectivity()->begin(); + const int *index=(*iter)->getNodalConnectivityIndex()->begin(); int nbOfCells=(*iter)->getNumberOfCells(); int meshLgth2=(*iter)->getNodalConnectivityArrayLen(); nodalPtr=std::copy(nod,nod+meshLgth2,nodalPtr); @@ -8280,7 +8278,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vectorgetConstPointer(); + const int *o2nPtr=o2n->begin(); for(std::size_t i=0;i o2n=DataArrayInt::ConvertIndexArrayToO2N(oldNbOfNodes,comm->begin(),commI->begin(),commI->end(),newNbOfNodes); if(oldNbOfNodes==newNbOfNodes) return ; - MCAuto newCoords=coo->renumberAndReduce(o2n->getConstPointer(),newNbOfNodes); + MCAuto newCoords=coo->renumberAndReduce(o2n->begin(),newNbOfNodes); for(std::vector::const_iterator it=meshes.begin();it!=meshes.end();it++) { - (*it)->renumberNodesInConn(o2n->getConstPointer()); + (*it)->renumberNodesInConn(o2n->begin()); (*it)->setCoords(newCoords); } } @@ -8626,15 +8624,15 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble for(int i=0;igetConstPointer(),stFaceConn,endFaceConn,vPtr,pPtr); + ComputeVecAndPtOfFace(eps,coords->begin(),stFaceConn,endFaceConn,vPtr,pPtr); stFaceConn=endFaceConn+1; } pPtr=p->getPointer(); vPtr=v->getPointer(); DataArrayInt *comm1=0,*commI1=0; v->findCommonTuples(eps,-1,comm1,commI1); MCAuto comm1Auto(comm1),commI1Auto(commI1); - const int *comm1Ptr=comm1->getConstPointer(); - const int *commI1Ptr=commI1->getConstPointer(); + const int *comm1Ptr=comm1->begin(); + const int *commI1Ptr=commI1->begin(); int nbOfGrps1=commI1Auto->getNumberOfTuples()-1; res->pushBackSilent((int)INTERP_KERNEL::NORM_POLYHED); // @@ -8649,8 +8647,8 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble DataArrayInt *comm2=0,*commI2=0; tmpgrp2->findCommonTuples(eps,-1,comm2,commI2); MCAuto comm2Auto(comm2),commI2Auto(commI2); - const int *comm2Ptr=comm2->getConstPointer(); - const int *commI2Ptr=commI2->getConstPointer(); + const int *comm2Ptr=comm2->begin(); + const int *commI2Ptr=commI2->begin(); int nbOfGrps2=commI2Auto->getNumberOfTuples()-1; for(int j=0;j mm3=static_cast(mm2->buildPartOfMySelf(ids2->begin(),ids2->end(),true)); MCAuto idsNodeTmp=mm3->zipCoordsTraducer(); MCAuto idsNode=idsNodeTmp->invertArrayO2N2N2O(mm3->getNumberOfNodes()); - const int *idsNodePtr=idsNode->getConstPointer(); + const int *idsNodePtr=idsNode->begin(); double center[3]; center[0]=pPtr[pointId]*vPtr[3*vecId]; center[1]=pPtr[pointId]*vPtr[3*vecId+1]; center[2]=pPtr[pointId]*vPtr[3*vecId+2]; double vec[3]; vec[0]=vPtr[3*vecId+1]; vec[1]=-vPtr[3*vecId]; vec[2]=0.; double norm=vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2]; @@ -8680,8 +8678,8 @@ void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble } mm3->changeSpaceDimension(2); MCAuto mm4=mm3->buildSpreadZonesWithPoly(); - const int *conn4=mm4->getNodalConnectivity()->getConstPointer(); - const int *connI4=mm4->getNodalConnectivityIndex()->getConstPointer(); + const int *conn4=mm4->getNodalConnectivity()->begin(); + const int *connI4=mm4->getNodalConnectivityIndex()->begin(); int nbOfCells=mm4->getNumberOfCells(); for(int k=0;kgetNumberOfNodes()); - const int *n2oPtr(n2o->getConstPointer()); + const int *n2oPtr(n2o->begin()); MCAuto revNodal(DataArrayInt::New()),revNodalI(DataArrayInt::New()); skin->getReverseNodalConnectivity(revNodal,revNodalI); - const int *revNodalPtr(revNodal->getConstPointer()),*revNodalIPtr(revNodalI->getConstPointer()); - const int *nodalPtr(skin->getNodalConnectivity()->getConstPointer()); - const int *nodalIPtr(skin->getNodalConnectivityIndex()->getConstPointer()); + const int *revNodalPtr(revNodal->begin()),*revNodalIPtr(revNodalI->begin()); + const int *nodalPtr(skin->getNodalConnectivity()->begin()); + const int *nodalIPtr(skin->getNodalConnectivityIndex()->begin()); MCAuto ret(DataArrayInt::New()); ret->alloc(nbOfNodesExpected+1,1); int *work(ret->getPointer()); *work++=INTERP_KERNEL::NORM_POLYGON; if(nbOfNodesExpected<1) @@ -8872,12 +8870,12 @@ DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMeshQuadratic(const MEDCouplingUMe { int nbOfNodesExpected(skin->getNumberOfNodes()); int nbOfTurn(nbOfNodesExpected/2); - const int *n2oPtr(n2o->getConstPointer()); + const int *n2oPtr(n2o->begin()); MCAuto revNodal(DataArrayInt::New()),revNodalI(DataArrayInt::New()); skin->getReverseNodalConnectivity(revNodal,revNodalI); - const int *revNodalPtr(revNodal->getConstPointer()),*revNodalIPtr(revNodalI->getConstPointer()); - const int *nodalPtr(skin->getNodalConnectivity()->getConstPointer()); - const int *nodalIPtr(skin->getNodalConnectivityIndex()->getConstPointer()); + const int *revNodalPtr(revNodal->begin()),*revNodalIPtr(revNodalI->begin()); + const int *nodalPtr(skin->getNodalConnectivity()->begin()); + const int *nodalIPtr(skin->getNodalConnectivityIndex()->begin()); MCAuto ret(DataArrayInt::New()); ret->alloc(nbOfNodesExpected+1,1); int *work(ret->getPointer()); *work++=INTERP_KERNEL::NORM_QPOLYG; if(nbOfNodesExpected<1) @@ -8951,8 +8949,8 @@ DataArrayInt *MEDCouplingUMesh::buildUnionOf3DMesh() const if(getMeshDimension()!=3 || getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf3DMesh : meshdimension, spacedimension must be equal to 2 !"); MCAuto m=computeSkin(); - const int *conn=m->getNodalConnectivity()->getConstPointer(); - const int *connI=m->getNodalConnectivityIndex()->getConstPointer(); + const int *conn=m->getNodalConnectivity()->begin(); + const int *connI=m->getNodalConnectivityIndex()->begin(); int nbOfCells=m->getNumberOfCells(); MCAuto ret=DataArrayInt::New(); ret->alloc(m->getNodalConnectivity()->getNumberOfTuples(),1); int *work=ret->getPointer(); *work++=INTERP_KERNEL::NORM_POLYHED; @@ -8985,16 +8983,16 @@ MEDCouplingSkyLineArray *MEDCouplingUMesh::generateGraph() const MEDCoupling::DataArrayInt* indexr=MEDCoupling::DataArrayInt::New(); MEDCoupling::DataArrayInt* revConn=MEDCoupling::DataArrayInt::New(); this->getReverseNodalConnectivity(revConn,indexr); - const int* indexr_ptr=indexr->getConstPointer(); - const int* revConn_ptr=revConn->getConstPointer(); + const int* indexr_ptr=indexr->begin(); + const int* revConn_ptr=revConn->begin(); const MEDCoupling::DataArrayInt* index; const MEDCoupling::DataArrayInt* conn; conn=this->getNodalConnectivity(); // it includes a type as the 1st element!!! index=this->getNodalConnectivityIndex(); int nbCells=this->getNumberOfCells(); - const int* index_ptr=index->getConstPointer(); - const int* conn_ptr=conn->getConstPointer(); + const int* index_ptr=index->begin(); + const int* conn_ptr=conn->begin(); //creating graph arcs (cell to cell relations) //arcs are stored in terms of (index,value) notation @@ -9086,8 +9084,8 @@ void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData } ofs << " \n"; ofs << " \n"; - const int *cPtr=_nodal_connec->getConstPointer(); - const int *cIPtr=_nodal_connec_index->getConstPointer(); + const int *cPtr=_nodal_connec->begin(); + const int *cIPtr=_nodal_connec_index->begin(); MCAuto faceoffsets=DataArrayInt::New(); faceoffsets->alloc(nbOfCells,1); MCAuto types=DataArrayInt::New(); types->alloc(nbOfCells,1); MCAuto offsets=DataArrayInt::New(); offsets->alloc(nbOfCells,1); @@ -9238,7 +9236,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1 // Step 3: std::vector cr,crI; //no DataArrayInt because interface with Geometric2D std::vector cNb1,cNb2; //no DataArrayInt because interface with Geometric2D - BuildIntersecting2DCellsFromEdges(eps,m1,desc1->getConstPointer(),descIndx1->getConstPointer(),intersectEdge1,colinear2,m2,desc2->getConstPointer(),descIndx2->getConstPointer(),intersectEdge2,addCoo, + BuildIntersecting2DCellsFromEdges(eps,m1,desc1->begin(),descIndx1->begin(),intersectEdge1,colinear2,m2,desc2->begin(),descIndx2->begin(),intersectEdge2,addCoo, /* outputs -> */addCoordsQuadratic,cr,crI,cNb1,cNb2); // Step 4: Prepare final result: @@ -10173,11 +10171,11 @@ void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCo std::vector& addCoordsQuadratic, std::vector& cr, std::vector& crI, std::vector& cNb1, std::vector& cNb2) { static const int SPACEDIM=2; - const double *coo1(m1->getCoords()->getConstPointer()); - const int *conn1(m1->getNodalConnectivity()->getConstPointer()),*connI1(m1->getNodalConnectivityIndex()->getConstPointer()); + const double *coo1(m1->getCoords()->begin()); + const int *conn1(m1->getNodalConnectivity()->begin()),*connI1(m1->getNodalConnectivityIndex()->begin()); int offset1(m1->getNumberOfNodes()); - const double *coo2(m2->getCoords()->getConstPointer()); - const int *conn2(m2->getNodalConnectivity()->getConstPointer()),*connI2(m2->getNodalConnectivityIndex()->getConstPointer()); + const double *coo2(m2->getCoords()->begin()); + const int *conn2(m2->getNodalConnectivity()->begin()),*connI2(m2->getNodalConnectivityIndex()->begin()); int offset2(offset1+m2->getNumberOfNodes()); int offset3(offset2+((int)addCoords.size())/2); MCAuto bbox1Arr(m1->getBoundingBoxForBBTree()),bbox2Arr(m2->getBoundingBoxForBBTree()); @@ -10269,10 +10267,10 @@ DataArrayInt *MEDCouplingUMesh::orderConsecutiveCells1D() const MCAuto _d(DataArrayInt::New()),_dI(DataArrayInt::New()); MCAuto _rD(DataArrayInt::New()),_rDI(DataArrayInt::New()); MCAuto m_points(buildDescendingConnectivity(_d, _dI, _rD, _rDI)); - const int *d(_d->getConstPointer()), *dI(_dI->getConstPointer()); - const int *rD(_rD->getConstPointer()), *rDI(_rDI->getConstPointer()); + const int *d(_d->begin()), *dI(_dI->begin()); + const int *rD(_rD->begin()), *rDI(_rDI->begin()); MCAuto _dsi(_rDI->deltaShiftIndex()); - const int * dsi(_dsi->getConstPointer()); + const int * dsi(_dsi->begin()); MCAuto dsii = _dsi->findIdsNotInRange(0,3); m_points=0; if (dsii->getNumberOfTuples()) @@ -10432,7 +10430,7 @@ DataArrayInt *MEDCouplingUMesh::conformize2D(double eps) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::conformize2D : This method only works for meshes with spaceDim=2 and meshDim=2 !"); MCAuto desc1(DataArrayInt::New()),descIndx1(DataArrayInt::New()),revDesc1(DataArrayInt::New()),revDescIndx1(DataArrayInt::New()); MCAuto mDesc(buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1)); - const int *c(mDesc->getNodalConnectivity()->getConstPointer()),*ci(mDesc->getNodalConnectivityIndex()->getConstPointer()),*rd(revDesc1->getConstPointer()),*rdi(revDescIndx1->getConstPointer()); + const int *c(mDesc->getNodalConnectivity()->begin()),*ci(mDesc->getNodalConnectivityIndex()->begin()),*rd(revDesc1->begin()),*rdi(revDescIndx1->begin()); MCAuto bboxArr(mDesc->getBoundingBoxForBBTree()); const double *bbox(bboxArr->begin()),*coords(getCoords()->begin()); int nCell(getNumberOfCells()),nDescCell(mDesc->getNumberOfCells()); @@ -10611,7 +10609,7 @@ void MEDCouplingUMesh::Intersect1DMeshes(const MEDCouplingUMesh *m1Desc, const M static const int SPACEDIM=2; INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps; INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps; - const int *c1(m1Desc->getNodalConnectivity()->getConstPointer()),*ci1(m1Desc->getNodalConnectivityIndex()->getConstPointer()); + const int *c1(m1Desc->getNodalConnectivity()->begin()),*ci1(m1Desc->getNodalConnectivityIndex()->begin()); // Build BB tree of all edges in the tool mesh (second mesh) MCAuto bbox1Arr(m1Desc->getBoundingBoxForBBTree()),bbox2Arr(m2Desc->getBoundingBoxForBBTree()); const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin()); @@ -10705,10 +10703,10 @@ void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MED { int offset1=m1->getNumberOfNodes(); int ncell=m2->getNumberOfCells(); - const int *c=m2->getNodalConnectivity()->getConstPointer(); - const int *cI=m2->getNodalConnectivityIndex()->getConstPointer(); - const double *coo=m2->getCoords()->getConstPointer(); - const double *cooBis=m1->getCoords()->getConstPointer(); + const int *c=m2->getNodalConnectivity()->begin(); + const int *cI=m2->getNodalConnectivityIndex()->begin(); + const double *coo=m2->getCoords()->begin(); + const double *cooBis=m1->getCoords()->begin(); int offset2=offset1+m2->getNumberOfNodes(); intersectEdge.resize(ncell); for(int i=0;igetPointer(); *arrIPtr++=0; int previousArrI=0; - const int *arrPtr=arr->getConstPointer(); + const int *arrPtr=arr->begin(); std::vector arrOut;//no utility to switch to DataArrayInt because copy always needed for(int i=0;igetNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : input arrays must have exactly one component !"); std::size_t sz=std::distance(idsOfSelectBg,idsOfSelectEnd); - const int *arrInPtr=arrIn->getConstPointer(); - const int *arrIndxPtr=arrIndxIn->getConstPointer(); + const int *arrInPtr=arrIn->begin(); + const int *arrIndxPtr=arrIndxIn->begin(); int nbOfGrps=arrIndxIn->getNumberOfTuples()-1; if(nbOfGrps<0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !"); @@ -11241,8 +11239,8 @@ void MEDCouplingUMesh::ExtractFromIndexedArraysSlice(int idsOfSelectStart, int i if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArraysSlice : input arrays must have exactly one component !"); int sz=DataArrayInt::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArraysSlice : Input slice "); - const int *arrInPtr=arrIn->getConstPointer(); - const int *arrIndxPtr=arrIndxIn->getConstPointer(); + const int *arrInPtr=arrIn->begin(); + const int *arrIndxPtr=arrIndxIn->begin(); int nbOfGrps=arrIndxIn->getNumberOfTuples()-1; if(nbOfGrps<0) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArraysSlice : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !"); @@ -11318,8 +11316,8 @@ void MEDCouplingUMesh::SetPartOfIndexedArrays(const int *idsOfSelectBg, const in int nbOfTuples=arrIndxIn->getNumberOfTuples()-1; std::vector v(nbOfTuples,true); int offset=0; - const int *arrIndxInPtr=arrIndxIn->getConstPointer(); - const int *srcArrIndexPtr=srcArrIndex->getConstPointer(); + const int *arrIndxInPtr=arrIndxIn->begin(); + const int *srcArrIndexPtr=srcArrIndex->begin(); for(const int *it=idsOfSelectBg;it!=idsOfSelectEnd;it++,srcArrIndexPtr++) { if(*it>=0 && *itgetConstPointer(); + srcArrIndexPtr=srcArrIndex->begin(); arrIo->alloc(nbOfTuples+1,1); arro->alloc(arrIn->getNumberOfTuples()+offset,1); - const int *arrInPtr=arrIn->getConstPointer(); - const int *srcArrPtr=srcArr->getConstPointer(); + const int *arrInPtr=arrIn->begin(); + const int *srcArrPtr=srcArr->begin(); int *arrIoPtr=arrIo->getPointer(); *arrIoPtr++=0; int *arroPtr=arro->getPointer(); for(int ii=0;iigetNumberOfTuples()-1; - const int *arrIndxInPtr=arrIndxIn->getConstPointer(); - const int *srcArrIndexPtr=srcArrIndex->getConstPointer(); + const int *arrIndxInPtr=arrIndxIn->begin(); + const int *srcArrIndexPtr=srcArrIndex->begin(); int *arrInOutPtr=arrInOut->getPointer(); - const int *srcArrPtr=srcArr->getConstPointer(); + const int *srcArrPtr=srcArr->begin(); for(const int *it=idsOfSelectBg;it!=idsOfSelectEnd;it++,srcArrIndexPtr++) { if(*it>=0 && *itgetConstPointer(); - const int *arrIndxPtr=arrIndxIn->getConstPointer(); + const int *arrInPtr=arrIn->begin(); + const int *arrIndxPtr=arrIndxIn->begin(); int targetNbOfDepthPeeling=nbOfDepthPeeling!=-1?nbOfDepthPeeling:std::numeric_limits::max(); std::vector idsToFetch1(seedBg,seedEnd); std::vector idsToFetch2; @@ -11522,8 +11520,8 @@ void MEDCouplingUMesh::SetPartOfIndexedArraysSlice(int start, int end, int step, MCAuto arrIo=DataArrayInt::New(); int nbOfTuples=arrIndxIn->getNumberOfTuples()-1; int offset=0; - const int *arrIndxInPtr=arrIndxIn->getConstPointer(); - const int *srcArrIndexPtr=srcArrIndex->getConstPointer(); + const int *arrIndxInPtr=arrIndxIn->begin(); + const int *srcArrIndexPtr=srcArrIndex->begin(); int nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::SetPartOfIndexedArraysSlice : "); int it=start; for(int i=0;igetConstPointer(); + srcArrIndexPtr=srcArrIndex->begin(); arrIo->alloc(nbOfTuples+1,1); arro->alloc(arrIn->getNumberOfTuples()+offset,1); - const int *arrInPtr=arrIn->getConstPointer(); - const int *srcArrPtr=srcArr->getConstPointer(); + const int *arrInPtr=arrIn->begin(); + const int *srcArrPtr=srcArr->begin(); int *arrIoPtr=arrIo->getPointer(); *arrIoPtr++=0; int *arroPtr=arro->getPointer(); for(int ii=0;iigetNumberOfTuples()-1; - const int *arrIndxInPtr=arrIndxIn->getConstPointer(); - const int *srcArrIndexPtr=srcArrIndex->getConstPointer(); + const int *arrIndxInPtr=arrIndxIn->begin(); + const int *srcArrIndexPtr=srcArrIndex->begin(); int *arrInOutPtr=arrInOut->getPointer(); - const int *srcArrPtr=srcArr->getConstPointer(); + const int *srcArrPtr=srcArr->begin(); int nbOfElemsToSet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCouplingUMesh::SetPartOfIndexedArraysSameIdxSlice : "); int it=start; for(int i=0;iinsertNextCell((INTERP_KERNEL::NormalizedCellType)cell->getIJSafe(0,0),cell->getNumberOfTuples()-1,cell->getConstPointer()+1); + ret->insertNextCell((INTERP_KERNEL::NormalizedCellType)cell->getIJSafe(0,0),cell->getNumberOfTuples()-1,cell->begin()+1); } // ret->finishInsertingCells(); @@ -12053,7 +12051,7 @@ void MEDCouplingUMesh::ComputeAllTypesInternal(std::setgetConstPointer()),*connIndex(nodalConnecIndex->getConstPointer()); + const int *conn(nodalConnec->begin()),*connIndex(nodalConnecIndex->begin()); int nbOfElem(nodalConnecIndex->getNbOfElems()-1); if(nbOfElem>0) for(const int *pt=connIndex;pt!=connIndex+nbOfElem;pt++) @@ -12163,8 +12161,8 @@ MEDCouplingUMeshCellByTypeIterator::~MEDCouplingUMeshCellByTypeIterator() MEDCouplingUMeshCellEntry *MEDCouplingUMeshCellByTypeIterator::nextt() { - const int *c=_mesh->getNodalConnectivity()->getConstPointer(); - const int *ci=_mesh->getNodalConnectivityIndex()->getConstPointer(); + const int *c=_mesh->getNodalConnectivity()->begin(); + const int *ci=_mesh->getNodalConnectivityIndex()->begin(); if(_cell_id<_nb_cell) { INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)c[ci[_cell_id]]; diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py index 45c3ae72b..6e9febf06 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest5.py @@ -4796,6 +4796,62 @@ class MEDCouplingBasicsTest5(unittest.TestCase): mea2=mea.sumPerTuple() self.assertTrue(mea2.isEqual(meaRef,1e-12)) pass + + def testFieldDoubleConvertToLinear1(self): + da=DataArrayDouble([0,0, 1,0, 2,0, 3,0, 0.5,0, 1.5,0, 2.5,0, 0,0.5, 0.5,0.5, 1, 0.5, 1.5,0.5, 2,0.5, 3,0.5, 0,1, 1,1, 2,1, 2.5,1, 3,1],18,2) + da.setInfoOnComponents(["g","h"]) + m=MEDCouplingUMesh("mesh",2) + m.setCoords(da) + m.allocateCells() + m.insertNextCell(NORM_TRI6,[0,1,13,4,9,7]) + m.insertNextCell(NORM_TRI6,[1,2,14,5,10,9]) + m.insertNextCell(NORM_QUAD8,[2,3,17,15,6,12,16,11]) + refPtr=m.getHiddenCppPointer() + f=MEDCouplingFieldDouble(ON_NODES) + f.setName("aa") + f.setMesh(m) + arr=DataArrayDouble(18*2) ; arr.iota() + arr.rearrange(2) + arr.setInfoOnComponents(["bb","ccc"]) + f.setArray(arr) + f.setTime(0.5,2,3) + f.checkConsistencyLight() + # + f1=f.convertQuadraticCellsToLinear() + self.assertTrue(f.getMesh().getHiddenCppPointer(),refPtr) + self.assertTrue(f1.getMesh().getHiddenCppPointer()!=refPtr) + f1.checkConsistencyLight() + self.assertEqual(f1.getName(),"aa") + self.assertEqual(f1.getTypeOfField(),ON_NODES) + da0=DataArrayDouble([(0,0),(1,0),(2,0),(3,0),(0,1),(1,1),(2,1),(3,1)]) + da0.setInfoOnComponents(["g","h"]) + self.assertTrue(f1.getMesh().getCoords().isEqual(da0,1e-12)) + self.assertTrue(f1.getMesh().getNodalConnectivity().isEqual(DataArrayInt([3,0,1,4,3,1,2,5,4,2,3,7,6]))) + self.assertTrue(f1.getMesh().getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,13]))) + da2=DataArrayDouble([(0,1),(2,3),(4,5),(6,7),(26,27),(28,29),(30,31),(34,35)]) + da2.setInfoOnComponents(["bb","ccc"]) + self.assertTrue(f1.getArray().isEqual(da2,1e-12)) + self.assertEqual(f1.getTime(),[0.5,2,3]) + # + f2=MEDCouplingFieldDouble(ON_CELLS) + f2.setName("aa") + f2.setMesh(m) + arr=DataArrayDouble(3*2) ; arr.iota() + arr.rearrange(2) + arr.setInfoOnComponents(["bb","ccc"]) + f2.setArray(arr) + f2.setTime(0.5,2,3) + f2.checkConsistencyLight() + f3=f2.convertQuadraticCellsToLinear() + self.assertEqual(f2.getMesh().getHiddenCppPointer(),refPtr) + f3.checkConsistencyLight() + self.assertTrue(f3.getMesh().getHiddenCppPointer()!=refPtr) + self.assertTrue(f3.getMesh().getCoords().isEqual(da0,1e-12)) + self.assertTrue(f3.getMesh().getNodalConnectivity().isEqual(DataArrayInt([3,0,1,4,3,1,2,5,4,2,3,7,6]))) + self.assertTrue(f3.getMesh().getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,13]))) + self.assertEqual(f2.getArray().getHiddenCppPointer(),f3.getArray().getHiddenCppPointer()) + self.assertEqual(f3.getTime(),[0.5,2,3]) + pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 6f6b5a748..78f3867d3 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -213,6 +213,7 @@ using namespace INTERP_KERNEL; %newobject MEDCoupling::MEDCouplingFieldDouble::buildSubPart; %newobject MEDCoupling::MEDCouplingFieldDouble::buildSubPartRange; %newobject MEDCoupling::MEDCouplingFieldDouble::voronoize; +%newobject MEDCoupling::MEDCouplingFieldDouble::convertQuadraticCellsToLinear; %newobject MEDCoupling::MEDCouplingFieldDouble::__getitem__; %newobject MEDCoupling::MEDCouplingFieldDouble::__neg__; %newobject MEDCoupling::MEDCouplingFieldDouble::__add__; @@ -3960,6 +3961,12 @@ namespace MEDCoupling MCAuto ret(self->voronoize(eps)); return ret.retn(); } + + MEDCouplingFieldDouble *convertQuadraticCellsToLinear() const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->convertQuadraticCellsToLinear()); + return ret.retn(); + } MEDCouplingFieldDouble *computeVectorFieldCyl(PyObject *center, PyObject *vector) const { -- 2.39.2