ITK  6.0.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 * 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
19#ifndef itkLevelSetContainer_h
20#define itkLevelSetContainer_h
21
23
25
26
27namespace itk
28{
38template <typename TIdentifier, typename TLevelSet>
39class ITK_TEMPLATE_EXPORT LevelSetContainer : public LevelSetContainerBase<TIdentifier, TLevelSet>
40{
41public:
42 ITK_DISALLOW_COPY_AND_MOVE(LevelSetContainer);
43
48
50 itkNewMacro(Self);
51
52 itkOverrideGetNameOfClassMacro(LevelSetContainer);
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
83protected:
84 LevelSetContainer() = default;
85 ~LevelSetContainer() override = default;
86};
87
92template <typename TIdentifier, typename TImage>
93class LevelSetContainer<TIdentifier, LevelSetDenseImage<TImage>>
94 : public LevelSetContainerBase<TIdentifier, LevelSetDenseImage<TImage>>
95{
96public:
97 ITK_DISALLOW_COPY_AND_MOVE(LevelSetContainer);
98
100
105
107 itkNewMacro(Self);
108
109 itkOverrideGetNameOfClassMacro(LevelSetContainer);
110
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
123
124 using typename Superclass::HeavisideType;
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
141
143 void
144 CopyInformationAndAllocate(const Self * iOther, const bool iAllocate)
145 {
146 LevelSetContainerType internalContainer = iOther->GetContainer();
147 LevelSetContainerConstIteratorType it = internalContainer.begin();
150 LevelSetContainerType newContainer;
151
152 while (it != internalContainer.end())
153 {
154 if (iAllocate)
155 {
157
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->AllocateInitialized();
166
167 temp_ls->SetImage(image);
168 newContainer[it->first] = temp_ls;
169 newContainer[it->first]->SetDomainOffset((it->second)->GetDomainOffset());
170 }
171 else
172 {
173 LevelSetPointer temp_ls;
174 newContainer[it->first] = temp_ls;
175 }
176 ++it;
177 }
178
179 this->SetContainer(newContainer);
180 }
181
182protected:
183 LevelSetContainer() = default;
184 ~LevelSetContainer() override = default;
185};
186
187} // namespace itk
188
189#endif // itkLevelSetContainer_h
typename LevelSetType::OutputType OutputType
typename LevelSetType::InputType InputIndexType
typename DomainMapImageFilterType::LevelSetDomain LevelSetDomainType
typename LevelSetType::OutputRealType OutputRealType
void SetContainer(const LevelSetContainerType &iContainer)
typename LevelSetType::HessianType HessianType
typename IdListType::iterator IdListIterator
typename LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType
HeavisideStepFunctionBase< OutputRealType, OutputRealType > HeavisideType
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
std::list< LevelSetIdentifierType > IdListType
typename DomainContainerType::iterator DomainIteratorType
typename LevelSetType::Pointer LevelSetPointer
Image< short, Dimension > CacheImageType
Image< IdListType, Dimension > IdListImageType
typename DomainMapImageFilterType::Pointer DomainMapImageFilterPointer
typename LevelSetContainerType::iterator LevelSetContainerIteratorType
LevelSetDomainMapImageFilter< IdListImageType, CacheImageType > DomainMapImageFilterType
typename HeavisideType::ConstPointer HeavisideConstPointer
typename LevelSetType::GradientType GradientType
void CopyInformationAndAllocate(const Self *iOther, const bool iAllocate)
Container of Level-Sets.
~LevelSetContainer() override=default
typename Superclass::OutputType OutputPixelType
static constexpr unsigned int Dimension
Base class for the "dense" representation of a level-set function on one image.
Light weight base class for most itk classes.
static Pointer New()
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....