RTK  2.1.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  * http://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  itkTypeMacro(BoxShape, ConvexShape);
66 
68  bool
69  IsInside(const PointType & point) const override;
70 
74  bool
75  IsIntersectedByRay(const PointType & rayOrigin,
76  const VectorType & rayDirection,
77  double & nearDist,
78  double & farDist) const override;
79 
81  void
82  Rescale(const VectorType & r) override;
83 
85  void
86  Translate(const VectorType & t) override;
87 
89  void
90  Rotate(const RotationMatrixType & r) override;
91 
94  itkGetConstMacro(BoxMin, PointType);
95  itkSetMacro(BoxMin, PointType);
97 
100  itkGetConstMacro(BoxMax, PointType);
101  itkSetMacro(BoxMax, PointType);
103 
106  itkGetConstMacro(Direction, RotationMatrixType);
107  itkSetMacro(Direction, RotationMatrixType);
109 
111  InternalClone() const override;
112 
116  void
117  SetBoxFromImage(const ImageBaseType * img, bool bWithExternalHalfPixelBorder = true);
118 
119 private:
120  BoxShape();
121 
125 };
126 
127 } // end namespace rtk
128 
129 #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:123
constexpr unsigned int Dimension
#define itkSetMacro(name, type)
PointType m_BoxMin
Definition: rtkBoxShape.h:122
RotationMatrixType m_Direction
Definition: rtkBoxShape.h:124
Superclass::ScalarType ScalarType
Definition: rtkBoxShape.h:55
Superclass::RotationMatrixType RotationMatrixType
Definition: rtkBoxShape.h:58
Base class for a 3D convex shape.