AIS_PointCloud doesn't show any points

bioan

CAD practitioner
Hello!
In my Open Cascade project I have a class derived from AIS_InteractiveObject which includes a private member: Handle(AIS_PointCloud) aPntCloud;
I like to display the content of this cloud_of_points variable but so far I haven't succeeded.

C++:
Graphic3d_ArrayFlags aArrayFlags = Graphic3d_ArrayFlags_None;
aArrayFlags |= Graphic3d_ArrayFlags_VertexColor;

Handle(Graphic3d_ArrayOfPoints) aPointsArray = new Graphic3d_ArrayOfPoints(6, aArrayFlags);
aPointsArray->AddVertex(gp_Pnt(160, 115, 15), Quantity_Color(Quantity_NOC_MAGENTA));
aPointsArray->AddVertex(gp_Pnt(160, 115, 0), Quantity_Color(Quantity_NOC_MAGENTA));
aPointsArray->AddVertex(gp_Pnt(65, 115, 0), Quantity_Color(Quantity_NOC_MAGENTA));
aPointsArray->AddVertex(gp_Pnt(65, 65, 0), Quantity_Color(Quantity_NOC_MAGENTA));
aPointsArray->AddVertex(gp_Pnt(160, 65, 0), Quantity_Color(Quantity_NOC_MAGENTA));
aPointsArray->AddVertex(gp_Pnt(160, 65, 15), Quantity_Color(Quantity_NOC_MAGENTA));

aPntCloud = new AIS_PointCloud();
aPntCloud->SetPoints(aPointsArray);

When I try to display the cloud_of_points using GetContext()->Display(aPntCloud, false); nothing is displayed on the screen.
The Display() method is invoked inside Compute() method of my AIS_InteractiveObject class.
Instead when I move the cursor in the vertexes region, the bounding box of the entire cloud is displayed all the time.
What is wrong?
What can be done to properly display the cloud_of_points?
Any idea is welcome!
Thank you!
 

bioan

CAD practitioner
It turned out that the points are displayed but they are very small - 1 pixel. How can I change the visual aspect of an AIS_PointCloud like marker, color and the size?
 

natalia

CAD community veteran
Hi @bioan

When you move over the vertices, you see the bounding box of the entire cloud. The reason is the next row in AIS_PointCloud’s constructor:

C++:
SetHilightMode (AIS_PointCloud::DM_BndBox);

To be able selecting a separate point, we need call this method with ‘DM_Points’ parameter.

To change color of AIS_PointCloud presentation use SetColor. The result of change color:

pointcloud_point_color_shaded.png

Regarding markers or size setting, this presentation need customization to do so. The default implementation uses shading aspect in Compute, we need redefine Compute and use point aspect instead:

C++:
Compute(…)
{
  Handle(Graphic3d_Group) aGroup = prs->NewGroup();
  aGroup->SetGroupPrimitivesAspect (Attributes()->PointAspect()->Aspect());
  aGroup->AddPrimitiveArray (aPoints);
}

After this, we may change markers/size parameters of this aspect:

C++:
prs->Attributes()->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_O_PLUS, Quantity_NOC_DARKGOLDENROD, 1))

The result will be the next:
pointcloud_point_color_point.png
Regards, Natalia
 

bioan

CAD practitioner
Thank you very much Natalia!!!
It works just perfect!
One more question here: when I modify the SetHilightMode to use DM_Points parameter, a small blue cross is displayed above each selected point. Is this marker customizable? I like to display other type of marker, like a sphere and with a different color when I highlight or select the point.
Best regards!
Ioan
 

natalia

CAD community veteran
hi @bioan
try to change property defined in AIS_PointCloud constructor:
C++:
myDynHilightDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_CYAN1, 1.0));

Regards, Natalia
 
Top