problem of visualization of TopoDS_Shape

I have an object of type TopoDS_Shape. Now I wanted to visualize this data, which classes I can use, I searched the forum, I try the sample codes in forum but they were not working. Is there any thread or any classes you could advice?

Thank you already.

Marco Nanni's picture

Hello Canan,

Give a look to the doc visu at "4. 2. 4 Create an interactive context".
I assume you have already set up a window, a viewer, a view, and an ais interactive context. If not, look as well some page backward.

Cheers,
Marco.

canangunicen's picture

Thank you Marco.
I will be grateful if you help me with problem below.

After I saw your post,

Handle(Graphic3d_WNTGraphicDevice) TheGraphicDevice = new Graphic3d_WNTGraphicDevice();
TCollection_ExtendedString aName("3DV");
Handle (V3d_Viewer) myViewer;
myViewer = new V3d_Viewer ( TheGraphicDevice, aName.ToExtString(), "");

myViewer->SetDefaultLights();
myViewer->SetLightOn();

Handle ( WNT_Window) aWNTWindow;
aWNTWindow = new WNT_Window(TheGraphicDevice, theApp.m_pMainWnd->GetSafeHwnd());
Handle(V3d_View) myView = myViewer->CreateView();
myView->SetWindow(aWNTWindow);

StlAPI_Reader reader;
TopoDS_Shape aShape;
std::string filename = "flank_original.tcl";
reader.Read(aShape, (char*)filename.c_str());

Handle(AIS_InteractiveContext) myAISContext = new AIS_InteractiveContext(myViewer);
Handle(AIS_Shape) aAISShape = new AIS_Shape(aShape);
myAISContext->Display(aAISShape);

I created this code piece, but there is a problem with this line :

Handle(Graphic3d_WNTGraphicDevice) TheGraphicDevice = new Graphic3d_WNTGraphicDevice();

The error says unhandled exception. Btw I am running MFC application.

What can be the problem?

Thank you already!
Canan.

Marco Nanni's picture

Hello Canan,

This should work well.

I never used MFC, but I usually you do not use the macro Handle() to declare the type:

Could you try insteed:

Handle_Graphic3d_WNTGraphicDevice TheGraphicDevice = new Graphic3d_WNTGraphicDevice();

I guess you forget to import Standard_Macro.hxx.

Cheers,

Marco.

canangunicen's picture

Hi Marco,

I guess you forgot something here, what will I try instead :

Handle_Graphic3d_WNTGraphicDevice TheGraphicDevice = new Graphic3d_WNTGraphicDevice();

Btw I also included Standard_Macro.hxx but it didn't work.

What do you recommend to use instead of MFC?

I know I am keeping you busy and I am sorry, but I hope you can help.

Cheers,

Canan.

Marco Nanni's picture

No problem Canan,

MFC is not the problem, I would stay with it.

It is like you have an initialization problem. Try to study the samples. There is one very good based on MFC. You will find it in the binary distribution as well (under samples).

I am sorry but, as I do not use MFC, I cannot help you further.

Cheers,

Marco.

shmsh's picture

Dear Canan Gunicen

I also tried to do the same thing but it did not work ...
did you get a solution for that ???
if you got it kindly post it ???
I'm also using MFC , and when i try to debug it ,it gives me an error of
"First-chance exception at 0x75c0c41f in CIRCLE.exe: Microsoft C++ exception: Aspect_GraphicDeviceDefinitionError at memory location 0x002ae98c..
Unhandled exception at 0x75c0c41f in CIRCLE.exe: Microsoft C++ exception: Aspect_GraphicDeviceDefinitionError at memory location 0x002ae98c.."

Regards

Marco Nanni's picture

Hello Canan,

try to put as well after SetWindow(aWNTWindow):

if (!aWNTWindow->IsMapped()) aWNTWindow->Map();

Cheers,

Marco.