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

itkMesh.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMesh.h,v $
00005   Language:  C++
00006   Date:      $Date: 2003/09/10 14:29:15 $
00007   Version:   $Revision: 1.86 $
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   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
00018 
00019 =========================================================================*/
00020 #ifndef __itkMesh_h
00021 #define __itkMesh_h
00022 
00023 #if defined(_MSC_VER)
00024 #pragma warning ( disable : 4786 )
00025 #endif
00026 
00027 #include "itkPointSet.h"
00028 #include "itkCellInterface.h"
00029 #include "itkMapContainer.h"
00030 #include <vector>
00031 #include <set>
00032 
00033 
00034 namespace itk
00035 {
00036 
00096 template <
00097   typename TPixelType,
00098   unsigned int VDimension = 3,
00099   typename TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension, VDimension >
00100   >
00101 class ITK_EXPORT Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
00102 {
00103 public:
00105   typedef Mesh                Self;
00106   typedef PointSet<TPixelType, VDimension, TMeshTraits>  Superclass;
00107   typedef SmartPointer<Self>  Pointer;
00108   typedef SmartPointer<const Self>  ConstPointer;
00109 
00110   typedef typename Superclass::RegionType RegionType;
00111 
00113   itkNewMacro(Self);
00114 
00116   itkTypeMacro(Mesh, PointSet);
00117 
00119   typedef TMeshTraits   MeshTraits;
00120   typedef typename MeshTraits::PixelType                PixelType;  
00121   typedef typename MeshTraits::CellPixelType            CellPixelType;  
00122 
00124   itkStaticConstMacro(PointDimension, unsigned int,
00125                       TMeshTraits::PointDimension);
00126   itkStaticConstMacro(MaxTopologicalDimension, unsigned int,
00127                       TMeshTraits::MaxTopologicalDimension);
00128 
00131   typedef  enum {     CellsAllocationMethodUndefined,
00132                       CellsAllocatedAsStaticArray, 
00133                       CellsAllocatedAsADynamicArray,
00134                       CellsAllocatedDynamicallyCellByCell
00135                                                 } CellsAllocationMethodType;
00136 
00138   typedef typename MeshTraits::CoordRepType            CoordRepType;  
00139   typedef typename MeshTraits::InterpolationWeightType InterpolationWeightType;
00140   typedef typename MeshTraits::PointIdentifier         PointIdentifier;
00141   typedef typename MeshTraits::CellIdentifier          CellIdentifier;
00142   typedef typename MeshTraits::CellFeatureIdentifier   CellFeatureIdentifier;
00143   typedef typename MeshTraits::PointType               PointType;
00144   typedef typename MeshTraits::PointsContainer         PointsContainer;
00145   typedef typename MeshTraits::CellTraits              CellTraits;
00146   typedef typename MeshTraits::CellsContainer          CellsContainer;
00147   typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer;
00148   typedef typename MeshTraits::CellLinksContainer      CellLinksContainer;
00149   typedef typename MeshTraits::PointDataContainer      PointDataContainer;
00150   typedef typename MeshTraits::CellDataContainer       CellDataContainer;  
00151 
00153   typedef PointLocator<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00154                        CoordRepType,PointsContainer>  PointLocatorType;
00155   typedef BoundingBox<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00156                       CoordRepType,PointsContainer>   BoundingBoxType;
00157 
00159   typedef typename PointsContainer::Pointer       PointsContainerPointer;
00160   typedef typename CellsContainer::Pointer        CellsContainerPointer;
00161   typedef typename CellLinksContainer::Pointer    CellLinksContainerPointer;
00162   typedef typename PointDataContainer::Pointer    PointDataContainerPointer;
00163   typedef typename CellDataContainer::Pointer     CellDataContainerPointer;
00164   typedef typename PointLocatorType::Pointer      PointLocatorPointer;
00165   typedef typename BoundingBoxType::Pointer       BoundingBoxPointer;
00166 
00168   typedef typename
00169           PointsContainer::ConstIterator        PointsContainerConstIterator;
00170   typedef typename
00171           PointsContainer::Iterator             PointsContainerIterator;
00172   typedef typename
00173           CellsContainer::ConstIterator         CellsContainerConstIterator;
00174   typedef typename
00175           CellsContainer::Iterator              CellsContainerIterator;
00176   typedef typename
00177           CellLinksContainer::ConstIterator     CellLinksContainerIterator;
00178   typedef typename
00179           PointDataContainer::ConstIterator     PointDataContainerIterator;
00180   typedef typename
00181           CellDataContainer::ConstIterator      CellDataContainerIterator;
00182   typedef typename
00183      PointCellLinksContainer::const_iterator  PointCellLinksContainerIterator;
00184 
00186   typedef CellFeatureIdentifier  CellFeatureCount;
00187 
00189   typedef CellInterface<CellPixelType,CellTraits>  CellType;
00190   typedef typename CellType::CellAutoPointer       CellAutoPointer;
00191 
00193   typedef typename CellType::MultiVisitor CellMultiVisitorType;
00194 
00195 protected:
00196 
00197 
00205   class BoundaryAssignmentIdentifier
00206   {
00207   public:
00209     typedef BoundaryAssignmentIdentifier Self;
00210 
00213     BoundaryAssignmentIdentifier() {}
00214     BoundaryAssignmentIdentifier(CellIdentifier cellId,
00215                                  CellFeatureIdentifier featureId):
00216       m_CellId(cellId), m_FeatureId(featureId) {}    
00217 
00219     CellIdentifier m_CellId;
00220 
00222     CellFeatureIdentifier  m_FeatureId;
00223 
00226     bool operator < (const Self& r) const
00227       {
00228       return ((m_CellId < r.m_CellId) ||
00229               ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
00230       }
00231 
00234     bool operator == (const Self& r) const
00235       {
00236       return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
00237       }
00238   }; // End Class: Mesh::BoundaryAssignmentIdentifier
00239 
00240 
00243   CellsContainerPointer  m_CellsContainer;
00244 
00249   CellDataContainerPointer  m_CellDataContainer;
00250 
00254   CellLinksContainerPointer  m_CellLinksContainer;
00255 
00263   typedef MapContainer< BoundaryAssignmentIdentifier , CellIdentifier >
00264         BoundaryAssignmentsContainer;
00265   typedef typename BoundaryAssignmentsContainer::Pointer
00266         BoundaryAssignmentsContainerPointer;
00267   typedef std::vector< BoundaryAssignmentsContainerPointer >
00268         BoundaryAssignmentsContainerVector;
00269 
00279   BoundaryAssignmentsContainerVector  m_BoundaryAssignmentsContainers;
00280 
00281 public:
00283   unsigned long GetNumberOfCells() const;
00284   void PassStructure(Self* inputMesh);
00285   virtual void Initialize();
00286 
00291   void SetCellLinks(CellLinksContainer*);
00292   CellLinksContainerPointer GetCellLinks();
00293   const CellLinksContainerPointer GetCellLinks() const;
00294 
00297   void SetCells(CellsContainer*);
00298   CellsContainerPointer GetCells();
00299   const CellsContainerPointer GetCells() const;
00300 
00305   void SetCellData(CellDataContainer*);
00306   CellDataContainerPointer GetCellData();
00307   const CellDataContainerPointer GetCellData() const;
00308 
00317   void SetBoundaryAssignments(int dimension,
00318                               BoundaryAssignmentsContainer*);
00319   BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension);
00320   const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00321     int dimension) const;
00322 
00328   void SetCell(CellIdentifier, CellAutoPointer & );
00329   bool GetCell(CellIdentifier, CellAutoPointer & ) const;
00330 
00333   void SetCellData(CellIdentifier, CellPixelType);
00334   bool GetCellData(CellIdentifier, CellPixelType*) const;
00335 
00348   void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00349                              CellFeatureIdentifier featureId,
00350                              CellIdentifier boundaryId);
00351 
00360   bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00361                              CellFeatureIdentifier featureId,
00362                              CellIdentifier* boundaryId) const;
00363   bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00364                                 CellFeatureIdentifier featureId);
00365 
00367   CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
00368                                                    CellIdentifier) const;
00369 
00372   bool GetCellBoundaryFeature(int dimension, CellIdentifier,
00373                               CellFeatureIdentifier, CellAutoPointer& ) const;
00374 
00379   unsigned long GetCellBoundaryFeatureNeighbors(
00380     int dimension, CellIdentifier, CellFeatureIdentifier,
00381     std::set<CellIdentifier>* cellSet);
00382 
00387   unsigned long GetCellNeighbors( CellIdentifier cellId,
00388                                   std::set<CellIdentifier>* cellSet );
00389 
00397   bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
00398                                           CellFeatureIdentifier,
00399                                           CellAutoPointer& ) const;
00400 
00403   void BuildCellLinks();
00404 
00408   BoundingBoxPointer GetCellBoundingBox(CellIdentifier cellId, 
00409                                         BoundingBoxPointer bbox);
00410 
00414   virtual void Accept(CellMultiVisitorType* mv);
00415 
00417   virtual void UpdateOutputInformation();
00418   virtual void SetRequestedRegionToLargestPossibleRegion();
00419   virtual void CopyInformation(const DataObject *data);
00420   virtual bool RequestedRegionIsOutsideOfTheBufferedRegion();
00421   virtual bool VerifyRequestedRegion();
00422 
00425   int GetMaximumNumberOfRegions() const
00426     {return m_MaximumNumberOfRegions;}
00427 
00432   virtual void SetRequestedRegion(DataObject *data);
00433 
00435   virtual void SetRequestedRegion( const RegionType & region );
00436   itkGetMacro( RequestedRegion, RegionType );
00437 
00442   itkSetMacro( CellsAllocationMethod, CellsAllocationMethodType );  
00443   itkGetConstMacro( CellsAllocationMethod, CellsAllocationMethodType );  
00444 
00445 protected:
00447   Mesh();
00448   ~Mesh();
00449   void PrintSelf(std::ostream& os, Indent indent) const;
00450 
00454   void ReleaseCellsMemory();
00455 
00456 private:
00457   Mesh(const Self&); //purposely not implemented
00458   void operator=(const Self&); //purposely not implemented
00459 
00460   CellsAllocationMethodType             m_CellsAllocationMethod;
00461 
00462 }; // End Class: Mesh
00463 
00464 } // end namespace itk
00465 
00466 #ifndef ITK_MANUAL_INSTANTIATION
00467 #include "itkMesh.txx"
00468 #endif
00469 
00470 #endif
00471 
00472 
00473 

Generated at Tue Sep 16 11:32:04 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000