]> Creatis software - clitk.git/blobdiff - segmentation/clitkMorphoMathFilter.txx
Remove warnings
[clitk.git] / segmentation / clitkMorphoMathFilter.txx
index 81356df1c808a66cebda79e307746c6710258524..8b380c8c9b45f8dd414b1cdecccfc05c10924dbe 100644 (file)
@@ -85,15 +85,9 @@ template<class ImageType>
 void clitk::MorphoMathFilter<ImageType>::
 SetOperationType(int type)
 {
-  switch (type) {
-  case 0: m_OperationType = Erode; return;
-  case 1: m_OperationType = Dilate; return;
-  case 2: m_OperationType = Open; return;
-  case 3: m_OperationType = Close; return;
-  case 4: m_OperationType = CondErode; return;
-  case 5: m_OperationType = CondDilate; return;
-  default: clitkExceptionMacro("Operation type must be between 0-5 (0=Erode, 1=Dilate, 2=Close (erode(dilate(x))), 3=Open (dilate(erode(x))), 4=CondErode, 5=CondDilate)");
-  }    
+  if(type<0 || type>5)
+    clitkExceptionMacro("Operation type must be between 0-5 (0=Erode, 1=Dilate, 2=Close (erode(dilate(x))), 3=Open (dilate(erode(x))), 4=CondErode, 5=CondDilate)");
+  m_OperationType = OperationTypeEnumeration(type);
 }
 //--------------------------------------------------------------------
 
@@ -123,6 +117,7 @@ GenerateOutputInformation()
   // Define the images
   //---------------------------------
   ImagePointer m_input = dynamic_cast<ImageType*>(itk::ProcessObject::GetInput(0));
+  const unsigned int dim = ImageType::ImageDimension;
 
   //---------------------------------
   // Cast into internalimagetype
@@ -137,7 +132,7 @@ GenerateOutputInformation()
   // Compute the radius in pixel
   //---------------------------------
   if (m_RadiusInMMIsSet) {
-    for(uint i=0; i<ImageType::ImageDimension; i++) {
+    for(uint i=0; i<dim; i++) {
       m_Radius[i] = (uint)lrint(m_RadiusInMM[i]/input->GetSpacing()[i]);
     }
   }
@@ -151,7 +146,7 @@ GenerateOutputInformation()
     padFilter->SetInput(input);
     typename ImageType::SizeType lower;
     typename ImageType::SizeType upper;
-    for(uint i=0; i<3; i++) {
+    for(uint i=0; i<dim; i++) {
       lower[i] = upper[i] = 2*(m_Radius[i]+1);
     }
     padFilter->SetPadLowerBound(lower);