#ifndef VVIMAGE_CXX
#define VVIMAGE_CXX
#include "vvImage.h"
-#include "vtkImageData.h"
#include "clitkCommon.h"
+
+#include <vtkImageData.h>
+#include <vtkImageReslice.h>
+
#include <cassert>
//--------------------------------------------------------------------
vvImage::vvImage() {
- mVtkImages.resize(0);
- mTimeSpacing = 1;
- mTimeOrigin = 0;
+ Init();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+void vvImage::Init() {
+ mTimeSpacing = 1;
+ mTimeOrigin = 0;
+ if (CLITK_EXPERIMENTAL)
+ {
+ mVtkImageReslice = vtkSmartPointer<vtkImageReslice>::New();
+ mVtkImageReslice->SetInterpolationModeToLinear();
+ mVtkImageReslice->AutoCropOutputOn();
+ }
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
vvImage::~vvImage() {
- for (unsigned int i = 0; i < mVtkImages.size(); i++) {
- if (mVtkImages[i] != NULL)
- mVtkImages[i]->Delete();
- }
+ Reset();
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
-void vvImage::SetImage(std::vector<vtkImageData*> images) {
- for (unsigned int i = 0; i < mVtkImages.size(); i++) {
- if (mVtkImages[i] != NULL)
- mVtkImages[i]->Delete();
- }
- mVtkImages.resize(0);
- for (unsigned int i = 0; i < images.size(); i++) {
- mVtkImages.push_back(images[i]);
- }
+void vvImage::Reset() {
+ if (CLITK_EXPERIMENTAL)
+ {
+ for (unsigned int i = 0; i < mVtkImages.size(); i++)
+ mVtkImages[i] = (vtkImageData*)mVtkImageReslice->GetInput(i);
+ mVtkImageReslice->RemoveAllInputs();
+ }
+ for (unsigned int i = 0; i < mVtkImages.size(); i++)
+ mVtkImages[i]->Delete();
+ mVtkImages.resize(0);
+ Init();
}
//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
-void vvImage::AddImage(vtkImageData* image) {
- mVtkImages.push_back(image);
+void vvImage::SetImage(std::vector< vtkImageData* > images) {
+ Reset();
+ for (unsigned int i = 0; i < images.size(); i++)
+ AddImage(images[i]);
}
//--------------------------------------------------------------------
+
//--------------------------------------------------------------------
-void vvImage::Init() {
- for (unsigned int i = 0; i < mVtkImages.size(); i++) {
- if (mVtkImages[i] != NULL)
- mVtkImages[i]->Delete();
- }
- mVtkImages.resize(0);
+void vvImage::AddImage(vtkImageData* image) {
+ if (CLITK_EXPERIMENTAL)
+ {
+ mVtkImageReslice->SetInput(mVtkImages.size(), image);
+ mVtkImageReslice->Update();
+ mVtkImages.push_back( mVtkImageReslice->GetOutput( mVtkImages.size() ) );
+ }
+ else
+ mVtkImages.push_back(image);
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void vvImage::SetTransform(vtkAbstractTransform *transform)
+{
+ mVtkImageReslice->SetResliceTransform(transform);
+}
+//--------------------------------------------------------------------
+
#endif // VVIMAGE_CXX
#include <iostream>
#include <vector>
#include <itkObjectFactory.h>
+#include <vtkSmartPointer.h>
class vtkImageData;
+class vtkImageReslice;
+class vtkAbstractTransform;
class vvImage : public itk::LightObject {
public :
itkNewMacro(Self);
void Init();
+ void Reset();
+
void SetImage(std::vector<vtkImageData*> images);
void AddImage(vtkImageData* image);
const std::vector<vtkImageData*>& GetVTKImages();
void SetTimeSpacing(double s) { mTimeSpacing = s; }
void SetTimeOrigin(double o) { mTimeOrigin = o; }
+ void SetTransform(vtkAbstractTransform *transform);
private:
vvImage();
std::vector<vtkImageData*> mVtkImages;
double mTimeOrigin;
double mTimeSpacing;
-
+ vtkSmartPointer<vtkImageReslice> mVtkImageReslice;
};
#endif