00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __itkConnectedRegionsMeshFilter_h
00021 #define __itkConnectedRegionsMeshFilter_h
00022
00023 #include "itkMeshToMeshFilter.h"
00024
00025 namespace itk
00026 {
00027
00040 template <class TInputMesh, class TOutputMesh>
00041 class ITK_EXPORT ConnectedRegionsMeshFilter :
00042 public MeshToMeshFilter<TInputMesh,TOutputMesh>
00043 {
00044 public:
00048 typedef ConnectedRegionsMeshFilter Self;
00049
00053 typedef MeshToMeshFilter<TInputMesh,TOutputMesh> Superclass;
00054
00058 typedef SmartPointer<Self> Pointer;
00059 typedef SmartPointer<const Self> ConstPointer;
00060
00062
00065 typedef TInputMesh InputMeshType;
00066 typedef TOutputMesh OutputMeshType;
00067 typedef typename TInputMesh::Pointer InputMeshPointer;
00068 typedef typename TOutputMesh::Pointer OutputMeshPointer;
00069 itkStaticConstMacro(PointDimension, unsigned int,TInputMesh::PointDimension);
00070 typedef typename TInputMesh::PointType InputMeshPointType;
00071 typedef typename TInputMesh::PointIdentifier InputMeshPointIdentifier;
00072 typedef typename TInputMesh::PointsContainerPointer
00073 InputMeshPointsContainerPointer;
00074 typedef typename TInputMesh::CellsContainer InputMeshCellsContainer;
00075 typedef typename TInputMesh::CellsContainerPointer
00076 InputMeshCellsContainerPointer;
00077 typedef typename TInputMesh::CellDataContainer InputMeshCellDataContainer;
00078 typedef typename TInputMesh::CellDataContainerPointer
00079 InputMeshCellDataContainerPointer;
00080 typedef typename InputMeshType::PointsContainer::ConstIterator
00081 PointsContainerConstIterator;
00082 typedef typename InputMeshType::CellsContainer::ConstIterator
00083 CellsContainerConstIterator;
00084 typedef typename InputMeshType::CellDataContainer::ConstIterator
00085 CellDataContainerConstIterator;
00086 typedef typename TInputMesh::CellAutoPointer InputMeshCellPointer;
00087 typedef typename TInputMesh::CellTraits::PointIdConstIterator
00088 InputMeshPointIdConstIterator;
00089 typedef typename TInputMesh::CellLinksContainerPointer
00090 InputMeshCellLinksContainerPointer;
00091 typedef typename TInputMesh::PointCellLinksContainer
00092 InputMeshCellLinksContainer;
00093 typedef typename TInputMesh::CellIdentifier InputMeshCellIdentifier;
00095
00099 itkNewMacro(Self);
00100
00105 enum { PointSeededRegions = 0,
00106 CellSeededRegions = 1,
00107 SpecifiedRegions = 2,
00108 LargestRegion = 3,
00109 AllRegions = 4,
00110 ClosestPointRegion = 5 };
00111
00118 itkSetMacro(ExtractionMode,int);
00119 itkGetMacro(ExtractionMode,int);
00120 void SetExtractionModeToPointSeededRegions ()
00121 {this->SetExtractionMode(Self::PointSeededRegions);}
00122 void SetExtractionModeToCellSeededRegions ()
00123 {this->SetExtractionMode(Self::CellSeededRegions);}
00124 void SetExtractionModeToSpecifiedRegions ()
00125 {this->SetExtractionMode(Self::SpecifiedRegions);}
00126 void SetExtractionModeToLargestRegion ()
00127 {this->SetExtractionMode(Self::LargestRegion);}
00128 void SetExtractionModeToAllRegions ()
00129 {this->SetExtractionMode(Self::AllRegions);}
00130 void SetExtractionModeToClosestPointRegion ()
00131 {this->SetExtractionMode(Self::ClosestPointRegion);}
00132
00136 void InitializeSeedList()
00137 {this->Modified(); m_SeedList.clear();}
00138
00142 void AddSeed(unsigned long id)
00143 {this->Modified(); m_SeedList.push_back(id);}
00144
00148 void DeleteSeed(unsigned long id);
00149
00153 void InitializeSpecifiedRegionList()
00154 {this->Modified(); m_RegionList.clear();}
00155
00159 void AddSpecifiedRegion(unsigned long id)
00160 {this->Modified(); m_RegionList.push_back(id);}
00161
00165 void DeleteSpecifiedRegion(unsigned long id);
00166
00171 void SetClosestPoint(InputMeshPointType& p)
00172 {
00173 if ( m_ClosestPoint != p )
00174 {
00175 m_ClosestPoint = p;
00176 this->Modified();
00177 }
00178 }
00179 InputMeshPointType& GetClosestPoint(InputMeshPointType& p)
00180 {return m_ClosestPoint;}
00181
00185 unsigned long GetNumberOfExtractedRegions();
00186
00187 protected:
00188 ConnectedRegionsMeshFilter();
00189 virtual ~ConnectedRegionsMeshFilter() {}
00190 void PrintSelf(std::ostream& os, Indent indent) const;
00191
00192 virtual void GenerateData();
00193 void PropagateConnectedWave();
00194
00195 private:
00196 ConnectedRegionsMeshFilter(const Self&);
00197 void operator=(const Self&);
00198
00199 int m_ExtractionMode;
00200 InputMeshPointType m_ClosestPoint;
00201 std::vector<unsigned long> m_SeedList;
00202 std::vector<unsigned long> m_RegionList;
00203 std::vector<unsigned long> m_RegionSizes;
00204
00205 std::vector<long> m_Visited;
00206 unsigned long m_NumberOfCellsInRegion;
00207 unsigned long m_RegionNumber;
00208 std::vector<unsigned long> *m_Wave;
00209 std::vector<unsigned long> *m_Wave2;
00210
00211 };
00212
00213 }
00214
00215 #ifndef ITK_MANUAL_INSTANTIATION
00216 #include "itkConnectedRegionsMeshFilter.txx"
00217 #endif
00218
00219 #endif