[vtkusers] "reverse lookup" in vtkDataArray
David Doria
daviddoria+vtk at gmail.com
Fri Aug 20 09:56:28 EDT 2010
I currently have the "forward mapping" from "new id" to "old id":
vtkIdTypeArray* originalIds =
vtkIdTypeArray::SafeDownCast(selected->GetPointData()->GetArray("vtkOriginalPointIds"));
for(vtkIdType i = 0; i < originalIds->GetNumberOfTuples(); i++)
{
std::cout << "Point " << i << " was originally point " <<
originalIds->GetValue(i) << std::endl;
}
If I want the reverse mapping, i.e. "Which new id corresponds to original id
X?", is there a better way to do it than a linear search through the array?
for(vtkIdType i = 0; i < originalIds->GetNumberOfTuples(); i++)
{
if(originalIds->GetValue(i) == X)
{
cout << "current ID corresponding to original ID X is " << i << endl;
}
}
This seems horribly inefficient!
Thanks,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100820/620bf41c/attachment.htm>
More information about the vtkusers
mailing list