
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...
Fri, 04/28/2023 - 05:42
Hello, I am now using the Qt creator to do my project with the OPENCASCADE. However, when I use the code "#include <Handle_Geom_Axis2Placement.hxx>", I got the error that this file is not found. I installed and compiled opencascade with VTK in the latest version. Why I got this problem?
Fri, 04/28/2023 - 09:42
Hello,
Handle_* are artifact classes. They are exist just to use old way to work with OCC smart pointers.
Please ignore Handle_ part. Make #include <Geom_Axis2Placement.hxx>
When you would like to create a new object of this class, use Handle(Geom_Axis2Placement) anAxis2P = new Geom_Axis2Placement();
Best regards, Dmitrii.
Tue, 05/02/2023 - 08:37
Thank you for your response. I changed and it work. However, now I encountered another problem. When I included the header file <AIS_Drawer.hxx>, there is also an error saying the file does not exist. How can I solve this problem?