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 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkProgrammableDataObjectSource.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkProgrammableDataObjectSource.h"
#include "vtkDataObject.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
vtkStandardNewMacro(vtkProgrammableDataObjectSource);
// Construct programmable filter with empty execute method.
vtkProgrammableDataObjectSource::vtkProgrammableDataObjectSource()
{
this->ExecuteMethod = NULL;
this->ExecuteMethodArg = NULL;
this->ExecuteMethodArgDelete = NULL;
vtkDataObject *output = vtkDataObject::New();
this->SetOutput(output);
// Releasing data for pipeline parallism.
// 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 != NULL )
{
(*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";
}
}
|