ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkConnectedRegionsMeshFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkConnectedRegionsMeshFilter_h
00029 #define __itkConnectedRegionsMeshFilter_h
00030 
00031 #include "itkIntTypes.h"
00032 #include "itkMeshToMeshFilter.h"
00033 
00034 namespace itk
00035 {
00049 template< class TInputMesh, class TOutputMesh >
00050 class ITK_EXPORT ConnectedRegionsMeshFilter:
00051   public MeshToMeshFilter< TInputMesh, TOutputMesh >
00052 {
00053 public:
00057   typedef ConnectedRegionsMeshFilter Self;
00058 
00062   typedef MeshToMeshFilter< TInputMesh, TOutputMesh > Superclass;
00063 
00067   typedef SmartPointer< Self >       Pointer;
00068   typedef SmartPointer< const Self > ConstPointer;
00069 
00073   itkNewMacro(Self);
00074 
00078   typedef TInputMesh                        InputMeshType;
00079   typedef TOutputMesh                       OutputMeshType;
00080   typedef typename TInputMesh::ConstPointer InputMeshConstPointer;
00081   typedef typename TOutputMesh::Pointer     OutputMeshPointer;
00082 
00083   itkStaticConstMacro(PointDimension, unsigned int,
00084                       TInputMesh::PointDimension);
00085 
00086   typedef typename TInputMesh::PointType                           InputMeshPointType;
00087   typedef typename TInputMesh::PointIdentifier                     InputMeshPointIdentifier;
00088   typedef typename TInputMesh::PointsContainerConstPointer         InputMeshPointsContainerConstPointer;
00089   typedef typename TInputMesh::CellsContainer                      InputMeshCellsContainer;
00090   typedef typename TInputMesh::CellsContainerPointer               InputMeshCellsContainerPointer;
00091   typedef typename TInputMesh::CellsContainerConstPointer          InputMeshCellsContainerConstPointer;
00092   typedef typename TInputMesh::CellDataContainer                   InputMeshCellDataContainer;
00093   typedef typename TInputMesh::CellDataContainerPointer            InputMeshCellDataContainerPointer;
00094   typedef typename TInputMesh::CellDataContainerConstPointer       InputMeshCellDataContainerConstPointer;
00095   typedef typename InputMeshType::PointsContainer::ConstIterator   PointsContainerConstIterator;
00096   typedef typename InputMeshType::CellsContainer::ConstIterator    CellsContainerConstIterator;
00097   typedef typename InputMeshType::CellDataContainer::ConstIterator CellDataContainerConstIterator;
00098   typedef typename TInputMesh::CellAutoPointer                     InputMeshCellPointer;
00099   typedef typename TInputMesh::CellTraits::PointIdConstIterator    InputMeshPointIdConstIterator;
00100   typedef typename TInputMesh::CellLinksContainerConstPointer      InputMeshCellLinksContainerConstPointer;
00101   typedef typename TInputMesh::PointCellLinksContainer             InputMeshCellLinksContainer;
00102   typedef typename TInputMesh::CellIdentifier                      InputMeshCellIdentifier;
00103 
00108   enum { PointSeededRegions = 0,
00109          CellSeededRegions = 1,
00110          SpecifiedRegions = 2,
00111          LargestRegion = 3,
00112          AllRegions = 4,
00113          ClosestPointRegion = 5 };
00114 
00121   itkSetMacro(ExtractionMode, int);
00122   itkGetConstMacro(ExtractionMode, int);
00124 
00125   void SetExtractionModeToPointSeededRegions(void)
00126   {
00127     this->SetExtractionMode(Self::PointSeededRegions);
00128   }
00129 
00130   void SetExtractionModeToCellSeededRegions(void)
00131   {
00132     this->SetExtractionMode(Self::CellSeededRegions);
00133   }
00134 
00135   void SetExtractionModeToSpecifiedRegions(void)
00136   {
00137     this->SetExtractionMode(Self::SpecifiedRegions);
00138   }
00139 
00140   void SetExtractionModeToLargestRegion(void)
00141   {
00142     this->SetExtractionMode(Self::LargestRegion);
00143   }
00144 
00145   void SetExtractionModeToAllRegions(void)
00146   {
00147     this->SetExtractionMode(Self::AllRegions);
00148   }
00149 
00150   void SetExtractionModeToClosestPointRegion(void)
00151   {
00152     this->SetExtractionMode(Self::ClosestPointRegion);
00153   }
00154 
00158   void InitializeSeedList(void)
00159   {
00160     this->Modified();
00161     m_SeedList.clear();
00162   }
00164 
00168   void AddSeed(IdentifierType id)
00169   {
00170     this->Modified();
00171     m_SeedList.push_back(id);
00172   }
00174 
00178   void DeleteSeed(IdentifierType id);
00179 
00183   void InitializeSpecifiedRegionList(void)
00184   {
00185     this->Modified();
00186     m_RegionList.clear();
00187   }
00189 
00193   void AddSpecifiedRegion(IdentifierType id)
00194   {
00195     this->Modified();
00196     m_RegionList.push_back(id);
00197   }
00199 
00203   void DeleteSpecifiedRegion(IdentifierType id);
00204 
00209   void SetClosestPoint(InputMeshPointType & p)
00210   {
00211     if ( m_ClosestPoint != p )
00212       {
00213       m_ClosestPoint = p;
00214       this->Modified();
00215       }
00216   }
00218 
00219   InputMeshPointType & GetClosestPoint(InputMeshPointType &)
00220   {
00221     return m_ClosestPoint;
00222   }
00223 
00227   SizeValueType GetNumberOfExtractedRegions()
00228   {
00229     return m_RegionList.size();
00230   }
00231 
00232 protected:
00233 
00234   ConnectedRegionsMeshFilter(void);
00235   virtual ~ConnectedRegionsMeshFilter(void) {}
00236 
00237   void PrintSelf(std::ostream & os, Indent indent) const;
00238 
00239   virtual void GenerateData(void);
00240 
00241   void PropagateConnectedWave(void);
00242 
00243 private:
00244 
00245   ConnectedRegionsMeshFilter(const Self &); //purposely not implemented
00246   void operator=(const Self &);             //purposely not implemented
00247 
00248   int                            m_ExtractionMode;
00249   InputMeshPointType             m_ClosestPoint;
00250   std::vector< IdentifierType >  m_SeedList;
00251   std::vector< IdentifierType >  m_RegionList;
00252   std::vector< SizeValueType >   m_RegionSizes;
00253 
00254   std::vector< OffsetValueType > m_Visited;
00255   SizeValueType                  m_NumberOfCellsInRegion;
00256   IdentifierType                 m_RegionNumber;
00257   std::vector< IdentifierType > *m_Wave;
00258   std::vector< IdentifierType > *m_Wave2;
00259 }; // class declaration
00260 } // end namespace itk
00261 
00262 #ifndef ITK_MANUAL_INSTANTIATION
00263 #include "itkConnectedRegionsMeshFilter.hxx"
00264 #endif
00265 
00266 #endif
00267