ITK  5.4.0
Insight Toolkit
itkPointBasedSpatialObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 #ifndef itkPointBasedSpatialObject_h
19 #define itkPointBasedSpatialObject_h
20 
21 #include "itkSpatialObject.h"
22 #include "itkSpatialObjectPoint.h"
23 
24 namespace itk
25 {
36 template <unsigned int TDimension = 3, class TSpatialObjectPointType = SpatialObjectPoint<TDimension>>
37 class ITK_TEMPLATE_EXPORT PointBasedSpatialObject : public SpatialObject<TDimension>
38 {
39 public:
40  ITK_DISALLOW_COPY_AND_MOVE(PointBasedSpatialObject);
41 
46 
47  using ScalarType = double;
48 
49  using SpatialObjectPointType = TSpatialObjectPointType;
50  using SpatialObjectPointListType = std::vector<SpatialObjectPointType>;
51 
52  using typename Superclass::PointType;
53  using typename Superclass::TransformType;
54  using typename Superclass::VectorType;
55  using typename Superclass::CovariantVectorType;
56  using typename Superclass::BoundingBoxType;
58  itkNewMacro(Self);
59 
61  itkOverrideGetNameOfClassMacro(PointBasedSpatialObject);
62 
65  void
66  Clear() override;
67 
70  virtual void
71  AddPoint(const SpatialObjectPointType & newPoint);
72 
74  virtual void
75  RemovePoint(IdentifierType id);
76 
79  virtual void
80  SetPoints(const SpatialObjectPointListType & newPoints);
81 
85  {
86  return m_Points;
87  }
88 
90  virtual const SpatialObjectPointListType &
91  GetPoints() const
92  {
93  return m_Points;
94  }
95 
97  virtual const SpatialObjectPointType *
99  {
100  return &(m_Points[id]);
101  }
102 
103  virtual SpatialObjectPointType *
105  {
106  return &(m_Points[id]);
107  }
108 
110  virtual SizeValueType
112  {
113  return static_cast<SizeValueType>(m_Points.size());
114  }
115 
117  TSpatialObjectPointType
118  ClosestPointInWorldSpace(const PointType & point) const;
119 
121  TSpatialObjectPointType
122  ClosestPointInObjectSpace(const PointType & point) const;
123 
128  bool
129  IsInsideInObjectSpace(const PointType & point) const override;
130 
131  /* Avoid hiding the overload that supports depth and name arguments */
132  using Superclass::IsInsideInObjectSpace;
133 
134 protected:
136  void
137  ComputeMyBoundingBox() override;
138 
140  ~PointBasedSpatialObject() override = default;
141 
143 
145  void
146  PrintSelf(std::ostream & os, Indent indent) const override;
147 
148  typename LightObject::Pointer
149  InternalClone() const override;
150 };
151 } // end namespace itk
152 
153 #ifndef ITK_MANUAL_INSTANTIATION
154 # include "itkPointBasedSpatialObject.hxx"
155 #endif
156 
157 #endif // itkPointBasedSpatialObject_h
itk::DTITubeSpatialObjectPoint
Point used for a tube definition.
Definition: itkDTITubeSpatialObjectPoint.h:61
itk::PointBasedSpatialObject
This class serves as the base class for point-based spatial objects.
Definition: itkPointBasedSpatialObject.h:37
itk::PointBasedSpatialObject::GetPoint
virtual const SpatialObjectPointType * GetPoint(IdentifierType id) const
Definition: itkPointBasedSpatialObject.h:98
itk::PointBasedSpatialObject< TDimension, DTITubeSpatialObjectPoint< TDimension > >::SpatialObjectPointListType
std::vector< SpatialObjectPointType > SpatialObjectPointListType
Definition: itkPointBasedSpatialObject.h:50
itk::PointBasedSpatialObject< TDimension, DTITubeSpatialObjectPoint< TDimension > >::ScalarType
double ScalarType
Definition: itkPointBasedSpatialObject.h:47
itkSpatialObject.h
itk::GTest::TypedefsAndConstructors::Dimension2::VectorType
ImageBaseType::SpacingType VectorType
Definition: itkGTestTypedefsAndConstructors.h:53
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::SpatialObject
Implementation of the composite pattern.
Definition: itkSpatialObject.h:58
itk::PointBasedSpatialObject::GetPoints
virtual SpatialObjectPointListType & GetPoints()
Definition: itkPointBasedSpatialObject.h:84
itk::PointBasedSpatialObject::GetNumberOfPoints
virtual SizeValueType GetNumberOfPoints() const
Definition: itkPointBasedSpatialObject.h:111
itk::PointBasedSpatialObject::GetPoints
virtual const SpatialObjectPointListType & GetPoints() const
Definition: itkPointBasedSpatialObject.h:91
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itk::PointBasedSpatialObject::GetPoint
virtual SpatialObjectPointType * GetPoint(IdentifierType id)
Definition: itkPointBasedSpatialObject.h:104
itkSpatialObjectPoint.h
itk::IdentifierType
SizeValueType IdentifierType
Definition: itkIntTypes.h:87
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293