SIGABORT/terminate thrown in AISInteractiveContent::SelectPoint()

Whilst processing selection from mouse-clicks, I've notice that if I click the same object twice (in my case a Point): aka I select something which is already selected, SelectPoint() throws a SIGABORT and dies.

Alas, I don't have the debug OCCT build running. Before I dive into this further, has anyone seen this before or can take a guess why?

I've attached a picture showing the backtrace.

Running 7.8.2

Mat

Dmitrii Pasukhin's picture

Hello. Could you please attach your small sample as a code. It is looke a bug. For sure you can check that object are selected or not as a workaround. But crash should not be exist.

And if possible, create an issue: https://github.com/Open-Cascade-SAS/OCCT/issues/new?assignees=&labels=2....

Best regards, Dmitrii 

Mat Maher's picture

Thanks Dmitrii,

Before posting as a bug, I rebuilt the OCCT libraries in Debug mode and its led me down some more paths. It seems I'm getting exceptions throw way before I get to this point, they just aren't showing up.

My application uses the mouse input to insert points, then lines between them, to build shapes. I use the mouse-move events to dynamically redraw the line from the previous point, until the user clicks and 'locks it' into place. The big problem I've got is that any line will always start with the same start and end points (because the mouse will always be hovering over it). This causes an exception to be thrown in

inline gp_Dir::gp_Dir (const gp_XYZ& theXYZ)
{
  Standard_Real aX = theXYZ.X();
  Standard_Real aY = theXYZ.Y();
  Standard_Real aZ = theXYZ.Z();
  Standard_Real aD = sqrt (aX * aX + aY * aY + aZ * aZ);
  Standard_ConstructionError_Raise_if (aD <= gp::Resolution(), "gp_Dir() - input vector has zero norm");
  coord.SetX (aX / aD);
  coord.SetY (aY / aD);
  coord.SetZ (aZ / aD);
} 

which is called from AIS_Line::ComputeSegmentLine()

I can't for the life of my think of a way to get around this at application level: there will always be a possibility of a zero-vector line, because no matter where I start from, its user-controlled (the mouse). I'm wondering if this is still a bug, as a zero-vector line isn't actual an invalid case (just an odd one) - it seems a little overkill to be throwing an exception on.

Appreciate your thoughts?

Mat

gkv311 n's picture

...which is called from AIS_Line::ComputeSegmentLine()

One may conclude from AIS_Line name that this presentation is defined to display an infinite line (clipped to some segment for viewing purposes). And line cannot be defined between two identical points...

While it might be nice if AIS_Line would catch this and emit some error or throw exception in AIS_Line::Points() instead of ::Compute() - that wouldn't make it make much a difference for your use case. Instead, you may use AIS_Shape for the same purposes.

gp_Pnt thePnt1 = ...;
gp_Pnt thePnt2 = ...;

TopoDS_Shape aShape;
BRepLib_MakeEdge aBuilder(thePnt1, thePnt2);
if (aBuilder.IsDone()) {
  // display a line segment
  aShape = aBuilder.Edge();
} else {
  // display a point
  aShape = BRepLib_MakeVertex(thePnt1).Vertex();
}

Handle(AIS_Shape) aShapePrs = ...
aShapePrs->SetShape(aShape);
...
Mat Maher's picture

Thanks!

In the end I managed to solve it using several beers. As I'm working in 2D, I just set Z to be 0 at the start point and 1 at the end!