ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkTriangleCell.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkTriangleCell_h
00019 #define __itkTriangleCell_h
00020 
00021 #include "itkLineCell.h"
00022 #include "itkTriangleCellTopology.h"
00023 
00024 #include <vector>
00025 
00026 namespace itk
00027 {
00044 template< typename TCellInterface >
00045 class ITK_EXPORT TriangleCell:
00046   public TCellInterface, private TriangleCellTopology
00047 {
00048 public:
00050   itkCellCommonTypedefs(TriangleCell);
00051   itkCellInheritedTypedefs(TCellInterface);
00053 
00055   itkTypeMacro(TriangleCell, CellInterface);
00056 
00058   typedef VertexCell< TCellInterface >         VertexType;
00059   typedef typename VertexType::SelfAutoPointer VertexAutoPointer;
00060 
00062   typedef LineCell< TCellInterface >         EdgeType;
00063   typedef typename EdgeType::SelfAutoPointer EdgeAutoPointer;
00064 
00066   itkStaticConstMacro(NumberOfPoints, unsigned int, 3);
00067   itkStaticConstMacro(NumberOfVertices, unsigned int, 3);
00068   itkStaticConstMacro(NumberOfEdges, unsigned int, 3);
00069   itkStaticConstMacro(CellDimension, unsigned int, 2);
00071 
00073   virtual CellGeometry GetType(void) const
00074   { return Superclass::TRIANGLE_CELL; }
00075   virtual void MakeCopy(CellAutoPointer &) const;
00077 
00078   virtual unsigned int GetDimension(void) const;
00079 
00080   virtual unsigned int GetNumberOfPoints(void) const;
00081 
00082   virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const;
00083 
00084   virtual bool GetBoundaryFeature(int dimension, CellFeatureIdentifier,
00085                                   CellAutoPointer &);
00086   virtual void SetPointIds(PointIdConstIterator first);
00087 
00088   virtual void SetPointIds(PointIdConstIterator first,
00089                            PointIdConstIterator last);
00090 
00091   virtual void SetPointId(int localId, PointIdentifier);
00092   virtual PointIdIterator      PointIdsBegin(void);
00093 
00094   virtual PointIdConstIterator PointIdsBegin(void) const;
00095 
00096   virtual PointIdIterator      PointIdsEnd(void);
00097 
00098   virtual PointIdConstIterator PointIdsEnd(void) const;
00099 
00101   virtual CellFeatureCount GetNumberOfVertices(void) const;
00102 
00103   virtual CellFeatureCount GetNumberOfEdges(void) const;
00104 
00105   virtual bool GetVertex(CellFeatureIdentifier, VertexAutoPointer &);
00106   virtual bool GetEdge(CellFeatureIdentifier, EdgeAutoPointer &);
00107 
00108   virtual bool EvaluatePosition(CoordRepType *,
00109                                 PointsContainer *,
00110                                 CoordRepType *,
00111                                 CoordRepType[],
00112                                 double *,
00113                                 InterpolationWeightType *);
00114 
00116   itkCellVisitMacro(Superclass::TRIANGLE_CELL);
00117 
00119   CoordRepType ComputeArea(PointsContainer *);
00120 
00121   PointType ComputeBarycenter(CoordRepType *,
00122                               PointsContainer *);
00123 
00124   PointType ComputeCenterOfGravity(PointsContainer *);
00125 
00126   PointType ComputeCircumCenter(PointsContainer *);
00127 
00128 public:
00129   TriangleCell():
00130     m_PointIds( NumberOfPoints, NumericTraits< PointIdentifier >::max() )
00131   {}
00132   ~TriangleCell() {}
00133 protected:
00135   std::vector< PointIdentifier > m_PointIds;
00136 private:
00137   TriangleCell(const Self &);   //purposely not implemented
00138   void operator=(const Self &); //purposely not implemented
00140 
00143   double DistanceToLine(PointType x, PointType p1, PointType p2,
00144                         double & t, CoordRepType *closestPoint);
00145 
00146   double DistanceToLine(PointType x, PointType p1, PointType p2,
00147                         double & t, PointType & closestPoint);
00148 };
00149 } // end namespace itk
00150 
00151 #ifndef ITK_MANUAL_INSTANTIATION
00152 #include "itkTriangleCell.hxx"
00153 #endif
00154 
00155 #endif
00156