RTK  2.6.0
Reconstruction Toolkit
rtkConvexShape.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 rtkConvexShape_h
20 #define rtkConvexShape_h
21 
22 #include <itkMatrix.h>
23 #include <itkPoint.h>
24 #include <itkDataObject.h>
25 #include <itkObjectFactory.h>
26 
27 #include "RTKExport.h"
28 #include "rtkMacro.h"
29 
30 namespace rtk
31 {
46 class RTK_EXPORT ConvexShape : public itk::DataObject
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_MOVE(ConvexShape);
50 
52  using Self = ConvexShape;
56 
58  static constexpr unsigned int Dimension = 3;
59  using ScalarType = double;
63 
65  itkNewMacro(Self);
66 
68 #ifdef itkOverrideGetNameOfClassMacro
69  itkOverrideGetNameOfClassMacro(ConvexShape);
70 #else
71  itkTypeMacro(ConvexShape, itk::DataObject);
72 #endif
73 
74 
76  virtual bool
77  IsInside(const PointType & point) const;
78 
82  virtual bool
83  IsIntersectedByRay(const PointType & rayOrigin,
84  const VectorType & rayDirection,
85  double & nearDist,
86  double & farDist) const;
87 
89  virtual void
90  Rescale(const VectorType & r);
91 
93  virtual void
94  Translate(const VectorType & t);
95 
97  virtual void
98  Rotate(const RotationMatrixType & r);
99 
102  void
103  AddClipPlane(const VectorType & dir, const ScalarType & pos);
104  void
105  SetClipPlanes(const std::vector<VectorType> & dir, const std::vector<ScalarType> & pos);
107 
109  itkSetMacro(Density, ScalarType);
110  itkGetConstMacro(Density, ScalarType);
111  itkGetMacro(Density, ScalarType);
113 
115  itkGetConstReferenceMacro(PlaneDirections, std::vector<VectorType>);
116  itkGetConstReferenceMacro(PlanePositions, std::vector<ScalarType>);
118 
119 protected:
120  ConvexShape();
121  bool
122  ApplyClipPlanes(const PointType & rayOrigin,
123  const VectorType & rayDirection,
124  ScalarType & nearDist,
125  ScalarType & farDist) const;
126  bool
127  ApplyClipPlanes(const PointType & point) const;
129  InternalClone() const override;
130 
131 private:
132  ScalarType m_Density{ 0. };
133  std::vector<VectorType> m_PlaneDirections;
134  std::vector<ScalarType> m_PlanePositions;
135 };
136 
137 } // namespace rtk
138 #endif
std::vector< ScalarType > m_PlanePositions
std::vector< VectorType > m_PlaneDirections
class ITK_FORWARD_EXPORT DataObject
constexpr unsigned int Dimension
#define itkSetMacro(name, type)
Base class for a 3D convex shape.