ITK  4.8.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 >
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  {}
133 
134 protected:
136  std::vector< PointIdentifier > m_PointIds;
137 
138 private:
139  TriangleCell(const Self &); //purposely not implemented
140  void operator=(const Self &); //purposely not implemented
141 
144  double DistanceToLine(PointType x, PointType p1, PointType p2,
145  double & t, CoordRepType *closestPoint);
146 
147  double DistanceToLine(PointType x, PointType p1, PointType p2,
148  double & t, PointType & closestPoint);
149 };
150 } // end namespace itk
151 
152 #ifndef ITK_MANUAL_INSTANTIATION
153 #include "itkTriangleCell.hxx"
154 #endif
155 
156 #endif
virtual bool GetBoundaryFeature(int dimension, CellFeatureIdentifier, CellAutoPointer &) override
VertexType::SelfAutoPointer VertexAutoPointer
PointType ComputeCenterOfGravity(PointsContainer *)
static const unsigned int CellDimension
virtual unsigned int GetDimension(void) const override
Represents a line segment for a Mesh.
Definition: itkLineCell.h:42
virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &)
virtual PointIdIterator PointIdsBegin(void) override
itkCellCommonTypedefs(TriangleCell)
virtual CellFeatureCount GetNumberOfEdges() const
virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const override
virtual void MakeCopy(CellAutoPointer &) const override
VertexCell< TCellInterface > VertexType
void operator=(const Self &)
An abstract interface for cells.
static const unsigned int NumberOfVertices
virtual CellFeatureCount GetNumberOfVertices() const
CoordRepType ComputeArea(PointsContainer *)
Compute Area to a TriangleCell given a PointsContainer.
double DistanceToLine(PointType x, PointType p1, PointType p2, double &t, CoordRepType *closestPoint)
virtual unsigned int GetNumberOfPoints(void) const override
virtual void SetPointId(int localId, PointIdentifier) override
virtual bool EvaluatePosition(CoordRepType *, PointsContainer *, CoordRepType *, CoordRepType[], double *, InterpolationWeightType *) override
static const unsigned int NumberOfEdges
virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &)
std::vector< PointIdentifier > m_PointIds
PointType ComputeCircumCenter(PointsContainer *)
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:39
itkCellInheritedTypedefs(TCellInterface)
static const unsigned int NumberOfPoints
LineCell< TCellInterface > EdgeType
PointType ComputeBarycenter(CoordRepType *, PointsContainer *)
Define additional traits for native types such as int or float.
EdgeType::SelfAutoPointer EdgeAutoPointer
virtual void SetPointIds(PointIdConstIterator first) override
virtual CellGeometry GetType(void) const override
virtual PointIdIterator PointIdsEnd(void) override
itkCellVisitMacro(Superclass::TRIANGLE_CELL)