ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkPolygonCell.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 __itkPolygonCell_h
00029 #define __itkPolygonCell_h
00030 
00031 #include "itkLineCell.h"
00032 #include "itkPoint.h"
00033 #include <vector>
00034 #include <deque>
00035 
00036 namespace itk
00037 {
00052 template< typename TCellInterface >
00053 class ITK_EXPORT PolygonCell:public TCellInterface
00054 {
00055 public:
00057   itkCellCommonTypedefs(PolygonCell);
00058   itkCellInheritedTypedefs(TCellInterface);
00060 
00062   itkTypeMacro(PolygonCell, CellInterface);
00063 
00065   itkStaticConstMacro(CellDimension, unsigned int, 2);
00066 
00068   typedef VertexCell< TCellInterface >         VertexType;
00069   typedef typename VertexType::SelfAutoPointer VertexAutoPointer;
00070 
00072   typedef LineCell< TCellInterface >         EdgeType;
00073   typedef typename EdgeType::SelfAutoPointer EdgeAutoPointer;
00074 
00075   typedef FixedArray< int, 2 >   EdgeInfo;
00076   typedef std::deque< EdgeInfo > EdgeInfoDQ;
00077 
00079   itkCellVisitMacro(Superclass::POLYGON_CELL);
00080 
00082   virtual CellGeometry GetType(void) const
00083   { return Superclass::POLYGON_CELL; }
00084   virtual void MakeCopy(CellAutoPointer &) const;
00086 
00087   virtual unsigned int GetDimension(void) const;
00088 
00089   virtual unsigned int GetNumberOfPoints(void) const;
00090 
00091   virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const;
00092 
00093   virtual bool GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &);
00094 
00095   virtual void SetPointIds(PointIdConstIterator first);
00096 
00097   virtual void SetPointIds(PointIdConstIterator first,
00098                            PointIdConstIterator last);
00099 
00100   void AddPointId(PointIdentifier);
00101   void RemovePointId(PointIdentifier);
00102   void SetPointIds(int dummy, int num, PointIdConstIterator first);
00103 
00104   void BuildEdges(void);
00105 
00106   void ClearPoints(void);
00107 
00108   virtual void SetPointId(int localId, PointIdentifier);
00109   virtual PointIdIterator      PointIdsBegin(void);
00110 
00111   virtual PointIdConstIterator PointIdsBegin(void) const;
00112 
00113   virtual PointIdIterator      PointIdsEnd(void);
00114 
00115   virtual PointIdConstIterator PointIdsEnd(void) const;
00116 
00118   virtual CellFeatureCount GetNumberOfVertices(void) const;
00119 
00120   virtual CellFeatureCount GetNumberOfEdges(void) const;
00121 
00122   virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
00123   virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
00124 
00126   PolygonCell() {}
00127   PolygonCell(PointIdentifier NumberOfPoints)
00128   {
00129     for ( PointIdentifier i = 0; i < NumberOfPoints; i++ )
00130       {
00131       m_PointIds.push_back( NumericTraits< PointIdentifier >::max() );
00132       }
00133     this->BuildEdges();
00134   }
00136 
00137   ~PolygonCell() {}
00138 protected:
00139   std::vector< EdgeInfo >        m_Edges;
00140   std::vector< PointIdentifier > m_PointIds;
00141 private:
00142   PolygonCell(const Self &);    //purposely not implemented
00143   void operator=(const Self &); //purposely not implemented
00144 };
00145 } //end namespace
00146 
00147 #ifndef ITK_MANUAL_INSTANTIATION
00148 #include "itkPolygonCell.hxx"
00149 #endif
00150 
00151 #endif
00152