ITK  4.13.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< typename TInputMesh, typename TOutputMesh >
50 class ITK_TEMPLATE_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 
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 
126  {
127  this->SetExtractionMode(Self::PointSeededRegions);
128  }
129 
131  {
132  this->SetExtractionMode(Self::CellSeededRegions);
133  }
134 
136  {
137  this->SetExtractionMode(Self::SpecifiedRegions);
138  }
139 
141  {
142  this->SetExtractionMode(Self::LargestRegion);
143  }
144 
146  {
147  this->SetExtractionMode(Self::AllRegions);
148  }
149 
151  {
152  this->SetExtractionMode(Self::ClosestPointRegion);
153  }
154 
159  {
160  this->Modified();
161  m_SeedList.clear();
162  }
164 
169  {
170  this->Modified();
171  m_SeedList.push_back(id);
172  }
174 
178  void DeleteSeed(IdentifierType id);
179 
184  {
185  this->Modified();
186  m_RegionList.clear();
187  }
189 
194  {
195  this->Modified();
196  m_RegionList.push_back(id);
197  }
199 
203  void DeleteSpecifiedRegion(IdentifierType id);
204 
210  {
211  if ( m_ClosestPoint != p )
212  {
213  m_ClosestPoint = p;
214  this->Modified();
215  }
216  }
218 
220  {
221  return m_ClosestPoint;
222  }
223 
228  {
229  return m_RegionList.size();
230  }
231 
232 protected:
233 
235  virtual ~ConnectedRegionsMeshFilter() ITK_OVERRIDE {}
236 
237  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
238 
239  virtual void GenerateData() ITK_OVERRIDE;
240 
241  void PropagateConnectedWave();
242 
243 private:
244 
245  ITK_DISALLOW_COPY_AND_ASSIGN(ConnectedRegionsMeshFilter);
246 
247  int m_ExtractionMode;
248  InputMeshPointType m_ClosestPoint;
249  std::vector< IdentifierType > m_SeedList;
250  std::vector< IdentifierType > m_RegionList;
251  std::vector< SizeValueType > m_RegionSizes;
252 
253  std::vector< OffsetValueType > m_Visited;
254  SizeValueType m_NumberOfCellsInRegion;
255  IdentifierType m_RegionNumber;
256  std::vector< IdentifierType > *m_Wave;
257  std::vector< IdentifierType > *m_Wave2;
258 }; // class declaration
259 } // end namespace itk
260 
261 #ifndef ITK_MANUAL_INSTANTIATION
262 #include "itkConnectedRegionsMeshFilter.hxx"
263 #endif
264 
265 #endif
InputMeshType::CellsContainer::ConstIterator CellsContainerConstIterator
TInputMesh::CellLinksContainerConstPointer InputMeshCellLinksContainerConstPointer
TInputMesh::PointIdentifier InputMeshPointIdentifier
Light weight base class for most itk classes.
MeshToMeshFilter< TInputMesh, TOutputMesh > Superclass
signed long OffsetValueType
Definition: itkIntTypes.h:154
TInputMesh::PointsContainerConstPointer InputMeshPointsContainerConstPointer
InputMeshType::PointsContainer::ConstIterator PointsContainerConstIterator
InputMeshPointType & GetClosestPoint(InputMeshPointType &)
TInputMesh::CellIdentifier InputMeshCellIdentifier
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
TInputMesh::CellTraits::PointIdConstIterator InputMeshPointIdConstIterator
unsigned long SizeValueType
Definition: itkIntTypes.h:143
TInputMesh::CellsContainerPointer InputMeshCellsContainerPointer
SizeValueType IdentifierType
Definition: itkIntTypes.h:147
TInputMesh::CellDataContainer InputMeshCellDataContainer
TInputMesh::CellsContainer InputMeshCellsContainer
TInputMesh::PointCellLinksContainer InputMeshCellLinksContainer
TInputMesh::CellDataContainerPointer InputMeshCellDataContainerPointer
TInputMesh::CellAutoPointer InputMeshCellPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
TInputMesh::CellDataContainerConstPointer InputMeshCellDataContainerConstPointer
InputMeshType::CellDataContainer::ConstIterator CellDataContainerConstIterator
TInputMesh::CellsContainerConstPointer InputMeshCellsContainerConstPointer
Extract portions of a mesh that are connected at vertices.