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

John Biddiscombe biddisco at cscs.ch
Mon Oct 9 09:41:06 EDT 2006


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


-- 
John Biddiscombe,                            email:biddisco @ cscs.ch
http://www.cscs.ch/about/BJohn.php
CSCS, Swiss National Supercomputing Centre  | Tel:  +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 (91) 610.82.82





More information about the vtkusers mailing list