[vtkusers] quadratic comparison of points in a polyData mesh, a faster way?

David Gobbi david.gobbi at gmail.com
Mon Feb 1 16:07:54 EST 2010


Hi Ryven,

The GetPoint() method involves a virtual method call, since it needs
some way to resolve whether the underlying data is double or float.
You can increase the efficiency by calling points->GetData() in order
to get the underlying data array:

vtkDoubleArray *doubleArray = vtkDoubleArray::SafeDownCast(points->GetData());
vtkFloatArray *floatArray = vtkFloatArray::SafeDownCast(points->GetData());

if (doubleArray != NULL)
  {
  // write a loop that uses doubleArray->GetTupleValue() to get each point
  }
else if (floatArray != NULL)
  {
  // write a loop that uses floatArray->GetTupleValue() to get each point
  }

By doing this, you will be calling the inline method "GetTupleValue()"
instead of the virtual method "GetPoint()".  You can go even further
by calling GetPointer() on the array to get a pointer to the
underlying floats or doubles, but that probably won't be any more
efficient that the inline GetTupleValue() methods.

   David





On Mon, Feb 1, 2010 at 1:34 PM, Ryven <swifteye at gmail.com> wrote:
> Hi
>
> Currently i'm doing a embedded for loop comparison of points in a mesh
> (points->GetPoint(i)) to compare them for equality (i need to make a list of
> identical points). I'm not necessary trying to remove identical points, so
> just using the vtkClean class is no good, all i really want to do is be able
> to identify these points. Currently it's pretty slow, just looping through
> (it seems to act like a linkedList?).
>
> My question is if there's a faster way of accessing data in the points array
> to do comparisons?
>
> Thanks
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>



More information about the vtkusers mailing list