VTK  9.6.20260516
HDFTestUtilities.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
3#ifndef HDFTestUtilities_h
4#define HDFTestUtilities_h
5
7#include "vtkHyperTreeGrid.h"
10#include "vtkInformation.h"
12#include "vtkNew.h"
13#include "vtkObjectFactory.h"
15
16#include <array>
17#include <numeric>
18
20{
26{
27public:
30
31 void SetDescriptors(const std::vector<std::string>& descriptors)
32 {
33 this->Descriptors = descriptors;
34 }
35 void SetMasks(const std::vector<std::string>& masks) { this->Masks = masks; }
36 void SetDimensions(const std::array<unsigned int, 3>& dimensions)
37 {
38 this->Dimensions = dimensions;
39 }
40 void SetBranchFactor(const unsigned int bf) { this->BranchFactor = bf; }
41
42protected:
44 {
45 info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkHyperTreeGrid");
46 return 1;
47 }
48
54
57 {
58 vtkInformation* outInfo = outputVector->GetInformationObject(0);
59 std::vector<double> timeSteps(this->Descriptors.size());
60 std::iota(timeSteps.begin(), timeSteps.end(), 0);
61 double timeRange[2] = { timeSteps.front(), timeSteps.back() };
62 outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), timeSteps.data(),
63 static_cast<int>(timeSteps.size()));
65 static_cast<int>(sizeof(timeRange) / sizeof(timeRange[0])));
67 outInfo->Set(CAN_HANDLE_PIECE_REQUEST(), 1);
68 return 1;
69 }
70
72 {
73 intSource->SetDimensions(3, 3, 2);
74 intSource->SetBranchFactor(2);
75 intSource->SetMaxDepth(4);
76 intSource->SetUseMask(!this->Masks.empty());
77 intSource->SetDimensions(this->Dimensions.data());
78 intSource->SetBranchFactor(BranchFactor);
79 if (intSource->GetUseMask())
80 {
81 intSource->SetMask(this->Masks.at(static_cast<int>(this->RequestedTime)).c_str());
82 }
83
84 intSource->SetDescriptor(this->Descriptors.at(static_cast<int>(this->RequestedTime)).c_str());
85
86 return 1;
87 }
88
91 {
92 vtkInformation* outInfo = outputVector->GetInformationObject(0);
94 if (!output)
95 {
96 return 0;
97 }
98
100 {
102 }
103
104 this->ProcessTrees(nullptr, nullptr);
105
106 typedef vtkStreamingDemandDrivenPipeline vtkSDDP;
108 if (outInfo->Has(vtkSDDP::UPDATE_PIECE_NUMBER()))
109 {
110 intSource->UpdatePiece(outInfo->Get(vtkSDDP::UPDATE_PIECE_NUMBER()),
111 outInfo->Get(vtkSDDP::UPDATE_NUMBER_OF_PIECES()), 0);
112 }
113 else
114 {
115 intSource->Update();
116 }
117
118 output->ShallowCopy(intSource->GetOutputDataObject(0));
119
120 return 1;
121 }
122
123private:
125 void operator=(const vtkHTGChangingDescriptorSource&) = delete;
126
127 std::vector<std::string> Descriptors;
128 std::vector<std::string> Masks;
129 std::array<unsigned int, 3> Dimensions;
130 unsigned int BranchFactor = 2;
131
132 double RequestedTime = 0.0;
134};
135}
136#endif
Custom source to generate time-dependent HTG.
static vtkHTGChangingDescriptorSource * New()
void SetDimensions(const std::array< unsigned int, 3 > &dimensions)
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *outputVector) override
void SetMasks(const std::vector< std::string > &masks)
int ProcessTrees(vtkHyperTreeGrid *, vtkDataObject *) override
Main routine to process individual trees in the grid This is pure virtual method to be implemented by...
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *outputVector) override
This is called by the superclass.
void SetDescriptors(const std::vector< std::string > &descriptors)
int FillOutputPortInformation(int, vtkInformation *info) override
Fill the output port information objects for this algorithm.
virtual void SetNumberOfOutputPorts(int n)
Set the number of output ports provided by the algorithm.
virtual void SetNumberOfInputPorts(int n)
Set the number of input ports used by the algorithm.
general representation of visualization data
A dataset containing a grid of vtkHyperTree instances arranged as a rectilinear grid.
static vtkHyperTreeGrid * SafeDownCast(vtkObjectBase *o)
Store zero or more vtkInformation instances.
vtkInformation * GetInformationObject(int index)
Get/Set the vtkInformation instance stored at the given index in the vector.
Store vtkAlgorithm input/output information.
int Get(vtkInformationIntegerKey *key)
Get/Set an integer-valued entry.
int Has(vtkInformationKey *key) VTK_FUTURE_CONST
Check whether the given key appears in this information object.
void Set(vtkInformationRequestKey *key)
Get/Set a request-valued entry.
Allocate and hold a VTK object.
Definition vtkNew.h:168
Executive supporting partial updates.
static vtkInformationDoubleKey * UPDATE_TIME_STEP()
Update time steps requested by the pipeline.
static vtkInformationIntegerKey * CAN_HANDLE_PIECE_REQUEST()
Key that tells the pipeline that a particular algorithm can or cannot handle piece request.
static vtkInformationIntegerKey * TIME_DEPENDENT_INFORMATION()
Whether there are time dependent meta information if there is, the pipeline will perform two extra pa...
static vtkInformationDoubleVectorKey * TIME_RANGE()
Key to store available time range for continuous sources.
static vtkInformationStringKey * DATA_TYPE_NAME()
Information keys to describe the content of this vtkDataObject.
static vtkInformationDoubleVectorKey * TIME_STEPS()
Key to store available time steps.
static vtkInformationDataObjectKey * DATA_OBJECT()
Store a vtkDataObject pointer.