ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkMesh.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef __itkMesh_h
29 #define __itkMesh_h
30 
31 
32 #include "itkPointSet.h"
33 
34 #include "itkBoundingBox.h"
35 #include "itkCellInterface.h"
36 #include "itkMapContainer.h"
37 #include <vector>
38 #include <set>
39 
40 namespace itk
41 {
48 template< typename TMesh >
50  itkStaticConstMacro(MaxTopologicalDimension, unsigned int, TMesh::MaxTopologicalDimension);
51  itkStaticConstMacro(PointDimension, unsigned int, TMesh::PointDimension);
52 };
54 
115 template<
116  typename TPixelType,
117  unsigned int VDimension = 3,
119  >
120 class ITK_EXPORT Mesh:public PointSet< TPixelType, VDimension, TMeshTraits >
121 {
122 public:
124  typedef Mesh Self;
128 
129  typedef typename Superclass::RegionType RegionType;
130 
132  itkNewMacro(Self);
133 
135  itkTypeMacro(Mesh, PointSet);
136 
138  typedef TMeshTraits MeshTraits;
139  typedef typename MeshTraits::PixelType PixelType;
140  typedef typename MeshTraits::CellPixelType CellPixelType;
141 
143  itkStaticConstMacro(PointDimension, unsigned int,
144  TMeshTraits::PointDimension);
145  itkStaticConstMacro(MaxTopologicalDimension, unsigned int,
146  TMeshTraits::MaxTopologicalDimension);
148 
154  CellsAllocatedDynamicallyCellByCell } CellsAllocationMethodType;
155 
157  typedef typename MeshTraits::CoordRepType CoordRepType;
158  typedef typename MeshTraits::InterpolationWeightType InterpolationWeightType;
159  typedef typename MeshTraits::PointIdentifier PointIdentifier;
160  typedef typename MeshTraits::CellIdentifier CellIdentifier;
161  typedef typename MeshTraits::CellFeatureIdentifier CellFeatureIdentifier;
162  typedef typename MeshTraits::PointHashType PointHashType;
163  typedef typename MeshTraits::PointType PointType;
164  typedef typename MeshTraits::PointsContainer PointsContainer;
165  typedef typename MeshTraits::CellTraits CellTraits;
166  typedef typename MeshTraits::CellsContainer CellsContainer;
167  typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer;
168  typedef typename MeshTraits::CellLinksContainer CellLinksContainer;
169  typedef typename MeshTraits::PointDataContainer PointDataContainer;
170  typedef typename MeshTraits::CellDataContainer CellDataContainer;
171 
173  typedef BoundingBox< PointIdentifier, itkGetStaticConstMacro(PointDimension),
175 
177  typedef typename PointsContainer::Pointer PointsContainerPointer;
178  typedef typename CellsContainer::Pointer CellsContainerPointer;
179  typedef typename CellsContainer::ConstPointer CellsContainerConstPointer;
180  typedef typename CellLinksContainer::Pointer CellLinksContainerPointer;
181  typedef typename PointDataContainer::Pointer PointDataContainerPointer;
182  typedef typename CellDataContainer::Pointer CellDataContainerPointer;
183  typedef typename CellDataContainer::ConstPointer CellDataContainerConstPointer;
185  typedef typename CellLinksContainer::ConstPointer CellLinksContainerConstPointer;
186 
188  typedef typename PointsContainer::ConstIterator PointsContainerConstIterator;
189  typedef typename PointsContainer::Iterator PointsContainerIterator;
190  typedef typename CellsContainer::ConstIterator CellsContainerConstIterator;
191  typedef typename CellsContainer::Iterator CellsContainerIterator;
192  typedef typename CellLinksContainer::ConstIterator CellLinksContainerIterator;
193  typedef typename PointDataContainer::ConstIterator PointDataContainerIterator;
194  typedef typename CellDataContainer::ConstIterator CellDataContainerIterator;
195  typedef typename PointCellLinksContainer::const_iterator PointCellLinksContainerIterator;
196 
199 
203 
206 
218  {
219 public:
222 
227  CellFeatureIdentifier featureId):
228  m_CellId(cellId), m_FeatureId(featureId) {}
230 
233 
236 
239  bool operator<(const Self & r) const
240  {
241  return ( ( m_CellId < r.m_CellId )
242  || ( ( m_CellId == r.m_CellId ) && ( m_FeatureId < r.m_FeatureId ) ) );
243  }
244 
247  bool operator==(const Self & r) const
248  {
249  return ( ( m_CellId == r.m_CellId ) && ( m_FeatureId == r.m_FeatureId ) );
250  }
251  }; // End Class: Mesh::BoundaryAssignmentIdentifier
253 
265  typedef std::vector< BoundaryAssignmentsContainerPointer >
267 protected:
268 
272 
278 
283 
294 public:
295 
297  CellIdentifier GetNumberOfCells() const;
298 
299  void PassStructure(Self *inputMesh);
300 
301  virtual void Initialize();
302 
304  virtual void CopyInformation(const DataObject *data);
305 
306  virtual void Graft(const DataObject *data);
307 
310  const BoundingBoxType * GetBoundingBox(void) const;
311 
316  void SetCellLinks(CellLinksContainer *);
317 
318  CellLinksContainer * GetCellLinks();
319 
320  const CellLinksContainer * GetCellLinks() const;
321 
324  void SetCells(CellsContainer *);
325 
326  CellsContainer * GetCells();
327 
328  const CellsContainer * GetCells() const;
329 
334  void SetCellData(CellDataContainer *);
335 
336  CellDataContainer * GetCellData();
337 
338  const CellDataContainer * GetCellData() const;
339 
340 #if !defined( CABLE_CONFIGURATION )
341 
349  void SetBoundaryAssignments(int dimension,
351 
352 
353  BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension);
354 
355  const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
356  int dimension) const;
357 #endif
358 
364  void SetCell(CellIdentifier, CellAutoPointer &);
365  bool GetCell(CellIdentifier, CellAutoPointer &) const;
366 
369  void SetCellData(CellIdentifier, CellPixelType);
370  bool GetCellData(CellIdentifier, CellPixelType *) const;
372 
385  void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
386  CellFeatureIdentifier featureId,
387  CellIdentifier boundaryId);
388 
397  bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
398  CellFeatureIdentifier featureId,
399  CellIdentifier *boundaryId) const;
400 
401  bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
402  CellFeatureIdentifier featureId);
403 
405  CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
406  CellIdentifier) const;
407 
410  bool GetCellBoundaryFeature(int dimension, CellIdentifier,
412 
417  CellIdentifier GetCellBoundaryFeatureNeighbors(
418  int dimension, CellIdentifier, CellFeatureIdentifier,
419  std::set< CellIdentifier > *cellSet);
420 
425  CellIdentifier GetCellNeighbors(CellIdentifier cellId,
426  std::set< CellIdentifier > *cellSet);
427 
435  bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
437  CellAutoPointer &) const;
438 
441  void BuildCellLinks() const;
442 
446  virtual void Accept(CellMultiVisitorType *mv) const;
447 
452  itkSetMacro(CellsAllocationMethod, CellsAllocationMethodType);
453  itkGetConstReferenceMacro(CellsAllocationMethod, CellsAllocationMethodType);
454 protected:
455 
457  Mesh();
458  ~Mesh();
459  void PrintSelf(std::ostream & os, Indent indent) const;
461 
465  void ReleaseCellsMemory();
466 
470 
471 private:
472  Mesh(const Self &); //purposely not implemented
473  void operator=(const Self &); //purposely not implemented
474 
475  CellsAllocationMethodType m_CellsAllocationMethod;
476 }; // End Class: Mesh
477 } // end namespace itk
478 
479 #ifndef ITK_MANUAL_INSTANTIATION
480 #ifndef CABLE_CONFIGURATION
481 #include "itkMesh.hxx"
482 #endif
483 #endif
484 
485 #endif
486