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);
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 #if defined(__GNUC__)
188  // A bug in some versions of the GCC and Clang compilers
189  // result in an ICE or linker error when "= default" is requested.
190  // This was observed in at least gcc 4.8 and 5.4.0, and
191  // AppleClang 7.0.2 and 8.0.0. Probably others too.
192  // "= default" doesn't gain us much, so just don't use it here.
193  ~TriangleCell() override{};
194 #else
195  ~TriangleCell() override = default;
196 #endif
197 
198 protected:
200  std::array<PointIdentifier, NumberOfPoints> m_PointIds{ MakeFilled<std::array<PointIdentifier, NumberOfPoints>>(
202 
203 private:
206  double
207  DistanceToLine(PointType x, PointType p1, PointType p2, double & t, CoordRepType * closestPoint);
208 
209  double
210  DistanceToLine(PointType x, PointType p1, PointType p2, double & t, PointType & closestPoint);
211 };
212 } // end namespace itk
213 
214 #ifndef ITK_MANUAL_INSTANTIATION
215 # include "itkTriangleCell.hxx"
216 #endif
217 
218 #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
itkOverrideGetNameOfClassMacro
itkOverrideGetNameOfClassMacro(AddImageFilter)
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
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:79
itk::TriangleCell::EdgeAutoPointer
typename EdgeType::SelfAutoPointer EdgeAutoPointer
Definition: itkTriangleCell.h:67
itkCellCommonTypedefs
#define itkCellCommonTypedefs(celltype)
Definition: itkCellInterface.h:46