14 #include <vtkImageImport.h> 15 #include <vtkImageData.h> 44 mImageData = filemanager->loadVtkImageData(mFilename);
62 for (
unsigned i=0; i<this->size(); ++i)
76 CachedImageDataContainer::CachedImageDataContainer(QString baseFilename,
int size,
FileManagerServicePtr filemanagerservice) :
77 mDeleteFilesOnRelease(false),
78 mFileManagerService(filemanagerservice)
80 QFileInfo info(baseFilename);
82 for (
int i=0;
true; ++i)
84 QString file = info.absolutePath()+
"/"+info.completeBaseName()+QString(
"_%1.mhd").arg(i);
86 if (!QFileInfo(file).exists())
90 mImages.push_back(cache);
92 if (size>=0 && i>=size)
103 mDeleteFilesOnRelease(false),
104 mFileManagerService(filemanagerservice)
108 CachedImageDataContainer::CachedImageDataContainer(std::vector<QString> frames,
FileManagerServicePtr filemanagerservice) :
109 mDeleteFilesOnRelease(false),
110 mFileManagerService(filemanagerservice)
112 for (
unsigned i=0; i<frames.size(); ++i)
123 if (mDeleteFilesOnRelease)
125 for (
unsigned i=0; i<mImages.size(); ++i)
139 if (index >= this->
size())
141 std::cout << QString(
"Attempt to call index %1, size=%2").arg(index).arg(this->
size()) << std::endl;
145 vtkImageDataPtr retval = mImages[index]->getImage(mFileManagerService);
146 mImages[index]->purge();
152 return mImages[index]->getFilename();
158 return (
unsigned)mImages.size();
167 mOptionalWholeBase = image3D;
168 mImages.resize(image3D->GetDimensions()[2]);
170 for (
int i=0; i<mImages.size(); ++i)
174 import->SetImportVoidPointer(image3D->GetScalarPointer(0,0,i));
175 import->SetDataScalarType(image3D->GetScalarType());
176 import->SetDataSpacing(image3D->GetSpacing());
177 import->SetNumberOfScalarComponents(image3D->GetNumberOfScalarComponents());
183 import->SetWholeExtent(extent.data());
184 import->SetDataExtentToWholeExtent();
187 mImages[i] =
import->GetOutput();
197 return mImages[index];
202 return (
unsigned)mImages.size();
217 return mImages[index];
222 return mImages.size();
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
#define CX_ASSERT(statement)
boost::shared_ptr< CachedImageData > CachedImageDataPtr
virtual QString getFilename(unsigned index)
virtual vtkImageDataPtr get(unsigned index)
CachedImageData(QString filename, vtkImageDataPtr image=NULL)
virtual unsigned size() const
virtual unsigned size() const
virtual unsigned size() const
Representation of an integer bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
virtual ~CachedImageDataContainer()
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
QString changeExtension(QString name, QString ext)
vtkImageDataPtr getImage(FileManagerServicePtr filemanager)
void append(QString filename)
virtual vtkImageDataPtr get(unsigned index)
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
SplitFramesContainer(vtkImageDataPtr image3D)
virtual vtkImageDataPtr get(unsigned index)
FramesDataContainer(std::vector< vtkImageDataPtr > images)
Namespace for all CustusX production code.