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
00096 template <
00097 typename TPixelType,
00098 unsigned int VDimension = 3,
00099 typename TMeshTraits = DefaultStaticMeshTraits< TPixelType , VDimension, VDimension >
00100 >
00101 class Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
00102 {
00103 public:
00105 typedef Mesh Self;
00106 typedef PointSet<TPixelType, VDimension, TMeshTraits> Superclass;
00107 typedef SmartPointer<Self> Pointer;
00108 typedef SmartPointer<const Self> ConstPointer;
00109
00111 itkNewMacro(Self);
00112
00114 itkTypeMacro(Mesh, PointSet);
00115
00117 typedef TMeshTraits MeshTraits;
00118 typedef typename MeshTraits::PixelType PixelType;
00119 typedef typename MeshTraits::CellPixelType CellPixelType;
00120
00122 itkStaticConstMacro(PointDimension, unsigned int,
00123 TMeshTraits::PointDimension);
00124 itkStaticConstMacro(MaxTopologicalDimension, unsigned int,
00125 TMeshTraits::MaxTopologicalDimension);
00126
00128 typedef enum { CellsAllocationMethodUndefined,
00129 CellsAllocatedAsStaticArray,
00130 CellsAllocatedAsADynamicArray,
00131 CellsAllocatedDynamicallyCellByCell
00132 } CellsAllocationMethodType;
00133
00135 typedef enum { BoundariesAllocationMethodUndefined,
00136 BoundariesAllocatedAsStaticArray,
00137 BoundariesAllocatedAsADynamicArray,
00138 BoundariesAllocatedDynamicallyCellByCell
00139 } BoundariesAllocationMethodType;
00140
00142 typedef typename MeshTraits::CoordRepType CoordRepType;
00143 typedef typename MeshTraits::InterpolationWeightType InterpolationWeightType;
00144 typedef typename MeshTraits::PointIdentifier PointIdentifier;
00145 typedef typename MeshTraits::CellIdentifier CellIdentifier;
00146 typedef typename MeshTraits::BoundaryIdentifier BoundaryIdentifier;
00147 typedef typename MeshTraits::CellFeatureIdentifier CellFeatureIdentifier;
00148 typedef typename MeshTraits::PointType PointType;
00149 typedef typename MeshTraits::PointsContainer PointsContainer;
00150 typedef typename MeshTraits::CellTraits CellTraits;
00151 typedef typename MeshTraits::CellsContainer CellsContainer;
00152 typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer;
00153 typedef typename MeshTraits::CellLinksContainer CellLinksContainer;
00154 typedef typename MeshTraits::PointDataContainer PointDataContainer;
00155 typedef typename MeshTraits::CellDataContainer CellDataContainer;
00156 typedef typename MeshTraits::BoundariesContainer BoundariesContainer;
00157 typedef typename MeshTraits::BoundaryDataContainer BoundaryDataContainer;
00158
00160 typedef PointLocator<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00161 CoordRepType,PointsContainer> PointLocatorType;
00162 typedef BoundingBox<PointIdentifier,itkGetStaticConstMacro(PointDimension),
00163 CoordRepType,PointsContainer> BoundingBoxType;
00164
00166 typedef typename PointsContainer::Pointer PointsContainerPointer;
00167 typedef typename CellsContainer::Pointer CellsContainerPointer;
00168 typedef typename CellLinksContainer::Pointer CellLinksContainerPointer;
00169 typedef typename PointDataContainer::Pointer PointDataContainerPointer;
00170 typedef typename CellDataContainer::Pointer CellDataContainerPointer;
00171 typedef typename BoundariesContainer::Pointer BoundariesContainerPointer;
00172 typedef typename BoundaryDataContainer::Pointer BoundaryDataContainerPointer;
00173 typedef typename PointLocatorType::Pointer PointLocatorPointer;
00174 typedef typename BoundingBoxType::Pointer BoundingBoxPointer;
00175
00177 typedef typename
00178 PointsContainer::ConstIterator PointsContainerConstIterator;
00179 typedef typename
00180 PointsContainer::Iterator PointsContainerIterator;
00181 typedef typename
00182 CellsContainer::ConstIterator CellsContainerConstIterator;
00183 typedef typename
00184 CellsContainer::Iterator CellsContainerIterator;
00185 typedef typename
00186 CellLinksContainer::ConstIterator CellLinksContainerIterator;
00187 typedef typename
00188 PointDataContainer::ConstIterator PointDataContainerIterator;
00189 typedef typename
00190 CellDataContainer::ConstIterator CellDataContainerIterator;
00191 typedef typename
00192 BoundariesContainer::ConstIterator BoundariesContainerIterator;
00193 typedef typename
00194 BoundaryDataContainer::ConstIterator BoundaryDataContainerIterator;
00195 typedef typename
00196 PointCellLinksContainer::const_iterator PointCellLinksContainerIterator;
00197
00199 typedef CellFeatureIdentifier CellFeatureCount;
00200
00202 typedef CellInterface<CellPixelType,CellTraits> CellType;
00203 typedef typename CellType::CellAutoPointer CellAutoPointer;
00204
00206 typedef CellType BoundaryType;
00207 typedef CellAutoPointer BoundaryAutoPointer;
00208
00210 typedef typename CellType::MultiVisitor CellMultiVisitorType;
00211
00212 protected:
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) {}
00232
00234 CellIdentifier m_CellId;
00235
00237 CellFeatureIdentifier m_FeatureId;
00238
00241 bool operator < (const Self& r) const
00242 {
00243 return ((m_CellId < r.m_CellId) ||
00244 ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
00245 }
00246
00249 bool operator == (const Self& r) const
00250 {
00251 return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
00252 }
00253 };
00254
00257 CellsContainerPointer m_CellsContainer;
00258
00263 CellDataContainerPointer m_CellDataContainer;
00264
00268 CellLinksContainerPointer m_CellLinksContainer;
00269
00271 typedef std::vector<BoundariesContainerPointer> BoundariesContainerVector;
00272 typedef std::vector< BoundaryDataContainerPointer >
00273 BoundaryDataContainerVector;
00274 typedef MapContainer< BoundaryAssignmentIdentifier , BoundaryIdentifier >
00275 BoundaryAssignmentsContainer;
00276 typedef typename BoundaryAssignmentsContainer::Pointer
00277 BoundaryAssignmentsContainerPointer;
00278 typedef std::vector< BoundaryAssignmentsContainerPointer >
00279 BoundaryAssignmentsContainerVector;
00280
00293 mutable BoundariesContainerVector m_BoundariesContainers;
00294
00300 BoundaryDataContainerVector m_BoundaryDataContainers;
00301
00311 BoundaryAssignmentsContainerVector m_BoundaryAssignmentsContainers;
00312
00313 public:
00315 unsigned long GetNumberOfCells(void);
00316 void PassStructure(Self* inputMesh);
00317 virtual void Initialize(void);
00318
00322 void SetCellLinks(CellLinksContainer*);
00323 CellLinksContainerPointer GetCellLinks(void);
00324 void SetCells(CellsContainer*);
00325 CellsContainerPointer GetCells(void);
00326 void SetCellData(CellDataContainer*);
00327 CellDataContainerPointer GetCellData(void);
00328 void SetBoundaries(int dimension, BoundariesContainer*);
00329 BoundariesContainerPointer GetBoundaries(int dimension);
00330 void SetBoundaryData(int dimension, BoundaryDataContainer*);
00331 BoundaryDataContainerPointer GetBoundaryData(int dimension);
00332 void SetBoundaryAssignments(int dimension,
00333 BoundaryAssignmentsContainer*);
00334 BoundaryAssignmentsContainerPointer
00335 GetBoundaryAssignments(int dimension);
00336
00342 void SetCell(CellIdentifier, CellAutoPointer & );
00343 bool GetCell(CellIdentifier, CellAutoPointer & ) const;
00344
00347 void SetCellData(CellIdentifier, CellPixelType);
00348 bool GetCellData(CellIdentifier, CellPixelType*) const;
00349
00352 void SetBoundary(int dimension, BoundaryIdentifier, BoundaryAutoPointer & );
00353 bool GetBoundary(int dimension, BoundaryIdentifier, BoundaryAutoPointer & ) const;
00354
00357 void SetBoundaryData(int dimension, BoundaryIdentifier, CellPixelType);
00358 bool GetBoundaryData(int dimension, BoundaryIdentifier, CellPixelType*) const;
00359
00362 void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
00363 CellFeatureIdentifier featureId,
00364 BoundaryIdentifier);
00365 bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
00366 CellFeatureIdentifier featureId,
00367 BoundaryIdentifier*) const;
00368 bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
00369 CellFeatureIdentifier featureId);
00370
00372 CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
00373 CellIdentifier) const;
00374 bool GetCellBoundaryFeature(int dimension, CellIdentifier,
00375 CellFeatureIdentifier, BoundaryAutoPointer & ) const;
00376 unsigned long GetCellBoundaryFeatureNeighbors(
00377 int dimension, CellIdentifier, CellFeatureIdentifier,
00378 std::set<CellIdentifier>* cellSet);
00379
00380 bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
00381 CellFeatureIdentifier,
00382 BoundaryAutoPointer& ) const;
00383 void BuildCellLinks(void);
00384
00388 BoundingBoxPointer GetCellBoundingBox(CellIdentifier cellId,
00389 BoundingBoxPointer bbox);
00390
00394 virtual void Accept(CellMultiVisitorType* mv);
00395
00397 virtual void UpdateOutputInformation();
00398 virtual void SetRequestedRegionToLargestPossibleRegion();
00399 virtual void CopyInformation(const DataObject *data);
00400 virtual bool RequestedRegionIsOutsideOfTheBufferedRegion();
00401 virtual bool VerifyRequestedRegion();
00402
00405 int GetMaximumNumberOfRegions() const
00406 {return m_MaximumNumberOfRegions;}
00407
00412 virtual void SetRequestedRegion(DataObject *data);
00413
00418 itkSetMacro( CellsAllocationMethod, CellsAllocationMethodType );
00419 itkGetConstMacro( CellsAllocationMethod, CellsAllocationMethodType );
00420
00425 itkSetMacro( BoundariesAllocationMethod, BoundariesAllocationMethodType );
00426 itkGetConstMacro( BoundariesAllocationMethod, BoundariesAllocationMethodType );
00427
00428
00429 protected:
00431 Mesh();
00432 ~Mesh();
00433 void PrintSelf(std::ostream& os, Indent indent) const;
00434
00438 void ReleaseCellsMemory(void);
00439
00443 void ReleaseBoundariesMemory(void);
00444
00449 void ReleaseBoundariesMemory( unsigned int dimension );
00450
00451 private:
00452 Mesh(const Self&);
00453 void operator=(const Self&);
00454
00455 CellsAllocationMethodType m_CellsAllocationMethod;
00456 BoundariesAllocationMethodType m_BoundariesAllocationMethod;
00457
00458 };
00459
00460 }
00461
00462 #ifndef ITK_MANUAL_INSTANTIATION
00463 #include "itkMesh.txx"
00464 #endif
00465
00466 #endif
00467
00468
00469