Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkQuadEdgeMeshParamMatrixCoefficients.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdgeMeshParamMatrixCoefficients.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-03 21:55:06 $
00007   Version:   $Revision: 1.3 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkQuadEdgeMeshParamMatrixCoefficients_h
00019 #define __itkQuadEdgeMeshParamMatrixCoefficients_h
00020 
00021 #include "itkQuadEdgeMesh.h"
00022 #include "itkCrossHelper.h"
00023 #include "itkTriangleHelper.h"
00024 #include <vnl/vnl_math.h>
00025 
00026 namespace itk
00027 {
00032 template< typename TInputMesh >
00033 class MatrixCoefficients
00034 {
00035 public:
00036   typedef TInputMesh                              InputMeshType;
00037   typedef typename InputMeshType::CoordRepType    InputCoordRepType;
00038   typedef typename InputMeshType::QEType          InputQEType;
00039 
00040   MatrixCoefficients( ){}
00041   virtual ~MatrixCoefficients( ) {}
00042 
00043   virtual InputCoordRepType operator ( )
00044       ( InputMeshType* iMesh, InputQEType* iEdge ) const = 0;
00045 };
00046 
00053 template< typename TInputMesh >
00054 class OnesMatrixCoefficients : public MatrixCoefficients< TInputMesh >
00055 {
00056 public:
00057   typedef MatrixCoefficients< TInputMesh > Superclass;
00058 
00059   typedef TInputMesh                              InputMeshType;
00060   typedef typename InputMeshType::CoordRepType    InputCoordRepType;
00061   typedef typename InputMeshType::QEType          InputQEType;
00062 
00063   OnesMatrixCoefficients() {}
00064 
00070   InputCoordRepType operator ( ) ( InputMeshType * itkNotUsed( iMesh ),
00071                                    InputQEType *   itkNotUsed( iEdge ) ) const
00072     {
00073     return 1.0;
00074     }
00075 };
00077 
00084 template< typename TInputMesh >
00085 class InverseEuclideanDistanceMatrixCoefficients :
00086     public MatrixCoefficients< TInputMesh >
00087 {
00088 public:
00089   typedef MatrixCoefficients< TInputMesh > Superclass;
00090 
00091   typedef TInputMesh                              InputMeshType;
00092   typedef typename InputMeshType::CoordRepType    InputCoordRepType;
00093   typedef typename InputMeshType::PointType       InputPointType;
00094   typedef typename InputMeshType::PointIdentifier InputPointIdentifier;
00095   typedef typename InputMeshType::QEType          InputQEType;
00096   typedef typename InputMeshType::VectorType      InputVectorType;
00097 
00098   InverseEuclideanDistanceMatrixCoefficients() {}
00099 
00105   InputCoordRepType operator () ( InputMeshType* iMesh, InputQEType* iEdge ) const
00106     {
00107     InputPointIdentifier id1 = iEdge->GetOrigin( );
00108     InputPointIdentifier id2 = iEdge->GetDestination( );
00110 
00111     InputPointType pt1 = iMesh->GetPoint( id1 );
00112     InputPointType pt2 = iMesh->GetPoint( id2 );
00113 
00114     InputCoordRepType oValue = 1.0 / pt1.EuclideanDistanceTo( pt2 );
00115 
00116     return oValue;
00117     }
00118 };
00119 
00120 
00127 template< typename TInputMesh >
00128 class ConformalMatrixCoefficients : public MatrixCoefficients< TInputMesh >
00129 {
00130 public:
00131   typedef MatrixCoefficients< TInputMesh > Superclass;
00132 
00133   typedef TInputMesh                              InputMeshType;
00134   typedef typename InputMeshType::CoordRepType    InputCoordRepType;
00135   typedef typename InputMeshType::PointType       InputPointType;
00136   typedef typename InputMeshType::PointIdentifier InputPointIdentifier;
00137   typedef typename InputMeshType::QEType          InputQEType;
00138 
00139   ConformalMatrixCoefficients() { }
00140 
00146   InputCoordRepType operator ( ) ( InputMeshType* iMesh, InputQEType* iEdge ) const
00147     {
00148     InputPointIdentifier id1 = iEdge->GetOrigin( );
00149     InputPointIdentifier id2 = iEdge->GetDestination( );
00150     InputPointType pt1 = iMesh->GetPoint( id1 );
00151     InputPointType pt2 = iMesh->GetPoint( id2 );
00153 
00154     InputCoordRepType oValue( 0.0 );
00155 
00156     if( iEdge->IsLeftSet() )
00157       {
00158       InputPointIdentifier idA = iEdge->GetLnext( )->GetDestination( );
00159       InputPointType ptA = iMesh->GetPoint( idA );
00160       oValue += TriangleHelper< InputPointType >::Cotangent( pt1, ptA, pt2);
00161       }
00162     if( iEdge->IsRightSet() )
00163       {
00164       InputPointIdentifier idB = iEdge->GetRnext( )->GetOrigin( );
00165       InputPointType ptB = iMesh->GetPoint( idB );
00166       oValue += TriangleHelper< InputPointType >::Cotangent( pt1, ptB, pt2);
00167       }
00168 
00169     return vnl_math_max( static_cast< InputCoordRepType >( 0.0 ), oValue );
00170     }
00171 };
00172 
00180 template< typename TInputMesh >
00181 class AuthalicMatrixCoefficients : public MatrixCoefficients< TInputMesh >
00182 {
00183 public:
00184   typedef MatrixCoefficients< TInputMesh >        Superclass;
00185 
00186   typedef TInputMesh                              InputMeshType;
00187   typedef typename InputMeshType::CoordRepType    InputCoordRepType;
00188   typedef typename InputMeshType::PointType       InputPointType;
00189   typedef typename InputMeshType::PointIdentifier InputPointIdentifier;
00190   typedef typename InputMeshType::QEType          InputQEType;
00191 
00192   AuthalicMatrixCoefficients() { }
00193 
00200   InputCoordRepType operator ( ) ( InputMeshType* iMesh, InputQEType* iEdge ) const
00201     {
00202     InputPointIdentifier id1 = iEdge->GetOrigin( );
00203     InputPointType pt1 = iMesh->GetPoint( id1 );
00205 
00206     InputPointIdentifier id2 = iEdge->GetDestination( );
00207     InputPointType pt2 = iMesh->GetPoint( id2 );
00208     
00209     InputCoordRepType oValue( 0.0 );
00210 
00211     if( iEdge->IsLeftSet() )
00212       {
00213       InputPointIdentifier idA = iEdge->GetLnext( )->GetDestination( );
00214       InputPointType ptA = iMesh->GetPoint( idA );
00215       oValue +=
00216         TriangleHelper< InputPointType >::Cotangent( pt1, pt2, ptA );
00217       }
00218 
00219     if( iEdge->IsRightSet() )
00220       {
00221       InputPointIdentifier idB = iEdge->GetRnext( )->GetOrigin( );
00222       InputPointType ptB = iMesh->GetPoint( idB );
00223       oValue += TriangleHelper< InputPointType >::Cotangent( pt1, pt2, ptB );
00224       }
00225 
00226     return oValue / pt1.EuclideanDistanceTo( pt2 );
00227     }
00228 };
00229 
00236 template< typename TInputMesh >
00237 class IntrinsicMatrixCoefficients : public MatrixCoefficients< TInputMesh >
00238 {
00239 public:
00240   typedef MatrixCoefficients< TInputMesh >        Superclass;
00241 
00242   typedef TInputMesh                              InputMeshType;
00243   typedef typename InputMeshType::CoordRepType    InputCoordRepType;
00244   typedef typename InputMeshType::QEType          InputQEType;
00245 
00246   InputCoordRepType m_Lambda;
00247 
00248   IntrinsicMatrixCoefficients( const InputCoordRepType& iLambda ) :
00249       m_Lambda( iLambda )
00250     { }
00251 
00252   InputCoordRepType operator ( ) ( InputMeshType* iMesh,
00253                                   InputQEType* iEdge ) const
00254     {
00255     AuthalicMatrixCoefficients< TInputMesh >   authalic;
00256     ConformalMatrixCoefficients< TInputMesh >  conformal;
00257 
00258     InputCoordRepType oValue = m_Lambda * conformal( iMesh, iEdge )
00259       + ( 1.0 - m_Lambda ) * authalic( iMesh, iEdge );
00260 
00261     return oValue;
00262     }
00263 };
00264 
00271 template< typename TInputMesh >
00272 class HarmonicMatrixCoefficients : public MatrixCoefficients< TInputMesh >
00273 {
00274 public:
00275   typedef MatrixCoefficients< TInputMesh > Superclass;
00276 
00277   typedef TInputMesh                                InputMeshType;
00278   typedef typename InputMeshType::CoordRepType      InputCoordRepType;
00279   typedef typename InputMeshType::PointType         InputPointType;
00280   typedef typename InputPointType::VectorType       InputVectorType;
00281   typedef typename InputMeshType::PointIdentifier   InputPointIdentifier;
00282   typedef typename InputMeshType::QEType            InputQEType;
00283 
00284   itkStaticConstMacro( PointDimension, unsigned int,
00285       InputPointType::PointDimension );
00286 
00287 
00288   HarmonicMatrixCoefficients() { }
00289 
00290 
00291   InputCoordRepType operator () ( InputMeshType* iMesh, InputQEType* iEdge ) const
00292     {
00293     InputPointIdentifier id1 = iEdge->GetOrigin( );
00294     InputPointIdentifier id2 = iEdge->GetDestination( );
00295 
00296     InputPointIdentifier idA = iEdge->GetLnext( )->GetDestination( );
00297     InputPointIdentifier idB = iEdge->GetRnext( )->GetOrigin( );
00298 
00299     InputPointType pt1 = iMesh->GetPoint( id1 );
00300     InputPointType pt2 = iMesh->GetPoint( id2 );
00301     InputPointType ptA = iMesh->GetPoint( idA );
00302     InputPointType ptB = iMesh->GetPoint( idB );
00303 
00304     InputVectorType v1A = ptA - pt1;
00305     InputVectorType v1B = ptB - pt1;
00306     InputVectorType v12 = pt2 - pt1;
00307 
00308     InputCoordRepType L1A = v1A * v1A;
00309     InputCoordRepType L1B = v1B * v1B;
00310     InputCoordRepType L12 = v12 * v12;
00311 
00312     InputCoordRepType L2A = pt2.SquaredEuclideanDistanceTo( ptA );
00313     InputCoordRepType L2B = pt2.SquaredEuclideanDistanceTo( ptB );
00314 
00315     CrossHelper< InputVectorType > cross;
00316 
00317     InputCoordRepType AreaA = 0.5 * ( cross( v1A, v12 ).GetNorm( ) );
00318     InputCoordRepType AreaB = 0.5 * ( cross( v1B, v12 ).GetNorm( ) );
00319 
00320     InputCoordRepType
00321         oValue = ( L1A + L2A - L12 ) / AreaA + ( L1B + L2B - L12 ) / AreaB;
00322 
00323     return oValue;
00324     }
00325 };
00326 
00327 }
00328 #endif
00329 

Generated at Tue Sep 15 04:28:19 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000