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 
27 namespace itk
28 {
45 template <typename TCellInterface>
46 class ITK_TEMPLATE_EXPORT TriangleCell
47  : public TCellInterface
48  , private TriangleCellTopology
49 {
50 public:
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
142  GetNumberOfVertices() const;
143 
145  virtual CellFeatureCount
146  GetNumberOfEdges() const;
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 
176  PointType
177  ComputeBarycenter(CoordRepType *, PointsContainer *);
178 
179  PointType
180  ComputeCenterOfGravity(PointsContainer *);
181 
182  PointType
183  ComputeCircumCenter(PointsContainer *);
184 
185 public:
186  TriangleCell() = default;
187  ~TriangleCell() override = default;
188 
189 protected:
191  std::array<PointIdentifier, NumberOfPoints> m_PointIds{ MakeFilled<std::array<PointIdentifier, NumberOfPoints>>(
193 
194 private:
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
itk::VertexCell
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:37
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itkCellVisitMacro
#define itkCellVisitMacro(TopologyId)
Definition: itkCellInterface.h:32
itkLineCell.h
itk::TriangleCell::VertexAutoPointer
typename VertexType::SelfAutoPointer VertexAutoPointer
Definition: itkTriangleCell.h:63
itk::TriangleCellTopology
Definition: itkTriangleCellTopology.h:36
itk::CommonEnums::CellGeometry
CellGeometry
Definition: itkCommonEnums.h:132
itkTriangleCellTopology.h
itk::TriangleCell
Definition: itkTriangleCell.h:46
itkCellInheritedTypedefs
#define itkCellInheritedTypedefs(superclassArg)
Definition: itkCellInterface.h:56
itkMakeFilled.h
itk::LineCell
Represents a line segment for a Mesh.
Definition: itkLineCell.h:40
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:169
itk::CommonEnums::CellGeometry::TRIANGLE_CELL
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::TriangleCell::GetType
CellGeometryEnum GetType() const override
Definition: itkTriangleCell.h:79
itk::TriangleCell::EdgeAutoPointer
typename EdgeType::SelfAutoPointer EdgeAutoPointer
Definition: itkTriangleCell.h:67
itkCellCommonTypedefs
#define itkCellCommonTypedefs(celltype)
Definition: itkCellInterface.h:47