ITK  5.1.0
Insight 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 "ITKMeshExport.h"
38 #include <vector>
39 #include <set>
40 
41 namespace itk
42 {
48 {
53 };
54 
121 template <typename TPixelType,
122  unsigned int VDimension = 3,
123  typename TMeshTraits = DefaultStaticMeshTraits<TPixelType, VDimension, VDimension>>
124 class ITK_TEMPLATE_EXPORT Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
125 {
126 public:
127  ITK_DISALLOW_COPY_AND_ASSIGN(Mesh);
128 
130  using Self = Mesh;
134 
136 
138  itkNewMacro(Self);
139 
141  itkTypeMacro(Mesh, PointSet);
142 
144  using MeshTraits = TMeshTraits;
145  using PixelType = typename MeshTraits::PixelType;
146  using CellPixelType = typename MeshTraits::CellPixelType;
147 
149  static constexpr unsigned int PointDimension = TMeshTraits::PointDimension;
150  static constexpr unsigned int MaxTopologicalDimension = TMeshTraits::MaxTopologicalDimension;
151 
154 #if !defined(ITK_LEGACY_REMOVE)
155  // We need to expose the enum values at the class level
156  // for backwards compatibility
165 #endif
166 
168  using CoordRepType = typename MeshTraits::CoordRepType;
169  using InterpolationWeightType = typename MeshTraits::InterpolationWeightType;
170  using PointIdentifier = typename MeshTraits::PointIdentifier;
171  using CellIdentifier = typename MeshTraits::CellIdentifier;
172  using CellFeatureIdentifier = typename MeshTraits::CellFeatureIdentifier;
173  using PointHashType = typename MeshTraits::PointHashType;
175  using PointsContainer = typename MeshTraits::PointsContainer;
176  using CellTraits = typename MeshTraits::CellTraits;
177  using CellsContainer = typename MeshTraits::CellsContainer;
178  using PointCellLinksContainer = typename MeshTraits::PointCellLinksContainer;
179  using CellLinksContainer = typename MeshTraits::CellLinksContainer;
180  using PointDataContainer = typename MeshTraits::PointDataContainer;
181  using CellDataContainer = typename MeshTraits::CellDataContainer;
182 
185 
187  using PointsContainerPointer = typename PointsContainer::Pointer;
188  using CellsContainerPointer = typename CellsContainer::Pointer;
189  using CellsContainerConstPointer = typename CellsContainer::ConstPointer;
190  using CellLinksContainerPointer = typename CellLinksContainer::Pointer;
191  using PointDataContainerPointer = typename PointDataContainer::Pointer;
192  using CellDataContainerPointer = typename CellDataContainer::Pointer;
193  using CellDataContainerConstPointer = typename CellDataContainer::ConstPointer;
195  using CellLinksContainerConstPointer = typename CellLinksContainer::ConstPointer;
196 
198  using PointsContainerConstIterator = typename PointsContainer::ConstIterator;
199  using PointsContainerIterator = typename PointsContainer::Iterator;
200  using CellsContainerConstIterator = typename CellsContainer::ConstIterator;
201  using CellsContainerIterator = typename CellsContainer::Iterator;
202  using CellLinksContainerIterator = typename CellLinksContainer::ConstIterator;
203  using PointDataContainerIterator = typename PointDataContainer::ConstIterator;
204  using CellDataContainerIterator = typename CellDataContainer::ConstIterator;
205  using PointCellLinksContainerIterator = typename PointCellLinksContainer::const_iterator;
206 
209 
213 
216 
228  {
229  public:
232 
235  BoundaryAssignmentIdentifier() = default;
237  : m_CellId(cellId)
238  , m_FeatureId(featureId)
239  {}
240 
243 
246 
249  bool
250  operator<(const Self & r) const
251  {
252  return ((m_CellId < r.m_CellId) || ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
253  }
254 
257  bool
258  operator==(const Self & r) const
259  {
260  return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
261  }
262  }; // End Class: Mesh::BoundaryAssignmentIdentifier
264 
274  using BoundaryAssignmentsContainerVector = std::vector<BoundaryAssignmentsContainerPointer>;
275 
276 protected:
280 
286 
291 
302 
303 public:
306  GetNumberOfCells() const;
307 
308  void
309  PassStructure(Self * inputMesh);
310 
311  void
312  Initialize() override;
313 
315  void
316  CopyInformation(const DataObject * data) override;
317 
318  void
319  Graft(const DataObject * data) override;
320 
323  const BoundingBoxType *
324  GetBoundingBox() const;
325 
330  void
331  SetCellLinks(CellLinksContainer *);
332 
334  GetCellLinks();
335 
336  const CellLinksContainer *
337  GetCellLinks() const;
338 
341  void
342  SetCells(CellsContainer *);
343 
345  GetCells();
346 
347  const CellsContainer *
348  GetCells() const;
349 
354  void
355  SetCellData(CellDataContainer *);
356 
358  GetCellData();
359 
360  const CellDataContainer *
361  GetCellData() const;
362 
366  void
367  DeleteUnusedCellData();
368 
369 #if !defined(ITK_WRAPPING_PARSER)
370 
378  void
379  SetBoundaryAssignments(int dimension, BoundaryAssignmentsContainer *);
380 
381 
383  GetBoundaryAssignments(int dimension);
384 
386  GetBoundaryAssignments(int dimension) const;
387 #endif
388 
394  void
395  SetCell(CellIdentifier, CellAutoPointer &);
396  bool
397  GetCell(CellIdentifier, CellAutoPointer &) const;
398 
401  void SetCellData(CellIdentifier, CellPixelType);
402  bool
403  GetCellData(CellIdentifier, CellPixelType *) const;
405 
418  void
419  SetBoundaryAssignment(int dimension,
420  CellIdentifier cellId,
421  CellFeatureIdentifier featureId,
422  CellIdentifier boundaryId);
423 
432  bool
433  GetBoundaryAssignment(int dimension,
434  CellIdentifier cellId,
435  CellFeatureIdentifier featureId,
436  CellIdentifier * boundaryId) const;
437 
438  bool
439  RemoveBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId);
440 
443  GetNumberOfCellBoundaryFeatures(int dimension, CellIdentifier) const;
444 
447  bool
448  GetCellBoundaryFeature(int dimension, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const;
449 
455  GetCellBoundaryFeatureNeighbors(int dimension,
458  std::set<CellIdentifier> * cellSet);
459 
465  GetCellNeighbors(CellIdentifier cellId, std::set<CellIdentifier> * cellSet);
466 
474  bool
475  GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const;
476 
479  void
480  BuildCellLinks() const;
481 
485  virtual void
486  Accept(CellMultiVisitorType * mv) const;
487 
492  itkSetMacro(CellsAllocationMethod, CellsAllocationMethodType);
493  itkGetConstReferenceMacro(CellsAllocationMethod, CellsAllocationMethodType);
495 
496 protected:
498  Mesh();
499  ~Mesh() override;
500  void
501  PrintSelf(std::ostream & os, Indent indent) const override;
503 
507  void
508  ReleaseCellsMemory();
509 
513 
514 private:
516 }; // End Class: Mesh
517 
519 extern ITKMesh_EXPORT std::ostream &
520  operator<<(std::ostream & out, const MeshClassCellsAllocationMethodEnum value);
521 } // end namespace itk
522 
523 #ifndef ITK_MANUAL_INSTANTIATION
524 # ifndef ITK_WRAPPING_PARSER
525 # include "itkMesh.hxx"
526 # endif
527 #endif
528 
529 #endif
itk::Mesh< TPixel, VDimension, TTraits >::PointCellLinksContainer
typename MeshTraits::PointCellLinksContainer PointCellLinksContainer
Definition: itkMesh.h:178
itk::Mesh< TPixel, VDimension, TTraits >::CellTraits
typename MeshTraits::CellTraits CellTraits
Definition: itkMesh.h:176
itk::Mesh< TPixel, VDimension, TTraits >::CellMultiVisitorType
typename CellType::MultiVisitor CellMultiVisitorType
Definition: itkMesh.h:215
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::Mesh::BoundaryAssignmentIdentifier::operator==
bool operator==(const Self &r) const
Definition: itkMesh.h:258
itk::Mesh::BoundaryAssignmentIdentifier
Definition: itkMesh.h:227
itk::Mesh< TPixel, VDimension, TTraits >::CellDataContainerIterator
typename CellDataContainer::ConstIterator CellDataContainerIterator
Definition: itkMesh.h:204
itk::PointSet< TPixel, VDimension, TTraits >::PointsContainerIterator
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkPointSet.h:121
itk::PointSet< TPixel, VDimension, TTraits >::PointDataContainerPointer
typename PointDataContainer::Pointer PointDataContainerPointer
Definition: itkPointSet.h:116
itk::operator<
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:546
itk::PointSet
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:82
itk::Mesh< TPixel, VDimension, TTraits >::CellLinksContainer
typename MeshTraits::CellLinksContainer CellLinksContainer
Definition: itkMesh.h:179
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:211
itk::MeshClassCellsAllocationMethodEnum::CellsAllocatedDynamicallyCellByCell
itk::MeshClassCellsAllocationMethodEnum
MeshClassCellsAllocationMethodEnum
Definition: itkMesh.h:47
itk::Mesh::m_CellsAllocationMethod
CellsAllocationMethodType m_CellsAllocationMethod
Definition: itkMesh.h:515
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::Mesh< TPixel, VDimension, TTraits >::BoundingBoxPointer
typename BoundingBoxType::Pointer BoundingBoxPointer
Definition: itkMesh.h:194
itk::Mesh::m_CellsContainer
CellsContainerPointer m_CellsContainer
Definition: itkMesh.h:279
itk::Mesh< TPixel, VDimension, TTraits >::CellLinksContainerPointer
typename CellLinksContainer::Pointer CellLinksContainerPointer
Definition: itkMesh.h:190
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainerPointer
typename CellsContainer::Pointer CellsContainerPointer
Definition: itkMesh.h:188
itk::Mesh::m_CellDataContainer
CellDataContainerPointer m_CellDataContainer
Definition: itkMesh.h:285
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::CellInterface::MultiVisitor
A visitor that can visit different cell types in a mesh. CellInterfaceVisitor instances can be regist...
Definition: itkCellInterface.h:169
itk::Mesh< TPixel, VDimension, TTraits >::CellDataContainerConstPointer
typename CellDataContainer::ConstPointer CellDataContainerConstPointer
Definition: itkMesh.h:193
itk::MapContainer
A wrapper of the STL "map" container.
Definition: itkMapContainer.h:45
itk::Mesh< TPixel, VDimension, TTraits >::CellAutoPointer
typename CellType::CellAutoPointer CellAutoPointer
Definition: itkMesh.h:212
itk::Mesh< TPixel, VDimension, TTraits >::CellLinksContainerConstPointer
typename CellLinksContainer::ConstPointer CellLinksContainerConstPointer
Definition: itkMesh.h:195
MeshClassCellsAllocationMethodEnum
itk::Mesh< TPixel, VDimension, TTraits >::CellIdentifier
typename MeshTraits::CellIdentifier CellIdentifier
Definition: itkMesh.h:171
itk::MeshClassCellsAllocationMethodEnum::CellsAllocatedAsStaticArray
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainer
typename MeshTraits::CellsContainer CellsContainer
Definition: itkMesh.h:177
itk::PointSet< TPixel, VDimension, TTraits >::PointIdentifier
typename MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:105
itk::MeshClassCellsAllocationMethodEnum::CellsAllocatedAsADynamicArray
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::PointSet< TPixel, VDimension, TTraits >::MeshTraits
TTraits MeshTraits
Definition: itkPointSet.h:100
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainerConstPointer
typename CellsContainer::ConstPointer CellsContainerConstPointer
Definition: itkMesh.h:189
itk::CellInterface::CellAutoPointer
SelfAutoPointer CellAutoPointer
Definition: itkCellInterface.h:131
itk::PointSet< TPixel, VDimension, TTraits >::PixelType
typename MeshTraits::PixelType PixelType
Definition: itkPointSet.h:101
itk::PointSet< TPixel, VDimension, TTraits >::PointsContainerPointer
typename PointsContainer::Pointer PointsContainerPointer
Definition: itkPointSet.h:114
itk::PointSet< TPixel, VDimension, TTraits >::CoordRepType
typename MeshTraits::CoordRepType CoordRepType
Definition: itkPointSet.h:104
itk::Mesh::BoundaryAssignmentIdentifier::m_FeatureId
CellFeatureIdentifier m_FeatureId
Definition: itkMesh.h:245
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainerConstIterator
typename CellsContainer::ConstIterator CellsContainerConstIterator
Definition: itkMesh.h:200
itk::MeshClassCellsAllocationMethodEnum::CellsAllocationMethodUndefined
itk::Mesh< TPixel, VDimension, TTraits >::InterpolationWeightType
typename MeshTraits::InterpolationWeightType InterpolationWeightType
Definition: itkMesh.h:169
itk::PointSet< TPixel, VDimension, TTraits >::PointDataContainerIterator
typename PointDataContainer::ConstIterator PointDataContainerIterator
Definition: itkPointSet.h:122
itk::PointSet< TPixel, VDimension, TTraits >::PointsContainer
typename MeshTraits::PointsContainer PointsContainer
Definition: itkPointSet.h:107
itk::CellInterface
An abstract interface for cells.
Definition: itkCellInterface.h:94
itk::PointSet< TPixel, VDimension, TTraits >::RegionType
long RegionType
Definition: itkPointSet.h:125
itk::Mesh< TPixel, VDimension, TTraits >::CellFeatureIdentifier
typename MeshTraits::CellFeatureIdentifier CellFeatureIdentifier
Definition: itkMesh.h:172
itk::Mesh< TPixel, VDimension, TTraits >::CellLinksContainerIterator
typename CellLinksContainer::ConstIterator CellLinksContainerIterator
Definition: itkMesh.h:202
itk::Mesh::m_BoundingBox
BoundingBoxPointer m_BoundingBox
Definition: itkMesh.h:512
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::Mesh
Implements the N-dimensional mesh structure.
Definition: itkMesh.h:124
itk::Mesh< TPixel, VDimension, TTraits >::CellPixelType
typename MeshTraits::CellPixelType CellPixelType
Definition: itkMesh.h:146
itk::PointSet< TPixel, VDimension, TTraits >::PointDataContainer
typename MeshTraits::PointDataContainer PointDataContainer
Definition: itkPointSet.h:108
itk::Mesh< TPixel, VDimension, TTraits >::PointCellLinksContainerIterator
typename PointCellLinksContainer::const_iterator PointCellLinksContainerIterator
Definition: itkMesh.h:205
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:60
itkCellInterface.h
itk::Mesh< TPixel, VDimension, TTraits >::BoundaryAssignmentsContainerVector
std::vector< BoundaryAssignmentsContainerPointer > BoundaryAssignmentsContainerVector
Definition: itkMesh.h:274
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainerIterator
typename CellsContainer::Iterator CellsContainerIterator
Definition: itkMesh.h:201
itk::PointSet< TPixel, VDimension, TTraits >::PointType
typename MeshTraits::PointType PointType
Definition: itkPointSet.h:106
itkPointSet.h
itk::BoundingBox
Represent and compute information about bounding boxes.
Definition: itkBoundingBox.h:69
itk::Mesh::m_BoundaryAssignmentsContainers
BoundaryAssignmentsContainerVector m_BoundaryAssignmentsContainers
Definition: itkMesh.h:301
itkMapContainer.h
itk::Mesh< TPixel, VDimension, TTraits >::CellFeatureCount
CellFeatureIdentifier CellFeatureCount
Definition: itkMesh.h:208
itk::Mesh::BoundaryAssignmentIdentifier::m_CellId
CellIdentifier m_CellId
Definition: itkMesh.h:242
itk::PointSet< TPixel, VDimension, TTraits >::PointsContainerConstIterator
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkPointSet.h:120
itk::Mesh< TPixel, VDimension, TTraits >::CellDataContainerPointer
typename CellDataContainer::Pointer CellDataContainerPointer
Definition: itkMesh.h:192
itk::Mesh< TPixel, VDimension, TTraits >::BoundaryAssignmentsContainerPointer
typename BoundaryAssignmentsContainer::Pointer BoundaryAssignmentsContainerPointer
Definition: itkMesh.h:273
itk::Mesh::m_CellLinksContainer
CellLinksContainerPointer m_CellLinksContainer
Definition: itkMesh.h:290
itk::Mesh::BoundaryAssignmentIdentifier::BoundaryAssignmentIdentifier
BoundaryAssignmentIdentifier(CellIdentifier cellId, CellFeatureIdentifier featureId)
Definition: itkMesh.h:236
itk::Mesh< TPixel, VDimension, TTraits >::PointHashType
typename MeshTraits::PointHashType PointHashType
Definition: itkMesh.h:173
itk::Mesh< TPixel, VDimension, TTraits >::CellDataContainer
typename MeshTraits::CellDataContainer CellDataContainer
Definition: itkMesh.h:181
itkBoundingBox.h
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:288