File: itkConnectedRegionsMeshFilter.h

package info (click to toggle)
insighttoolkit 3.6.0-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 94,956 kB
  • ctags: 74,981
  • sloc: cpp: 355,621; ansic: 195,070; fortran: 28,713; python: 3,802; tcl: 1,996; sh: 1,175; java: 583; makefile: 415; csh: 184; perl: 175
file content (260 lines) | stat: -rw-r--r-- 7,993 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: itkConnectedRegionsMeshFilter.h,v $
  Language:  C++
  Date:      $Date: 2008-01-01 21:43:34 $
  Version:   $Revision: 1.25 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

  Portions of this code are covered under the VTK copyright.
  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __itkConnectedRegionsMeshFilter_h
#define __itkConnectedRegionsMeshFilter_h

#include "itkMeshToMeshFilter.h"

namespace itk
{
  
/** \class ConnectedRegionsMeshFilter
 * \brief Extract portions of a mesh that are connected at vertices.
 *
 * ConnectedRegionsMeshFilter will extract portions of a mesh that
 * are connected at vertices. (Such connected portions of the mesh
 * are referred to as a region.) Options exist to extract the largest
 * region, a particular region, a region containing a specified
 * point, or a region containing a specified cell.
 *
 * \ingroup MeshFilters 
 */

template <class TInputMesh, class TOutputMesh>
class ITK_EXPORT ConnectedRegionsMeshFilter 
: public MeshToMeshFilter<TInputMesh, TOutputMesh> 
{
  public:
  /**
   * Standard class typedefs.
   */
  typedef ConnectedRegionsMeshFilter               Self;

  /**
   * Standard "Superclass" typedef.
   */
  typedef MeshToMeshFilter<TInputMesh, TOutputMesh> Superclass;

  /** 
   * Smart pointer typedef support 
   */
  typedef SmartPointer<Self>                       Pointer;
  typedef SmartPointer<const Self>                 ConstPointer;

  /**
   * Method for creation through the object factory.
   */
  itkNewMacro( Self );

  /**
   * Convenient typedefs for this filter.
   */
  typedef TInputMesh                               InputMeshType;
  typedef TOutputMesh                              OutputMeshType;
  typedef typename TInputMesh::Pointer             InputMeshPointer;
  typedef typename TOutputMesh::Pointer            OutputMeshPointer;

  itkStaticConstMacro( PointDimension, unsigned int,
                       TInputMesh::PointDimension );

  typedef typename TInputMesh::PointType           InputMeshPointType;
  typedef typename TInputMesh::PointIdentifier     InputMeshPointIdentifier;
  typedef typename TInputMesh::PointsContainerPointer 
                                                   InputMeshPointsContainerPointer;
  typedef typename TInputMesh::CellsContainer      InputMeshCellsContainer;
  typedef typename TInputMesh::CellsContainerPointer 
                                                   InputMeshCellsContainerPointer;
  typedef typename TInputMesh::CellDataContainer   InputMeshCellDataContainer;
  typedef typename TInputMesh::CellDataContainerPointer 
                                                   InputMeshCellDataContainerPointer;
  typedef typename InputMeshType::PointsContainer::ConstIterator 
                                                   PointsContainerConstIterator;
  typedef typename InputMeshType::CellsContainer::ConstIterator
                                                   CellsContainerConstIterator;
  typedef typename InputMeshType::CellDataContainer::ConstIterator
                                                   CellDataContainerConstIterator;
  typedef typename TInputMesh::CellAutoPointer     InputMeshCellPointer;
  typedef typename TInputMesh::CellTraits::PointIdConstIterator 
                                                   InputMeshPointIdConstIterator;
  typedef typename TInputMesh::CellLinksContainerPointer
                                                   InputMeshCellLinksContainerPointer;
  typedef typename TInputMesh::PointCellLinksContainer
                                                   InputMeshCellLinksContainer;
  typedef typename TInputMesh::CellIdentifier      InputMeshCellIdentifier;

  /**
   * Different modes of operation. Use these to specify
   * how to extract the regions.
   */
  enum { PointSeededRegions = 0,
         CellSeededRegions = 1,
         SpecifiedRegions = 2,
         LargestRegion = 3,
         AllRegions = 4,
         ClosestPointRegion = 5 };
  
  /**
   * Methods specify mode of operation for the filter. Note that
   * some modes require additional information. For example, 
   * SetExtractionModeToClosestPointRegion() also requires that
   * a point be defined.
   */
  itkSetMacro( ExtractionMode, int );
  itkGetMacro( ExtractionMode, int );

  void SetExtractionModeToPointSeededRegions( void )
    {
    this->SetExtractionMode( Self::PointSeededRegions );
    }

  void SetExtractionModeToCellSeededRegions( void )
    {
    this->SetExtractionMode( Self::CellSeededRegions );
    }

  void SetExtractionModeToSpecifiedRegions( void )
    {
    this->SetExtractionMode( Self::SpecifiedRegions );
    }

  void SetExtractionModeToLargestRegion( void )
    {
    this->SetExtractionMode( Self::LargestRegion );
    }

  void SetExtractionModeToAllRegions( void )
    {
    this->SetExtractionMode( Self::AllRegions );
    }

  void SetExtractionModeToClosestPointRegion( void )
    {
    this->SetExtractionMode( Self::ClosestPointRegion );
    }

  /**
   * Initialize list of point ids/cell ids used to seed regions.
   */
  void InitializeSeedList( void )
    {
    this->Modified();
    m_SeedList.clear();
    }

  /**
   * Add a seed id (point or cell id). Note: ids are 0-offset.
   */
  void AddSeed( unsigned long id )
    {
    this->Modified();
    m_SeedList.push_back(id);
    }

  /**
   * Delete a seed id (point or cell id). Note: ids are 0-offset.
   */
  void DeleteSeed( unsigned long id );

  /**
   * Initialize list of region ids to extract.
   */
  void InitializeSpecifiedRegionList( void )
    {
    this->Modified();
    m_RegionList.clear();
    }

  /**
   * Add a region id to extract. Note: ids are 0-offset.
   */
  void AddSpecifiedRegion( unsigned long id )
    {
    this->Modified();
    m_RegionList.push_back(id);
    }

  /**
   * Delete a region id to extract. Note: ids are 0-offset.
   */
  void DeleteSpecifiedRegion( unsigned long id );

  /**
   * Use to specify x-y-z point coordinates when extracting the region 
   * closest to a specified point.
   */
  void SetClosestPoint( InputMeshPointType& p )
    {
    if( m_ClosestPoint != p )
      {
      m_ClosestPoint = p;
      this->Modified();
      }
    }

  InputMeshPointType& GetClosestPoint( InputMeshPointType& p )
    {
    return m_ClosestPoint;
    }

  /**
   * Obtain the number of connected regions.
   */
  unsigned long GetNumberOfExtractedRegions()
    {
    return m_RegionList.size();
    }

protected:

  ConnectedRegionsMeshFilter( void );
  virtual ~ConnectedRegionsMeshFilter( void ) {}

  void PrintSelf( std::ostream& os, Indent indent ) const;

  virtual void GenerateData( void );

  void PropagateConnectedWave( void );

private:  

  ConnectedRegionsMeshFilter( const Self& ); //purposely not implemented
  void operator=( const Self& ); //purposely not implemented

  int                        m_ExtractionMode;
  InputMeshPointType         m_ClosestPoint;
  std::vector<unsigned long> m_SeedList;
  std::vector<unsigned long> m_RegionList;
  std::vector<unsigned long> m_RegionSizes;
  
  std::vector<long>          m_Visited;
  unsigned long              m_NumberOfCellsInRegion;
  unsigned long              m_RegionNumber;
  std::vector<unsigned long> *m_Wave;
  std::vector<unsigned long> *m_Wave2;
  
}; // class declaration

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
#include "itkConnectedRegionsMeshFilter.txx"
#endif

#endif