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

itkQuadEdgeMesh.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdgeMesh.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-07-12 00:10:13 $
00007   Version:   $Revision: 1.31 $
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 __itkQuadEdgeMesh_h
00019 #define __itkQuadEdgeMesh_h
00020 
00021 #include "vcl_cstdarg.h"
00022 #include <queue>
00023 #include <vector>
00024 #include <list>
00025 
00026 #include "itkMesh.h"
00027 
00028 #include "itkQuadEdgeMeshTraits.h"
00029 #include "itkQuadEdgeMeshLineCell.h"
00030 #include "itkQuadEdgeMeshPolygonCell.h"
00031 
00032 #include "itkQuadEdgeMeshFrontIterator.h"
00033 #include "itkConceptChecking.h"
00034 
00097 namespace itk
00098 {
00099 
00111 template< typename TPixel, unsigned int VDimension,
00112   typename TTraits = QuadEdgeMeshTraits< TPixel, VDimension, bool, bool > >
00113 class QuadEdgeMesh : public Mesh< TPixel, VDimension, TTraits >
00114 {
00115 public:
00116 
00118   typedef TTraits Traits;
00119   typedef TPixel  PixelType;
00120 
00122   typedef QuadEdgeMesh                            Self;
00123   typedef Mesh< TPixel, VDimension, Traits >      Superclass;
00124   typedef SmartPointer< Self >                    Pointer;
00125   typedef SmartPointer< const Self >              ConstPointer;
00126 
00128   itkStaticConstMacro( PointDimension, unsigned int,
00129                        Traits::PointDimension );
00130   itkStaticConstMacro( MaxTopologicalDimension, unsigned int,
00131                        Traits::MaxTopologicalDimension );
00133 
00135   typedef typename Superclass::CellPixelType    CellPixelType;
00136   typedef typename Superclass::CoordRepType     CoordRepType;
00137   typedef typename Superclass::PointIdentifier  PointIdentifier;
00138   typedef typename Superclass::PointHashType    PointHashType;
00139   typedef typename Superclass::PointType        PointType;
00140   typedef typename Superclass::CellTraits       CellTraits;
00141 
00142   typedef typename CellTraits::PointIdInternalIterator PointIdInternalIterator;
00143   typedef typename CellTraits::PointIdIterator         PointIdIterator;
00144 
00145   // Point section:
00146   typedef typename Superclass::PointsContainer        PointsContainer;
00147   typedef typename Superclass::PointsContainerPointer PointsContainerPointer;
00148   typedef typename Superclass::PointLocatorPointer    PointLocatorPointer;
00149   typedef typename Superclass::PointLocatorType       PointLocatorType;
00150   typedef CoordRepType  CoordRepArrayType[ 
00151                               itkGetStaticConstMacro( PointDimension ) ];
00152 
00153   // Point data section:
00154   typedef typename Superclass::PointDataContainer     PointDataContainer;
00155   typedef typename Superclass::PointDataContainerPointer
00156                                PointDataContainerPointer;
00157   typedef typename Superclass::PointDataContainerIterator
00158                                PointDataContainerIterator;
00159   typedef typename Superclass::PointsContainerConstIterator
00160                                PointsContainerConstIterator;
00161   typedef typename Superclass::PointsContainerIterator
00162                                PointsContainerIterator;
00163 
00164   // Cell section:
00165   typedef typename Superclass::CellIdentifier         CellIdentifier;
00166   typedef typename Superclass::CellType               CellType;
00167   typedef typename Superclass::CellAutoPointer        CellAutoPointer;
00168   typedef typename Superclass::CellFeatureIdentifier  CellFeatureIdentifier;
00169   typedef typename Superclass::CellFeatureCount       CellFeatureCount;
00170   typedef typename Superclass::CellMultiVisitorType   CellMultiVisitorType;
00171   typedef typename Superclass::CellsContainer         CellsContainer;
00172   typedef typename Superclass::CellsContainerPointer  CellsContainerPointer;
00173 
00174   typedef typename Superclass::CellsContainerConstIterator
00175                                                   CellsContainerConstIterator;
00176   typedef typename Superclass::CellsContainerIterator
00177                                                   CellsContainerIterator;
00178 
00179   typedef typename Superclass::CellLinksContainer CellLinksContainer;
00180   typedef typename Superclass::CellLinksContainerPointer
00181                                                   CellLinksContainerPointer;
00182   typedef typename Superclass::CellLinksContainerIterator
00183                                                   CellLinksContainerIterator;
00184 
00185   // Cell data section:
00186   typedef typename Superclass::CellDataContainer  CellDataContainer;
00187   typedef typename Superclass::CellDataContainerPointer
00188                                                   CellDataContainerPointer;
00189   typedef typename Superclass::CellDataContainerIterator
00190                                                   CellDataContainerIterator;
00191 
00192   // Point / Cell correspondance section:
00193   typedef typename Superclass::PointCellLinksContainer
00194                                         PointCellLinksContainer;
00195   typedef typename Superclass::PointCellLinksContainerIterator
00196                                         PointCellLinksContainerIterator;
00197 
00198   // BoundaryAssignMents section:
00199   typedef typename Superclass::BoundaryAssignmentsContainer
00200                                BoundaryAssignmentsContainer;
00201   typedef typename Superclass::BoundaryAssignmentsContainerPointer
00202                                BoundaryAssignmentsContainerPointer;
00203   typedef typename Superclass::BoundaryAssignmentsContainerVector
00204                                BoundaryAssignmentsContainerVector;
00205 
00206   // Miscelaneous section:
00207   typedef typename Superclass::BoundingBoxPointer         BoundingBoxPointer;
00208   typedef typename Superclass::BoundingBoxType            BoundingBoxType;
00209   typedef typename Superclass::RegionType                 RegionType;
00210   typedef typename Superclass::InterpolationWeightType
00211                                InterpolationWeightType;
00212 
00214   typedef typename Traits::PrimalDataType PrimalDataType;
00215   typedef typename Traits::DualDataType   DualDataType;
00216   typedef typename Traits::QEPrimal       QEPrimal;
00217   typedef typename Traits::QEDual         QEDual;
00218   typedef typename Traits::QEPrimal       QEType;
00219   // See the TODO entry dated from 2005-05-28
00220   // struct QEType : public QEPrimal, public QEDual {};
00221   typedef typename Traits::VertexRefType  VertexRefType;
00222   typedef typename Traits::FaceRefType    FaceRefType;
00223   typedef typename Traits::VectorType     VectorType;
00224 
00226   typedef QuadEdgeMeshLineCell< CellType >    EdgeCellType;
00227   typedef QuadEdgeMeshPolygonCell< CellType > PolygonCellType;
00228 
00230   typedef std::queue< PointIdentifier > FreePointIndexesType;
00231   typedef std::queue< CellIdentifier >  FreeCellIndexesType;
00232 
00234   typedef std::vector< PointIdentifier >    PointIdList;
00235   typedef std::list< QEPrimal* >            EdgeListType;
00236   typedef EdgeListType*                     EdgeListPointerType;
00237 
00239   static const PointIdentifier m_NoPoint;
00240 
00242   static const CellIdentifier m_NoFace;
00243 
00244 public:
00245 
00247   itkNewMacro( Self );
00248   itkTypeMacro( QuadEdgeMesh, Mesh );
00250 
00252   itkQEDefineFrontIteratorMethodsMacro( Self );
00253 
00254 
00255 public:
00256 
00257   // Multithreading framework: not tested yet.
00258   virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
00259     {
00260     return( false );
00261     }
00262 
00263   virtual void Initialize();
00264 
00266   virtual void Clear();
00267 
00268   CellsContainerPointer GetEdgeCells() {return m_EdgeCellsContainer;};
00269   const CellsContainerPointer GetEdgeCells() const {return m_EdgeCellsContainer;};
00270   void SetEdgeCells(CellsContainerPointer edgeCells)
00271     {m_EdgeCellsContainer = edgeCells;}; 
00272   void SetEdgeCell(CellIdentifier cellId, CellAutoPointer & cellPointer )
00273     {m_EdgeCellsContainer->InsertElement(cellId,cellPointer.ReleaseOwnership());};
00274 
00275 
00282   virtual void CopyInformation( const DataObject* data ) { (void)data; }
00283   virtual void Graft( const DataObject* data );
00285 
00287   void SqueezePointsIds( );
00288 
00290   void BuildCellLinks() { }
00291 
00293   void SetBoundaryAssignments(int dimension,
00294                               BoundaryAssignmentsContainer* container)
00295     {
00296     (void)dimension;
00297     (void)container;
00298     }
00300 
00302   BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension)
00303     {
00304     (void)dimension;
00305     return( (BoundaryAssignmentsContainerPointer)0 );
00306     }
00308 
00310   const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00311     int dimension) const
00312     {
00313     (void)dimension;
00314     return( (const BoundaryAssignmentsContainerPointer)0 );
00315     }
00317 
00319   void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00320                              CellFeatureIdentifier featureId,
00321                              CellIdentifier boundaryId)
00322     {
00323     (void)dimension;
00324     (void)cellId;
00325     (void)featureId;
00326     (void)boundaryId;
00327     }
00329 
00331   bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00332                              CellFeatureIdentifier featureId,
00333                              CellIdentifier* boundaryId) const
00334     {
00335     (void)dimension;
00336     (void)cellId;
00337     (void)featureId;
00338     (void)boundaryId;
00339     return( false ); // ALEX: is it the good way?
00340     }
00342 
00344   bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00345                                 CellFeatureIdentifier featureId)
00346     {
00347     (void)dimension;
00348     (void)cellId;
00349     (void)featureId;
00350     return( false ); // ALEX: is it the good way?
00351     }
00353 
00355   bool GetCellBoundaryFeature(int dimension, CellIdentifier cellId,
00356                               CellFeatureIdentifier featureId,
00357                               CellAutoPointer& cellAP) const
00358     { 
00359     (void)dimension;
00360     (void)cellId;
00361     (void)featureId;
00362     (void)cellAP;
00363     return( false );
00364     }
00366 
00368   unsigned long GetCellBoundaryFeatureNeighbors(int dimension,
00369                                              CellIdentifier cellId,
00370                                              CellFeatureIdentifier featureId,
00371                                              std::set<CellIdentifier>* cellSet)
00372     {
00373     (void)dimension;
00374     (void)cellId;
00375     (void)featureId;
00376     cellSet = (std::set<CellIdentifier>*)0;
00377     return( (unsigned long)0 );
00378     }
00380 
00382   unsigned long GetCellNeighbors( CellIdentifier cellId,
00383                                   std::set<CellIdentifier>* cellSet )
00384     {
00385     (void)cellId;
00386     cellSet = (std::set<CellIdentifier>*)0;
00387     return( (unsigned long)0 );
00388     }
00390 
00392   bool GetAssignedCellBoundaryIfOneExists(int dimension,
00393                                           CellIdentifier cellId,
00394                                           CellFeatureIdentifier featureId,
00395                                           CellAutoPointer& cellAP) const
00396     {
00397     (void)dimension;
00398     (void)featureId;
00399     (void)cellAP;
00400     return( false ); // ALEX: is it the good way?
00401     }
00403 
00405   void SetCell( CellIdentifier cId, CellAutoPointer& cell );
00406 
00408   virtual PointIdentifier FindFirstUnusedPointIndex();
00409   virtual CellIdentifier  FindFirstUnusedCellIndex();
00411 
00412   virtual void PushOnContainer( EdgeCellType* newEdge );
00413 
00414   // Adding Point/Edge/Face methods
00415   virtual PointIdentifier AddPoint( const PointType& p );
00416   
00418   virtual QEPrimal* AddEdge( const PointIdentifier& orgPid,
00419                              const PointIdentifier& destPid );
00420   virtual QEPrimal* AddEdgeWithSecurePointList( const PointIdentifier& orgPid,
00421                              const PointIdentifier& destPid );
00423 
00425   virtual void      AddFace( QEPrimal* e );
00426 
00431   virtual QEPrimal* AddFace( const PointIdList& points );
00432   virtual QEPrimal* AddFaceWithSecurePointList( const PointIdList& points );
00434 
00436   virtual QEPrimal* AddFaceTriangle( const PointIdentifier& aPid,
00437                                      const PointIdentifier& bPid,
00438                                      const PointIdentifier& cPid );
00439 
00441   virtual void DeletePoint( const PointIdentifier& pid );
00442   virtual void DeleteEdge( const PointIdentifier& orgPid,
00443                            const PointIdentifier& destPid );
00444   virtual void DeleteEdge( QEPrimal* e );
00445   virtual void LightWeightDeleteEdge( EdgeCellType* e );
00446   virtual void LightWeightDeleteEdge( QEPrimal* e );
00447   virtual void DeleteFace( FaceRefType faceToDelete );
00449 
00450   // 
00451   bool GetPoint( PointIdentifier pid, PointType * pt) const
00452     {
00453     return( Superclass::GetPoint( pid, pt ) );
00454     }
00455   virtual PointType  GetPoint ( const PointIdentifier& pid ) const;
00456   virtual VectorType GetVector( const PointIdentifier& pid ) const;
00457   virtual QEPrimal*  GetEdge() const;
00458   virtual QEPrimal*  GetEdge( const CellIdentifier& eid ) const;
00459   virtual QEPrimal*  FindEdge( const PointIdentifier& pid0 ) const;
00460   virtual QEPrimal*  FindEdge( const PointIdentifier& pid0,
00461                                const PointIdentifier& pid1 ) const;
00462 
00463   virtual EdgeCellType*  FindEdgeCell( const PointIdentifier& pid0,
00464                                  const PointIdentifier& pid1 ) const;
00465 
00467   CoordRepType ComputeEdgeLength( QEPrimal* e );
00468 
00469   unsigned long ComputeNumberOfPoints() const;
00470   unsigned long ComputeNumberOfFaces() const;
00471   unsigned long ComputeNumberOfEdges() const;
00472 
00473   PointIdentifier Splice( QEPrimal* a, QEPrimal* b );
00474 
00475 #ifdef ITK_USE_CONCEPT_CHECKING
00476 
00477   itkConceptMacro(DimensionShouldBe3,
00478     (Concept::SameDimension<itkGetStaticConstMacro(PointDimension),3>));
00479 
00481 #endif
00482 
00483   // for reusability of a mesh in the MeshToMesh filter
00484   void ClearFreePointAndCellIndexesLists( )
00485     {
00486     while( !this->m_FreePointIndexes.empty( ) )
00487       {
00488       this->m_FreePointIndexes.pop( );
00489       }
00490     while( !this->m_FreeCellIndexes.empty( ) )
00491       {
00492       this->m_FreeCellIndexes.pop( );
00493       }
00494     }
00495 
00496   CellIdentifier GetNumberOfFaces( ) const {return( m_NumberOfFaces );};
00497   CellIdentifier GetNumberOfEdges( ) const {return( m_NumberOfEdges );};
00498 
00499 protected:
00501   QuadEdgeMesh();
00502   virtual ~QuadEdgeMesh(); 
00504 
00505   CellsContainerPointer  m_EdgeCellsContainer;
00506 
00507 private:
00508   QuadEdgeMesh( const Self& );    //purposely not implemented
00509   void operator=( const Self& );  //purposely not implemented
00510   CellIdentifier m_NumberOfFaces;
00511   CellIdentifier m_NumberOfEdges;
00512 
00513 protected:
00514   FreePointIndexesType m_FreePointIndexes;
00515   FreeCellIndexesType  m_FreeCellIndexes;
00516 
00517 };
00518 
00519 }
00520 
00521 
00522 #ifndef ITK_MANUAL_INSTANTIATION
00523 #include "itkQuadEdgeMesh.txx"
00524 #endif
00525 
00526 #endif
00527 

Generated at Tue Jul 29 21:49:50 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000