ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkTriangleCell.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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, private TriangleCellTopology
47 {
48 public:
51  itkCellInheritedTypedefs(TCellInterface);
53 
55  itkTypeMacro(TriangleCell, CellInterface);
56 
59  typedef typename VertexType::SelfAutoPointer VertexAutoPointer;
60 
63  typedef typename EdgeType::SelfAutoPointer EdgeAutoPointer;
64 
66  itkStaticConstMacro(NumberOfPoints, unsigned int, 3);
67  itkStaticConstMacro(NumberOfVertices, unsigned int, 3);
68  itkStaticConstMacro(NumberOfEdges, unsigned int, 3);
69  itkStaticConstMacro(CellDimension, unsigned int, 2);
71 
73  virtual CellGeometry GetType(void) const ITK_OVERRIDE
74  { return Superclass::TRIANGLE_CELL; }
75  virtual void MakeCopy(CellAutoPointer &) const ITK_OVERRIDE;
77 
78  virtual unsigned int GetDimension(void) const ITK_OVERRIDE;
79 
80  virtual unsigned int GetNumberOfPoints(void) const ITK_OVERRIDE;
81 
82  virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const ITK_OVERRIDE;
83 
84  virtual bool GetBoundaryFeature(int dimension, CellFeatureIdentifier,
85  CellAutoPointer &) ITK_OVERRIDE;
86  virtual void SetPointIds(PointIdConstIterator first) ITK_OVERRIDE;
87 
88  virtual void SetPointIds(PointIdConstIterator first,
89  PointIdConstIterator last) ITK_OVERRIDE;
90 
91  virtual void SetPointId(int localId, PointIdentifier) ITK_OVERRIDE;
92  virtual PointIdIterator PointIdsBegin(void) ITK_OVERRIDE;
93 
94  virtual PointIdConstIterator PointIdsBegin(void) const ITK_OVERRIDE;
95 
96  virtual PointIdIterator PointIdsEnd(void) ITK_OVERRIDE;
97 
98  virtual PointIdConstIterator PointIdsEnd(void) const ITK_OVERRIDE;
99 
101  virtual CellFeatureCount GetNumberOfVertices() const;
102 
103  virtual CellFeatureCount GetNumberOfEdges() const;
104 
105  virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
106  virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
107 
108  virtual bool EvaluatePosition(CoordRepType *,
109  PointsContainer *,
110  CoordRepType *,
111  CoordRepType[],
112  double *,
113  InterpolationWeightType *) ITK_OVERRIDE;
114 
116  itkCellVisitMacro(Superclass::TRIANGLE_CELL);
117 
119  CoordRepType ComputeArea(PointsContainer *);
120 
121  PointType ComputeBarycenter(CoordRepType *,
122  PointsContainer *);
123 
124  PointType ComputeCenterOfGravity(PointsContainer *);
125 
126  PointType ComputeCircumCenter(PointsContainer *);
127 
128 public:
130  m_PointIds( NumberOfPoints, NumericTraits< PointIdentifier >::max() )
131  {}
132  ~TriangleCell() ITK_OVERRIDE {}
133 
134 protected:
136  std::vector< PointIdentifier > m_PointIds;
137 
138 private:
139  ITK_DISALLOW_COPY_AND_ASSIGN(TriangleCell);
140 
143  double DistanceToLine(PointType x, PointType p1, PointType p2,
144  double & t, CoordRepType *closestPoint);
145 
146  double DistanceToLine(PointType x, PointType p1, PointType p2,
147  double & t, PointType & closestPoint);
148 };
149 } // end namespace itk
150 
151 #ifndef ITK_MANUAL_INSTANTIATION
152 #include "itkTriangleCell.hxx"
153 #endif
154 
155 #endif
VertexType::SelfAutoPointer VertexAutoPointer
Represents a line segment for a Mesh.
Definition: itkLineCell.h:42
VertexCell< TCellInterface > VertexType
An abstract interface for cells.
~TriangleCell() override
#define itkCellCommonTypedefs(celltype)
std::vector< PointIdentifier > m_PointIds
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:39
#define itkCellVisitMacro(TopologyId)
LineCell< TCellInterface > EdgeType
Define additional traits for native types such as int or float.
EdgeType::SelfAutoPointer EdgeAutoPointer
#define itkCellInheritedTypedefs(superclassArg)
virtual CellGeometry GetType(void) const override