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
00220 class BoundaryAssignmentIdentifier
00221 {
00222 public:
00224 typedef BoundaryAssignmentIdentifier Self;
00225
00228 BoundaryAssignmentIdentifier() {}
00229 BoundaryAssignmentIdentifier(CellIdentifier cellId,
00230 CellFeatureIdentifier featureId):
00231 m_CellId(cellId), m_FeatureId(featureId) {}
00233
00235 CellIdentifier m_CellId;
00236
00238 CellFeatureIdentifier m_FeatureId;
00239
00242 bool operator < (const Self& r) const
00243 {
00244 return ((m_CellId < r.m_CellId) ||
00245 ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
00246 }
00247
00250 bool operator == (const Self& r) const
00251 {
00252 return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
00253 }
00254 };
00256
00257
00265 typedef MapContainer< BoundaryAssignmentIdentifier , CellIdentifier >
00266 BoundaryAssignmentsContainer;
00267 typedef typename BoundaryAssignmentsContainer::Pointer
00268 BoundaryAssignmentsContainerPointer;
00269 typedef std::vector< BoundaryAssignmentsContainerPointer >
00270 BoundaryAssignmentsContainerVector;
00271
00272
00273 protected:
00274
00277 CellsContainerPointer m_CellsContainer;
00278
00283 CellDataContainerPointer m_CellDataContainer;
00284
00288 CellLinksContainerPointer m_CellLinksContainer;
00289
00299 BoundaryAssignmentsContainerVector m_BoundaryAssignmentsContainers;
00300
00301 public:
00303 unsigned long GetNumberOfCells() const;
00304 void PassStructure(Self* inputMesh);
00305 virtual void Initialize();
00307
00309 virtual void CopyInformation(const DataObject *data);
00310 virtual void Graft(const DataObject *data);
00312
00317 void SetCellLinks(CellLinksContainer*);
00318 #ifndef CABLE_CONFIGURATION
00319 CellLinksContainerPointer GetCellLinks();
00320 const CellLinksContainerPointer GetCellLinks() const;
00322
00325 void SetCells(CellsContainer*);
00326
00327 CellsContainerPointer GetCells();
00328 const CellsContainerPointer GetCells() const;
00329 #endif
00330
00334 void SetCellData(CellDataContainer*);
00335 CellDataContainerPointer GetCellData();
00336 const CellDataContainerPointer GetCellData() const;
00338
00347 #if !defined(CABLE_CONFIGURATION)
00348 void SetBoundaryAssignments(int dimension,
00349 BoundaryAssignmentsContainer*);
00350 #endif
00351
00352 #ifndef CABLE_CONFIGURATION
00353 BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension);
00354 const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00355 int dimension) const;
00356
00362 void SetCell(CellIdentifier, CellAutoPointer & );
00363 bool GetCell(CellIdentifier, CellAutoPointer & ) const;
00364 #endif
00365
00368 void SetCellData(CellIdentifier, CellPixelType);
00369 bool GetCellData(CellIdentifier, CellPixelType*) const;
00371
00384 void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00385 CellFeatureIdentifier featureId,
00386 CellIdentifier boundaryId);
00387
00396 bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00397 CellFeatureIdentifier featureId,
00398 CellIdentifier* boundaryId) const;
00399 bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00400 CellFeatureIdentifier featureId);
00402
00404 CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
00405 CellIdentifier) const;
00406
00407 #ifndef CABLE_CONFIGURATION
00408
00410 bool GetCellBoundaryFeature(int dimension, CellIdentifier,
00411 CellFeatureIdentifier, CellAutoPointer& ) const;
00412 #endif
00413
00418 unsigned long GetCellBoundaryFeatureNeighbors(
00419 int dimension, CellIdentifier, CellFeatureIdentifier,
00420 std::set<CellIdentifier>* cellSet);
00421
00426 unsigned long GetCellNeighbors( CellIdentifier cellId,
00427 std::set<CellIdentifier>* cellSet );
00428 #ifndef CABLE_CONFIGURATION
00429
00437 bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
00438 CellFeatureIdentifier,
00439 CellAutoPointer& ) const;
00440 #endif
00441
00444 void BuildCellLinks();
00445
00446 #ifndef CABLE_CONFIGURATION
00447
00450 BoundingBoxPointer GetCellBoundingBox(CellIdentifier cellId,
00451 BoundingBoxPointer bbox);
00452
00456 virtual void Accept(CellMultiVisitorType* mv);
00457 #endif
00458
00463 itkSetMacro( CellsAllocationMethod, CellsAllocationMethodType );
00464 itkGetConstReferenceMacro( CellsAllocationMethod, CellsAllocationMethodType );
00466
00467 protected:
00469 Mesh();
00470 ~Mesh();
00471 void PrintSelf(std::ostream& os, Indent indent) const;
00473
00477 void ReleaseCellsMemory();
00478
00479 private:
00480 Mesh(const Self&);
00481 void operator=(const Self&);
00482
00483 CellsAllocationMethodType m_CellsAllocationMethod;
00484
00485 };
00486
00487 }
00488
00489 #ifndef ITK_MANUAL_INSTANTIATION
00490 #ifndef CABLE_CONFIGURATION
00491 #include "itkMesh.txx"
00492 #endif
00493 #endif
00494
00495 #endif
00496