File: vtkPolyDataPointSampler.h

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 205,916 kB
  • sloc: cpp: 2,336,565; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 178; javascript: 165; objc: 153; tcl: 59
file content (196 lines) | stat: -rw-r--r-- 7,076 bytes parent folder | download | duplicates (7)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkPolyDataPointSampler
 * @brief   generate points from vtkPolyData
 *
 * vtkPolyDataPointSampler generates points from input vtkPolyData. The
 * filter has two modes of operation: random point generation, or regular
 * point generation. In random generation mode, points are generated in each
 * polygonal entity using a random approach. In regular generation mode, the
 * points are placed approximately a specified distance apart. Optionally,
 * the points attributes can be interpolated from the generating vertices,
 * edges, and polygons.
 *
 * In regular point generation mode, this filter functions as follows. First,
 * it regurgitates all input points, then it samples all lines, plus edges
 * associated with the input polygons and triangle strips to produce edge
 * points. Finally, the interiors of polygons and triangle strips are
 * subsampled to produce points. All of these operations can be enabled or
 * disabled separately. Note that this algorithm only approximately generates
 * points the specified distance apart. Generally the point density is finer
 * than requested.
 *
 * In random point generation mode, this filter functions as follows. First,
 * it randomly regurgitates all input points (if enabled), then it randomly
 * samples all lines, plus edges associated with the input polygons and
 * triangle strips to produce edge points (if enabled). Finally, the
 * interiors of polygons and triangle strips are randomly subsampled to
 * produce points. All of these operations can be enabled or disabled
 * separately. Note that this algorithm only approximately generates points
 * the specified distance apart. Generally the point density is finer than
 * requested. Also note that the result is not truly random due to the
 * constraints of the mesh construction.
 *
 * @warning
 * Although this algorithm processes general polygons. it does so by performing
 * a fan triangulation. This may produce poor results, especially for concave
 * polygons. For better results, use a triangle filter to pre-tesselate
 * polygons.
 *
 * @warning
 * In random point generation mode, producing random edges and vertex points
 * from polygons and triangle strips is less random than is typically
 * desirable. You may wish to disable vertex and edge point generation for a
 * result that is closer to random.
 *
 * @warning
 * Point generation can be useful in a variety of applications. For example,
 * generating seed points for glyphing or streamline generation. Another
 * useful application is generating points for implicit modeling. In many
 * cases implicit models can be more efficiently generated from points than
 * from polygons or other primitives.
 *
 * @warning
 * When sampling polygons of five sides or more, the polygon is triangulated.
 * This can result in variations in point density near tessellation boundaries.
 *
 * @sa
 * vtkTriangleFilter vtkImplicitModeller
 */

#ifndef vtkPolyDataPointSampler_h
#define vtkPolyDataPointSampler_h

#include "vtkEdgeTable.h"             // for sampling edges
#include "vtkFiltersModelingModule.h" // For export macro
#include "vtkNew.h"                   // for data members
#include "vtkPolyDataAlgorithm.h"

VTK_ABI_NAMESPACE_BEGIN
class VTKFILTERSMODELING_EXPORT vtkPolyDataPointSampler : public vtkPolyDataAlgorithm
{
public:
  /**
   * Instantiate this class.
   */
  static vtkPolyDataPointSampler* New();

  ///@{
  /**
   * Standard macros for type information and printing.
   */
  vtkTypeMacro(vtkPolyDataPointSampler, vtkPolyDataAlgorithm);
  void PrintSelf(ostream& os, vtkIndent indent) override;
  ///@}

  ///@{
  /**
   * Set/Get the approximate distance between points. This is an absolute
   * distance measure. The default is 0.01.
   */
  vtkSetClampMacro(Distance, double, 0.0, VTK_FLOAT_MAX);
  vtkGetMacro(Distance, double);
  ///@}

  /**
   * Specify how points are to be generated.
   */
  enum
  {
    REGULAR_GENERATION,
    RANDOM_GENERATION
  };

  ///@{
  /**
   * Specify/retrieve the type of point generation: either regular point
   * generation or random point generation. By default, regular point
   * generation is used.
   */
  vtkSetClampMacro(PointGenerationMode, int, REGULAR_GENERATION, RANDOM_GENERATION);
  vtkGetMacro(PointGenerationMode, int);
  void SetPointGenerationModeToRegular() { this->SetPointGenerationMode(REGULAR_GENERATION); }
  void SetPointGenerationModeToRandom() { this->SetPointGenerationMode(RANDOM_GENERATION); }
  ///@}

  ///@{
  /**
   * Specify/retrieve a boolean flag indicating whether cell vertex points should
   * be output.
   */
  vtkGetMacro(GenerateVertexPoints, bool);
  vtkSetMacro(GenerateVertexPoints, bool);
  vtkBooleanMacro(GenerateVertexPoints, bool);
  ///@}

  ///@{
  /**
   * Specify/retrieve a boolean flag indicating whether cell edges should
   * be sampled to produce output points. The default is true.
   */
  vtkGetMacro(GenerateEdgePoints, bool);
  vtkSetMacro(GenerateEdgePoints, bool);
  vtkBooleanMacro(GenerateEdgePoints, bool);
  ///@}

  ///@{
  /**
   * Specify/retrieve a boolean flag indicating whether cell interiors should
   * be sampled to produce output points. The default is true.
   */
  vtkGetMacro(GenerateInteriorPoints, bool);
  vtkSetMacro(GenerateInteriorPoints, bool);
  vtkBooleanMacro(GenerateInteriorPoints, bool);
  ///@}

  ///@{
  /**
   * Specify/retrieve a boolean flag indicating whether cell vertices should
   * be generated. Cell vertices are useful if you actually want to display
   * the points (that is, for each point generated, a vertex is generated).
   * Recall that VTK only renders vertices and not points.  The default is
   * true.
   */
  vtkGetMacro(GenerateVertices, bool);
  vtkSetMacro(GenerateVertices, bool);
  vtkBooleanMacro(GenerateVertices, bool);
  ///@}

  ///@{
  /**
   * Specify/retrieve a boolean flag indicating whether point data should be
   * interpolated onto the newly generated points. If enabled, points
   * generated from existing vertices will carry the vertex point data;
   * points generated from edges will interpolate point data along each edge;
   * and interior point data (inside triangles, polygons cells) will be
   * interpolated from the cell vertices. By default this is off.
   */
  vtkGetMacro(InterpolatePointData, bool);
  vtkSetMacro(InterpolatePointData, bool);
  vtkBooleanMacro(InterpolatePointData, bool);
  ///@}

protected:
  vtkPolyDataPointSampler();
  ~vtkPolyDataPointSampler() override = default;

  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;

  double Distance;
  int PointGenerationMode;

  bool GenerateVertexPoints;
  bool GenerateEdgePoints;
  bool GenerateInteriorPoints;
  bool GenerateVertices;

  bool InterpolatePointData;

private:
  vtkPolyDataPointSampler(const vtkPolyDataPointSampler&) = delete;
  void operator=(const vtkPolyDataPointSampler&) = delete;
};

VTK_ABI_NAMESPACE_END
#endif