1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkPointSource
* @brief create a random cloud of points
*
* vtkPointSource is a source object that creates a user-specified number of
* points within a specified radius about a specified center point. By
* default the location of the points is random within the sphere. It is also
* possible to generate random points only on the surface of the sphere; or a
* exponential distribution weighted towards the center point. The output
* PolyData has the specified number of points and a single cell - a
* vtkPolyVertex cell referencing all of the points.
*
* @note
* If Lambda set to zero, a uniform distribution is used. Negative lambda
* values are allowed, but the distribution function becomes inverted.
*
* @note
* If you desire to create complex point clouds (e.g., stellar distributions)
* then use multiple point sources and then append them together using the
* an append filter (e.g., vtkAppendPolyData).
*
* @sa
* vtkAppendPolyData
*/
#ifndef vtkPointSource_h
#define vtkPointSource_h
#include "vtkFiltersSourcesModule.h" // For export macro
#include "vtkPolyDataAlgorithm.h"
#define VTK_POINT_SHELL 0
#define VTK_POINT_UNIFORM 1
#define VTK_POINT_EXPONENTIAL 2
VTK_ABI_NAMESPACE_BEGIN
class vtkRandomSequence;
class VTKFILTERSSOURCES_EXPORT vtkPointSource : public vtkPolyDataAlgorithm
{
public:
///@{
/**
* Standard methods for instantiation, type information, and printing.
*/
static vtkPointSource* New();
vtkTypeMacro(vtkPointSource, vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
///@}
///@{
/**
* Set the number of points to generate.
*/
vtkSetClampMacro(NumberOfPoints, vtkIdType, 1, VTK_ID_MAX);
vtkGetMacro(NumberOfPoints, vtkIdType);
///@}
///@{
/**
* Set the center of the point cloud.
*/
vtkSetVector3Macro(Center, double);
vtkGetVectorMacro(Center, double, 3);
///@}
///@{
/**
* Set the radius of the point cloud. If you are
* generating a Gaussian distribution, then this is
* the standard deviation for each of x, y, and z.
*/
vtkSetClampMacro(Radius, double, 0.0, VTK_DOUBLE_MAX);
vtkGetMacro(Radius, double);
///@}
///@{
/**
* Specify the point distribution to use. The default is a uniform
* distribution. The shell distribution produces random points on the
* surface of the sphere Radius=constant, no points in the interior. The
* exponential distribution creates more points towards the center point
* weighted by the exponential function.
*/
vtkSetClampMacro(Distribution, int, VTK_POINT_SHELL, VTK_POINT_EXPONENTIAL);
void SetDistributionToShell() { this->SetDistribution(VTK_POINT_SHELL); }
void SetDistributionToUniform() { this->SetDistribution(VTK_POINT_UNIFORM); }
void SetDistributionToExponential() { this->SetDistribution(VTK_POINT_EXPONENTIAL); }
vtkGetMacro(Distribution, int);
///@}
///@{
/**
* If the distribution is set to exponential, then Lambda is used to
* scale the exponential distribution defined by
* f(x) = Lambda*exp(-Lambda*radius) where the radius is the distance
* from the Center of the point source. By default, the value of Lambda
* is Lambda=1.0.
*/
vtkSetMacro(Lambda, double);
vtkGetMacro(Lambda, double);
///@}
///@{
/**
* Set/get the desired precision for the output points.
* vtkAlgorithm::SINGLE_PRECISION - Output single-precision floating point.
* vtkAlgorithm::DOUBLE_PRECISION - Output double-precision floating point.
*/
vtkSetMacro(OutputPointsPrecision, int);
vtkGetMacro(OutputPointsPrecision, int);
///@}
///@{
/**
* Set/Get a random sequence generator.
* By default, the generator in vtkMath is used to maintain backwards
* compatibility.
*/
virtual void SetRandomSequence(vtkRandomSequence* randomSequence);
vtkGetObjectMacro(RandomSequence, vtkRandomSequence);
///@}
protected:
vtkPointSource(vtkIdType numPts = 10);
~vtkPointSource() override;
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
double Random();
vtkIdType NumberOfPoints;
double Center[3];
double Radius;
int Distribution;
double Lambda;
int OutputPointsPrecision;
vtkRandomSequence* RandomSequence;
private:
vtkPointSource(const vtkPointSource&) = delete;
void operator=(const vtkPointSource&) = delete;
};
VTK_ABI_NAMESPACE_END
#endif
|