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 
34 namespace itk
35 {
49 template <typename TInputMesh, typename TOutputMesh>
50 class ITK_TEMPLATE_EXPORT ConnectedRegionsMeshFilter : public MeshToMeshFilter<TInputMesh, TOutputMesh>
51 {
52 public:
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
194  DeleteSeed(IdentifierType id);
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
222  DeleteSpecifiedRegion(IdentifierType id);
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 
254 protected:
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
265  PropagateConnectedWave();
266 
267 private:
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
itk::ConnectedRegionsMeshFilter::InputMeshPointIdentifier
typename TInputMesh::PointIdentifier InputMeshPointIdentifier
Definition: itkConnectedRegionsMeshFilter.h:91
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::ConnectedRegionsMeshFilter::InputMeshPointType
typename TInputMesh::PointType InputMeshPointType
Definition: itkConnectedRegionsMeshFilter.h:90
itk::ConnectedRegionsMeshFilter::CellDataContainerConstIterator
typename InputMeshType::CellDataContainer::ConstIterator CellDataContainerConstIterator
Definition: itkConnectedRegionsMeshFilter.h:101
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::ConnectedRegionsMeshFilter::InputMeshPointsContainerConstPointer
typename TInputMesh::PointsContainerConstPointer InputMeshPointsContainerConstPointer
Definition: itkConnectedRegionsMeshFilter.h:92
itk::ConnectedRegionsMeshFilter::SetExtractionModeToLargestRegion
void SetExtractionModeToLargestRegion()
Definition: itkConnectedRegionsMeshFilter.h:151
itk::ConnectedRegionsMeshFilter::InputMeshPointIdConstIterator
typename TInputMesh::CellTraits::PointIdConstIterator InputMeshPointIdConstIterator
Definition: itkConnectedRegionsMeshFilter.h:103
itk::ConnectedRegionsMeshFilter::InputMeshCellsContainer
typename TInputMesh::CellsContainer InputMeshCellsContainer
Definition: itkConnectedRegionsMeshFilter.h:93
itk::ConnectedRegionsMeshFilter::SetExtractionModeToPointSeededRegions
void SetExtractionModeToPointSeededRegions()
Definition: itkConnectedRegionsMeshFilter.h:133
itk::ConnectedRegionsMeshFilter::InputMeshType
TInputMesh InputMeshType
Definition: itkConnectedRegionsMeshFilter.h:83
itk::ConnectedRegionsMeshFilter::GetNumberOfExtractedRegions
SizeValueType GetNumberOfExtractedRegions()
Definition: itkConnectedRegionsMeshFilter.h:249
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ConnectedRegionsMeshFilter::GetClosestPoint
InputMeshPointType & GetClosestPoint(InputMeshPointType &)
Definition: itkConnectedRegionsMeshFilter.h:240
itk::ConnectedRegionsMeshFilter::PointsContainerConstIterator
typename InputMeshType::PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkConnectedRegionsMeshFilter.h:99
itk::ConnectedRegionsMeshFilter::InputMeshCellLinksContainerConstPointer
typename TInputMesh::CellLinksContainerConstPointer InputMeshCellLinksContainerConstPointer
Definition: itkConnectedRegionsMeshFilter.h:104
itk::ConnectedRegionsMeshFilter::InputMeshCellsContainerPointer
typename TInputMesh::CellsContainerPointer InputMeshCellsContainerPointer
Definition: itkConnectedRegionsMeshFilter.h:94
itk::ConnectedRegionsMeshFilter::SetClosestPoint
void SetClosestPoint(InputMeshPointType &p)
Definition: itkConnectedRegionsMeshFilter.h:229
itk::ConnectedRegionsMeshFilter::OutputMeshType
TOutputMesh OutputMeshType
Definition: itkConnectedRegionsMeshFilter.h:84
itk::ConnectedRegionsMeshFilter::InputMeshCellDataContainerConstPointer
typename TInputMesh::CellDataContainerConstPointer InputMeshCellDataContainerConstPointer
Definition: itkConnectedRegionsMeshFilter.h:98
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::ConnectedRegionsMeshFilter::SetExtractionModeToCellSeededRegions
void SetExtractionModeToCellSeededRegions()
Definition: itkConnectedRegionsMeshFilter.h:139
itk::ConnectedRegionsMeshFilter::InputMeshCellLinksContainer
typename TInputMesh::PointCellLinksContainer InputMeshCellLinksContainer
Definition: itkConnectedRegionsMeshFilter.h:105
itk::MeshToMeshFilter
MeshToMeshFilter is the base class for all process objects that output mesh data, and require mesh da...
Definition: itkMeshToMeshFilter.h:47
itk::ConnectedRegionsMeshFilter::InputMeshCellPointer
typename TInputMesh::CellAutoPointer InputMeshCellPointer
Definition: itkConnectedRegionsMeshFilter.h:102
itk::ConnectedRegionsMeshFilter::AddSeed
void AddSeed(IdentifierType id)
Definition: itkConnectedRegionsMeshFilter.h:183
itk::ConnectedRegionsMeshFilter::CellsContainerConstIterator
typename InputMeshType::CellsContainer::ConstIterator CellsContainerConstIterator
Definition: itkConnectedRegionsMeshFilter.h:100
itkIntTypes.h
itk::ConnectedRegionsMeshFilter::InitializeSpecifiedRegionList
void InitializeSpecifiedRegionList()
Definition: itkConnectedRegionsMeshFilter.h:200
itkMeshToMeshFilter.h
itk::ConnectedRegionsMeshFilter
Extract portions of a mesh that are connected at vertices.
Definition: itkConnectedRegionsMeshFilter.h:50
itk::ConnectedRegionsMeshFilter::InputMeshCellDataContainerPointer
typename TInputMesh::CellDataContainerPointer InputMeshCellDataContainerPointer
Definition: itkConnectedRegionsMeshFilter.h:97
itk::ConnectedRegionsMeshFilter::SetExtractionModeToAllRegions
void SetExtractionModeToAllRegions()
Definition: itkConnectedRegionsMeshFilter.h:157
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ConnectedRegionsMeshFilter::InputMeshCellsContainerConstPointer
typename TInputMesh::CellsContainerConstPointer InputMeshCellsContainerConstPointer
Definition: itkConnectedRegionsMeshFilter.h:95
itk::ConnectedRegionsMeshFilter::AddSpecifiedRegion
void AddSpecifiedRegion(IdentifierType id)
Definition: itkConnectedRegionsMeshFilter.h:211
itk::ConnectedRegionsMeshFilter::InitializeSeedList
void InitializeSeedList()
Definition: itkConnectedRegionsMeshFilter.h:172
itk::ConnectedRegionsMeshFilter::SetExtractionModeToClosestPointRegion
void SetExtractionModeToClosestPointRegion()
Definition: itkConnectedRegionsMeshFilter.h:163
itk::ConnectedRegionsMeshFilter::SetExtractionModeToSpecifiedRegions
void SetExtractionModeToSpecifiedRegions()
Definition: itkConnectedRegionsMeshFilter.h:145
itk::ConnectedRegionsMeshFilter::InputMeshCellIdentifier
typename TInputMesh::CellIdentifier InputMeshCellIdentifier
Definition: itkConnectedRegionsMeshFilter.h:106
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
itk::ConnectedRegionsMeshFilter::InputMeshCellDataContainer
typename TInputMesh::CellDataContainer InputMeshCellDataContainer
Definition: itkConnectedRegionsMeshFilter.h:96
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::ConnectedRegionsMeshFilter::InputMeshConstPointer
typename TInputMesh::ConstPointer InputMeshConstPointer
Definition: itkConnectedRegionsMeshFilter.h:85
itk::ConnectedRegionsMeshFilter::OutputMeshPointer
typename TOutputMesh::Pointer OutputMeshPointer
Definition: itkConnectedRegionsMeshFilter.h:86