ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 /*========================================================================= 00019 * 00020 * Portions of this file are subject to the VTK Toolkit Version 3 copyright. 00021 * 00022 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00023 * 00024 * For complete copyright, license and disclaimer of warranty information 00025 * please refer to the NOTICE file at the top of the ITK source tree. 00026 * 00027 *=========================================================================*/ 00028 #ifndef __itkMesh_h 00029 #define __itkMesh_h 00030 00031 00032 #include "itkPointSet.h" 00033 00034 #include "itkBoundingBox.h" 00035 #include "itkCellInterface.h" 00036 #include "itkMapContainer.h" 00037 #include <vector> 00038 #include <set> 00039 00040 namespace itk 00041 { 00048 template< typename TMesh > 00049 struct GetMeshDimension { 00050 itkStaticConstMacro(MaxTopologicalDimension, unsigned int, TMesh::MaxTopologicalDimension); 00051 itkStaticConstMacro(PointDimension, unsigned int, TMesh::PointDimension); 00052 }; 00054 00115 template< 00116 typename TPixelType, 00117 unsigned int VDimension = 3, 00118 typename TMeshTraits = DefaultStaticMeshTraits< TPixelType, VDimension, VDimension > 00119 > 00120 class ITK_EXPORT Mesh:public PointSet< TPixelType, VDimension, TMeshTraits > 00121 { 00122 public: 00124 typedef Mesh Self; 00125 typedef PointSet< TPixelType, VDimension, TMeshTraits > Superclass; 00126 typedef SmartPointer< Self > Pointer; 00127 typedef SmartPointer< const Self > ConstPointer; 00128 00129 typedef typename Superclass::RegionType RegionType; 00130 00132 itkNewMacro(Self); 00133 00135 itkTypeMacro(Mesh, PointSet); 00136 00138 typedef TMeshTraits MeshTraits; 00139 typedef typename MeshTraits::PixelType PixelType; 00140 typedef typename MeshTraits::CellPixelType CellPixelType; 00141 00143 itkStaticConstMacro(PointDimension, unsigned int, 00144 TMeshTraits::PointDimension); 00145 itkStaticConstMacro(MaxTopologicalDimension, unsigned int, 00146 TMeshTraits::MaxTopologicalDimension); 00148 00151 typedef enum { CellsAllocationMethodUndefined, 00152 CellsAllocatedAsStaticArray, 00153 CellsAllocatedAsADynamicArray, 00154 CellsAllocatedDynamicallyCellByCell } CellsAllocationMethodType; 00155 00157 typedef typename MeshTraits::CoordRepType CoordRepType; 00158 typedef typename MeshTraits::InterpolationWeightType InterpolationWeightType; 00159 typedef typename MeshTraits::PointIdentifier PointIdentifier; 00160 typedef typename MeshTraits::CellIdentifier CellIdentifier; 00161 typedef typename MeshTraits::CellFeatureIdentifier CellFeatureIdentifier; 00162 typedef typename MeshTraits::PointHashType PointHashType; 00163 typedef typename MeshTraits::PointType PointType; 00164 typedef typename MeshTraits::PointsContainer PointsContainer; 00165 typedef typename MeshTraits::CellTraits CellTraits; 00166 typedef typename MeshTraits::CellsContainer CellsContainer; 00167 typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer; 00168 typedef typename MeshTraits::CellLinksContainer CellLinksContainer; 00169 typedef typename MeshTraits::PointDataContainer PointDataContainer; 00170 typedef typename MeshTraits::CellDataContainer CellDataContainer; 00171 00173 typedef BoundingBox< PointIdentifier, itkGetStaticConstMacro(PointDimension), 00174 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 CellDataContainer::ConstPointer CellDataContainerConstPointer; 00184 typedef typename BoundingBoxType::Pointer BoundingBoxPointer; 00185 typedef typename CellLinksContainer::ConstPointer CellLinksContainerConstPointer; 00186 00188 typedef typename PointsContainer::ConstIterator PointsContainerConstIterator; 00189 typedef typename PointsContainer::Iterator PointsContainerIterator; 00190 typedef typename CellsContainer::ConstIterator CellsContainerConstIterator; 00191 typedef typename CellsContainer::Iterator CellsContainerIterator; 00192 typedef typename CellLinksContainer::ConstIterator CellLinksContainerIterator; 00193 typedef typename PointDataContainer::ConstIterator PointDataContainerIterator; 00194 typedef typename CellDataContainer::ConstIterator CellDataContainerIterator; 00195 typedef typename PointCellLinksContainer::const_iterator PointCellLinksContainerIterator; 00196 00198 typedef CellFeatureIdentifier CellFeatureCount; 00199 00201 typedef CellInterface< CellPixelType, CellTraits > CellType; 00202 typedef typename CellType::CellAutoPointer CellAutoPointer; 00203 00205 typedef typename CellType::MultiVisitor CellMultiVisitorType; 00206 00217 class BoundaryAssignmentIdentifier 00218 { 00219 public: 00221 typedef BoundaryAssignmentIdentifier Self; 00222 00225 BoundaryAssignmentIdentifier() {} 00226 BoundaryAssignmentIdentifier(CellIdentifier cellId, 00227 CellFeatureIdentifier featureId): 00228 m_CellId(cellId), m_FeatureId(featureId) {} 00230 00232 CellIdentifier m_CellId; 00233 00235 CellFeatureIdentifier m_FeatureId; 00236 00239 bool operator<(const Self & r) const 00240 { 00241 return ( ( m_CellId < r.m_CellId ) 00242 || ( ( m_CellId == r.m_CellId ) && ( m_FeatureId < r.m_FeatureId ) ) ); 00243 } 00244 00247 bool operator==(const Self & r) const 00248 { 00249 return ( ( m_CellId == r.m_CellId ) && ( m_FeatureId == r.m_FeatureId ) ); 00250 } 00251 }; // End Class: Mesh::BoundaryAssignmentIdentifier 00253 00261 typedef MapContainer< BoundaryAssignmentIdentifier, CellIdentifier > 00262 BoundaryAssignmentsContainer; 00263 typedef typename BoundaryAssignmentsContainer::Pointer 00264 BoundaryAssignmentsContainerPointer; 00265 typedef std::vector< BoundaryAssignmentsContainerPointer > 00266 BoundaryAssignmentsContainerVector; 00267 protected: 00268 00271 CellsContainerPointer m_CellsContainer; 00272 00277 CellDataContainerPointer m_CellDataContainer; 00278 00282 mutable CellLinksContainerPointer m_CellLinksContainer; 00283 00293 BoundaryAssignmentsContainerVector m_BoundaryAssignmentsContainers; 00294 public: 00295 00297 CellIdentifier GetNumberOfCells() const; 00298 00299 void PassStructure(Self *inputMesh); 00300 00301 virtual void Initialize(); 00302 00304 virtual void CopyInformation(const DataObject *data); 00305 00306 virtual void Graft(const DataObject *data); 00307 00310 const BoundingBoxType * GetBoundingBox(void) const; 00311 00316 void SetCellLinks(CellLinksContainer *); 00317 00318 CellLinksContainer * GetCellLinks(); 00319 00320 const CellLinksContainer * GetCellLinks() const; 00321 00324 void SetCells(CellsContainer *); 00325 00326 CellsContainer * GetCells(); 00327 00328 const CellsContainer * GetCells() const; 00329 00334 void SetCellData(CellDataContainer *); 00335 00336 CellDataContainer * GetCellData(); 00337 00338 const CellDataContainer * GetCellData() const; 00339 00340 #if !defined( CABLE_CONFIGURATION ) 00341 00349 void SetBoundaryAssignments(int dimension, 00350 BoundaryAssignmentsContainer *); 00351 00352 00353 BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension); 00354 00355 const BoundaryAssignmentsContainerPointer GetBoundaryAssignments( 00356 int dimension) const; 00357 #endif 00358 00364 void SetCell(CellIdentifier, CellAutoPointer &); 00365 bool GetCell(CellIdentifier, CellAutoPointer &) const; 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 00401 bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId, 00402 CellFeatureIdentifier featureId); 00403 00405 CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension, 00406 CellIdentifier) const; 00407 00410 bool GetCellBoundaryFeature(int dimension, CellIdentifier, 00411 CellFeatureIdentifier, CellAutoPointer &) const; 00412 00417 CellIdentifier GetCellBoundaryFeatureNeighbors( 00418 int dimension, CellIdentifier, CellFeatureIdentifier, 00419 std::set< CellIdentifier > *cellSet); 00420 00425 CellIdentifier GetCellNeighbors(CellIdentifier cellId, 00426 std::set< CellIdentifier > *cellSet); 00427 00435 bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier, 00436 CellFeatureIdentifier, 00437 CellAutoPointer &) const; 00438 00441 void BuildCellLinks() const; 00442 00446 virtual void Accept(CellMultiVisitorType *mv) const; 00447 00452 itkSetMacro(CellsAllocationMethod, CellsAllocationMethodType); 00453 itkGetConstReferenceMacro(CellsAllocationMethod, CellsAllocationMethodType); 00454 protected: 00455 00457 Mesh(); 00458 ~Mesh(); 00459 void PrintSelf(std::ostream & os, Indent indent) const; 00461 00465 void ReleaseCellsMemory(); 00466 00469 BoundingBoxPointer m_BoundingBox; 00470 00471 private: 00472 Mesh(const Self &); //purposely not implemented 00473 void operator=(const Self &); //purposely not implemented 00474 00475 CellsAllocationMethodType m_CellsAllocationMethod; 00476 }; // End Class: Mesh 00477 } // end namespace itk 00478 00479 #ifndef ITK_MANUAL_INSTANTIATION 00480 #ifndef CABLE_CONFIGURATION 00481 #include "itkMesh.hxx" 00482 #endif 00483 #endif 00484 00485 #endif 00486