ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkConnectedRegionsMeshFilter.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  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkConnectedRegionsMeshFilter_h
29 #define __itkConnectedRegionsMeshFilter_h
30 
31 #include "itkIntTypes.h"
32 #include "itkMeshToMeshFilter.h"
33 
34 namespace itk
35 {
49 template< class TInputMesh, class TOutputMesh >
50 class ITK_EXPORT ConnectedRegionsMeshFilter:
51  public MeshToMeshFilter< TInputMesh, TOutputMesh >
52 {
53 public:
58 
63 
69 
73  itkNewMacro(Self);
74 
78  typedef TInputMesh InputMeshType;
79  typedef TOutputMesh OutputMeshType;
80  typedef typename TInputMesh::ConstPointer InputMeshConstPointer;
81  typedef typename TOutputMesh::Pointer OutputMeshPointer;
82 
83  itkStaticConstMacro(PointDimension, unsigned int,
84  TInputMesh::PointDimension);
85 
86  typedef typename TInputMesh::PointType InputMeshPointType;
87  typedef typename TInputMesh::PointIdentifier InputMeshPointIdentifier;
88  typedef typename TInputMesh::PointsContainerConstPointer InputMeshPointsContainerConstPointer;
89  typedef typename TInputMesh::CellsContainer InputMeshCellsContainer;
90  typedef typename TInputMesh::CellsContainerPointer InputMeshCellsContainerPointer;
91  typedef typename TInputMesh::CellsContainerConstPointer InputMeshCellsContainerConstPointer;
92  typedef typename TInputMesh::CellDataContainer InputMeshCellDataContainer;
93  typedef typename TInputMesh::CellDataContainerPointer InputMeshCellDataContainerPointer;
94  typedef typename TInputMesh::CellDataContainerConstPointer InputMeshCellDataContainerConstPointer;
95  typedef typename InputMeshType::PointsContainer::ConstIterator PointsContainerConstIterator;
96  typedef typename InputMeshType::CellsContainer::ConstIterator CellsContainerConstIterator;
97  typedef typename InputMeshType::CellDataContainer::ConstIterator CellDataContainerConstIterator;
98  typedef typename TInputMesh::CellAutoPointer InputMeshCellPointer;
99  typedef typename TInputMesh::CellTraits::PointIdConstIterator InputMeshPointIdConstIterator;
100  typedef typename TInputMesh::CellLinksContainerConstPointer InputMeshCellLinksContainerConstPointer;
101  typedef typename TInputMesh::PointCellLinksContainer InputMeshCellLinksContainer;
102  typedef typename TInputMesh::CellIdentifier InputMeshCellIdentifier;
103 
108  enum { PointSeededRegions = 0,
109  CellSeededRegions = 1,
110  SpecifiedRegions = 2,
111  LargestRegion = 3,
112  AllRegions = 4,
113  ClosestPointRegion = 5 };
114 
121  itkSetMacro(ExtractionMode, int);
122  itkGetConstMacro(ExtractionMode, int);
124 
125  void SetExtractionModeToPointSeededRegions(void)
126  {
127  this->SetExtractionMode(Self::PointSeededRegions);
128  }
129 
130  void SetExtractionModeToCellSeededRegions(void)
131  {
132  this->SetExtractionMode(Self::CellSeededRegions);
133  }
134 
135  void SetExtractionModeToSpecifiedRegions(void)
136  {
137  this->SetExtractionMode(Self::SpecifiedRegions);
138  }
139 
140  void SetExtractionModeToLargestRegion(void)
141  {
142  this->SetExtractionMode(Self::LargestRegion);
143  }
144 
145  void SetExtractionModeToAllRegions(void)
146  {
147  this->SetExtractionMode(Self::AllRegions);
148  }
149 
150  void SetExtractionModeToClosestPointRegion(void)
151  {
152  this->SetExtractionMode(Self::ClosestPointRegion);
153  }
154 
158  void InitializeSeedList(void)
159  {
160  this->Modified();
161  m_SeedList.clear();
162  }
164 
168  void AddSeed(IdentifierType id)
169  {
170  this->Modified();
171  m_SeedList.push_back(id);
172  }
174 
178  void DeleteSeed(IdentifierType id);
179 
183  void InitializeSpecifiedRegionList(void)
184  {
185  this->Modified();
186  m_RegionList.clear();
187  }
189 
193  void AddSpecifiedRegion(IdentifierType id)
194  {
195  this->Modified();
196  m_RegionList.push_back(id);
197  }
199 
203  void DeleteSpecifiedRegion(IdentifierType id);
204 
209  void SetClosestPoint(InputMeshPointType & p)
210  {
211  if ( m_ClosestPoint != p )
212  {
213  m_ClosestPoint = p;
214  this->Modified();
215  }
216  }
218 
220  {
221  return m_ClosestPoint;
222  }
223 
227  SizeValueType GetNumberOfExtractedRegions()
228  {
229  return m_RegionList.size();
230  }
231 
232 protected:
233 
236 
237  void PrintSelf(std::ostream & os, Indent indent) const;
238 
239  virtual void GenerateData(void);
240 
241  void PropagateConnectedWave(void);
242 
243 private:
244 
245  ConnectedRegionsMeshFilter(const Self &); //purposely not implemented
246  void operator=(const Self &); //purposely not implemented
247 
250  std::vector< IdentifierType > m_SeedList;
251  std::vector< IdentifierType > m_RegionList;
252  std::vector< SizeValueType > m_RegionSizes;
253 
254  std::vector< OffsetValueType > m_Visited;
257  std::vector< IdentifierType > *m_Wave;
258  std::vector< IdentifierType > *m_Wave2;
259 }; // class declaration
260 } // end namespace itk
261 
262 #ifndef ITK_MANUAL_INSTANTIATION
263 #include "itkConnectedRegionsMeshFilter.hxx"
264 #endif
265 
266 #endif
267