ITK  5.3.0
Insight Toolkit
itkLevelSetContainer.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  * http://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 
19 #ifndef itkLevelSetContainer_h
20 #define itkLevelSetContainer_h
21 
23 
24 #include "itkLevelSetDenseImage.h"
25 
26 
27 namespace itk
28 {
38 template <typename TIdentifier, typename TLevelSet>
39 class ITK_TEMPLATE_EXPORT LevelSetContainer : public LevelSetContainerBase<TIdentifier, TLevelSet>
40 {
41 public:
42  ITK_DISALLOW_COPY_AND_MOVE(LevelSetContainer);
43 
48 
50  itkNewMacro(Self);
51 
53 
54  using typename Superclass::LevelSetIdentifierType;
55 
56  using typename Superclass::LevelSetType;
57  using typename Superclass::LevelSetPointer;
58  using typename Superclass::InputIndexType;
59  using OutputPixelType = typename Superclass::OutputType;
60  using typename Superclass::OutputRealType;
61  using typename Superclass::GradientType;
62  using typename Superclass::HessianType;
63 
64  using typename Superclass::LevelSetContainerType;
65  using typename Superclass::LevelSetContainerConstIteratorType;
66  using typename Superclass::LevelSetContainerIteratorType;
67 
68  using typename Superclass::HeavisideType;
69  using typename Superclass::HeavisideConstPointer;
70 
71  static constexpr unsigned int Dimension = LevelSetType::Dimension;
72 
73  using typename Superclass::IdListType;
74  using typename Superclass::IdListIterator;
75  using typename Superclass::IdListImageType;
76  using typename Superclass::CacheImageType;
77  using typename Superclass::DomainMapImageFilterType;
78 
79  using typename Superclass::DomainMapImageFilterPointer;
80  using typename Superclass::LevelSetDomainType;
81  using typename Superclass::DomainIteratorType;
82 
83 protected:
84  LevelSetContainer() = default;
85  ~LevelSetContainer() override = default;
86 };
87 
92 template <typename TIdentifier, typename TImage>
93 class LevelSetContainer<TIdentifier, LevelSetDenseImage<TImage>>
94  : public LevelSetContainerBase<TIdentifier, LevelSetDenseImage<TImage>>
95 {
96 public:
97  ITK_DISALLOW_COPY_AND_MOVE(LevelSetContainer);
98 
100 
105 
107  itkNewMacro(Self);
108 
110 
111  using typename Superclass::LevelSetIdentifierType;
112 
113  using typename Superclass::LevelSetPointer;
114  using typename Superclass::InputIndexType;
116  using typename Superclass::OutputRealType;
117  using typename Superclass::GradientType;
118  using typename Superclass::HessianType;
119 
120  using typename Superclass::LevelSetContainerType;
123 
124  using typename Superclass::HeavisideType;
125  using typename Superclass::HeavisideConstPointer;
126 
127  static constexpr unsigned int Dimension = LevelSetType::Dimension;
128 
129  using typename Superclass::IdListType;
130  using typename Superclass::IdListIterator;
131  using typename Superclass::IdListImageType;
132  using typename Superclass::CacheImageType;
134 
136  using typename Superclass::LevelSetDomainType;
137  using typename Superclass::DomainIteratorType;
138 
140  using LevelSetImagePointer = typename LevelSetImageType::Pointer;
141 
143  void
144  CopyInformationAndAllocate(const Self * iOther, const bool & iAllocate)
145  {
146  LevelSetContainerType internalContainer = iOther->GetContainer();
147  LevelSetContainerConstIteratorType it = internalContainer.begin();
149 
150  LevelSetContainerType newContainer;
151 
152  while (it != internalContainer.end())
153  {
154  if (iAllocate)
155  {
156  LevelSetPointer temp_ls = LevelSetType::New();
157 
158  LevelSetImagePointer image = LevelSetImageType::New();
159  const LevelSetImageType * otherImage = (it->second)->GetImage();
160 
161  image->CopyInformation(otherImage);
162  image->SetBufferedRegion(otherImage->GetBufferedRegion());
163  image->SetRequestedRegion(otherImage->GetRequestedRegion());
164  image->SetLargestPossibleRegion(otherImage->GetLargestPossibleRegion());
165  image->Allocate();
166  image->FillBuffer(NumericTraits<OutputPixelType>::ZeroValue());
167 
168  temp_ls->SetImage(image);
169  newContainer[it->first] = temp_ls;
170  newContainer[it->first]->SetDomainOffset((it->second)->GetDomainOffset());
171  }
172  else
173  {
174  LevelSetPointer temp_ls;
175  newContainer[it->first] = temp_ls;
176  }
177  ++it;
178  }
179 
180  this->SetContainer(newContainer);
181  }
182 
183 protected:
184  LevelSetContainer() = default;
185  ~LevelSetContainer() override = default;
186 };
187 
188 } // namespace itk
189 
190 #endif // itkLevelSetContainer_h
itk::LevelSetContainerBase::HeavisideConstPointer
typename HeavisideType::ConstPointer HeavisideConstPointer
Definition: itkLevelSetContainerBase.h:73
itk::LevelSetContainerBase::LevelSetContainerType
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
Definition: itkLevelSetContainerBase.h:68
itkLevelSetContainerBase.h
itk::LevelSetContainer< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetImagePointer
typename LevelSetImageType::Pointer LevelSetImagePointer
Definition: itkLevelSetContainer.h:140
itk::LevelSetContainerBase::HeavisideType
HeavisideStepFunctionBase< OutputRealType, OutputRealType > HeavisideType
Definition: itkLevelSetContainerBase.h:72
itk::LevelSetDenseImage
Base class for the "dense" representation of a level-set function on one image.
Definition: itkLevelSetDenseImage.h:41
itk::LevelSetDenseImage::ImageType
TImage ImageType
Definition: itkLevelSetDenseImage.h:47
itk::LevelSetContainer::OutputPixelType
typename Superclass::OutputType OutputPixelType
Definition: itkLevelSetContainer.h:59
itk::LevelSetContainerBase::LevelSetDomainType
typename DomainMapImageFilterType::LevelSetDomain LevelSetDomainType
Definition: itkLevelSetContainerBase.h:88
itk::LevelSetContainerBase::SetContainer
void SetContainer(const LevelSetContainerType &iContainer)
itk::LevelSetContainerBase::DomainMapImageFilterPointer
typename DomainMapImageFilterType::Pointer DomainMapImageFilterPointer
Definition: itkLevelSetContainerBase.h:87
itk::SmartPointer< Self >
itk::LevelSetContainer< TIdentifier, LevelSetDenseImage< TImage > >::OutputPixelType
typename Superclass::OutputType OutputPixelType
Definition: itkLevelSetContainer.h:115
itk::LevelSetContainerBase::IdListType
std::list< LevelSetIdentifierType > IdListType
Definition: itkLevelSetContainerBase.h:77
itk::LevelSetContainer::LevelSetContainer
LevelSetContainer()=default
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::LevelSetContainerBase::OutputType
typename LevelSetType::OutputType OutputType
Definition: itkLevelSetContainerBase.h:59
itk::LevelSetContainer< TIdentifier, LevelSetDenseImage< TImage > >::CopyInformationAndAllocate
void CopyInformationAndAllocate(const Self *iOther, const bool &iAllocate)
Definition: itkLevelSetContainer.h:144
itk::LevelSetContainerBase::LevelSetContainerConstIteratorType
typename LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType
Definition: itkLevelSetContainerBase.h:69
itk::LevelSetContainerBase::InputIndexType
typename LevelSetType::InputType InputIndexType
Definition: itkLevelSetContainerBase.h:58
itk::LevelSetContainer
Container of Level-Sets.
Definition: itkLevelSetContainer.h:39
itk::LevelSetContainerBase::CacheImageType
Image< short, Dimension > CacheImageType
Definition: itkLevelSetContainerBase.h:81
itk::LevelSetContainerBase::GradientType
typename LevelSetType::GradientType GradientType
Definition: itkLevelSetContainerBase.h:61
itkLevelSetDenseImage.h
itk::LevelSetContainer::Dimension
static constexpr unsigned int Dimension
Definition: itkLevelSetContainer.h:71
itk::LevelSetContainerBase
Container of level set.
Definition: itkLevelSetContainerBase.h:42
itk::LevelSetContainerBase::DomainIteratorType
typename DomainContainerType::iterator DomainIteratorType
Definition: itkLevelSetContainerBase.h:91
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::LevelSetContainerBase::LevelSetIdentifierType
TIdentifier LevelSetIdentifierType
Definition: itkLevelSetContainerBase.h:66
itk::LevelSetContainerBase::HessianType
typename LevelSetType::HessianType HessianType
Definition: itkLevelSetContainerBase.h:62
itk::LevelSetContainerBase::OutputRealType
typename LevelSetType::OutputRealType OutputRealType
Definition: itkLevelSetContainerBase.h:60
itk::LevelSetContainerBase::DomainMapImageFilterType
LevelSetDomainMapImageFilter< IdListImageType, CacheImageType > DomainMapImageFilterType
Definition: itkLevelSetContainerBase.h:83
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::LevelSetContainerBase::LevelSetContainerIteratorType
typename LevelSetContainerType::iterator LevelSetContainerIteratorType
Definition: itkLevelSetContainerBase.h:70
itk::LevelSetContainerBase::IdListIterator
typename IdListType::iterator IdListIterator
Definition: itkLevelSetContainerBase.h:78
itk::LevelSetContainer::~LevelSetContainer
~LevelSetContainer() override=default
itk::LevelSetContainerBase::LevelSetPointer
typename LevelSetType::Pointer LevelSetPointer
Definition: itkLevelSetContainerBase.h:57
itk::LevelSetContainerBase::IdListImageType
Image< IdListType, Dimension > IdListImageType
Definition: itkLevelSetContainerBase.h:80
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::LevelSetContainer< TIdentifier, LevelSetDenseImage< TImage > >::LevelSetImageType
typename LevelSetType::ImageType LevelSetImageType
Definition: itkLevelSetContainer.h:139