[vtkusers] save slice contours using vtkAppendPolyData

Elena Faggiano elena.faggiano at gmail.com
Mon Oct 13 10:16:40 EDT 2008


Hi,

I want to save contours generated cutting a Mesh (vtkPolyData) with a
vtkCutter in a unique file.
I've tried to use vtkAppendPolyData in different ways but when I read
the file I only see the last contour and all previously
'appended' contours are missing. I can't find the error!!

I've tried also with 2 contours (base test):


 vtkPlane *plane = vtkPlane::New();
 vtkCutter *cutter = vtkCutter::New();

 plane->SetNormal(0,0,1);

 vtkAppendPolyData* append = vtkAppendPolyData::New();
 vtkPolyDataWriter *pdw = vtkPolyDataWriter::New();

//first contour
  plane->SetOrigin(0.0 , 0.0, z+spacing);
  cutter->SetInput(data);
  cutter->SetCutFunction(plane);
  cutter->Update();

  append->AddInputConnection(cutter->GetOutputPort());
  append->Update();

//second contour
  plane->SetOrigin(0.0 , 0.0, z+2*spacing);
  cutter->SetInput(data);
  cutter->SetCutFunction(plane);
  cutter->Update();

  append->AddInputConnection(cutter->GetOutputPort());
  append->Update();

  pdw->SetInputConnection(append->GetOutputPort());
  pdw->SetFileName('cutplane.vtk');
  pdw->Write();
  pdw->Update();

I've tried with and without calling the Update method and also passing
the cutter->GetOutput to a polyData and than appending the polyData
but the problem is always the same...only the last contour appended is
written in the file .vtk

thanks a lot.
Elena Faggiano



More information about the vtkusers mailing list