RTK  2.0.1
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  * 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 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_ASSIGN(ConvexShape);
50 
52  using Self = ConvexShape;
56 
58  static constexpr unsigned int Dimension = 3;
59  using ScalarType = double;
63 
65  itkNewMacro ( Self );
66 
68  itkTypeMacro(ConvexShape, itk::DataObject);
69 
71  virtual bool IsInside(const PointType & point) const;
72 
76  virtual bool IsIntersectedByRay(const PointType & rayOrigin,
77  const VectorType & rayDirection,
78  double & nearDist,
79  double & farDist) const;
80 
82  virtual void Rescale(const VectorType &r);
83 
85  virtual void Translate(const VectorType &t);
86 
88  virtual void Rotate(const RotationMatrixType &r);
89 
92  void AddClipPlane(const VectorType & dir, const ScalarType & pos);
93  void SetClipPlanes(const std::vector<VectorType> & dir, const std::vector<ScalarType> & pos);
95 
97  itkSetMacro (Density, ScalarType);
98  itkGetConstMacro (Density, ScalarType);
99  itkGetMacro (Density, ScalarType);
101 
103  itkGetConstReferenceMacro(PlaneDirections, std::vector<VectorType>);
104  itkGetConstReferenceMacro(PlanePositions, std::vector<ScalarType>);
106 
107 protected:
108  ConvexShape();
109  bool ApplyClipPlanes(const PointType & rayOrigin,
110  const VectorType & rayDirection,
111  ScalarType & nearDist,
112  ScalarType & farDist) const;
113  bool ApplyClipPlanes(const PointType & point) const;
114  itk::LightObject::Pointer InternalClone() const override;
115 
116 private:
117  ScalarType m_Density{0.};
118  std::vector<VectorType> m_PlaneDirections;
119  std::vector<ScalarType> m_PlanePositions;
120 };
121 
122 }
123 #endif
std::vector< ScalarType > m_PlanePositions
std::vector< VectorType > m_PlaneDirections
class ITK_FORWARD_EXPORT DataObject
constexpr unsigned int Dimension
Base class for a 3D convex shape.
#define itkSetMacro(name, type)