ITK  5.0.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_TEMPLATE_EXPORT PolygonCell:public TCellInterface
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_ASSIGN(PolygonCell);
57 
60  itkCellInheritedTypedefs(TCellInterface);
62 
64  itkTypeMacro(PolygonCell, CellInterface);
65 
67  static constexpr unsigned int CellDimension = 2;
68 
71  using VertexAutoPointer = typename VertexType::SelfAutoPointer;
72 
75  using EdgeAutoPointer = typename EdgeType::SelfAutoPointer;
76 
78  using EdgeInfoDQ = std::deque< EdgeInfo >;
79 
81  itkCellVisitMacro(Superclass::POLYGON_CELL);
82 
84  CellGeometry GetType() const override
85  { return Superclass::POLYGON_CELL; }
86  void MakeCopy(CellAutoPointer &) const override;
88 
89  unsigned int GetDimension() const override;
90 
91  unsigned int GetNumberOfPoints() const override;
92 
93  CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const override;
94 
95  bool GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &) override;
96 
97  void SetPointIds(PointIdConstIterator first) override;
98 
99  void SetPointIds(PointIdConstIterator first,
100  PointIdConstIterator last) override;
101 
102  void AddPointId(PointIdentifier);
103  void RemovePointId(PointIdentifier);
104  void SetPointIds(int dummy, int num, PointIdConstIterator first);
105 
106  void BuildEdges();
107 
108  void ClearPoints();
109 
110  void SetPointId(int localId, PointIdentifier) override;
111  PointIdIterator PointIdsBegin() override;
112 
113  PointIdConstIterator PointIdsBegin() const override;
114 
115  PointIdIterator PointIdsEnd() override;
116 
117  PointIdConstIterator PointIdsEnd() const override;
118 
120  virtual CellFeatureCount GetNumberOfVertices() const;
121 
122  virtual CellFeatureCount GetNumberOfEdges() const;
123 
124  virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
125  virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
126 
128  PolygonCell() = default;
129  PolygonCell(PointIdentifier NumberOfPoints)
130  {
131  for ( PointIdentifier i = 0; i < NumberOfPoints; i++ )
132  {
133  m_PointIds.push_back( NumericTraits< PointIdentifier >::max() );
134  }
135  this->BuildEdges();
136  }
138 
139  ~PolygonCell() override = default;
140 
141 protected:
142  std::vector< EdgeInfo > m_Edges;
143  std::vector< PointIdentifier > m_PointIds;
144 };
145 } //end namespace
146 
147 #ifndef ITK_MANUAL_INSTANTIATION
148 #include "itkPolygonCell.hxx"
149 #endif
150 
151 #endif
Represents a line segment for a Mesh.
Definition: itkLineCell.h:42
Define numeric traits for std::vector.
std::deque< EdgeInfo > EdgeInfoDQ
typename VertexType::SelfAutoPointer VertexAutoPointer
An abstract interface for cells.
PolygonCell(PointIdentifier NumberOfPoints)
Simulate a standard C array with copy semnatics.
Definition: itkFixedArray.h:51
#define itkCellCommonTypedefs(celltype)
typename EdgeType::SelfAutoPointer EdgeAutoPointer
Represents a polygon in a Mesh.
CellGeometry GetType() const override
std::vector< PointIdentifier > m_PointIds
std::vector< EdgeInfo > m_Edges
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:39
#define itkCellVisitMacro(TopologyId)
#define itkCellInheritedTypedefs(superclassArg)