ITK  5.4.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  itkTypeMacro(TriangleCell, CellInterface);
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 
77  GetType() const override
78  {
80  }
81  void
82  MakeCopy(CellAutoPointer &) const override;
85  unsigned int
86  GetDimension() const override;
87 
88  unsigned int
89  GetNumberOfPoints() const override;
90 
91  CellFeatureCount
92  GetNumberOfBoundaryFeatures(int dimension) const override;
93 
94  bool
95  GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &) override;
96  void
97  SetPointIds(PointIdConstIterator first) override;
98 
99  void
100  SetPointIds(PointIdConstIterator first, PointIdConstIterator last) override;
101 
102  void
103  SetPointId(int localId, PointIdentifier) override;
104  PointIdIterator
105  PointIdsBegin() override;
106 
107  PointIdConstIterator
108  PointIdsBegin() const override;
109 
110  PointIdIterator
111  PointIdsEnd() override;
112 
113  PointIdConstIterator
114  PointIdsEnd() const override;
115 
117  virtual CellFeatureCount
118  GetNumberOfVertices() const;
119 
120  virtual CellFeatureCount
121  GetNumberOfEdges() const;
122 
123  virtual bool
124  GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
125  virtual bool
126  GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
127 
128  bool
129  EvaluatePosition(CoordRepType *,
130  PointsContainer *,
131  CoordRepType *,
132  CoordRepType[],
133  double *,
134  InterpolationWeightType *) override;
135 
138 
140  CoordRepType
141  ComputeArea(PointsContainer *);
142 
143  PointType
144  ComputeBarycenter(CoordRepType *, PointsContainer *);
145 
146  PointType
147  ComputeCenterOfGravity(PointsContainer *);
148 
149  PointType
150  ComputeCircumCenter(PointsContainer *);
151 
152 public:
153  TriangleCell() = default;
154 #if defined(__GNUC__)
155  // A bug in some versions of the GCC and Clang compilers
156  // result in an ICE or linker error when "= default" is requested.
157  // This was observed in at least gcc 4.8 and 5.4.0, and
158  // AppleClang 7.0.2 and 8.0.0. Probably others too.
159  // "= default" doesn't gain us much, so just don't use it here.
160  ~TriangleCell() override{};
161 #else
162  ~TriangleCell() override = default;
163 #endif
164 
165 protected:
167  std::array<PointIdentifier, NumberOfPoints> m_PointIds{ MakeFilled<std::array<PointIdentifier, NumberOfPoints>>(
169 
170 private:
173  double
174  DistanceToLine(PointType x, PointType p1, PointType p2, double & t, CoordRepType * closestPoint);
175 
176  double
177  DistanceToLine(PointType x, PointType p1, PointType p2, double & t, PointType & closestPoint);
178 };
179 } // end namespace itk
180 
181 #ifndef ITK_MANUAL_INSTANTIATION
182 # include "itkTriangleCell.hxx"
183 #endif
184 
185 #endif
itk::VertexCell
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:42
itk::CommonEnums::CellGeometry::TRIANGLE_CELL
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
itkTriangleCellTopology.h
itk::TriangleCell
Definition: itkTriangleCell.h:46
itkCellInheritedTypedefs
#define itkCellInheritedTypedefs(superclassArg)
Definition: itkCellInterface.h:55
itkMakeFilled.h
itk::CommonEnums::CellGeometry
CellGeometry
Definition: itkCommonEnums.h:138
itk::LineCell
Represents a line segment for a Mesh.
Definition: itkLineCell.h:45
itk::NumericTraits::max
static constexpr T max(const T &)
Definition: itkNumericTraits.h:168
itk::CellInterface
An abstract interface for cells.
Definition: itkCellInterface.h:96
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::TriangleCell::GetType
CellGeometryEnum GetType() const override
Definition: itkTriangleCell.h:77
itk::TriangleCell::EdgeAutoPointer
typename EdgeType::SelfAutoPointer EdgeAutoPointer
Definition: itkTriangleCell.h:67
itkCellCommonTypedefs
#define itkCellCommonTypedefs(celltype)
Definition: itkCellInterface.h:46