From b15f05e9bae336ca871a152c78519a1b71c89973 Mon Sep 17 00:00:00 2001 From: enk Date: Mon, 16 Apr 2007 10:24:14 +0000 Subject: [PATCH] performance improvement --- src/CONVERTOR/VISU_CommonCellsFilter.cxx | 38 ++++++++++++++---------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/CONVERTOR/VISU_CommonCellsFilter.cxx b/src/CONVERTOR/VISU_CommonCellsFilter.cxx index 6ca42755..fb040b8f 100644 --- a/src/CONVERTOR/VISU_CommonCellsFilter.cxx +++ b/src/CONVERTOR/VISU_CommonCellsFilter.cxx @@ -22,6 +22,15 @@ #include #include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +// TTimerLog +#include "VISU_ConvertorUtils.hxx" + namespace { typedef std::vector 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;iGetId(i)); + if(aResult == aSortedPointIds.end()){ + aGoodCell = false; + break; + } + } + if(aGoodCell) aOutputCellIds.push_back(idCell); + else + continue; + } outputSortedArray.swap(aOutputCellIds); -- 2.39.2