]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
performance improvement
authorenk <enk@opencascade.com>
Mon, 16 Apr 2007 10:24:14 +0000 (10:24 +0000)
committerenk <enk@opencascade.com>
Mon, 16 Apr 2007 10:24:14 +0000 (10:24 +0000)
src/CONVERTOR/VISU_CommonCellsFilter.cxx

index 6ca427555710870fddfcd94425d725e7baf7a301..fb040b8f089b93c48ae2aef99dbda4f2ac1c131b 100644 (file)
 #include <vector>
 #include <map>
 
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+// TTimerLog
+#include "VISU_ConvertorUtils.hxx"
+
 namespace
 {
   typedef std::vector<int> TSortedArray;
@@ -46,6 +55,7 @@ namespace
                 vtkIntArray* inputPointIds,
                 TSortedArray& outputSortedArray)
   {
+    VISU::TTimerLog aTimerLog(MYDEBUG,"GetIdsForCopy");
     if(inputUGrid){
       TSortedArray aSortedPointIds;
       TSortedArray aOutputCellIds;
@@ -59,22 +69,20 @@ namespace
         vtkCell*   aCell = inputUGrid->GetCell(idCell);
         vtkIdList* ptIds = aCell->GetPointIds();
         int aMaxId = ptIds->GetNumberOfIds();
-        int* aPointer = ptIds->GetPointer(0);
-        int* anEndPointer = ptIds->GetPointer(aMaxId + 1);
-        TSortedArray aSortedArray(aPointer, anEndPointer);
-        std::sort(aSortedArray.begin(), aSortedArray.end());
-
-        int aMaxLength = std::max(aSortedArray.size(), aSortedPointIds.size());
-        TSortedArray anIntersectionArray(aMaxLength);
-        TSortedArray::iterator anArrayIter = anIntersectionArray.begin();
-        anArrayIter = std::set_intersection(aSortedArray.begin(),
-                                            aSortedArray.end(),
-                                            aSortedPointIds.begin(),
-                                            aSortedPointIds.end(),
-                                            anArrayIter);
-        anIntersectionArray.erase(anArrayIter, anIntersectionArray.end());
-        if(anIntersectionArray.size() == aSortedArray.size())
+        int nbPointsInCell = ptIds->GetNumberOfIds();
+        bool aGoodCell = true;
+        for(int i=0;i<nbPointsInCell;i++){
+          TSortedArray::iterator aResult = find(aSortedPointIds.begin(),aSortedPointIds.end(),ptIds->GetId(i));
+          if(aResult == aSortedPointIds.end()){
+            aGoodCell = false;
+            break;
+          }
+        }
+        if(aGoodCell)
           aOutputCellIds.push_back(idCell);
+        else
+          continue;
+        
       }
 
       outputSortedArray.swap(aOutputCellIds);