Is UpdateCurrentViewer() ,from AIS_InteractiveContext, thread-safe?

Hello there,

I'm working on MFC samples, specifically, Animation sample but while the fan is moving I cannot do any other functionality like zoom-in, select it... In other words, when I do so the movement of the fan is stopped. 

After searching I get the reason, which is all these functionalities are in the same thread (main thread) alongside the animation process. So, I tried to put the animation process in other thread but when I call  UpdateCurrentViewer() inside the thread, it seems to be invisible to it (maybe it doesn't executed). 

Thanks in advance,

Kirill Gavrilov's picture

Is UpdateCurrentViewer() ,from AIS_InteractiveContext, thread-safe?

No, OCCT classes do not provide any implicit thread-safety, as long as documentation of specific class does not clearly state opposite.

emad samni's picture

thanks Mr.Gavrilov 

I have faced the same problem , would you Suggest any solution  ?

I need to do animation and other functionalities  like rotate and zoom-in at the same time .

thanks again 

Kirill Gavrilov's picture

I would suggest looking into direction of AIS_Animation class for defining animation pipeline in 3D viewer.

TIAN DAJIANG's picture
TopoDS_Shape obj1 = BRepPrimAPI_MakeBox(100, 500, 20);
Handle(AIS_Shape) ais_obj1 = new AIS_Shape(obj1);
g_pDoc->myAISContext->Display(ais_obj1, true);

gp_Trsf start_pnt, end_pnt;
	
start_pnt.SetValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0);
end_pnt.SetValues(1, 0, 0, 100, 0, 1, 0, 100, 0, 0, 1, 100);
	
Handle(AIS_Animation) ais_animation = new AIS_Animation("obj1");
Handle(AIS_AnimationObject) ais_ao = new AIS_AnimationObject("obj1", g_pDoc->myAISContext, ais_obj1, start_pnt, end_pnt);
ais_ao->SetOwnDuration(10);
ais_ao->SetStartPts(0);
	
ais_animation->Add(ais_ao);

double duration = ais_animation->Duration();

ais_animation->StartTimer(0, 1.0, true);

while (!ais_animation->IsStopped())
{
	ais_animation->UpdateTimer();
		
	g_pDoc->myAISContext->UpdateCurrentViewer();
}

I use this code in my product, it can run,but cannot rotation and other interactive, Need other define?

TIAN DAJIANG's picture
TopoDS_Shape obj1 = BRepPrimAPI_MakeBox(100, 500, 20);
Handle(AIS_Shape) ais_obj1 = new AIS_Shape(obj1);
g_pDoc->myAISContext->Display(ais_obj1, true);

gp_Trsf start_pnt, end_pnt;
	
start_pnt.SetValues(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0);
end_pnt.SetValues(1, 0, 0, 100, 0, 1, 0, 100, 0, 0, 1, 100);
	
Handle(AIS_Animation) ais_animation = new AIS_Animation("obj1");
Handle(AIS_AnimationObject) ais_ao = new AIS_AnimationObject("obj1", g_pDoc->myAISContext, ais_obj1, start_pnt, end_pnt);
ais_ao->SetOwnDuration(10);
ais_ao->SetStartPts(0);
	
ais_animation->Add(ais_ao);

double duration = ais_animation->Duration();

ais_animation->StartTimer(0, 1.0, true);

while (!ais_animation->IsStopped())
{
	ais_animation->UpdateTimer();
		
	g_pDoc->myAISContext->UpdateCurrentViewer();
}

I use this code in my product, it can run,but cannot rotation and other interactive, Need other define?

Kadir Canik's picture

Any solution?