<div dir="ltr"><div>Hi Nil,</div><div><br></div><div>I wrote a stencil iterator that provides the x, y, and z indices (not in VTK yet). It still requires an image to iterate over, but it might be worth a glance:</div><a href="https://github.com/dgobbi/AIRS/blob/master/ImageSegmentation/vtkImageRegionIterator.h" target="_blank">https://github.com/dgobbi/AIRS/blob/master/ImageSegmentation/vtkImageRegionIterator.h</a><br><div class="gmail_extra"><br></div><div class="gmail_extra">In order for your GetNext() function to work as an iterator function, it should not have any loops, just conditionals:</div><div class="gmail_extra"><br></div><div class="gmail_extra">if ->GetNextExtent() returns zero, it should reset m_Iter to zero and increment m_Y<br></div><div class="gmail_extra">if m_Y > maxY, it should reset m_Y to zero and increment m_Z</div><div class="gmail_extra">if m_Z > maxZ, it should reset m_Z to zero and return false</div><div class="gmail_extra"><br></div><div class="gmail_extra">Also, maxZ, maxY, and maxX should not be multiplied by two :)</div><div class="gmail_extra"><br></div><div class="gmail_extra"> - David</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 30, 2015 at 8:54 AM, Nil Goyette <span dir="ltr"><<a href="mailto:nil.goyette@imeka.ca" target="_blank">nil.goyette@imeka.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi all,<br>
<br>
I'm using <tt>vtkPolyDataToImageStencil</tt> to get all voxels
index inside of a surface. If I understand correctly, I have only
two choices here:<br>
- <tt>vtkImageStencil</tt> to create a new image<br>
- <tt>vtkImageStencilIterator</tt> to iterate on the values (of
another image)<br>
The problem is, I have a different goal in mind. I need the index of
all voxels inside a surface.<br>
<br>
I read the <tt>vtkPolyDataToImageStencil</tt> code and tried to
create my own "iterator" but there's probably something I don't
understand; <tt>GetNextExtent</tt> always return 0.<br>
<small><tt>bool GetNext(int& x1, int& x2, int& y,
int& z)</tt><tt><br>
</tt><tt>{</tt><tt><br>
// m_Y, m_Z and m_Iter == 0</tt></small><small><tt><br>
int maxX, maxY, maxZ, dump;</tt><tt><br>
</tt><tt> m_ImageStencilData->GetExtent(dump, maxX, dump,
maxY, dump, maxZ);</tt><tt><br>
</tt><tt> maxX *= 2; maxY *= 2; maxZ *= 2;</tt><tt><br>
</tt><tt><br>
</tt><tt> for ( ; m_Z <= maxZ; ++m_Z)</tt><tt><br>
</tt><tt> {</tt><tt><br>
</tt><tt> for ( ; m_Y <= maxY; ++m_Y)</tt><tt><br>
</tt><tt> {</tt><tt><br>
</tt><tt> if (m_ImageStencilData->GetNextExtent(x1, x2, 0,
maxX, m_Y, m_Z, m_Iter))</tt><tt><br>
</tt><tt> {</tt><tt><br>
</tt><tt> y = m_Y; z = m_Z;</tt><tt><br>
</tt><tt> return true;</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> return false;</tt><tt><br>
</tt><tt>}</tt></small><br>
<br>
Is there a way to access all inside-voxels hidden in the <tt>vtkPolyDataToImageStencil</tt>?
By index or by index range, it's not important. I just want to know
to access them without useless work (like creating an image) because
it's gonna be called often; it needs to be fast. Thank you for your
time.<span><font color="#888888"><br>
<br>
Nil<br>
</font></span></div>
<br></blockquote></div><br></div></div>