VTK  9.6.20260615
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
27
28#ifndef vtkConvexHull_h
29#define vtkConvexHull_h
30
31#include "vtkFiltersCoreModule.h" // For export macro
33#include "vtkVector.h" // For vtkVector3D
34#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
35
36#include <vector> // For std::vector
37
38VTK_ABI_NAMESPACE_BEGIN
39
40class vtkDataArray;
41class vtkPolyData;
42
43//------------------------------------------------------------------------------
44class VTKFILTERSCORE_EXPORT VTK_MARSHALAUTO vtkConvexHull : public vtkPointSetAlgorithm
45{
46public:
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
107protected:
109 ~vtkConvexHull() override = default;
110
112 int FillOutputPortInformation(int port, vtkInformation* info) override;
113
114private:
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
130VTK_ABI_NAMESPACE_END
131#endif // vtkConvexHull_h
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool IsPointWithinConvexHull(const double point[3], double tol=1e-8) const
static void ComputeConvexHull(vtkDataArray *points, int dimension, std::vector< Plane > &planes)
Compute the convex hull of the points in points (a vtkDataArray with 3 components) for the given dime...
static void ComputeConvexHull(const vtkVector3d *points, int numPoints, int dimension, std::vector< Plane > &planes)
Compute the convex hull of numPoints points stored in points for the given dimension and write the ha...
static vtkConvexHull * New()
~vtkConvexHull() override=default
bool IsPointWithinConvexHull(double x, double y, double z, double tol=1e-8) const
Return true iff the point (x, y, z) lies inside (or on the boundary of) the hull computed by the most...
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
static bool IsPointInside(const vtkVector3d &p, const std::vector< Plane > &planes, double tol=1e-8)
Return true iff p lies inside (or on the boundary of) the given half-planes.
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:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
concrete dataset represents vertices, lines, polygons, and triangle strips
Half-plane representation: point P is inside the hull iff P·Normal ≤ D for every plane in the set.
#define vtkDataArray
int vtkIdType
Definition vtkType.h:363
#define VTK_MARSHALAUTO