]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
DataArrayDouble::findCommonTuples method.
authorageay <ageay>
Thu, 5 Jan 2012 07:46:37 +0000 (07:46 +0000)
committerageay <ageay>
Thu, 5 Jan 2012 07:46:37 +0000 (07:46 +0000)
19 files changed:
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingExtrudedMesh.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingFieldTemplate.cxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingMemArray.txx
src/MEDCoupling/MEDCouplingMultiFields.cxx
src/MEDCoupling/MEDCouplingPointSet.cxx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingPointSet.txx
src/MEDCoupling/MEDCouplingTimeDiscretization.cxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/MEDCouplingUMeshDesc.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest2.cxx
src/MEDCoupling_Swig/MEDCoupling.i
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py

index 290cd362319dc59cf7f35f9134e5a77dade78347..6daf60045f3157296ac57a455bda344d7d4c717c 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <functional>
 #include <algorithm>
+#include <sstream>
 #include <numeric>
 
 using namespace ParaMEDMEM;
index 8e187d956bc260f4384ac586ecb457d8ec12a282..abd42cbeca21fce96f86a68e365b8417454b88de 100644 (file)
@@ -30,6 +30,7 @@
 #include <algorithm>
 #include <functional>
 #include <iterator>
+#include <sstream>
 #include <cmath>
 #include <list>
 #include <set>
index d9c5734503f0a1b33bdd186d933a2fa564067b60..8800898eab93544abbae0a6f2e7ae738ba917eb4 100644 (file)
@@ -31,6 +31,7 @@
 #include <set>
 #include <list>
 #include <limits>
+#include <sstream>
 #include <algorithm>
 #include <functional>
 
index 0c63601e219a30cea7ab745087bc1bd6ff125ed4..eeb8b0f0748465b183539cae094e79f0bfe57bd6 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <sstream>
 #include <limits>
+#include <algorithm>
 #include <functional>
 
 using namespace ParaMEDMEM;
index fb6680a86e0855d112f39109102d2d277991d2eb..77ecf457781696e51a15bc85d6aa19928cb4114b 100644 (file)
@@ -22,6 +22,8 @@
 #include "MEDCouplingFieldDouble.hxx"
 #include "MEDCouplingFieldDiscretization.hxx"
 
+#include <sstream>
+
 using namespace ParaMEDMEM;
 
 MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception)
index 1addb5ea2cdca7066bd0022c5ebd578a72b6d0bd..eb7c5662bf44f7f8735c8064b7a7aeeba3c3aa93 100644 (file)
@@ -33,6 +33,48 @@ typedef double (*MYFUNCPTR)(double);
 
 using namespace ParaMEDMEM;
 
+template<int SPACEDIM>
+void DataArrayDouble::findCommonTuplesAlg(std::vector<double>& bbox,
+                                          int nbNodes, int limitNodeId, double prec, std::vector<int>& c, std::vector<int>& cI) const
+{
+  const double *coordsPtr=getConstPointer();
+  BBTree<SPACEDIM,int> myTree(&bbox[0],0,0,nbNodes,-prec);
+  double bb[2*SPACEDIM];
+  double prec2=prec*prec;
+  std::vector<bool> isDone(nbNodes);
+  for(int i=0;i<nbNodes;i++)
+    {
+      if(!isDone[i])
+        {
+          for(int j=0;j<SPACEDIM;j++)
+            {
+              bb[2*j]=coordsPtr[SPACEDIM*i+j];
+              bb[2*j+1]=coordsPtr[SPACEDIM*i+j];
+            }
+          std::vector<int> intersectingElems;
+          myTree.getIntersectingElems(bb,intersectingElems);
+          if(intersectingElems.size()>1)
+            {
+              std::vector<int> commonNodes;
+              for(std::vector<int>::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++)
+                if(*it!=i)
+                  if(*it>=limitNodeId)
+                    if(INTERP_KERNEL::distance2<SPACEDIM>(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it))<prec2)
+                      {
+                        commonNodes.push_back(*it);
+                        isDone[*it]=true;
+                      }
+              if(!commonNodes.empty())
+                {
+                  cI.push_back(cI.back()+commonNodes.size()+1);
+                  c.push_back(i);
+                  c.insert(c.end(),commonNodes.begin(),commonNodes.end());
+                }
+            }
+        }
+    }
+}
+
 void DataArray::setName(const char *name)
 {
   _name=name;
@@ -798,6 +840,55 @@ void DataArrayDouble::meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL
   copyPartOfStringInfoFrom2(compIds,*other);
 }
 
+/*!
+ * This methods searches for each tuple if there are any tuples in 'this' that are less far than 'prec' from n1. if any, these tuples are stored in out params
+ * comm and commIndex. The distance is computed using norm2. This method expects that 'this' is allocated and that the number of components is in [1,2,3].
+ * If not an exception will be thrown.
+ * This method is typically used by MEDCouplingPointSet::findCommonNodes and MEDCouplingUMesh::mergeNodes.
+ * @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 DataArrayDouble::findCommonTuples(double prec, int limitNodeId, DataArrayInt *&comm, DataArrayInt *&commIndex) const throw(INTERP_KERNEL::Exception)
+{
+  comm=DataArrayInt::New();
+  commIndex=DataArrayInt::New();
+  //
+  checkAllocated();
+  int nbOfTuples=getNumberOfTuples();
+  int nbOfCompo=getNumberOfComponents();
+  std::vector<double> bbox(2*nbOfTuples*nbOfCompo);
+  const double *coordsPtr=getConstPointer();
+  for(int i=0;i<nbOfTuples;i++)
+    {
+      for(int j=0;j<nbOfCompo;j++)
+        {
+          bbox[2*nbOfCompo*i+2*j]=coordsPtr[nbOfCompo*i+j];
+          bbox[2*nbOfCompo*i+2*j+1]=coordsPtr[nbOfCompo*i+j];
+        }
+    }
+  //
+  std::vector<int> 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<int>& compoIds) throw(INTERP_KERNEL::Exception)
 {
   copyPartOfStringInfoFrom2(compoIds,*a);
index d93191e93c819ea929eca2f064061f861e62aa6c..cc5eb01962ac7162580d31ce690d21b335afd672 100644 (file)
@@ -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<int>& 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<int>& 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<std::string>& tinyInfo) const;
     MEDCOUPLING_EXPORT bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
     MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
+  protected:
+    template<int SPACEDIM>
+    void findCommonTuplesAlg(std::vector<double>& bbox,
+                             int nbNodes, int limitNodeId, double prec, std::vector<int>& c, std::vector<int>& cI) const;
   private:
     DataArrayDouble() { }
   private:
index 197798b51db9cbb840f3f0988ff6f7691ba08553..2868a086736b36a6919e6bb9a3f8a9113295da0a 100644 (file)
@@ -22,6 +22,8 @@
 #include "MEDCouplingMemArray.hxx"
 #include "NormalizedUnstructuredMesh.hxx"
 #include "InterpKernelException.hxx"
+#include "InterpolationUtils.hxx"
+#include "BBTree.txx"
 
 #include <sstream>
 #include <algorithm>
index 86b4955594afd5ea825e4362588bb90ad4b9f3af..a9dc65f76e70855819cd74ae1be8f8a63bcc5704 100644 (file)
@@ -23,6 +23,9 @@
 #include "MEDCouplingMesh.hxx"
 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
 
+#include <sstream>
+#include <algorithm>
+
 using namespace ParaMEDMEM;
 
 MEDCouplingMultiFields *MEDCouplingMultiFields::New(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception)
index f19def6b401065afd0c67db6abd66fb34e2ab18a..cac4884674e6aac9731915f98afecb93fbe31066 100644 (file)
@@ -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<double> bbox(2*nbNodesOld*spaceDim);
-  const double *coordsPtr=_coords->getConstPointer();
-  for(int i=0;i<nbNodesOld;i++)
-    {
-      for(int j=0;j<spaceDim;j++)
-        {
-          bbox[2*spaceDim*i+2*j]=coordsPtr[spaceDim*i+j];
-          bbox[2*spaceDim*i+2*j+1]=coordsPtr[spaceDim*i+j];
-        }
-    }
-  //
-  std::vector<int> 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<int> MEDCouplingPointSet::getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception)
index e6125afe178baf6ec9ced2f8e596a9e49d9c494e..eba412ecdecf2256ab732a9c92db422de760b5a4 100644 (file)
@@ -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<int> getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception);
     void getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& 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<double>& res) const;
     static bool isButterfly2DCell(const std::vector<double>& res, bool isQuad);
     template<int SPACEDIM>
-    void findCommonNodesAlg(std::vector<double>& bbox,
-                            int nbNodes, int limitNodeId, double prec, std::vector<int>& c, std::vector<int>& cI) const;
-    template<int SPACEDIM>
     void findNodeIdsNearPointAlg(std::vector<double>& bbox, const double *pos, int nbNodes, double eps,
                                  std::vector<int>& c, std::vector<int>& cI) const;
   protected:
index 9bd37459f14cbd50cb93206a3f3da49290273680..62324e9f40df16228c1ab8667da3ce13810c141e 100644 (file)
 
 namespace ParaMEDMEM
 {
-  template<int SPACEDIM>
-  void MEDCouplingPointSet::findCommonNodesAlg(std::vector<double>& bbox,
-                                               int nbNodes, int limitNodeId, double prec,
-                                               std::vector<int>& c, std::vector<int>& cI) const
-  {
-    const double *coordsPtr=_coords->getConstPointer();
-    BBTree<SPACEDIM,int> myTree(&bbox[0],0,0,nbNodes,-prec);
-    double bb[2*SPACEDIM];
-    double prec2=prec*prec;
-    std::vector<bool> isDone(nbNodes);
-    for(int i=0;i<nbNodes;i++)
-      {
-        if(!isDone[i])
-          {
-            for(int j=0;j<SPACEDIM;j++)
-              {
-                bb[2*j]=coordsPtr[SPACEDIM*i+j];
-                bb[2*j+1]=coordsPtr[SPACEDIM*i+j];
-              }
-            std::vector<int> intersectingElems;
-            myTree.getIntersectingElems(bb,intersectingElems);
-            if(intersectingElems.size()>1)
-              {
-                std::vector<int> commonNodes;
-                for(std::vector<int>::const_iterator it=intersectingElems.begin();it!=intersectingElems.end();it++)
-                  if(*it!=i)
-                    if(*it>=limitNodeId)
-                      if(INTERP_KERNEL::distance2<SPACEDIM>(coordsPtr+SPACEDIM*i,coordsPtr+SPACEDIM*(*it))<prec2)
-                        {
-                          commonNodes.push_back(*it);
-                          isDone[*it]=true;
-                        }
-                if(!commonNodes.empty())
-                  {
-                    cI.push_back(cI.back()+commonNodes.size()+1);
-                    c.push_back(i);
-                    c.insert(c.end(),commonNodes.begin(),commonNodes.end());
-                  }
-              }
-          }
-      }
-  }
-  
   template<int SPACEDIM>
   void MEDCouplingPointSet::findNodeIdsNearPointAlg(std::vector<double>& bbox, const double *pos, int nbNodes, double eps,
                                                     std::vector<int>& c, std::vector<int>& cI) const
index 9800c8baffbce49b58564cebf88e5da83e38b9e5..9ace409e8f30946eb413a0272c8784db040ea269 100644 (file)
@@ -22,7 +22,9 @@
 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
 
 #include <cmath>
+#include <sstream>
 #include <iterator>
+#include <algorithm>
 #include <functional>
 
 using namespace ParaMEDMEM;
index eab8240cef8e53fe7b88e10279757dd6f66defc3..151849e873219e8cad7d3213bb4e44f60b026fa2 100644 (file)
@@ -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<DataArrayInt> da=m->buildPermArrayForMergeNode(oldNbOfNodes,prec,areNodesMerged,newNbOfNodes);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<DataArrayInt> da=buildPermArrayForMergeNode(otherNbOfNodes,epsilon,areNodesMerged,newNbOfNodes);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=buildPermArrayForMergeNode(epsilon,otherNbOfNodes,areNodesMerged,newNbOfNodes);
   if(!areNodesMerged)
     {
       setCoords(oldCoords);
index 9f956fa6b3821a6ad9a40536b220a9b2a94b79ee..1b1b3dbb570fe043f7a29022981167f61d3471bf 100644 (file)
@@ -22,6 +22,7 @@
 #include "MEDCouplingMemArray.hxx"
 
 #include <limits>
+#include <sstream>
 
 using namespace ParaMEDMEM;
 
index 7820cfa333d4759422f7469cd1394368b977e77e..a4778c3a7b35db77755a1a3e7f026d708de9ec32 100644 (file)
@@ -25,6 +25,7 @@
 #include "MEDCouplingMemArray.hxx"
 
 #include <cmath>
+#include <algorithm>
 #include <functional>
 
 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};
index 9c5c4bf1231289107ea4b82540412441c57d331b..2c04b395904e8097b1a74d679abae772548e88a7 100644 (file)
@@ -26,6 +26,7 @@
 #include "MEDCouplingGaussLocalization.hxx"
 
 #include <cmath>
+#include <algorithm>
 #include <functional>
 #include <iterator>
 
index 381eec04b8ad9f35deb60b59258815117a132acd..51a097a2702094a515153c5b6d27185246953c06 100644 (file)
@@ -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<int> tmp;
index 5c088955687c19e39e88f61170ef26c1964d03f8..c64947c0e6086e41e0ed47ea8c2b5a2980904d88 100644 (file)
@@ -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]