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 149 150 151 152 153 154 155
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* @class vtkLineSource
* @brief create a line defined by two end points
*
* vtkLineSource is a source object that creates a polyline defined by
* two endpoints or a collection of connected line segments. To define the line
* by end points, use `SetPoint1` and `SetPoint2` methods. To define a broken
* line comprising of multiple line segments, use `SetPoints` to provide the
* corner points that for the line.
*
* Intermediate points within line segment (when specifying end points alone) or
* each of the individual line segments (when specifying broken line) can be
* specified in two ways. First, when `UseRegularRefinement` is true (default),
* the `Resolution` is used to determine how many intermediate points to add
* using regular refinement. Thus, if `Resolution` is set to 1, a mid point will
* be added for each of the line segments resulting in a line with 3 points: the
* two end points and the mid point. Second, when `UseRegularRefinement` is
* false, refinement ratios for points per segment are specified using
* `SetRefinementRatio` and `SetNumberOfRefinementRatios`. To generate same
* points as `Resolution` set to 1, the refinement ratios will be `[0, 0.5,
* 1.0]`. To add the end points of the line segment `0.0` and `1.0` must be
* included in the collection of refinement ratios.
*
* @section ChangesVTK9 Changes in VTK 9.0
*
* Prior to VTK 9.0, when broken line was being generated, the texture
* coordinates for each of the individual breaks in the line ranged from [0.0,
* 1.0]. This has been changed to generate texture coordinates in the range
* [0.0, 1.0] over the entire output line irrespective of whether the line was
* generated by simply specifying the end points or multiple line segments.
*
* @par Thanks:
* This class was extended by Philippe Pebay, Kitware SAS 2011, to support
* broken lines as well as simple lines.
*/
#ifndef vtkLineSource_h
#define vtkLineSource_h
#include "vtkFiltersSourcesModule.h" // For export macro
#include "vtkPolyDataAlgorithm.h"
#include <vector> // for std::vector
VTK_ABI_NAMESPACE_BEGIN
class vtkPoints;
class VTKFILTERSSOURCES_EXPORT vtkLineSource : public vtkPolyDataAlgorithm
{
public:
static vtkLineSource* New();
vtkTypeMacro(vtkLineSource, vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
///@{
/**
* Set position of first end point.
*/
vtkSetVector3Macro(Point1, double);
vtkGetVectorMacro(Point1, double, 3);
void SetPoint1(float[3]);
///@}
///@{
/**
* Set position of other end point.
*/
vtkSetVector3Macro(Point2, double);
vtkGetVectorMacro(Point2, double, 3);
void SetPoint2(float[3]);
///@}
///@{
/**
* Set/Get how the line segment is to be refined. One can choose to add points
* at regular intervals per segment (defined using `Resolution`) or explicit
* locations (defined using `SetRefinementRatio`). Default is true i.e
* `Resolution` will be used to determine placement of points within each line
* segment.
*/
vtkSetMacro(UseRegularRefinement, bool);
vtkGetMacro(UseRegularRefinement, bool);
vtkBooleanMacro(UseRegularRefinement, bool);
///@}
///@{
/**
* Divide line into Resolution number of pieces. This is used when
* `UseRegularRefinement` is true.
*/
vtkSetClampMacro(Resolution, int, 1, VTK_INT_MAX);
vtkGetMacro(Resolution, int);
///@}
///@{
/**
* API for setting/getting refinement ratios for points added to the line
* segment. The ratio is in the range `[0.0, 1.0]` where 0.0 is the start of
* the line segment and 1.0 is the end. When generating broken lines i.e.
* using `SetPoints`, this specifies refinement points for each of the
* individual line segment. Note that `0.0` and `1.0` must be explicitly
* included to generate a point and the start and/or end of the line segment.
* This is used only when `UseRegularRefinement` is false.
*/
void SetNumberOfRefinementRatios(int);
void SetRefinementRatio(int index, double value);
int GetNumberOfRefinementRatios();
double GetRefinementRatio(int index);
///@}
///@{
/**
* Set/Get the list of points defining a broken line
*/
virtual void SetPoints(vtkPoints*);
vtkGetObjectMacro(Points, vtkPoints);
///@}
///@{
/**
* 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);
///@}
protected:
vtkLineSource(int res = 1);
~vtkLineSource() override;
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
double Point1[3];
double Point2[3];
int Resolution;
int OutputPointsPrecision;
bool UseRegularRefinement;
std::vector<double> RefinementRatios;
/**
* The list of points defining a broken line
* NB: The Point1/Point2 definition of a single line segment is used by default
*/
vtkPoints* Points;
private:
vtkLineSource(const vtkLineSource&) = delete;
void operator=(const vtkLineSource&) = delete;
};
VTK_ABI_NAMESPACE_END
#endif
|