CustusX  2021.04.21-dev+develop.337f9
An IGT application
cxImageDataContainer.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #ifndef CXIMAGEDATACONTAINER_H
12 #define CXIMAGEDATACONTAINER_H
13 
14 #include "cxResourceExport.h"
15 
16 #include "vtkForwardDeclarations.h"
17 #include "cxForwardDeclarations.h"
18 #include <vector>
19 
20 namespace cx
21 {
22 
34 class cxResource_EXPORT CachedImageData
35 {
36 public:
40  explicit CachedImageData(QString filename, vtkImageDataPtr image = NULL);
41  ~CachedImageData();
45  QString getFilename() { return mFilename; }
46  vtkImageDataPtr getImage(FileManagerServicePtr filemanager);
51  bool purge();
52 
53 private:
54  QString mFilename;
55  vtkImageDataPtr mImageData;
56 };
57 typedef boost::shared_ptr<CachedImageData> CachedImageDataPtr;
58 
65 class cxResource_EXPORT ImageDataContainer
66 {
67 public:
68  virtual ~ImageDataContainer() {}
69  virtual vtkImageDataPtr get(unsigned index) = 0;
70  virtual unsigned size() const = 0;
71  bool empty() const { return this->size()==0; }
72  virtual bool purge(unsigned index) { return false; }
73  virtual void purgeAll();
74 };
75 typedef boost::shared_ptr<ImageDataContainer> ImageDataContainerPtr;
76 
83 class cxResource_EXPORT CachedImageDataContainer : public ImageDataContainer
84 {
85 public:
87  CachedImageDataContainer(QString baseFilename, int size, FileManagerServicePtr filemanagerservice);
88  CachedImageDataContainer(std::vector<QString> frames, FileManagerServicePtr filemanagerservice);
89 // CachedImageDataContainer(std::vector<CachedImageDataPtr> frames);
90  virtual ~CachedImageDataContainer();
91  virtual vtkImageDataPtr get(unsigned index);
92  virtual QString getFilename(unsigned index);
93  virtual unsigned size() const;
94  virtual bool purge(unsigned index) { return mImages[index]->purge(); }
99  void setDeleteFilesOnRelease(bool on) { mDeleteFilesOnRelease = on; }
100  void append(QString filename);
101 private:
102  std::vector<CachedImageDataPtr> mImages;
103  bool mDeleteFilesOnRelease;
104  FileManagerServicePtr mFileManagerService;
106 };
107 typedef boost::shared_ptr<CachedImageDataContainer> CachedImageDataContainerPtr;
108 
114 class cxResource_EXPORT SplitFramesContainer : public ImageDataContainer
115 {
116 public:
119  virtual vtkImageDataPtr get(unsigned index);
120  virtual unsigned size() const;
121 private:
122  std::vector<vtkImageDataPtr> mImages;
123  vtkImageDataPtr mOptionalWholeBase;
124 };
125 
132 class cxResource_EXPORT FramesDataContainer : public ImageDataContainer
133 {
134 public:
135  FramesDataContainer(std::vector<vtkImageDataPtr> images);
136  virtual ~FramesDataContainer() {}
137  virtual vtkImageDataPtr get(unsigned index);
138  virtual unsigned size() const;
139 private:
140  std::vector<vtkImageDataPtr> mImages;
141 };
142 
143 
148 } // namespace cx
149 
150 
151 
152 #endif // CXIMAGEDATACONTAINER_H
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
boost::shared_ptr< CachedImageData > CachedImageDataPtr
virtual bool purge(unsigned index)
virtual bool purge(unsigned index)
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
boost::shared_ptr< class CachedImageDataContainer > CachedImageDataContainerPtr
boost::shared_ptr< class ImageDataContainer > ImageDataContainerPtr
Definition: cxUSFrameData.h:24
Namespace for all CustusX production code.