RTK  2.6.0
Reconstruction Toolkit
rtkBoxShape.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK Consortium
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 #ifndef rtkBoxShape_h
20 #define rtkBoxShape_h
21 
22 #include "RTKExport.h"
23 #include "rtkMacro.h"
24 #include "rtkConvexShape.h"
25 
26 #include <itkImageBase.h>
27 
28 namespace rtk
29 {
30 
44 class RTK_EXPORT BoxShape : public ConvexShape
45 {
46 public:
48  using Self = BoxShape;
52 
54  static constexpr unsigned int Dimension = Superclass::Dimension;
57  using VectorType = Superclass::VectorType;
58  using RotationMatrixType = Superclass::RotationMatrixType;
60 
62  itkNewMacro(Self);
63 
65 #ifdef itkOverrideGetNameOfClassMacro
66  itkOverrideGetNameOfClassMacro(BoxShape);
67 #else
68  itkTypeMacro(BoxShape, ConvexShape);
69 #endif
70 
71 
73  bool
74  IsInside(const PointType & point) const override;
75 
79  bool
80  IsIntersectedByRay(const PointType & rayOrigin,
81  const VectorType & rayDirection,
82  double & nearDist,
83  double & farDist) const override;
84 
86  void
87  Rescale(const VectorType & r) override;
88 
90  void
91  Translate(const VectorType & t) override;
92 
94  void
95  Rotate(const RotationMatrixType & r) override;
96 
99  itkGetConstMacro(BoxMin, PointType);
100  itkSetMacro(BoxMin, PointType);
102 
105  itkGetConstMacro(BoxMax, PointType);
106  itkSetMacro(BoxMax, PointType);
108 
111  itkGetConstMacro(Direction, RotationMatrixType);
112  itkSetMacro(Direction, RotationMatrixType);
114 
116  InternalClone() const override;
117 
121  void
122  SetBoxFromImage(const ImageBaseType * img, bool bWithExternalHalfPixelBorder = true);
123 
124 private:
125  BoxShape();
126 
130 };
131 
132 } // end namespace rtk
133 
134 #endif
BoxShape defines a paralleliped. The box is defined by its two opposite corners, BoxMin and BoxMax...
Definition: rtkBoxShape.h:44
Superclass::VectorType VectorType
Definition: rtkBoxShape.h:57
PointType m_BoxMax
Definition: rtkBoxShape.h:128
constexpr unsigned int Dimension
#define itkSetMacro(name, type)
PointType m_BoxMin
Definition: rtkBoxShape.h:127
RotationMatrixType m_Direction
Definition: rtkBoxShape.h:129
Superclass::ScalarType ScalarType
Definition: rtkBoxShape.h:55
Superclass::RotationMatrixType RotationMatrixType
Definition: rtkBoxShape.h:58
Base class for a 3D convex shape.