From 6941c4e83adab84412a10e63830574fa25267e33 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Mon, 1 Oct 2012 11:47:39 +0200
Subject: [PATCH] BUG: 576: compatibility with DefaultDynamicMeshTraits in
 PointSet filters

---
 Code/BasicFilters/otbImageToPointSetFilter.txx            | 8 ++++++--
 .../otbThresholdImageToPointSetFilter.txx                 | 7 +++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Code/BasicFilters/otbImageToPointSetFilter.txx b/Code/BasicFilters/otbImageToPointSetFilter.txx
index 6e6565ef99..1be6aabe30 100644
--- a/Code/BasicFilters/otbImageToPointSetFilter.txx
+++ b/Code/BasicFilters/otbImageToPointSetFilter.txx
@@ -219,6 +219,7 @@ ImageToPointSetFilter<TInputImage, TOutputPointSet>
 {
   // copy the lists to the output
   PointsContainerType * outputPointsContainer = this->GetOutput()->GetPoints();
+  unsigned long currentIndex = outputPointsContainer->Size();
 
   typedef typename PointsContainerType::ConstIterator OutputPointsContainerIterator;
   for (unsigned int i = 0; i < this->m_PointsContainerPerThread.size(); ++i)
@@ -229,12 +230,14 @@ ImageToPointSetFilter<TInputImage, TOutputPointSet>
            it != this->m_PointsContainerPerThread[i]->End();
            ++it)
         {
-        outputPointsContainer->push_back(it.Value());
+        outputPointsContainer->InsertElement(currentIndex,it.Value());
+        ++currentIndex;
         }
       }
     }
 
   PointDataContainerType * outputPointDataContainer = this->GetOutput()->GetPointData();
+  currentIndex = outputPointDataContainer->Size();
 
   typedef typename PointDataContainerType::ConstIterator OutputPointDataContainerIterator;
   for (unsigned int i = 0; i < this->m_PointDataContainerPerThread.size(); ++i)
@@ -245,7 +248,8 @@ ImageToPointSetFilter<TInputImage, TOutputPointSet>
            it != this->m_PointDataContainerPerThread[i]->End();
            ++it)
         {
-        outputPointDataContainer->push_back(it.Value());
+        outputPointDataContainer->InsertElement(currentIndex,it.Value());
+        ++currentIndex;
         }
       }
     }
diff --git a/Code/FeatureExtraction/otbThresholdImageToPointSetFilter.txx b/Code/FeatureExtraction/otbThresholdImageToPointSetFilter.txx
index 3676b6404e..92622560b7 100644
--- a/Code/FeatureExtraction/otbThresholdImageToPointSetFilter.txx
+++ b/Code/FeatureExtraction/otbThresholdImageToPointSetFilter.txx
@@ -51,6 +51,8 @@ ThresholdImageToPointSetFilter<TInputImage, TOutputPointSet>
 
   typename OutputPointSetType::PointType position;
   inputIt.GoToBegin();
+  
+  unsigned long currentIndex = 0;
 
   while (!inputIt.IsAtEnd())
     {
@@ -61,8 +63,9 @@ ThresholdImageToPointSetFilter<TInputImage, TOutputPointSet>
       const IndexType index = inputIt.GetIndex();
       position[0] = index[0];
       position[1] = index[1];
-      this->m_PointsContainerPerThread[threadId]->push_back(position);
-      this->m_PointDataContainerPerThread[threadId]->push_back(static_cast<typename PointDataContainerType::Element>(value));
+      this->m_PointsContainerPerThread[threadId]->InsertElement(currentIndex,position);
+      this->m_PointDataContainerPerThread[threadId]->InsertElement(currentIndex,static_cast<typename PointDataContainerType::Element>(value));
+      ++currentIndex;
       }
     ++inputIt;
     progress.CompletedPixel();  // potential exception thrown here
-- 
GitLab