Fraxinus  16.5.0-fx-rc4
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 #ifndef CXIMAGEDATACONTAINER_H
33 #define CXIMAGEDATACONTAINER_H
34 
35 #include "cxResourceExport.h"
36 
37 #include "vtkForwardDeclarations.h"
38 #include "cxForwardDeclarations.h"
39 #include <vector>
40 
41 namespace cx
42 {
43 
55 class cxResource_EXPORT CachedImageData
56 {
57 public:
61  explicit CachedImageData(QString filename, vtkImageDataPtr image = NULL);
62  ~CachedImageData();
66  QString getFilename() { return mFilename; }
67  vtkImageDataPtr getImage();
72  bool purge();
73 
74 private:
75  QString mFilename;
76  vtkImageDataPtr mImageData;
77 };
78 typedef boost::shared_ptr<CachedImageData> CachedImageDataPtr;
79 
86 class cxResource_EXPORT ImageDataContainer
87 {
88 public:
89  virtual ~ImageDataContainer() {}
90  virtual vtkImageDataPtr get(unsigned index) = 0;
91  virtual unsigned size() const = 0;
92  bool empty() const { return this->size()==0; }
93  virtual bool purge(unsigned index) { return false; }
94  virtual void purgeAll();
95 };
96 typedef boost::shared_ptr<ImageDataContainer> ImageDataContainerPtr;
97 
104 class cxResource_EXPORT CachedImageDataContainer : public ImageDataContainer
105 {
106 public:
108  CachedImageDataContainer(QString baseFilename, int size);
109  CachedImageDataContainer(std::vector<QString> frames);
110 // CachedImageDataContainer(std::vector<CachedImageDataPtr> frames);
111  virtual ~CachedImageDataContainer();
112  virtual vtkImageDataPtr get(unsigned index);
113  virtual QString getFilename(unsigned index);
114  virtual unsigned size() const;
115  virtual bool purge(unsigned index) { return mImages[index]->purge(); }
120  void setDeleteFilesOnRelease(bool on) { mDeleteFilesOnRelease = on; }
121  void append(QString filename);
122 private:
123  std::vector<CachedImageDataPtr> mImages;
124  bool mDeleteFilesOnRelease;
125 };
126 typedef boost::shared_ptr<CachedImageDataContainer> CachedImageDataContainerPtr;
127 
133 class cxResource_EXPORT SplitFramesContainer : public ImageDataContainer
134 {
135 public:
138  virtual vtkImageDataPtr get(unsigned index);
139  virtual unsigned size() const;
140 private:
141  std::vector<vtkImageDataPtr> mImages;
142  vtkImageDataPtr mOptionalWholeBase;
143 };
144 
151 class cxResource_EXPORT FramesDataContainer : public ImageDataContainer
152 {
153 public:
154  FramesDataContainer(std::vector<vtkImageDataPtr> images);
155  virtual ~FramesDataContainer() {}
156  virtual vtkImageDataPtr get(unsigned index);
157  virtual unsigned size() const;
158 private:
159  std::vector<vtkImageDataPtr> mImages;
160 };
161 
162 
167 } // namespace cx
168 
169 
170 
171 #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:45