ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkQuadEdgeMeshLineCell.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkQuadEdgeMeshLineCell_h
00019 #define __itkQuadEdgeMeshLineCell_h
00020 
00021 #include "itkAutoPointer.h"
00022 #include "itkGeometricalQuadEdge.h"
00023 
00024 namespace itk
00025 {
00038 template< class TCellInterface >
00039 class ITK_EXPORT QuadEdgeMeshLineCell:
00040   public TCellInterface, public TCellInterface::CellTraits::QuadEdgeType
00041 {
00042 public:
00043 
00045   // itkCellCommonTypedefs
00046   typedef QuadEdgeMeshLineCell      Self;
00047   typedef AutoPointer< const Self > ConstSelfAutoPointer;
00048   typedef AutoPointer< Self >       SelfAutoPointer;
00049   typedef Self *                    RawPointer;
00050   typedef const Self *              ConstRawPointer;
00051 
00052   // itkCellInheritedTypedefs
00053   typedef TCellInterface                                Superclass;
00054   typedef typename Superclass::PixelType                PixelType;
00055   typedef typename Superclass::CellType                 CellType;
00056   typedef typename Superclass::CellAutoPointer          CellAutoPointer;
00057   typedef typename Superclass::CellConstAutoPointer     CellConstAutoPointer;
00058   typedef typename Superclass::CellRawPointer           CellRawPointer;
00059   typedef typename Superclass::CellConstRawPointer      CellConstRawPointer;
00060   typedef typename Superclass::CellTraits               CellTraits;
00061   typedef typename Superclass::CoordRepType             CoordRepType;
00062   typedef typename Superclass::InterpolationWeightType  InterpolationWeightType;
00063   typedef typename Superclass::PointIdentifier          PointIdentifier;
00064   typedef typename Superclass::CellIdentifier           CellIdentifier;
00065   typedef typename Superclass::CellFeatureIdentifier    CellFeatureIdentifier;
00066   typedef typename Superclass::CellFeatureIdentifier    CellFeatureCount;
00067   typedef typename Superclass::PointType                PointType;
00068   typedef typename Superclass::PointsContainer          PointsContainer;
00069   typedef typename Superclass::UsingCellsContainer      UsingCellsContainer;
00070   typedef typename Superclass::CellGeometry             CellGeometry;
00071   typedef typename Superclass::ParametricCoordArrayType ParametricCoordArrayType;
00072   typedef typename Superclass::ShapeFunctionsArrayType  ShapeFunctionsArrayType;
00073   itkStaticConstMacro(PointDimension, unsigned int, Superclass::PointDimension);
00074   itkStaticConstMacro(CellDimension, unsigned int, 2);
00075 
00077   typedef typename CellType::MultiVisitor MultiVisitor;
00078 
00080   typedef typename CellTraits::PointIdIterator              PointIdIterator;
00081   typedef typename CellTraits::PointIdConstIterator         PointIdConstIterator;
00082   typedef typename CellTraits::PointIdInternalIterator      PointIdInternalIterator;
00083   typedef typename CellTraits::PointIdInternalConstIterator PointIdInternalConstIterator;
00084 
00086   typedef typename CellTraits::QuadEdgeType  QEType;
00087   typedef typename QEType::OriginRefType     VertexRefType;
00088   typedef typename QEType::DualOriginRefType FaceRefType;
00089   typedef typename QEType::PrimalDataType    PrimalDataType;
00090   typedef typename QEType::DualDataType      DualDataType;
00091   typedef typename QEType::DualType          QEDual;
00092 public:
00093 
00095   itkTypeMacro(QuadEdgeMeshLineCell, TCellInterface);
00096 
00097   // accessor to the new QEGeom link that replaces now inheritance.
00098   QEType * GetQEGeom() const { return ( m_QuadEdgeGeom ); }
00099 public:
00101   QuadEdgeMeshLineCell();
00102   virtual ~QuadEdgeMeshLineCell();
00104 
00106   void SetIdent(CellIdentifier cid);
00107 
00108   CellIdentifier GetIdent();
00109 
00111   virtual void Accept(CellIdentifier cellId, MultiVisitor *mv);
00112 
00113   virtual CellGeometry GetType() const;
00114 
00116   static int GetTopologyId();
00117 
00118   virtual unsigned int GetDimension() const;
00119 
00120   virtual unsigned int GetNumberOfPoints() const;
00121 
00122   virtual CellFeatureCount GetNumberOfBoundaryFeatures(int dimension) const;
00123 
00124   virtual bool GetBoundaryFeature(int dimension,
00125                                   CellFeatureIdentifier cellId,
00126                                   CellAutoPointer & cell);
00127 
00129   virtual void MakeCopy(CellAutoPointer & cell) const
00130   {
00131     cell.TakeOwnership(new Self);
00132     cell->SetPointId( 0, this->GetQEGeom()->GetOrigin() );
00133     cell->SetPointId( 1, this->GetQEGeom()->GetDestination() );
00134   }
00136 
00141   virtual void SetPointIds(PointIdConstIterator first);
00142 
00143   virtual void SetPointIds(PointIdConstIterator first,
00144                            PointIdConstIterator last);
00145 
00146   virtual void SetPointId(int localId, PointIdentifier pId);
00147 
00148   virtual PointIdIterator PointIdsBegin()
00149   {
00150     SynchronizePointsAPI();
00151     return &m_PointIds[0];
00152   }
00153 
00154   virtual PointIdIterator PointIdsEnd()
00155   {
00156     SynchronizePointsAPI();
00157     return ( &m_PointIds[1] + 1 );
00158   }
00159 
00160   virtual PointIdConstIterator GetPointIds() const
00161   {
00162     SynchronizePointsAPI();
00163     return &m_PointIds[0];
00164   }
00165 
00166   virtual PointIdConstIterator PointIdsBegin() const
00167   {
00168     SynchronizePointsAPI();
00169     return &m_PointIds[0];
00170   }
00171 
00172   virtual PointIdConstIterator PointIdsEnd() const
00173   {
00174     SynchronizePointsAPI();
00175     return ( &m_PointIds[1] + 1 );
00176   }
00177 
00179   void SynchronizePointsAPI() const
00180   {
00181     m_PointIds[0] = GetQEGeom()->GetOrigin();
00182     m_PointIds[1] = GetQEGeom()->GetDestination();
00183   }
00185 
00187   virtual void InternalSetPointIds(PointIdInternalConstIterator first);
00188 
00189   virtual void InternalSetPointIds(
00190     PointIdInternalConstIterator first,
00191     PointIdInternalConstIterator last);
00192 
00193   virtual PointIdInternalIterator InternalPointIdsBegin();
00194 
00195   virtual PointIdInternalIterator InternalPointIdsEnd();
00196 
00197   virtual PointIdInternalConstIterator InternalGetPointIds() const;
00198 
00199   virtual PointIdInternalConstIterator InternalPointIdsBegin() const;
00200 
00201   virtual PointIdInternalConstIterator InternalPointIdsEnd() const;
00202 
00203 private:
00204   QuadEdgeMeshLineCell(const Self &); //purposely not implemented
00205   void operator=(const Self &);       //purposely not implemented
00206 
00211   CellIdentifier          m_Identifier;
00212   QEType *                m_QuadEdgeGeom;
00213   mutable PointIdentifier m_PointIds[2];
00214 };
00215 } // end namespace itk
00216 
00217 #ifndef ITK_MANUAL_INSTANTIATION
00218 #include "itkQuadEdgeMeshLineCell.hxx"
00219 #endif
00220 
00221 #endif
00222