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

itkQuadEdgeMeshPolygonCell.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkQuadEdgeMeshPolygonCell.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/08/28 15:53:46 $
00007   Version:   $Revision: 1.14 $
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 __itkQuadEdgeMeshPolygonCell_h
00019 #define __itkQuadEdgeMeshPolygonCell_h
00020 
00021 namespace itk
00022 {
00023 
00035 template< class TCellInterface >
00036 class QuadEdgeMeshPolygonCell : public TCellInterface
00037 {
00038 public:
00040   // itkCellCommonTypedefs
00041   typedef QuadEdgeMeshPolygonCell   Self;
00042   typedef AutoPointer< const Self > ConstSelfAutoPointer;
00043   typedef AutoPointer< Self >       SelfAutoPointer;
00044   typedef Self*                     RawPointer;
00045   typedef const Self*               ConstRawPointer;
00046 
00047   // itkCellInheritedTypedefs
00048   typedef TCellInterface                                Superclass;
00049   typedef typename Superclass::PixelType                PixelType;
00050   typedef typename Superclass::CellType                 CellType;
00051   typedef typename Superclass::CellAutoPointer          CellAutoPointer;
00052   typedef typename Superclass::CellConstAutoPointer     CellConstAutoPointer;
00053   typedef typename Superclass::CellRawPointer           CellRawPointer;
00054   typedef typename Superclass::CellConstRawPointer      CellConstRawPointer;
00055   typedef typename Superclass::CellTraits               CellTraits;
00056   typedef typename Superclass::CoordRepType             CoordRepType;
00057   typedef typename Superclass::InterpolationWeightType  InterpolationWeightType;
00058   typedef typename Superclass::PointIdentifier          PointIdentifier;
00059   typedef typename Superclass::CellIdentifier           CellIdentifier;
00060   typedef typename Superclass::CellFeatureIdentifier    CellFeatureIdentifier;
00061   typedef typename Superclass::CellFeatureIdentifier    CellFeatureCount;
00062   typedef typename Superclass::PointType                PointType;
00063   typedef typename Superclass::PointsContainer          PointsContainer;
00064   typedef typename Superclass::UsingCellsContainer      UsingCellsContainer;
00065   typedef typename Superclass::CellGeometry             CellGeometry;
00066   typedef typename Superclass::ParametricCoordArrayType ParametricCoordArrayType;
00067   typedef typename Superclass::ShapeFunctionsArrayType  ShapeFunctionsArrayType;
00068   itkStaticConstMacro( PointDimension, unsigned int, Superclass::PointDimension );
00069   itkStaticConstMacro( CellDimension, unsigned int, 2 );
00070   
00072   typedef typename CellType::MultiVisitor MultiVisitor;
00073 
00074   typedef QuadEdgeMeshLineCell< CellType >               EdgeCellType;
00075   typedef std::vector< EdgeCellType* >                   EdgeCellListType; 
00076 
00078   typedef typename CellTraits::PointIdIterator              PointIdIterator;
00079   typedef typename CellTraits::PointIdConstIterator         PointIdConstIterator;
00080   typedef typename CellTraits::PointIdInternalIterator      PointIdInternalIterator;
00081   typedef typename CellTraits::PointIdInternalConstIterator PointIdInternalConstIterator;
00082 
00084   typedef typename CellTraits::QuadEdgeType              QuadEdgeType;
00085   typedef typename QuadEdgeType::OriginRefType           VertexRefType;
00086   typedef typename QuadEdgeType::DualOriginRefType       FaceRefType;
00087   typedef typename QuadEdgeType::PrimalDataType          PrimalDataType;
00088   typedef typename QuadEdgeType::DualDataType            DualDataType;
00089   typedef typename QuadEdgeType::DualType                QEDual;
00090 
00091 public:
00093   itkTypeMacro( QuadEdgeMeshPolygonCell, TCellInterface );
00094 
00096   QuadEdgeMeshPolygonCell( PointIdentifier nPoints = 0 );
00097   QuadEdgeMeshPolygonCell( QuadEdgeType* e );
00098   virtual ~QuadEdgeMeshPolygonCell();
00100 
00102   void SetIdent( CellIdentifier cid ) { m_Ident = cid; }
00103   CellIdentifier GetIdent()          { return( m_Ident ); }
00105 
00107   QuadEdgeType* GetEdgeRingEntry() const      { return( m_EdgeRingEntry ); }
00108   void SetEdgeRingEntry( QuadEdgeType* entry ) { m_EdgeRingEntry = entry; }
00110 
00112   SelfAutoPointer New();
00113 
00115   virtual void Accept( unsigned long cellId, MultiVisitor* mv );
00116   virtual CellGeometry GetType() const { return( Superclass::POLYGON_CELL );}
00118 
00120   static int GetTopologyId()
00121     {
00122     return( Superclass::POLYGON_CELL );
00123     }
00124   virtual unsigned int GetDimension() const 
00125     { 
00126     return( Self::CellDimension );
00127     }
00128   virtual unsigned int GetNumberOfPoints() const;
00129   virtual CellFeatureCount GetNumberOfBoundaryFeatures( int dimension ) const;
00130   virtual bool GetBoundaryFeature( int dimension,
00131                                    CellFeatureIdentifier cellId,
00132                                    CellAutoPointer& cell );
00134 
00136   virtual void MakeCopy( CellAutoPointer& cell ) const 
00137     { 
00138     const unsigned long numberOfPoints = this->GetNumberOfPoints();
00139     Self * newPolygonCell = new Self( numberOfPoints );
00140     cell.TakeOwnership( newPolygonCell );
00141     if ( numberOfPoints ) 
00142       {
00143       for( unsigned long i = 0; i < numberOfPoints; i++ )
00144         { 
00145         newPolygonCell->SetPointId( i, this->GetPointId( i ) );
00146         }
00147       }
00148     }
00150 
00151   
00153   virtual void SetPointIds( PointIdConstIterator first );
00154   virtual void SetPointIds( PointIdConstIterator first,
00155                             PointIdConstIterator last );
00156   virtual void SetPointId( int localId, PointIdentifier pId );
00158 
00159   virtual PointIdentifier GetPointId( int localId ) const;
00160 
00161   virtual PointIdIterator PointIdsBegin()
00162     {
00163     if (m_PointIds.size() >0)
00164       {
00165       return &*(m_PointIds.begin());
00166       }
00167     else
00168       {
00169       return NULL;
00170       }
00171     }
00172 
00173   virtual PointIdIterator PointIdsEnd()
00174     {
00175     if (m_PointIds.size() >0)
00176       {
00177       return &m_PointIds[m_PointIds.size()-1] + 1;
00178       }
00179     else
00180       {
00181       return NULL;
00182       }
00183     }
00184 
00185   virtual PointIdConstIterator PointIdsBegin() const
00186     {
00187     if (m_PointIds.size() >0)
00188       {
00189       return &*(m_PointIds.begin());
00190       }
00191     else
00192       {
00193       return NULL;
00194       }
00195 
00196     }
00197 
00198   virtual PointIdConstIterator PointIdsEnd() const
00199     {
00200     if (m_PointIds.size() >0)
00201       {
00202       return &m_PointIds[m_PointIds.size()-1] + 1;
00203       }
00204     else
00205       {
00206       return NULL;
00207       }
00208     }
00209 
00211   virtual void InternalSetPointIds( PointIdInternalConstIterator first );
00212   virtual void InternalSetPointIds( PointIdInternalConstIterator first,
00213                             PointIdInternalConstIterator last );
00215 
00216   virtual PointIdInternalIterator InternalPointIdsBegin();
00217   virtual PointIdInternalIterator InternalPointIdsEnd();
00218 
00219   virtual PointIdInternalConstIterator InternalGetPointIds() const;
00220   virtual PointIdInternalConstIterator InternalPointIdsBegin() const;
00221   virtual PointIdInternalConstIterator InternalPointIdsEnd() const;
00222 
00223 protected:
00224   std::vector<PointIdentifier>  m_PointIds;
00225   //std::vector<EdgeInfo> m_Edges;
00226 
00227 private:
00228   QuadEdgeMeshPolygonCell( const Self& ); // Not impl.
00229   void operator=( const Self& ); // Not impl.
00230 
00231   void MakePointIds()
00232     {
00233     if( !this->GetNumberOfPoints( ) )
00234       {
00235       return;
00236       }
00237 
00238     // NOTE ALEX: very inefficient way of doing it ...
00239     for( PointIdentifier i = 0; i < this->GetNumberOfPoints( ); i++ )
00240       {
00241       m_PointIds.push_back( GetPointId( i ) );
00242       }
00243     }
00244 
00248   CellIdentifier m_Ident;
00249 
00253   QuadEdgeType * m_EdgeRingEntry;
00254 
00258   EdgeCellListType m_EdgeCellList;
00259 
00260 };
00261 
00262 } // end namespace itk
00263 
00264 #ifndef ITK_MANUAL_INSTANTIATION
00265 #include "itkQuadEdgeMeshPolygonCell.txx"
00266 #endif
00267 
00268 #endif
00269 

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