// vtk
#include <vtkImageData.h>
-#include <vtkImageReslice.h>
#include <vtkTransform.h>
// std
//--------------------------------------------------------------------
vvImage::~vvImage()
{
- // DD("vvImage got deleted!");
Reset();
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void vvImage::Reset()
{
- mVtkImages.resize(0);
- mTransformedVtkImages.resize(0);
- mVtkImageReslice.resize(0);
-
+ mVtkImages.clear();
Init();
}
//--------------------------------------------------------------------
}
//--------------------------------------------------------------------
-//--------------------------------------------------------------------
-const std::vector<vtkImageData*>& vvImage::GetTransformedVTKImages()
-{
- return mTransformedVtkImages;
-}
-//--------------------------------------------------------------------
-
//--------------------------------------------------------------------
vtkImageData* vvImage::GetFirstVTKImageData()
{
return false;
}
}
-
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//--------------------------------------------------------------------
-//--------------------------------------------------------------------
-void vvImage::UpdateReslice()
-{
- for (unsigned int i=0; i<mVtkImageReslice.size(); i++) {
- mVtkImageReslice[i]->Update();
- }
-}
-//--------------------------------------------------------------------
-
-
//--------------------------------------------------------------------
bool vvImage::HaveSameSizeAndSpacingThan(vvImage * other)
{
#include <itkObjectFactory.h>
#include <itkProcessObject.h>
-#include <vtkImageReslice.h>
#include <vtkSmartPointer.h>
#include <vtkTransform.h>
void Reset();
template<class TItkImageType> void AddItkImage(TItkImageType *input);
const std::vector<vtkImageData*>& GetVTKImages();
- const std::vector<vtkImageData*>& GetTransformedVTKImages();
vtkImageData* GetFirstVTKImageData();
int GetNumberOfDimensions() const;
int GetNumberOfSpatialDimensions();
vtkSmartPointer<vtkTransform> GetTransform();
void SetTimeSpacing(double s) { mTimeSpacing = s; }
void SetTimeOrigin(double o) { mTimeOrigin = o; }
- void UpdateReslice();
bool HaveSameSizeAndSpacingThan(vvImage * other);
private:
std::vector< ConverterPointer > mItkToVtkConverters;
std::vector<vtkImageData*> mVtkImages;
-
- std::vector< vtkSmartPointer<vtkImageReslice> > mVtkImageReslice;
vtkSmartPointer<vtkTransform> mTransform;
- std::vector<vtkImageData*> mTransformedVtkImages;
double mTimeOrigin;
double mTimeSpacing;
converter->Update();
mVtkImages.push_back( converter->GetOutput() );
- // Account for direction in transform. The offset is already accounted for
+ // Account for direction in transform. The offset is already accounted for
// in the VTK image coordinates, no need to put it in the transform.
vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
matrix->Identity();
for(unsigned int i=0; i<input->GetImageDimension(); i++)
(*matrix)[i][j] = input->GetDirection()[i][j];
mTransform->SetMatrix(matrix);
-
- // Create the corresponding transformed image
- mVtkImageReslice.push_back(vtkSmartPointer<vtkImageReslice>::New());
- mVtkImageReslice.back()->SetInterpolationModeToLinear();
- mVtkImageReslice.back()->AutoCropOutputOn();
- mVtkImageReslice.back()->SetBackgroundColor(-1000,-1000,-1000,1);
- mVtkImageReslice.back()->SetResliceTransform(mTransform);
- mVtkImageReslice.back()->SetInput(0, converter->GetOutput());
- mVtkImageReslice.back()->UpdateInformation();
- mTransformedVtkImages.push_back( mVtkImageReslice.back()->GetOutput(0) );
}
//--------------------------------------------------------------------