ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkPolygonCell.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkPolygonCell_h
29 #define __itkPolygonCell_h
30 
31 #include "itkLineCell.h"
32 #include "itkPoint.h"
33 #include <vector>
34 #include <deque>
35 
36 namespace itk
37 {
52 template< typename TCellInterface >
53 class ITK_EXPORT PolygonCell:public TCellInterface
54 {
55 public:
58  itkCellInheritedTypedefs(TCellInterface);
60 
62  itkTypeMacro(PolygonCell, CellInterface);
63 
65  itkStaticConstMacro(CellDimension, unsigned int, 2);
66 
69  typedef typename VertexType::SelfAutoPointer VertexAutoPointer;
70 
73  typedef typename EdgeType::SelfAutoPointer EdgeAutoPointer;
74 
76  typedef std::deque< EdgeInfo > EdgeInfoDQ;
77 
79  itkCellVisitMacro(Superclass::POLYGON_CELL);
80 
82  virtual CellGeometry GetType(void) const
83  { return Superclass::POLYGON_CELL; }
84  virtual void MakeCopy(CellAutoPointer &) const;
86 
87  virtual unsigned int GetDimension(void) const;
88 
89  virtual unsigned int GetNumberOfPoints(void) const;
90 
91  virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const;
92 
93  virtual bool GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &);
94 
95  virtual void SetPointIds(PointIdConstIterator first);
96 
97  virtual void SetPointIds(PointIdConstIterator first,
98  PointIdConstIterator last);
99 
100  void AddPointId(PointIdentifier);
101  void RemovePointId(PointIdentifier);
102  void SetPointIds(int dummy, int num, PointIdConstIterator first);
103 
104  void BuildEdges(void);
105 
106  void ClearPoints(void);
107 
108  virtual void SetPointId(int localId, PointIdentifier);
109  virtual PointIdIterator PointIdsBegin(void);
110 
111  virtual PointIdConstIterator PointIdsBegin(void) const;
112 
113  virtual PointIdIterator PointIdsEnd(void);
114 
115  virtual PointIdConstIterator PointIdsEnd(void) const;
116 
118  virtual CellFeatureCount GetNumberOfVertices(void) const;
119 
120  virtual CellFeatureCount GetNumberOfEdges(void) const;
121 
122  virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
123  virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
124 
127  PolygonCell(PointIdentifier NumberOfPoints)
128  {
129  for ( PointIdentifier i = 0; i < NumberOfPoints; i++ )
130  {
131  m_PointIds.push_back( NumericTraits< PointIdentifier >::max() );
132  }
133  this->BuildEdges();
134  }
136 
138 
139 protected:
140  std::vector< EdgeInfo > m_Edges;
141  std::vector< PointIdentifier > m_PointIds;
142 
143 private:
144  PolygonCell(const Self &); //purposely not implemented
145  void operator=(const Self &); //purposely not implemented
146 };
147 } //end namespace
148 
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "itkPolygonCell.hxx"
151 #endif
152 
153 #endif
154