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: 2009-09-17 11:14:56 $
00007   Version:   $Revision: 1.99 $
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 };
00050 
00051 
00111 template <
00112   typename TPixelType,
00113   unsigned int VDimension = 3,
00114   typename TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension, VDimension >
00115   >
00116 class ITK_EXPORT Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
00117 {
00118 public:
00120   typedef Mesh                                          Self;
00121   typedef PointSet<TPixelType, VDimension, TMeshTraits> Superclass;
00122   typedef SmartPointer<Self>                            Pointer;
00123   typedef SmartPointer<const Self>                      ConstPointer;
00124 
00125   typedef typename Superclass::RegionType RegionType;
00126 
00128   itkNewMacro(Self);
00129 
00131   itkTypeMacro(Mesh, PointSet);
00132 
00134   typedef TMeshTraits                        MeshTraits;
00135   typedef typename MeshTraits::PixelType     PixelType;
00136   typedef typename MeshTraits::CellPixelType CellPixelType;
00137 
00139   itkStaticConstMacro(PointDimension, unsigned int,
00140                       TMeshTraits::PointDimension);
00141   itkStaticConstMacro(MaxTopologicalDimension, unsigned int,
00142                       TMeshTraits::MaxTopologicalDimension);
00144 
00147   typedef  enum {     CellsAllocationMethodUndefined,
00148                       CellsAllocatedAsStaticArray,
00149                       CellsAllocatedAsADynamicArray,
00150                       CellsAllocatedDynamicallyCellByCell
00151                                                 } CellsAllocationMethodType;
00152 
00154   typedef typename MeshTraits::CoordRepType            CoordRepType;
00155   typedef typename MeshTraits::InterpolationWeightType InterpolationWeightType;
00156   typedef typename MeshTraits::PointIdentifier         PointIdentifier;
00157   typedef typename MeshTraits::CellIdentifier          CellIdentifier;
00158   typedef typename MeshTraits::CellFeatureIdentifier   CellFeatureIdentifier;
00159   typedef typename MeshTraits::PointHashType           PointHashType;
00160   typedef typename MeshTraits::PointType               PointType;
00161   typedef typename MeshTraits::PointsContainer         PointsContainer;
00162   typedef typename MeshTraits::CellTraits              CellTraits;
00163   typedef typename MeshTraits::CellsContainer          CellsContainer;
00164   typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer;
00165   typedef typename MeshTraits::CellLinksContainer      CellLinksContainer;
00166   typedef typename MeshTraits::PointDataContainer      PointDataContainer;
00167   typedef typename MeshTraits::CellDataContainer       CellDataContainer;
00168 
00170   typedef PointLocator<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00171                        CoordRepType,PointsContainer>  PointLocatorType;
00172   typedef BoundingBox<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00173                       CoordRepType,PointsContainer>   BoundingBoxType;
00175 
00177   typedef typename PointsContainer::Pointer           PointsContainerPointer;
00178   typedef typename CellsContainer::Pointer            CellsContainerPointer;
00179   typedef typename CellsContainer::ConstPointer       CellsContainerConstPointer;
00180   typedef typename CellLinksContainer::Pointer        CellLinksContainerPointer;
00181   typedef typename PointDataContainer::Pointer        PointDataContainerPointer;
00182   typedef typename CellDataContainer::Pointer         CellDataContainerPointer;
00183   typedef typename CellDataContainer::ConstPointer    CellDataContainerConstPointer;
00184   typedef typename PointLocatorType::Pointer          PointLocatorPointer;
00185   typedef typename BoundingBoxType::Pointer           BoundingBoxPointer;
00186   typedef typename CellLinksContainer::ConstPointer   CellLinksContainerConstPointer;
00187 
00189   typedef typename
00190           PointsContainer::ConstIterator        PointsContainerConstIterator;
00191   typedef typename
00192           PointsContainer::Iterator             PointsContainerIterator;
00193   typedef typename
00194           CellsContainer::ConstIterator         CellsContainerConstIterator;
00195   typedef typename
00196           CellsContainer::Iterator              CellsContainerIterator;
00197   typedef typename
00198           CellLinksContainer::ConstIterator     CellLinksContainerIterator;
00199   typedef typename
00200           PointDataContainer::ConstIterator     PointDataContainerIterator;
00201   typedef typename
00202           CellDataContainer::ConstIterator      CellDataContainerIterator;
00203   typedef typename
00204      PointCellLinksContainer::const_iterator  PointCellLinksContainerIterator;
00205 
00207   typedef CellFeatureIdentifier  CellFeatureCount;
00208 
00210   typedef CellInterface<CellPixelType,CellTraits>  CellType;
00211   typedef typename CellType::CellAutoPointer       CellAutoPointer;
00212 
00214   typedef typename CellType::MultiVisitor CellMultiVisitorType;
00215 
00224   class BoundaryAssignmentIdentifier
00225     {
00226   public:
00228     typedef BoundaryAssignmentIdentifier Self;
00229 
00232     BoundaryAssignmentIdentifier() {}
00233     BoundaryAssignmentIdentifier(CellIdentifier cellId,
00234                                  CellFeatureIdentifier featureId):
00235       m_CellId(cellId), m_FeatureId(featureId) {}
00237 
00239     CellIdentifier m_CellId;
00240 
00242     CellFeatureIdentifier  m_FeatureId;
00243 
00246     bool operator < (const Self& r) const
00247       {
00248       return ((m_CellId < r.m_CellId) ||
00249               ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
00250       }
00251 
00254     bool operator == (const Self& r) const
00255       {
00256       return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
00257       }
00258   }; // End Class: Mesh::BoundaryAssignmentIdentifier
00260 
00261 
00269   typedef MapContainer< BoundaryAssignmentIdentifier , CellIdentifier >
00270         BoundaryAssignmentsContainer;
00271   typedef typename BoundaryAssignmentsContainer::Pointer
00272         BoundaryAssignmentsContainerPointer;
00273   typedef std::vector< BoundaryAssignmentsContainerPointer >
00274         BoundaryAssignmentsContainerVector;
00275 
00276 
00277 protected:
00278 
00281   CellsContainerPointer  m_CellsContainer;
00282 
00287   CellDataContainerPointer  m_CellDataContainer;
00288 
00292   mutable CellLinksContainerPointer  m_CellLinksContainer;
00293 
00303   BoundaryAssignmentsContainerVector  m_BoundaryAssignmentsContainers;
00304 
00305 public:
00307   unsigned long GetNumberOfCells() const;
00308   void PassStructure(Self* inputMesh);
00309   virtual void Initialize();
00311 
00313   virtual void CopyInformation(const DataObject *data);
00314   virtual void Graft(const DataObject *data);
00316 
00321   void SetCellLinks(CellLinksContainer*);
00322 #ifndef CABLE_CONFIGURATION
00323   CellLinksContainer * GetCellLinks();
00324   const CellLinksContainer * GetCellLinks() const;
00326 
00329   void SetCells(CellsContainer*);
00330 
00331   CellsContainer * GetCells();
00332   const CellsContainer * GetCells() const;
00333 #endif
00334 
00338   void SetCellData(CellDataContainer*);
00339   CellDataContainer *  GetCellData();
00340   const CellDataContainer * GetCellData() const;
00342 
00351 #if !defined(CABLE_CONFIGURATION)
00352   void SetBoundaryAssignments(int dimension,
00353                               BoundaryAssignmentsContainer*);
00354 #endif
00355 
00356 #ifndef CABLE_CONFIGURATION
00357   BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension);
00358   const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00359     int dimension) const;
00360 
00366   void SetCell(CellIdentifier, CellAutoPointer & );
00367   bool GetCell(CellIdentifier, CellAutoPointer & ) const;
00368 #endif
00369 
00372   void SetCellData(CellIdentifier, CellPixelType);
00373   bool GetCellData(CellIdentifier, CellPixelType*) const;
00375 
00388   void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00389                              CellFeatureIdentifier featureId,
00390                              CellIdentifier boundaryId);
00391 
00400   bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00401                              CellFeatureIdentifier featureId,
00402                              CellIdentifier* boundaryId) const;
00403   bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00404                                 CellFeatureIdentifier featureId);
00406 
00408   CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
00409                                                    CellIdentifier) const;
00410 
00411 #ifndef CABLE_CONFIGURATION
00412 
00414   bool GetCellBoundaryFeature(int dimension, CellIdentifier,
00415                               CellFeatureIdentifier, CellAutoPointer& ) const;
00416 #endif
00417 
00422   unsigned long GetCellBoundaryFeatureNeighbors(
00423     int dimension, CellIdentifier, CellFeatureIdentifier,
00424     std::set<CellIdentifier>* cellSet);
00425 
00430   unsigned long GetCellNeighbors( CellIdentifier cellId,
00431                                   std::set<CellIdentifier>* cellSet );
00432 #ifndef CABLE_CONFIGURATION
00433 
00441   bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
00442                                           CellFeatureIdentifier,
00443                                           CellAutoPointer& ) const;
00444 #endif
00445 
00448   void BuildCellLinks() const;
00449 
00450 #ifndef CABLE_CONFIGURATION
00451 
00454   BoundingBoxPointer GetCellBoundingBox(CellIdentifier cellId,
00455                                         BoundingBoxPointer bbox);
00456 
00460   virtual void Accept(CellMultiVisitorType* mv) const;
00461 #endif
00462 
00467   itkSetMacro( CellsAllocationMethod, CellsAllocationMethodType );
00468   itkGetConstReferenceMacro( CellsAllocationMethod, CellsAllocationMethodType );
00470 
00471 protected:
00473   Mesh();
00474   ~Mesh();
00475   void PrintSelf(std::ostream& os, Indent indent) const;
00477 
00481   void ReleaseCellsMemory();
00482 
00483 private:
00484   Mesh(const Self&); //purposely not implemented
00485   void operator=(const Self&); //purposely not implemented
00486 
00487   CellsAllocationMethodType             m_CellsAllocationMethod;
00488 
00489 }; // End Class: Mesh
00490 
00491 } // end namespace itk
00492 
00493 #ifndef ITK_MANUAL_INSTANTIATION
00494 #ifndef CABLE_CONFIGURATION
00495 #include "itkMesh.txx"
00496 #endif
00497 #endif
00498 
00499 #endif
00500 

Generated at Fri Apr 16 19:01:46 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000