Fraxinus  18.10
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();
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);
88  CachedImageDataContainer(std::vector<QString> frames);
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 };
105 typedef boost::shared_ptr<CachedImageDataContainer> CachedImageDataContainerPtr;
106 
112 class cxResource_EXPORT SplitFramesContainer : public ImageDataContainer
113 {
114 public:
117  virtual vtkImageDataPtr get(unsigned index);
118  virtual unsigned size() const;
119 private:
120  std::vector<vtkImageDataPtr> mImages;
121  vtkImageDataPtr mOptionalWholeBase;
122 };
123 
130 class cxResource_EXPORT FramesDataContainer : public ImageDataContainer
131 {
132 public:
133  FramesDataContainer(std::vector<vtkImageDataPtr> images);
134  virtual ~FramesDataContainer() {}
135  virtual vtkImageDataPtr get(unsigned index);
136  virtual unsigned size() const;
137 private:
138  std::vector<vtkImageDataPtr> mImages;
139 };
140 
141 
146 } // namespace cx
147 
148 
149 
150 #endif // CXIMAGEDATACONTAINER_H
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.