]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Acceleration of algorithm.
authorageay <ageay>
Tue, 30 Nov 2010 07:09:09 +0000 (07:09 +0000)
committerageay <ageay>
Tue, 30 Nov 2010 07:09:09 +0000 (07:09 +0000)
src/MEDCoupling/MEDCouplingPointSet.txx

index 658d6d9c5dab25bbd52ec29d12e7df7d6e9b7b7e..9374a1cb692ee268e0f2bedfd9ccb07a4f387ff5 100644 (file)
@@ -36,30 +36,35 @@ namespace ParaMEDMEM
     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(std::find(c.begin(),c.end(),i)!=c.end())
-          continue;
-        for(int j=0;j<SPACEDIM;j++)
+        if(!isDone[i])
           {
-            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);
-            if(!commonNodes.empty())
+            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)
               {
-                cI.push_back(cI.back()+commonNodes.size()+1);
-                c.push_back(i);
-                c.insert(c.end(),commonNodes.begin(),commonNodes.end());
+                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());
+                  }
               }
           }
       }