3#include <vtkCompositeDataPipeline.h>
4#include <vtkDoubleArray.h>
5#include <vtkFieldData.h>
6#include <vtkInformation.h>
7#include <vtkInformationVector.h>
8#include <vtkMultiBlockDataSet.h>
17 SetNumberOfInputPorts(2);
18 SetNumberOfOutputPorts(1);
24 if(port == 0 || port == 1) {
25 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(),
"vtkDataObject", 1);
39static int removeFieldDataRecursively(vtkDataObject *
object) {
40 object->GetFieldData()->RemoveArray(
"_ttk_IterationInfo");
41 if(object->IsA(
"vtkMultiBlockDataSet")) {
42 auto objectAsMB =
static_cast<vtkMultiBlockDataSet *
>(object);
43 for(
size_t i = 0; i < objectAsMB->GetNumberOfBlocks(); i++)
44 removeFieldDataRecursively(objectAsMB->GetBlock(i));
50 vtkInformationVector **inputVector,
51 vtkInformationVector *outputVector) {
56 auto inputAlgorithm = this->GetInputAlgorithm(1, 0);
57 while(inputAlgorithm && !inputAlgorithm->IsA(
"ttkForEach")) {
58 inputAlgorithm = inputAlgorithm->GetInputAlgorithm();
64 this->
printErr(
"Second input not connected to a ttkForEach filter.");
72 bool const isRepeatedIteration = this->LastIterationIdx == i && i > 0;
73 this->LastIterationIdx = i;
75 if(isRepeatedIteration)
76 this->
printMsg(
"For Loop Modified -> Restarting Iterations",
79 this->
printMsg(
"Iteration ( " + std::to_string(i) +
" / "
80 + std::to_string(n - 1) +
" ) complete ",
83 if(i >= n - 1 && !isRepeatedIteration) {
85 auto input = vtkDataObject::GetData(inputVector[0]);
86 auto output = vtkDataObject::GetData(outputVector);
87 output->ShallowCopy(input);
88 removeFieldDataRecursively(output);
89 request->Remove(vtkStreamingDemandDrivenPipeline::CONTINUE_EXECUTING());
93 this->GetInputAlgorithm(0, 0)->Update();
95 request->Set(vtkStreamingDemandDrivenPipeline::CONTINUE_EXECUTING(), 1);
static vtkInformationIntegerKey * SAME_DATA_TYPE_AS_INPUT_PORT()
TTK VTK-filter that requests data as long as it is available.
int FillInputPortInformation(int port, vtkInformation *info) override
int FillOutputPortInformation(int port, vtkInformation *info) override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
TTK VTK-filter that works in conjunction with the ttkEndFor filter to iterate over blocks,...
virtual int GetIterationNumber()
static ttkForEach * SafeDownCast(vtkObject *o)
virtual int GetIterationIdx()
void setDebugMsgPrefix(const std::string &prefix)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
vtkStandardNewMacro(ttkEndFor)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)