ITK  6.0.0
Insight Toolkit
itkTriangleCell.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 * https://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#include "itkMakeFilled.h"
24
25#include <array>
26
27namespace itk
28{
45template <typename TCellInterface>
46class ITK_TEMPLATE_EXPORT TriangleCell
47 : public TCellInterface
48 , private TriangleCellTopology
49{
50public:
51 ITK_DISALLOW_COPY_AND_MOVE(TriangleCell);
52
55 itkCellInheritedTypedefs(TCellInterface);
59 itkOverrideGetNameOfClassMacro(TriangleCell);
60
63 using VertexAutoPointer = typename VertexType::SelfAutoPointer;
64
67 using EdgeAutoPointer = typename EdgeType::SelfAutoPointer;
68
70 static constexpr unsigned int NumberOfPoints = 3;
71 static constexpr unsigned int NumberOfVertices = 3;
72 static constexpr unsigned int NumberOfEdges = 3;
73 static constexpr unsigned int CellDimension = 2;
74
75 // Standard CellInterface
76
79 GetType() const override
80 {
82 }
83 void
84 MakeCopy(CellAutoPointer &) const override;
88 unsigned int
89 GetDimension() const override;
90
92 unsigned int
93 GetNumberOfPoints() const override;
94
96 CellFeatureCount
97 GetNumberOfBoundaryFeatures(int dimension) const override;
98
102 bool
103 GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &) override;
104
108 void
109 SetPointIds(PointIdConstIterator first) override;
110
115 void
116 SetPointIds(PointIdConstIterator first, PointIdConstIterator last) override;
117
119 void
120 SetPointId(int localId, PointIdentifier) override;
121
123 PointIdIterator
124 PointIdsBegin() override;
125
127 PointIdConstIterator
128 PointIdsBegin() const override;
129
131 PointIdIterator
132 PointIdsEnd() override;
133
135 PointIdConstIterator
136 PointIdsEnd() const override;
137
138 // Triangle-specific interface
139
141 virtual CellFeatureCount
143
145 virtual CellFeatureCount
147
151 virtual bool
152 GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
153
157 virtual bool
158 GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
159
161 bool
162 EvaluatePosition(CoordRepType *,
163 PointsContainer *,
164 CoordRepType *,
165 CoordRepType[],
166 double *,
167 InterpolationWeightType *) override;
168
171
173 CoordRepType
174 ComputeArea(PointsContainer *);
175
177 ComputeBarycenter(CoordRepType *, PointsContainer *);
178
180 ComputeCenterOfGravity(PointsContainer *);
181
183 ComputeCircumCenter(PointsContainer *);
184
185public:
186 TriangleCell() = default;
187 ~TriangleCell() override = default;
188
189protected:
191 std::array<PointIdentifier, NumberOfPoints> m_PointIds{ MakeFilled<std::array<PointIdentifier, NumberOfPoints>>(
193
194private:
197 double
198 DistanceToLine(PointType x, PointType p1, PointType p2, double & t, CoordRepType * closestPoint);
199
200 double
201 DistanceToLine(PointType x, PointType p1, PointType p2, double & t, PointType & closestPoint);
202};
203} // end namespace itk
204
205#ifndef ITK_MANUAL_INSTANTIATION
206# include "itkTriangleCell.hxx"
207#endif
208
209#endif
Represents a line segment for a Mesh.
Definition: itkLineCell.h:41
static constexpr T max(const T &)
typename EdgeType::SelfAutoPointer EdgeAutoPointer
PointType ComputeCircumCenter(PointsContainer *)
bool GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &) override
virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &)
bool EvaluatePosition(CoordRepType *, PointsContainer *, CoordRepType *, CoordRepType[], double *, InterpolationWeightType *) override
virtual CellFeatureCount GetNumberOfVertices() const
itkCellInheritedTypedefs(TCellInterface)
PointIdConstIterator PointIdsEnd() const override
~TriangleCell() override=default
void SetPointId(int localId, PointIdentifier) override
PointIdConstIterator PointIdsBegin() const override
void SetPointIds(PointIdConstIterator first) override
unsigned int GetNumberOfPoints() const override
typename VertexType::SelfAutoPointer VertexAutoPointer
CellGeometryEnum GetType() const override
double DistanceToLine(PointType x, PointType p1, PointType p2, double &t, CoordRepType *closestPoint)
itkCellVisitMacro(CellGeometryEnum::TRIANGLE_CELL)
CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const override
virtual CellFeatureCount GetNumberOfEdges() const
TriangleCell()=default
PointType ComputeBarycenter(CoordRepType *, PointsContainer *)
unsigned int GetDimension() const override
PointIdIterator PointIdsEnd() override
PointIdIterator PointIdsBegin() override
virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &)
double DistanceToLine(PointType x, PointType p1, PointType p2, double &t, PointType &closestPoint)
itkCellCommonTypedefs(TriangleCell)
CoordRepType ComputeArea(PointsContainer *)
PointType ComputeCenterOfGravity(PointsContainer *)
void MakeCopy(CellAutoPointer &) const override
void SetPointIds(PointIdConstIterator first, PointIdConstIterator last) override
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:38
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....