<div dir="auto">Yes, use<div dir="auto">SetInputData</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 29, 2017 6:43 PM, "majinsaha" <<a href="mailto:saiya-jin@yandex.ru">saiya-jin@yandex.ru</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<br>
I am trying to extract a certain number of cells from vtkImageData object<br>
and make them a separate actor. If I had vtkPolyData instead, that would be<br>
easy to do as follows:<br>
<br>
vtkSmartPointer<<wbr>vtkIdTypeArray> ids =<br>
vtkSmartPointer<<wbr>vtkIdTypeArray>::New();<br>
ids->SetNumberOfComponents(1);<br>
<br>
// TODO: Filling ids with the cell indices of interest<br>
<br>
vtkSmartPointer<<wbr>vtkSelectionNode> selectionNode =<br>
vtkSmartPointer<<wbr>vtkSelectionNode>::New();<br>
selectionNode->SetFieldType(<wbr>vtkSelectionNode::CELL);<br>
selectionNode->SetContentType(<wbr>vtkSelectionNode::INDICES);<br>
selectionNode-><wbr>SetSelectionList(ids);<br>
<br>
vtkSmartPointer<vtkSelection> selection =<br>
vtkSmartPointer<vtkSelection>:<wbr>:New();<br>
selection->AddNode(<wbr>selectionNode);<br>
<br>
vtkSmartPointer<<wbr>vtkExtractSelectedPolyDataIds> extractSelection =<br>
vtkSmartPointer<<wbr>vtkExtractSelectedPolyDataIds><wbr>::New();<br>
extractSelection-><wbr>SetInputData(0, myPolyData);<br>
extractSelection-><wbr>SetInputData(1, selection);<br>
extractSelection->Update();<br>
<br>
vtkSmartPointer<<wbr>vtkPolyDataMapper> cellsMapper =<br>
vtkSmartPointer<<wbr>vtkPolyDataMapper>::New();<br>
cellsMapper->SetInputData(<wbr>extractSelection->GetOutput())<wbr>;<br>
<br>
Is there a way to do it similarly for vtkImageData?<br>
<br>
If not, I assume I should then transform vtkImageData to vtkPolyData to use<br>
all the shown benefits, right? However, what is a nice and painless way to<br>
do this transformation? I know there is ImageDataGeometryFilter that's<br>
supposed to do it, but I've only seen how it works for sources such as here:<br>
<br>
<br>
vtkSmartPointer<<wbr>vtkImageCanvasSource2D> source1 =<br>
    vtkSmartPointer<<wbr>vtkImageCanvasSource2D>::New()<wbr>;<br>
  // TODO: DO SOMETHING WITH SOURCE<br>
<br>
  // Convert the image to a polydata<br>
  vtkSmartPointer<<wbr>vtkImageDataGeometryFilter> imageDataGeometryFilter =<br>
    vtkSmartPointer<<wbr>vtkImageDataGeometryFilter>::<wbr>New();<br>
  imageDataGeometryFilter-><wbr>SetInputConnection(source1-><wbr>GetOutputPort());<br>
  imageDataGeometryFilter-><wbr>Update();<br>
<br>
<br>
Is there a way to attach vtkImageData itself to a pipeline like this instead<br>
of a source? It doesn't have GetOutputPort() method so I can't seem to be<br>
able to use this approach.<br>
<br>
The answers to both questions are greatly appreciated!<br>
<br>
P.S. I realize I can do this in brute-force way by remaking entire<br>
vtkImageData from the selected cells, but that would take a long time. Don't<br>
want to reinvent the wheel here.<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Extracting-cells-from-vtkImageData-tp5742666.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.<wbr>com/Extracting-cells-from-<wbr>vtkImageData-tp5742666.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
</blockquote></div></div>