
Wed, 04/27/2022 - 00:17
Forums:
Dear OCCT Community,
I have added a sphere to a vertex I have chosen in the scene and I am trying to locate an AIS_Trihedron at the origin of this sphere. The direction information is correct, but its position is far from where I set it and it is drawn. I've added the image about this issue and I am sharing my method below:
void VisualizerWidget::createTrihedronWithOriginPoint(TopoDS_Shape ais_shape, gp_Pnt origin_xyz)
{
gp_Ax2 Position;
Position.SetLocation(origin_xyz);
Handle_Geom_Axis2Placement axis = new Geom_Axis2Placement(Position);
Handle_AIS_Trihedron aisTrihedron = new AIS_Trihedron(axis);
aisTrihedron->SetDatumDisplayMode(Prs3d_DM_WireFrame);
aisTrihedron->SetDrawArrows(true);
aisTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_XAxis)->SetWidth(2.5);
aisTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_YAxis)->SetWidth(2.5);
aisTrihedron->Attributes()->DatumAspect()->LineAspect(Prs3d_DP_ZAxis)->SetWidth(2.5);
aisTrihedron->SetDatumPartColor(Prs3d_DP_XAxis, Quantity_NOC_RED2);
aisTrihedron->SetDatumPartColor(Prs3d_DP_YAxis, Quantity_NOC_GREEN2);
aisTrihedron->SetDatumPartColor(Prs3d_DP_ZAxis, Quantity_NOC_BLUE2);
aisTrihedron->SetLabel(Prs3d_DP_XAxis, "X");
aisTrihedron->SetLabel(Prs3d_DP_YAxis, "Y");
aisTrihedron->SetLabel(Prs3d_DP_ZAxis, "Z");
aisTrihedron->SetTextColor(Quantity_NOC_BLACK);
aisTrihedron->SetSize(60);
aisTrihedron->SetTransformPersistence(
new Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, axis->Ax2().Location()));
aisTrihedron->Attributes()->SetZLayer(Graphic3d_ZLayerId_Topmost);
aisTrihedron->SetInfiniteState(true);
ais_interactive_context_->Display(aisTrihedron, true);
}
I haven't figured out where I went wrong yet. If you have any suggestions for a solution about this issue, I'm looking forward to hearing. Thank you in advance!
Wed, 04/27/2022 - 08:36
Check the documentation of Graphic3d_TransformPers. It requires an extra caution when it comes to location. So that if you want to use Graphic3d_TMF_ZoomPers, you need defining object's origin as identity and pass this point to Graphic3d_TransformPers.
Sun, 05/15/2022 - 22:37
Thank you very much for your reply to my question. Thanks to your blog, I am now able to change the location of the AIS_Trihedron. However, I couldn't change its rotation, I'm probably missing a point again.
Normally, if I would like to change a TopoDS_Shape, I use below implementation (and it works correctly):
But if I would like to rotate the AIS_Trihedron, I am not able to rotate it. How can I change the rotation of AIS_Trihedron? Or how can I convert/transform the AIS_Trihedron to TopoDS_Shape? Like below implementations, is it possible convert AIS_Trihedron to TopoDS_Shape?
Example 1: TopoDS_Shape topods_sphere_shape = BRepPrimAPI_MakeSphere(origin_xyz, sphere_radius).Shape();
Example 2:TopoDS_Shape topods_box_shape= BRepPrimAPI_MakeBox(10, 20, 30).Shape();
Best regards and thank you!
Sun, 05/15/2022 - 23:34
Hello again, Please ignore the previous message I wrote, because there are many logic errors there. If I had set setDirection like I set setLocation I could see the rotation of AIS_Trihedron changed and now I've managed to do this.
My aim was to change the main AIS_Trihedron of the Scene only with mouse movements or with AIS_ViewCube; while the AIS_Trihedron above the selected vertex I was able to move independently of the main AIS_Trihedron of the scene. Anyway, my problem and question have been solved.
Thank you again for all your support...