From ef9b02c88f132a17f2292e84b4167c22e1b87f8d Mon Sep 17 00:00:00 2001 From: dsarrut Date: Wed, 7 Jul 2010 06:57:56 +0000 Subject: [PATCH] change GetScalarTypeAsString to GetScalarTypeAsITKString to make explicit that type name string is the convention of ITK (not VTK) --- common/vvImage.cxx | 16 +++++++++++++++- common/vvImage.h | 22 +++++++++------------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/common/vvImage.cxx b/common/vvImage.cxx index cbcf749..797fa3e 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -138,7 +138,7 @@ void vvImage::GetScalarRange(double* range) } //-------------------------------------------------------------------- -std::string vvImage::GetScalarTypeAsString() +std::string vvImage::GetScalarTypeAsITKString() { // WARNING VTK pixel type different from ITK Pixel type std::string vtktype = mVtkImages[0]->GetScalarTypeAsString(); @@ -295,4 +295,18 @@ void vvImage::UpdateReslice() } //-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +vtkImageData * CopyAndCastToFloatFrom(vtkImageData * input) +{ + vtkImageData * p = vtkImageData::New(); + p->SetExtent(input->GetExtent ()); // Only first ! could not be 4D + p->SetScalarTypeToFloat(); + p->AllocateScalars(); + p->CopyAndCastFrom(input, input->GetExtent()); + return p; +} +//-------------------------------------------------------------------- + + #endif // VVIMAGE_CXX diff --git a/common/vvImage.h b/common/vvImage.h index 38348ee..7dbba1f 100644 --- a/common/vvImage.h +++ b/common/vvImage.h @@ -29,6 +29,7 @@ class vtkTransform; class vtkImageReslice; class vtkAbstractTransform; +//------------------------------------------------------------------------------ class vvImage : public itk::LightObject { public : @@ -38,37 +39,27 @@ public : void Init(); void Reset(); - void SetImage(std::vector images); void AddImage(vtkImageData* image); const std::vector& GetVTKImages(); vtkImageData* GetFirstVTKImageData(); - int GetNumberOfDimensions() const; int GetNumberOfSpatialDimensions(); - ///Writes the scalar range to the provided array, which must have room for two doubles void GetScalarRange(double* range); unsigned long GetActualMemorySize(); std::vector GetSpacing(); std::vector GetOrigin() const; std::vector GetSize(); - std::string GetScalarTypeAsString(); + std::string GetScalarTypeAsITKString(); int GetNumberOfScalarComponents(); int GetScalarSize(); bool IsTimeSequence(); bool IsScalarTypeInteger(); bool IsScalarTypeInteger(int t); - vtkSmartPointer GetTransform(); void SetTransform(vtkSmartPointer transform); - - void SetTimeSpacing(double s) { - mTimeSpacing = s; - } - void SetTimeOrigin(double o) { - mTimeOrigin = o; - } - + void SetTimeSpacing(double s) { mTimeSpacing = s; } + void SetTimeOrigin(double o) { mTimeOrigin = o; } void UpdateReslice(); private: @@ -81,5 +72,10 @@ private: double mTimeOrigin; double mTimeSpacing; }; +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +vtkImageData * CopyAndCastToFloatFrom(vtkImageData * p); +//------------------------------------------------------------------------------ #endif -- 2.45.1