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);}
00133
00137 void InitializeSeedList()
00138 {this->Modified(); m_SeedList.clear();}
00139
00143 void AddSeed(unsigned long id)
00144 {this->Modified(); m_SeedList.push_back(id);}
00145
00149 void DeleteSeed(unsigned long id);
00150
00154 void InitializeSpecifiedRegionList()
00155 {this->Modified(); m_RegionList.clear();}
00156
00160 void AddSpecifiedRegion(unsigned long id)
00161 {this->Modified(); m_RegionList.push_back(id);}
00162
00166 void DeleteSpecifiedRegion(unsigned long id);
00167
00172 void SetClosestPoint(InputMeshPointType& p)
00173 {
00174 if ( m_ClosestPoint != p )
00175 {
00176 m_ClosestPoint = p;
00177 this->Modified();
00178 }
00179 }
00180 InputMeshPointType& GetClosestPoint(InputMeshPointType& p)
00181 {return m_ClosestPoint;}
00183
00187 unsigned long GetNumberOfExtractedRegions();
00188
00189 protected:
00190 ConnectedRegionsMeshFilter();
00191 virtual ~ConnectedRegionsMeshFilter() {}
00192 void PrintSelf(std::ostream& os, Indent indent) const;
00193
00194 virtual void GenerateData();
00195 void PropagateConnectedWave();
00196
00197 private:
00198 ConnectedRegionsMeshFilter(const Self&);
00199 void operator=(const Self&);
00200
00201 int m_ExtractionMode;
00202 InputMeshPointType m_ClosestPoint;
00203 std::vector<unsigned long> m_SeedList;
00204 std::vector<unsigned long> m_RegionList;
00205 std::vector<unsigned long> m_RegionSizes;
00206
00207 std::vector<long> m_Visited;
00208 unsigned long m_NumberOfCellsInRegion;
00209 unsigned long m_RegionNumber;
00210 std::vector<unsigned long> *m_Wave;
00211 std::vector<unsigned long> *m_Wave2;
00212
00213 };
00214
00215 }
00216
00217 #ifndef ITK_MANUAL_INSTANTIATION
00218 #include "itkConnectedRegionsMeshFilter.txx"
00219 #endif
00220
00221 #endif
00222