-/*
-# ---------------------------------------------------------------------
-#
-# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
-# pour la Sante)
-# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
-# Previous Authors : Laurent Guigues, Jean-Pierre Roux
-# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
-#
-# This software is governed by the CeCILL-B license under French law and
-# abiding by the rules of distribution of free software. You can use,
-# modify and/ or redistribute the software under the terms of the CeCILL-B
-# license as circulated by CEA, CNRS and INRIA at the following URL
-# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-# or in the file LICENSE.txt.
-#
-# As a counterpart to the access to the source code and rights to copy,
-# modify and redistribute granted by the license, users are provided only
-# with a limited warranty and the software's author, the holder of the
-# economic rights, and the successive licensors have only limited
-# liability.
-#
-# The fact that you are presently reading this means that you have had
-# knowledge of the CeCILL-B license and that you accept its terms.
-# ------------------------------------------------------------------------
-*/
-
-#include "creaVtkFromVtk4DToItk4D.h"
-//#include "itkImage.h"
-
-//#include <itkImageRegionConstIteratorWithIndex.h>
-
-
-//#include "itkImageRegionConstIterator.h"
-#include "itkImageRegionIterator.h"
-// #include "itkImageFileReader.h"
-#include <vector>
-
-//template <class TImage>
-//creaVtkFromVtk4DToItk4D<TImage>::creaVtkFromVtk4DToItk4D()
-creaVtkFromVtk4DToItk4D::creaVtkFromVtk4DToItk4D()
-{
-}
-
-//EED template <class TImage>
-//EED creaVtkFromVtk4DToItk4D<TImage>::~creaVtkFromVtk4DToItk4D()
-creaVtkFromVtk4DToItk4D::~creaVtkFromVtk4DToItk4D()
-{
-}
-
-//EED template <class TImage>
-//EED void creaVtkFromVtk4DToItk4D<TImage>::SetImage4D(TImage *image)
-//EED {
-//EED _image4D = image;
-//EED }
-
-
-Image4DType::Pointer creaVtkFromVtk4DToItk4D::GetResult()
-{
- return _image4D;
-}
-
-
-//EED template <class TImage>
-//EED void creaVtkFromVtk4DToItk4D<TImage>::SetImage4Dvtk( std::vector<vtkImageData*> image)
-void creaVtkFromVtk4DToItk4D::SetImage4Dvtk( std::vector<vtkImageData*> image)
-{
- _image4Dvtk = image;
-}
-
-//EED template <class TImage>
-//EED std::vector<itk::Image< unsigned char > > creaVtkFromVtk4DToItk4D<TImage>::Process()
-void creaVtkFromVtk4DToItk4D::Process()
-{
- /*
- int dir;
- double pv[65];
- int count = 0;
- typedef itk::ImageLinearConstIteratorWithIndex< TImage > ConstIteratorType;
- const unsigned int Dimension = 4;
- typedef unsigned char PixelType;
- typedef itk::Image< PixelType, Dimension > ImageType;
-
- ConstIteratorType inputIt( _image4D, inputRegion );
- inputIt.SetDirection(3);
- inputIt.GoToBegin();
-
- ImageType::RegionType outputRegion;
- ImageType::RegionType::IndexType outputStart;
- outputStart[0] = 0;
- outputStart[1] = 0;
- outputRegion.SetSize( size );
- outputRegion.SetIndex( outputStart );
-
- while( !inputIt.IsAtEnd() )
- {
- inputIt.GoToBeginOfLine();
- count = 0;
- while( !inputIt.IsAtEndOfLine() )
- {
- pv[count] = inputIt.Get();
- ++inputIt;
- ++count;
- }
- }
-*/
-
-
-/* EED2
- const unsigned int Dimension = 4;
- typedef unsigned char PixelType;
- typedef itk::Image< PixelType, Dimension > ImageType;
- typedef itk::ImageRegionConstIterator< ImageType > ConstIteratorType;
- typedef itk::ImageRegionIterator< ImageType> IteratorType;
-
- //typedef itk::ImageFileReader< ImageType > ReaderType;
- //typedef itk::ImageFileWriter< ImageType > WriterType;
-
- ImageType::RegionType inputRegion;
- ImageType::RegionType::IndexType inputStart;
- ImageType::RegionType::SizeType size;
- inputStart[0] = ::atoi( "20" );
- inputStart[1] = ::atoi( "70" );
- size[0] = ::atoi( "210" );
- size[1] = ::atoi( "140" );
- inputRegion.SetSize( size );
- inputRegion.SetIndex( inputStart );
-
- ImageType::RegionType outputRegion;
- ImageType::RegionType::IndexType outputStart;
- outputStart[0] = 0;
- outputStart[1] = 0;
- outputStart[2] = 0;
- outputStart[3] = 0;
- outputRegion.SetSize( size );
- outputRegion.SetIndex( outputStart );
-*/
-
- /*
- ReaderType::Pointer reader = ReaderType::New();
- reader->SetFileName( "foo.vtk" );
- try
- {
- reader->Update();
- }
- catch ( itk::ExceptionObject &err)
- {
- std::cerr << "ExceptionObject caught !" << std::endl;
- std::cerr << err << std::endl;
- return -1;
- }
-
- if ( ! reader->GetOutput()->GetRequestedRegion().IsInside( inputRegion ) )
- {
- std::cerr << "Error" << std::endl;
- std::cerr << "The region " << inputRegion << "is not contained within the input image region "
- << reader->GetOutput()->GetRequestedRegion() << std::endl;
- return -1;
- }*/
-
-
-
-/* EED
- std::vector<ImageType::Pointer> outputImage4D;
- for(int k = 0 ; k < _image4Dvtk.size() ; k++)
- {
- ImageType::Pointer outputImage = ImageType::New();
- outputImage->SetRegions( outputRegion );
- const ImageType::SpacingType& spacing = _image4Dvtk[k]->GetSpacing();
- const ImageType::PointType& inputOrigin = _image4Dvtk[k]->GetOrigin();
- double outputOrigin[ Dimension ];
- for(unsigned int i=0; i< Dimension; i++)
- {
- outputOrigin[i] = inputOrigin[i] + spacing[i] * inputStart[i];
- } // for
- outputImage->SetSpacing( spacing );
- outputImage->SetOrigin( outputOrigin );
- outputImage->Allocate();
-
- ConstIteratorType inputIt( _image4Dvtk[k], inputRegion );
- IteratorType outputIt( outputImage, outputRegion );
- inputIt.GoToBegin();
- outputIt.GoToBegin();
-
- while( !outputIt.IsAtEnd() )
- {
- outputIt.Set( inputIt.Get() );
- ++inputIt;
- ++outputIt;
- } // while
-//EED outputImage4D[k]=outputImage;
- } // for k
-//EED return outputImage4D;
-
-*/
-
-
-
-// http://www.itk.org/pipermail/insight-users/2003-December/005796.html
-// http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/InvertIntensityImageFilter
-
-
- int ext[6];
- int dimX, dimY, dimZ;
- long int sizeimage;
- unsigned int k, i;
-
- _image4Dvtk[0]->GetWholeExtent(ext);
- dimX = ext[1]-ext[0]+1;
- dimY = ext[3]-ext[2]+1;
- dimZ = ext[5]-ext[4]+1;
- sizeimage = dimX*dimY*dimZ;
-
-
-
- typedef itk::ImageRegionIterator< Image4DType > Iterator4D;
-// typedef itk::ImageRegionConstIterator< Image4DType > Iterator4D;
-// typedef itk::ImageRegionConstIteratorWithIndex< Image4DType > Iterator4D;
-
-
- _image4D = Image4DType::New();
-
- Image4DType::RegionType region;
- Image4DType::IndexType start;
- start[0] = 0;
- start[1] = 0;
- start[2] = 0;
- start[3] = 0;
-
- Image4DType::SizeType size;
- unsigned int NumRows = dimX;
- unsigned int NumCols = dimY;
- unsigned int NumSlices = dimZ;
- unsigned int NumVolumes = _image4Dvtk.size();
- size[0] = NumRows;
- size[1] = NumCols;
- size[2] = NumSlices;
- size[3] = NumVolumes;
-
- region.SetSize(size);
- region.SetIndex(start);
-
- _image4D->SetRegions(region);
- _image4D->Allocate();
-
-
-// Iterator4D it4( image4D, image4D->GetBufferedRegion() );
- Iterator4D it4( _image4D, _image4D->GetLargestPossibleRegion() );
- it4.GoToBegin();
- for(k = 0 ; k < _image4Dvtk.size() ; k++)
- {
- unsigned short * ptrVtkImage;
- ptrVtkImage = (unsigned short *)_image4Dvtk[k]->GetScalarPointer();
- for (i=0; i< sizeimage;i++)
- {
- it4.Set( *ptrVtkImage );
-// *it4 = *ptrVtkImage;
-// unsigned short q= it4.Get();
- ++it4;
- ptrVtkImage++;
- }
- }
-}
-//---------------------------------------------
-//Method template
-//---------------------------------------------
-/*
-void creaVtkFromVtk4DToItk4D::FunctionName(int& parameterA)
-{
- parameterA = 2 * parameterA;
- return;
-}
-*/