
Tue, 03/04/2025 - 19:01
Hi!
I am drawing huge shapes by loading measures with a lot of vertices (over 5 million). Given the amount of vertices, instead of generating a face for every triangle, I am using a function like this one:
//Build face/shape from triangulation
const Handle(Poly_Triangulation) aTris = new Poly_Triangulation(Nodes, Triangles);
auto aBuilder = new BRep_Builder();
aBuilder->MakeFace(TopoDS::Face(mShape), aTris);
With this method, I generate a mShape (TopoDS_Shape) that only contains 1 face from a triangulation with all my vertices.
Right now, if I want to hilight or "select" a group of vertices, the process follows these steps:
- Create a rectangle in 2D viewer
- Generate a Prism using the rectangle as a face ( BRepPrimAPI_MakePrism(face, viewDir) )
- Intersect my model with the prism by checking if my model vertices belong IN or ON the generated prism (cannot use Boolean Intersection from the API)
- Every vertex inside the Prism volume is considered a "selected" vertex, so these will be painted in a different color
This approach fits quite well with my needs... Until now. This method allows me to select vertices even when they are not visible in the viewer (maybe behind other vertices).
But now I would like to modify it. Instead of selecting every vertex inside the prism, I would like to select ONLY those vertices that are visible by me in the viewer.
In other words, I want to create a rectangle to select my vertices, but only the first ones that are "hit" by the intersection prism.
For example, in a closed cylinder, I would like to create my rectangle and only find the vertices in the part of the cylinder I can see, and avoid the vertices in the back of the cylinder.
I have tried some things, but the result always detects all vertices, even if they are behind others.
Could anyone give me some advice to do this?
Tue, 03/04/2025 - 20:38
OCCT Viewer doesn't implement such selection for the moment - either it picks by a ray/pixel with results sorted along the picking ray (
AIS_InteractiveContext::SelectPoint()
), or it picks everything that fits into frustum (AIS_InteractiveContext::SelectRectangle()
/::SelectPolygon()
). Detection mechanism works independently from Visualization, so that it cannot (easily) detect if particular entity is behind another object or not.I can imagine some ways to implement desired filtering of points at application level. The most brute-force approach could be first picking all vertices within frustum (
AIS_InteractiveContext::SelectRectangle()
/SelectMgr_ViewerSelector::Pick()
), then re-perform picking by ray from eye to each detected point (usingSelectMgr_ViewerSelector::Pick()
takinggp_Ax1
on input) to reject vertices having surfaces in front (by comparing depth/distance or other means). Cannot say what kind of performance this approach could show, but it might be not that bad.