ITK  5.2.0
Insight Toolkit
itkMesh.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 "itkCommonEnums.h"
38 #include "ITKMeshExport.h"
39 #include <vector>
40 #include <set>
41 
42 namespace itk
43 {
44 
111 template <typename TPixelType,
112  unsigned int VDimension = 3,
113  typename TMeshTraits = DefaultStaticMeshTraits<TPixelType, VDimension, VDimension>>
114 class ITK_TEMPLATE_EXPORT Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
115 {
116 public:
117  ITK_DISALLOW_COPY_AND_MOVE(Mesh);
118 
120  using Self = Mesh;
124 
126 
128  itkNewMacro(Self);
129 
131  itkTypeMacro(Mesh, PointSet);
132 
134  using MeshTraits = TMeshTraits;
135  using PixelType = typename MeshTraits::PixelType;
136  using CellPixelType = typename MeshTraits::CellPixelType;
138 
140  static constexpr unsigned int PointDimension = TMeshTraits::PointDimension;
141  static constexpr unsigned int MaxTopologicalDimension = TMeshTraits::MaxTopologicalDimension;
142 
143 #if !defined(ITK_LEGACY_REMOVE)
144  using CellsAllocationMethodType = MeshClassCellsAllocationMethodEnum;
146  // We need to expose the enum values at the class level
147  // for backwards compatibility
148  static constexpr CellsAllocationMethodType CellsAllocationMethodUndefined =
149  MeshClassCellsAllocationMethodEnum::CellsAllocationMethodUndefined;
150  static constexpr CellsAllocationMethodType CellsAllocatedAsStaticArray =
152  static constexpr CellsAllocationMethodType CellsAllocatedAsADynamicArray =
154  static constexpr CellsAllocationMethodType CellsAllocatedDynamicallyCellByCell =
156 #endif
157 
159  using CoordRepType = typename MeshTraits::CoordRepType;
160  using InterpolationWeightType = typename MeshTraits::InterpolationWeightType;
161  using PointIdentifier = typename MeshTraits::PointIdentifier;
162  using CellIdentifier = typename MeshTraits::CellIdentifier;
163  using CellFeatureIdentifier = typename MeshTraits::CellFeatureIdentifier;
164  using PointHashType = typename MeshTraits::PointHashType;
166  using PointsContainer = typename MeshTraits::PointsContainer;
167  using CellTraits = typename MeshTraits::CellTraits;
168  using CellsContainer = typename MeshTraits::CellsContainer;
169  using PointCellLinksContainer = typename MeshTraits::PointCellLinksContainer;
170  using CellLinksContainer = typename MeshTraits::CellLinksContainer;
171  using PointDataContainer = typename MeshTraits::PointDataContainer;
172  using CellDataContainer = typename MeshTraits::CellDataContainer;
173 
176 
178  using PointsContainerPointer = typename PointsContainer::Pointer;
179  using CellsContainerPointer = typename CellsContainer::Pointer;
180  using CellsContainerConstPointer = typename CellsContainer::ConstPointer;
181  using CellLinksContainerPointer = typename CellLinksContainer::Pointer;
182  using PointDataContainerPointer = typename PointDataContainer::Pointer;
183  using CellDataContainerPointer = typename CellDataContainer::Pointer;
184  using CellDataContainerConstPointer = typename CellDataContainer::ConstPointer;
186  using CellLinksContainerConstPointer = typename CellLinksContainer::ConstPointer;
187 
189  using PointsContainerConstIterator = typename PointsContainer::ConstIterator;
190  using PointsContainerIterator = typename PointsContainer::Iterator;
191  using CellsContainerConstIterator = typename CellsContainer::ConstIterator;
192  using CellsContainerIterator = typename CellsContainer::Iterator;
193  using CellLinksContainerIterator = typename CellLinksContainer::ConstIterator;
194  using PointDataContainerIterator = typename PointDataContainer::ConstIterator;
195  using CellDataContainerIterator = typename CellDataContainer::ConstIterator;
196  using PointCellLinksContainerIterator = typename PointCellLinksContainer::const_iterator;
197 
200 
204 
207 
219  {
220  public:
223 
226  BoundaryAssignmentIdentifier() = default;
228  : m_CellId(cellId)
229  , m_FeatureId(featureId)
230  {}
231 
234 
237 
240  bool
241  operator<(const Self & r) const
242  {
243  return ((m_CellId < r.m_CellId) || ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
244  }
245 
248  bool
249  operator==(const Self & r) const
250  {
251  return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
252  }
253  }; // End Class: Mesh::BoundaryAssignmentIdentifier
255 
265  using BoundaryAssignmentsContainerVector = std::vector<BoundaryAssignmentsContainerPointer>;
266 
267 protected:
271 
277 
282 
293 
294 public:
297  GetNumberOfCells() const;
298 
299  void
300  PassStructure(Self * inputMesh);
301 
302  void
303  Initialize() override;
304 
306  void
307  CopyInformation(const DataObject * data) override;
308 
309  void
310  Graft(const DataObject * data) override;
311 
314  const BoundingBoxType *
315  GetBoundingBox() const;
316 
321  void
322  SetCellLinks(CellLinksContainer *);
323 
325  GetCellLinks();
326 
327  const CellLinksContainer *
328  GetCellLinks() const;
329 
332  void
333  SetCells(CellsContainer *);
334 
336  GetCells();
337 
338  const CellsContainer *
339  GetCells() const;
340 
345  void
346  SetCellData(CellDataContainer *);
347 
349  GetCellData();
350 
351  const CellDataContainer *
352  GetCellData() const;
353 
357  void
358  DeleteUnusedCellData();
359 
360 #if !defined(ITK_WRAPPING_PARSER)
361 
369  void
370  SetBoundaryAssignments(int dimension, BoundaryAssignmentsContainer *);
371 
372 
374  GetBoundaryAssignments(int dimension);
375 
377  GetBoundaryAssignments(int dimension) const;
378 #endif
379 
385  void
386  SetCell(CellIdentifier, CellAutoPointer &);
387  bool
388  GetCell(CellIdentifier, CellAutoPointer &) const;
389 
392  void SetCellData(CellIdentifier, CellPixelType);
393  bool
394  GetCellData(CellIdentifier, CellPixelType *) const;
396 
409  void
410  SetBoundaryAssignment(int dimension,
411  CellIdentifier cellId,
412  CellFeatureIdentifier featureId,
413  CellIdentifier boundaryId);
414 
423  bool
424  GetBoundaryAssignment(int dimension,
425  CellIdentifier cellId,
426  CellFeatureIdentifier featureId,
427  CellIdentifier * boundaryId) const;
428 
429  bool
430  RemoveBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId);
431 
434  GetNumberOfCellBoundaryFeatures(int dimension, CellIdentifier) const;
435 
438  bool
439  GetCellBoundaryFeature(int dimension, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const;
440 
446  GetCellBoundaryFeatureNeighbors(int dimension,
449  std::set<CellIdentifier> * cellSet);
450 
456  GetCellNeighbors(CellIdentifier cellId, std::set<CellIdentifier> * cellSet);
457 
465  bool
466  GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const;
467 
470  void
471  BuildCellLinks() const;
472 
476  virtual void
477  Accept(CellMultiVisitorType * mv) const;
478 
483  itkSetMacro(CellsAllocationMethod, MeshClassCellsAllocationMethodEnum);
484  itkGetConstReferenceMacro(CellsAllocationMethod, MeshClassCellsAllocationMethodEnum);
486 
487 protected:
489  Mesh();
490  ~Mesh() override;
491  void
492  PrintSelf(std::ostream & os, Indent indent) const override;
494 
498  void
499  ReleaseCellsMemory();
500 
504 
505 private:
507 }; // End Class: Mesh
508 
510 extern ITKMesh_EXPORT std::ostream &
511  operator<<(std::ostream & out, const MeshEnums::MeshClassCellsAllocationMethod value);
512 } // end namespace itk
513 
514 #ifndef ITK_MANUAL_INSTANTIATION
515 # ifndef ITK_WRAPPING_PARSER
516 # include "itkMesh.hxx"
517 # endif
518 #endif
519 
520 #endif
itk::Mesh< TPixel, VDimension, TTraits >::PointCellLinksContainer
typename MeshTraits::PointCellLinksContainer PointCellLinksContainer
Definition: itkMesh.h:169
itk::Mesh< TPixel, VDimension, TTraits >::CellTraits
typename MeshTraits::CellTraits CellTraits
Definition: itkMesh.h:167
itk::Mesh< TPixel, VDimension, TTraits >::CellMultiVisitorType
typename CellType::MultiVisitor CellMultiVisitorType
Definition: itkMesh.h:206
itk::Mesh::BoundaryAssignmentIdentifier::operator==
bool operator==(const Self &r) const
Definition: itkMesh.h:249
itk::Mesh::BoundaryAssignmentIdentifier
Definition: itkMesh.h:218
itk::Mesh< TPixel, VDimension, TTraits >::CellDataContainerIterator
typename CellDataContainer::ConstIterator CellDataContainerIterator
Definition: itkMesh.h:195
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:170
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:218
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:185
itk::Mesh::m_CellsContainer
CellsContainerPointer m_CellsContainer
Definition: itkMesh.h:270
itk::Mesh< TPixel, VDimension, TTraits >::CellLinksContainerPointer
typename CellLinksContainer::Pointer CellLinksContainerPointer
Definition: itkMesh.h:181
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainerPointer
typename CellsContainer::Pointer CellsContainerPointer
Definition: itkMesh.h:179
itk::Mesh::m_CellDataContainer
CellDataContainerPointer m_CellDataContainer
Definition: itkMesh.h:276
itk::MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedDynamicallyCellByCell
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:155
itk::Mesh< TPixel, VDimension, TTraits >::CellDataContainerConstPointer
typename CellDataContainer::ConstPointer CellDataContainerConstPointer
Definition: itkMesh.h:184
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:203
itk::Mesh< TPixel, VDimension, TTraits >::CellLinksContainerConstPointer
typename CellLinksContainer::ConstPointer CellLinksContainerConstPointer
Definition: itkMesh.h:186
itk::Mesh< TPixel, VDimension, TTraits >::CellIdentifier
typename MeshTraits::CellIdentifier CellIdentifier
Definition: itkMesh.h:162
itk::MeshEnums::MeshClassCellsAllocationMethod
MeshClassCellsAllocationMethod
Definition: itkCommonEnums.h:197
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainer
typename MeshTraits::CellsContainer CellsContainer
Definition: itkMesh.h:168
itk::PointSet< TPixel, VDimension, TTraits >::PointIdentifier
typename MeshTraits::PointIdentifier PointIdentifier
Definition: itkPointSet.h:105
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:180
itk::Mesh::m_CellsAllocationMethod
MeshClassCellsAllocationMethodEnum m_CellsAllocationMethod
Definition: itkMesh.h:506
itk::CellInterface::CellAutoPointer
SelfAutoPointer CellAutoPointer
Definition: itkCellInterface.h:133
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:236
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainerConstIterator
typename CellsContainer::ConstIterator CellsContainerConstIterator
Definition: itkMesh.h:191
itk::Mesh< TPixel, VDimension, TTraits >::InterpolationWeightType
typename MeshTraits::InterpolationWeightType InterpolationWeightType
Definition: itkMesh.h:160
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:96
itk::MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedAsStaticArray
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:163
itk::Mesh< TPixel, VDimension, TTraits >::CellLinksContainerIterator
typename CellLinksContainer::ConstIterator CellLinksContainerIterator
Definition: itkMesh.h:193
itk::Mesh::m_BoundingBox
BoundingBoxPointer m_BoundingBox
Definition: itkMesh.h:503
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkCommonEnums.h
itk::Mesh
Implements the N-dimensional mesh structure.
Definition: itkMesh.h:114
itk::Mesh< TPixel, VDimension, TTraits >::CellPixelType
typename MeshTraits::CellPixelType CellPixelType
Definition: itkMesh.h:136
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:196
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itkCellInterface.h
itk::Mesh< TPixel, VDimension, TTraits >::BoundaryAssignmentsContainerVector
std::vector< BoundaryAssignmentsContainerPointer > BoundaryAssignmentsContainerVector
Definition: itkMesh.h:265
itk::Mesh< TPixel, VDimension, TTraits >::CellsContainerIterator
typename CellsContainer::Iterator CellsContainerIterator
Definition: itkMesh.h:192
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:70
itk::Mesh::m_BoundaryAssignmentsContainers
BoundaryAssignmentsContainerVector m_BoundaryAssignmentsContainers
Definition: itkMesh.h:292
itkMapContainer.h
itk::Mesh< TPixel, VDimension, TTraits >::CellFeatureCount
CellFeatureIdentifier CellFeatureCount
Definition: itkMesh.h:199
itk::Mesh::BoundaryAssignmentIdentifier::m_CellId
CellIdentifier m_CellId
Definition: itkMesh.h:233
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:183
itk::Mesh< TPixel, VDimension, TTraits >::BoundaryAssignmentsContainerPointer
typename BoundaryAssignmentsContainer::Pointer BoundaryAssignmentsContainerPointer
Definition: itkMesh.h:264
itk::Mesh::m_CellLinksContainer
CellLinksContainerPointer m_CellLinksContainer
Definition: itkMesh.h:281
itk::Mesh::BoundaryAssignmentIdentifier::BoundaryAssignmentIdentifier
BoundaryAssignmentIdentifier(CellIdentifier cellId, CellFeatureIdentifier featureId)
Definition: itkMesh.h:227
itk::Mesh< TPixel, VDimension, TTraits >::PointHashType
typename MeshTraits::PointHashType PointHashType
Definition: itkMesh.h:164
itk::Mesh< TPixel, VDimension, TTraits >::CellDataContainer
typename MeshTraits::CellDataContainer CellDataContainer
Definition: itkMesh.h:172
itkBoundingBox.h
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itk::MeshEnums::MeshClassCellsAllocationMethod::CellsAllocatedAsADynamicArray