vtkXMLPolyDataWriter using AddInputDataObject does not produce a file
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
I am using VTK 6.2 and Java 8
I attempted to export an actor with quadrilateral facets using the code below. The code seemed to succeed, but no file was produced.
When tracing through the code with debugger, the number of actors found in the renderer was 4 (correct). One had quadrilateral facets and two had only poly lines. The fourth was unused (null mapper). On one occasion, I got an export file (no changes in code).
In the one case that I got a file (see attached), I imported the file using the read code shown below. Only one output was found in the reader. It rendered the correct facet information. On following attempts to import the same file I found one output, but nothing was rendered.
public void exportGraphicFile(String filename) { vtkXMLPolyDataWriter writer = new vtkXMLPolyDataWriter(); writer.SetFileName(filename); writer.SetDataModeToAscii();
vtkActorCollection actors = renderer.GetActors();
actors.InitTraversal(); for(int a = 0; a<actors.GetNumberOfItems(); ++a) { vtkActor actor = actors.GetNextActor(); if(actor != null) { vtkPolyDataMapper mapper = (vtkPolyDataMapper) actor.GetMapper(); if(mapper != null) { vtkPolyData poly = mapper.GetInput();
writer.AddInputDataObject(poly);
}
} } writer.Update(); writer.Write(); }
public void importGraphicFile(String filename) { //read all the data from the file vtkXMLPolyDataReader reader = new vtkXMLPolyDataReader(); reader.SetFileName(filename); reader.Update();
int count = reader.GetNumberOfOutputPorts();
for(int i=0; i<count; i++) {
//Create a mapper and actor
vtkPolyData poly = reader.GetOutput(i);
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.SetInputData(poly);
elementFaceActor.SetMapper(mapper);
}
updateView();
}