ITK  4.9.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:
86 
87 private:
88  LevelSetContainer( const Self& ) ITK_DELETE_FUNCTION;
89  void operator = ( const Self& ) ITK_DELETE_FUNCTION;
90 };
91 
96 template< typename TIdentifier, typename TImage >
97 class LevelSetContainer< TIdentifier, LevelSetDenseImage< TImage > > :
98 public LevelSetContainerBase< TIdentifier, LevelSetDenseImage< TImage > >
99 {
100 public:
102 
107 
109  itkNewMacro ( Self );
110 
112 
114 
121 
125 
128 
129  itkStaticConstMacro ( Dimension, unsigned int, LevelSetType::Dimension );
130 
136 
140 
142  typedef typename LevelSetImageType::Pointer LevelSetImagePointer;
143 
145  void CopyInformationAndAllocate( const Self * iOther, const bool & iAllocate )
146  {
147  LevelSetContainerType internalContainer = iOther->GetContainer();
148  LevelSetContainerConstIteratorType it = internalContainer.begin();
150 
151  LevelSetContainerType newContainer;
152 
153  while( it != internalContainer.end() )
154  {
155  if( iAllocate )
156  {
157  LevelSetPointer temp_ls = LevelSetType::New();
158 
159  LevelSetImagePointer image = LevelSetImageType::New();
160  const LevelSetImageType * otherImage = (it->second)->GetImage();
161 
162  image->CopyInformation( otherImage );
163  image->SetBufferedRegion( otherImage->GetBufferedRegion() );
164  image->SetRequestedRegion( otherImage->GetRequestedRegion() );
165  image->SetLargestPossibleRegion( otherImage->GetLargestPossibleRegion() );
166  image->Allocate();
167  image->FillBuffer( NumericTraits< OutputPixelType >::ZeroValue() );
168 
169  temp_ls->SetImage( image );
170  newContainer[ it->first ] = temp_ls;
171  newContainer[ it->first ]->SetDomainOffset( (it->second)->GetDomainOffset() );
172  }
173  else
174  {
175  LevelSetPointer temp_ls;
176  newContainer[ it->first ] = temp_ls;
177  }
178  ++it;
179  }
180 
181  this->SetContainer( newContainer );
182  }
183 
184 protected:
187 
188 private:
189  LevelSetContainer( const Self& ) ITK_DELETE_FUNCTION;
190  void operator = ( const Self& ) ITK_DELETE_FUNCTION;
191 };
192 
193 }
194 
195 #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