ITK  6.0.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 * https://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#include "itkVectorContainer.h"
42#include "itkVertexCell.h"
43#include "itkLineCell.h"
44#include "itkPolyLineCell.h"
45#include "itkTriangleCell.h"
47#include "itkPolygonCell.h"
48#include "itkTetrahedronCell.h"
49#include "itkHexahedronCell.h"
52
53
54namespace itk
55{
56
123template <typename TPixelType,
124 unsigned int VDimension = 3,
125 typename TMeshTraits = DefaultStaticMeshTraits<TPixelType, VDimension, VDimension>>
126class ITK_TEMPLATE_EXPORT Mesh : public PointSet<TPixelType, VDimension, TMeshTraits>
127{
128public:
129 ITK_DISALLOW_COPY_AND_MOVE(Mesh);
130
132 using Self = Mesh;
136
137 using typename Superclass::RegionType;
138
140 itkNewMacro(Self);
141
143 itkOverrideGetNameOfClassMacro(Mesh);
144
146 using MeshTraits = TMeshTraits;
147 using PixelType = typename MeshTraits::PixelType;
148 using CellPixelType = typename MeshTraits::CellPixelType;
150
152 static constexpr unsigned int PointDimension = TMeshTraits::PointDimension;
153 static constexpr unsigned int MaxTopologicalDimension = TMeshTraits::MaxTopologicalDimension;
154
155#if !defined(ITK_LEGACY_REMOVE)
156 using CellsAllocationMethodType = MeshClassCellsAllocationMethodEnum;
158 // We need to expose the enum values at the class level
159 // for backwards compatibility
160 static constexpr CellsAllocationMethodType CellsAllocationMethodUndefined =
161 MeshClassCellsAllocationMethodEnum::CellsAllocationMethodUndefined;
162 static constexpr CellsAllocationMethodType CellsAllocatedAsStaticArray =
164 static constexpr CellsAllocationMethodType CellsAllocatedAsADynamicArray =
166 static constexpr CellsAllocationMethodType CellsAllocatedDynamicallyCellByCell =
168#endif
169
171 using CoordinateType = typename MeshTraits::CoordinateType;
172#ifndef ITK_FUTURE_LEGACY_REMOVE
173 using CoordRepType ITK_FUTURE_DEPRECATED(
174 "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
175#endif
176 using InterpolationWeightType = typename MeshTraits::InterpolationWeightType;
177 using PointIdentifier = typename MeshTraits::PointIdentifier;
178 using CellIdentifier = typename MeshTraits::CellIdentifier;
179 using CellFeatureIdentifier = typename MeshTraits::CellFeatureIdentifier;
180 using PointHashType = typename MeshTraits::PointHashType;
182 using PointsContainer = typename MeshTraits::PointsContainer;
183 using CellTraits = typename MeshTraits::CellTraits;
184 using CellsContainer = typename MeshTraits::CellsContainer;
185 using PointCellLinksContainer = typename MeshTraits::PointCellLinksContainer;
186 using CellLinksContainer = typename MeshTraits::CellLinksContainer;
187 using PointDataContainer = typename MeshTraits::PointDataContainer;
188 using CellDataContainer = typename MeshTraits::CellDataContainer;
189
193
196
207
209 using PointsContainerConstIterator = typename PointsContainer::ConstIterator;
210 using PointsContainerIterator = typename PointsContainer::Iterator;
211 using CellsContainerConstIterator = typename CellsContainer::ConstIterator;
212 using CellsContainerIterator = typename CellsContainer::Iterator;
213 using CellLinksContainerIterator = typename CellLinksContainer::ConstIterator;
214 using PointDataContainerIterator = typename PointDataContainer::ConstIterator;
215 using CellDataContainerIterator = typename CellDataContainer::ConstIterator;
216 using PointCellLinksContainerIterator = typename PointCellLinksContainer::const_iterator;
217
220
234
237
249 {
250 public:
253
258 : m_CellId(cellId)
259 , m_FeatureId(featureId)
260 {}
261
264
267
270 bool
271 operator<(const Self & r) const
272 {
273 return ((m_CellId < r.m_CellId) || ((m_CellId == r.m_CellId) && (m_FeatureId < r.m_FeatureId)));
274 }
275
278 bool
279 operator==(const Self & r) const
280 {
281 return ((m_CellId == r.m_CellId) && (m_FeatureId == r.m_FeatureId));
282 }
283 }; // End Class: Mesh::BoundaryAssignmentIdentifier
295 using BoundaryAssignmentsContainerVector = std::vector<BoundaryAssignmentsContainerPointer>;
296
297protected:
300 CellsContainerPointer m_CellsContainer{};
301
307 CellDataContainerPointer m_CellDataContainer{};
308
312 mutable CellLinksContainerPointer m_CellLinksContainer{};
313
323 BoundaryAssignmentsContainerVector m_BoundaryAssignmentsContainers{};
324
325public:
327 CellIdentifier
329
333 void
334 PassStructure(Self * inputMesh);
335
339 void
340 Initialize() override;
341
343 void
344 CopyInformation(const DataObject * data) override;
345
346 void
347 Graft(const DataObject * data) override;
348
351 const BoundingBoxType *
353
358 void
360
364
366 const CellLinksContainer *
368
371 void
373
379 virtual void
381
386 virtual void
388
392 virtual CellsVectorContainer *
394
398
400 const CellsContainer *
401 GetCells() const;
402
407 void
409
413
415 const CellDataContainer *
416 GetCellData() const;
417
421 void
423
424#if !defined(ITK_WRAPPING_PARSER)
433 void
435
439
442 GetBoundaryAssignments(int dimension) const;
443#endif
444
450 void
452
459 bool
461
467
474 bool
476
489 void
491 CellIdentifier cellId,
492 CellFeatureIdentifier featureId,
493 CellIdentifier boundaryId);
494
503 bool
505 CellIdentifier cellId,
506 CellFeatureIdentifier featureId,
507 CellIdentifier * boundaryId) const;
508
512 bool
514
520
529 bool
531
540 std::set<CellIdentifier> * cellSet);
541
547 GetCellNeighbors(CellIdentifier cellId, std::set<CellIdentifier> * cellSet);
548
556 bool
558
561 void
563
569 virtual void
571
576 itkSetMacro(CellsAllocationMethod, MeshClassCellsAllocationMethodEnum);
577 itkGetConstReferenceMacro(CellsAllocationMethod, MeshClassCellsAllocationMethodEnum);
580protected:
583 ~Mesh() override;
584 void
585 PrintSelf(std::ostream & os, Indent indent) const override;
592 void
594
597 BoundingBoxPointer m_BoundingBox{};
598
599private:
600 MeshClassCellsAllocationMethodEnum m_CellsAllocationMethod{};
601
603 void
604 CreateCell(int cellType, CellAutoPointer &);
605}; // End Class: Mesh
606
608extern ITKMesh_EXPORT std::ostream &
609 operator<<(std::ostream & out, const MeshEnums::MeshClassCellsAllocationMethod value);
610} // end namespace itk
611
612#ifndef ITK_MANUAL_INSTANTIATION
613# ifndef ITK_WRAPPING_PARSER
614# include "itkMesh.hxx"
615# endif
616#endif
617
618#endif
Represent and compute information about bounding boxes.
A visitor that can visit different cell types in a mesh. CellInterfaceVisitor instances can be regist...
An abstract interface for cells.
SelfAutoPointer CellAutoPointer
Base class for all data objects in ITK.
Represents a hexahedron (cuboid) for a Mesh.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Represents a line segment for a Mesh.
Definition: itkLineCell.h:41
A wrapper of the STL "map" container.
BoundaryAssignmentIdentifier(CellIdentifier cellId, CellFeatureIdentifier featureId)
Definition: itkMesh.h:257
bool operator==(const Self &r) const
Definition: itkMesh.h:279
CellFeatureIdentifier m_FeatureId
Definition: itkMesh.h:266
Implements the N-dimensional mesh structure.
Definition: itkMesh.h:127
typename CellsContainer::ConstPointer CellsContainerConstPointer
Definition: itkMesh.h:200
CellDataContainer * GetCellData()
typename MeshTraits::CellDataContainer CellDataContainer
Definition: itkMesh.h:188
bool GetBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellIdentifier *boundaryId) const
typename PointsContainer::Pointer PointsContainerPointer
Definition: itkMesh.h:198
typename CellLinksContainer::Pointer CellLinksContainerPointer
Definition: itkMesh.h:201
typename MeshTraits::CellFeatureIdentifier CellFeatureIdentifier
Definition: itkMesh.h:179
typename CellDataContainer::ConstIterator CellDataContainerIterator
Definition: itkMesh.h:215
void PrintSelf(std::ostream &os, Indent indent) const override
typename MeshTraits::PointCellLinksContainer PointCellLinksContainer
Definition: itkMesh.h:185
CellsContainer * GetCells()
void ReleaseCellsMemory()
CellLinksContainer * GetCellLinks()
void SetBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId, CellIdentifier boundaryId)
virtual void SetCellsArray(CellsVectorContainer *)
BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension)
CellFeatureIdentifier CellFeatureCount
Definition: itkMesh.h:219
typename BoundingBoxType::Pointer BoundingBoxPointer
Definition: itkMesh.h:205
bool GetCellData(CellIdentifier, CellPixelType *) const
virtual void SetCellsArray(CellsVectorContainer *, int cellType)
void SetCellData(CellIdentifier, CellPixelType)
void SetCellLinks(CellLinksContainer *)
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkMesh.h:210
typename MeshTraits::PointHashType PointHashType
Definition: itkMesh.h:180
typename itk::VectorContainer< IdentifierType > CellsVectorContainer
Definition: itkMesh.h:191
typename CellDataContainer::ConstPointer CellDataContainerConstPointer
Definition: itkMesh.h:204
typename MeshTraits::PixelType PixelType
Definition: itkMesh.h:147
typename MeshTraits::PointIdentifier PointIdentifier
Definition: itkMesh.h:177
void BuildCellLinks() const
const BoundingBoxType * GetBoundingBox() const
typename CellsContainer::Pointer CellsContainerPointer
Definition: itkMesh.h:199
CellIdentifier GetNumberOfCells() const
typename CellDataContainer::Pointer CellDataContainerPointer
Definition: itkMesh.h:203
typename CellLinksContainer::ConstIterator CellLinksContainerIterator
Definition: itkMesh.h:213
typename CellsVectorContainer::Pointer CellsVectorContainerPointer
Definition: itkMesh.h:192
typename PointCellLinksContainer::const_iterator PointCellLinksContainerIterator
Definition: itkMesh.h:216
typename MeshTraits::CellIdentifier CellIdentifier
Definition: itkMesh.h:178
CellIdentifier GetCellNeighbors(CellIdentifier cellId, std::set< CellIdentifier > *cellSet)
void PassStructure(Self *inputMesh)
typename PointDataContainer::Pointer PointDataContainerPointer
Definition: itkMesh.h:202
typename MeshTraits::CellPixelType CellPixelType
Definition: itkMesh.h:148
CellIdentifier GetCellBoundaryFeatureNeighbors(int dimension, CellIdentifier, CellFeatureIdentifier, std::set< CellIdentifier > *cellSet)
TMeshTraits MeshTraits
Definition: itkMesh.h:146
bool GetCell(CellIdentifier, CellAutoPointer &) const
const BoundaryAssignmentsContainerPointer GetBoundaryAssignments(int dimension) const
typename CellsContainer::ConstIterator CellsContainerConstIterator
Definition: itkMesh.h:211
const CellDataContainer * GetCellData() const
const CellLinksContainer * GetCellLinks() const
typename MeshTraits::CellsContainer CellsContainer
Definition: itkMesh.h:184
void Initialize() override
void SetCells(CellsContainer *)
void CreateCell(int cellType, CellAutoPointer &)
virtual CellsVectorContainer * GetCellsArray()
bool RemoveBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId)
void SetBoundaryAssignments(int dimension, BoundaryAssignmentsContainer *)
typename CellType::CellAutoPointer CellAutoPointer
Definition: itkMesh.h:233
typename MeshTraits::CoordinateType CoordinateType
Definition: itkMesh.h:171
typename CellType::MultiVisitor CellMultiVisitorType
Definition: itkMesh.h:236
void Graft(const DataObject *data) override
void SetCellData(CellDataContainer *)
virtual void Accept(CellMultiVisitorType *mv) const
bool GetAssignedCellBoundaryIfOneExists(int dimension, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const
CellsVectorContainerPointer cellOutputVectorContainer
Definition: itkMesh.h:302
typename MeshTraits::PointsContainer PointsContainer
Definition: itkMesh.h:182
typename MeshTraits::CellLinksContainer CellLinksContainer
Definition: itkMesh.h:186
typename MeshTraits::InterpolationWeightType InterpolationWeightType
Definition: itkMesh.h:176
void DeleteUnusedCellData()
typename PointDataContainer::ConstIterator PointDataContainerIterator
Definition: itkMesh.h:214
typename CellsContainer::Iterator CellsContainerIterator
Definition: itkMesh.h:212
std::vector< BoundaryAssignmentsContainerPointer > BoundaryAssignmentsContainerVector
Definition: itkMesh.h:295
typename CellLinksContainer::ConstPointer CellLinksContainerConstPointer
Definition: itkMesh.h:206
typename BoundaryAssignmentsContainer::Pointer BoundaryAssignmentsContainerPointer
Definition: itkMesh.h:294
void CopyInformation(const DataObject *data) override
typename MeshTraits::CellTraits CellTraits
Definition: itkMesh.h:183
const CellsContainer * GetCells() const
bool GetCellBoundaryFeature(int dimension, CellIdentifier, CellFeatureIdentifier, CellAutoPointer &) const
~Mesh() override
void SetCell(CellIdentifier, CellAutoPointer &)
typename MeshTraits::PointDataContainer PointDataContainer
Definition: itkMesh.h:187
typename MeshTraits::PointType PointType
Definition: itkMesh.h:181
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkMesh.h:209
CellFeatureCount GetNumberOfCellBoundaryFeatures(int dimension, CellIdentifier) const
Base class for most ITK classes.
Definition: itkObject.h:62
A superclass of the N-dimensional mesh structure; supports point (geometric coordinate and attribute)...
Definition: itkPointSet.h:82
Represents a series of connected line segments for a Mesh.
Represents a polygon in a Mesh.
Represents a second order line segment for a Mesh.
Represents a second order triangular patch for a Mesh.
Represents a quadrilateral for a Mesh.
TetrahedronCell represents a tetrahedron for a Mesh.
Represents a single vertex for a Mesh.
Definition: itkVertexCell.h:38
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
bool operator<(const Index< VDimension > &one, const Index< VDimension > &two)
Definition: itkIndex.h:566