VTK  9.7.1
vtkConvexHull.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
28 #ifndef vtkConvexHull_h
29 #define vtkConvexHull_h
30 
31 #include "vtkFiltersCoreModule.h" // For export macro
32 #include "vtkPointSetAlgorithm.h"
33 #include "vtkVector.h" // For vtkVector3D
34 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
35 
36 #include <vector> // For std::vector
37 
38 VTK_ABI_NAMESPACE_BEGIN
39 
40 class vtkDataArray;
41 class vtkPolyData;
42 
43 //------------------------------------------------------------------------------
44 class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkConvexHull : public vtkPointSetAlgorithm
45 {
46 public:
47  static vtkConvexHull* New();
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
55  struct Plane
56  {
58  double D{ 0.0 };
59  };
60 
63  vtkSetClampMacro(Dimension, int, 1, 3);
64  vtkGetMacro(Dimension, int);
66 
68 
73  vtkSetMacro(GeneratePolyData, bool);
74  vtkGetMacro(GeneratePolyData, bool);
75  vtkBooleanMacro(GeneratePolyData, bool);
77 
82  bool IsPointWithinConvexHull(double x, double y, double z, double tol = 1e-8) const;
83  bool IsPointWithinConvexHull(const double point[3], double tol = 1e-8) const;
84 
89  static bool IsPointInside(
90  const vtkVector3d& p, const std::vector<Plane>& planes, double tol = 1e-8);
91 
97  static void ComputeConvexHull(vtkDataArray* points, int dimension, std::vector<Plane>& planes);
98 
104  static void ComputeConvexHull(
105  const vtkVector3d* points, int numPoints, int dimension, std::vector<Plane>& planes);
106 
107 protected:
108  vtkConvexHull();
109  ~vtkConvexHull() override = default;
110 
113 
114 private:
115  vtkConvexHull(const vtkConvexHull&) = delete;
116  void operator=(const vtkConvexHull&) = delete;
117 
118  int Dimension{ 3 };
119  bool GeneratePolyData{ true };
120  std::vector<Plane> HullPlanes;
121 
122  static void Compute1D(
123  const vtkVector3d* pts, vtkIdType n, std::vector<Plane>& planes, vtkPolyData* geom);
124  static void Compute2D(
125  const vtkVector3d* pts, vtkIdType n, std::vector<Plane>& planes, vtkPolyData* geom);
126  static void Compute3D(
127  const vtkVector3d* pts, vtkIdType n, std::vector<Plane>& planes, vtkPolyData* geom);
128 };
129 
130 VTK_ABI_NAMESPACE_END
131 #endif // vtkConvexHull_h
Convex hull and point-in-hull testing for 1-D, 2-D, and 3-D point sets.
Definition: vtkConvexHull.h:44
Half-plane representation: point P is inside the hull iff P·Normal ≤ D for every plane in the set...
Definition: vtkConvexHull.h:55
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
Store vtkAlgorithm input/output information.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods for instantiation, obtaining type information, and printing instances of the class...
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
Superclass for algorithms that process vtkPointSet input.
static vtkPointSetAlgorithm * New()
Standard methods for instantiation, obtaining type information, and printing instances of the class...
Store zero or more vtkInformation instances.
#define VTK_MARSHALAUTO