ITK  6.0.0
Insight Toolkit
itkBoundingBox.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 itkBoundingBox_h
29#define itkBoundingBox_h
30
31#include "itkPoint.h"
32#include "itkVectorContainer.h"
33#include "itkIntTypes.h"
34
35#include <array>
36
37namespace itk
38{
39
66template <typename TPointIdentifier = IdentifierType,
67 unsigned int VPointDimension = 3,
68 typename TCoordinate = float,
69 typename TPointsContainer = VectorContainer<TPointIdentifier, Point<TCoordinate, VPointDimension>>>
70class ITK_TEMPLATE_EXPORT BoundingBox : public Object
71{
72public:
73 ITK_DISALLOW_COPY_AND_MOVE(BoundingBox);
74
80
82 itkOverrideGetNameOfClassMacro(BoundingBox);
83
85 itkNewMacro(Self);
86
87 /* Number of corners of this bounding box. Equals `pow(2, VPointDimension)` */
88 static constexpr SizeValueType NumberOfCorners = SizeValueType{ 1 } << VPointDimension;
89
91 using PointIdentifier = TPointIdentifier;
92 using CoordinateType = TCoordinate;
93#ifndef ITK_FUTURE_LEGACY_REMOVE
94 using CoordRepType ITK_FUTURE_DEPRECATED(
95 "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
96#endif
97 using PointsContainer = TPointsContainer;
100
103
105 static constexpr unsigned int PointDimension = VPointDimension;
106
108 using PointsContainerConstIterator = typename PointsContainer::ConstIterator;
109 using PointsContainerIterator = typename PointsContainer::Iterator;
110
114 void
116
117 const PointsContainer *
118 GetPoints() const;
119
125 std::array<PointType, NumberOfCorners>
127
129 itkLegacyMacro(const PointsContainer * GetCorners();)
130
132 bool
133 ComputeBoundingBox() const;
134
140 itkGetConstReferenceMacro(Bounds, BoundsArrayType);
141
145 GetCenter() const;
146
150 GetMinimum() const;
151
155 void
157
161 GetMaximum() const;
162
166 void
168
173 void
175
182
184 bool
185 IsInside(const PointType &) const;
186
189 GetMTime() const override;
190
192 Pointer
193 DeepCopy() const;
194
195protected:
196 BoundingBox() = default;
197 ~BoundingBox() override = default;
198 void
199 PrintSelf(std::ostream & os, Indent indent) const override;
200
201 using ConstIterator = typename PointsContainer::ConstIterator;
202
203private:
204 PointsContainerConstPointer m_PointsContainer{};
205#if !defined(ITK_LEGACY_REMOVE)
206 PointsContainerPointer m_CornersContainer{ PointsContainer::New() };
207#endif
208 mutable BoundsArrayType m_Bounds{};
209 mutable TimeStamp m_BoundsMTime{}; // The last time the bounds
210 // were computed.
211};
212} // end namespace itk
213
214#ifndef ITK_MANUAL_INSTANTIATION
215# include "itkBoundingBox.hxx"
216#endif
217
218#endif
Represent and compute information about bounding boxes.
ModifiedTimeType GetMTime() const override
BoundingBox()=default
TPointsContainer PointsContainer
Pointer DeepCopy() const
itkLegacyMacro(const PointsContainer *GetCorners();) bool ComputeBoundingBox() const
void SetMaximum(const PointType &)
typename PointsContainer::Iterator PointsContainerIterator
void ConsiderPoint(const PointType &)
void SetPoints(const PointsContainer *)
AccumulateType GetDiagonalLength2() const
typename PointsContainer::Pointer PointsContainerPointer
void SetMinimum(const PointType &)
typename PointsContainer::ConstPointer PointsContainerConstPointer
typename NumericTraits< CoordinateType >::AccumulateType AccumulateType
bool IsInside(const PointType &) const
~BoundingBox() override=default
void PrintSelf(std::ostream &os, Indent indent) const override
TPointIdentifier PointIdentifier
TCoordinate CoordinateType
typename PointsContainer::ConstIterator PointsContainerConstIterator
std::array< PointType, NumberOfCorners > ComputeCorners() const
PointType GetMaximum() const
PointType GetMinimum() const
typename PointsContainer::ConstIterator ConstIterator
const PointsContainer * GetPoints() const
PointType GetCenter() const
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:54
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Base class for most ITK classes.
Definition: itkObject.h:62
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:61
SmartPointer< const Self > ConstPointer
static Pointer New()
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105
unsigned long SizeValueType
Definition: itkIntTypes.h:86