Open mleon08 opened 2 years ago
I've just run into this issue, and it seems to cause a subsequent crash (though that could be unrelated).
This is an assertion failure when inserting a value into the std::map
that holds scanline data. The assertion essentially checks that if a < b
then !(b < a)
.
The buggy comparator is scanline_base::less_half_edge
. It's easy to see that it's incorrect. For example, let a=(0, 0)
, b=(1, 1)
, c=(3, 2)
, and d=(4, 1)
. Let the first edge be elm1=a->b
and the second elm2=c->d
. In this case, less_half_edge
will consider elm1
to be below elm2
, but it will also consider elm2
to be below elm1
!
I'm not sure what this function is trying to do exactly. It's comparing y values, but then also doing a cross product check, and yet it isn't sensitive to the orientation of the edges in some cases.
EDIT: actually, it looks like every failing case I've found is one in which there's no overlap between the 2 half-edges along the x axis. But in a scanline all elements by definition should overlap at at least one x-value (the current position of the scanline). Indeed, I've found that in the original geometry that tripped the assert for me, there are some edges in the scanline that don't overlap it at all. So the bug is probably in the inclusion of those edges rather than in the predicate being wrong.
Executing this code aborted in version 1.66.0. I confirmed that aborted in version 1.79.0. Aborted when run in debug mode.
This is the call stack and The value of the variable when aborting.
The call stack
The value of the variable
Left ({coords=0x000001ece6044590 {354838000, 490016000} }, {coords_=0x000001ece60445a0 {354958000, 490000000} }) const std::pair<boost::polygon::point_data<__int64>,boost::polygon::point_data<__int64> > &
first {coords_=0x000001ece6044590 {354838000, 490016000} } boost::polygon::point_data<__int64>
second {coords_=0x000001ece60445a0 {354958000, 490000000} } boost::polygon::point_data<__int64>
[未加工ビュー] {first={coords=0x000001ece6044590 {354838000, 490016000} } second={coords=0x000001ece60445a0 {354958000, ...} } } const std::pair<boost::polygon::point_data<__int64>,boost::polygon::point_data<__int64> > _Line 1744 unsigned int
Pred {x=0x0000008e9d53d428 {354838000} justBefore=0x0000008e9d53d438 {0} pack=0x0000008e9d53d440 {evalAtXforYret=...} } boost::polygon::scanline_base<__int64>::less_half_edge &
x_ 0x0000008e9d53d428 {354838000} __int64 *
justBefore_ 0x0000008e9d53d438 {0} int *
pack_ 0x0000008e9d53d440 {evalAtXforYret=0.0000000000000000 evalAtXforYxIn=0.0000000000000000 evalAtXforYx1=...} boost::polygon::scanline_base<__int64>::evalAtXforYPack *
Right ({coords=0x000001ece6035b30 {353296040, 489714261} }, {coords_=0x000001ece6035b40 {353343000, 490071000} }) const std::pair<boost::polygon::point_data<__int64>,boost::polygon::point_data<__int64> > &
first {coords_=0x000001ece6035b30 {353296040, 489714261} } boost::polygon::point_data<__int64>
second {coords_=0x000001ece6035b40 {353343000, 490071000} } boost::polygon::point_data<__int64>
[未加工ビュー] {first={coords=0x000001ece6035b30 {353296040, 489714261} } second={coords=0x000001ece6035b40 {353343000, ...} } } const std::pair<boost::polygon::point_data<__int64>,boost::polygon::point_data<__int64> >
Please investigate the cause of the abort.