
Tue, 04/26/2022 - 19:02
Forums:
Dear OCCT Community,
I have added a sphere to a vertex I have chosen in the scene and I am trying to locate a 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(false);
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!
Attachments:
Fri, 05/09/2025 - 13:31
i have the same problem, i try to set the location of my trihedron according to the active grid origin, they end up with an offset somehow, here is the debug:
displayCurrentTrihedron: placement.Location() = 5 5 10
newPlacement Location: 5 5 10
newPlacement Direction: 0 0 1
newPlacement XDir: 1 0 0
GridPlane Origin: 5 5 10
GridPlane Normal: 0 0 1
GridPlane XDir: 1 0 0
GridPlane YDir: 0 1 0
Trihedron Origin: 5 5 10
Trihedron Direction: 0 0 1
Trihedron XDir: 1 0 0
so the position is setup correctly within the trihedron, but it is placed somewhere else somehow.