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: 2005/11/28 19:20:13 $
00007   Version:   $Revision: 1.93 $
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 
00043 template <typename TMesh>
00044 struct GetMeshDimension
00045 {
00046 itkStaticConstMacro(MaxTopologicalDimension, unsigned int, TMesh::MaxTopologicalDimension); 
00047 itkStaticConstMacro(PointDimension, unsigned int,  TMesh::PointDimension);
00048 }; 
00049   
00050 
00110 template <
00111   typename TPixelType,
00112   unsigned int VDimension = 3,
00113   typename TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension, VDimension >
00114   >
00115 class ITK_EXPORT Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
00116 {
00117 public:
00119   typedef Mesh                Self;
00120   typedef PointSet<TPixelType, VDimension, TMeshTraits>  Superclass;
00121   typedef SmartPointer<Self>  Pointer;
00122   typedef SmartPointer<const Self>  ConstPointer;
00123 
00124   typedef typename Superclass::RegionType RegionType;
00125 
00127   itkNewMacro(Self);
00128 
00130   itkTypeMacro(Mesh, PointSet);
00131 
00133   typedef TMeshTraits   MeshTraits;
00134   typedef typename MeshTraits::PixelType                PixelType;  
00135   typedef typename MeshTraits::CellPixelType            CellPixelType;  
00136 
00138   itkStaticConstMacro(PointDimension, unsigned int,
00139                       TMeshTraits::PointDimension);
00140   itkStaticConstMacro(MaxTopologicalDimension, unsigned int,
00141                       TMeshTraits::MaxTopologicalDimension);
00142 
00145   typedef  enum {     CellsAllocationMethodUndefined,
00146                       CellsAllocatedAsStaticArray, 
00147                       CellsAllocatedAsADynamicArray,
00148                       CellsAllocatedDynamicallyCellByCell
00149                                                 } CellsAllocationMethodType;
00150 
00152   typedef typename MeshTraits::CoordRepType            CoordRepType;  
00153   typedef typename MeshTraits::InterpolationWeightType InterpolationWeightType;
00154   typedef typename MeshTraits::PointIdentifier         PointIdentifier;
00155   typedef typename MeshTraits::CellIdentifier          CellIdentifier;
00156   typedef typename MeshTraits::CellFeatureIdentifier   CellFeatureIdentifier;
00157   typedef typename MeshTraits::PointType               PointType;
00158   typedef typename MeshTraits::PointsContainer         PointsContainer;
00159   typedef typename MeshTraits::CellTraits              CellTraits;
00160   typedef typename MeshTraits::CellsContainer          CellsContainer;
00161   typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer;
00162   typedef typename MeshTraits::CellLinksContainer      CellLinksContainer;
00163   typedef typename MeshTraits::PointDataContainer      PointDataContainer;
00164   typedef typename MeshTraits::CellDataContainer       CellDataContainer;  
00165 
00167   typedef PointLocator<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00168                        CoordRepType,PointsContainer>  PointLocatorType;
00169   typedef BoundingBox<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00170                       CoordRepType,PointsContainer>   BoundingBoxType;
00171 
00173   typedef typename PointsContainer::Pointer       PointsContainerPointer;
00174   typedef typename CellsContainer::Pointer        CellsContainerPointer;
00175   typedef typename CellLinksContainer::Pointer    CellLinksContainerPointer;
00176   typedef typename PointDataContainer::Pointer    PointDataContainerPointer;
00177   typedef typename CellDataContainer::Pointer     CellDataContainerPointer;
00178   typedef typename PointLocatorType::Pointer      PointLocatorPointer;
00179   typedef typename BoundingBoxType::Pointer       BoundingBoxPointer;
00180 
00182   typedef typename
00183           PointsContainer::ConstIterator        PointsContainerConstIterator;
00184   typedef typename
00185           PointsContainer::Iterator             PointsContainerIterator;
00186   typedef typename
00187           CellsContainer::ConstIterator         CellsContainerConstIterator;
00188   typedef typename
00189           CellsContainer::Iterator              CellsContainerIterator;
00190   typedef typename
00191           CellLinksContainer::ConstIterator     CellLinksContainerIterator;
00192   typedef typename
00193           PointDataContainer::ConstIterator     PointDataContainerIterator;
00194   typedef typename
00195           CellDataContainer::ConstIterator      CellDataContainerIterator;
00196   typedef typename
00197      PointCellLinksContainer::const_iterator  PointCellLinksContainerIterator;
00198 
00200   typedef CellFeatureIdentifier  CellFeatureCount;
00201 
00203   typedef CellInterface<CellPixelType,CellTraits>  CellType;
00204   typedef typename CellType::CellAutoPointer       CellAutoPointer;
00205 
00207   typedef typename CellType::MultiVisitor CellMultiVisitorType;
00208 
00209 
00210 
00218   class BoundaryAssignmentIdentifier
00219   {
00220   public:
00222     typedef BoundaryAssignmentIdentifier Self;
00223 
00226     BoundaryAssignmentIdentifier() {}
00227     BoundaryAssignmentIdentifier(CellIdentifier cellId,
00228                                  CellFeatureIdentifier featureId):
00229       m_CellId(cellId), m_FeatureId(featureId) {}    
00230 
00232     CellIdentifier m_CellId;
00233 
00235     CellFeatureIdentifier  m_FeatureId;
00236 
00239     bool operator < (const Self& r) const
00240       {
00241       return ((m_CellId < r.m_CellId) ||
00242               ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
00243       }
00244 
00247     bool operator == (const Self& r) const
00248       {
00249       return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
00250       }
00251   }; // End Class: Mesh::BoundaryAssignmentIdentifier
00252 
00253 
00261   typedef MapContainer< BoundaryAssignmentIdentifier , CellIdentifier >
00262         BoundaryAssignmentsContainer;
00263   typedef typename BoundaryAssignmentsContainer::Pointer
00264         BoundaryAssignmentsContainerPointer;
00265   typedef std::vector< BoundaryAssignmentsContainerPointer >
00266         BoundaryAssignmentsContainerVector;
00267 
00268 
00269 protected:
00270 
00273   CellsContainerPointer  m_CellsContainer;
00274 
00279   CellDataContainerPointer  m_CellDataContainer;
00280 
00284   CellLinksContainerPointer  m_CellLinksContainer;
00285 
00295   BoundaryAssignmentsContainerVector  m_BoundaryAssignmentsContainers;
00296 
00297 public:
00299   unsigned long GetNumberOfCells() const;
00300   void PassStructure(Self* inputMesh);
00301   virtual void Initialize();
00302 
00304   virtual void CopyInformation(const DataObject *data);
00305   virtual void Graft(const DataObject *data);
00306   
00311   void SetCellLinks(CellLinksContainer*);
00312 #ifndef CABLE_CONFIGURATION
00313   CellLinksContainerPointer GetCellLinks();
00314   const CellLinksContainerPointer GetCellLinks() const;
00315 
00318   void SetCells(CellsContainer*);
00319 
00320   CellsContainerPointer GetCells();
00321   const CellsContainerPointer GetCells() const;
00322 #endif
00323 
00327   void SetCellData(CellDataContainer*);
00328   CellDataContainerPointer GetCellData();
00329   const CellDataContainerPointer GetCellData() const;
00330 
00339   void SetBoundaryAssignments(int dimension,
00340                               BoundaryAssignmentsContainer*);
00341 #ifndef CABLE_CONFIGURATION
00342   BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension);
00343   const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00344     int dimension) const;
00345 
00351   void SetCell(CellIdentifier, CellAutoPointer & );
00352   bool GetCell(CellIdentifier, CellAutoPointer & ) const;
00353 #endif
00354 
00356   void SetCellData(CellIdentifier, CellPixelType);
00357   bool GetCellData(CellIdentifier, CellPixelType*) const;
00358 
00371   void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00372                              CellFeatureIdentifier featureId,
00373                              CellIdentifier boundaryId);
00374 
00383   bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00384                              CellFeatureIdentifier featureId,
00385                              CellIdentifier* boundaryId) const;
00386   bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00387                                 CellFeatureIdentifier featureId);
00388 
00390   CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
00391                                                    CellIdentifier) const;
00392 
00393 #ifndef CABLE_CONFIGURATION
00394 
00396   bool GetCellBoundaryFeature(int dimension, CellIdentifier,
00397                               CellFeatureIdentifier, CellAutoPointer& ) const;
00398 #endif
00399 
00403   unsigned long GetCellBoundaryFeatureNeighbors(
00404     int dimension, CellIdentifier, CellFeatureIdentifier,
00405     std::set<CellIdentifier>* cellSet);
00406 
00411   unsigned long GetCellNeighbors( CellIdentifier cellId,
00412                                   std::set<CellIdentifier>* cellSet );
00413 #ifndef CABLE_CONFIGURATION
00414 
00421   bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
00422                                           CellFeatureIdentifier,
00423                                           CellAutoPointer& ) const;
00424 #endif
00425 
00427   void BuildCellLinks();
00428 
00429 #ifndef CABLE_CONFIGURATION
00430 
00433   BoundingBoxPointer GetCellBoundingBox(CellIdentifier cellId, 
00434                                         BoundingBoxPointer bbox);
00435 
00439   virtual void Accept(CellMultiVisitorType* mv);
00440 #endif
00441 
00445   itkSetMacro( CellsAllocationMethod, CellsAllocationMethodType );  
00446   itkGetConstReferenceMacro( CellsAllocationMethod, CellsAllocationMethodType );  
00447 
00448 protected:
00450   Mesh();
00451   ~Mesh();
00452   void PrintSelf(std::ostream& os, Indent indent) const;
00453 
00457   void ReleaseCellsMemory();
00458 
00459 private:
00460   Mesh(const Self&); //purposely not implemented
00461   void operator=(const Self&); //purposely not implemented
00462 
00463   CellsAllocationMethodType             m_CellsAllocationMethod;
00464 
00465 }; // End Class: Mesh
00466 
00467 } // end namespace itk
00468 
00469 #ifndef ITK_MANUAL_INSTANTIATION
00470 #ifndef CABLE_CONFIGURATION
00471 #include "itkMesh.txx"
00472 #endif
00473 #endif
00474 
00475 #endif
00476 
00477 
00478 

Generated at Wed May 24 23:40:11 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000