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  itkOverrideGetNameOfClassMacro(ConvexShape);
69 
71  virtual bool
72  IsInside(const PointType & point) const;
73 
77  virtual bool
78  IsIntersectedByRay(const PointType & rayOrigin,
79  const VectorType & rayDirection,
80  double & nearDist,
81  double & farDist) const;
82 
84  virtual void
85  Rescale(const VectorType & r);
86 
88  virtual void
89  Translate(const VectorType & t);
90 
92  virtual void
93  Rotate(const RotationMatrixType & r);
94 
97  void
98  AddClipPlane(const VectorType & dir, const ScalarType & pos);
99  void
100  SetClipPlanes(const std::vector<VectorType> & dir, const std::vector<ScalarType> & pos);
102 
104  itkSetMacro(Density, ScalarType);
105  itkGetConstMacro(Density, ScalarType);
106  itkGetMacro(Density, ScalarType);
108 
110  itkGetConstReferenceMacro(PlaneDirections, std::vector<VectorType>);
111  itkGetConstReferenceMacro(PlanePositions, std::vector<ScalarType>);
113 
114 protected:
115  ConvexShape();
116  bool
117  ApplyClipPlanes(const PointType & rayOrigin,
118  const VectorType & rayDirection,
119  ScalarType & nearDist,
120  ScalarType & farDist) const;
121  bool
122  ApplyClipPlanes(const PointType & point) const;
124  InternalClone() const override;
125 
126 private:
127  ScalarType m_Density{ 0. };
128  std::vector<VectorType> m_PlaneDirections;
129  std::vector<ScalarType> m_PlanePositions;
130 };
131 
132 } // namespace rtk
133 #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.