[vtkusers] Extracting cells from vtkImageData
Bill Lorensen
bill.lorensen at gmail.com
Wed Mar 29 19:10:08 EDT 2017
Yes, use
SetInputData
On Mar 29, 2017 6:43 PM, "majinsaha" <saiya-jin at yandex.ru> wrote:
> Hello!
>
> I am trying to extract a certain number of cells from vtkImageData object
> and make them a separate actor. If I had vtkPolyData instead, that would be
> easy to do as follows:
>
> vtkSmartPointer<vtkIdTypeArray> ids =
> vtkSmartPointer<vtkIdTypeArray>::New();
> ids->SetNumberOfComponents(1);
>
> // TODO: Filling ids with the cell indices of interest
>
> vtkSmartPointer<vtkSelectionNode> selectionNode =
> vtkSmartPointer<vtkSelectionNode>::New();
> selectionNode->SetFieldType(vtkSelectionNode::CELL);
> selectionNode->SetContentType(vtkSelectionNode::INDICES);
> selectionNode->SetSelectionList(ids);
>
> vtkSmartPointer<vtkSelection> selection =
> vtkSmartPointer<vtkSelection>::New();
> selection->AddNode(selectionNode);
>
> vtkSmartPointer<vtkExtractSelectedPolyDataIds> extractSelection =
> vtkSmartPointer<vtkExtractSelectedPolyDataIds>::New();
> extractSelection->SetInputData(0, myPolyData);
> extractSelection->SetInputData(1, selection);
> extractSelection->Update();
>
> vtkSmartPointer<vtkPolyDataMapper> cellsMapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> cellsMapper->SetInputData(extractSelection->GetOutput());
>
> Is there a way to do it similarly for vtkImageData?
>
> If not, I assume I should then transform vtkImageData to vtkPolyData to use
> all the shown benefits, right? However, what is a nice and painless way to
> do this transformation? I know there is ImageDataGeometryFilter that's
> supposed to do it, but I've only seen how it works for sources such as
> here:
>
>
> vtkSmartPointer<vtkImageCanvasSource2D> source1 =
> vtkSmartPointer<vtkImageCanvasSource2D>::New();
> // TODO: DO SOMETHING WITH SOURCE
>
> // Convert the image to a polydata
> vtkSmartPointer<vtkImageDataGeometryFilter> imageDataGeometryFilter =
> vtkSmartPointer<vtkImageDataGeometryFilter>::New();
> imageDataGeometryFilter->SetInputConnection(source1->GetOutputPort());
> imageDataGeometryFilter->Update();
>
>
> Is there a way to attach vtkImageData itself to a pipeline like this
> instead
> of a source? It doesn't have GetOutputPort() method so I can't seem to be
> able to use this approach.
>
> The answers to both questions are greatly appreciated!
>
> P.S. I realize I can do this in brute-force way by remaking entire
> vtkImageData from the selected cells, but that would take a long time.
> Don't
> want to reinvent the wheel here.
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.
> com/Extracting-cells-from-vtkImageData-tp5742666.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170329/80100ec5/attachment.html>
More information about the vtkusers
mailing list