Select point in AIS_PointCloud

Hello,

Is it possible to select/detect a point in an AIS_PointCloud?

I added an AIS_PointCloud and opened a local context with selection mode TopAbs_VERTEX

 m_hAISContext->CloseAllContexts();
 m_hAISContext->OpenLocalContext();

 m_hAISContext->ActivateStandardMode(TopAbs_VERTEX);

If I hoover over the points with the mouse nothing gets selected/detected. If I don't open a local context the complete PointCloud gets selected/detected

Tried with OCC7.1 and OCC7.3 with new selection mechanism. Both yield the same result, no detection / hilight.

 

 

Kirill Gavrilov's picture

AIS_PointCloud supports detection of points within AIS_PointCloud::SM_Points selection mode, but this mode is designed for selection of entire cloud, not individual points.
AIS_PointCloud has no any BRep vertices, hence TopAbs_VERTEX and other selection modes available for AIS_Shape are not applicable to this presentation.

Though, AIS_PointCloud::SM_SubsetOfPoints has been introduced recently within current development branch (master).

Arjan Schouten's picture

Thanks Kirill, makes sense.

Daniel Duesentrieb's picture

I can selected single points with

m_occView->context()->Display(m_pointsCloud, AIS_PointCloud::DisplayMode::DM_Points, AIS_PointCloud::SM_SubsetOfPoints, true);

but it doesn't matter how many points I select the result from following is always one object:

QList<Handle(AIS_InteractiveObject)> result; Handle(AIS_InteractiveObject) pointCloud;

m_occView->context()->InitSelected();
while( m_occView->context()->MoreSelected() )
{
    pointCloud = m_occView->context()->SelectedInteractive();
    result.append(pointCloud);
    m_occView->context()->NextSelected();
}
return result;

how to get access to the actually selected points?

Thanks!

Kirill Gavrilov's picture

AIS_InteractiveContext::SelectedInteractive() returns interactive object of selected entity, which will be always the same AIS_PointCloud as you have displayed all points with one object. To get point selection results you need requesting AIS_InteractiveContext::SelectedOwner() instead.

In case of a point cloud, this will be AIS_PointCloudOwner object, that have AIS_PointCloudOwner::SelectedPoints() method returning a map of indexes of selected points. The map is defined by TColStd_HPackedMapOfInteger which is a special map optimized for storing 32-bit integers (with more compact memory storage compared to a normal map and it also implements handy Boolean operators between maps).

Emre Demir's picture

Hi Mr. Gavrilov,
I used the classes you mentioned but I could not get any selected point information. I mean I select a point(Selection Mode is SM_SubsetOfPoints) with mouse click but after selection, when I call m_pCloudOwner->SelectedPoints(), it returns empty TColStd_HPackedMapOfInteger map. Before calling SelectedPoints() function, I initialize the owner (m_pCloudOwner = new AIS_PointCloudOwner(m_pointCloud);).

Can you help me?

Thanks,
Emre

Daniel Duesentrieb's picture

Thanks Kirill, got it going.

the boolean operators are indeed handy.

great job guys!