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
|
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
#include "vtkProgrammableDataObjectSource.h"
#include "vtkDataObject.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
VTK_ABI_NAMESPACE_BEGIN
vtkStandardNewMacro(vtkProgrammableDataObjectSource);
// Construct programmable filter with empty execute method.
vtkProgrammableDataObjectSource::vtkProgrammableDataObjectSource()
{
this->ExecuteMethod = nullptr;
this->ExecuteMethodArg = nullptr;
this->ExecuteMethodArgDelete = nullptr;
vtkDataObject* output = vtkDataObject::New();
this->SetOutput(output);
// Releasing data for pipeline parallelism.
// Filters will know it is empty.
output->ReleaseData();
output->Delete();
this->SetNumberOfInputPorts(0);
}
vtkProgrammableDataObjectSource::~vtkProgrammableDataObjectSource()
{
// delete the current arg if there is one and a delete meth
if ((this->ExecuteMethodArg) && (this->ExecuteMethodArgDelete))
{
(*this->ExecuteMethodArgDelete)(this->ExecuteMethodArg);
}
}
// Specify the function to use to generate the source data. Note
// that the function takes a single (void *) argument.
void vtkProgrammableDataObjectSource::SetExecuteMethod(void (*f)(void*), void* arg)
{
if (f != this->ExecuteMethod || arg != this->ExecuteMethodArg)
{
// delete the current arg if there is one and a delete meth
if ((this->ExecuteMethodArg) && (this->ExecuteMethodArgDelete))
{
(*this->ExecuteMethodArgDelete)(this->ExecuteMethodArg);
}
this->ExecuteMethod = f;
this->ExecuteMethodArg = arg;
this->Modified();
}
}
// Set the arg delete method. This is used to free user memory.
void vtkProgrammableDataObjectSource::SetExecuteMethodArgDelete(void (*f)(void*))
{
if (f != this->ExecuteMethodArgDelete)
{
this->ExecuteMethodArgDelete = f;
this->Modified();
}
}
int vtkProgrammableDataObjectSource::RequestData(
vtkInformation*, vtkInformationVector**, vtkInformationVector*)
{
vtkDebugMacro(<< "Executing programmable data object filter");
// Now invoke the procedure, if specified.
if (this->ExecuteMethod != nullptr)
{
(*this->ExecuteMethod)(this->ExecuteMethodArg);
}
return 1;
}
void vtkProgrammableDataObjectSource::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
if (this->ExecuteMethod)
{
os << indent << "An ExecuteMethod has been defined\n";
}
else
{
os << indent << "An ExecuteMethod has NOT been defined\n";
}
}
VTK_ABI_NAMESPACE_END
|