Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkVoronoiDiagram2D.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkVoronoiDiagram2D.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:28:40 $ 00007 Version: $Revision: 1.18 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkVoronoiDiagram2D_h 00018 #define __itkVoronoiDiagram2D_h 00019 00020 #if defined(_MSC_VER) 00021 #pragma warning ( disable : 4786 ) 00022 #endif 00023 00024 #include "itkCellInterface.h" 00025 #include "itkLineCell.h" 00026 #include "itkMesh.h" 00027 #include "itkDefaultDynamicMeshTraits.h" 00028 #include "itkPolygonCell.h" 00029 #include <vector> 00030 00031 #ifndef NULL 00032 #define NULL 0 00033 #endif 00034 00035 namespace itk 00036 { 00053 template <typename TCoordType> 00054 class ITK_EXPORT VoronoiDiagram2D: 00055 public Mesh <TCoordType, 2, 00056 DefaultDynamicMeshTraits<TCoordType, 2, 2, TCoordType> > 00057 { 00058 public: 00060 typedef VoronoiDiagram2D Self; 00061 typedef Mesh <TCoordType, 2, 00062 DefaultDynamicMeshTraits<TCoordType, 2, 2, TCoordType> > 00063 Superclass; 00064 typedef SmartPointer<Self> Pointer; 00065 typedef SmartPointer<const Self> ConstPointer; 00066 00068 itkNewMacro(Self); 00069 00071 itkTypeMacro(VoronoiDiagram2D, Mesh); 00072 00074 typedef DefaultDynamicMeshTraits<TCoordType, 2, 2, TCoordType> MeshTraits; 00075 00077 itkStaticConstMacro(PointDimension, unsigned int, 00078 MeshTraits::PointDimension); 00079 itkStaticConstMacro(MaxTopologicalDimension, unsigned int, 00080 MeshTraits::MaxTopologicalDimension); 00081 00083 typedef typename MeshTraits::PixelType PixelType; 00084 typedef typename MeshTraits::CoordRepType CoordRepType; 00085 typedef typename MeshTraits::InterpolationWeightType InterpolationWeightType; 00086 typedef typename MeshTraits::PointIdentifier PointIdentifier; 00087 typedef typename MeshTraits::CellIdentifier CellIdentifier; 00088 typedef typename MeshTraits::CellFeatureIdentifier CellFeatureIdentifier; 00089 typedef typename MeshTraits::PointType PointType; 00090 typedef typename MeshTraits::PointsContainer PointsContainer; 00091 typedef typename MeshTraits::CellTraits CellTraits; 00092 typedef typename MeshTraits::CellsContainer CellsContainer; 00093 typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer; 00094 typedef typename MeshTraits::CellLinksContainer CellLinksContainer; 00095 typedef typename MeshTraits::PointDataContainer PointDataContainer; 00096 typedef typename MeshTraits::CellDataContainer CellDataContainer; 00097 typedef typename MeshTraits::CellAutoPointer genericCellPointer; 00098 typedef PointLocator<PointIdentifier,itkGetStaticConstMacro(PointDimension), 00099 CoordRepType,PointsContainer> PointLocatorType; 00100 typedef BoundingBox<PointIdentifier,itkGetStaticConstMacro(PointDimension), 00101 CoordRepType,PointsContainer> BoundingBoxType; 00102 typedef typename PointsContainer::Pointer PointsContainerPointer; 00103 typedef typename CellsContainer::Pointer CellsContainerPointer; 00104 typedef typename CellLinksContainer::Pointer CellLinksContainerPointer; 00105 typedef typename PointDataContainer::Pointer PointDataContainerPointer; 00106 typedef typename CellDataContainer::Pointer CellDataContainerPointer; 00107 typedef typename PointLocatorType::Pointer PointLocatorPointer; 00108 typedef typename BoundingBoxType::Pointer BoundingBoxPointer; 00109 typedef typename 00110 PointsContainer::ConstIterator PointsContainerConstIterator; 00111 typedef typename 00112 PointsContainer::Iterator PointsContainerIterator; 00113 typedef typename 00114 CellsContainer::ConstIterator CellsContainerConstIterator; 00115 typedef typename 00116 CellsContainer::Iterator CellsContainerIterator; 00117 typedef typename 00118 CellLinksContainer::ConstIterator CellLinksContainerIterator; 00119 typedef typename 00120 PointDataContainer::ConstIterator PointDataContainerIterator; 00121 typedef typename 00122 CellDataContainer::ConstIterator CellDataContainerIterator; 00123 typedef typename 00124 PointCellLinksContainer::const_iterator PointCellLinksContainerIterator; 00125 typedef CellFeatureIdentifier CellFeatureCount; 00126 typedef CellInterface<PixelType,CellTraits> CellInterfaceType; 00127 typedef PolygonCell<CellInterfaceType> CellType; 00128 typedef typename CellType::CellAutoPointer CellAutoPointer; 00129 typedef Point<int,2> EdgeInfo; 00130 typedef std::deque<EdgeInfo> EdgeInfoDQ; 00131 typedef typename CellType::MultiVisitor CellMultiVisitorType; 00132 typedef std::vector<PointType> SeedsType; 00133 typedef typename SeedsType::iterator SeedsIterator; 00134 typedef LineCell <CellInterfaceType> Edge; 00135 typedef typename Edge::SelfAutoPointer EdgeAutoPointer; 00136 typedef std::list<PointType> PointList; 00137 typedef std::vector<int> INTvector; 00138 typedef typename INTvector::iterator NeighborIdIterator; 00139 typedef typename std::vector<PointType>::iterator VertexIterator; 00140 00142 itkGetMacro(NumberOfSeeds,unsigned int); 00143 00146 void SetSeeds (int num, SeedsIterator begin); 00147 00149 void SetBoundary(PointType vorsize); 00150 void SetOrigin(PointType vorsize); 00151 00153 NeighborIdIterator NeighborIdsBegin(int seeds); 00154 NeighborIdIterator NeighborIdsEnd(int seeds); 00155 00157 VertexIterator VertexBegin(void); 00158 VertexIterator VertexEnd(void); 00159 00161 PointType GetSeed(int SeedID); 00162 00164 void GetCellId(CellIdentifier cellId, CellAutoPointer &); 00165 00167 void GetPoint(int pId,PointType *answer); 00168 00169 class VoronoiEdge{ 00170 public: 00171 PointType m_Left; 00172 PointType m_Right; 00173 int m_LeftID; 00174 int m_RightID; 00175 int m_LineID; 00176 VoronoiEdge(){}; 00177 ~VoronoiEdge(){}; 00178 }; 00179 00181 typedef typename std::vector<VoronoiEdge>::iterator VoronoiEdgeIterator; 00182 00184 VoronoiEdgeIterator EdgeBegin(void); 00185 VoronoiEdgeIterator EdgeEnd(void); 00186 00188 EdgeInfo GetSeedsIDAroundEdge(VoronoiEdge *task); 00189 /********************************************************/ 00190 00191 void Reset(); 00192 void InsertCells(); 00193 00194 void AddCellNeighbor(EdgeInfo x){ 00195 m_CellNeighborsID[x[0]].push_back(x[1]); 00196 m_CellNeighborsID[x[1]].push_back(x[0]);}; 00197 void ClearRegion(int i){ m_VoronoiRegions[i]->ClearPoints();}; 00198 void VoronoiRegionAddPointId(int id, int x){m_VoronoiRegions[id]->AddPointId(x);}; 00199 void BuildEdge(int id){ m_VoronoiRegions[id]->BuildEdges();}; 00200 00201 void LineListClear(){ f_LineList.clear();}; 00202 void EdgeListClear(){ f_EdgeList.clear();}; 00203 void VertexListClear(){ f_VertexList.clear();}; 00204 int LineListSize(){ return static_cast<int>( f_LineList.size() );}; 00205 int EdgeListSize(){ return static_cast<int>( f_EdgeList.size() );}; 00206 int VertexListSize(){ return static_cast<int>( f_VertexList.size() );}; 00207 void AddLine(EdgeInfo x){ f_LineList.push_back(x);}; 00208 void AddEdge(VoronoiEdge x){ f_EdgeList.push_back(x);}; 00209 void AddVert(PointType x){ f_VertexList.push_back(x);}; 00210 EdgeInfo GetLine(int id){ return f_LineList[id];}; 00211 VoronoiEdge GetEdge(int id){ return f_EdgeList[id];}; 00212 PointType GetVertex(int id){ return f_VertexList[id];}; 00213 EdgeInfo GetEdgeEnd(int id){ 00214 EdgeInfo x; 00215 x[0]=f_EdgeList[id].m_LeftID; 00216 x[1]=f_EdgeList[id].m_RightID; 00217 return x; 00218 } 00219 int GetEdgeLineID(int id){ return f_EdgeList[id].m_LineID; }; 00220 00221 protected: 00222 VoronoiDiagram2D(); 00223 ~VoronoiDiagram2D(); 00224 virtual void PrintSelf(std::ostream& os, Indent indent) const; 00225 00226 00227 private: 00228 VoronoiDiagram2D(const Self&); //purposely not implemented 00229 void operator=(const Self&); //purposely not implemented 00230 00231 SeedsType m_Seeds; 00232 unsigned int m_NumberOfSeeds; 00233 std::vector<CellType *> m_VoronoiRegions; 00234 PointType m_VoronoiBoundary; 00235 PointType m_VoronoiBoundaryOrigin; 00236 std::vector< std::vector<int> > m_CellNeighborsID; 00237 00238 std::vector< EdgeInfo > f_LineList; 00239 std::vector< PointType > f_VertexList; 00240 std::vector< VoronoiEdge > f_EdgeList; 00241 00242 }; // end class: VoronoiDiagram2D 00243 00244 } // end namespace itk 00245 00246 #ifndef ITK_MANUAL_INSTANTIATION 00247 #include "itkVoronoiDiagram2D.txx" 00248 #endif 00249 00250 #endif 00251 00252

Generated at Sun Apr 1 02:47:23 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000