[vtkusers] vtkPolyDataToPolyDataFilter with n inputs - BUG?
Claudia Goenner
goenner at techinfo.rwth-aachen.de
Sat Nov 4 16:04:24 EST 2000
Hi all,
I wrote a vtkPolyDataToPolyDataFilter with n inputs and one output,
but when I allocate memmory for data structures during the execution of
the filter these overwrite the input data. The filter looks as follows:
call:
vtkLTIroboMergePolyData *mergeFilter =
vtkLTIroboMergePolyData::New();
mergeFilter->ReleaseDataFlagOff();
for (part=0;part<parts;part++)
mergeFilter->AddInput(preproc[part]); //preproc is an array
with polydata objects
mergeFilter->Update();
vtkLTIroboMergePolyData.h:
class VTK_EXPORT vtkLTIroboMergePolyData : public
vtkPolyDataToPolyDataFilter
{
public:
vtkTypeMacro(vtkLTIroboMergePolyData,vtkPolyDataToPolyDataFilter);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Construct with ...
static vtkLTIroboMergePolyData *New();
// Description:
// Set/Get the input
void SetInput(vtkPolyData *input);
void SetInput(int idx, vtkPolyData *input);
void AddInput(vtkPolyData *input);
......
vtkLTIroboMergePolyData.cxx:
vtkLTIroboMergePolyData* vtkLTIroboMergePolyData::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret =
vtkObjectFactory::CreateInstance("vtkLTIroboMergePolyData");
if(ret)
{
return (vtkLTIroboMergePolyData*)ret;
}
// If the factory was unable to create the object, then create it
here.
return new vtkLTIroboMergePolyData;
}
//----------------------------------------------------------------------------
// Multiple inputs
//----------------------------------------------------------------------------
// Specify the 1st input data or filter.
// (Because SetInput(int idx, vtkPolyData *input) overides def. in
// vtkPolyDataToPolyDataFilter.)
void vtkLTIroboMergePolyData::SetInput(vtkPolyData *input)
{
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
// Specify the next input data or filter.
void vtkLTIroboMergePolyData::AddInput(vtkPolyData *input)
{
int numInputs;
numInputs = this->vtkProcessObject::GetNumberOfInputs();
this->vtkProcessObject::SetNthInput(numInputs, input);
}
//----------------------------------------------------------------------------
// Specify the n-th input data or filter.
void vtkLTIroboMergePolyData::SetInput(int idx, vtkPolyData *input)
{
this->vtkProcessObject::SetNthInput(idx, input);
}
//----------------------------------------------------------------------------
// Get the n-th input data or filter.
vtkPolyData *vtkLTIroboMergePolyData::GetInput(int idx)
{
if (idx >= this->NumberOfInputs) {
return NULL;
}
return (vtkPolyData *)(this->Inputs[idx]);
}
...
The output polyData of the filter has a corrupted time stamp and cannot
be passed to other filters. In another filter with multiple inputs and
the same design as above, the point coordinates of the 1st polydata
input were set to undefined values after execution of the lines
this->CellMap = vtkIdList::New();
this->CellMap->SetNumberOfIds(numMergedPolys).
As that filter was only using the first input so far, I changed the
design to one input and the memory leak does not exist anymore. I
suspect that it had to do with my definition of SetInput and AddInput.
Is there anything wrong with the above design or maybe a bug in vtk. Im
am using an official vtk3.1 release (no nightly), obtained in spring.
Greetings and Thanks,
Claudia
More information about the vtkusers
mailing list