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 TCoordRep = float,
69  typename TPointsContainer = VectorContainer<TPointIdentifier, Point<TCoordRep, 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 CoordRepType = TCoordRep;
93  using PointsContainer = TPointsContainer;
96 
99 
101  static constexpr unsigned int PointDimension = VPointDimension;
102 
104  using PointsContainerConstIterator = typename PointsContainer::ConstIterator;
105  using PointsContainerIterator = typename PointsContainer::Iterator;
106 
110  void
111  SetPoints(const PointsContainer *);
112 
113  const PointsContainer *
114  GetPoints() const;
115 
121  std::array<PointType, NumberOfCorners>
122  ComputeCorners() const;
123 
125  itkLegacyMacro(const PointsContainer * GetCorners();)
126 
128  bool
129  ComputeBoundingBox() const;
130 
136  itkGetConstReferenceMacro(Bounds, BoundsArrayType);
137 
140  PointType
141  GetCenter() const;
142 
145  PointType
146  GetMinimum() const;
147 
151  void
152  SetMinimum(const PointType &);
153 
156  PointType
157  GetMaximum() const;
158 
162  void
163  SetMaximum(const PointType &);
164 
169  void
170  ConsiderPoint(const PointType &);
171 
177  GetDiagonalLength2() const;
178 
180  bool
181  IsInside(const PointType &) const;
182 
185  GetMTime() const override;
186 
188  Pointer
189  DeepCopy() const;
190 
191 protected:
192  BoundingBox() = default;
193  ~BoundingBox() override = default;
194  void
195  PrintSelf(std::ostream & os, Indent indent) const override;
196 
197  using ConstIterator = typename PointsContainer::ConstIterator;
198 
199 private:
200  PointsContainerConstPointer m_PointsContainer{};
201 #if !defined(ITK_LEGACY_REMOVE)
202  PointsContainerPointer m_CornersContainer{ PointsContainer::New() };
203 #endif
204  mutable BoundsArrayType m_Bounds{};
205  mutable TimeStamp m_BoundsMTime{}; // The last time the bounds
206  // were computed.
207 };
208 } // end namespace itk
209 
210 #ifndef ITK_MANUAL_INSTANTIATION
211 # include "itkBoundingBox.hxx"
212 #endif
213 
214 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::BoundingBox::CoordRepType
TCoordRep CoordRepType
Definition: itkBoundingBox.h:92
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105
itkPoint.h
itk::NumericTraits::AccumulateType
double AccumulateType
Definition: itkNumericTraits.h:76
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::BoundingBox::AccumulateType
typename NumericTraits< CoordRepType >::AccumulateType AccumulateType
Definition: itkBoundingBox.h:175
itk::BoundingBox::PointsContainerConstIterator
typename PointsContainer::ConstIterator PointsContainerConstIterator
Definition: itkBoundingBox.h:104
itk::BoundingBox::PointsContainerPointer
typename PointsContainer::Pointer PointsContainerPointer
Definition: itkBoundingBox.h:94
itk::BoundingBox::PointsContainer
TPointsContainer PointsContainer
Definition: itkBoundingBox.h:93
itk::TimeStamp
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:60
itk::BoundingBox::PointsContainerConstPointer
typename PointsContainer::ConstPointer PointsContainerConstPointer
Definition: itkBoundingBox.h:95
itkIntTypes.h
itk::FixedArray< CoordRepType, VPointDimension *2 >
itkVectorContainer.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::BoundingBox::PointsContainerIterator
typename PointsContainer::Iterator PointsContainerIterator
Definition: itkBoundingBox.h:105
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::PointIdentifier
TPointIdentifier PointIdentifier
Definition: itkBoundingBox.h:91
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:90
itk::BoundingBox::ConstIterator
typename PointsContainer::ConstIterator ConstIterator
Definition: itkBoundingBox.h:197
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86