-
Returned Data query
Hi guys
I'm a c++ newbie and am having issues with returned data.
In the documentation of the toolkit I'm using I'm provided with the following method:
SbBool SoVolumeData::getVolumeData ( SbVec3s & dimension,
void *& data, SoVolumeData:: DataType & type, int * numSignificantBits = NULL
)
Im trying to use the following code to get info pulled back but cant get this to work:
Code:
SoVolumeData *volData = new SoVolumeData();
volData->fileName.setValue("./Data/WORSLEY-MAN.am");
SbVec3s volDims = NULL;
SoVolumeData *ptoData;
SoVolumeData::DataType dtype ;
int sigBits =0;
volData->getVolumeData(volDims, ptoData, dtype, sigBits);
Upon compiling I get the following error msg:
error C2664: 'getVolumeData' : cannot convert parameter 2 from 'class SoVolumeData *' to 'void *& '
A reference that is not to 'const' cannot be bound to a non-lvalue
Any ideas what I need to alter in my code to resolve this...
Thanks
-
That's interesting. You don't see void pointers used much in C++. Anyway, the problem is that the pointer-to-T to pointer-to-void conversion results in an rvalue. You can't have a reference to an rvalue, so the function call is ill-formed. It also means that an explicit cast is also not going to work for the same reason.
The only way I can think of at the moment to work around this particular problem without changing the parameter list of the function in question is to use a void pointer first, then point ptoData to it after the function call:
Code:
void *vptoData;
volData->getVolumeData(volDims, vptoData, dtype, sigBits);
SoVolumeData *ptoData = static_cast<SoVolumeData*>(vptoData);