<div class="gmail_quote">On Mon, Feb 1, 2010 at 4:07 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Ryven,<br>
<br>
The GetPoint() method involves a virtual method call, since it needs<br>
some way to resolve whether the underlying data is double or float.<br>
You can increase the efficiency by calling points->GetData() in order<br>
to get the underlying data array:<br>
<br>
vtkDoubleArray *doubleArray = vtkDoubleArray::SafeDownCast(points->GetData());<br>
vtkFloatArray *floatArray = vtkFloatArray::SafeDownCast(points->GetData());<br>
<br>
if (doubleArray != NULL)<br>
{<br>
// write a loop that uses doubleArray->GetTupleValue() to get each point<br>
}<br>
else if (floatArray != NULL)<br>
{<br>
// write a loop that uses floatArray->GetTupleValue() to get each point<br>
}<br>
<br>
By doing this, you will be calling the inline method "GetTupleValue()"<br>
instead of the virtual method "GetPoint()". You can go even further<br>
by calling GetPointer() on the array to get a pointer to the<br>
underlying floats or doubles, but that probably won't be any more<br>
efficient that the inline GetTupleValue() methods.<br>
<br>
David<br>
<div><div></div><div class="h5"><br>
<br>
<br>
<br></div></div></blockquote><div class="gmail_quote"><br></div><div class="gmail_quote">Ryven,</div><div class="gmail_quote"><br></div><div class="gmail_quote">When you try this, can you report the resulting speed increase? Maybe you could setup a little experiment where all you do is read the data and iterate through all the points and let us know the timing of each?</div>
<br clear="all">Thanks,<br><br><div>David</div></div>