Wed, 06/26/2013 - 16:54
I have successfully tested the "voxeldemo" sample, located in the samples folder of OCC6.6, but now I am trying to create my own code to draw voxels but the next function in VoxelClient_VisDrawer is failing:
static OpenGl_Element* VisDrawerCallBack (const Graphic3d_CUserDraw* theUserDraw)
if (theUserDraw == 0)
// Retrieve the user structure
Voxel_VisData* aUserData = (Voxel_VisData*) (theUserDraw->Data);
if (aUserData == 0)
VoxelClient_VisDrawer::VisElement *aElem =
new VoxelClient_VisDrawer::VisElement (aUserData);
if (theUserDraw->Bounds != 0)
Everything goes fine until returns... Checking in debug mode, "aElem" contains an "OpenGl_Element" and "myHandler" atributes but in my code, myHandler is correctly initialized but OpenGl_Element is nothing; in debug mode says: "this secondary value (OpenGl_Element) cannot be evaluated".
I don't know what I am doing wrong and I am a bit lost right now. My code is in a DLL and I can draw igs shapes and detect voxels with the mouse cursor in a panel without problems, only drawing voxels is failing in my project.
(I am using c++ and visual studio 2008).
Please let me know if you need more information.
Wed, 06/26/2013 - 17:12
from your description it's hard to say why the problem occurs but my guess is that the VoxelClient_VisDrawer is not correctly initialized.
Wed, 06/26/2013 - 17:34
It seems you are right, I have just checked it. The value of myGraphicDriver, in my proyect, lacks one value that is present in the same variable in voxeldemo: "__vfptr" and that atribute is also missing in aElem.
I will check where is the problem in my code.
Thu, 06/27/2013 - 16:59
Still no luck.
I have seen that, in mi code, the attribute "entity" (Handle_Standard_Transient) of myGraphicDriver is different in comparison with the same attribute in voxeldemo sample. Is that normal or should they be equal?
Thu, 06/27/2013 - 17:08
maybe you create a new 'myGraphicDriver' when initializing the voxel viewer instead of using the existing one...
Thu, 06/27/2013 - 17:25
I use the same for my proyect :)
This is a bit of my code that initializes the viewer and voxel viewer (all of this is in the same .cpp):
Some declarations could be missing here, but they are in my code and everything compiles well.
static Handle(Graphic3d_GraphicDriver) Viewer_aGraphicDriver;
bool OCCViewer::InitViewer(void * wnd)
Handle (Aspect_DisplayConnection) aDisplayConnection;
Viewer_aGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);
myGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast(Viewer_aGraphicDriver);
myViewer = new V3d_Viewer (myGraphicDriver, a3DName.ToExtString(),"", 1000.0,
myView = myViewer->CreateView();
myAISContext = new AIS_InteractiveContext(myViewer);
Handle(WNT_Window) hWnd = new WNT_Window (reinterpret_cast (wnd));
myView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_BLACK, 0.1, V3d_ZBUFFER);
And for initialization:
I think that everything is correct, isn't it?
Thu, 06/27/2013 - 18:22
Indeed, it looks OK.
Well, the problems seems to be somewhere else ;)
Thu, 06/27/2013 - 21:37
Yes and that is bad for me hehe.
I have managed to catch the runtime error, and the exception says:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
I am going to see whats happening.
Fri, 06/28/2013 - 17:17
Very good news. I have solved the problem.
It was memory allocation problem with tbb... I was using the 3º party tools dlls in the same directory of my proyet (I copied and pasted them) but now I set the PATH variable with the location of that dlls and it is working fine.