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: 2007/09/01 18:33:08 $
00007   Version:   $Revision: 1.23 $
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::PointType        PointType;
00139   typedef typename Superclass::CellTraits       CellTraits;
00140 
00141   typedef typename CellTraits::PointIdInternalIterator PointIdInternalIterator;
00142   typedef typename CellTraits::PointIdIterator         PointIdIterator;
00143 
00144   // Point section:
00145   typedef typename Superclass::PointsContainer        PointsContainer;
00146   typedef typename Superclass::PointsContainerPointer PointsContainerPointer;
00147   typedef typename Superclass::PointLocatorPointer    PointLocatorPointer;
00148   typedef typename Superclass::PointLocatorType       PointLocatorType;
00149   typedef CoordRepType  CoordRepArrayType[ 
00150                               itkGetStaticConstMacro( PointDimension ) ];
00151 
00152   // Point data section:
00153   typedef typename Superclass::PointDataContainer     PointDataContainer;
00154   typedef typename Superclass::PointDataContainerPointer
00155                                PointDataContainerPointer;
00156   typedef typename Superclass::PointDataContainerIterator
00157                                PointDataContainerIterator;
00158   typedef typename Superclass::PointsContainerConstIterator
00159                                PointsContainerConstIterator;
00160   typedef typename Superclass::PointsContainerIterator
00161                                PointsContainerIterator;
00162 
00163   // Cell section:
00164   typedef typename Superclass::CellIdentifier         CellIdentifier;
00165   typedef typename Superclass::CellType               CellType;
00166   typedef typename Superclass::CellAutoPointer        CellAutoPointer;
00167   typedef typename Superclass::CellFeatureIdentifier  CellFeatureIdentifier;
00168   typedef typename Superclass::CellFeatureCount       CellFeatureCount;
00169   typedef typename Superclass::CellMultiVisitorType   CellMultiVisitorType;
00170   typedef typename Superclass::CellsContainer         CellsContainer;
00171   typedef typename Superclass::CellsContainerPointer  CellsContainerPointer;
00172 
00173   typedef typename Superclass::CellsContainerConstIterator
00174                                                   CellsContainerConstIterator;
00175   typedef typename Superclass::CellsContainerIterator
00176                                                   CellsContainerIterator;
00177 
00178   typedef typename Superclass::CellLinksContainer CellLinksContainer;
00179   typedef typename Superclass::CellLinksContainerPointer
00180                                                   CellLinksContainerPointer;
00181   typedef typename Superclass::CellLinksContainerIterator
00182                                                   CellLinksContainerIterator;
00183 
00184   // Cell data section:
00185   typedef typename Superclass::CellDataContainer  CellDataContainer;
00186   typedef typename Superclass::CellDataContainerPointer
00187                                                   CellDataContainerPointer;
00188   typedef typename Superclass::CellDataContainerIterator
00189                                                   CellDataContainerIterator;
00190 
00191   // Point / Cell correspondance section:
00192   typedef typename Superclass::PointCellLinksContainer
00193                                         PointCellLinksContainer;
00194   typedef typename Superclass::PointCellLinksContainerIterator
00195                                         PointCellLinksContainerIterator;
00196 
00197   // BoundaryAssignMents section:
00198   typedef typename Superclass::BoundaryAssignmentsContainer
00199                                BoundaryAssignmentsContainer;
00200   typedef typename Superclass::BoundaryAssignmentsContainerPointer
00201                                BoundaryAssignmentsContainerPointer;
00202   typedef typename Superclass::BoundaryAssignmentsContainerVector
00203                                BoundaryAssignmentsContainerVector;
00204 
00205   // Miscelaneous section:
00206   typedef typename Superclass::BoundingBoxPointer         BoundingBoxPointer;
00207   typedef typename Superclass::BoundingBoxType            BoundingBoxType;
00208   typedef typename Superclass::RegionType                 RegionType;
00209   typedef typename Superclass::InterpolationWeightType
00210                                InterpolationWeightType;
00211 
00213   typedef typename Traits::PrimalDataType PrimalDataType;
00214   typedef typename Traits::DualDataType   DualDataType;
00215   typedef typename Traits::QEPrimal       QEPrimal;
00216   typedef typename Traits::QEDual         QEDual;
00217   typedef typename Traits::QEPrimal       QEType;
00218   // See the TODO entry dated from 2005-05-28
00219   // struct QEType : public QEPrimal, public QEDual {};
00220   typedef typename Traits::VertexRefType  VertexRefType;
00221   typedef typename Traits::FaceRefType    FaceRefType;
00222   typedef typename Traits::VectorType     VectorType;
00223 
00225   typedef QuadEdgeMeshLineCell< CellType >    EdgeCellType;
00226   typedef QuadEdgeMeshPolygonCell< CellType > PolygonCellType;
00227 
00229   typedef std::queue< PointIdentifier > FreePointIndexesType;
00230   typedef std::queue< CellIdentifier >  FreeCellIndexesType;
00231 
00233   typedef std::vector< PointIdentifier >    PointIdList;
00234   typedef std::list< QEPrimal* >            EdgeListType;
00235   typedef EdgeListType*                     EdgeListPointerType;
00236 
00238   static const PointIdentifier m_NoPoint;
00239 
00241   static const CellIdentifier m_NoFace;
00242 
00243 public:
00244 
00246   itkNewMacro( Self );
00247   itkTypeMacro( QuadEdgeMesh, Mesh );
00249 
00251   itkQEDefineFrontIteratorMethodsMacro( Self );
00252 
00253 
00254 public:
00255 
00256   // Multithreading framework: not tested yet.
00257   virtual bool RequestedRegionIsOutsideOfTheBufferedRegion()
00258     {
00259     return( false );
00260     }
00261 
00263   virtual void Clear();
00264 
00271   virtual void CopyInformation( const DataObject* data ) { (void)data; }
00272 
00274   void BuildCellLinks() { }
00275 
00277   void SetBoundaryAssignments(int dimension,
00278                               BoundaryAssignmentsContainer* container)
00279     {
00280     (void)dimension;
00281     (void)container;
00282     }
00284 
00286   BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension)
00287     {
00288     (void)dimension;
00289     return( (BoundaryAssignmentsContainerPointer)0 );
00290     }
00292 
00294   const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00295     int dimension) const
00296     {
00297     (void)dimension;
00298     return( (const BoundaryAssignmentsContainerPointer)0 );
00299     }
00301 
00303   void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00304                              CellFeatureIdentifier featureId,
00305                              CellIdentifier boundaryId)
00306     {
00307     (void)dimension;
00308     (void)cellId;
00309     (void)featureId;
00310     (void)boundaryId;
00311     }
00313 
00315   bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00316                              CellFeatureIdentifier featureId,
00317                              CellIdentifier* boundaryId) const
00318     {
00319     (void)dimension;
00320     (void)cellId;
00321     (void)featureId;
00322     (void)boundaryId;
00323     return( false ); // ALEX: is it the good way?
00324     }
00326 
00328   bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00329                                 CellFeatureIdentifier featureId)
00330     {
00331     (void)dimension;
00332     (void)cellId;
00333     (void)featureId;
00334     return( false ); // ALEX: is it the good way?
00335     }
00337 
00339   bool GetCellBoundaryFeature(int dimension, CellIdentifier cellId,
00340                               CellFeatureIdentifier featureId,
00341                               CellAutoPointer& cellAP) const
00342     { 
00343     (void)dimension;
00344     (void)cellId;
00345     (void)featureId;
00346     (void)cellAP;
00347     return( false );
00348     }
00350 
00352   unsigned long GetCellBoundaryFeatureNeighbors(int dimension,
00353                                              CellIdentifier cellId,
00354                                              CellFeatureIdentifier featureId,
00355                                              std::set<CellIdentifier>* cellSet)
00356     {
00357     (void)dimension;
00358     (void)cellId;
00359     (void)featureId;
00360     cellSet = (std::set<CellIdentifier>*)0;
00361     return( (unsigned long)0 );
00362     }
00364 
00366   unsigned long GetCellNeighbors( CellIdentifier cellId,
00367                                   std::set<CellIdentifier>* cellSet )
00368     {
00369     (void)cellId;
00370     cellSet = (std::set<CellIdentifier>*)0;
00371     return( (unsigned long)0 );
00372     }
00374 
00376   bool GetAssignedCellBoundaryIfOneExists(int dimension,
00377                                           CellIdentifier cellId,
00378                                           CellFeatureIdentifier featureId,
00379                                           CellAutoPointer& cellAP) const
00380     {
00381     (void)dimension;
00382     (void)featureId;
00383     (void)cellAP;
00384     return( false ); // ALEX: is it the good way?
00385     }
00387 
00389   void SetCell( CellIdentifier cId, CellAutoPointer& cell );
00390 
00392   virtual PointIdentifier FindFirstUnusedPointIndex();
00393   virtual CellIdentifier  FindFirstUnusedCellIndex();
00395 
00396   virtual void PushOnContainer( EdgeCellType* newEdge );
00397 
00398   // Adding Point/Edge/Face methods
00399   virtual PointIdentifier AddPoint( const PointType& p );
00400   
00402   virtual QEPrimal* AddEdge( const PointIdentifier& orgPid,
00403                              const PointIdentifier& destPid );
00404 
00406   virtual void      AddFace( QEPrimal* e );
00407 
00412   virtual QEPrimal* AddFace( const PointIdList& points );
00413 
00415   virtual QEPrimal* AddFaceTriangle( const PointIdentifier& aPid,
00416                                      const PointIdentifier& bPid,
00417                                      const PointIdentifier& cPid );
00418 
00420   virtual void DeletePoint( const PointIdentifier& pid );
00421   virtual void DeleteEdge( const PointIdentifier& orgPid,
00422                            const PointIdentifier& destPid );
00423   virtual void DeleteEdge( QEPrimal* e );
00424   virtual void LightWeightDeleteEdge( EdgeCellType* e );
00425   virtual void LightWeightDeleteEdge( QEPrimal* e );
00426   virtual void DeleteFace( FaceRefType faceToDelete );
00428 
00429   // 
00430   bool GetPoint( PointIdentifier pid, PointType * pt) const
00431     {
00432     return( Superclass::GetPoint( pid, pt ) );
00433     }
00434   virtual PointType  GetPoint ( const PointIdentifier& pid ) const;
00435   virtual VectorType GetVector( const PointIdentifier& pid ) const;
00436   virtual QEPrimal*  GetEdge() const;
00437   virtual QEPrimal*  GetEdge( const CellIdentifier& eid ) const;
00438   virtual QEPrimal*  FindEdge( const PointIdentifier& pid0 ) const;
00439   virtual QEPrimal*  FindEdge( const PointIdentifier& pid0,
00440                                const PointIdentifier& pid1 ) const;
00441 
00442   virtual EdgeCellType*  FindEdgeCell( const PointIdentifier& pid0,
00443                                  const PointIdentifier& pid1 ) const;
00444 
00446   CoordRepType ComputeEdgeLength( QEPrimal* e );
00447 
00448   unsigned long ComputeNumberOfPoints() const;
00449   unsigned long ComputeNumberOfFaces() const;
00450   unsigned long ComputeNumberOfEdges() const;
00451 
00452   PointIdentifier Splice( QEPrimal* a, QEPrimal* b );
00453 
00454 #ifdef ITK_USE_CONCEPT_CHECKING
00455 
00456   itkConceptMacro(DimensionShouldBe3,
00457     (Concept::SameDimension<itkGetStaticConstMacro(PointDimension),3>));
00458 
00460 #endif
00461 
00462   // for reusability of a mesh in the MeshToMesh filter
00463   void ClearFreePointAndCellIndexesLists( )
00464     {
00465     while( !this->m_FreePointIndexes.empty( ) )
00466       {
00467       this->m_FreePointIndexes.pop( );
00468       }
00469     while( !this->m_FreeCellIndexes.empty( ) )
00470       {
00471       this->m_FreeCellIndexes.pop( );
00472       }
00473     }
00474 
00475 protected:
00477   QuadEdgeMesh();
00478   virtual ~QuadEdgeMesh() {}
00479 
00480 private:
00481   QuadEdgeMesh( const Self& );    //purposely not implemented
00482   void operator=( const Self& );  //purposely not implemented
00483 
00484 protected:
00485   FreePointIndexesType m_FreePointIndexes;
00486   FreeCellIndexesType  m_FreeCellIndexes;
00487 
00488 };
00489 
00490 }
00491 
00492 
00493 #ifndef ITK_MANUAL_INSTANTIATION
00494 #include "itkQuadEdgeMesh.txx"
00495 #endif
00496 
00497 #endif
00498 

Generated at Sun Sep 23 13:56:54 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000