From 25744e68848161106b35bdab7aae3ac7c35ec971 Mon Sep 17 00:00:00 2001 From: Thomas Feuvrier <thomas.feuvrier@c-s.fr> Date: Wed, 17 Oct 2007 13:00:40 +0000 Subject: [PATCH] =?UTF-8?q?-=20Cast=20pour=20warning=20dans=20test=20if=20?= =?UTF-8?q?-=20Ajout=20ExceptionMacro=20-=20Modification=20su=20rutilisati?= =?UTF-8?q?on=20des=20variable=20de=20direction=20(UPPER,=20LEFT,=20CENTER?= =?UTF-8?q?,=20etc...)=20=20=20->=20D=C3=A9claration=20a=20un=20seul=20end?= =?UTF-8?q?roit.=20Puis=20commentaire=20variable=20non=20utilis=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../otbAddCarvingPathFilter.txx | 10 +++---- .../otbImageToCarvingPathFilter.txx | 28 +++++-------------- .../otbRemoveCarvingPathFilter.txx | 3 +- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/Code/FeatureExtraction/otbAddCarvingPathFilter.txx b/Code/FeatureExtraction/otbAddCarvingPathFilter.txx index 31a9b29d9e..d7e5682e5c 100644 --- a/Code/FeatureExtraction/otbAddCarvingPathFilter.txx +++ b/Code/FeatureExtraction/otbAddCarvingPathFilter.txx @@ -20,6 +20,7 @@ #define __otbAddCarvingPathFilter_txx #include "otbAddCarvingPathFilter.h" +#include "itkMacro.h" namespace otb { @@ -82,6 +83,7 @@ AddCarvingPathFilter<TInputImage,TInputPath,TOutputImage> typename InputPathType::VertexListType::ConstPointer vertexList = inputPath->GetVertexList(); typename InputPathType::VertexListType::ConstIterator pathIterator; typename InputImageType::IndexType indexToAdd; + typedef typename InputImageType::IndexType::IndexValueType IndexValueType; typename InputImageType::SizeType inputSize; inputSize = inputImage->GetLargestPossibleRegion().GetSize(); @@ -112,20 +114,18 @@ AddCarvingPathFilter<TInputImage,TInputPath,TOutputImage> --pathIterator; if(index[dir1] != indexToAdd[dir1]) { - std::cout << "Error : " << index[dir1] << " , " << indexToAdd[dir1] << std::endl; + itkExceptionMacro(<< "Error : " << index[dir1] << " , " << indexToAdd[dir1]); } } - if (flag || ((index[dir0] != indexToAdd[dir0]) && (index[dir0] < inputSize[dir0]))) + if ( (flag==true) || ((index[dir0] != indexToAdd[dir0]) && (index[dir0] < static_cast<IndexValueType>(inputSize[dir0])))) { outputIterator.Set(inputIterator.Get()); ++inputIterator; } else { -// std::cout << "Adding the value at " << outputIterator.GetIndex() << std::endl; flag = true; -// std::cout << "[" << index[0] << "," << index[1] << "] "; OutputImagePixelType newValue; newValue = (--inputIterator).Get(); newValue += (++inputIterator).Get(); @@ -139,7 +139,7 @@ AddCarvingPathFilter<TInputImage,TInputPath,TOutputImage> if((outputIterator.GetIndex())[dir0] != (inputIterator.GetIndex())[dir0]+1) { - std::cout << "Error 2: "<< (outputIterator.GetIndex())[dir0] << " , " << (inputIterator.GetIndex())[dir0] << std::endl; + itkExceptionMacro(<< "Error 2: "<< (outputIterator.GetIndex())[dir0] << " , " << (inputIterator.GetIndex())[dir0]); } inputIterator.NextLine(); outputIterator.NextLine(); diff --git a/Code/FeatureExtraction/otbImageToCarvingPathFilter.txx b/Code/FeatureExtraction/otbImageToCarvingPathFilter.txx index b051badd27..89542db21e 100644 --- a/Code/FeatureExtraction/otbImageToCarvingPathFilter.txx +++ b/Code/FeatureExtraction/otbImageToCarvingPathFilter.txx @@ -81,47 +81,33 @@ ImageToCarvingPathFilter<TInputImage, TOutputPath> typename IteratorType::OffsetType NEXT; - if (m_Direction == 0) - { - dir0=0; - dir1=1; - const typename IteratorType::OffsetType LEFT ={{-1,0}}; const typename IteratorType::OffsetType RIGHT ={{1,0}}; const typename IteratorType::OffsetType UP ={{0,-1}}; const typename IteratorType::OffsetType DOWN ={{0,1}}; const typename IteratorType::OffsetType LEFTUP ={{-1,-1}}; - const typename IteratorType::OffsetType RIGHTDOWN ={{1,1}}; +// const typename IteratorType::OffsetType RIGHTDOWN ={{1,1}}; const typename IteratorType::OffsetType RIGHTUP ={{1,-1}}; const typename IteratorType::OffsetType LEFTDOWN ={{-1,1}}; - const typename IteratorType::OffsetType CENTER ={{0,0}}; - +// const typename IteratorType::OffsetType CENTER ={{0,0}}; + + if (m_Direction == 0) + { + dir0=0; + dir1=1; UP0 = LEFTUP; UP1 = UP; UP2 = RIGHTUP; NEXT = DOWN; - } else { dir0=1; dir1=0; - - const typename IteratorType::OffsetType LEFT ={{-1,0}}; - const typename IteratorType::OffsetType RIGHT ={{1,0}}; - const typename IteratorType::OffsetType UP ={{0,-1}}; - const typename IteratorType::OffsetType DOWN ={{0,1}}; - const typename IteratorType::OffsetType LEFTUP ={{-1,-1}}; - const typename IteratorType::OffsetType RIGHTDOWN ={{1,1}}; - const typename IteratorType::OffsetType RIGHTUP ={{1,-1}}; - const typename IteratorType::OffsetType LEFTDOWN ={{-1,1}}; - const typename IteratorType::OffsetType CENTER ={{0,0}}; - UP0 = LEFTUP; UP1 = LEFT; UP2 = LEFTDOWN; NEXT = RIGHT; - } /** Compute the energy image top-down or left-right diff --git a/Code/FeatureExtraction/otbRemoveCarvingPathFilter.txx b/Code/FeatureExtraction/otbRemoveCarvingPathFilter.txx index 74b83c7dbd..bb2a0dee22 100644 --- a/Code/FeatureExtraction/otbRemoveCarvingPathFilter.txx +++ b/Code/FeatureExtraction/otbRemoveCarvingPathFilter.txx @@ -20,6 +20,7 @@ #define __otbRemoveCarvingPathFilter_txx #include "otbRemoveCarvingPathFilter.h" +#include "itkMacro.h" namespace otb { @@ -108,7 +109,7 @@ RemoveCarvingPathFilter<TInputImage,TInputPath,TOutputImage> --pathIterator; if(index[dir1] != indexToRemove[dir1]) { - std::cout << "Error!!!" << std::endl; + itkExceptionMacro(<< "Error!!!"); } } if (index[dir0] != indexToRemove[dir0]) -- GitLab