H3D.org Forum Index Programming Issues
Issue using auto_ptr< SFVec3f> to get Vec3f | Register To Post |
| Threaded | Newest First | Previous Topic | Next Topic | Bottom |
| Poster | Thread |
|---|---|
| GBaitson | Posted on: 2010/2/2 13:04 |
Quite a regular ![]() ![]() Joined: 2009/5/19 From: National Digital Research Centre Posts: 25 |
Issue using auto_ptr< SFVec3f> to get Vec3f We are using ImageObjectInfo->totalSize to get the size of a Image3DTexture volume. The problem is that this returns an auto_ptr< SFVec3f >. We would like to be able to access the x, y and z dimensions but they are coming back as 0, 0 and 0.
We know that they are not zero as when we route the ImageObjectInfo->totalSize to a PythonScript and reference them with size.x, etc. they are giving us the true values. Is there anyway we can get access to the correct x y and z dimensions from the auto_ptr data type using C++/CPP? Also in relation to attempt 1, is there a reason why you can't use '.release' to dereference an auto_ptr? |
| Markus | Posted on: 2010/2/3 8:40 |
Webmaster ![]() ![]() Joined: 2006/3/27 From: SenseGraphics Posts: 1531 |
Re: Issue using auto_ptr< SFVec3f> to get Vec3f Where did you get the idea that totalSize->getValue returns an auto_ptr< SFVec3f >? If it says so in some documentation I would like to know in order to correct it. The getValue function of an SFVec3f returns a Vec3f.
Try this: If you get the value and store it in an auto_ptr then you steal the reference from the class. Which means that the class can no longer access that field. So you should get a run time error of some kind. The only function you should use of the auto_ptrs belonging to a node/class is .get(). Unless you are in the class and really really want to change something. If you use release then you need to have access to the pointer from somewhere else so that you can properly free memory later. Are you saying that release does nothing in your case? It should cause problems later when running the program. |
| GBaitson | Posted on: 2010/2/3 12:12 |
Quite a regular ![]() ![]() Joined: 2009/5/19 From: National Digital Research Centre Posts: 25 |
Re: Issue using auto_ptr< SFVec3f> to get Vec3f Hi Markus,
Thank you for your response. On mouse over of the imageInfo->totalSize function in Visual Studio Intellisense, it states that it returns an auto_ptr< SFVec3f >. The imageInfo->totalSize is passed into the PythonScript and then set as size = routes_in[0].getValue(). Then on printing this value in the PythonScript (i.e. print size.x), we are returned with the true x dimension (e.g. 0.3355). The problem is that when we try to print the same value in the C++ part of the program, we are returned with zero dimension. We know imageInfo->totalSize->getValue(); does say it returns a Vec3f but wen we try to read the values we get 0,0,0. When we use either of the code suggestions that you stated, Vec3f image_info = imageInfo->totalSize->getValue(); or const Vec3f &image_info = imageInfo->totalSize->getValue(); and then go to print the x dimesion (e.g. cout << image_info.x), we get zero. Have you any suggestions on why this is happening, or how to get the correct value? |
| Markus | Posted on: 2010/2/3 12:40 |
Webmaster ![]() ![]() Joined: 2006/3/27 From: SenseGraphics Posts: 1531 |
Re: Issue using auto_ptr< SFVec3f> to get Vec3f Check that myImage3DTexture->image->getValue(), where "myImage3DTexture" is taken from your example, does not return 0. If it return 0 (and you have set an url) then the image is not loaded, and imageInfo can not update its fields.
If image->getValue() is zero (which I am pretty sure that it is) then there are two things you could do. 1. Set X3DTextureNode::load_images_in_separate_thread to false. 2. Route from myImage3DTexture->image to your specialized field to only try to get the size when the image is finally loaded. |
| GBaitson | Posted on: 2010/2/3 14:23 |
Quite a regular ![]() ![]() Joined: 2009/5/19 From: National Digital Research Centre Posts: 25 |
Re: Issue using auto_ptr< SFVec3f> to get Vec3f Thanks for your suggestions.
That was the problem, myImage3DTexture->image->getValue() was returning zero. By setting 'X3DTextureNode::load_images_in_separate_thread = false' before the url was set, fixed this problem. Then in order to get the dimensions, we just used myImage3DTexture->textureSize().x Thanks very much for you help |
| Threaded | Newest First | Previous Topic | Next Topic | Top |
| Register To Post | |



