ITK  4.13.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 
48 
50  itkNewMacro ( Self );
51 
53 
55 
63 
67 
70 
71  itkStaticConstMacro ( Dimension, unsigned int, LevelSetType::Dimension );
72 
78 
82 
83 protected:
85  ~LevelSetContainer() ITK_OVERRIDE {}
86 
87 private:
88  ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetContainer);
89 };
90 
95 template< typename TIdentifier, typename TImage >
96 class LevelSetContainer< TIdentifier, LevelSetDenseImage< TImage > > :
97 public LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >
98 {
99 public:
101 
106 
108  itkNewMacro ( Self );
109 
111 
113 
120 
124 
127 
128  itkStaticConstMacro ( Dimension, unsigned int, LevelSetType::Dimension );
129 
135 
139 
141  typedef typename LevelSetImageType::Pointer LevelSetImagePointer;
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:
185  ~LevelSetContainer() ITK_OVERRIDE {}
186 
187 private:
188  ITK_DISALLOW_COPY_AND_ASSIGN(LevelSetContainer);
189 };
190 
191 }
192 
193 #endif // itkLevelSetContainer_h
Superclass::IdListImageType IdListImageType
Superclass::CacheImageType CacheImageType
LevelSetContainerBase< TIdentifier, LevelSetType > Superclass
DomainMapImageFilterType::Pointer DomainMapImageFilterPointer
Superclass::OutputType OutputPixelType
Light weight base class for most itk classes.
Superclass::LevelSetContainerIteratorType LevelSetContainerIteratorType
LevelSetType::GradientType GradientType
Superclass::LevelSetContainerConstIteratorType LevelSetContainerConstIteratorType
Superclass::DomainIteratorType DomainIteratorType
Superclass::OutputRealType OutputRealType
Superclass::DomainMapImageFilterPointer DomainMapImageFilterPointer
LevelSetContainerType::iterator LevelSetContainerIteratorType
LevelSetType::HessianType HessianType
Superclass::GradientType GradientType
Superclass::LevelSetIdentifierType LevelSetIdentifierType
HeavisideStepFunctionBase< OutputRealType, OutputRealType > HeavisideType
SmartPointer< const Self > ConstPointer
LevelSetContainerBase< TIdentifier, TLevelSet > Superclass
Superclass::HeavisideConstPointer HeavisideConstPointer
Superclass::LevelSetContainerIteratorType LevelSetContainerIteratorType
Superclass::LevelSetPointer LevelSetPointer
static const unsigned int Dimension
HeavisideType::ConstPointer HeavisideConstPointer
Superclass::InputIndexType InputIndexType
Superclass::DomainMapImageFilterType DomainMapImageFilterType
Superclass::HeavisideType HeavisideType
LevelSetType::OutputType OutputType
Base class for the &quot;dense&quot; representation of a level-set function on one image.
LevelSetContainerType::const_iterator LevelSetContainerConstIteratorType
Superclass::LevelSetDomainType LevelSetDomainType
Superclass::IdListIterator IdListIterator
Container of Level-Sets.
Superclass::IdListType IdListType
LevelSetType::Pointer LevelSetPointer
std::map< LevelSetIdentifierType, LevelSetPointer > LevelSetContainerType
DomainMapImageFilterType::LevelSetDomain LevelSetDomainType
Image< short, Dimension > CacheImageType
DomainContainerType::iterator DomainIteratorType
Superclass::LevelSetContainerConstIteratorType LevelSetContainerConstIteratorType
void CopyInformationAndAllocate(const Self *iOther, const bool &iAllocate)
LevelSetDomainMapImageFilter< IdListImageType, CacheImageType > DomainMapImageFilterType
Superclass::LevelSetContainerType LevelSetContainerType
LevelSetType::InputType InputIndexType
Superclass::LevelSetType LevelSetType
Image< IdListType, Dimension > IdListImageType
SmartPointer< Self > Pointer
Superclass::HessianType HessianType
Define additional traits for native types such as int or float.
std::list< LevelSetIdentifierType > IdListType
void SetContainer(const LevelSetContainerType &iContainer)
LevelSetType::OutputRealType OutputRealType