ITK  5.2.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  * 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
47  , private TriangleCellTopology
48 {
49 public:
50  ITK_DISALLOW_COPY_AND_MOVE(TriangleCell);
51 
54  itkCellInheritedTypedefs(TCellInterface);
56 
58  itkTypeMacro(TriangleCell, CellInterface);
59 
62  using VertexAutoPointer = typename VertexType::SelfAutoPointer;
63 
66  using EdgeAutoPointer = typename EdgeType::SelfAutoPointer;
67 
69  static constexpr unsigned int NumberOfPoints = 3;
70  static constexpr unsigned int NumberOfVertices = 3;
71  static constexpr unsigned int NumberOfEdges = 3;
72  static constexpr unsigned int CellDimension = 2;
73 
76  GetType() const override
77  {
79  }
80  void
81  MakeCopy(CellAutoPointer &) const override;
83 
84  unsigned int
85  GetDimension() const override;
86 
87  unsigned int
88  GetNumberOfPoints() const override;
89 
90  CellFeatureCount
91  GetNumberOfBoundaryFeatures(int dimension) const override;
92 
93  bool
94  GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &) override;
95  void
96  SetPointIds(PointIdConstIterator first) override;
97 
98  void
99  SetPointIds(PointIdConstIterator first, PointIdConstIterator last) override;
100 
101  void
102  SetPointId(int localId, PointIdentifier) override;
103  PointIdIterator
104  PointIdsBegin() override;
105 
106  PointIdConstIterator
107  PointIdsBegin() const override;
108 
109  PointIdIterator
110  PointIdsEnd() override;
111 
112  PointIdConstIterator
113  PointIdsEnd() const override;
114 
116  virtual CellFeatureCount
117  GetNumberOfVertices() const;
118 
119  virtual CellFeatureCount
120  GetNumberOfEdges() const;
121 
122  virtual bool
123  GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
124  virtual bool
125  GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
126 
127  bool
128  EvaluatePosition(CoordRepType *,
129  PointsContainer *,
130  CoordRepType *,
131  CoordRepType[],
132  double *,
133  InterpolationWeightType *) override;
134 
137 
139  CoordRepType
140  ComputeArea(PointsContainer *);
141 
142  PointType
143  ComputeBarycenter(CoordRepType *, PointsContainer *);
144 
145  PointType
146  ComputeCenterOfGravity(PointsContainer *);
147 
148  PointType
149  ComputeCircumCenter(PointsContainer *);
150 
151 public:
153  : m_PointIds(NumberOfPoints, NumericTraits<PointIdentifier>::max())
154  {}
155 #if defined(__GNUC__)
156  // A bug in some versions of the GCC and Clang compilers
157  // result in an ICE or linker error when "= default" is requested.
158  // This was observed in at least gcc 4.8 and 5.4.0, and
159  // AppleClang 7.0.2 and 8.0.0. Probably others too.
160  // "= default" doesn't gain us much, so just don't use it here.
161  ~TriangleCell() override{};
162 #else
163  ~TriangleCell() override = default;
164 #endif
165 
166 protected:
168  std::vector<PointIdentifier> m_PointIds;
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:39
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::m_PointIds
std::vector< PointIdentifier > m_PointIds
Definition: itkTriangleCell.h:168
itk::TriangleCell::VertexAutoPointer
typename VertexType::SelfAutoPointer VertexAutoPointer
Definition: itkTriangleCell.h:62
itk::TriangleCellTopology
Definition: itkTriangleCellTopology.h:36
itkTriangleCellTopology.h
itk::TriangleCell::TriangleCell
TriangleCell()
Definition: itkTriangleCell.h:152
itk::TriangleCell
Definition: itkTriangleCell.h:45
itkCellInheritedTypedefs
#define itkCellInheritedTypedefs(superclassArg)
Definition: itkCellInterface.h:55
itk::CommonEnums::CellGeometry
CellGeometry
Definition: itkCommonEnums.h:138
itk::LineCell
Represents a line segment for a Mesh.
Definition: itkLineCell.h:42
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
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:76
itk::TriangleCell::EdgeAutoPointer
typename EdgeType::SelfAutoPointer EdgeAutoPointer
Definition: itkTriangleCell.h:66
itkCellCommonTypedefs
#define itkCellCommonTypedefs(celltype)
Definition: itkCellInterface.h:46