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 
37 namespace itk
38 {
39 
66 template <typename TPointIdentifier = IdentifierType,
67  unsigned int VPointDimension = 3,
68  typename TCoordinate = float,
69  typename TPointsContainer = VectorContainer<TPointIdentifier, Point<TCoordinate, VPointDimension>>>
70 class ITK_TEMPLATE_EXPORT BoundingBox : public Object
71 {
72 public:
73  ITK_DISALLOW_COPY_AND_MOVE(BoundingBox);
74 
76  using Self = BoundingBox;
77  using Superclass = Object;
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
115  SetPoints(const PointsContainer *);
116 
117  const PointsContainer *
118  GetPoints() const;
119 
125  std::array<PointType, NumberOfCorners>
126  ComputeCorners() const;
127 
129  itkLegacyMacro(const PointsContainer * GetCorners();)
130 
132  bool
133  ComputeBoundingBox() const;
134 
140  itkGetConstReferenceMacro(Bounds, BoundsArrayType);
141 
144  PointType
145  GetCenter() const;
146 
149  PointType
150  GetMinimum() const;
151 
155  void
156  SetMinimum(const PointType &);
157 
160  PointType
161  GetMaximum() const;
162 
166  void
167  SetMaximum(const PointType &);
168 
173  void
174  ConsiderPoint(const PointType &);
175 
181  GetDiagonalLength2() const;
182 
184  bool
185  IsInside(const PointType &) const;
186 
189  GetMTime() const override;
190 
192  Pointer
193  DeepCopy() const;
194 
195 protected:
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 
203 private:
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
itk::BoundingBox::PointsContainerPointer
typename PointsContainer::Pointer PointsContainerPointer
Definition: itkBoundingBox.h:98
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105
itkPoint.h
itk::NumericTraits::AccumulateType
double AccumulateType
Definition: itkNumericTraits.h:76
itk::BoundingBox::PointsContainer
TPointsContainer PointsContainer
Definition: itkBoundingBox.h:97
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::BoundingBox::PointIdentifier
TPointIdentifier PointIdentifier
Definition: itkBoundingBox.h:91
itk::BoundingBox::ConstIterator
typename PointsContainer::ConstIterator ConstIterator
Definition: itkBoundingBox.h:201
itk::BoundingBox::PointsContainerConstPointer
typename PointsContainer::ConstPointer PointsContainerConstPointer
Definition: itkBoundingBox.h:99
itk::BoundingBox::PointsContainerConstIterator
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkBoundingBox.h:108
itk::BoundingBox::CoordinateType
TCoordinate CoordinateType
Definition: itkBoundingBox.h:92
itk::BoundingBox::AccumulateType
typename NumericTraits< CoordinateType >::AccumulateType AccumulateType
Definition: itkBoundingBox.h:179
itk::TimeStamp
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
itkIntTypes.h
itk::FixedArray< CoordinateType, VPointDimension *2 >
itkVectorContainer.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
New
static Pointer New()
itk::BoundingBox
Represent and compute information about bounding boxes.
Definition: itkBoundingBox.h:70
itk::BoundingBox::PointsContainerIterator
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkBoundingBox.h:109
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86