]> Creatis software - clitk.git/blobdiff - tools/clitkImageFillRegion.cxx
Reformatted using new coding style
[clitk.git] / tools / clitkImageFillRegion.cxx
index 500f1a6c9037b0d824ceb98375a75f86c7e3c92c..fbb67aa9a5a53b6c2b26216c70c080a2fdb68fde 100644 (file)
@@ -1,7 +1,7 @@
 /*=========================================================================
   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
 
-  Authors belong to: 
+  Authors belong to:
   - University of LYON              http://www.universite-lyon.fr/
   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
@@ -21,7 +21,7 @@
    ------------------------------------------------=
    * @file   clitkImageFillRegion.cxx
    * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
-   * @date   23 Feb 2008 
+   * @date   23 Feb 2008
    ------------------------------------------------=*/
 
 // clitk include
@@ -30,7 +30,8 @@
 #include "clitkIO.h"
 
 //--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
+int main(int argc, char * argv[])
+{
 
   // Init command line
   GGO(clitkImageFillRegion, args_info);
@@ -39,84 +40,74 @@ int main(int argc, char * argv[]) {
   // Read image dimension
   itk::ImageIOBase::Pointer header = clitk::readImageHeader(args_info.input_arg);
   unsigned int dim = header->GetNumberOfDimensions();
-  
+
   // Main filter
   clitk::ImageFillRegionGenericFilter filter;
   filter.SetInputFilename(args_info.input_arg);
   filter.SetOutputFilename(args_info.output_arg);
   filter.SetFillPixelValue(args_info.value_arg);
-  
-  if(!args_info.ellips_flag && !args_info.rect_flag)
-    {
-      std::cerr << "ERROR : No type of region specified!"<< std::endl;
-      exit(-1);
-    }
 
-  if(args_info.ellips_flag && args_info.rect_flag)
-    {
-      std::cerr << "ERROR : Multiple types of regions specified!"<< std::endl;
-      exit(-1);
-    }
+  if(!args_info.ellips_flag && !args_info.rect_flag) {
+    std::cerr << "ERROR : No type of region specified!"<< std::endl;
+    exit(-1);
+  }
+
+  if(args_info.ellips_flag && args_info.rect_flag) {
+    std::cerr << "ERROR : Multiple types of regions specified!"<< std::endl;
+    exit(-1);
+  }
 
-  if(args_info.rect_flag)
-    {
-      if (args_info.size_given && args_info.start_given) {
-       // Check parameters
-       if (args_info.size_given != dim) {
-         std::cerr << "ERROR : image has " << dim << "dimensions, --size should have the same number of values." << std::endl;
-         exit(-1);
-       }
-       if (args_info.start_given != dim) {
-         std::cerr << "ERROR : image has " << dim << "dimensions, --size should have the same number of values." << std::endl;
-         exit(-1);
-       }
-       filter.SetRegion(args_info.size_arg, args_info.start_arg);
+  if(args_info.rect_flag) {
+    if (args_info.size_given && args_info.start_given) {
+      // Check parameters
+      if (args_info.size_given != dim) {
+        std::cerr << "ERROR : image has " << dim << "dimensions, --size should have the same number of values." << std::endl;
+        exit(-1);
       }
-      else {
-       std::cerr << "ERROR : both size and start should be given!"<< std::endl;
-       exit(-1);
+      if (args_info.start_given != dim) {
+        std::cerr << "ERROR : image has " << dim << "dimensions, --size should have the same number of values." << std::endl;
+        exit(-1);
       }
+      filter.SetRegion(args_info.size_arg, args_info.start_arg);
+    } else {
+      std::cerr << "ERROR : both size and start should be given!"<< std::endl;
+      exit(-1);
     }
+  }
 
-  if(args_info.ellips_flag)
-    {
-      
-      std::vector<double> c, a;
-      if (args_info.center_given) 
-       {
-         if (args_info.center_given != dim) 
-           {
-             std::cerr << "ERROR : image has " << dim << "dimensions, --center should have the same number of values." << std::endl;
-             exit(-1);
-           }
-         for(unsigned int i=0; i<dim; i++) 
-           c.push_back(args_info.center_arg[i]);
-       }
-      
-      if (args_info.axes_given) 
-       {
-         if (args_info.axes_given != dim) 
-           {
-             std::cerr << "ERROR : image has " << dim << "dimensions, --axes should have the same number of values." << std::endl;
-             exit(-1);
-           }
-         for(unsigned int i=0; i<dim; i++) 
-           a.push_back(args_info.axes_arg[i]);
-
-       }
-      else
-       for(unsigned int i=0; i<dim; i++) 
-         a.push_back(10.0);
-      
-      if ((args_info.center_given))
-       filter.SetSphericRegion(a,c);
-      else
-       filter.SetSphericRegion(a);
+  if(args_info.ellips_flag) {
+
+    std::vector<double> c, a;
+    if (args_info.center_given) {
+      if (args_info.center_given != dim) {
+        std::cerr << "ERROR : image has " << dim << "dimensions, --center should have the same number of values." << std::endl;
+        exit(-1);
+      }
+      for(unsigned int i=0; i<dim; i++)
+        c.push_back(args_info.center_arg[i]);
     }
-  
+
+    if (args_info.axes_given) {
+      if (args_info.axes_given != dim) {
+        std::cerr << "ERROR : image has " << dim << "dimensions, --axes should have the same number of values." << std::endl;
+        exit(-1);
+      }
+      for(unsigned int i=0; i<dim; i++)
+        a.push_back(args_info.axes_arg[i]);
+
+    } else
+      for(unsigned int i=0; i<dim; i++)
+        a.push_back(10.0);
+
+    if ((args_info.center_given))
+      filter.SetSphericRegion(a,c);
+    else
+      filter.SetSphericRegion(a);
+  }
+
   filter.Update();
 
-  // this is the end my friend  
+  // this is the end my friend
   return 0;
 } // end main