ITK  4.3.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 {
42 
103 template<
104  typename TPixelType,
105  unsigned int VDimension = 3,
106  typename TMeshTraits = DefaultStaticMeshTraits< TPixelType, VDimension, VDimension >
107  >
108 class ITK_EXPORT Mesh:public PointSet< TPixelType, VDimension, TMeshTraits >
109 {
110 public:
112  typedef Mesh Self;
116 
117  typedef typename Superclass::RegionType RegionType;
118 
120  itkNewMacro(Self);
121 
123  itkTypeMacro(Mesh, PointSet);
124 
126  typedef TMeshTraits MeshTraits;
127  typedef typename MeshTraits::PixelType PixelType;
128  typedef typename MeshTraits::CellPixelType CellPixelType;
129 
131  itkStaticConstMacro(PointDimension, unsigned int,
132  TMeshTraits::PointDimension);
133  itkStaticConstMacro(MaxTopologicalDimension, unsigned int,
134  TMeshTraits::MaxTopologicalDimension);
136 
142  CellsAllocatedDynamicallyCellByCell } CellsAllocationMethodType;
143 
145  typedef typename MeshTraits::CoordRepType CoordRepType;
146  typedef typename MeshTraits::InterpolationWeightType InterpolationWeightType;
147  typedef typename MeshTraits::PointIdentifier PointIdentifier;
148  typedef typename MeshTraits::CellIdentifier CellIdentifier;
149  typedef typename MeshTraits::CellFeatureIdentifier CellFeatureIdentifier;
150  typedef typename MeshTraits::PointHashType PointHashType;
151  typedef typename MeshTraits::PointType PointType;
152  typedef typename MeshTraits::PointsContainer PointsContainer;
153  typedef typename MeshTraits::CellTraits CellTraits;
154  typedef typename MeshTraits::CellsContainer CellsContainer;
155  typedef typename MeshTraits::PointCellLinksContainer PointCellLinksContainer;
156  typedef typename MeshTraits::CellLinksContainer CellLinksContainer;
157  typedef typename MeshTraits::PointDataContainer PointDataContainer;
158  typedef typename MeshTraits::CellDataContainer CellDataContainer;
159 
161  typedef BoundingBox< PointIdentifier, itkGetStaticConstMacro(PointDimension),
163 
165  typedef typename PointsContainer::Pointer PointsContainerPointer;
166  typedef typename CellsContainer::Pointer CellsContainerPointer;
167  typedef typename CellsContainer::ConstPointer CellsContainerConstPointer;
168  typedef typename CellLinksContainer::Pointer CellLinksContainerPointer;
169  typedef typename PointDataContainer::Pointer PointDataContainerPointer;
170  typedef typename CellDataContainer::Pointer CellDataContainerPointer;
171  typedef typename CellDataContainer::ConstPointer CellDataContainerConstPointer;
173  typedef typename CellLinksContainer::ConstPointer CellLinksContainerConstPointer;
174 
176  typedef typename PointsContainer::ConstIterator PointsContainerConstIterator;
177  typedef typename PointsContainer::Iterator PointsContainerIterator;
178  typedef typename CellsContainer::ConstIterator CellsContainerConstIterator;
179  typedef typename CellsContainer::Iterator CellsContainerIterator;
180  typedef typename CellLinksContainer::ConstIterator CellLinksContainerIterator;
181  typedef typename PointDataContainer::ConstIterator PointDataContainerIterator;
182  typedef typename CellDataContainer::ConstIterator CellDataContainerIterator;
183  typedef typename PointCellLinksContainer::const_iterator PointCellLinksContainerIterator;
184 
187 
191 
194 
206  {
207 public:
210 
215  CellFeatureIdentifier featureId):
216  m_CellId(cellId), m_FeatureId(featureId) {}
218 
221 
224 
227  bool operator<(const Self & r) const
228  {
229  return ( ( m_CellId < r.m_CellId )
230  || ( ( m_CellId == r.m_CellId ) && ( m_FeatureId < r.m_FeatureId ) ) );
231  }
232 
235  bool operator==(const Self & r) const
236  {
237  return ( ( m_CellId == r.m_CellId ) && ( m_FeatureId == r.m_FeatureId ) );
238  }
239  }; // End Class: Mesh::BoundaryAssignmentIdentifier
241 
253  typedef std::vector< BoundaryAssignmentsContainerPointer >
255 
256 protected:
257 
261 
267 
272 
283 
284 public:
286  CellIdentifier GetNumberOfCells() const;
287 
288  void PassStructure(Self *inputMesh);
289 
290  virtual void Initialize();
291 
293  virtual void CopyInformation(const DataObject *data);
294 
295  virtual void Graft(const DataObject *data);
296 
299  const BoundingBoxType * GetBoundingBox(void) const;
300 
305  void SetCellLinks(CellLinksContainer *);
306 
307  CellLinksContainer * GetCellLinks();
308 
309  const CellLinksContainer * GetCellLinks() const;
310 
313  void SetCells(CellsContainer *);
314 
315  CellsContainer * GetCells();
316 
317  const CellsContainer * GetCells() const;
318 
323  void SetCellData(CellDataContainer *);
324 
325  CellDataContainer * GetCellData();
326 
327  const CellDataContainer * GetCellData() const;
328 
329 #if !defined( CABLE_CONFIGURATION )
330 
338  void SetBoundaryAssignments(int dimension,
340 
341 
342  BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension);
343 
344  const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(
345  int dimension) const;
346 #endif
347 
353  void SetCell(CellIdentifier, CellAutoPointer &);
354  bool GetCell(CellIdentifier, CellAutoPointer &) const;
355 
358  void SetCellData(CellIdentifier, CellPixelType);
359  bool GetCellData(CellIdentifier, CellPixelType *) const;
361 
374  void SetBoundaryAssignment(int dimension, CellIdentifier cellId,
375  CellFeatureIdentifier featureId,
376  CellIdentifier boundaryId);
377 
386  bool GetBoundaryAssignment(int dimension, CellIdentifier cellId,
387  CellFeatureIdentifier featureId,
388  CellIdentifier *boundaryId) const;
389 
390  bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId,
391  CellFeatureIdentifier featureId);
392 
394  CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension,
395  CellIdentifier) const;
396 
399  bool GetCellBoundaryFeature(int dimension, CellIdentifier,
401 
406  CellIdentifier GetCellBoundaryFeatureNeighbors(
407  int dimension, CellIdentifier, CellFeatureIdentifier,
408  std::set< CellIdentifier > *cellSet);
409 
414  CellIdentifier GetCellNeighbors(CellIdentifier cellId,
415  std::set< CellIdentifier > *cellSet);
416 
424  bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier,
426  CellAutoPointer &) const;
427 
430  void BuildCellLinks() const;
431 
435  virtual void Accept(CellMultiVisitorType *mv) const;
436 
441  itkSetMacro(CellsAllocationMethod, CellsAllocationMethodType);
442  itkGetConstReferenceMacro(CellsAllocationMethod, CellsAllocationMethodType);
444 
445 protected:
447  Mesh();
448  ~Mesh();
449  void PrintSelf(std::ostream & os, Indent indent) const;
451 
455  void ReleaseCellsMemory();
456 
460 
461 private:
462  Mesh(const Self &); //purposely not implemented
463  void operator=(const Self &); //purposely not implemented
464 
465  CellsAllocationMethodType m_CellsAllocationMethod;
466 }; // End Class: Mesh
467 } // end namespace itk
468 
469 #ifndef ITK_MANUAL_INSTANTIATION
470 #ifndef CABLE_CONFIGURATION
471 #include "itkMesh.hxx"
472 #endif
473 #endif
474 
475 #endif
476