ITK  6.0.0
Insight Toolkit
itkConnectedRegionsMeshFilter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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
34namespace itk
35{
49template <typename TInputMesh, typename TOutputMesh>
50class ITK_TEMPLATE_EXPORT ConnectedRegionsMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
51{
52public:
53 ITK_DISALLOW_COPY_AND_MOVE(ConnectedRegionsMeshFilter);
54
59
64
70
75 itkNewMacro(Self);
76
78 itkOverrideGetNameOfClassMacro(ConnectedRegionsMeshFilter);
79
83 using InputMeshType = TInputMesh;
84 using OutputMeshType = TOutputMesh;
87
88 static constexpr unsigned int PointDimension = TInputMesh::PointDimension;
89
91 using InputMeshPointIdentifier = typename TInputMesh::PointIdentifier;
92 using InputMeshPointsContainerConstPointer = typename TInputMesh::PointsContainerConstPointer;
93 using InputMeshCellsContainer = typename TInputMesh::CellsContainer;
94 using InputMeshCellsContainerPointer = typename TInputMesh::CellsContainerPointer;
95 using InputMeshCellsContainerConstPointer = typename TInputMesh::CellsContainerConstPointer;
96 using InputMeshCellDataContainer = typename TInputMesh::CellDataContainer;
97 using InputMeshCellDataContainerPointer = typename TInputMesh::CellDataContainerPointer;
98 using InputMeshCellDataContainerConstPointer = typename TInputMesh::CellDataContainerConstPointer;
99 using PointsContainerConstIterator = typename InputMeshType::PointsContainer::ConstIterator;
100 using CellsContainerConstIterator = typename InputMeshType::CellsContainer::ConstIterator;
101 using CellDataContainerConstIterator = typename InputMeshType::CellDataContainer::ConstIterator;
102 using InputMeshCellPointer = typename TInputMesh::CellAutoPointer;
103 using InputMeshPointIdConstIterator = typename TInputMesh::CellTraits::PointIdConstIterator;
104 using InputMeshCellLinksContainerConstPointer = typename TInputMesh::CellLinksContainerConstPointer;
105 using InputMeshCellLinksContainer = typename TInputMesh::PointCellLinksContainer;
106 using InputMeshCellIdentifier = typename TInputMesh::CellIdentifier;
107
112 enum
113 {
114 PointSeededRegions = 0,
115 CellSeededRegions = 1,
116 SpecifiedRegions = 2,
117 LargestRegion = 3,
118 AllRegions = 4,
119 ClosestPointRegion = 5
120 };
121
128 itkSetMacro(ExtractionMode, int);
129 itkGetConstMacro(ExtractionMode, int);
132 void
134 {
135 this->SetExtractionMode(Self::PointSeededRegions);
136 }
137
138 void
140 {
141 this->SetExtractionMode(Self::CellSeededRegions);
142 }
143
144 void
146 {
147 this->SetExtractionMode(Self::SpecifiedRegions);
148 }
149
150 void
152 {
153 this->SetExtractionMode(Self::LargestRegion);
154 }
155
156 void
158 {
159 this->SetExtractionMode(Self::AllRegions);
160 }
161
162 void
164 {
165 this->SetExtractionMode(Self::ClosestPointRegion);
166 }
167
171 void
173 {
174 this->Modified();
175 m_SeedList.clear();
176 }
182 void
184 {
185 this->Modified();
186 m_SeedList.push_back(id);
187 }
193 void
195
199 void
201 {
202 this->Modified();
203 m_RegionList.clear();
204 }
210 void
212 {
213 this->Modified();
214 m_RegionList.push_back(id);
215 }
221 void
223
228 void
230 {
231 if (m_ClosestPoint != p)
232 {
233 m_ClosestPoint = p;
234 this->Modified();
235 }
236 }
239 InputMeshPointType &
241 {
242 return m_ClosestPoint;
243 }
244
250 {
251 return m_RegionNumber;
252 }
253
254protected:
256 ~ConnectedRegionsMeshFilter() override = default;
257
258 void
259 PrintSelf(std::ostream & os, Indent indent) const override;
260
261 void
262 GenerateData() override;
263
264 void
266
267private:
268 int m_ExtractionMode{};
269 InputMeshPointType m_ClosestPoint{};
270 std::vector<IdentifierType> m_SeedList{};
271 std::vector<IdentifierType> m_RegionList{};
272 std::vector<SizeValueType> m_RegionSizes{};
273
274 std::vector<OffsetValueType> m_Visited{};
275 SizeValueType m_NumberOfCellsInRegion{};
276 IdentifierType m_RegionNumber{};
277 std::vector<IdentifierType> * m_Wave{ nullptr };
278 std::vector<IdentifierType> * m_Wave2{ nullptr };
279}; // class declaration
280} // end namespace itk
281
282#ifndef ITK_MANUAL_INSTANTIATION
283# include "itkConnectedRegionsMeshFilter.hxx"
284#endif
285
286#endif
Extract portions of a mesh that are connected at vertices.
typename TInputMesh::CellAutoPointer InputMeshCellPointer
typename TInputMesh::CellDataContainerPointer InputMeshCellDataContainerPointer
typename TInputMesh::PointIdentifier InputMeshPointIdentifier
typename TInputMesh::PointCellLinksContainer InputMeshCellLinksContainer
typename InputMeshType::CellsContainer::ConstIterator CellsContainerConstIterator
typename TInputMesh::PointsContainerConstPointer InputMeshPointsContainerConstPointer
typename TInputMesh::CellDataContainer InputMeshCellDataContainer
typename TInputMesh::CellLinksContainerConstPointer InputMeshCellLinksContainerConstPointer
typename InputMeshType::CellDataContainer::ConstIterator CellDataContainerConstIterator
~ConnectedRegionsMeshFilter() override=default
typename InputMeshType::PointsContainer::ConstIterator PointsContainerConstIterator
typename TOutputMesh::Pointer OutputMeshPointer
typename TInputMesh::PointType InputMeshPointType
typename TInputMesh::CellTraits::PointIdConstIterator InputMeshPointIdConstIterator
void DeleteSpecifiedRegion(IdentifierType id)
InputMeshPointType & GetClosestPoint(InputMeshPointType &)
typename TInputMesh::CellsContainerPointer InputMeshCellsContainerPointer
void PrintSelf(std::ostream &os, Indent indent) const override
typename TInputMesh::ConstPointer InputMeshConstPointer
typename TInputMesh::CellIdentifier InputMeshCellIdentifier
typename TInputMesh::CellsContainerConstPointer InputMeshCellsContainerConstPointer
typename TInputMesh::CellDataContainerConstPointer InputMeshCellDataContainerConstPointer
void DeleteSeed(IdentifierType id)
typename TInputMesh::CellsContainer InputMeshCellsContainer
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
unsigned long SizeValueType
Definition: itkIntTypes.h:86