[vtkusers] Multiple unstructured grid outputs

George Buzzell gbuzzell at memcad.com
Tue Oct 31 15:09:44 EST 2000


Hi all.

I have developed an unstructured data based reader that generates a
number of outputs corresponding to parts in an assembly. I have found it
necessary to add outputs (seems there is only one by default) using the
following local method:

void vtkMyReader::LocalSetOutputs(int num) {
  SetNumberOfOutputs(num);
  for (int i = 0;i<num;i++) {
    vtkUnstructuredGrid *ugrid = GetOutput(i);
    if (ugrid == NULL) {
      ugrid = vtkUnstructuredGrid::New();
      vtkSource::SetNthOutput(i,ugrid);
    }
  }
}

When I cycle the reader through a few files (which may have any number
of outputs), I delete the outputs and regenerate them before each read.

void vtkMyReader::LocalRemoveOutputs() {
  int num = GetNumberOfOutputs();
  for (int i=0;i<num;i++) {
    vtkUnstructuredGrid *ugrid = GetOutput(i);
    RemoveOutput(ugrid);
  }
}

The reader itself is never deleted.

I am currently having problems with memory leaks (under vtk 3.1) and
suspect that adding and deleting outputs in this manner might not be
correct (I perform the ugrid->Delete() call external to the reader for
each output where an assembly of the outputs is created). My question
simply put is: is the above aproach correct, or is there something
fundamentally wrong here (the program displays quite nicely, it just
leaks memory, so I suspect I'm on the right track).

Thanks in advance for your help,

George Buzzell
Microcosm Technologies





More information about the vtkusers mailing list