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::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 CellLinksContainer::Pointer CellLinksContainerPointer;
00180 typedef typename PointDataContainer::Pointer PointDataContainerPointer;
00181 typedef typename CellDataContainer::Pointer CellDataContainerPointer;
00182 typedef typename PointLocatorType::Pointer PointLocatorPointer;
00183 typedef typename BoundingBoxType::Pointer BoundingBoxPointer;
00184
00186 typedef typename
00187 PointsContainer::ConstIterator PointsContainerConstIterator;
00188 typedef typename
00189 PointsContainer::Iterator PointsContainerIterator;
00190 typedef typename
00191 CellsContainer::ConstIterator CellsContainerConstIterator;
00192 typedef typename
00193 CellsContainer::Iterator CellsContainerIterator;
00194 typedef typename
00195 CellLinksContainer::ConstIterator CellLinksContainerIterator;
00196 typedef typename
00197 PointDataContainer::ConstIterator PointDataContainerIterator;
00198 typedef typename
00199 CellDataContainer::ConstIterator CellDataContainerIterator;
00200 typedef typename
00201 PointCellLinksContainer::const_iterator PointCellLinksContainerIterator;
00202
00204 typedef CellFeatureIdentifier CellFeatureCount;
00205
00207 typedef CellInterface<CellPixelType,CellTraits> CellType;
00208 typedef typename CellType::CellAutoPointer CellAutoPointer;
00209
00211 typedef typename CellType::MultiVisitor CellMultiVisitorType;
00212
00221 class BoundaryAssignmentIdentifier
00222 {
00223 public:
00225 typedef BoundaryAssignmentIdentifier Self;
00226
00229 BoundaryAssignmentIdentifier() {}
00230 BoundaryAssignmentIdentifier(CellIdentifier cellId,
00231 CellFeatureIdentifier featureId):
00232 m_CellId(cellId), m_FeatureId(featureId) {}
00234
00236 CellIdentifier m_CellId;
00237
00239 CellFeatureIdentifier m_FeatureId;
00240
00243 bool operator < (const Self& r) const
00244 {
00245 return ((m_CellId < r.m_CellId) ||
00246 ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
00247 }
00248
00251 bool operator == (const Self& r) const
00252 {
00253 return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
00254 }
00255 };
00257
00258
00266 typedef MapContainer< BoundaryAssignmentIdentifier , CellIdentifier >
00267 BoundaryAssignmentsContainer;
00268 typedef typename BoundaryAssignmentsContainer::Pointer
00269 BoundaryAssignmentsContainerPointer;
00270 typedef std::vector< BoundaryAssignmentsContainerPointer >
00271 BoundaryAssignmentsContainerVector;
00272
00273
00274 protected:
00275
00278 CellsContainerPointer m_CellsContainer;
00279
00284 CellDataContainerPointer m_CellDataContainer;
00285
00289 CellLinksContainerPointer m_CellLinksContainer;
00290
00300 BoundaryAssignmentsContainerVector m_BoundaryAssignmentsContainers;
00301
00302 public:
00304 unsigned long GetNumberOfCells() const;
00305 void PassStructure(Self* inputMesh);
00306 virtual void Initialize();
00308
00310 virtual void CopyInformation(const DataObject *data);
00311 virtual void Graft(const DataObject *data);
00313
00318 void SetCellLinks(CellLinksContainer*);
00319 #ifndef CABLE_CONFIGURATION
00320 CellLinksContainerPointer GetCellLinks();
00321 const CellLinksContainerPointer GetCellLinks() const;
00323
00326 void SetCells(CellsContainer*);
00327
00328 CellsContainerPointer GetCells();
00329 const CellsContainerPointer GetCells() const;
00330 #endif
00331
00335 void SetCellData(CellDataContainer*);
00336 CellDataContainerPointer GetCellData();
00337 const CellDataContainerPointer GetCellData() const;
00339
00348 #if !defined(CABLE_CONFIGURATION)
00349 void SetBoundaryAssignments(int dimension,
00350 BoundaryAssignmentsContainer*);
00351 #endif
00352
00353 #ifndef CABLE_CONFIGURATION
00354 BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension);
00355 const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
00356 int dimension) const;
00357
00363 void SetCell(CellIdentifier, CellAutoPointer & );
00364 bool GetCell(CellIdentifier, CellAutoPointer & ) const;
00365 #endif
00366
00369 void SetCellData(CellIdentifier, CellPixelType);
00370 bool GetCellData(CellIdentifier, CellPixelType*) const;
00372
00385 void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00386 CellFeatureIdentifier featureId,
00387 CellIdentifier boundaryId);
00388
00397 bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00398 CellFeatureIdentifier featureId,
00399 CellIdentifier* boundaryId) const;
00400 bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00401 CellFeatureIdentifier featureId);
00403
00405 CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
00406 CellIdentifier) const;
00407
00408 #ifndef CABLE_CONFIGURATION
00409
00411 bool GetCellBoundaryFeature(int dimension, CellIdentifier,
00412 CellFeatureIdentifier, CellAutoPointer& ) const;
00413 #endif
00414
00419 unsigned long GetCellBoundaryFeatureNeighbors(
00420 int dimension, CellIdentifier, CellFeatureIdentifier,
00421 std::set<CellIdentifier>* cellSet);
00422
00427 unsigned long GetCellNeighbors( CellIdentifier cellId,
00428 std::set<CellIdentifier>* cellSet );
00429 #ifndef CABLE_CONFIGURATION
00430
00438 bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
00439 CellFeatureIdentifier,
00440 CellAutoPointer& ) const;
00441 #endif
00442
00445 void BuildCellLinks();
00446
00447 #ifndef CABLE_CONFIGURATION
00448
00451 BoundingBoxPointer GetCellBoundingBox(CellIdentifier cellId,
00452 BoundingBoxPointer bbox);
00453
00457 virtual void Accept(CellMultiVisitorType* mv);
00458 #endif
00459
00464 itkSetMacro( CellsAllocationMethod, CellsAllocationMethodType );
00465 itkGetConstReferenceMacro( CellsAllocationMethod, CellsAllocationMethodType );
00467
00468 protected:
00470 Mesh();
00471 ~Mesh();
00472 void PrintSelf(std::ostream& os, Indent indent) const;
00474
00478 void ReleaseCellsMemory();
00479
00480 private:
00481 Mesh(const Self&);
00482 void operator=(const Self&);
00483
00484 CellsAllocationMethodType m_CellsAllocationMethod;
00485
00486 };
00487
00488 }
00489
00490 #ifndef ITK_MANUAL_INSTANTIATION
00491 #ifndef CABLE_CONFIGURATION
00492 #include "itkMesh.txx"
00493 #endif
00494 #endif
00495
00496 #endif
00497