--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+
+// clitk
+#include "clitkExtrude_ggo.h"
+#include "clitkExtrudeGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+ // Init command line
+ GGO(clitkExtrude, args_info);
+ CLITK_INIT;
+
+ // Filter
+ typedef clitk::ExtrudeGenericFilter<args_info_clitkExtrude> FilterType;
+ FilterType::Pointer filter = FilterType::New();
+
+ filter->SetArgsInfo(args_info);
+ try {
+ filter->Update();
+ } catch(std::runtime_error e) {
+ std::cout << e.what() << std::endl;
+ }
+
+ return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef clitkExtrudeGenericFilter_h
+#define clitkExtrudeGenericFilter_h
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT ExtrudeGenericFilter:
+ public ImageToImageGenericFilter<ExtrudeGenericFilter<args_info_type> >
+{
+
+public:
+
+ //--------------------------------------------------------------------
+ ExtrudeGenericFilter();
+
+ //--------------------------------------------------------------------
+ typedef ExtrudeGenericFilter Self;
+ typedef itk::SmartPointer<Self> Pointer;
+ typedef itk::SmartPointer<const Self> ConstPointer;
+
+ //--------------------------------------------------------------------
+ // Method for creation through the object factory
+ // and Run-time type information (and related methods)
+ itkNewMacro(Self);
+ itkTypeMacro(ExtrudeGenericFilter, LightObject);
+
+ //--------------------------------------------------------------------
+ void SetArgsInfo(const args_info_type & a);
+
+ //--------------------------------------------------------------------
+ // Main function called each time the filter is updated
+ template<class InputImageType>
+ void UpdateWithInputImageType();
+
+protected:
+ template<unsigned int Dim> void InitializeImageType();
+ args_info_type mArgsInfo;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkExtrudeGenericFilter.txx"
+#endif
+
+#endif // #define clitkExtrudeGenericFilter_h
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef clitkExtrudeGenericFilter_txx
+#define clitkExtrudeGenericFilter_txx
+
+// itk include
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+ExtrudeGenericFilter<args_info_type>::ExtrudeGenericFilter():
+ ImageToImageGenericFilter<Self>("Extrude")
+{
+ InitializeImageType<2>();
+ InitializeImageType<3>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<unsigned int Dim>
+void ExtrudeGenericFilter<args_info_type>::InitializeImageType()
+{
+ ADD_DEFAULT_IMAGE_TYPES(Dim);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+void ExtrudeGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+{
+ mArgsInfo=a;
+ this->SetIOVerbose(mArgsInfo.verbose_flag);
+
+ if (mArgsInfo.input_given) {
+ this->SetInputFilename(mArgsInfo.input_arg);
+ }
+ if (mArgsInfo.output_given) {
+ this->SetOutputFilename(mArgsInfo.output_arg);
+ }
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<class InputImageType>
+void
+ExtrudeGenericFilter<args_info_type>::UpdateWithInputImageType()
+{
+
+ // Reading input
+ typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+
+ // Main filter
+ typedef typename InputImageType::PixelType PixelType;
+ const int Dim = InputImageType::ImageDimension;
+ typedef itk::Image<PixelType,Dim> ImageType;
+ typedef itk::Image<PixelType,Dim+1> OutputImageType;
+
+ //Create the output
+ typename OutputImageType::IndexType start;
+ typename OutputImageType::SizeType size;
+ typename OutputImageType::PointType origin;
+ typename OutputImageType::SpacingType spacing;
+ typename OutputImageType::DirectionType direction;
+ typename OutputImageType::Pointer output = OutputImageType::New();
+
+ start.Fill(0);
+
+ int extrusionSize(1);
+ if (mArgsInfo.size_given) {
+ if (mArgsInfo.size_arg > 0)
+ extrusionSize = mArgsInfo.size_arg;
+ else {
+ std::cerr << "The size has to be > 0" << std::endl;
+ return;
+ }
+ }
+
+ for (unsigned int i=0; i<Dim; ++i)
+ size[i] = input->GetLargestPossibleRegion().GetSize()[i];
+ size[Dim] = extrusionSize;
+
+ for (unsigned int i=0; i<Dim; ++i)
+ origin[i] = input->GetOrigin()[i];
+ if (mArgsInfo.origin_given)
+ origin[Dim] = mArgsInfo.origin_arg;
+ else
+ origin[Dim] = 0;
+
+ for (unsigned int i=0; i<Dim; ++i)
+ spacing[i] = input->GetSpacing()[i];
+ if (mArgsInfo.spacing_given)
+ spacing[Dim] = mArgsInfo.spacing_arg;
+ else
+ spacing[Dim] = 1;
+
+ for (unsigned int i=0; i<Dim; ++i) {
+ for (unsigned int j=0; j<Dim; ++j)
+ direction[i][j] = input->GetDirection()[i][j];
+ direction[i][Dim] = 0;
+ }
+ for (unsigned int i=0; i<Dim; ++i)
+ direction[Dim][i] = 0;
+ direction[Dim][Dim] = 1;
+
+ typename OutputImageType::RegionType region(start, size);
+ output->SetRegions(region);
+ output->Allocate();
+ output->FillBuffer(0);
+ output->SetOrigin(origin);
+ output->SetSpacing(spacing);
+ output->SetDirection(direction);
+
+ itk::ImageRegionIteratorWithIndex<InputImageType> inputIterator(input, input->GetLargestPossibleRegion());
+ while(!inputIterator.IsAtEnd()) {
+ typename OutputImageType::IndexType pixelIndex;
+ for (unsigned int i=0; i<Dim; ++i)
+ pixelIndex[i] = inputIterator.GetIndex()[i];
+ for (unsigned int i=0; i<extrusionSize; ++i) {
+ pixelIndex[Dim] = i;
+ output->SetPixel(pixelIndex, inputIterator.Get());
+ }
+ ++inputIterator;
+ }
+
+ this->template SetNextOutput<OutputImageType>(output);
+
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkExtrudeGenericFilter_txx