How to change Vertex color

Hi,
I try to change Vertex color, but it is always yellow. my code as following:
TopoDS_Vertex aVex;
Handle(AIS_Shape) aAisShape=new AIS_Shape(aVex);
aAisShape->SetColor(Quantity_NOC_RED);
myCurrentIC->Display(aAisShape);

Sincerely,
Angel

Shawn Yang's picture

Hi Angel:

You want to change vertex color. I think you can take from AIS_Point. I have tried the following code that can successfully make it change.

gp_Pnt P1(20,20,20);
Handle(AIS_Point) aAisPnt = new AIS_Point(new Geom_CartesianPoint(P1));
aAisPnt->SetColor(Quantity_NOC_RED);
myAISContext->Display(aAisPnt);

Hopefully it can help.

Shawn

angel's picture

Hi Shawn,
I know use AIS_Point can change Color, but I don't want to use AIS_Point, I want to use AIS_Shape.

Sincerely,
Angel

Stephane Routelous's picture

Hi,

you have to get the drawer from your AIS_Shape ( aAisShape->Attributes() ).
You get the AIS_Drawer instance used by your InteractiveObject for the display.
Get the Handle_Prs3d_PointAspect with the PointAspect() method of the drawer.
Sett the color of your Handle_Prs3d_PointAspect instance.

Basically:
aAisShape->Attributes()->PointASpect()->SetColor(Quantity_NOC_RED);
myCurrentIC->Display(aAISShape);
*should* work.

HTH

angel's picture

Hi Stephane,
I try your code, but it is not work. I modify it as following, and it is work.

Handle(AIS_Shape) DetAisVex=new AIS_Shape(DetVex);
Handle_Prs3d_PointAspect myPointAspect=new Prs3d_PointAspect(Aspect_TOM_PLUS,Quantity_NOC_RED,1.);
DetAisVex->Attributes()->SetPointAspect(myPointAspect);
myCurrentIC->Display(DetAisVex);

Sincerely,
Angel