<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">David, <div class=""><br class=""></div><div class="">Sorry for the belated reply; it took me a while to get round to testing the new classes.</div><div class="">I can confirm that they respond perfectly to my needs, thanks a million!</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Richard</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 25 Jan 2016, at 14:40, David Gobbi <<a href="mailto:david.gobbi@gmail.com" class="">david.gobbi@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi Richard,</div><div class=""><br class=""></div><div class="">I've put my code up on gitlab, three classes in total:</div><a href="https://gitlab.kitware.com/vtk/vtk/merge_requests/1118" class="">https://gitlab.kitware.com/vtk/vtk/merge_requests/1118</a><br class=""><div class=""><br class=""></div><div class="">Two of these classes are iterators, meaning that they allow you to</div><div class="">write your own loop. The third class is a filter that extracts all of</div><div class="">the point data that lies within the stencil. Here are some examples</div><div class="">(the examples are python, C++ code would be similar):</div><div class=""><br class=""></div><div class=""># Example for iterating over all point Ids in an image</div><div class=""><div class="">iter = vtkImagePointDataIterator(image, image.GetExtent(), stencil)</div><div class="">scalars = image.GetPointData().GetScalars()</div><div class="">while (not iter.IsAtEnd()):</div><div class=""> # loop over a contiguous span of Ids</div><div class=""> for i in range(iter.GetId(), iter.GetId() + iter.GetSpanSize()):</div><div class=""> value = scalars.GetTuple(i)</div><div class=""> # advance to the next span</div><div class=""> iter.NextSpan()</div></div><div class=""><br class=""></div><div class=""># Example for iterating over all points in an image</div><div class=""><div class="">iter = vtkImagePointIterator(image, image.GetExtent(), stencil)</div><div class="">scalars = image.GetPointData().GetScalars()</div><div class="">while (not iter.IsAtEnd()):</div><div class=""> point = iter.GetPosition()</div><div class=""> idx = iter.GetIndex()</div><div class=""> value = scalars.GetTuple(iter.GetId())</div><div class=""> iter.Next()</div></div><div class=""><br class=""></div><div class=""># Example for using the vtkImageToPoints filter</div><div class="">filter = vtkImageToPoints()</div><div class="">filter.SetInputConnection(reader.GetOutputPort())</div><div class="">filter.SetStencilConnection(polyToStencil.GetOutputPort())</div><div class="">filter.Update()</div><div class=""># Get a polydata object with points and attributes</div><div class="">polyData = filter.GetOutput()</div><div class="">points = polyData.GetPoints()</div><div class="">scalars = polyData.GetPointData().GetScalars()</div><div class=""><br class=""></div><div class="">I'm not sure if these were quite what you were looking for, I was</div><div class="">aiming to create general-purpose classes.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""> - David</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jan 20, 2016 at 9:31 AM, David Gobbi <span dir="ltr" class=""><<a href="mailto:david.gobbi@gmail.com" target="_blank" class="">david.gobbi@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class="">Proposed patches for VTK are at this page:<div class=""><a href="https://gitlab.kitware.com/vtk/vtk/merge_requests" target="_blank" class="">https://gitlab.kitware.com/vtk/vtk/merge_requests</a><br class=""></div><div class="">And a log of accepted patches is at this page:</div><div class=""><a href="https://gitlab.kitware.com/groups/vtk" target="_blank" class="">https://gitlab.kitware.com/groups/vtk</a><br class=""></div><div class=""><br class=""></div><div class="">When my patch is ready, I'll send you a link.</div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class=""> - David</div><div class=""><br class=""></div></font></span></div><div class=""><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jan 20, 2016 at 9:10 AM, Richard Brown <span dir="ltr" class=""><<a href="mailto:richard.j.brown@live.co.uk" target="_blank" class="">richard.j.brown@live.co.uk</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Great thanks David.<div class=""><br class=""></div><div class="">Silly question, but where is gitlab?</div><div class=""><br class=""></div><div class="">Regards,</div><div class="">Richard</div><div class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 19 Jan 2016, at 23:09, David Gobbi <<a href="mailto:david.gobbi@gmail.com" target="_blank" class="">david.gobbi@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="">Hi Rich,</div><div class=""><br class=""></div><div class="">The quick answer is no, there are no classes in VTK to do this.</div><div class=""><br class=""></div><div class="">However, I have a class of my own called vtkImageExtractVoxels that</div><div class="">almost does what you need: it creates a vtkDataArray that contains the</div><div class="">the values of all of the voxels in the stencil. It would be trivial to modify</div><div class="">this class so it so that it gives all the IDs.</div><div class=""><br class=""></div><div class="">Coincidentally, just 5 minutes before I saw your email, I started editing</div><div class="">this class because I need it to give the (x,y,z) of all in-stencil voxels.</div><div class="">So I'll get it to produce the IDs as well, and then put it on gitlab if you</div><div class="">want to try it out.</div><div class=""><br class=""></div><div class=""> - David</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Jan 19, 2016 at 2:59 PM, mbcx9rb9 <span dir="ltr" class=""><<a href="mailto:richard.j.brown@live.co.uk" target="_blank" class="">richard.j.brown@live.co.uk</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi all,<br class="">
<br class="">
Is there any way to get a list containing the IDs of all voxels within a<br class="">
vtkImageStencilData?<br class="">
<br class="">
My method at the moment for getting all the voxels in the stencil is to<br class="">
create a vtkOBBTree and check if the centre of each voxel is inside the<br class="">
vtkPolyData related to the stencil, but this is very slow.<br class="">
<br class="">
Thanks in advance for any pointers,<br class="">
Rich<br class=""></blockquote></div></div></div>
</div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>