Ryven,<div><br></div><div>Are you looping through each point and doing an exhaustive search through the remaining points for equality? If so, you might want to try one of the locators. vtkPointLocator for example. They use a spatial decomposition to limit the number of points that must be tested to find the closest point.</div>
<div><br></div><div><a href="http://www.vtk.org/doc/nightly/html/classvtkPointLocator.html">http://www.vtk.org/doc/nightly/html/classvtkPointLocator.html</a></div><div><br></div><div><a href="http://www.vtk.org/doc/nightly/html/classvtkPointLocator.html"></a>- Wes<br>
<br><div class="gmail_quote">On Mon, Feb 1, 2010 at 4:18 PM, David Doria <span dir="ltr"><<a href="mailto:daviddoria%2Bvtk@gmail.com">daviddoria+vtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div class="im">On Mon, Feb 1, 2010 at 4:07 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">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><br>
<br>
<br>
<br></div></div></blockquote><div class="gmail_quote"><br></div></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><font color="#888888"><br><div>David</div></font></div>
<br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/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" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>Technical Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4920<br>
</div>