1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkImageSliceCollection.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 /** 16 * @class vtkImageSliceCollection 17 * @brief a sorted list of image slice objects 18 * 19 * vtkImageSliceCollection is a vtkPropCollection that maintains 20 * a list of vtkImageSlice objects that are sorted by LayerNumber. 21 * This allows the images to be rendered in the correct order. 22 * @sa 23 * vtkImageSlice vtkImageAssembly 24 */ 25 26 #ifndef vtkImageSliceCollection_h 27 #define vtkImageSliceCollection_h 28 29 #include "vtkImageSlice.h" // to allow inline static-cast 30 #include "vtkPropCollection.h" 31 #include "vtkRenderingImageModule.h" // For export macro 32 33 class VTKRENDERINGIMAGE_EXPORT vtkImageSliceCollection : public vtkPropCollection 34 { 35 public: 36 static vtkImageSliceCollection* New(); 37 vtkTypeMacro(vtkImageSliceCollection, vtkPropCollection); 38 void PrintSelf(ostream& os, vtkIndent indent) override; 39 40 /** 41 * Sorts the vtkImageSliceCollection by layer number. Smaller layer 42 * numbers are first. Layer numbers can be any integer value. Items 43 * with the same layer number will be kept in the same relative order 44 * as before the sort. 45 */ 46 void Sort(); 47 48 /** 49 * Add an image to the list. The new image is inserted in the list 50 * according to its layer number. 51 */ 52 void AddItem(vtkImageSlice* a); 53 54 /** 55 * Standard Collection methods. You must call InitTraversal 56 * before calling GetNextImage. If possible, you should use the 57 * GetNextImage method that takes a collection iterator instead. 58 */ 59 vtkImageSlice* GetNextImage(); 60 61 /** 62 * Reentrant safe way to get an object in a collection. 63 */ 64 vtkImageSlice* GetNextImage(vtkCollectionSimpleIterator& cookie); 65 66 /** 67 * Access routine provided for compatibility with previous 68 * versions of VTK. Please use the GetNextImage() variant 69 * where possible. 70 */ GetNextItem()71 vtkImageSlice* GetNextItem() { return this->GetNextImage(); } 72 73 protected: 74 vtkImageSliceCollection() = default; 75 ~vtkImageSliceCollection() override; 76 77 void DeleteElement(vtkCollectionElement*) override; 78 79 private: 80 // hide the standard AddItem from the user and the compiler. AddItem(vtkObject * o)81 void AddItem(vtkObject* o) { this->vtkCollection::AddItem(o); } AddItem(vtkProp * o)82 void AddItem(vtkProp* o) { this->vtkPropCollection::AddItem(o); } 83 84 private: 85 vtkImageSliceCollection(const vtkImageSliceCollection&) = delete; 86 void operator=(const vtkImageSliceCollection&) = delete; 87 }; 88 GetNextImage()89inline vtkImageSlice* vtkImageSliceCollection::GetNextImage() 90 { 91 return static_cast<vtkImageSlice*>(this->GetNextItemAsObject()); 92 } 93 GetNextImage(vtkCollectionSimpleIterator & cookie)94inline vtkImageSlice* vtkImageSliceCollection::GetNextImage(vtkCollectionSimpleIterator& cookie) 95 { 96 return static_cast<vtkImageSlice*>(this->GetNextItemAsObject(cookie)); 97 } 98 99 #endif 100