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

index 4b8a17cc0846f406754bde71a54a454e864c3fef..e587b297892922b0055e8192947ba52c141c6915 100644 (file)
@@ -277,33 +277,28 @@ DataArrayInt *MEDCouplingPointSet::buildNewNumberingFromCommonNodesFormat(const
   DataArrayInt *ret=DataArrayInt::New();
   int nbNodesOld=getNumberOfNodes();
   ret->alloc(nbNodesOld,1);
-  std::fill(ret->getPointer(),ret->getPointer()+nbNodesOld,-1);
-  int *retPtr=ret->getPointer();
-  std::vector<int> commRemain(comm->getConstPointer(),comm->getConstPointer()+comm->getNumberOfTuples());
-  std::vector<int> commIRemain(commIndex->getConstPointer(),commIndex->getConstPointer()+commIndex->getNumberOfTuples());
+  int *pt=ret->getPointer();
+  std::fill(pt,pt+nbNodesOld,-1);
+  int nbOfGrps=commIndex->getNumberOfTuples()-1;
+  const int *cIPtr=commIndex->getPointer();
+  const int *cPtr=comm->getPointer();
+  for(int i=0;i<nbOfGrps;i++)
+    pt[cPtr[cIPtr[i]]]=-(i+2);
   int newNb=0;
   for(int iNode=0;iNode<nbNodesOld;iNode++)
     {
-      if(retPtr[iNode]!=-1)
-        continue;
-      if(commRemain.empty())
+      if(pt[iNode]<0)
         {
-          retPtr[iNode]=newNb++;
-          continue;
-        }
-      if(commRemain[0]!=iNode)
-        retPtr[iNode]=newNb;
-      else
-        {
-          for(std::vector<int>::const_iterator iNode2=commRemain.begin();
-              iNode2!=commRemain.begin()+commIRemain[1];iNode2++)
-            retPtr[*iNode2]=newNb;
-          int delta=commIRemain[1];
-          commRemain.erase(commRemain.begin(),commRemain.begin()+commIRemain[1]);
-          commIRemain.erase(commIRemain.begin());
-          std::transform(commIRemain.begin(),commIRemain.end(),commIRemain.begin(),std::bind2nd(std::minus<int>(),delta));
+          if(pt[iNode]==-1)
+            pt[iNode]=newNb++;
+          else
+            {
+              int grpId=-(pt[iNode]+2);
+              for(int j=cIPtr[grpId];j<cIPtr[grpId+1];j++)
+                pt[cPtr[j]]=newNb;
+              newNb++;
+            }
         }
-      newNb++;
     }
   newNbOfNodes=newNb;
   return ret;