ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkTriangleCell.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 #ifndef itkTriangleCell_h
19 #define itkTriangleCell_h
20 
21 #include "itkLineCell.h"
23 
24 #include <vector>
25 
26 namespace itk
27 {
44 template< typename TCellInterface >
45 class ITK_TEMPLATE_EXPORT TriangleCell:
46  public TCellInterface, private TriangleCellTopology
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(TriangleCell);
50 
53  itkCellInheritedTypedefs(TCellInterface);
55 
57  itkTypeMacro(TriangleCell, CellInterface);
58 
61  using VertexAutoPointer = typename VertexType::SelfAutoPointer;
62 
65  using EdgeAutoPointer = typename EdgeType::SelfAutoPointer;
66 
68  static constexpr unsigned int NumberOfPoints = 3;
69  static constexpr unsigned int NumberOfVertices = 3;
70  static constexpr unsigned int NumberOfEdges = 3;
71  static constexpr unsigned int CellDimension = 2;
72 
74  CellGeometry GetType() const override
75  { return Superclass::TRIANGLE_CELL; }
76  void MakeCopy(CellAutoPointer &) const override;
78 
79  unsigned int GetDimension() const override;
80 
81  unsigned int GetNumberOfPoints() const override;
82 
83  CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const override;
84 
85  bool GetBoundaryFeature(int dimension, CellFeatureIdentifier,
86  CellAutoPointer &) override;
87  void SetPointIds(PointIdConstIterator first) override;
88 
89  void SetPointIds(PointIdConstIterator first,
90  PointIdConstIterator last) override;
91 
92  void SetPointId(int localId, PointIdentifier) override;
93  PointIdIterator PointIdsBegin() override;
94 
95  PointIdConstIterator PointIdsBegin() const override;
96 
97  PointIdIterator PointIdsEnd() override;
98 
99  PointIdConstIterator PointIdsEnd() const override;
100 
102  virtual CellFeatureCount GetNumberOfVertices() const;
103 
104  virtual CellFeatureCount GetNumberOfEdges() const;
105 
106  virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
107  virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
108 
109  bool EvaluatePosition(CoordRepType *,
110  PointsContainer *,
111  CoordRepType *,
112  CoordRepType[],
113  double *,
114  InterpolationWeightType *) override;
115 
117  itkCellVisitMacro(Superclass::TRIANGLE_CELL);
118 
120  CoordRepType ComputeArea(PointsContainer *);
121 
122  PointType ComputeBarycenter(CoordRepType *,
123  PointsContainer *);
124 
125  PointType ComputeCenterOfGravity(PointsContainer *);
126 
127  PointType ComputeCircumCenter(PointsContainer *);
128 
129 public:
131  m_PointIds( NumberOfPoints, NumericTraits< PointIdentifier >::max() )
132  {}
133 #if defined(__GNUC__) && (__GNUC__ > 5)
134  ~TriangleCell() override = default;
135 #else
136  ~TriangleCell() override {};
137 #endif
138 
139 protected:
141  std::vector< PointIdentifier > m_PointIds;
142 
143 private:
146  double DistanceToLine(PointType x, PointType p1, PointType p2,
147  double & t, CoordRepType *closestPoint);
148 
149  double DistanceToLine(PointType x, PointType p1, PointType p2,
150  double & t, PointType & closestPoint);
151 };
152 } // end namespace itk
153 
154 #ifndef ITK_MANUAL_INSTANTIATION
155 #include "itkTriangleCell.hxx"
156 #endif
157 
158 #endif
Represents a line segment for a Mesh.
Definition: itkLineCell.h:42
typename VertexType::SelfAutoPointer VertexAutoPointer
Define numeric traits for std::vector.
An abstract interface for cells.
~TriangleCell() override
#define itkCellCommonTypedefs(celltype)
CellGeometry GetType() const override
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:39
#define itkCellVisitMacro(TopologyId)
typename EdgeType::SelfAutoPointer EdgeAutoPointer
#define itkCellInheritedTypedefs(superclassArg)