[vtkusers] double* GetPoint() doesnt return a pointer but value?

Dominik Szczerba domi at vision.ee.ethz.ch
Mon Oct 9 10:16:41 EDT 2006


John,
Thanks a lot for claryfying that issue. Using:

double* p = 
vtkDoubleArray::SafeDownCast(xxx->GetPoints()->GetData())->GetPointer(3*i);

provides a pointer, as I need it.

Thanks again,
Dominik

John Biddiscombe wrote:
> Dominik
> 
> It only returns a pointer to an internal mini-array - the points array 
> itself might be float or double, so vtkPoints maintains a double p[3] 
> which is what you are getting. For efficiency I'd recommend something 
> more like
> 
> if (xxx->GetPoints()->GetDataType()==VTK_FLOAT)
>      float * data = 
> vtkFloatArray::SafeDownCast(xxx->GetPoints()->GetData())->GetVoidPointer();
> call templated function <float>
> else {
>    double * data = 
> vtkDoubleArray::SafeDownCast(xxx->GetPoints()->GetData())->GetVoidPointer(); 
> 
> call templated function <double>
> }
> 
> this way you can process a lot of data much faster and work directly on 
> the actual data. Note that if you are processing your own data and you 
> know it is always double, just skip the checks.
> 
> Note also that modifying the output of a filter is not good if the 
> filter will reexecute and overwrite it.
> 
> Note 3  - the above was from memory and undoubtedly contains mistakes.
> 
> JB
> 
>> Hi,
>> I call double* p = vtkPolyData::GetPoints()::GetPoint(id) and expect 
>> it to return a pointer to double but it clearly is a value. I.e. I 
>> modify the result but the only way to see my polydata modified is to 
>> call vtkPolyData::GetPoints()::SetPoint(). The docu says 'p' should be 
>> a pointer, but vtkDataArrayTemplate seems to be copying the values. 
>> What's up?
>> Thanks a lot,
>> Dominik
> 
> 

-- 
Dominik Szczerba, Ph.D.
Computer Vision Lab, ETH
http://www.vision.ee.ethz.ch/~domi



More information about the vtkusers mailing list