[vtkusers] save slice contours using vtkAppendPolyData

kent williams nkwmailinglists at gmail.com
Fri Jan 30 15:55:06 EST 2009


I think your problem may well be the fact that you're re-using the
cutting filter.  I also use 'AddInput' instead of
AddInputConnection.

You can get around the output problem by making a copy of the output, e.g.

vtkPolyData *pdCopy = vtkPolyData::New();
pdCopy->DeepCopy(cutter->GetOutputPort());
cutter->SetInput(pdCopy);

I'm foggy on the memory management involved -- I think I'd try keeping
a std::list of your copied PolyData and then only deleting it after
you've copied the results and deleted the Filter.

On Mon, Oct 13, 2008 at 8:16 AM, Elena Faggiano
<elena.faggiano at gmail.com> wrote:
> 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
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list