VTK  9.3.20240425
vtkRandomHyperTreeGridSource.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
11#ifndef vtkRandomHyperTreeGridSource_h
12#define vtkRandomHyperTreeGridSource_h
13
14#include "vtkFiltersSourcesModule.h" // For export macro
16
17#include <vector>
18#include <vtkNew.h> // For vtkNew
19
20VTK_ABI_NAMESPACE_BEGIN
21class vtkDoubleArray;
25
26class VTKFILTERSSOURCES_EXPORT vtkRandomHyperTreeGridSource : public vtkHyperTreeGridAlgorithm
27{
28public:
31 void PrintSelf(ostream& os, vtkIndent indent) override;
32
38 vtkGetVector3Macro(Dimensions, unsigned int);
39 vtkSetVector3Macro(Dimensions, unsigned int);
46 vtkGetVector6Macro(OutputBounds, double);
47 vtkSetVector6Macro(OutputBounds, double);
48
55 vtkGetMacro(Seed, vtkTypeUInt32);
56 vtkSetMacro(Seed, vtkTypeUInt32);
64 vtkGetMacro(MaxDepth, vtkIdType);
65 vtkSetClampMacro(MaxDepth, vtkIdType, 1, VTK_ID_MAX);
73 vtkGetMacro(SplitFraction, double);
74 vtkSetClampMacro(SplitFraction, double, 0., 1.);
88 vtkGetMacro(MaskedFraction, double);
89 vtkSetClampMacro(MaskedFraction, double, 0., 1.);
97 vtkGetMacro(ActualMaskedCellFraction, double);
100protected:
103
105 vtkInformation* req, vtkInformationVector** inInfo, vtkInformationVector* outInfo) override;
106
108 vtkInformation* req, vtkInformationVector** inInfo, vtkInformationVector* outInfo) override;
109
110 // We just do the work in RequestData.
111 int ProcessTrees(vtkHyperTreeGrid*, vtkDataObject*) final { return 1; }
112
113 int FillOutputPortInformation(int port, vtkInformation* info) override;
114
123
125
126 unsigned int Dimensions[3];
127 double OutputBounds[6];
128 vtkTypeUInt32 Seed;
131
132private:
134 void operator=(const vtkRandomHyperTreeGridSource&) = delete;
135
137 // We have 2 different RNG for retrocompatibility, since the mask
138 // has been added later on.
140 vtkNew<vtkExtentTranslator> ExtentTranslator;
141 vtkDoubleArray* Levels;
142 double MaskedFraction = 0;
143 double ActualMaskedCellFraction = 0;
144 std::vector<double> MaskingCostPerLevel{ 1.0 };
145
152 bool ShouldMask(double siblingsMasked = 0.0, int level = 0, double errorMargin = 0.0);
153
157 double GenerateMask(vtkHyperTreeGridNonOrientedCursor* cursor, vtkIdType treeId,
158 double unmaskedFraction = 1.0, bool isParentMasked = false, double siblingsMasked = 0.0);
159
163 void InitializeMaskingNodeCostPerLevel();
164
173 double GetMaskingNodeCost(int level);
174
178 void ShuffleArray(std::vector<int>& array, int size, vtkMinimalStandardRandomSequence* rng);
179};
180
181VTK_ABI_NAMESPACE_END
182#endif // vtkRandomHyperTreeGridSource_h
general representation of visualization data
dynamic, self-adjusting array of double
Generates a structured extent from unstructured.
Superclass for algorithms that produce a hyper tree grid as output.
Objects for traversal a HyperTreeGrid.
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Park and Miller Sequence of pseudo random numbers.
Allocate and hold a VTK object.
Definition vtkNew.h:160
Builds a randomized but reproducible vtkHyperTreeGrid.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkRandomHyperTreeGridSource * New()
void SubdivideLeaves(vtkHyperTreeGridNonOrientedCursor *cursor, vtkIdType treeId)
Recursively subdivides the leafs of the tree using a pseudo random number generator and the SplitFrac...
int FillOutputPortInformation(int port, vtkInformation *info) override
Define default input and output port types.
int RequestData(vtkInformation *req, vtkInformationVector **inInfo, vtkInformationVector *outInfo) override
This is called by the superclass.
~vtkRandomHyperTreeGridSource() override
int ProcessTrees(vtkHyperTreeGrid *, vtkDataObject *) final
Main routine to process individual trees in the grid This is pure virtual method to be implemented by...
int RequestInformation(vtkInformation *req, vtkInformationVector **inInfo, vtkInformationVector *outInfo) override
bool ShouldRefine(vtkIdType level)
int vtkIdType
Definition vtkType.h:315
#define VTK_ID_MAX
Definition vtkType.h:319