ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkLevelSetContainer.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 >
40 public LevelSetContainerBase< TIdentifier, TLevelSet >
41 {
42 public:
43  ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetContainer);
44 
49 
51  itkNewMacro ( Self );
52 
53  itkTypeMacro ( LevelSetContainer, LevelSetContainerBase );
54 
56 
64 
68 
71 
72  static constexpr unsigned int Dimension = LevelSetType::Dimension;
73 
79 
83 
84 protected:
85  LevelSetContainer() = default;
86  ~LevelSetContainer() override = default;
87 };
88 
93 template< typename TIdentifier, typename TImage >
94 class LevelSetContainer< TIdentifier, LevelSetDenseImage< TImage > > :
95 public LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >
96 {
97 public:
98  ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetContainer);
99 
101 
106 
108  itkNewMacro ( Self );
109 
110  itkTypeMacro ( LevelSetContainer, LevelSetContainerBase );
111 
113 
120 
124 
127 
128  static constexpr unsigned int Dimension = LevelSetType::Dimension;
129 
135 
139 
141  using LevelSetImagePointer = typename LevelSetImageType::Pointer;
142 
144  void 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 }
189 
190 #endif // itkLevelSetContainer_h
typename Superclass::IdListImageType IdListImageType
typename Superclass::HeavisideConstPointer HeavisideConstPointer
typename Superclass::LevelSetDomainType LevelSetDomainType
Light weight base class for most itk classes.
Image< IdListType, Dimension > IdListImageType
typename Superclass::OutputRealType OutputRealType
typename Superclass::DomainMapImageFilterType DomainMapImageFilterType
Define numeric traits for std::vector.
typename IdListType::iterator IdListIterator
~LevelSetContainer() override=default
typename Superclass::LevelSetContainerIteratorType LevelSetContainerIteratorType
typename Superclass::LevelSetIdentifierType LevelSetIdentifierType
typename LevelSetType::Pointer LevelSetPointer
typename Superclass::DomainMapImageFilterPointer DomainMapImageFilterPointer
Image< short, Dimension > CacheImageType
typename Superclass::LevelSetContainerConstIteratorType LevelSetContainerConstIteratorType
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
typename Superclass::HeavisideType HeavisideType
typename Superclass::LevelSetType LevelSetType
typename LevelSetType::InputType InputIndexType
typename DomainMapImageFilterType::Pointer DomainMapImageFilterPointer
typename Superclass::DomainMapImageFilterPointer DomainMapImageFilterPointer
HeavisideStepFunctionBase< OutputRealType, OutputRealType > HeavisideType
typename Superclass::LevelSetContainerType LevelSetContainerType
typename LevelSetType::OutputRealType OutputRealType
typename Superclass::LevelSetPointer LevelSetPointer
typename HeavisideType::ConstPointer HeavisideConstPointer
typename LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType
std::list< LevelSetIdentifierType > IdListType
typename Superclass::DomainMapImageFilterType DomainMapImageFilterType
typename LevelSetContainerType::iterator LevelSetContainerIteratorType
Base class for the &quot;dense&quot; representation of a level-set function on one image.
typename DomainMapImageFilterType::LevelSetDomain LevelSetDomainType
typename Superclass::DomainIteratorType DomainIteratorType
Container of Level-Sets.
typename Superclass::IdListType IdListType
LevelSetDomainMapImageFilter< IdListImageType, CacheImageType > DomainMapImageFilterType
typename Superclass::LevelSetContainerIteratorType LevelSetContainerIteratorType
typename Superclass::HessianType HessianType
void CopyInformationAndAllocate(const Self *iOther, const bool &iAllocate)
typename Superclass::LevelSetContainerConstIteratorType LevelSetContainerConstIteratorType
static constexpr unsigned int Dimension
typename Superclass::LevelSetIdentifierType LevelSetIdentifierType
typename Superclass::GradientType GradientType
typename Superclass::IdListIterator IdListIterator
typename Superclass::CacheImageType CacheImageType
typename LevelSetType::HessianType HessianType
void SetContainer(const LevelSetContainerType &iContainer)
typename Superclass::OutputType OutputPixelType
typename LevelSetType::GradientType GradientType
typename DomainContainerType::iterator DomainIteratorType
typename Superclass::InputIndexType InputIndexType
typename LevelSetType::OutputType OutputType