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

itkQuadEdgeMeshDelaunayConformingFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdgeMeshDelaunayConformingFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-07 20:13:57 $
00007   Version:   $Revision: 1.4 $
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 __itkQuadEdgeMeshDelaunayConformingFilter_h
00019 #define __itkQuadEdgeMeshDelaunayConformingFilter_h
00020 
00021 #include "itkPriorityQueueContainer.h"
00022 #include <itkQuadEdgeMeshToQuadEdgeMeshFilter.h>
00023 #include <itkQuadEdgeMeshEulerOperatorFlipEdgeFunction.h>
00024 
00025 namespace itk
00026 {
00033 template< class TInputMesh, class TOutputMesh >
00034 class QuadEdgeMeshDelaunayConformingFilter :
00035   public QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh, TOutputMesh >
00036 {
00037 public:
00038 
00040   typedef QuadEdgeMeshDelaunayConformingFilter              Self;
00041   typedef QuadEdgeMeshToQuadEdgeMeshFilter< TInputMesh,
00042     TOutputMesh >                                           Superclass;
00043   typedef SmartPointer< Self >                              Pointer;
00044   typedef SmartPointer< const Self >                        ConstPointer;
00045 
00047   typedef TInputMesh                                        InputMeshType;
00048   typedef typename InputMeshType::Pointer                   InputMeshPointer;
00049   typedef typename InputMeshType::CoordRepType              InputCoordRepType;
00050   typedef typename InputMeshType::PointType                 InputPointType;
00051   typedef typename InputPointType::VectorType               InputPointVectorType;
00052   typedef typename InputMeshType::PointIdentifier           InputPointIdentifier;
00053   typedef typename InputMeshType::QEType                    InputQEType;
00054   typedef typename InputMeshType::VectorType                InputVectorType;
00055   typedef typename InputMeshType::EdgeListType              InputEdgeListType;
00056   typedef typename InputMeshType::PixelType                 InputPixelType;
00057   typedef typename InputMeshType::Traits                    InputTraits;
00058 
00059   itkStaticConstMacro( InputVDimension, unsigned int, InputMeshType::PointDimension );
00060 
00061   typedef typename InputMeshType::PointsContainer               InputPointsContainer;
00062   typedef typename InputMeshType::PointsContainerConstIterator  InputPointsContainerConstIterator;
00063   typedef typename InputMeshType::CellsContainerConstIterator   InputCellsContainerConstIterator;
00064   typedef typename InputMeshType::EdgeCellType                  InputEdgeCellType;
00065   typedef typename InputMeshType::PolygonCellType               InputPolygonCellType;
00066   typedef typename InputMeshType::PointIdList                   InputPointIdList;
00067 
00068   typedef typename InputQEType::IteratorGeom                  InputQEIterator;
00069 
00071   typedef TOutputMesh                                         OutputMeshType;
00072   typedef typename OutputMeshType::Pointer                    OutputMeshPointer;
00073   typedef typename OutputMeshType::CoordRepType               OutputCoordRepType;
00074   typedef typename OutputMeshType::PointType                  OutputPointType;
00075   typedef typename OutputMeshType::PointIdentifier            OutputPointIdentifier;
00076   typedef typename OutputMeshType::CellType                   OutputCellType;
00077   typedef typename OutputMeshType::CellIdentifier             OutputCellIdentifier;
00078   typedef typename OutputMeshType::EdgeCellType               OutputEdgeCellType;
00079   typedef typename OutputMeshType::QEType                     OutputQEType;
00080   typedef typename OutputQEType::LineCellIdentifier           OutputLineCellIdentifier;
00081   typedef typename OutputMeshType::VectorType                 OutputVectorType;
00082   typedef typename OutputQEType::IteratorGeom                 OutputQEIterator;
00083   typedef typename OutputMeshType::PointsContainerPointer     OutputPointsContainerPointer;
00084   typedef typename OutputMeshType::PointsContainerIterator    OutputPointsContainerIterator;
00085   typedef typename OutputMeshType::CellsContainer             OutputCellsContainer;
00086   typedef typename OutputMeshType::CellsContainerIterator     OutputCellsContainerIterator;
00087 
00088   itkStaticConstMacro( OutputVDimension, unsigned int, OutputMeshType::PointDimension );
00089 
00090   itkNewMacro( Self );
00091   itkTypeMacro( QuadEdgeMeshDelaunayConformingFilter, QuadEdgeMeshToQuadEdgeMeshFilter );
00092 
00093   itkGetMacro( NumberOfEdgeFlips, unsigned long );
00094 
00095 public:
00096   typedef std::list< OutputEdgeCellType* >               OutputEdgeCellListType;
00097   typedef typename OutputEdgeCellListType::iterator      OutputEdgeCellListIterator;
00098 
00099   typedef double                                         CriterionValueType;
00100   typedef std::pair< bool, CriterionValueType >          PriorityType;
00101 
00102   typedef MaxPriorityQueueElementWrapper< 
00103     OutputEdgeCellType*, PriorityType, long >            PriorityQueueItemType;
00104 
00105   typedef PriorityQueueContainer< PriorityQueueItemType*,
00106     ElementWrapperPointerInterface< PriorityQueueItemType* >,
00107     PriorityType,
00108     long >   PriorityQueueType;
00109 
00110   typedef typename PriorityQueueType::Pointer                       PriorityQueuePointer;
00111   typedef std::map< OutputEdgeCellType*, PriorityQueueItemType* >   QueueMapType;
00112   typedef typename QueueMapType::iterator                           QueueMapIterator;
00113 
00114   typedef QuadEdgeMeshEulerOperatorFlipEdgeFunction< 
00115     OutputMeshType, OutputQEType >                                  FlipEdgeFunctionType;
00116   typedef typename FlipEdgeFunctionType::Pointer                    FlipEdgeFunctionPointer;
00117 
00118   void SetListOfConstrainedEdges( const OutputEdgeCellListType& iList )
00119     {
00120     m_ListOfConstrainedEdges = iList;
00121     }
00122 
00123 protected:
00124   QuadEdgeMeshDelaunayConformingFilter( );
00125   virtual ~QuadEdgeMeshDelaunayConformingFilter( );
00126 
00127   OutputEdgeCellListType            m_ListOfConstrainedEdges;
00128   PriorityQueuePointer              m_PriorityQueue;
00129   QueueMapType                      m_QueueMapper;
00130 
00131   unsigned long                     m_NumberOfEdgeFlips;
00132   FlipEdgeFunctionPointer           m_FlipEdge;
00133         
00134 
00135   void GenerateData( );
00136   void InitializePriorityQueue();
00137   void Process();
00138 
00139   inline CriterionValueType
00140     Dyer07Criterion( OutputMeshType* iMesh, OutputQEType* iEdge ) const
00141     {
00142     OutputPointIdentifier id1 = iEdge->GetOrigin( );
00143     OutputPointIdentifier id2 = iEdge->GetDestination( );
00144 
00145     OutputPointIdentifier idA = iEdge->GetLnext( )->GetDestination( );
00146     OutputPointIdentifier idB = iEdge->GetRnext( )->GetOrigin( );
00147 
00148     OutputPointType pt1 = iMesh->GetPoint( id1 );
00149     OutputPointType pt2 = iMesh->GetPoint( id2 );
00150     OutputPointType ptA = iMesh->GetPoint( idA );
00151     OutputPointType ptB = iMesh->GetPoint( idB );
00152 
00153     OutputVectorType v1A = ptA - pt1;
00154     OutputVectorType v1B = ptB - pt1;
00155     OutputVectorType v2A = ptA - pt2;
00156     OutputVectorType v2B = ptB - pt2;
00157 
00158     OutputCoordRepType sq_norm1A = v1A * v1A;
00159     OutputCoordRepType sq_norm1B = v1B * v1B;
00160     OutputCoordRepType sq_norm2A = v2A * v2A;
00161     OutputCoordRepType sq_norm2B = v2B * v2B;
00162 
00163     CriterionValueType dotA = static_cast< CriterionValueType >( v1A * v2A );
00164     CriterionValueType dotB = static_cast< CriterionValueType >( v1B * v2B );
00165     CriterionValueType den  = static_cast< CriterionValueType >( sq_norm1A * sq_norm2A );
00166 
00167     if( den != 0. )
00168       {
00169       dotA /= vcl_sqrt( den );
00170       }
00171 
00172     if( dotA > 1. )
00173       {
00174       dotA = 1.;
00175       }
00176 
00177     if( dotA < -1. )
00178       {
00179       dotA = -1.;
00180       }
00181 
00182     den = static_cast< CriterionValueType >( sq_norm1B * sq_norm2B );
00183 
00184     if( den != 0. )
00185       {
00186       dotB /= vcl_sqrt( den );
00187       }
00188 
00189     if( dotB > 1. )
00190       {
00191       dotB = 1.;
00192       }
00193       
00194     if( dotB < -1. )
00195       {
00196       dotB = -1.;
00197       }
00198 
00199     return ( vcl_acos( dotA ) + vcl_acos( dotB ) - vnl_math::pi );
00200     }
00201 
00202 private:
00203 
00204   QuadEdgeMeshDelaunayConformingFilter( const Self& ); // Purposely not implemented
00205   void operator=( const Self& );  // Purposely not implemented
00206 
00207 }; //
00208 
00209 } // end namespace itk
00210 
00211 #include "itkQuadEdgeMeshDelaunayConformingFilter.txx"
00212 
00213 #endif
00214 

Generated at Wed Nov 5 23:37:53 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000