ITK  6.0.0
Insight Toolkit
itkSparseImage.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * https://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkSparseImage_h
19 #define itkSparseImage_h
20 
21 #include "itkImage.h"
22 #include "itkSparseFieldLayer.h"
23 #include "itkObjectStore.h"
24 
25 namespace itk
26 {
66 template <typename TNode, unsigned int VImageDimension = 2>
67 class ITK_TEMPLATE_EXPORT SparseImage : public Image<TNode *, VImageDimension>
68 {
69 public:
70  ITK_DISALLOW_COPY_AND_MOVE(SparseImage);
71 
73  using Self = SparseImage;
78 
80  itkNewMacro(Self);
81 
83  itkOverrideGetNameOfClassMacro(SparseImage);
84 
86  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
87 
89  using NodeType = TNode;
90 
92  using typename Superclass::IndexType;
93 
97 
98  using typename Superclass::IOPixelType;
99 
103 
108  {
110  }
111 
114  const NeighborhoodAccessorFunctorType
116  {
118  }
119 
122  NodeType *
123  AddNode(const IndexType & index)
124  {
125  m_NodeList->PushFront(m_NodeStore->Borrow());
126  NodeType * node = m_NodeList->Front();
127  node->m_Index = index;
128  this->SetPixel(index, node);
129  return node;
130  }
135  NodeListType *
137  {
138  return m_NodeList;
139  }
140 
143  void
144  Initialize() override;
145 
146 protected:
147  SparseImage() = default;
148  ~SparseImage() override = default;
149 
150  void
151  PrintSelf(std::ostream & os, Indent indent) const override;
152 
153 private:
155  typename NodeListType::Pointer m_NodeList{ NodeListType::New() };
156 
157  typename NodeStoreType::Pointer m_NodeStore{ NodeStoreType::New() };
158 };
159 } // end namespace itk
160 
161 #ifndef ITK_MANUAL_INSTANTIATION
162 # include "itkSparseImage.hxx"
163 #endif
164 
165 #endif
itk::SparseImage::AddNode
NodeType * AddNode(const IndexType &index)
Definition: itkSparseImage.h:123
itk::Index< VImageDimension >
itk::SparseImage::GetNodeList
NodeListType * GetNodeList()
Definition: itkSparseImage.h:136
itkObjectStore.h
itk::SparseImage::GetNeighborhoodAccessor
NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
Definition: itkSparseImage.h:107
itk::SparseImage::GetNeighborhoodAccessor
const NeighborhoodAccessorFunctorType GetNeighborhoodAccessor() const
Definition: itkSparseImage.h:115
itkImage.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::NeighborhoodAccessorFunctor
Provides accessor interfaces to Get pixels and is meant to be used on pointers contained within Neigh...
Definition: itkNeighborhoodAccessorFunctor.h:41
itk::SparseFieldLayer
A very simple linked list that is used to manage nodes in a layer of a sparse field level-set solver.
Definition: itkSparseFieldLayer.h:162
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ObjectStore
A specialized memory management object for allocating and destroying contiguous blocks of objects.
Definition: itkObjectStore.h:84
itk::SparseImage
A storage type for sparse image data.
Definition: itkSparseImage.h:67
itk::SparseImage::NodeType
TNode NodeType
Definition: itkSparseImage.h:89
itk::WeakPointer
Implements a weak reference to an object.
Definition: itkWeakPointer.h:44
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
New
static Pointer New()
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itkSparseFieldLayer.h