For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Drawing voxels problem - VoxelClient_VisDrawer

Julio Alberto's picture
Forums: 

Hello.

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)
return 0;

// Retrieve the user structure
Voxel_VisData* aUserData = (Voxel_VisData*) (theUserDraw->Data);

if (aUserData == 0)
return 0;

VoxelClient_VisDrawer::VisElement *aElem =
new VoxelClient_VisDrawer::VisElement (aUserData);

if (theUserDraw->Bounds != 0)
aElem->EvaluateBounds (*(theUserDraw->Bounds));

return aElem;
}

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.

Pawel's picture

Hello Julio,

from your description it's hard to say why the problem occurs but my guess is that the VoxelClient_VisDrawer is not correctly initialized.

Pawel

Julio Alberto's picture

Thanks.

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.

Julio Alberto's picture

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?

Pawel's picture

maybe you create a new 'myGraphicDriver' when initializing the voxel viewer instead of using the existing one...

Pawel

Julio Alberto's picture

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.

Handle_V3d_Viewer myViewer;
Handle(V3d_View) myView;
Handle(AIS_InteractiveContext) myAISContext;
Handle_OpenGl_GraphicDriver myGraphicDriver;
static Handle(Graphic3d_GraphicDriver) Viewer_aGraphicDriver;

bool OCCViewer::InitViewer(void * wnd)
{
if (myGraphicDriver.IsNull())
{
if (Viewer_aGraphicDriver.IsNull())
{
Handle (Aspect_DisplayConnection) aDisplayConnection;
Viewer_aGraphicDriver = Graphic3d::InitGraphicDriver (aDisplayConnection);

}
myGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast(Viewer_aGraphicDriver);

}

TCollection_ExtendedString a3DName("Visu3D");
myViewer = new V3d_Viewer (myGraphicDriver, a3DName.ToExtString(),"", 1000.0,
V3d_XposYnegZpos, Quantity_NOC_BLACK,
V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT,
Standard_True, Standard_False);
myViewer->Init();

myViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);

myView = myViewer->CreateView();
myAISContext = new AIS_InteractiveContext(myViewer);
myAISContext->SetDeviationCoefficient(1.e-3);

Handle(WNT_Window) hWnd = new WNT_Window (reinterpret_cast (wnd));

myView->SetWindow(hWnd);
if(!hWnd->IsMapped())
hWnd->Map();

myView->MustBeResized();
myView->SetSurfaceDetail(V3d_TEX_NONE);
myView->SetTransparency(Standard_True);
myView->SetSize(10000.0);
myView->SetZSize(10000.0);
myView->SetViewMappingDefault();

myView->ZBufferTriedronSetup();
myView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_BLACK, 0.1, V3d_ZBUFFER);

return true;
}

And for initialization:
[...]
VoxelClient_VisDrawer::Init(myGraphicDriver);
[...]

I think that everything is correct, isn't it?

Thanks!

Pawel's picture

Indeed, it looks OK.

Well, the problems seems to be somewhere else ;)

Pawel

Julio Alberto's picture

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.

Julio Alberto's picture

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.

:)

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.