00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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::PointType PointType;
00160 typedef typename MeshTraits::PointsContainer PointsContainer;
00161 typedef typename MeshTraits::CellTraits CellTraits;
00162 typedef typename MeshTraits::CellsContainer CellsContainer;
00163 typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer;
00164 typedef typename MeshTraits::CellLinksContainer CellLinksContainer;
00165 typedef typename MeshTraits::PointDataContainer PointDataContainer;
00166 typedef typename MeshTraits::CellDataContainer CellDataContainer;
00167
00169 typedef PointLocator<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00170 CoordRepType,PointsContainer> PointLocatorType;
00171 typedef BoundingBox<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00172 CoordRepType,PointsContainer> BoundingBoxType;
00174
00176 typedef typename PointsContainer::Pointer PointsContainerPointer;
00177 typedef typename CellsContainer::Pointer CellsContainerPointer;
00178 typedef typename CellLinksContainer::Pointer CellLinksContainerPointer;
00179 typedef typename PointDataContainer::Pointer PointDataContainerPointer;
00180 typedef typename CellDataContainer::Pointer CellDataContainerPointer;
00181 typedef typename PointLocatorType::Pointer PointLocatorPointer;
00182 typedef typename BoundingBoxType::Pointer BoundingBoxPointer;
00183
00185 typedef typename
00186 PointsContainer::ConstIterator PointsContainerConstIterator;
00187 typedef typename
00188 PointsContainer::Iterator PointsContainerIterator;
00189 typedef typename
00190 CellsContainer::ConstIterator CellsContainerConstIterator;
00191 typedef typename
00192 CellsContainer::Iterator CellsContainerIterator;
00193 typedef typename
00194 CellLinksContainer::ConstIterator CellLinksContainerIterator;
00195 typedef typename
00196 PointDataContainer::ConstIterator PointDataContainerIterator;
00197 typedef typename
00198 CellDataContainer::ConstIterator CellDataContainerIterator;
00199 typedef typename
00200 PointCellLinksContainer::const_iterator PointCellLinksContainerIterator;
00201
00203 typedef CellFeatureIdentifier CellFeatureCount;
00204
00206 typedef CellInterface<CellPixelType,CellTraits> CellType;
00207 typedef typename CellType::CellAutoPointer CellAutoPointer;
00208
00210 typedef typename CellType::MultiVisitor CellMultiVisitorType;
00211
00212
00213
00221 class BoundaryAssignmentIdentifier
00222 {
00223 public:
00224
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 };
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 CellLinksContainerPointer GetCellLinks();
00322 const CellLinksContainerPointer GetCellLinks() const;
00324
00327 void SetCells(CellsContainer*);
00328
00329 CellsContainerPointer GetCells();
00330 const CellsContainerPointer GetCells() const;
00331 #endif
00332
00336 void SetCellData(CellDataContainer*);
00337 CellDataContainerPointer GetCellData();
00338 const CellDataContainerPointer 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&);
00483 void operator=(const Self&);
00484
00485 CellsAllocationMethodType m_CellsAllocationMethod;
00486
00487 };
00488
00489 }
00490
00491 #ifndef ITK_MANUAL_INSTANTIATION
00492 #ifndef CABLE_CONFIGURATION
00493 #include "itkMesh.txx"
00494 #endif
00495 #endif
00496
00497 #endif
00498
00499
00500
00501