X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingPointSet.cxx;h=1f8b34bccd063146c2d1da9d472ca03043ac34d9;hb=a6c4fa941f2f989606ab1ccf0d89c5992a0193a9;hp=4793b7993ff5adfc236eee4c9f2298347a76d2d2;hpb=7f3a9dc9613422e5f56bd258d6ef6f1e5865c5e7;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 4793b7993..1f8b34bcc 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,7 @@ // Author : Anthony Geay (CEA/DEN) #include "MEDCouplingPointSet.hxx" -#include "MEDCouplingAutoRefCountObjectPtr.hxx" +#include "MCAuto.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMemArray.hxx" @@ -32,17 +32,18 @@ #include #include #include +#include -using namespace ParaMEDMEM; +using namespace MEDCoupling; MEDCouplingPointSet::MEDCouplingPointSet():_coords(0) { } -MEDCouplingPointSet::MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCopy):MEDCouplingMesh(other),_coords(0) +MEDCouplingPointSet::MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy):MEDCouplingMesh(other),_coords(0) { if(other._coords) - _coords=other._coords->performCpy(deepCopy); + _coords=other._coords->performCopyOrIncrRef(deepCpy); } MEDCouplingPointSet::~MEDCouplingPointSet() @@ -265,7 +266,7 @@ DataArrayInt *MEDCouplingPointSet::buildPermArrayForMergeNode(double precision, DataArrayInt *comm,*commI; findCommonNodes(precision,limitNodeId,comm,commI); int oldNbOfNodes=getNumberOfNodes(); - MEDCouplingAutoRefCountObjectPtr ret=buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes); + MCAuto ret=buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes); areNodesMerged=(oldNbOfNodes!=newNbOfNodes); comm->decrRef(); commI->decrRef(); @@ -326,7 +327,7 @@ DataArrayInt *MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double { DataArrayInt *c=0,*cI=0; getNodeIdsNearPoints(pos,1,eps,c,cI); - MEDCouplingAutoRefCountObjectPtr cITmp(cI); + MCAuto cITmp(cI); return c; } @@ -362,7 +363,7 @@ void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfPoints if(!_coords) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::getNodeIdsNearPoint : no coordiantes set !"); int spaceDim=getSpaceDimension(); - MEDCouplingAutoRefCountObjectPtr points=DataArrayDouble::New(); + MCAuto points=DataArrayDouble::New(); points->useArray(pos,false,CPP_DEALLOC,nbOfPoints,spaceDim); _coords->computeTupleIdsNearTuples(points,eps,c,cI); } @@ -370,14 +371,14 @@ void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfPoints /*! * @param comm in param in the same format than one returned by findCommonNodes method (\ref numbering-indirect). * @param commI in param in the same format than one returned by findCommonNodes method (\ref numbering-indirect). - * @return the old to new correspondance array. + * @return the old to new correspondence array. */ DataArrayInt *MEDCouplingPointSet::buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex, int& newNbOfNodes) const { if(!_coords) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::buildNewNumberingFromCommonNodesFormat : no coords specified !"); - return DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(getNumberOfNodes(),comm->begin(),commIndex->begin(),commIndex->end(),newNbOfNodes); + return DataArrayInt::ConvertIndexArrayToO2N(getNumberOfNodes(),comm->begin(),commIndex->begin(),commIndex->end(),newNbOfNodes); } /*! @@ -401,7 +402,7 @@ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNo { if(!_coords) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::renumberNodes : no coords specified !"); - MEDCouplingAutoRefCountObjectPtr newCoords=_coords->renumberAndReduce(newNodeNumbers,newNbOfNodes); + MCAuto newCoords=_coords->renumberAndReduce(newNodeNumbers,newNbOfNodes); renumberNodesInConn(newNodeNumbers); setCoords(newCoords);//let it here not before renumberNodesInConn because old number of nodes is sometimes used... } @@ -425,7 +426,7 @@ void MEDCouplingPointSet::renumberNodes(const int *newNodeNumbers, int newNbOfNo * \ref py_mcumesh_renumberNodes "Here is a Python example". * \endif */ -void MEDCouplingPointSet::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes) +void MEDCouplingPointSet::renumberNodesCenter(const int *newNodeNumbers, int newNbOfNodes) { DataArrayDouble *newCoords=DataArrayDouble::New(); std::vector div(newNbOfNodes); @@ -674,8 +675,8 @@ void MEDCouplingPointSet::duplicateNodesInCoords(const int *nodeIdsToDuplicateBg { if(!_coords) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::duplicateNodesInCoords : no coords set !"); - MEDCouplingAutoRefCountObjectPtr newCoords=_coords->selectByTupleIdSafe(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd); - MEDCouplingAutoRefCountObjectPtr newCoords2=DataArrayDouble::Aggregate(_coords,newCoords); + MCAuto newCoords=_coords->selectByTupleIdSafe(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd); + MCAuto newCoords2=DataArrayDouble::Aggregate(_coords,newCoords); setCoords(newCoords2); } @@ -947,10 +948,10 @@ void MEDCouplingPointSet::unserialization(const std::vector& tinyInfoD, } } -void MEDCouplingPointSet::checkCoherency() const +void MEDCouplingPointSet::checkConsistencyLight() const { if(!_coords) - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkCoherency : no coordinates set !"); + throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkConsistencyLight : no coordinates set !"); } /*! @@ -994,8 +995,8 @@ bool MEDCouplingPointSet::intersectsBoundingBox(const double* bb1, const double* */ bool MEDCouplingPointSet::intersectsBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bb1, const double* bb2, int dim, double eps) { - double* bbtemp = new double[2*dim]; - double deltamax=0.0; + double* bbtemp(new double[2*dim]); + double deltamax(0.0); for (int i=0; i< dim; i++) { @@ -1011,7 +1012,7 @@ bool MEDCouplingPointSet::intersectsBoundingBox(const INTERP_KERNEL::DirectedBou bbtemp[i*2+1]=bb2[i*2+1]+deltamax*eps; } - bool intersects = !bb1.isDisjointWith( bbtemp ); + bool intersects(!bb1.isDisjointWith(bbtemp)); delete [] bbtemp; return intersects; } @@ -1021,49 +1022,9 @@ bool MEDCouplingPointSet::intersectsBoundingBox(const INTERP_KERNEL::DirectedBou */ void MEDCouplingPointSet::rotate3D(const double *center, const double *vect, double angle) { - double *coords=_coords->getPointer(); - int nbNodes=getNumberOfNodes(); - Rotate3DAlg(center,vect,angle,nbNodes,coords); -} - -/*! - * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' - * around an axe ('center','vect') and with angle 'angle'. - */ -void MEDCouplingPointSet::Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords) -{ - if(!center || !vect) - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::Rotate3DAlg : null vector in input !"); - double sina=sin(angle); - double cosa=cos(angle); - double vectorNorm[3]; - double matrix[9]; - double matrixTmp[9]; - double norm=sqrt(vect[0]*vect[0]+vect[1]*vect[1]+vect[2]*vect[2]); - if(norm::min()) - throw INTERP_KERNEL::Exception("MEDCouplingPointSet::Rotate3DAlg : magnitude of input vector is too close of 0. !"); - std::transform(vect,vect+3,vectorNorm,std::bind2nd(std::multiplies(),1/norm)); - //rotation matrix computation - matrix[0]=cosa; matrix[1]=0.; matrix[2]=0.; matrix[3]=0.; matrix[4]=cosa; matrix[5]=0.; matrix[6]=0.; matrix[7]=0.; matrix[8]=cosa; - matrixTmp[0]=vectorNorm[0]*vectorNorm[0]; matrixTmp[1]=vectorNorm[0]*vectorNorm[1]; matrixTmp[2]=vectorNorm[0]*vectorNorm[2]; - matrixTmp[3]=vectorNorm[1]*vectorNorm[0]; matrixTmp[4]=vectorNorm[1]*vectorNorm[1]; matrixTmp[5]=vectorNorm[1]*vectorNorm[2]; - matrixTmp[6]=vectorNorm[2]*vectorNorm[0]; matrixTmp[7]=vectorNorm[2]*vectorNorm[1]; matrixTmp[8]=vectorNorm[2]*vectorNorm[2]; - std::transform(matrixTmp,matrixTmp+9,matrixTmp,std::bind2nd(std::multiplies(),1-cosa)); - std::transform(matrix,matrix+9,matrixTmp,matrix,std::plus()); - matrixTmp[0]=0.; matrixTmp[1]=-vectorNorm[2]; matrixTmp[2]=vectorNorm[1]; - matrixTmp[3]=vectorNorm[2]; matrixTmp[4]=0.; matrixTmp[5]=-vectorNorm[0]; - matrixTmp[6]=-vectorNorm[1]; matrixTmp[7]=vectorNorm[0]; matrixTmp[8]=0.; - std::transform(matrixTmp,matrixTmp+9,matrixTmp,std::bind2nd(std::multiplies(),sina)); - std::transform(matrix,matrix+9,matrixTmp,matrix,std::plus()); - //rotation matrix computed. - double tmp[3]; - for(int i=0; i()); - coords[i*3]=matrix[0]*tmp[0]+matrix[1]*tmp[1]+matrix[2]*tmp[2]+center[0]; - coords[i*3+1]=matrix[3]*tmp[0]+matrix[4]*tmp[1]+matrix[5]*tmp[2]+center[1]; - coords[i*3+2]=matrix[6]*tmp[0]+matrix[7]*tmp[1]+matrix[8]*tmp[2]+center[2]; - } + double *coords(_coords->getPointer()); + int nbNodes(getNumberOfNodes()); + DataArrayDouble::Rotate3DAlg(center,vect,angle,nbNodes,coords,coords); } /*! @@ -1081,7 +1042,7 @@ DataArrayInt *MEDCouplingPointSet::ComputeNbOfInteractionsWithSrcCells(const MED { if(!srcMesh || !trgMesh) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::ComputeNbOfInteractionsWithSrcCells : the input meshes must be not NULL !"); - MEDCouplingAutoRefCountObjectPtr sbbox(srcMesh->getBoundingBoxForBBTree()),tbbox(trgMesh->getBoundingBoxForBBTree()); + MCAuto sbbox(srcMesh->getBoundingBoxForBBTree(eps)),tbbox(trgMesh->getBoundingBoxForBBTree(eps)); return tbbox->computeNbOfInteractionsWith(sbbox,eps); } @@ -1115,7 +1076,7 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPart(const int *start, const int *end */ MEDCouplingMesh *MEDCouplingPointSet::buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const { - MEDCouplingAutoRefCountObjectPtr ret=buildPartOfMySelf(start,end,true); + MCAuto ret=buildPartOfMySelf(start,end,true); arr=ret->zipCoordsTraducer(); return ret.retn(); } @@ -1129,7 +1090,7 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPartAndReduceNodes(const int *start, * * \return a new ref to be managed by the caller. Warning this ref can be equal to \a this if input slice is exactly equal to the whole cells in the same order. * - * \sa MEDCouplingUMesh::buildPartOfMySelf2 + * \sa MEDCouplingUMesh::buildPartOfMySelfSlice */ MEDCouplingMesh *MEDCouplingPointSet::buildPartRange(int beginCellIds, int endCellIds, int stepCellIds) const { @@ -1141,7 +1102,7 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPartRange(int beginCellIds, int endCe } else { - return buildPartOfMySelf2(beginCellIds,endCellIds,stepCellIds,true); + return buildPartOfMySelfSlice(beginCellIds,endCellIds,stepCellIds,true); } } @@ -1151,13 +1112,13 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPartRange(int beginCellIds, int endCe * \param [out] beginOut valid only if \a arr not NULL ! * \param [out] endOut valid only if \a arr not NULL ! * \param [out] stepOut valid only if \a arr not NULL ! - * \param [out] arr correspondance old to new in node ids. + * \param [out] arr correspondence old to new in node ids. * - * \sa MEDCouplingUMesh::buildPartOfMySelf2 + * \sa MEDCouplingUMesh::buildPartOfMySelfSlice */ MEDCouplingMesh *MEDCouplingPointSet::buildPartRangeAndReduceNodes(int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt*& arr) const { - MEDCouplingAutoRefCountObjectPtr ret=buildPartOfMySelf2(beginCellIds,endCellIds,stepCellIds,true); + MCAuto ret(buildPartOfMySelfSlice(beginCellIds,endCellIds,stepCellIds,true)); arr=ret->zipCoordsTraducer(); return ret.retn(); } @@ -1167,28 +1128,9 @@ MEDCouplingMesh *MEDCouplingPointSet::buildPartRangeAndReduceNodes(int beginCell */ void MEDCouplingPointSet::rotate2D(const double *center, double angle) { - double *coords=_coords->getPointer(); - int nbNodes=getNumberOfNodes(); - Rotate2DAlg(center,angle,nbNodes,coords); -} - -/*! - * Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords' - * around the center point 'center' and with angle 'angle'. - */ -void MEDCouplingPointSet::Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords) -{ - double cosa=cos(angle); - double sina=sin(angle); - double matrix[4]; - matrix[0]=cosa; matrix[1]=-sina; matrix[2]=sina; matrix[3]=cosa; - double tmp[2]; - for(int i=0; i()); - coords[i*2]=matrix[0]*tmp[0]+matrix[1]*tmp[1]+center[0]; - coords[i*2+1]=matrix[2]*tmp[0]+matrix[3]*tmp[1]+center[1]; - } + double *coords(_coords->getPointer()); + int nbNodes(getNumberOfNodes()); + DataArrayDouble::Rotate2DAlg(center,angle,nbNodes,coords,coords); } /// @cond INTERNAL @@ -1212,8 +1154,8 @@ public: */ void MEDCouplingPointSet::project2DCellOnXY(const int *startConn, const int *endConn, std::vector& res) const { - const double *coords=_coords->getConstPointer(); - int spaceDim=getSpaceDimension(); + const double *coords(_coords->getConstPointer()); + int spaceDim(getSpaceDimension()); for(const int *it=startConn;it!=endConn;it++) res.insert(res.end(),coords+spaceDim*(*it),coords+spaceDim*(*it+1)); if(spaceDim==2) @@ -1239,21 +1181,21 @@ void MEDCouplingPointSet::project2DCellOnXY(const int *startConn, const int *end */ bool MEDCouplingPointSet::isButterfly2DCell(const std::vector& res, bool isQuad, double eps) { - std::size_t nbOfNodes=res.size()/2; + INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + + std::size_t nbOfNodes(res.size()/2); std::vector nodes(nbOfNodes); for(std::size_t i=0;iisButterflyAbs(); + bool ret(pol->isButterflyAbs()); delete pol; return ret; } @@ -1269,7 +1211,7 @@ bool MEDCouplingPointSet::areCellsFrom2MeshEqual(const MEDCouplingPointSet *othe std::vector c1,c2; getNodeIdsOfCell(cellId,c1); other->getNodeIdsOfCell(cellId,c2); - std::size_t sz=c1.size(); + std::size_t sz(c1.size()); if(sz!=c2.size()) return false; for(std::size_t i=0;i newCoords=MergeNodesArray(&other,this); + MCAuto newCoords=MergeNodesArray(&other,this); _coords->incrRef(); - MEDCouplingAutoRefCountObjectPtr oldCoords=_coords; + MCAuto oldCoords=_coords; setCoords(newCoords); bool areNodesMerged; int newNbOfNodes; - MEDCouplingAutoRefCountObjectPtr da=buildPermArrayForMergeNode(epsilon,otherNbOfNodes,areNodesMerged,newNbOfNodes); + MCAuto da=buildPermArrayForMergeNode(epsilon,otherNbOfNodes,areNodesMerged,newNbOfNodes); if(!areNodesMerged) { setCoords(oldCoords); @@ -1334,15 +1276,15 @@ void MEDCouplingPointSet::tryToShareSameCoordsPermute(const MEDCouplingPointSet& MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const { - MEDCouplingAutoRefCountObjectPtr ret=buildPartOfMySelfKeepCoords(begin,end); + MCAuto ret=buildPartOfMySelfKeepCoords(begin,end); if(!keepCoords) ret->zipCoords(); return ret.retn(); } -MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelf2(int start, int end, int step, bool keepCoords) const +MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelfSlice(int start, int end, int step, bool keepCoords) const { - MEDCouplingAutoRefCountObjectPtr ret=buildPartOfMySelfKeepCoords2(start,end,step); + MCAuto ret=buildPartOfMySelfKeepCoordsSlice(start,end,step); if(!keepCoords) ret->zipCoords(); return ret.retn(); @@ -1375,7 +1317,7 @@ MEDCouplingPointSet *MEDCouplingPointSet::buildPartOfMySelfNode(const int *begin { DataArrayInt *cellIdsKept=0; fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept); - MEDCouplingAutoRefCountObjectPtr cellIdsKept2(cellIdsKept); + MCAuto cellIdsKept2(cellIdsKept); return buildPartOfMySelf(cellIdsKept->begin(),cellIdsKept->end(),true); } @@ -1414,12 +1356,12 @@ DataArrayInt *MEDCouplingPointSet::zipConnectivityTraducer(int compType, int sta { DataArrayInt *commonCells=0,*commonCellsI=0; findCommonCells(compType,startCellId,commonCells,commonCellsI); - MEDCouplingAutoRefCountObjectPtr commonCellsTmp(commonCells),commonCellsITmp(commonCellsI); + MCAuto commonCellsTmp(commonCells),commonCellsITmp(commonCellsI); int newNbOfCells=-1; - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(getNumberOfCells(),commonCells->begin(),commonCellsI->begin(), + MCAuto ret=DataArrayInt::ConvertIndexArrayToO2N(getNumberOfCells(),commonCells->begin(),commonCellsI->begin(), commonCellsI->end(),newNbOfCells); - MEDCouplingAutoRefCountObjectPtr ret2=ret->invertArrayO2N2N2O(newNbOfCells); - MEDCouplingAutoRefCountObjectPtr self=buildPartOfMySelf(ret2->begin(),ret2->end(),true); + MCAuto ret2=ret->invertArrayO2N2N2O(newNbOfCells); + MCAuto self=buildPartOfMySelf(ret2->begin(),ret2->end(),true); shallowCopyConnectivityFrom(self); return ret.retn(); } @@ -1445,6 +1387,14 @@ bool MEDCouplingPointSet::areAllNodesFetched() const * mesh (with a specified precision) and (2) \a this mesh contains the same cells as * the \a other mesh (with use of a specified cell comparison technique). The mapping * from \a other to \a this for nodes and cells is returned via out parameters. + * + * If \a cellCor is null (or Py_None) it means that for all #i cell in \a other is equal to cell # i in \a this. + * + * If \a nodeCor is null (or Py_None) it means that for all #i node in \a other is equal to node # i in \a this. + * + * So null (or Py_None) returned in \a cellCor and/or \a nodeCor means identity array. This is for optimization reason to avoid building + * useless arrays for some \a levOfCheck (for example 0). + * * \param [in] other - the mesh to compare with. * \param [in] cellCompPol - id [0-2] of cell comparison method. See meaning of * each method in description of MEDCouplingPointSet::zipConnectivityTraducer(). @@ -1468,11 +1418,11 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int const MEDCouplingPointSet *otherC=dynamic_cast(other); if(!otherC) throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkDeepEquivalWith : other is not a PointSet mesh !"); - MEDCouplingAutoRefCountObjectPtr m=dynamic_cast(mergeMyselfWith(otherC)); + MCAuto m=dynamic_cast(mergeMyselfWith(otherC)); bool areNodesMerged; int newNbOfNodes; int oldNbOfNodes=getNumberOfNodes(); - MEDCouplingAutoRefCountObjectPtr da=m->buildPermArrayForMergeNode(prec,oldNbOfNodes,areNodesMerged,newNbOfNodes); + MCAuto da=m->buildPermArrayForMergeNode(prec,oldNbOfNodes,areNodesMerged,newNbOfNodes); //mergeNodes if(!areNodesMerged && oldNbOfNodes != 0) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Nodes are incompatible ! "); @@ -1481,7 +1431,7 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some nodes in other are not in this !"); m->renumberNodes(da->getConstPointer(),newNbOfNodes); // - MEDCouplingAutoRefCountObjectPtr nodeCor2=da->substr(oldNbOfNodes); + MCAuto nodeCor2=da->subArray(oldNbOfNodes); da=m->mergeNodes(prec,areNodesMerged,newNbOfNodes); // da=m->zipConnectivityTraducer(cellCompPol); @@ -1491,7 +1441,7 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int int dan(da->getNumberOfTuples()); if (dan) { - MEDCouplingAutoRefCountObjectPtr da1(DataArrayInt::New()),da2(DataArrayInt::New()); + MCAuto da1(DataArrayInt::New()),da2(DataArrayInt::New()); da1->alloc(dan/2,1); da2->alloc(dan/2,1); std::copy(da->getConstPointer(), da->getConstPointer()+dan/2, da1->getPointer()); std::copy(da->getConstPointer()+dan/2, da->getConstPointer()+dan, da2->getPointer()); @@ -1499,9 +1449,9 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int if (!da1->isEqualWithoutConsideringStr(*da2)) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : some cells in other are not in this !"); } - MEDCouplingAutoRefCountObjectPtr cellCor2=da->selectByTupleId2(nbCells,da->getNbOfElems(),1); - nodeCor=nodeCor2->isIdentity()?0:nodeCor2.retn(); - cellCor=cellCor2->isIdentity()?0:cellCor2.retn(); + MCAuto cellCor2=da->selectByTupleIdSafeSlice(nbCells,da->getNbOfElems(),1); + nodeCor=nodeCor2->isIota(nodeCor2->getNumberOfTuples())?0:nodeCor2.retn(); + cellCor=cellCor2->isIota(cellCor2->getNumberOfTuples())?0:cellCor2.retn(); } /*! @@ -1510,6 +1460,9 @@ void MEDCouplingPointSet::checkDeepEquivalWith(const MEDCouplingMesh *other, int * node coordinates array and (2) they contain the same cells (with use of a specified * cell comparison technique). The mapping from cells of the \a other to ones of \a this * is returned via an out parameter. + * + * If \a cellCor is null (or Py_None) it means that for all #i cell in \a other is equal to cell # i in \a this. + * * \param [in] other - the mesh to compare with. * \param [in] cellCompPol - id [0-2] of cell comparison method. See the meaning of * each method in description of MEDCouplingPointSet::zipConnectivityTraducer(). @@ -1533,16 +1486,16 @@ void MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh throw INTERP_KERNEL::Exception("MEDCouplingPointSet::checkDeepEquivalOnSameNodesWith : other is not a PointSet mesh !"); if(_coords!=otherC->_coords) throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : meshes do not share the same coordinates ! Use tryToShareSameCoordinates or call checkDeepEquivalWith !"); - MEDCouplingAutoRefCountObjectPtr m=mergeMyselfWithOnSameCoords(otherC); - MEDCouplingAutoRefCountObjectPtr da=m->zipConnectivityTraducer(cellCompPol); + MCAuto m=mergeMyselfWithOnSameCoords(otherC); + MCAuto da=m->zipConnectivityTraducer(cellCompPol); int maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells()); const int *pt=std::find_if(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater(),maxId)); if(pt!=da->getConstPointer()+da->getNbOfElems()) { throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : some cells in other are not in this !"); } - MEDCouplingAutoRefCountObjectPtr cellCor2=da->selectByTupleId2(getNumberOfCells(),da->getNbOfElems(),1); - cellCor=cellCor2->isIdentity()?0:cellCor2.retn(); + MCAuto cellCor2=da->selectByTupleIdSafeSlice(getNumberOfCells(),da->getNbOfElems(),1); + cellCor=cellCor2->isIota(cellCor2->getNumberOfTuples())?0:cellCor2.retn(); } void MEDCouplingPointSet::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const @@ -1636,7 +1589,7 @@ DataArrayInt *MEDCouplingPointSet::getCellIdsFullyIncludedInNodeIds(const int *p DataArrayInt *MEDCouplingPointSet::zipCoordsTraducer() { int newNbOfNodes=-1; - MEDCouplingAutoRefCountObjectPtr traducer=getNodeIdsInUse(newNbOfNodes); + MCAuto traducer=getNodeIdsInUse(newNbOfNodes); renumberNodes(traducer->getConstPointer(),newNbOfNodes); return traducer.retn(); } @@ -1661,7 +1614,7 @@ DataArrayInt *MEDCouplingPointSet::zipCoordsTraducer() */ DataArrayInt *MEDCouplingPointSet::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) { - MEDCouplingAutoRefCountObjectPtr ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes); + MCAuto ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes); if(areNodesMerged) renumberNodes(ret->begin(),newNbOfNodes); return ret.retn(); @@ -1686,10 +1639,10 @@ DataArrayInt *MEDCouplingPointSet::mergeNodes(double precision, bool& areNodesMe * \ref py_mcumesh_mergeNodes "Here is a Python example". * \endif */ -DataArrayInt *MEDCouplingPointSet::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) +DataArrayInt *MEDCouplingPointSet::mergeNodesCenter(double precision, bool& areNodesMerged, int& newNbOfNodes) { DataArrayInt *ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes); if(areNodesMerged) - renumberNodes2(ret->getConstPointer(),newNbOfNodes); + renumberNodesCenter(ret->getConstPointer(),newNbOfNodes); return ret; }