I think I'm hitting some limitations of the AIS module (or the documentation thereof - e.g. how do I display an edge with the orientation indicated).
How doing this with the AIS module of OCCT:
If under “an edge with the orientation indicated” we consider a line with the arrow at the end, AIS_Line is the simplest way to have it. By default, this presentation has no arrow at the end. For visualizing it, just correct attributes in the following way:
the code | the result |
// creating the presentation
Handle(Geom_CartesianPoint) pointA = new Geom_CartesianPoint(50., 50., 0.);
Handle(Geom_CartesianPoint) pointB = new Geom_CartesianPoint(100., 80., 0.);
Handle(AIS_Line) line= new AIS_Line(pointA, pointB);
// switch ON arrow using
line->Attributes()->SetLineArrowDraw( Standard_True);
line ->Attributes()->SetArrowAspect(new Prs3d_ArrowAspect(15./*angle*/, 5./*length*/));
// visualize presentation in context
AISContext->Display (line, Standard_True); |  |
Here, 3D segmented arrow is visualized (constructed with Prs3d_Arrow:: DrawSegments).
At the same time, there are lots of parameters that the custom application requires to settle, like 3D or 2D arrow type, arrow length, angle, thickness and others. So, another and more flexible way is implementing a new presentation by ourselves using the standard approach of OCCT presentations creation (“https://dev.opencascade.org/doc/overview/html/occt_user_guides__visualization.html”, rows “If you are creating your own type…”).
We need to:
- create inheritance from the AIS_InteractiveObject,
- redefine Compute() and prepare graphical elements,
- redefine ComputeSelection() [optional, only if processing of selection is necessary for the presentation]
Samples of other arrow presentations that might be useful to fill Compute() of this custom presentation:
arrow kind | draw command/test (based on OCCT-750) | preview | how to |
Shaded 3D arrow
samples are:
AIS_Trihedron,
AIS_ViewCube,
AIS_Manipulator | vtrihedron t -drawAxes X -hideLabels on -dispmode sh -attribute TubeRadiusPercent 0.005 -color XAxis white -color origin white |  | call Prs3d_Arrow:: DrawShaded() |
2D arrow
sample is:
PrsDim_AngleDimension | tests\v3d\dimensions\angle180 |  | Implement the primitives creation as in PrsDim_Dimension:: DrawExtension() |
some 3D arrows in one presentation
MeshVS_Mesh | tests\v3d\mesh\B7 |  | Implementation is similar to
MeshVS_VectorPrsBuilder:: DrawVector() |
Also, it is always possible to prepare a topology shape that contains the edge and orientation lines and fill AIS_Shape with it.
OCCT visualization toolkit is not a container of presentations for all cases. However, it contains lots of samples of how a presentation of interest might be constructed.