[vtkusers] how to use PolyData::GetPolys()?
John Biddiscombe
biddisco at cscs.ch
Wed Oct 11 04:48:21 EDT 2006
Dominik
> Thanks a lot for the hints, but after your previous hints I was not
> copying anything already. There were two things:
>
> 1) To use e.g.
> const double* p1 =
> (double*)(polydata->GetPoints()->GetData())->GetVoidPointer(3*id1);
>
> instead
> const double* p1 =
> vtkDoubleArray::SafeDownCast(polydata->GetPoints()->GetData())->GetPointer(3*id1);
>
>
> Somehow this works twice faster for me, maybe tricks g++ does to -Ox
> switches
The SafeDownCast method uses string comparisons from the
vtkXXX::GetClassName() and queries a lot of unnecessary stuff, but is in
general safer
You should only ever call it once at the start of an execution. If you
are executing many times on small data then this would be a performance
hit and the (double*) or static_cast<double*> would be a better option.
Note that vtkXXX::SafeDownCast should internally be replaced with
somthing using dynamic_cast<...> but when it was first included not all
compilers supported dynamic_cast (and it is possible to turn off rtti in
the compiler which would break it I expect).
JB
More information about the vtkusers
mailing list