From: tbaudier Date: Tue, 6 Jun 2017 08:16:18 +0000 (+0200) Subject: Debug clitkMaskOfIntegratedIntensityGenericFilter to avoid c++11 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=99ed57bf639e9b161e7aff4a6b0830397d0cfef9;p=clitk.git Debug clitkMaskOfIntegratedIntensityGenericFilter to avoid c++11 --- diff --git a/tools/clitkMaskOfIntegratedIntensityGenericFilter.h b/tools/clitkMaskOfIntegratedIntensityGenericFilter.h index a2df346..3d64550 100644 --- a/tools/clitkMaskOfIntegratedIntensityGenericFilter.h +++ b/tools/clitkMaskOfIntegratedIntensityGenericFilter.h @@ -66,6 +66,9 @@ namespace clitk }; // end class //-------------------------------------------------------------------- +//Implementation of the pair comparative function +template bool comparator ( const std::pair& l, const std::pair& r); + } // end namespace clitk #ifndef ITK_MANUAL_INSTANTIATION diff --git a/tools/clitkMaskOfIntegratedIntensityGenericFilter.txx b/tools/clitkMaskOfIntegratedIntensityGenericFilter.txx index 3096d87..5f91cbd 100644 --- a/tools/clitkMaskOfIntegratedIntensityGenericFilter.txx +++ b/tools/clitkMaskOfIntegratedIntensityGenericFilter.txx @@ -74,11 +74,17 @@ namespace clitk // initialize original index locations std::vector idx(v.size()); - iota(idx.begin(), idx.end(), 0); + std::vector > compVector(v.size()); + for (size_t i = 0; i < v.size(); ++i) { + compVector[i].first = v[i]; + compVector[i].second = i; + } // sort indexes based on comparing values in v - std::sort(idx.begin(), idx.end(), - [&v](size_t i1, size_t i2) {return v[i1] > v[i2];}); + std::sort(compVector.begin(), compVector.end(), comparator); + for (size_t i = 0; i < v.size(); ++i) { + idx[i] = compVector[i].second; + } return idx; } @@ -122,13 +128,13 @@ namespace clitk } // Sort (reverse) - auto indices = sort_indexes(values); + std::vector indices = sort_indexes(values); // Get max index of pixel to reach xx percent double current = 0.0; double max = GetPercentage()/100.0*total; int i=0; - auto n = input->GetLargestPossibleRegion().GetNumberOfPixels(); + int n = input->GetLargestPossibleRegion().GetNumberOfPixels(); std::vector should_keep(values.size());; std::fill(should_keep.begin(), should_keep.end(), 0); while (current +bool comparator ( const std::pair& l, const std::pair& r) + { return l.first < r.first; } +//-------------------------------------------------------------------- }//end clitk