
Tue, 04/29/2008 - 00:58
Hi,
I have got a problem that I think it will be very easy to solve for you.
I have got a hierarchical structure like grandfather, father and son (All of them as TopoDS_Shape). To get that, I have created a compoundSon (with son), compoundFather (with father and compoundSon) and compoundGrandFather (with grandFather and compoundFather).
Doing that, I save those compounds, and I wait for a user input.
I need to translate the grandfather, and rotate parent a son.
My problem is that I don't know why.
Animation sample gives a clue: "Transform AIS_Shape and you will get it"
gp_Trsf trans;
trans.SetTranslation(gp_Vec(x, y, z));
myAISContext->SetLocation(aisGrandFather, trans);
It works, but I don't have aisFather and aisSon. If I create them, I get duplicated objects, of course. This method don't allow me to manage all the objects tree.
Trying with another method, I can't get results.
gp_Trsf trans;
trans.SetTranslation(gp_Vec(x, y, z));
TopLoc_Location toploc_location(trans);
compoundGrandFather.Location(toploc_location);
myAISContext->UpdateCurrentViewer();
If this last method could work, I will apply other gp_Trsf to the other compunds.
Nothing gets translated so, are there a sentence missing? Have I forgotten something?
If I have to replan all, please tell me why I should do it.
Thank you very much.
Tue, 04/29/2008 - 21:50
Ok, my TopoDS_Compound gets translated, even with this code:
gp_Trsf trans;
trans.SetTranslation(gp_Vec(x, y, z));
TopLoc_Location tpTrans(trans);
compoundGrandFather.Move(tpTrans);
or this one
gp_Trsf trans;
trans.SetTranslation(gp_Vec(x, y, z));
BRepBuilderAPI_Transform trsf (trans);
trsf.Perform(compoundGrandFather);
TopoDS_Shape result = trsf.Shape();
if (result.ShapeType() == TopAbs_COMPOUND)
compoundGrandFather= TopoDS::Compound(result);
I know it because if I create a new AIS_Shape and display it, I realize that compound has been translated.
So my original problem is not how to translate, but how to bound my AIS_Shape with the new compound translated or how to refresh AIS_Shape in the viewer.
I thought both objects were linked, and with "myAISContext->UpdateCurrentViewer();" instruction was enough.
Thanks in advance.
Thu, 05/01/2008 - 13:29
Unique way to get my goal I found is:
myAISContext->Remove(aisMachine, Standard_False());
aisMachine->Set(machineAll);
aisMachine= new AIS_Shape(machineAll);
myAISContext->SetMaterial(aisMachine,Graphic3d_NOM_GOLD);
myAISContext->SetDisplayMode(aisMachine,1,Standard_False);
myAISContext->Display(aisMachine, Standard_False);
myAISContext->SetCurrentObject(aisMachine,Standard_False);
I remove the aisObject and recreate again. I think this method will have a poor performance, and not only that, it flickers a lot.
Resolved (I think in a bad way) compoundGrandFather translation. I make the same to rotate compoundFather and I get no results :(
I think it is a simple task: To animate a typical 5X machine.
Please, I pray for any hint. A valid hint is to tell me it is impossible.
I am getting crazy with this problem...
Tue, 05/06/2008 - 17:28
Hello,
Your topic helped me to understand how to translate a TopoDS_Shape and its associated AIS_Shape.
However, recreating the AIS_Shape was not acceptable for my needs, so I looked a bit forward, and found the following solution:
// Translate the TopoDS_Shape
gp_Trsf tsf;
tsf.SetTranslation ( gp_Vec ( iX,iY,iZ ) );
topoDS_Shape.Move ( TopLoc_Location ( tsf ) );
// Update AIS_Shape whith the 2 following lines:
hAIS_Shape->Set ( topoDS_Shape );
hAIS_Shape->Redisplay( Standard_True );
Hope it will help you if you did not find any way since you wrote this topic
Have a good day,
Nicolas Berron