ITK  5.0.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:
54  ITK_DISALLOW_COPY_AND_ASSIGN(ConnectedRegionsMeshFilter);
55 
60 
65 
71 
75  itkNewMacro(Self);
76 
80  using InputMeshType = TInputMesh;
81  using OutputMeshType = TOutputMesh;
82  using InputMeshConstPointer = typename TInputMesh::ConstPointer;
83  using OutputMeshPointer = typename TOutputMesh::Pointer;
84 
85  static constexpr unsigned int PointDimension = TInputMesh::PointDimension;
86 
88  using InputMeshPointIdentifier = typename TInputMesh::PointIdentifier;
89  using InputMeshPointsContainerConstPointer = typename TInputMesh::PointsContainerConstPointer;
90  using InputMeshCellsContainer = typename TInputMesh::CellsContainer;
91  using InputMeshCellsContainerPointer = typename TInputMesh::CellsContainerPointer;
92  using InputMeshCellsContainerConstPointer = typename TInputMesh::CellsContainerConstPointer;
93  using InputMeshCellDataContainer = typename TInputMesh::CellDataContainer;
94  using InputMeshCellDataContainerPointer = typename TInputMesh::CellDataContainerPointer;
95  using InputMeshCellDataContainerConstPointer = typename TInputMesh::CellDataContainerConstPointer;
96  using PointsContainerConstIterator = typename InputMeshType::PointsContainer::ConstIterator;
97  using CellsContainerConstIterator = typename InputMeshType::CellsContainer::ConstIterator;
98  using CellDataContainerConstIterator = typename InputMeshType::CellDataContainer::ConstIterator;
99  using InputMeshCellPointer = typename TInputMesh::CellAutoPointer;
100  using InputMeshPointIdConstIterator = typename TInputMesh::CellTraits::PointIdConstIterator;
101  using InputMeshCellLinksContainerConstPointer = typename TInputMesh::CellLinksContainerConstPointer;
102  using InputMeshCellLinksContainer = typename TInputMesh::PointCellLinksContainer;
103  using InputMeshCellIdentifier = typename TInputMesh::CellIdentifier;
104 
109  enum { PointSeededRegions = 0,
110  CellSeededRegions = 1,
111  SpecifiedRegions = 2,
112  LargestRegion = 3,
113  AllRegions = 4,
114  ClosestPointRegion = 5 };
115 
122  itkSetMacro(ExtractionMode, int);
123  itkGetConstMacro(ExtractionMode, int);
125 
127  {
128  this->SetExtractionMode(Self::PointSeededRegions);
129  }
130 
132  {
133  this->SetExtractionMode(Self::CellSeededRegions);
134  }
135 
137  {
138  this->SetExtractionMode(Self::SpecifiedRegions);
139  }
140 
142  {
143  this->SetExtractionMode(Self::LargestRegion);
144  }
145 
147  {
148  this->SetExtractionMode(Self::AllRegions);
149  }
150 
152  {
153  this->SetExtractionMode(Self::ClosestPointRegion);
154  }
155 
160  {
161  this->Modified();
162  m_SeedList.clear();
163  }
165 
170  {
171  this->Modified();
172  m_SeedList.push_back(id);
173  }
175 
179  void DeleteSeed(IdentifierType id);
180 
185  {
186  this->Modified();
187  m_RegionList.clear();
188  }
190 
195  {
196  this->Modified();
197  m_RegionList.push_back(id);
198  }
200 
204  void DeleteSpecifiedRegion(IdentifierType id);
205 
211  {
212  if ( m_ClosestPoint != p )
213  {
214  m_ClosestPoint = p;
215  this->Modified();
216  }
217  }
219 
221  {
222  return m_ClosestPoint;
223  }
224 
229  {
230  return m_RegionList.size();
231  }
232 
233 protected:
234 
236  ~ConnectedRegionsMeshFilter() override = default;
237 
238  void PrintSelf(std::ostream & os, Indent indent) const override;
239 
240  void GenerateData() override;
241 
242  void PropagateConnectedWave();
243 
244 private:
245 
248  std::vector< IdentifierType > m_SeedList;
249  std::vector< IdentifierType > m_RegionList;
250  std::vector< SizeValueType > m_RegionSizes;
251 
252  std::vector< OffsetValueType > m_Visited;
255  std::vector< IdentifierType > *m_Wave{nullptr};
256  std::vector< IdentifierType > *m_Wave2{nullptr};
257 }; // class declaration
258 } // end namespace itk
259 
260 #ifndef ITK_MANUAL_INSTANTIATION
261 #include "itkConnectedRegionsMeshFilter.hxx"
262 #endif
263 
264 #endif
std::vector< IdentifierType > m_RegionList
typename TInputMesh::PointCellLinksContainer InputMeshCellLinksContainer
typename TInputMesh::CellsContainerPointer InputMeshCellsContainerPointer
Light weight base class for most itk classes.
typename InputMeshType::CellDataContainer::ConstIterator CellDataContainerConstIterator
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename TInputMesh::CellIdentifier InputMeshCellIdentifier
typename TInputMesh::CellDataContainerPointer InputMeshCellDataContainerPointer
typename TInputMesh::CellDataContainer InputMeshCellDataContainer
InputMeshPointType & GetClosestPoint(InputMeshPointType &)
std::vector< SizeValueType > m_RegionSizes
typename TInputMesh::CellTraits::PointIdConstIterator InputMeshPointIdConstIterator
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
typename TInputMesh::CellsContainerConstPointer InputMeshCellsContainerConstPointer
typename TInputMesh::CellAutoPointer InputMeshCellPointer
typename TInputMesh::CellDataContainerConstPointer InputMeshCellDataContainerConstPointer
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
typename InputMeshType::PointsContainer::ConstIterator PointsContainerConstIterator
typename TInputMesh::PointsContainerConstPointer InputMeshPointsContainerConstPointer
typename TInputMesh::CellLinksContainerConstPointer InputMeshCellLinksContainerConstPointer
typename TInputMesh::PointIdentifier InputMeshPointIdentifier
std::vector< OffsetValueType > m_Visited
std::vector< IdentifierType > m_SeedList
typename TInputMesh::PointType InputMeshPointType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename TOutputMesh::Pointer OutputMeshPointer
typename TInputMesh::CellsContainer InputMeshCellsContainer
typename TInputMesh::ConstPointer InputMeshConstPointer
Extract portions of a mesh that are connected at vertices.
typename InputMeshType::CellsContainer::ConstIterator CellsContainerConstIterator