ITK  4.3.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< class TIdentifier, class 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& ); // purposely not implemented
89  void operator = ( const Self& ); // purposely not implemented
90 };
91 
96 template< class TIdentifier, class 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 >::Zero );
168 
169  temp_ls->SetImage( image );
170  newContainer[ it->first ] = temp_ls;
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:
186 
187 private:
188  LevelSetContainer( const Self& ); // purposely not implemented
189  void operator = ( const Self& ); // purposely not implemented
190 };
191 
192 }
193 
194 #endif // __itkLevelSetContainer_h
195