MakeEdge with Poly_Polygon3D

Hi, Guys!

I'm try to create some lined shape with BRep_Builder. And after creating the resulting shape can't be Picked with StdSelect_ViewerSelector3d. It's don't working if I'm use BRep_Builder::MakeEdge with Poly_Polygon3D, but working on another curves. Object displayed, but can't be selected:

Simple Rectangle:

TopoDS_Shape ResultShape;
TColgp_Array1OfPnt array (1,5); // sizing array


Handle(Poly_Polygon3D) aPolygon = new Poly_Polygon3D(array);

BRep_Builder Brep;
TopoDS_Edge& E = TopoDS::Edge(ResultShape);


After I'm creating a AISPresentation and created rectangle are displayed correctly, but can't be selected.
I'm think may be here is not completed code of StdSelect_ViewerSelector3d. It's very hard to understand because in sources of OCC many inline functions and they are *.lxx in inc directory...

Liang Zhang's picture

Hi, Guy. This is 6 years later.
Did you solve it? I have encountered the same problem recently. I made a TopoDS_Edge using BRep_Builder::MakeEdge() and Poly_Polygon3D. It could't be selected by mouse.
If you have solved it please tell me that. Thanks.

Kirill Gavrilov's picture

If you have found a bug in Open CASCADE Technology - please register it on bug tracker:

Note that the main purpose of Poly_Polygon3D in TopoDS_Edge is providing a (cached) discrete representation of the curve in addition to a main analytic representation (Geom_Curve).
Thus, if you actually need creating a line segment, use another building procedure.

I think that apart from 3D Viewer (which looks like a bug), the edges created solely from Poly_Polygon3D will NOT be processed (correctly) by (most) modeling algorithms of Open CASCADE Technology.

Liang Zhang's picture

Thank your answer very much. I'm sorry to reply so late.

In fact I'm working for a company which mainly sales CNC system, including all-in-one hardware and software. The company wants a new software module which can display and select CNC traces. At first I used AIS_Line to present trace segments. But it took too much memory, about 250MB every 10k lines (use OpenGL es 2.0 to compile). I found use Poly_Polygon3D could save a lot of memory, just 5MB every 10k lines. But it can't be selected by mouse.

Maybe I should transform the mouse coordinate into Opencascade coordinate, and travel local lines data to judge whether a line is selected? It looks like take too much CPU time. The hardware is based on ARM or Intel Atom CPU.

I have struggled for several days for this problem. If I can't find the solution, the company tends to spend money to

buy a software module from outside, sigh…

Kirill Gavrilov's picture

If you are creating a big data set of (poly)lines for visualization purpose only, then creating a custom AIS_InteractiveObject should be a best option (methods ::Compute() and ::ComputeSelection() should be implemented).
You will be able defining primitive arrays in most optimal way eliminating redundant transient copies and define selection in desired way.
But of course, custom presentation would require extra efforts comparing to usage of standard classes (which are optimal for standard tasks).

Liang Zhang's picture

Hi, Kirill. 

Thank your answer very much. I think you are right. It may be the most convenient way to create a custom class inherit​ing AIS_InteractiveObject and implement the ::ComputeSelection(). I haven't found that until you reply. I'll try to do this way.