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-02-07 15:58:06 $
00007   Version:   $Revision: 1.27 $
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 
00264   virtual void Clear();
00265 
00272   virtual void CopyInformation( const DataObject* data ) { (void)data; }
00273 
00275   void BuildCellLinks() { }
00276 
00278   void SetBoundaryAssignments(int dimension,
00279                               BoundaryAssignmentsContainer* container)
00280     {
00281     (void)dimension;
00282     (void)container;
00283     }
00285 
00287   BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension)
00288     {
00289     (void)dimension;
00290     return( (BoundaryAssignmentsContainerPointer)0 );
00291     }
00293 
00295   const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00296     int dimension) const
00297     {
00298     (void)dimension;
00299     return( (const BoundaryAssignmentsContainerPointer)0 );
00300     }
00302 
00304   void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00305                              CellFeatureIdentifier featureId,
00306                              CellIdentifier boundaryId)
00307     {
00308     (void)dimension;
00309     (void)cellId;
00310     (void)featureId;
00311     (void)boundaryId;
00312     }
00314 
00316   bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00317                              CellFeatureIdentifier featureId,
00318                              CellIdentifier* boundaryId) const
00319     {
00320     (void)dimension;
00321     (void)cellId;
00322     (void)featureId;
00323     (void)boundaryId;
00324     return( false ); // ALEX: is it the good way?
00325     }
00327 
00329   bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00330                                 CellFeatureIdentifier featureId)
00331     {
00332     (void)dimension;
00333     (void)cellId;
00334     (void)featureId;
00335     return( false ); // ALEX: is it the good way?
00336     }
00338 
00340   bool GetCellBoundaryFeature(int dimension, CellIdentifier cellId,
00341                               CellFeatureIdentifier featureId,
00342                               CellAutoPointer& cellAP) const
00343     { 
00344     (void)dimension;
00345     (void)cellId;
00346     (void)featureId;
00347     (void)cellAP;
00348     return( false );
00349     }
00351 
00353   unsigned long GetCellBoundaryFeatureNeighbors(int dimension,
00354                                              CellIdentifier cellId,
00355                                              CellFeatureIdentifier featureId,
00356                                              std::set<CellIdentifier>* cellSet)
00357     {
00358     (void)dimension;
00359     (void)cellId;
00360     (void)featureId;
00361     cellSet = (std::set<CellIdentifier>*)0;
00362     return( (unsigned long)0 );
00363     }
00365 
00367   unsigned long GetCellNeighbors( CellIdentifier cellId,
00368                                   std::set<CellIdentifier>* cellSet )
00369     {
00370     (void)cellId;
00371     cellSet = (std::set<CellIdentifier>*)0;
00372     return( (unsigned long)0 );
00373     }
00375 
00377   bool GetAssignedCellBoundaryIfOneExists(int dimension,
00378                                           CellIdentifier cellId,
00379                                           CellFeatureIdentifier featureId,
00380                                           CellAutoPointer& cellAP) const
00381     {
00382     (void)dimension;
00383     (void)featureId;
00384     (void)cellAP;
00385     return( false ); // ALEX: is it the good way?
00386     }
00388 
00390   void SetCell( CellIdentifier cId, CellAutoPointer& cell );
00391 
00393   virtual PointIdentifier FindFirstUnusedPointIndex();
00394   virtual CellIdentifier  FindFirstUnusedCellIndex();
00396 
00397   virtual void PushOnContainer( EdgeCellType* newEdge );
00398 
00399   // Adding Point/Edge/Face methods
00400   virtual PointIdentifier AddPoint( const PointType& p );
00401   
00403   virtual QEPrimal* AddEdge( const PointIdentifier& orgPid,
00404                              const PointIdentifier& destPid );
00405   virtual QEPrimal* AddEdgeWithSecurePointList( const PointIdentifier& orgPid,
00406                              const PointIdentifier& destPid );
00408 
00410   virtual void      AddFace( QEPrimal* e );
00411 
00416   virtual QEPrimal* AddFace( const PointIdList& points );
00417   virtual QEPrimal* AddFaceWithSecurePointList( const PointIdList& points );
00419 
00421   virtual QEPrimal* AddFaceTriangle( const PointIdentifier& aPid,
00422                                      const PointIdentifier& bPid,
00423                                      const PointIdentifier& cPid );
00424 
00426   virtual void DeletePoint( const PointIdentifier& pid );
00427   virtual void DeleteEdge( const PointIdentifier& orgPid,
00428                            const PointIdentifier& destPid );
00429   virtual void DeleteEdge( QEPrimal* e );
00430   virtual void LightWeightDeleteEdge( EdgeCellType* e );
00431   virtual void LightWeightDeleteEdge( QEPrimal* e );
00432   virtual void DeleteFace( FaceRefType faceToDelete );
00434 
00435   // 
00436   bool GetPoint( PointIdentifier pid, PointType * pt) const
00437     {
00438     return( Superclass::GetPoint( pid, pt ) );
00439     }
00440   virtual PointType  GetPoint ( const PointIdentifier& pid ) const;
00441   virtual VectorType GetVector( const PointIdentifier& pid ) const;
00442   virtual QEPrimal*  GetEdge() const;
00443   virtual QEPrimal*  GetEdge( const CellIdentifier& eid ) const;
00444   virtual QEPrimal*  FindEdge( const PointIdentifier& pid0 ) const;
00445   virtual QEPrimal*  FindEdge( const PointIdentifier& pid0,
00446                                const PointIdentifier& pid1 ) const;
00447 
00448   virtual EdgeCellType*  FindEdgeCell( const PointIdentifier& pid0,
00449                                  const PointIdentifier& pid1 ) const;
00450 
00452   CoordRepType ComputeEdgeLength( QEPrimal* e );
00453 
00454   unsigned long ComputeNumberOfPoints() const;
00455   unsigned long ComputeNumberOfFaces() const;
00456   unsigned long ComputeNumberOfEdges() const;
00457 
00458   PointIdentifier Splice( QEPrimal* a, QEPrimal* b );
00459 
00460 #ifdef ITK_USE_CONCEPT_CHECKING
00461 
00462   itkConceptMacro(DimensionShouldBe3,
00463     (Concept::SameDimension<itkGetStaticConstMacro(PointDimension),3>));
00464 
00466 #endif
00467 
00468   // for reusability of a mesh in the MeshToMesh filter
00469   void ClearFreePointAndCellIndexesLists( )
00470     {
00471     while( !this->m_FreePointIndexes.empty( ) )
00472       {
00473       this->m_FreePointIndexes.pop( );
00474       }
00475     while( !this->m_FreeCellIndexes.empty( ) )
00476       {
00477       this->m_FreeCellIndexes.pop( );
00478       }
00479     }
00480 
00481 protected:
00483   QuadEdgeMesh();
00484   virtual ~QuadEdgeMesh() {}
00485 
00486 private:
00487   QuadEdgeMesh( const Self& );    //purposely not implemented
00488   void operator=( const Self& );  //purposely not implemented
00489 
00490 protected:
00491   FreePointIndexesType m_FreePointIndexes;
00492   FreeCellIndexesType  m_FreeCellIndexes;
00493 
00494 };
00495 
00496 }
00497 
00498 
00499 #ifndef ITK_MANUAL_INSTANTIATION
00500 #include "itkQuadEdgeMesh.txx"
00501 #endif
00502 
00503 #endif
00504 

Generated at Mon Apr 14 14:04:03 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000