From f85c68676c64326e1c03eb5cc9dcfd85c6bb14f4 Mon Sep 17 00:00:00 2001 From: ageay Date: Thu, 5 Jan 2012 07:46:37 +0000 Subject: [PATCH] DataArrayDouble::findCommonTuples method. --- src/MEDCoupling/MEDCouplingCMesh.cxx | 1 + src/MEDCoupling/MEDCouplingExtrudedMesh.cxx | 1 + .../MEDCouplingFieldDiscretization.cxx | 1 + src/MEDCoupling/MEDCouplingFieldDouble.cxx | 1 + src/MEDCoupling/MEDCouplingFieldTemplate.cxx | 2 + src/MEDCoupling/MEDCouplingMemArray.cxx | 91 +++++++++++++++++++ src/MEDCoupling/MEDCouplingMemArray.hxx | 5 + src/MEDCoupling/MEDCouplingMemArray.txx | 2 + src/MEDCoupling/MEDCouplingMultiFields.cxx | 3 + src/MEDCoupling/MEDCouplingPointSet.cxx | 46 ++-------- src/MEDCoupling/MEDCouplingPointSet.hxx | 7 +- src/MEDCoupling/MEDCouplingPointSet.txx | 43 --------- .../MEDCouplingTimeDiscretization.cxx | 2 + src/MEDCoupling/MEDCouplingUMesh.cxx | 9 +- src/MEDCoupling/MEDCouplingUMeshDesc.cxx | 1 + .../Test/MEDCouplingBasicsTest1.cxx | 5 +- .../Test/MEDCouplingBasicsTest2.cxx | 1 + src/MEDCoupling_Swig/MEDCoupling.i | 14 ++- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 4 +- 19 files changed, 142 insertions(+), 97 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 290cd3623..6daf60045 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -24,6 +24,7 @@ #include #include +#include #include using namespace ParaMEDMEM; diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index 8e187d956..abd42cbec 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index d9c573450..8800898ea 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 0c63601e2..eeb8b0f07 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -27,6 +27,7 @@ #include #include +#include #include using namespace ParaMEDMEM; diff --git a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx index fb6680a86..77ecf4577 100644 --- a/src/MEDCoupling/MEDCouplingFieldTemplate.cxx +++ b/src/MEDCoupling/MEDCouplingFieldTemplate.cxx @@ -22,6 +22,8 @@ #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldDiscretization.hxx" +#include + using namespace ParaMEDMEM; MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 1addb5ea2..eb7c5662b 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -33,6 +33,48 @@ typedef double (*MYFUNCPTR)(double); using namespace ParaMEDMEM; +template +void DataArrayDouble::findCommonTuplesAlg(std::vector& bbox, + int nbNodes, int limitNodeId, double prec, std::vector& c, std::vector& cI) const +{ + const double *coordsPtr=getConstPointer(); + BBTree myTree(&bbox[0],0,0,nbNodes,-prec); + double bb[2*SPACEDIM]; + double prec2=prec*prec; + std::vector isDone(nbNodes); + for(int i=0;i intersectingElems; + myTree.getIntersectingElems(bb,intersectingElems); + if(intersectingElems.size()>1) + { + std::vector commonNodes; + for(std::vector::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++) + if(*it!=i) + if(*it>=limitNodeId) + if(INTERP_KERNEL::distance2(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it)) bbox(2*nbOfTuples*nbOfCompo); + const double *coordsPtr=getConstPointer(); + for(int i=0;i c,cI(1); + switch(nbOfCompo) + { + case 3: + findCommonTuplesAlg<3>(bbox,nbOfTuples,limitNodeId,prec,c,cI); + break; + case 2: + findCommonTuplesAlg<2>(bbox,nbOfTuples,limitNodeId,prec,c,cI); + break; + case 1: + findCommonTuplesAlg<1>(bbox,nbOfTuples,limitNodeId,prec,c,cI); + break; + default: + throw INTERP_KERNEL::Exception("Unexpected spacedim of coords. Must be 1, 2 or 3."); + } + commIndex->alloc(cI.size(),1); + std::copy(cI.begin(),cI.end(),commIndex->getPointer()); + comm->alloc(cI.back(),1); + std::copy(c.begin(),c.end(),comm->getPointer()); +} + void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds) throw(INTERP_KERNEL::Exception) { copyPartOfStringInfoFrom2(compoIds,*a); diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index d93191e93..cc5eb0196 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -173,6 +173,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector& compoIds) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void findCommonTuples(double prec, int limitNodeId, DataArrayInt *&comm, DataArrayInt *&commIndex) const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector& compoIds) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception); @@ -252,6 +253,10 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector& tinyInfoI); MEDCOUPLING_EXPORT void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS); + protected: + template + void findCommonTuplesAlg(std::vector& bbox, + int nbNodes, int limitNodeId, double prec, std::vector& c, std::vector& cI) const; private: DataArrayDouble() { } private: diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 197798b51..2868a0867 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -22,6 +22,8 @@ #include "MEDCouplingMemArray.hxx" #include "NormalizedUnstructuredMesh.hxx" #include "InterpKernelException.hxx" +#include "InterpolationUtils.hxx" +#include "BBTree.txx" #include #include diff --git a/src/MEDCoupling/MEDCouplingMultiFields.cxx b/src/MEDCoupling/MEDCouplingMultiFields.cxx index 86b495559..a9dc65f76 100644 --- a/src/MEDCoupling/MEDCouplingMultiFields.cxx +++ b/src/MEDCoupling/MEDCouplingMultiFields.cxx @@ -23,6 +23,9 @@ #include "MEDCouplingMesh.hxx" #include "MEDCouplingAutoRefCountObjectPtr.hxx" +#include +#include + using namespace ParaMEDMEM; MEDCouplingMultiFields *MEDCouplingMultiFields::New(const std::vector& fs) throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index f19def6b4..cac488467 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -159,10 +159,10 @@ bool MEDCouplingPointSet::areCoordsEqualWithoutConsideringStr(const MEDCouplingP * @param areNodesMerged output parameter that states if some nodes have been "merged" in returned array * @param newNbOfNodes output parameter too this is the maximal id in returned array to avoid to recompute it. */ -DataArrayInt *MEDCouplingPointSet::buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const +DataArrayInt *MEDCouplingPointSet::buildPermArrayForMergeNode(double precision, int limitNodeId, bool& areNodesMerged, int& newNbOfNodes) const { DataArrayInt *comm,*commI; - findCommonNodes(limitNodeId,precision,comm,commI); + findCommonNodes(precision,limitNodeId,comm,commI); int oldNbOfNodes=getNumberOfNodes(); DataArrayInt *ret=buildNewNumberingFromCommonNodesFormat(comm,commI,newNbOfNodes); areNodesMerged=(oldNbOfNodes!=newNbOfNodes); @@ -172,49 +172,17 @@ DataArrayInt *MEDCouplingPointSet::buildPermArrayForMergeNode(int limitNodeId, d } /*! - * This methods searches for each node n1 nodes in _coords that are less far than 'prec' from n1. if any these nodes are stored in params + * This methods searches for each node if there are any nodes in _coords that are less far than 'prec' from n1. if any, these nodes are stored in out params * comm and commIndex. * @param limitNodeId is the limit node id. All nodes which id is strictly lower than 'limitNodeId' will not be merged each other. * @param comm out parameter (not inout) * @param commIndex out parameter (not inout) */ -void MEDCouplingPointSet::findCommonNodes(int limitNodeId, double prec, DataArrayInt *&comm, DataArrayInt *&commIndex) const +void MEDCouplingPointSet::findCommonNodes(double prec, int limitNodeId, DataArrayInt *&comm, DataArrayInt *&commIndex) const { - comm=DataArrayInt::New(); - commIndex=DataArrayInt::New(); - // - int nbNodesOld=getNumberOfNodes(); - int spaceDim=getSpaceDimension(); - std::vector bbox(2*nbNodesOld*spaceDim); - const double *coordsPtr=_coords->getConstPointer(); - for(int i=0;i c,cI(1); - switch(spaceDim) - { - case 3: - findCommonNodesAlg<3>(bbox,nbNodesOld,limitNodeId,prec,c,cI); - break; - case 2: - findCommonNodesAlg<2>(bbox,nbNodesOld,limitNodeId,prec,c,cI); - break; - case 1: - findCommonNodesAlg<1>(bbox,nbNodesOld,limitNodeId,prec,c,cI); - break; - default: - throw INTERP_KERNEL::Exception("Unexpected spacedim of coords. Must be 1, 2 or 3."); - } - commIndex->alloc(cI.size(),1); - std::copy(cI.begin(),cI.end(),commIndex->getPointer()); - comm->alloc(cI.back(),1); - std::copy(c.begin(),c.end(),comm->getPointer()); + if(!_coords) + throw INTERP_KERNEL::Exception("MEDCouplingPointSet::findCommonNodes : no coords specified !"); + _coords->findCommonTuples(prec,limitNodeId,comm,commIndex); } std::vector MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index e6125afe1..eba412ecd 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -64,10 +64,10 @@ namespace ParaMEDMEM bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const; virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0; virtual DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0; - DataArrayInt *buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const; + DataArrayInt *buildPermArrayForMergeNode(double precision, int limitNodeId, bool& areNodesMerged, int& newNbOfNodes) const; std::vector getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception); void getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector& c, std::vector& cI) const throw(INTERP_KERNEL::Exception); - void findCommonNodes(int limitNodeId, double prec, DataArrayInt *&comm, DataArrayInt *&commIndex) const; + void findCommonNodes(double prec, int limitNodeId, DataArrayInt *&comm, DataArrayInt *&commIndex) const; DataArrayInt *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex, int& newNbOfNodes) const; void getBoundingBox(double *bbox) const; @@ -113,9 +113,6 @@ namespace ParaMEDMEM void project2DCellOnXY(const int *startConn, const int *endConn, std::vector& res) const; static bool isButterfly2DCell(const std::vector& res, bool isQuad); template - void findCommonNodesAlg(std::vector& bbox, - int nbNodes, int limitNodeId, double prec, std::vector& c, std::vector& cI) const; - template void findNodeIdsNearPointAlg(std::vector& bbox, const double *pos, int nbNodes, double eps, std::vector& c, std::vector& cI) const; protected: diff --git a/src/MEDCoupling/MEDCouplingPointSet.txx b/src/MEDCoupling/MEDCouplingPointSet.txx index 9bd37459f..62324e9f4 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.txx +++ b/src/MEDCoupling/MEDCouplingPointSet.txx @@ -27,49 +27,6 @@ namespace ParaMEDMEM { - template - void MEDCouplingPointSet::findCommonNodesAlg(std::vector& bbox, - int nbNodes, int limitNodeId, double prec, - std::vector& c, std::vector& cI) const - { - const double *coordsPtr=_coords->getConstPointer(); - BBTree myTree(&bbox[0],0,0,nbNodes,-prec); - double bb[2*SPACEDIM]; - double prec2=prec*prec; - std::vector isDone(nbNodes); - for(int i=0;i intersectingElems; - myTree.getIntersectingElems(bb,intersectingElems); - if(intersectingElems.size()>1) - { - std::vector commonNodes; - for(std::vector::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++) - if(*it!=i) - if(*it>=limitNodeId) - if(INTERP_KERNEL::distance2(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it)) void MEDCouplingPointSet::findNodeIdsNearPointAlg(std::vector& bbox, const double *pos, int nbNodes, double eps, std::vector& c, std::vector& cI) const diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 9800c8baf..9ace409e8 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -22,7 +22,9 @@ #include "MEDCouplingAutoRefCountObjectPtr.hxx" #include +#include #include +#include #include using namespace ParaMEDMEM; diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index eab8240ce..151849e87 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -18,6 +18,7 @@ // #include "MEDCouplingUMesh.hxx" +#include "MEDCouplingMemArray.txx" #include "MEDCouplingFieldDouble.hxx" #include "CellModel.hxx" #include "VolSurfUser.txx" @@ -373,7 +374,7 @@ void MEDCouplingUMesh::checkDeepEquivalWith(const MEDCouplingMesh *other, int ce bool areNodesMerged; int newNbOfNodes; int oldNbOfNodes=getNumberOfNodes(); - MEDCouplingAutoRefCountObjectPtr da=m->buildPermArrayForMergeNode(oldNbOfNodes,prec,areNodesMerged,newNbOfNodes); + MEDCouplingAutoRefCountObjectPtr da=m->buildPermArrayForMergeNode(prec,oldNbOfNodes,areNodesMerged,newNbOfNodes); //mergeNodes if(!areNodesMerged) throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Nodes are incompatible ! "); @@ -1192,7 +1193,7 @@ bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int com */ DataArrayInt *MEDCouplingUMesh::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) { - DataArrayInt *ret=buildPermArrayForMergeNode(-1,precision,areNodesMerged,newNbOfNodes); + DataArrayInt *ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes); if(areNodesMerged) renumberNodes(ret->getConstPointer(),newNbOfNodes); return ret; @@ -1203,7 +1204,7 @@ DataArrayInt *MEDCouplingUMesh::mergeNodes(double precision, bool& areNodesMerge */ DataArrayInt *MEDCouplingUMesh::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) { - DataArrayInt *ret=buildPermArrayForMergeNode(-1,precision,areNodesMerged,newNbOfNodes); + DataArrayInt *ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes); if(areNodesMerged) renumberNodes2(ret->getConstPointer(),newNbOfNodes); return ret; @@ -1229,7 +1230,7 @@ void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& ot setCoords(newCoords); bool areNodesMerged; int newNbOfNodes; - MEDCouplingAutoRefCountObjectPtr da=buildPermArrayForMergeNode(otherNbOfNodes,epsilon,areNodesMerged,newNbOfNodes); + MEDCouplingAutoRefCountObjectPtr da=buildPermArrayForMergeNode(epsilon,otherNbOfNodes,areNodesMerged,newNbOfNodes); if(!areNodesMerged) { setCoords(oldCoords); diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx index 9f956fa6b..1b1b3dbb5 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx @@ -22,6 +22,7 @@ #include "MEDCouplingMemArray.hxx" #include +#include using namespace ParaMEDMEM; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 7820cfa33..a4778c3a7 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -25,6 +25,7 @@ #include "MEDCouplingMemArray.hxx" #include +#include #include using namespace ParaMEDMEM; @@ -1159,7 +1160,7 @@ void MEDCouplingBasicsTest1::testFindCommonNodes() { DataArrayInt *comm,*commI; MEDCouplingUMesh *targetMesh=build3DTargetMesh_1(); - targetMesh->findCommonNodes(-1,1e-10,comm,commI); + targetMesh->findCommonNodes(1e-10,-1,comm,commI); CPPUNIT_ASSERT_EQUAL(1,commI->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(0,comm->getNumberOfTuples()); int newNbOfNodes; @@ -1179,7 +1180,7 @@ void MEDCouplingBasicsTest1::testFindCommonNodes() // targetMesh=build3DTargetMeshMergeNode_1(); CPPUNIT_ASSERT_EQUAL(31,targetMesh->getNumberOfNodes()); - targetMesh->findCommonNodes(-1,1e-10,comm,commI); + targetMesh->findCommonNodes(1e-10,-1,comm,commI); CPPUNIT_ASSERT_EQUAL(3,commI->getNumberOfTuples()); CPPUNIT_ASSERT_EQUAL(6,comm->getNumberOfTuples()); const int commExpected[6]={1,27,28,29,23,30}; diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx index 9c5c4bf12..2c04b3959 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx @@ -26,6 +26,7 @@ #include "MEDCouplingGaussLocalization.hxx" #include +#include #include #include diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 381eec04b..51a097a27 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -690,10 +690,10 @@ namespace ParaMEDMEM return res; } - PyObject *findCommonNodes(int limitNodeId, double prec) const throw(INTERP_KERNEL::Exception) + PyObject *findCommonNodes(double prec, int limitNodeId=-1) const throw(INTERP_KERNEL::Exception) { DataArrayInt *comm, *commIndex; - self->findCommonNodes(limitNodeId,prec,comm,commIndex); + self->findCommonNodes(prec,limitNodeId,comm,commIndex); PyObject *res = PyList_New(2); PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); @@ -2003,6 +2003,16 @@ namespace ParaMEDMEM return self->keepSelectedComponents(tmp); } + PyObject *findCommonTuples(double prec, int limitNodeId=-1) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *comm, *commIndex; + self->findCommonTuples(prec,limitNodeId,comm,commIndex); + PyObject *res = PyList_New(2); + PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + return res; + } + void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception) { std::vector tmp; diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 5c0889556..c64947c0e 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -778,7 +778,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): def testFindCommonNodes(self): targetMesh=MEDCouplingDataForTest.build3DTargetMesh_1(); - comm,commI=targetMesh.findCommonNodes(-1,1e-10); + comm,commI=targetMesh.findCommonNodes(1e-10,-1); self.assertEqual(1,commI.getNumberOfTuples()); self.assertEqual(0,comm.getNumberOfTuples()); o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI); @@ -789,7 +789,7 @@ class MEDCouplingBasicsTest(unittest.TestCase): # targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1(); self.assertEqual(31,targetMesh.getNumberOfNodes()); - comm,commI=targetMesh.findCommonNodes(-1,1e-10); + comm,commI=targetMesh.findCommonNodes(1e-10);# testing default parameter self.assertEqual(3,commI.getNumberOfTuples()); self.assertEqual(6,comm.getNumberOfTuples()); commExpected=[1,27,28,29,23,30] -- 2.39.2