Dispaly an Arrow

Hi Guys, I am trying to dispaly an arrow
and this are my codes

gp_Pnt A(10,0,0);
gp_Pnt B(100,0,0);
gp_Vec V(A,B);
gp_Dir dir(V);

Handle(AIS_InteractiveContext) aCtx;
Handle(Prs3d_Presentation) aPresentation = new Prs3d_Presentation (aCtx->CurrentViewer()->Viewer());

Prs3d_Arrow::Draw(aPresentation,B,dir,0.20,1.00);

It crashes, anyone knows what I do wrong?

Thanks!

ATTIA's picture

I have the same problem. I want to display an arrow and I use the same method but it doesn't work

ATTIA's picture

I have used the class Isession_direction in the samples Geometry.
It's work but I have another problem.
I want to change the color of this arrow. I have used myArrow->setColor(Quantity_Noc_Red)
but whaen I run the color appear also yellow et not red.
Thank you

ATTIA's picture

To change the color of line you add this line in the file ISessionDirection.cpp:
aPresentation->Color(aColor);
void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer aMode)
{

//Prs3d_Arrow::Draw(aPresentation,myPnt,myDir,0.20,myArrowLength);
//Handle_Prs3d_LengthAspect myLengthAspect;
Handle(Prs3d_LengthAspect) lengthAspect=new Prs3d_LengthAspect();
//Handle_Prs3d_LineAspect myLineAspect;
Handle(Prs3d_LineAspect) lineaspect= new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_SOLID,1);
lengthAspect->SetLineAspect(lineaspect);
//lineaspect->SetColor(Quantity_NOC_RED);
Handle(Prs3d_ArrowAspect) anArrowAspect = new Prs3d_ArrowAspect(); //myDrawer->ArrowAspect();
anArrowAspect->Aspect()=new Graphic3d_AspectLine3d(Quantity_NOC_RED,Aspect_TOL_SOLID,1);
anArrowAspect->SetColor(Quantity_NOC_RED);
anArrowAspect->SetLength(myArrowLength);
myDrawer->SetArrowAspect(anArrowAspect);
myDrawer->SetLineAspect(lineaspect);
myDrawer->SetLengthAspect(lengthAspect);
//myDrawer->SetColor(Quantity_NOC_RED);
SetColor(Quantity_NOC_RED);
gp_Pnt LastPoint = myPnt ;
LastPoint.Translate (myLength*gp_Vec(myDir)) ;
aPresentation->Color(Quantity_NOC_RED);
if (myText.Length() == 0)
DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myPnt,LastPoint,DsgPrs_AS_LASTAR);
else
{
gp_Pnt OffsetPoint = myPnt;
OffsetPoint.Translate ( (myLength) *gp_Vec(myDir)) ;
DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myText,myPnt,LastPoint, -myDir, OffsetPoint, DsgPrs_AS_LASTAR);
}
}