router: fix 'Bowen knot'-looking hulls for 0-length segments
This commit is contained in:
parent
0595440d79
commit
d07d6c9a30
|
@ -193,54 +193,59 @@ const SHAPE_LINE_CHAIN SegmentHull ( const SHAPE_SEGMENT& aSeg, int aClearance,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( !IsSegment45Degree( aSeg.GetSeg() ) )
|
if( a != b )
|
||||||
{
|
{
|
||||||
if ( len <= kinkThreshold && len > 0 )
|
if ( !IsSegment45Degree( aSeg.GetSeg() ) )
|
||||||
{
|
{
|
||||||
int ll = std::max( std::abs( w ), std::abs( h ) );
|
if ( len <= kinkThreshold && len > 0 )
|
||||||
|
{
|
||||||
|
int ll = std::max( std::abs( w ), std::abs( h ) );
|
||||||
|
|
||||||
b = a + VECTOR2I( sgn( w ) * ll, sgn( h ) * ll );
|
b = a + VECTOR2I( sgn( w ) * ll, sgn( h ) * ll );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
if( len <= kinkThreshold )
|
|
||||||
{
|
{
|
||||||
int delta45 = std::abs( std::abs(w) - std::abs(h) );
|
if( len <= kinkThreshold )
|
||||||
if( std::abs(w) <= 1 ) // almost vertical
|
|
||||||
{
|
{
|
||||||
w = 0;
|
int delta45 = std::abs( std::abs(w) - std::abs(h) );
|
||||||
cl ++;
|
if( std::abs(w) <= 1 ) // almost vertical
|
||||||
}
|
{
|
||||||
else if ( std::abs(h) <= 1 ) // almost horizontal
|
w = 0;
|
||||||
{
|
cl ++;
|
||||||
h = 0;
|
}
|
||||||
cl ++;
|
else if ( std::abs(h) <= 1 ) // almost horizontal
|
||||||
}
|
{
|
||||||
else if ( delta45 <= 2 ) // almost 45 degree
|
h = 0;
|
||||||
{
|
cl ++;
|
||||||
int newW = sgn( w ) * std::max( std::abs(w), std::abs( h ) );
|
}
|
||||||
int newH = sgn( h ) * std::max( std::abs(w), std::abs( h ) );
|
else if ( delta45 <= 2 ) // almost 45 degree
|
||||||
w = newW;
|
{
|
||||||
h = newH;
|
int newW = sgn( w ) * std::max( std::abs(w), std::abs( h ) );
|
||||||
cl += 2;
|
int newH = sgn( h ) * std::max( std::abs(w), std::abs( h ) );
|
||||||
//PNS_DBG( dbg, AddShape, &aSeg, CYAN, 10000, wxString::Format( "almostkinky45 45 %d l %d dx %d dy %d", !!IsSegment45Degree( aSeg.GetSeg() ), len, w, h ) );
|
w = newW;
|
||||||
|
h = newH;
|
||||||
|
cl += 2;
|
||||||
|
//PNS_DBG( dbg, AddShape, &aSeg, CYAN, 10000, wxString::Format( "almostkinky45 45 %d l %d dx %d dy %d", !!IsSegment45Degree( aSeg.GetSeg() ), len, w, h ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b.x = a.x + w;
|
b.x = a.x + w;
|
||||||
b.y = a.y + h;
|
b.y = a.y + h;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( a == b )
|
if( a == b )
|
||||||
{
|
{
|
||||||
int xx2 = KiROUND( 2.0 * ( 1.0 - M_SQRT2 ) * d );
|
int xx2 = KiROUND( 2.0 * ( 1.0 - M_SQRT1_2 ) * d );
|
||||||
|
|
||||||
return OctagonalHull( a - VECTOR2I( aSeg.GetWidth() / 2, aSeg.GetWidth() / 2 ),
|
auto ohull = OctagonalHull( a - VECTOR2I( aSeg.GetWidth() / 2, aSeg.GetWidth() / 2 ),
|
||||||
VECTOR2I( aSeg.GetWidth(), aSeg.GetWidth() ),
|
VECTOR2I( aSeg.GetWidth(), aSeg.GetWidth() ),
|
||||||
cl,
|
cl,
|
||||||
xx2 );
|
xx2 );
|
||||||
|
|
||||||
|
return ohull;
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTOR2I dir = b - a;
|
VECTOR2I dir = b - a;
|
||||||
|
|
Loading…
Reference in New Issue