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-06-21 16:25:08 $
00007   Version:   $Revision: 1.98 $
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 PointLocatorType::Pointer      PointLocatorPointer;
00184   typedef typename BoundingBoxType::Pointer       BoundingBoxPointer;
00185 
00187   typedef typename
00188           PointsContainer::ConstIterator        PointsContainerConstIterator;
00189   typedef typename
00190           PointsContainer::Iterator             PointsContainerIterator;
00191   typedef typename
00192           CellsContainer::ConstIterator         CellsContainerConstIterator;
00193   typedef typename
00194           CellsContainer::Iterator              CellsContainerIterator;
00195   typedef typename
00196           CellLinksContainer::ConstIterator     CellLinksContainerIterator;
00197   typedef typename
00198           PointDataContainer::ConstIterator     PointDataContainerIterator;
00199   typedef typename
00200           CellDataContainer::ConstIterator      CellDataContainerIterator;
00201   typedef typename
00202      PointCellLinksContainer::const_iterator  PointCellLinksContainerIterator;
00203 
00205   typedef CellFeatureIdentifier  CellFeatureCount;
00206 
00208   typedef CellInterface<CellPixelType,CellTraits>  CellType;
00209   typedef typename CellType::CellAutoPointer       CellAutoPointer;
00210 
00212   typedef typename CellType::MultiVisitor CellMultiVisitorType;
00213 
00222   class BoundaryAssignmentIdentifier
00223     {
00224   public:
00226     typedef BoundaryAssignmentIdentifier Self;
00227 
00230     BoundaryAssignmentIdentifier() {}
00231     BoundaryAssignmentIdentifier(CellIdentifier cellId,
00232                                  CellFeatureIdentifier featureId):
00233       m_CellId(cellId), m_FeatureId(featureId) {}
00235 
00237     CellIdentifier m_CellId;
00238 
00240     CellFeatureIdentifier  m_FeatureId;
00241 
00244     bool operator < (const Self& r) const
00245       {
00246       return ((m_CellId < r.m_CellId) ||
00247               ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
00248       }
00249 
00252     bool operator == (const Self& r) const
00253       {
00254       return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
00255       }
00256   }; // End Class: Mesh::BoundaryAssignmentIdentifier
00258 
00259 
00267   typedef MapContainer< BoundaryAssignmentIdentifier , CellIdentifier >
00268         BoundaryAssignmentsContainer;
00269   typedef typename BoundaryAssignmentsContainer::Pointer
00270         BoundaryAssignmentsContainerPointer;
00271   typedef std::vector< BoundaryAssignmentsContainerPointer >
00272         BoundaryAssignmentsContainerVector;
00273 
00274 
00275 protected:
00276 
00279   CellsContainerPointer  m_CellsContainer;
00280 
00285   CellDataContainerPointer  m_CellDataContainer;
00286 
00290   CellLinksContainerPointer  m_CellLinksContainer;
00291 
00301   BoundaryAssignmentsContainerVector  m_BoundaryAssignmentsContainers;
00302 
00303 public:
00305   unsigned long GetNumberOfCells() const;
00306   void PassStructure(Self* inputMesh);
00307   virtual void Initialize();
00309 
00311   virtual void CopyInformation(const DataObject *data);
00312   virtual void Graft(const DataObject *data);
00314 
00319   void SetCellLinks(CellLinksContainer*);
00320 #ifndef CABLE_CONFIGURATION
00321   CellLinksContainer * GetCellLinks();
00322   const CellLinksContainer * GetCellLinks() const;
00324 
00327   void SetCells(CellsContainer*);
00328 
00329   CellsContainer * GetCells();
00330   const CellsContainer * GetCells() const;
00331 #endif
00332 
00336   void SetCellData(CellDataContainer*);
00337   CellDataContainer *  GetCellData();
00338   const CellDataContainer * GetCellData() const;
00340 
00349 #if !defined(CABLE_CONFIGURATION)
00350   void SetBoundaryAssignments(int dimension,
00351                               BoundaryAssignmentsContainer*);
00352 #endif
00353 
00354 #ifndef CABLE_CONFIGURATION
00355   BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension);
00356   const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00357     int dimension) const;
00358 
00364   void SetCell(CellIdentifier, CellAutoPointer & );
00365   bool GetCell(CellIdentifier, CellAutoPointer & ) const;
00366 #endif
00367 
00370   void SetCellData(CellIdentifier, CellPixelType);
00371   bool GetCellData(CellIdentifier, CellPixelType*) const;
00373 
00386   void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00387                              CellFeatureIdentifier featureId,
00388                              CellIdentifier boundaryId);
00389 
00398   bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00399                              CellFeatureIdentifier featureId,
00400                              CellIdentifier* boundaryId) const;
00401   bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00402                                 CellFeatureIdentifier featureId);
00404 
00406   CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
00407                                                    CellIdentifier) const;
00408 
00409 #ifndef CABLE_CONFIGURATION
00410 
00412   bool GetCellBoundaryFeature(int dimension, CellIdentifier,
00413                               CellFeatureIdentifier, CellAutoPointer& ) const;
00414 #endif
00415 
00420   unsigned long GetCellBoundaryFeatureNeighbors(
00421     int dimension, CellIdentifier, CellFeatureIdentifier,
00422     std::set<CellIdentifier>* cellSet);
00423 
00428   unsigned long GetCellNeighbors( CellIdentifier cellId,
00429                                   std::set<CellIdentifier>* cellSet );
00430 #ifndef CABLE_CONFIGURATION
00431 
00439   bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
00440                                           CellFeatureIdentifier,
00441                                           CellAutoPointer& ) const;
00442 #endif
00443 
00446   void BuildCellLinks();
00447 
00448 #ifndef CABLE_CONFIGURATION
00449 
00452   BoundingBoxPointer GetCellBoundingBox(CellIdentifier cellId,
00453                                         BoundingBoxPointer bbox);
00454 
00458   virtual void Accept(CellMultiVisitorType* mv);
00459 #endif
00460 
00465   itkSetMacro( CellsAllocationMethod, CellsAllocationMethodType );
00466   itkGetConstReferenceMacro( CellsAllocationMethod, CellsAllocationMethodType );
00468 
00469 protected:
00471   Mesh();
00472   ~Mesh();
00473   void PrintSelf(std::ostream& os, Indent indent) const;
00475 
00479   void ReleaseCellsMemory();
00480 
00481 private:
00482   Mesh(const Self&); //purposely not implemented
00483   void operator=(const Self&); //purposely not implemented
00484 
00485   CellsAllocationMethodType             m_CellsAllocationMethod;
00486 
00487 }; // End Class: Mesh
00488 
00489 } // end namespace itk
00490 
00491 #ifndef ITK_MANUAL_INSTANTIATION
00492 #ifndef CABLE_CONFIGURATION
00493 #include "itkMesh.txx"
00494 #endif
00495 #endif
00496 
00497 #endif
00498 

Generated at Tue Sep 15 03:57:37 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000