select face, interrupt!

I use the following code to select a face but the program crash! why? thanks!
myAISContext->CloseAllContexts();
myAISContext->OpenLocalContext();
myAISContext->ActivateStandardMode(TopAbs_FACE);

Paul Jimenez's picture

Hi,

Does it always happen, or only under some circumstances?

I'm facing the same problem, but only after having modified a shape. It seems to depend on how I modify it. It happens after a Fuse operation for me, but only in some cases.

P Dolbey's picture

I think I had a similar problem - I found that I needed to wrapp the CloseAllContexts within a HasOpenedContext test - sample code below. It might fix your problem.

Pete

bool QoccController::hasLocalContext( void )
{
return (bool) myContext->HasOpenedContext();
}

void QoccController::clearLocalContext( void )
{
if (hasLocalContext())
{
myContext->ClearLocalContext();
myContext->CloseLocalContext();
}
}

void QoccController::clearAllLocalContexts( void )
{
if (hasLocalContext())
{
myContext->CloseAllContexts();
}
}

void QoccController::setLocalContext( TopAbs_ShapeEnum lcType )
{
clearLocalContext();
myContext->OpenLocalContext();
myContext->ActivateStandardMode( lcType );
myLcType = lcType;
}

Paul Jimenez's picture

Actually, without any previous open contexts, it also happens. Here's my test case:

//...
m_AISContext = new AIS_InteractiveContext(m_Viewer);
m_AISContext->SetDisplayMode(AIS_Shaded);
m_AISContext->SelectionColor(Quantity_NOC_YELLOW);

BRepPrimAPI_MakeBox b(200., 100., 50.);
TopoDS_Shell b_1 = b.Shell();

BRepBuilderAPI_MakePolygon p;
p.Add(gp_Pnt(100., 0., 0.));
p.Add(gp_Pnt(100., 100., 0.));
p.Add(gp_Pnt(100., 100., 50.));
p.Add(gp_Pnt(100., 0., 50.));
p.Add(gp_Pnt(100., 0., 0.));

BRepBuilderAPI_MakeFace f(p.Wire(), Standard_True);
TopoDS_Face f_1 = f.Face();

BRepAlgoAPI_Fuse r(b_1, f_1);
TopExp_Explorer ex(r.Shape(), TopAbs_SHELL);
TopoDS_Shell r_1 = TopoDS::Shell(ex.Current());

Handle(AIS_Shape) ais = new AIS_Shape(r_1);
m_AISContext->Display(ais);
m_AISContext->OpenLocalContext();
m_AISContext->ActivateStandardMode(TopAbs_FACE);

I did the same with the Test Harness, and I couldn't get it to crash.

Paul Jimenez's picture

I found that the crash didn't occur in a PC with a SiS 651 chipset, but it happened in one with an Intel 915G. I recompiled OCC in both Debug and Relase modes, then rebuilt my application, and it doesn't crash anymore in the Intel one.

Have you checked that your application is using the right TKOpengl.dll? I used Process Explorer to check that and found it wasn't using the right one in Debug mode.