VTK  9.7.1
vtkRandomAttributeGenerator.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
41 #ifndef vtkRandomAttributeGenerator_h
42 #define vtkRandomAttributeGenerator_h
43 
44 #include "vtkFiltersGeneralModule.h" // For export macro
46 
47 VTK_ABI_NAMESPACE_BEGIN
48 class vtkCellData;
50 class vtkDataSet;
51 class vtkFieldData;
52 class vtkHyperTreeGrid;
53 class vtkPointData;
54 
55 class VTKFILTERSGENERAL_EXPORT vtkRandomAttributeGenerator : public vtkPassInputTypeAlgorithm
56 {
57 public:
59 
64  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
68 
72  vtkSetMacro(DataType, int);
73  void SetDataTypeToBit() { this->SetDataType(VTK_BIT); }
74  void SetDataTypeToChar() { this->SetDataType(VTK_CHAR); }
75  void SetDataTypeToUnsignedChar() { this->SetDataType(VTK_UNSIGNED_CHAR); }
76  void SetDataTypeToShort() { this->SetDataType(VTK_SHORT); }
77  void SetDataTypeToUnsignedShort() { this->SetDataType(VTK_UNSIGNED_SHORT); }
78  void SetDataTypeToInt() { this->SetDataType(VTK_INT); }
79  void SetDataTypeToUnsignedInt() { this->SetDataType(VTK_UNSIGNED_INT); }
80  void SetDataTypeToLong() { this->SetDataType(VTK_LONG); }
81  void SetDataTypeToLongLong() { this->SetDataType(VTK_LONG_LONG); }
82  void SetDataTypeToUnsignedLong() { this->SetDataType(VTK_UNSIGNED_LONG); }
84  void SetDataTypeToIdType() { this->SetDataType(VTK_ID_TYPE); }
85  void SetDataTypeToFloat() { this->SetDataType(VTK_FLOAT); }
86  void SetDataTypeToDouble() { this->SetDataType(VTK_DOUBLE); }
87  vtkGetMacro(DataType, int);
89 
91 
97  vtkSetClampMacro(NumberOfComponents, int, 1, VTK_INT_MAX);
98  vtkGetMacro(NumberOfComponents, int);
100 
102 
107  vtkSetMacro(MinimumComponentValue, double);
108  vtkGetMacro(MinimumComponentValue, double);
109  void SetComponentRange(double minimumValue, double maximumValue)
110  {
111  this->SetMinimumComponentValue(minimumValue);
112  this->SetMaximumComponentValue(maximumValue);
113  }
115 
117 
122  vtkSetMacro(MaximumComponentValue, double);
123  vtkGetMacro(MaximumComponentValue, double);
125 
127 
132  vtkSetClampMacro(NumberOfTuples, vtkIdType, 0, VTK_INT_MAX);
133  vtkGetMacro(NumberOfTuples, vtkIdType);
135 
137 
141  vtkSetMacro(GeneratePointScalars, vtkTypeBool);
142  vtkGetMacro(GeneratePointScalars, vtkTypeBool);
143  vtkBooleanMacro(GeneratePointScalars, vtkTypeBool);
145 
147 
151  vtkSetMacro(GeneratePointVectors, vtkTypeBool);
152  vtkGetMacro(GeneratePointVectors, vtkTypeBool);
153  vtkBooleanMacro(GeneratePointVectors, vtkTypeBool);
155 
157 
161  vtkSetMacro(GeneratePointNormals, vtkTypeBool);
162  vtkGetMacro(GeneratePointNormals, vtkTypeBool);
163  vtkBooleanMacro(GeneratePointNormals, vtkTypeBool);
165 
167 
171  vtkSetMacro(GeneratePointTensors, vtkTypeBool);
172  vtkGetMacro(GeneratePointTensors, vtkTypeBool);
173  vtkBooleanMacro(GeneratePointTensors, vtkTypeBool);
175 
177 
182  vtkSetMacro(GeneratePointTCoords, vtkTypeBool);
183  vtkGetMacro(GeneratePointTCoords, vtkTypeBool);
184  vtkBooleanMacro(GeneratePointTCoords, vtkTypeBool);
186 
188 
195  vtkSetMacro(GeneratePointArray, vtkTypeBool);
196  vtkGetMacro(GeneratePointArray, vtkTypeBool);
197  vtkBooleanMacro(GeneratePointArray, vtkTypeBool);
199 
201 
205  vtkSetMacro(GenerateCellScalars, vtkTypeBool);
206  vtkGetMacro(GenerateCellScalars, vtkTypeBool);
207  vtkBooleanMacro(GenerateCellScalars, vtkTypeBool);
209 
211 
215  vtkSetMacro(GenerateCellVectors, vtkTypeBool);
216  vtkGetMacro(GenerateCellVectors, vtkTypeBool);
217  vtkBooleanMacro(GenerateCellVectors, vtkTypeBool);
219 
221 
225  vtkSetMacro(GenerateCellNormals, vtkTypeBool);
226  vtkGetMacro(GenerateCellNormals, vtkTypeBool);
227  vtkBooleanMacro(GenerateCellNormals, vtkTypeBool);
229 
231 
235  vtkSetMacro(GenerateCellTensors, vtkTypeBool);
236  vtkGetMacro(GenerateCellTensors, vtkTypeBool);
237  vtkBooleanMacro(GenerateCellTensors, vtkTypeBool);
239 
241 
246  vtkSetMacro(GenerateCellTCoords, vtkTypeBool);
247  vtkGetMacro(GenerateCellTCoords, vtkTypeBool);
248  vtkBooleanMacro(GenerateCellTCoords, vtkTypeBool);
250 
252 
259  vtkSetMacro(GenerateCellArray, vtkTypeBool);
260  vtkGetMacro(GenerateCellArray, vtkTypeBool);
261  vtkBooleanMacro(GenerateCellArray, vtkTypeBool);
263 
265 
269  vtkSetMacro(GenerateFieldArray, vtkTypeBool);
270  vtkGetMacro(GenerateFieldArray, vtkTypeBool);
271  vtkBooleanMacro(GenerateFieldArray, vtkTypeBool);
273 
275 
280  vtkSetMacro(AttributesConstantPerBlock, bool);
281  vtkGetMacro(AttributesConstantPerBlock, bool);
282  vtkBooleanMacro(AttributesConstantPerBlock, bool);
284 
286 
293  {
294  this->GeneratePointScalarsOn();
295  this->GeneratePointVectorsOn();
296  this->GeneratePointNormalsOn();
297  this->GeneratePointTCoordsOn();
298  this->GeneratePointTensorsOn();
299  this->GeneratePointArrayOn();
300  }
302  {
303  this->GeneratePointScalarsOff();
304  this->GeneratePointVectorsOff();
305  this->GeneratePointNormalsOff();
306  this->GeneratePointTCoordsOff();
307  this->GeneratePointTensorsOff();
308  this->GeneratePointArrayOff();
309  }
311  {
312  this->GenerateCellScalarsOn();
313  this->GenerateCellVectorsOn();
314  this->GenerateCellNormalsOn();
315  this->GenerateCellTCoordsOn();
316  this->GenerateCellTensorsOn();
317  this->GenerateCellArrayOn();
318  }
320  {
321  this->GenerateCellScalarsOff();
322  this->GenerateCellVectorsOff();
323  this->GenerateCellNormalsOff();
324  this->GenerateCellTCoordsOff();
325  this->GenerateCellTensorsOff();
326  this->GenerateCellArrayOff();
327  }
329  {
330  this->GenerateAllPointDataOn();
331  this->GenerateAllCellDataOn();
332  this->GenerateFieldArrayOn();
333  }
335  {
336  this->GenerateAllPointDataOff();
337  this->GenerateAllCellDataOff();
338  this->GenerateFieldArrayOff();
339  }
341 
342 protected:
343  vtkRandomAttributeGenerator() = default;
344  ~vtkRandomAttributeGenerator() override = default;
345 
347  int FillInputPortInformation(int port, vtkInformation* info) override;
348 
349  int DataType = VTK_FLOAT;
350  int NumberOfComponents = 1;
351  vtkIdType NumberOfTuples = 0;
352  double MinimumComponentValue = 0.0;
353  double MaximumComponentValue = 1.0;
354 
355  vtkTypeBool GeneratePointScalars = 0;
356  vtkTypeBool GeneratePointVectors = 0;
357  vtkTypeBool GeneratePointNormals = 0;
358  vtkTypeBool GeneratePointTCoords = 0;
359  vtkTypeBool GeneratePointTensors = 0;
360  vtkTypeBool GeneratePointArray = 0;
361 
362  vtkTypeBool GenerateCellScalars = 0;
363  vtkTypeBool GenerateCellVectors = 0;
364  vtkTypeBool GenerateCellNormals = 0;
365  vtkTypeBool GenerateCellTCoords = 0;
366  vtkTypeBool GenerateCellTensors = 0;
367  vtkTypeBool GenerateCellArray = 0;
368 
369  vtkTypeBool GenerateFieldArray = 0;
370  bool AttributesConstantPerBlock = false;
371 
376  vtkDataArray* GenerateData(int dataType, vtkIdType numTuples, int numComp, int minComp,
377  int maxComp, double min, double max);
378 
383  template <class T>
384  void GenerateRandomTuples(
385  T* data, vtkIdType numTuples, int numComp, int minComp, int maxComp, double min, double max);
386 
387 private:
389  void operator=(const vtkRandomAttributeGenerator&) = delete;
390 
394  int ProcessDataSet(vtkDataSet* input, vtkDataSet* output);
395  int ProcessComposite(vtkCompositeDataSet* input, vtkCompositeDataSet* output);
396  int ProcessHTG(vtkHyperTreeGrid* input, vtkHyperTreeGrid* output);
397 
404  void GeneratePointData(vtkPointData* outputPD, vtkIdType numPts);
405  void GenerateCellData(vtkCellData* outputCD, vtkIdType numCells);
406  void GenerateFieldData(vtkFieldData* outputFD);
407 };
408 
409 VTK_ABI_NAMESPACE_END
410 #endif
void SetDataTypeToUnsignedLongLong()
Specify the type of array to create (all components of this array are of this type).
#define VTK_UNSIGNED_INT
Definition: vtkType.h:40
represent and manipulate point attribute data
Definition: vtkPointData.h:30
Superclass for algorithms that produce output of the same type as input.
Store vtkAlgorithm input/output information.
#define VTK_UNSIGNED_SHORT
Definition: vtkType.h:38
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
void SetDataTypeToUnsignedShort()
Specify the type of array to create (all components of this array are of this type).
#define VTK_INT_MAX
Definition: vtkType.h:192
void GenerateAllPointDataOff()
Convenience methods for generating data: all data, all point data, or all cell data.
represent and manipulate cell attribute data
Definition: vtkCellData.h:31
void SetDataTypeToLong()
Specify the type of array to create (all components of this array are of this type).
int vtkIdType
Definition: vtkType.h:363
void GenerateAllPointDataOn()
Convenience methods for generating data: all data, all point data, or all cell data.
void GenerateAllCellDataOff()
Convenience methods for generating data: all data, all point data, or all cell data.
#define VTK_LONG_LONG
Definition: vtkType.h:52
void GenerateAllDataOn()
Convenience methods for generating data: all data, all point data, or all cell data.
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_DOUBLE
Definition: vtkType.h:44
#define VTK_FLOAT
Definition: vtkType.h:43
void SetDataTypeToInt()
Specify the type of array to create (all components of this array are of this type).
void GenerateAllDataOff()
Convenience methods for generating data: all data, all point data, or all cell data.
abstract superclass for composite (multi-block or AMR) datasets
void SetDataTypeToUnsignedChar()
Specify the type of array to create (all components of this array are of this type).
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
#define VTK_SHORT
Definition: vtkType.h:37
#define VTK_CHAR
Definition: vtkType.h:34
#define VTK_LONG
Definition: vtkType.h:41
void SetDataTypeToFloat()
Specify the type of array to create (all components of this array are of this type).
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
void SetDataTypeToUnsignedInt()
Specify the type of array to create (all components of this array are of this type).
void SetDataTypeToUnsignedLong()
Specify the type of array to create (all components of this array are of this type).
#define VTK_UNSIGNED_CHAR
Definition: vtkType.h:36
void SetDataTypeToBit()
Specify the type of array to create (all components of this array are of this type).
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetDataTypeToLongLong()
Specify the type of array to create (all components of this array are of this type).
void GenerateAllCellDataOn()
Convenience methods for generating data: all data, all point data, or all cell data.
#define VTK_BIT
Definition: vtkType.h:33
void SetDataTypeToIdType()
Specify the type of array to create (all components of this array are of this type).
Store zero or more vtkInformation instances.
#define VTK_ID_TYPE
Definition: vtkType.h:45
#define VTK_UNSIGNED_LONG
Definition: vtkType.h:42
generate and create random data attributes
void SetComponentRange(double minimumValue, double maximumValue)
Set the minimum component value.
void SetDataTypeToChar()
Specify the type of array to create (all components of this array are of this type).
void SetDataTypeToShort()
Specify the type of array to create (all components of this array are of this type).
#define VTK_UNSIGNED_LONG_LONG
Definition: vtkType.h:53
#define VTK_INT
Definition: vtkType.h:39
#define max(a, b)
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called within ProcessRequest when a request asks the algorithm to do its work.
void SetDataTypeToDouble()
Specify the type of array to create (all components of this array are of this type).
static vtkPassInputTypeAlgorithm * New()
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51