Skip to content
Snippets Groups Projects
Commit 25744e68 authored by Thomas Feuvrier's avatar Thomas Feuvrier
Browse files

- Cast pour warning dans test if

- Ajout ExceptionMacro
- Modification su rutilisation des variable de direction (UPPER, LEFT, CENTER, etc...)
  -> Déclaration a un seul endroit. Puis commentaire variable non utilisée
parent 435f482e
Branches
Tags
No related merge requests found
......@@ -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();
......
......@@ -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
......
......@@ -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])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment