router: rework the DEBUG_DECORATOR a bit:
- support for dumping complete PNS::ITEMs and generic SHAPEs - support for log nesting levels - wxT-ized strings - more verbose output where needed
This commit is contained in:
parent
b6fc96c1d5
commit
45f7cf9571
|
@ -232,7 +232,7 @@ bool COMPONENT_DRAGGER::Drag( const VECTOR2I& aP )
|
||||||
l_new.ClearLinks();
|
l_new.ClearLinks();
|
||||||
l_new.DragCorner( cn.p_next, cn.origLine.CLine().Find( cn.p_orig ) );
|
l_new.DragCorner( cn.p_next, cn.origLine.CLine().Find( cn.p_orig ) );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, l_new.CLine(), BLUE, 100000, "cdrag-new-fanout" );
|
PNS_DBG( Dbg(), AddItem, &l_new, BLUE, 0, wxT( "cdrag-new-fanout" ) );
|
||||||
m_draggedItems.Add( l_new );
|
m_draggedItems.Add( l_new );
|
||||||
|
|
||||||
LINE l_orig( cn.origLine );
|
LINE l_orig( cn.origLine );
|
||||||
|
|
|
@ -26,11 +26,14 @@
|
||||||
#include <math/box2.h>
|
#include <math/box2.h>
|
||||||
#include <geometry/seg.h>
|
#include <geometry/seg.h>
|
||||||
#include <geometry/shape_line_chain.h>
|
#include <geometry/shape_line_chain.h>
|
||||||
|
#include <geometry/shape_rect.h>
|
||||||
|
|
||||||
#include <gal/color4d.h>
|
#include <gal/color4d.h>
|
||||||
|
|
||||||
namespace PNS {
|
namespace PNS {
|
||||||
|
|
||||||
|
class ITEM;
|
||||||
|
|
||||||
class DEBUG_DECORATOR
|
class DEBUG_DECORATOR
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -57,25 +60,52 @@ public:
|
||||||
bool IsDebugEnabled() const { return m_debugEnabled; }
|
bool IsDebugEnabled() const { return m_debugEnabled; }
|
||||||
|
|
||||||
virtual void SetIteration( int iter ) {};
|
virtual void SetIteration( int iter ) {};
|
||||||
|
|
||||||
virtual void Message( const wxString& msg,
|
virtual void Message( const wxString& msg,
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
||||||
virtual void NewStage( const std::string& name, int iter,
|
|
||||||
|
virtual void NewStage( const wxString& name, int iter,
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
||||||
virtual void BeginGroup( const std::string& name,
|
|
||||||
|
virtual void BeginGroup( const wxString& name, int aLevel = 0,
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
||||||
|
|
||||||
virtual void EndGroup( const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
virtual void EndGroup( const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
||||||
|
|
||||||
virtual void AddPoint( const VECTOR2I& aP, const KIGFX::COLOR4D& aColor, int aSize,
|
virtual void AddPoint( const VECTOR2I& aP, const KIGFX::COLOR4D& aColor, int aSize,
|
||||||
const std::string& aName,
|
const wxString& aName = wxT( "" ),
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
||||||
virtual void AddLine( const SHAPE_LINE_CHAIN& aLine, const KIGFX::COLOR4D& aColor,
|
|
||||||
int aWidth, const std::string& aName,
|
virtual void AddItem( const ITEM* aItem, const KIGFX::COLOR4D& aColor,
|
||||||
|
int aOverrideWidth = 0,
|
||||||
|
const wxString& aName = wxT( "" ),
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) {};
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) {};
|
||||||
virtual void AddSegment( const SEG& aS, const KIGFX::COLOR4D& aColor,
|
|
||||||
const std::string& aName,
|
virtual void AddShape( const SHAPE* aShape, const KIGFX::COLOR4D& aColor,
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ){};
|
int aOverrideWidth = 0,
|
||||||
virtual void AddBox( const BOX2I& aB, const KIGFX::COLOR4D& aColor,
|
const wxString& aName = wxT( "" ),
|
||||||
const std::string& aName,
|
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) {};
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) {};
|
||||||
|
|
||||||
|
void AddShape( const BOX2I& aBox, const KIGFX::COLOR4D& aColor,
|
||||||
|
int aOverrideWidth = 0,
|
||||||
|
const wxString& aName = wxT( "" ),
|
||||||
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() )
|
||||||
|
{
|
||||||
|
SHAPE_RECT r( aBox );
|
||||||
|
AddShape( &r, aColor, aOverrideWidth, aName, aSrcLoc );
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddShape( const SEG& aSeg, const KIGFX::COLOR4D& aColor,
|
||||||
|
int aOverrideWidth = 0,
|
||||||
|
const wxString& aName = wxT( "" ),
|
||||||
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() )
|
||||||
|
{
|
||||||
|
SHAPE_LINE_CHAIN lc;
|
||||||
|
lc.Append( aSeg.A );
|
||||||
|
lc.Append( aSeg.B );
|
||||||
|
AddShape( &lc, aColor, aOverrideWidth, aName, aSrcLoc );
|
||||||
|
}
|
||||||
|
|
||||||
virtual void Clear() {};
|
virtual void Clear() {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -205,13 +205,13 @@ bool DP_MEANDER_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
|
||||||
for( const ITEM* item : m_tunedPathP.CItems() )
|
for( const ITEM* item : m_tunedPathP.CItems() )
|
||||||
{
|
{
|
||||||
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
||||||
PNS_DBG( Dbg(), AddLine, l->CLine(), YELLOW, 10000, "tuned-path-p" );
|
PNS_DBG( Dbg(), AddShape, &l->CLine(), YELLOW, 10000, wxT( "tuned-path-p" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const ITEM* item : m_tunedPathN.CItems() )
|
for( const ITEM* item : m_tunedPathN.CItems() )
|
||||||
{
|
{
|
||||||
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
||||||
PNS_DBG( Dbg(), AddLine, l->CLine(), YELLOW, 10000, "tuned-path-n" );
|
PNS_DBG( Dbg(), AddShape, &l->CLine(), YELLOW, 10000, wxT( "tuned-path-n" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
int curIndexP = 0, curIndexN = 0;
|
int curIndexP = 0, curIndexN = 0;
|
||||||
|
@ -220,7 +220,7 @@ bool DP_MEANDER_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
|
||||||
{
|
{
|
||||||
SEG base = baselineSegment( sp );
|
SEG base = baselineSegment( sp );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddSegment, base, GREEN, "dp-baseline" );
|
PNS_DBG( Dbg(), AddShape, base, GREEN, 10000, wxT( "dp-baseline" ) );
|
||||||
|
|
||||||
while( sp.indexP >= curIndexP && curIndexP != -1 )
|
while( sp.indexP >= curIndexP && curIndexP != -1 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -474,8 +474,8 @@ void DRAGGER::optimizeAndUpdateDraggedLine( LINE& aDragged, const LINE& aOrig, c
|
||||||
else if( !affectedArea )
|
else if( !affectedArea )
|
||||||
affectedArea = BOX2I( aP ); // No valid area yet? set to minimum to disable optimization
|
affectedArea = BOX2I( aP ); // No valid area yet? set to minimum to disable optimization
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddPoint, anchor, YELLOW, 100000, "drag-anchor" );
|
PNS_DBG( Dbg(), AddPoint, anchor, YELLOW, 100000, wxT( "drag-anchor" ) );
|
||||||
PNS_DBG( Dbg(), AddBox, *affectedArea, RED, "drag-affected-area" );
|
PNS_DBG( Dbg(), AddShape, *affectedArea, RED, 0, wxT( "drag-affected-area" ) );
|
||||||
|
|
||||||
optimizer.SetRestrictArea( *affectedArea );
|
optimizer.SetRestrictArea( *affectedArea );
|
||||||
optimizer.Optimize( &aDragged );
|
optimizer.Optimize( &aDragged );
|
||||||
|
@ -483,7 +483,7 @@ void DRAGGER::optimizeAndUpdateDraggedLine( LINE& aDragged, const LINE& aOrig, c
|
||||||
OPT_BOX2I optArea = aDragged.ChangedArea( &aOrig );
|
OPT_BOX2I optArea = aDragged.ChangedArea( &aOrig );
|
||||||
|
|
||||||
if( optArea )
|
if( optArea )
|
||||||
PNS_DBG( Dbg(), AddBox, *optArea, BLUE, "drag-opt-area" );
|
PNS_DBG( Dbg(), AddShape, *optArea, BLUE, 0, wxT( "drag-opt-area" ) );
|
||||||
|
|
||||||
m_lastNode->Add( aDragged );
|
m_lastNode->Add( aDragged );
|
||||||
m_draggedItems.Clear();
|
m_draggedItems.Clear();
|
||||||
|
@ -578,8 +578,8 @@ bool DRAGGER::dragWalkaround( const VECTOR2I& aP )
|
||||||
|
|
||||||
if( ok )
|
if( ok )
|
||||||
{
|
{
|
||||||
PNS_DBG( Dbg(), AddLine, origLine.CLine(), BLUE, 50000, "drag-orig-line" );
|
PNS_DBG( Dbg(), AddShape, &origLine.CLine(), BLUE, 50000, wxT( "drag-orig-line" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, draggedWalk.CLine(), CYAN, 75000, "drag-walk" );
|
PNS_DBG( Dbg(), AddShape, &draggedWalk.CLine(), CYAN, 75000, wxT( "drag-walk" ) );
|
||||||
m_lastNode->Remove( origLine );
|
m_lastNode->Remove( origLine );
|
||||||
optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP );
|
optimizeAndUpdateDraggedLine( draggedWalk, origLine, aP );
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ bool DRAGGER::dragShove( const VECTOR2I& aP )
|
||||||
else
|
else
|
||||||
dragged.DragCorner( aP, m_draggedSegmentIndex );
|
dragged.DragCorner( aP, m_draggedSegmentIndex );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, dragged.CLine(), BLUE, 5000, "drag-shove-line" );
|
PNS_DBG( Dbg(), AddShape, &dragged.CLine(), BLUE, 5000, wxT( "drag-shove-line" ) );
|
||||||
|
|
||||||
SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged );
|
SHOVE::SHOVE_STATUS st = m_shove->ShoveLines( dragged );
|
||||||
|
|
||||||
|
|
|
@ -751,10 +751,12 @@ public:
|
||||||
m_view->Add( m_items );
|
m_view->Add( m_items );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void AddPoint( const VECTOR2I& aP, const COLOR4D& aColor, int aSize,
|
virtual void AddPoint( const VECTOR2I& aP, const KIGFX::COLOR4D& aColor, int aSize,
|
||||||
const std::string& aName,
|
const wxString& aName = wxT( "" ),
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
||||||
|
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
SHAPE_LINE_CHAIN l;
|
SHAPE_LINE_CHAIN l;
|
||||||
|
|
||||||
l.Append( aP - VECTOR2I( -aSize, -aSize ) );
|
l.Append( aP - VECTOR2I( -aSize, -aSize ) );
|
||||||
|
@ -767,52 +769,7 @@ public:
|
||||||
l.Append( aP + VECTOR2I( aSize, -aSize ) );
|
l.Append( aP + VECTOR2I( aSize, -aSize ) );
|
||||||
|
|
||||||
AddLine( l, aColor, 10000, aName );
|
AddLine( l, aColor, 10000, aName );
|
||||||
}
|
#endif
|
||||||
|
|
||||||
virtual void AddBox( const BOX2I& aB, const COLOR4D& aColor, const std::string& aName,
|
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
|
||||||
{
|
|
||||||
SHAPE_LINE_CHAIN l;
|
|
||||||
|
|
||||||
VECTOR2I o = aB.GetOrigin();
|
|
||||||
VECTOR2I s = aB.GetSize();
|
|
||||||
|
|
||||||
l.Append( o );
|
|
||||||
l.Append( o.x + s.x, o.y );
|
|
||||||
l.Append( o.x + s.x, o.y + s.y );
|
|
||||||
l.Append( o.x, o.y + s.y );
|
|
||||||
l.Append( o );
|
|
||||||
|
|
||||||
AddLine( l, aColor, 10000, aName, aSrcLoc );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void AddSegment( const SEG& aS, const COLOR4D& aColor, const std::string& aName,
|
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
|
||||||
{
|
|
||||||
SHAPE_LINE_CHAIN l;
|
|
||||||
|
|
||||||
l.Append( aS.A );
|
|
||||||
l.Append( aS.B );
|
|
||||||
|
|
||||||
AddLine( l, aColor, 10000, aName, aSrcLoc );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
virtual void AddLine( const SHAPE_LINE_CHAIN& aLine, const COLOR4D& aColor,
|
|
||||||
int aWidth, const std::string& aName,
|
|
||||||
const SRC_LOCATION_INFO& aSrcLoc = SRC_LOCATION_INFO() ) override
|
|
||||||
{
|
|
||||||
if( !m_view )
|
|
||||||
return;
|
|
||||||
|
|
||||||
ROUTER_PREVIEW_ITEM* pitem = new ROUTER_PREVIEW_ITEM( nullptr, m_view );
|
|
||||||
|
|
||||||
pitem->SetColor( aColor );
|
|
||||||
pitem->Line( aLine, aWidth );
|
|
||||||
|
|
||||||
// Should not be needed, as m_items has been passed as a parent group in alloc;
|
|
||||||
m_items->Add( pitem );
|
|
||||||
m_view->Update( m_items );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear() override
|
void Clear() override
|
||||||
|
|
|
@ -550,7 +550,7 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead )
|
||||||
|
|
||||||
do {
|
do {
|
||||||
snprintf( name, sizeof( name ), "walk-round-%d", round );
|
snprintf( name, sizeof( name ), "walk-round-%d", round );
|
||||||
PNS_DBG( Dbg(), BeginGroup, name );
|
PNS_DBG( Dbg(), BeginGroup, name, 0 );
|
||||||
|
|
||||||
viaOk = buildInitialLine( walkP, initTrack, round == 0 );
|
viaOk = buildInitialLine( walkP, initTrack, round == 0 );
|
||||||
|
|
||||||
|
@ -567,8 +567,8 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead )
|
||||||
int len_cw = wr.statusCw == WALKAROUND::DONE ? l_cw.Length() : INT_MAX;
|
int len_cw = wr.statusCw == WALKAROUND::DONE ? l_cw.Length() : INT_MAX;
|
||||||
int len_ccw = wr.statusCcw == WALKAROUND::DONE ? l_ccw.Length() : INT_MAX;
|
int len_ccw = wr.statusCcw == WALKAROUND::DONE ? l_ccw.Length() : INT_MAX;
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, wr.lineCw.CLine(), CYAN, 10000, "wf-result-cw" );
|
PNS_DBG( Dbg(), AddItem, &wr.lineCw, CYAN, 10000, wxT( "wf-result-cw" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, wr.lineCcw.CLine(), BLUE, 20000, "wf-result-ccw" );
|
PNS_DBG( Dbg(), AddItem, &wr.lineCcw, BLUE, 20000, wxT( "wf-result-ccw" ) );
|
||||||
|
|
||||||
int bestLength = len_cw < len_ccw ? len_cw : len_ccw;
|
int bestLength = len_cw < len_ccw ? len_cw : len_ccw;
|
||||||
|
|
||||||
|
@ -596,8 +596,8 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead )
|
||||||
{
|
{
|
||||||
int idx_ccw = l_ccw.Split( p_ccw );
|
int idx_ccw = l_ccw.Split( p_ccw );
|
||||||
l_ccw = l_ccw.Slice( 0, idx_ccw );
|
l_ccw = l_ccw.Slice( 0, idx_ccw );
|
||||||
PNS_DBG( Dbg(), AddPoint, p_ccw, BLUE, 500000, "hug-target-ccw" );
|
PNS_DBG( Dbg(), AddPoint, p_ccw, BLUE, 500000, wxT( "hug-target-ccw" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, l_ccw, MAGENTA, 200000, "wh-result-ccw" );
|
PNS_DBG( Dbg(), AddShape, &l_ccw, MAGENTA, 200000, wxT( "wh-result-ccw" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,8 +609,8 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead )
|
||||||
{
|
{
|
||||||
int idx_cw = l_cw.Split( p_cw );
|
int idx_cw = l_cw.Split( p_cw );
|
||||||
l_cw = l_cw.Slice( 0, idx_cw );
|
l_cw = l_cw.Slice( 0, idx_cw );
|
||||||
PNS_DBG( Dbg(), AddPoint, p_cw, YELLOW, 500000, "hug-target-cw" );
|
PNS_DBG( Dbg(), AddPoint, p_cw, YELLOW, 500000, wxT( "hug-target-cw" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, l_cw, BLUE, 200000, "wh-result-cw" );
|
PNS_DBG( Dbg(), AddShape, &l_cw, BLUE, 200000, wxT( "wh-result-cw" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,7 +641,7 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead )
|
||||||
round++;
|
round++;
|
||||||
} while( round < 2 && m_placingVia );
|
} while( round < 2 && m_placingVia );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, walkFull.CLine(), GREEN, 200000, "walk-full" );
|
PNS_DBG( Dbg(), AddItem, &walkFull, GREEN, 200000, wxT( "walk-full" ) );
|
||||||
|
|
||||||
switch( Settings().OptimizerEffort() )
|
switch( Settings().OptimizerEffort() )
|
||||||
{
|
{
|
||||||
|
@ -887,7 +887,7 @@ bool LINE_PLACER::optimizeTailHeadTransition()
|
||||||
// the optimized line
|
// the optimized line
|
||||||
|
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, new_head.CLine(), LIGHTCYAN, 10000, "ht-newline" );
|
PNS_DBG( Dbg(), AddItem, &new_head, LIGHTCYAN, 10000, wxT( "ht-newline" ) );
|
||||||
|
|
||||||
if( OPTIMIZER::Optimize( &new_head, OPTIMIZER::MERGE_SEGMENTS, m_currentNode ) )
|
if( OPTIMIZER::Optimize( &new_head, OPTIMIZER::MERGE_SEGMENTS, m_currentNode ) )
|
||||||
{
|
{
|
||||||
|
@ -923,41 +923,41 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
|
||||||
m_head.ShapeCount(),
|
m_head.ShapeCount(),
|
||||||
m_tail.ShapeCount() );
|
m_tail.ShapeCount() );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), BeginGroup, "route-step" );
|
PNS_DBG( Dbg(), BeginGroup, wxT( "route-step" ), 0 );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 10000, "tail-init" );
|
PNS_DBG( Dbg(), AddItem, &m_tail, WHITE, 10000, wxT( "tail-init" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 10000, "head-init" );
|
PNS_DBG( Dbg(), AddItem, &m_head, GREEN, 10000, wxT( "head-init" ) );
|
||||||
|
|
||||||
for( i = 0; i < n_iter; i++ )
|
for( i = 0; i < n_iter; i++ )
|
||||||
{
|
{
|
||||||
if( !go_back && Settings().FollowMouse() )
|
if( !go_back && Settings().FollowMouse() )
|
||||||
reduceTail( aP );
|
reduceTail( aP );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 10000, "tail-after-reduce" );
|
PNS_DBG( Dbg(), AddItem, &m_tail, WHITE, 10000, wxT( "tail-after-reduce" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 10000, "head-after-reduce" );
|
PNS_DBG( Dbg(), AddItem, &m_head, GREEN, 10000, wxT( "head-after-reduce" ) );
|
||||||
|
|
||||||
go_back = false;
|
go_back = false;
|
||||||
|
|
||||||
if( !routeHead( aP, new_head ) )
|
if( !routeHead( aP, new_head ) )
|
||||||
|
{
|
||||||
fail = true;
|
fail = true;
|
||||||
|
}
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, new_head.CLine(), LIGHTGREEN, 100000, "new_head" );
|
PNS_DBG( Dbg(), AddItem, &new_head, LIGHTGREEN, 100000, wxT( "new_head" ) );
|
||||||
|
|
||||||
if( fail )
|
if( fail )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
m_head = new_head;
|
m_head = new_head;
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, m_head.CLine(), LIGHTGREEN, 100000, "head-new" );
|
|
||||||
|
|
||||||
if( handleSelfIntersections() )
|
if( handleSelfIntersections() )
|
||||||
{
|
{
|
||||||
n_iter++;
|
n_iter++;
|
||||||
go_back = true;
|
go_back = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 10000, "tail-after-si" );
|
PNS_DBG( Dbg(), AddItem, &m_tail, WHITE, 10000, wxT( "tail-after-si" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 10000, "head-after-si" );
|
PNS_DBG( Dbg(), AddItem, &m_head, GREEN, 10000, wxT( "head-after-si" ) );
|
||||||
|
|
||||||
if( !go_back && handlePullback() )
|
if( !go_back && handlePullback() )
|
||||||
{
|
{
|
||||||
|
@ -965,8 +965,8 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
|
||||||
go_back = true;
|
go_back = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 100000, "tail-after-pb" );
|
PNS_DBG( Dbg(), AddItem, &m_tail, WHITE, 100000, wxT( "tail-after-pb" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 100000, "head-after-pb" );
|
PNS_DBG( Dbg(), AddItem, &m_head, GREEN, 100000, wxT( "head-after-pb" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fail )
|
if( fail )
|
||||||
|
@ -988,16 +988,16 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP )
|
||||||
|
|
||||||
if( !fail && Settings().FollowMouse() )
|
if( !fail && Settings().FollowMouse() )
|
||||||
{
|
{
|
||||||
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 10000, "tail-pre-merge" );
|
PNS_DBG( Dbg(), AddItem, &m_tail, WHITE, 10000, wxT( "tail-pre-merge" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 10000, "head-pre-merge" );
|
PNS_DBG( Dbg(), AddItem, &m_head, GREEN, 10000, wxT( "head-pre-merge" ) );
|
||||||
|
|
||||||
if( !optimizeTailHeadTransition() )
|
if( !optimizeTailHeadTransition() )
|
||||||
{
|
{
|
||||||
mergeHead();
|
mergeHead();
|
||||||
}
|
}
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), WHITE, 100000, "tail-post-merge" );
|
PNS_DBG( Dbg(), AddItem, &m_tail, WHITE, 100000, wxT( "tail-post-merge" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 100000, "head-post-merge" );
|
PNS_DBG( Dbg(), AddItem, &m_head, GREEN, 100000, wxT( "head-post-merge" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
PNS_DBGN( Dbg(), EndGroup );
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
@ -1022,8 +1022,8 @@ const LINE LINE_PLACER::Trace() const
|
||||||
tmp.SetShape( m_tail.CLine() );
|
tmp.SetShape( m_tail.CLine() );
|
||||||
tmp.Line().Append( m_head.CLine() );
|
tmp.Line().Append( m_head.CLine() );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, m_tail.CLine(), GREEN, 100000, "tmp-tail" );
|
PNS_DBG( Dbg(), AddItem, &m_tail, GREEN, 100000, wxT( "tmp-tail" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, m_head.CLine(), LIGHTGREEN, 100000, "tmp-head" );
|
PNS_DBG( Dbg(), AddItem, &m_head, LIGHTGREEN, 100000, wxT( "tmp-head" ) );
|
||||||
|
|
||||||
tmp.Line().Simplify();
|
tmp.Line().Simplify();
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
|
@ -160,7 +160,7 @@ bool MEANDER_PLACER::doMove( const VECTOR2I& aP, ITEM* aEndItem, long long int a
|
||||||
{
|
{
|
||||||
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
||||||
{
|
{
|
||||||
PNS_DBG( Dbg(), AddLine, l->CLine(), BLUE, 30000, "tuned-line" );
|
PNS_DBG( Dbg(), AddItem, l, BLUE, 30000, wxT( "tuned-line" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,13 +142,13 @@ bool MEANDER_SKEW_PLACER::Move( const VECTOR2I& aP, ITEM* aEndItem )
|
||||||
for( const ITEM* item : m_tunedPathP.CItems() )
|
for( const ITEM* item : m_tunedPathP.CItems() )
|
||||||
{
|
{
|
||||||
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
||||||
PNS_DBG( Dbg(), AddLine, l->CLine(), BLUE, 10000, "tuned-path-skew-p" );
|
PNS_DBG( Dbg(), AddItem, l, BLUE, 10000, wxT( "tuned-path-skew-p" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const ITEM* item : m_tunedPathN.CItems() )
|
for( const ITEM* item : m_tunedPathN.CItems() )
|
||||||
{
|
{
|
||||||
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
if( const LINE* l = dyn_cast<const LINE*>( item ) )
|
||||||
PNS_DBG( Dbg(), AddLine, l->CLine(), YELLOW, 10000, "tuned-path-skew-n" );
|
PNS_DBG( Dbg(), AddItem, l, YELLOW, 10000, wxT( "tuned-path-skew-n" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return doMove( aP, aEndItem, m_coupledLength + m_settings.m_targetSkew );
|
return doMove( aP, aEndItem, m_coupledLength + m_settings.m_targetSkew );
|
||||||
|
|
|
@ -76,7 +76,7 @@ void MOUSE_TRAIL_TRACER::AddTrailPoint( const VECTOR2I& aP )
|
||||||
|
|
||||||
DEBUG_DECORATOR *dbg = ROUTER::GetInstance()->GetInterface()->GetDebugDecorator();
|
DEBUG_DECORATOR *dbg = ROUTER::GetInstance()->GetInterface()->GetDebugDecorator();
|
||||||
|
|
||||||
PNS_DBG( dbg, AddLine, m_trail, CYAN, 50000, "mt-trail" );
|
PNS_DBG( dbg, AddShape, &m_trail, CYAN, 50000, wxT( "mt-trail" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ DIRECTION_45 MOUSE_TRAIL_TRACER::GetPosture( const VECTOR2I& aP )
|
||||||
straight.Append( m_trail.Reverse() );
|
straight.Append( m_trail.Reverse() );
|
||||||
straight.Simplify();
|
straight.Simplify();
|
||||||
|
|
||||||
PNS_DBG( dbg, AddLine, straight, m_forced ? BLUE : GREEN, 100000, "mt-straight" );
|
PNS_DBG( dbg, AddShape, &straight, m_forced ? BLUE : GREEN, 100000, wxT( "mt-straight" ) );
|
||||||
|
|
||||||
double areaS = straight.Area();
|
double areaS = straight.Area();
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ DIRECTION_45 MOUSE_TRAIL_TRACER::GetPosture( const VECTOR2I& aP )
|
||||||
diag.SetClosed( true );
|
diag.SetClosed( true );
|
||||||
diag.Simplify();
|
diag.Simplify();
|
||||||
|
|
||||||
PNS_DBG( dbg, AddLine, diag, YELLOW, 100000, "mt-diag" );
|
PNS_DBG( dbg, AddShape, &diag, YELLOW, 100000, wxT( "mt-diag" ) );
|
||||||
|
|
||||||
double areaDiag = diag.Area();
|
double areaDiag = diag.Area();
|
||||||
double ratio = areaS / ( areaDiag + 1.0 );
|
double ratio = areaS / ( areaDiag + 1.0 );
|
||||||
|
|
|
@ -603,7 +603,7 @@ bool OPTIMIZER::Optimize( LINE* aLine, LINE* aResult, LINE* aRoot )
|
||||||
|
|
||||||
if( aRoot )
|
if( aRoot )
|
||||||
{
|
{
|
||||||
PNS_DBG( dbg, AddLine, aRoot->CLine(), BLUE, 100000, "root-line" );
|
PNS_DBG( dbg, AddItem, aRoot, BLUE, 100000, wxT( "root-line" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,8 @@ void SHOVE::replaceLine( LINE& aOld, LINE& aNew, bool aIncludeInChangedArea, NOD
|
||||||
|
|
||||||
if( changed_area )
|
if( changed_area )
|
||||||
{
|
{
|
||||||
if( Dbg() )
|
SHAPE_RECT r( *changed_area );
|
||||||
{
|
PNS_DBG(Dbg(), AddShape, &r, BLUE, 0, wxT( "shove-changed-area" ) );
|
||||||
Dbg()->AddBox( *changed_area, BLUE, "shove-changed-area" );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_affectedArea =
|
m_affectedArea =
|
||||||
m_affectedArea ? m_affectedArea->Merge( *changed_area ) : *changed_area;
|
m_affectedArea ? m_affectedArea->Merge( *changed_area ) : *changed_area;
|
||||||
|
@ -277,6 +275,8 @@ SHOVE::SHOVE_STATUS SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE&
|
||||||
|
|
||||||
int attempt;
|
int attempt;
|
||||||
|
|
||||||
|
PNS_DBG( Dbg(), BeginGroup, "shove-details", 1 );
|
||||||
|
|
||||||
for( attempt = 0; attempt < 4; attempt++ )
|
for( attempt = 0; attempt < 4; attempt++ )
|
||||||
{
|
{
|
||||||
bool invertTraversal = ( attempt >= 2 );
|
bool invertTraversal = ( attempt >= 2 );
|
||||||
|
@ -290,9 +290,9 @@ SHOVE::SHOVE_STATUS SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE&
|
||||||
{
|
{
|
||||||
const SHAPE_LINE_CHAIN& hull = aHulls[invertTraversal ? aHulls.size() - 1 - i : i];
|
const SHAPE_LINE_CHAIN& hull = aHulls[invertTraversal ? aHulls.size() - 1 - i : i];
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, hull, YELLOW, 10000, "hull" );
|
PNS_DBG( Dbg(), AddShape, &hull, YELLOW, 10000, wxT( "hull" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, path, WHITE, l.Width(), "path" );
|
PNS_DBG( Dbg(), AddShape, &path, WHITE, l.Width(), wxT( "path" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, obs, LIGHTGRAY, aObstacleLine.Width(), "obs" );
|
PNS_DBG( Dbg(), AddShape, &obs, LIGHTGRAY, aObstacleLine.Width(), wxT( "obs" ) );
|
||||||
|
|
||||||
if( !l.Walkaround( hull, path, clockwise ) )
|
if( !l.Walkaround( hull, path, clockwise ) )
|
||||||
{
|
{
|
||||||
|
@ -300,6 +300,8 @@ SHOVE::SHOVE_STATUS SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE&
|
||||||
hull.Format().c_str(),
|
hull.Format().c_str(),
|
||||||
l.CLine().Format().c_str(),
|
l.CLine().Format().c_str(),
|
||||||
clockwise? 1 : 0) );
|
clockwise? 1 : 0) );
|
||||||
|
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
return SH_INCOMPLETE;
|
return SH_INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,12 +360,6 @@ SHOVE::SHOVE_STATUS SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE&
|
||||||
|
|
||||||
bool colliding = l.Collide( &aCurLine, m_currentNode );
|
bool colliding = l.Collide( &aCurLine, m_currentNode );
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
char str[128];
|
|
||||||
sprintf( str, "att-%d-shoved", attempt );
|
|
||||||
Dbg()->AddLine( l.CLine(), BLUE, 20000, str );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if(( aCurLine.Marker() & MK_HEAD ) && !colliding )
|
if(( aCurLine.Marker() & MK_HEAD ) && !colliding )
|
||||||
{
|
{
|
||||||
JOINT* jtStart = m_currentNode->FindJoint( aCurLine.CPoint( 0 ), &aCurLine );
|
JOINT* jtStart = m_currentNode->FindJoint( aCurLine.CPoint( 0 ), &aCurLine );
|
||||||
|
@ -384,9 +380,13 @@ SHOVE::SHOVE_STATUS SHOVE::shoveLineToHullSet( const LINE& aCurLine, const LINE&
|
||||||
|
|
||||||
aResultLine.SetShape( l.CLine() );
|
aResultLine.SetShape( l.CLine() );
|
||||||
|
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
return SH_OK;
|
return SH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
return SH_INCOMPLETE;
|
return SH_INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,12 +465,6 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveObstacleLine( const LINE& aCurLine, const LINE&
|
||||||
hulls.push_back( aCurLine.Via().Hull( viaClearance, obstacleLineWidth ) );
|
hulls.push_back( aCurLine.Via().Hull( viaClearance, obstacleLineWidth ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
char str[128];
|
|
||||||
sprintf( str, "current-cl-%d", clearance );
|
|
||||||
Dbg()->AddLine( aCurLine.CLine(), BLUE, 20000, str );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rv = shoveLineToHullSet( aCurLine, aObstacleLine, aResultLine, hulls );
|
rv = shoveLineToHullSet( aCurLine, aObstacleLine, aResultLine, hulls );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,7 +486,10 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSegment( LINE& aCurrent, SEGMENT* aObstacl
|
||||||
SEGMENT tmp( *aObstacleSeg );
|
SEGMENT tmp( *aObstacleSeg );
|
||||||
|
|
||||||
if( obstacleLine.HasLockedSegments() )
|
if( obstacleLine.HasLockedSegments() )
|
||||||
|
{
|
||||||
|
PNS_DBG(Dbg(), Message, "try walk (locked segments)");
|
||||||
return SH_TRY_WALK;
|
return SH_TRY_WALK;
|
||||||
|
}
|
||||||
|
|
||||||
SHOVE_STATUS rv = ShoveObstacleLine( aCurrent, obstacleLine, shovedLine );
|
SHOVE_STATUS rv = ShoveObstacleLine( aCurrent, obstacleLine, shovedLine );
|
||||||
|
|
||||||
|
@ -512,19 +509,10 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSegment( LINE& aCurrent, SEGMENT* aObstacl
|
||||||
|
|
||||||
if( Dbg() )
|
if( Dbg() )
|
||||||
{
|
{
|
||||||
Dbg()->BeginGroup( wxString::Format( wxT( "on-colliding-segment-iter-%d" ),
|
PNS_DBG( Dbg(), AddItem, aObstacleSeg, BLUE, 0, wxT( "shove-changed-area" ) );
|
||||||
m_iter ).ToStdString() );
|
PNS_DBG( Dbg(), AddItem, &aCurrent, RED, 10000, wxT( "current-line" ) );
|
||||||
Dbg()->AddSegment( tmp.Seg(), WHITE, "obstacle-segment" );
|
PNS_DBG( Dbg(), AddItem, &obstacleLine, GREEN, 10000, wxT( "obstacle-line" ) );
|
||||||
Dbg()->AddLine( aCurrent.CLine(), RED, 10000, "current-line" );
|
PNS_DBG( Dbg(), AddItem, &shovedLine, BLUE, 10000, wxT( "shoved-line" ) );
|
||||||
Dbg()->AddLine( obstacleLine.CLine(), GREEN, 10000, "obstacle-line" );
|
|
||||||
Dbg()->AddLine( shovedLine.CLine(), BLUE, 10000, "shoved-line" );
|
|
||||||
|
|
||||||
if( rv == SH_OK )
|
|
||||||
Dbg()->Message( "Shove success" );
|
|
||||||
else
|
|
||||||
Dbg()->Message( "Shove FAIL" );
|
|
||||||
|
|
||||||
Dbg()->EndGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rv == SH_OK )
|
if( rv == SH_OK )
|
||||||
|
@ -580,16 +568,10 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingArc( LINE& aCurrent, ARC* aObstacleArc )
|
||||||
|
|
||||||
assert( obstacleLine.LayersOverlap( &shovedLine ) );
|
assert( obstacleLine.LayersOverlap( &shovedLine ) );
|
||||||
|
|
||||||
if ( Dbg() )
|
PNS_DBG( Dbg(), AddItem, &tmp, WHITE, 10000, wxT( "obstacle-arc" ) );
|
||||||
{
|
PNS_DBG( Dbg(), AddItem, &aCurrent, RED, 10000, wxT( "current-line" ) );
|
||||||
Dbg()->BeginGroup( wxString::Format( wxT( "on-colliding-arc-iter-%d" ),
|
PNS_DBG( Dbg(), AddItem, &obstacleLine, GREEN, 10000, wxT( "obstacle-line" ) );
|
||||||
m_iter ).ToStdString() );
|
PNS_DBG( Dbg(), AddItem, &shovedLine, BLUE, 10000, wxT( "shoved-line" ) );
|
||||||
Dbg()->AddLine( tmp.CLine(), WHITE, 10000, "obstacle-segment" );
|
|
||||||
Dbg()->AddLine( aCurrent.CLine(), RED, 10000, "current-line" );
|
|
||||||
Dbg()->AddLine( obstacleLine.CLine(), GREEN, 10000, "obstacle-line" );
|
|
||||||
Dbg()->AddLine( shovedLine.CLine(), BLUE, 10000, "shoved-line" );
|
|
||||||
Dbg()->EndGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( rv == SH_OK )
|
if( rv == SH_OK )
|
||||||
{
|
{
|
||||||
|
@ -624,10 +606,9 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingLine( LINE& aCurrent, LINE& aObstacle )
|
||||||
|
|
||||||
SHOVE_STATUS rv = ShoveObstacleLine( aCurrent, aObstacle, shovedLine );
|
SHOVE_STATUS rv = ShoveObstacleLine( aCurrent, aObstacle, shovedLine );
|
||||||
|
|
||||||
Dbg()->BeginGroup( "on-colliding-line" );
|
PNS_DBG( Dbg(), AddItem, &aObstacle, RED, 100000, wxT( "obstacle-line" ) );
|
||||||
Dbg()->AddLine( aObstacle.CLine(), RED, 100000, "obstacle-line" );
|
PNS_DBG( Dbg(), AddItem, &aCurrent, GREEN, 150000, wxT( "current-line" ) );
|
||||||
Dbg()->AddLine( aCurrent.CLine(), GREEN, 150000, "current-line" );
|
PNS_DBG( Dbg(), AddItem, &shovedLine, BLUE, 200000, wxT( "shoved-line" ) );
|
||||||
Dbg()->AddLine( shovedLine.CLine(), BLUE, 200000, "shoved-line" );
|
|
||||||
|
|
||||||
if( rv == SH_OK )
|
if( rv == SH_OK )
|
||||||
{
|
{
|
||||||
|
@ -766,13 +747,8 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingSolid( LINE& aCurrent, ITEM* aObstacle )
|
||||||
replaceLine( aCurrent, walkaroundLine );
|
replaceLine( aCurrent, walkaroundLine );
|
||||||
walkaroundLine.SetRank( nextRank );
|
walkaroundLine.SetRank( nextRank );
|
||||||
|
|
||||||
if( Dbg() )
|
PNS_DBG( Dbg(), AddItem, &aCurrent, RED, 10000, wxT( "current-line" ) );
|
||||||
{
|
PNS_DBG( Dbg(), AddItem, &walkaroundLine, BLUE, 10000, wxT( "walk-line" ) );
|
||||||
Dbg()->BeginGroup( "on-colliding-solid" );
|
|
||||||
Dbg()->AddLine( aCurrent.CLine(), RED, 10000, "current-line" );
|
|
||||||
Dbg()->AddLine( walkaroundLine.CLine(), BLUE, 10000, "walk-line" );
|
|
||||||
Dbg()->EndGroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
popLineStack();
|
popLineStack();
|
||||||
|
|
||||||
|
@ -930,6 +906,7 @@ SHOVE::SHOVE_STATUS SHOVE::pushOrShoveVia( VIA* aVia, const VECTOR2I& aForce, in
|
||||||
}
|
}
|
||||||
|
|
||||||
pushedVia->SetRank( aCurrentRank - 1 );
|
pushedVia->SetRank( aCurrentRank - 1 );
|
||||||
|
PNS_DBG( Dbg(), Message, wxString::Format("PushViaRank %d\n", pushedVia->Rank() ) );
|
||||||
|
|
||||||
if( aVia->Marker() & MK_HEAD ) // push
|
if( aVia->Marker() & MK_HEAD ) // push
|
||||||
{
|
{
|
||||||
|
@ -965,6 +942,9 @@ SHOVE::SHOVE_STATUS SHOVE::pushOrShoveVia( VIA* aVia, const VECTOR2I& aForce, in
|
||||||
replaceLine( lp.first, lp.second );
|
replaceLine( lp.first, lp.second );
|
||||||
lp.second.SetRank( aCurrentRank - 1 );
|
lp.second.SetRank( aCurrentRank - 1 );
|
||||||
|
|
||||||
|
|
||||||
|
PNS_DBG( Dbg(), Message, wxString::Format("PushViaF %p %d\n", &lp.second, lp.second.SegmentCount() ) );
|
||||||
|
|
||||||
if( !pushLineStack( lp.second, true ) )
|
if( !pushLineStack( lp.second, true ) )
|
||||||
return SH_INCOMPLETE;
|
return SH_INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
@ -973,8 +953,8 @@ SHOVE::SHOVE_STATUS SHOVE::pushOrShoveVia( VIA* aVia, const VECTOR2I& aForce, in
|
||||||
m_currentNode->Remove( lp.first );
|
m_currentNode->Remove( lp.first );
|
||||||
}
|
}
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, lp.first.CLine(), LIGHTGREEN, 10000, "fan-pre" );
|
PNS_DBG( Dbg(), AddItem, &lp.first, LIGHTGREEN, 10000, wxT( "fan-pre" ) );
|
||||||
PNS_DBG( Dbg(), AddLine, lp.second.CLine(), LIGHTRED, 10000, "fan-post" );
|
PNS_DBG( Dbg(), AddItem, &lp.second, LIGHTRED, 10000, wxT( "fan-post" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return SH_OK;
|
return SH_OK;
|
||||||
|
@ -995,16 +975,15 @@ SHOVE::SHOVE_STATUS SHOVE::onCollidingVia( ITEM* aCurrent, VIA* aObstacleVia )
|
||||||
bool viaCollision = false;
|
bool viaCollision = false;
|
||||||
VECTOR2I mtvLine, mtvVia;
|
VECTOR2I mtvLine, mtvVia;
|
||||||
|
|
||||||
PNS_DBG( Dbg(), BeginGroup, "push-via-by-line" );
|
PNS_DBG( Dbg(), BeginGroup, "push-via-by-line", 1 );
|
||||||
|
|
||||||
if( aCurrent->OfKind( ITEM::LINE_T ) )
|
if( aCurrent->OfKind( ITEM::LINE_T ) )
|
||||||
{
|
{
|
||||||
|
VIA vtmp ( *aObstacleVia );
|
||||||
LINE* currentLine = (LINE*) aCurrent;
|
LINE* currentLine = (LINE*) aCurrent;
|
||||||
|
|
||||||
#if 0
|
PNS_DBG( Dbg(), AddItem, currentLine, LIGHTRED, 10000, wxT( "current-line" ) );
|
||||||
m_logger.NewGroup( "push-via-by-line", m_iter );
|
PNS_DBG( Dbg(), AddItem, &vtmp, LIGHTRED, 100000, wxT( "orig-via" ) );
|
||||||
m_logger.Log( currentLine, 4, "current" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lineCollision = aObstacleVia->Shape()->Collide( currentLine->Shape(),
|
lineCollision = aObstacleVia->Shape()->Collide( currentLine->Shape(),
|
||||||
clearance + currentLine->Width() / 2,
|
clearance + currentLine->Width() / 2,
|
||||||
|
@ -1115,6 +1094,11 @@ SHOVE::SHOVE_STATUS SHOVE::onReverseCollidingVia( LINE& aCurrent, VIA* aObstacle
|
||||||
m_logger.Log( &aCurrent, 1, "current-line" );
|
m_logger.Log( &aCurrent, 1, "current-line" );
|
||||||
m_logger.Log( &shoved, 3, "shoved-line" );
|
m_logger.Log( &shoved, 3, "shoved-line" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
PNS_DBG( Dbg(), AddItem, aObstacleVia, YELLOW, 0, wxT( "rr-the-via" ) );
|
||||||
|
PNS_DBG( Dbg(), AddItem, &aCurrent, BLUE, 0, wxT( "rr-current-line" ) );
|
||||||
|
PNS_DBG( Dbg(), AddItem, &shoved, GREEN, 0, wxT( "rr-shoved-line" ) );
|
||||||
|
|
||||||
int currentRank = aCurrent.Rank();
|
int currentRank = aCurrent.Rank();
|
||||||
replaceLine( aCurrent, shoved );
|
replaceLine( aCurrent, shoved );
|
||||||
|
|
||||||
|
@ -1129,12 +1113,19 @@ SHOVE::SHOVE_STATUS SHOVE::onReverseCollidingVia( LINE& aCurrent, VIA* aObstacle
|
||||||
|
|
||||||
void SHOVE::unwindLineStack( LINKED_ITEM* aSeg )
|
void SHOVE::unwindLineStack( LINKED_ITEM* aSeg )
|
||||||
{
|
{
|
||||||
|
int d = 0;
|
||||||
|
|
||||||
for( std::vector<LINE>::iterator i = m_lineStack.begin(); i != m_lineStack.end() ; )
|
for( std::vector<LINE>::iterator i = m_lineStack.begin(); i != m_lineStack.end() ; )
|
||||||
{
|
{
|
||||||
if( i->ContainsLink( aSeg ) )
|
if( i->ContainsLink( aSeg ) )
|
||||||
|
{
|
||||||
|
PNS_DBG(Dbg(), Message, wxString::Format("Unwind lc %d (depth %d/%d)", i->SegmentCount(), d, (int)m_lineStack.size() ) );
|
||||||
i = m_lineStack.erase( i );
|
i = m_lineStack.erase( i );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
d++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( std::vector<LINE>::iterator i = m_optimizerQueue.begin(); i != m_optimizerQueue.end() ; )
|
for( std::vector<LINE>::iterator i = m_optimizerQueue.begin(); i != m_optimizerQueue.end() ; )
|
||||||
|
@ -1216,9 +1207,12 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
||||||
NODE::OPT_OBSTACLE nearest;
|
NODE::OPT_OBSTACLE nearest;
|
||||||
SHOVE_STATUS st = SH_NULL;
|
SHOVE_STATUS st = SH_NULL;
|
||||||
|
|
||||||
#ifdef DEBUG
|
if( Dbg() )
|
||||||
|
{
|
||||||
Dbg()->SetIteration( aIter );
|
Dbg()->SetIteration( aIter );
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
PNS_DBG( Dbg(), AddItem, ¤tLine, RED, currentLine.Width(), wxString::Format( "current-coll-chk rank %d", currentLine.Rank() ) );
|
||||||
|
|
||||||
for( ITEM::PnsKind search_order : { ITEM::SOLID_T, ITEM::VIA_T, ITEM::SEGMENT_T } )
|
for( ITEM::PnsKind search_order : { ITEM::SOLID_T, ITEM::VIA_T, ITEM::SEGMENT_T } )
|
||||||
{
|
{
|
||||||
|
@ -1226,8 +1220,8 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
||||||
|
|
||||||
if( nearest )
|
if( nearest )
|
||||||
PNS_DBG( Dbg(), Message,
|
PNS_DBG( Dbg(), Message,
|
||||||
wxString::Format( wxT( "nearest %p %s" ), nearest->m_item,
|
wxString::Format( wxT( "nearest %p %s rank %d" ), nearest->m_item,
|
||||||
nearest->m_item->KindStr() ) );
|
nearest->m_item->KindStr(), nearest->m_item->Rank() ) );
|
||||||
|
|
||||||
if( nearest )
|
if( nearest )
|
||||||
break;
|
break;
|
||||||
|
@ -1252,7 +1246,7 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
||||||
{
|
{
|
||||||
case ITEM::VIA_T:
|
case ITEM::VIA_T:
|
||||||
{
|
{
|
||||||
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: reverse-collide-via", aIter ) );
|
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: reverse-collide-via", aIter ).ToStdString(), 0 );
|
||||||
|
|
||||||
if( currentLine.EndsWithVia() )
|
if( currentLine.EndsWithVia() )
|
||||||
{
|
{
|
||||||
|
@ -1263,18 +1257,22 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
||||||
st = onReverseCollidingVia( currentLine, (VIA*) ni );
|
st = onReverseCollidingVia( currentLine, (VIA*) ni );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ITEM::SEGMENT_T:
|
case ITEM::SEGMENT_T:
|
||||||
{
|
{
|
||||||
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: reverse-collide-segment ",
|
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: reverse-collide-segment ",
|
||||||
aIter ) );
|
aIter ).ToStdString(), 0 );
|
||||||
LINE revLine = assembleLine( static_cast<SEGMENT*>( ni ) );
|
LINE revLine = assembleLine( static_cast<SEGMENT*>( ni ) );
|
||||||
|
|
||||||
popLineStack();
|
popLineStack();
|
||||||
st = onCollidingLine( revLine, currentLine );
|
st = onCollidingLine( revLine, currentLine );
|
||||||
|
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
if( !pushLineStack( revLine ) )
|
if( !pushLineStack( revLine ) )
|
||||||
return SH_INCOMPLETE;
|
return SH_INCOMPLETE;
|
||||||
|
|
||||||
|
@ -1284,12 +1282,14 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
||||||
case ITEM::ARC_T:
|
case ITEM::ARC_T:
|
||||||
{
|
{
|
||||||
//TODO(snh): Handle Arc shove separate from track
|
//TODO(snh): Handle Arc shove separate from track
|
||||||
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: reverse-collide-arc ", aIter ) );
|
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: reverse-collide-arc ", aIter ).ToStdString(), 0 );
|
||||||
LINE revLine = assembleLine( static_cast<ARC*>( ni ) );
|
LINE revLine = assembleLine( static_cast<ARC*>( ni ) );
|
||||||
|
|
||||||
popLineStack();
|
popLineStack();
|
||||||
st = onCollidingLine( revLine, currentLine );
|
st = onCollidingLine( revLine, currentLine );
|
||||||
|
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
if( !pushLineStack( revLine ) )
|
if( !pushLineStack( revLine ) )
|
||||||
return SH_INCOMPLETE;
|
return SH_INCOMPLETE;
|
||||||
|
|
||||||
|
@ -1307,38 +1307,45 @@ SHOVE::SHOVE_STATUS SHOVE::shoveIteration( int aIter )
|
||||||
switch( ni->Kind() )
|
switch( ni->Kind() )
|
||||||
{
|
{
|
||||||
case ITEM::SEGMENT_T:
|
case ITEM::SEGMENT_T:
|
||||||
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: collide-segment ", aIter ) );
|
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-segment ", aIter ), 0 );
|
||||||
|
|
||||||
st = onCollidingSegment( currentLine, (SEGMENT*) ni );
|
st = onCollidingSegment( currentLine, (SEGMENT*) ni );
|
||||||
|
|
||||||
if( st == SH_TRY_WALK )
|
if( st == SH_TRY_WALK )
|
||||||
st = onCollidingSolid( currentLine, ni );
|
st = onCollidingSolid( currentLine, ni );
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//TODO(snh): Customize Arc collide
|
//TODO(snh): Customize Arc collide
|
||||||
case ITEM::ARC_T:
|
case ITEM::ARC_T:
|
||||||
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: collide-arc ", aIter ) );
|
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-arc ", aIter ), 0 );
|
||||||
|
|
||||||
st = onCollidingArc( currentLine, static_cast<ARC*>( ni ) );
|
st = onCollidingArc( currentLine, static_cast<ARC*>( ni ) );
|
||||||
|
|
||||||
if( st == SH_TRY_WALK )
|
if( st == SH_TRY_WALK )
|
||||||
st = onCollidingSolid( currentLine, ni );
|
st = onCollidingSolid( currentLine, ni );
|
||||||
|
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEM::VIA_T:
|
case ITEM::VIA_T:
|
||||||
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: shove-via ", aIter ) );
|
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: collide-via (fixup: %d)", aIter, 0 ), 0 );
|
||||||
st = onCollidingVia( ¤tLine, (VIA*) ni );
|
st = onCollidingVia( ¤tLine, (VIA*) ni );
|
||||||
|
|
||||||
if( st == SH_TRY_WALK )
|
if( st == SH_TRY_WALK )
|
||||||
st = onCollidingSolid( currentLine, ni );
|
st = onCollidingSolid( currentLine, ni );
|
||||||
|
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEM::SOLID_T:
|
case ITEM::SOLID_T:
|
||||||
PNS_DBG( Dbg(), Message, wxString::Format( "iter %d: walk-solid ", aIter ) );
|
PNS_DBG( Dbg(), BeginGroup, wxString::Format( "iter %d: walk-solid ", aIter ), 0);
|
||||||
st = onCollidingSolid( currentLine, (SOLID*) ni );
|
st = onCollidingSolid( currentLine, (SOLID*) ni );
|
||||||
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1391,6 +1398,8 @@ SHOVE::SHOVE_STATUS SHOVE::shoveMainLoop()
|
||||||
|
|
||||||
if( st == SH_INCOMPLETE || timeLimit.Expired() || m_iter >= iterLimit )
|
if( st == SH_INCOMPLETE || timeLimit.Expired() || m_iter >= iterLimit )
|
||||||
{
|
{
|
||||||
|
PNS_DBG( Dbg(), Message, wxString::Format( "Fail [time limit expired: %d iter %d iter limit %d",
|
||||||
|
timeLimit.Expired()?1:0, m_iter, iterLimit ) );
|
||||||
st = SH_INCOMPLETE;
|
st = SH_INCOMPLETE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1462,7 +1471,7 @@ SHOVE::SHOVE_STATUS SHOVE::ShoveLines( const LINE& aCurrentHead )
|
||||||
head.Mark( MK_HEAD );
|
head.Mark( MK_HEAD );
|
||||||
head.SetRank( 100000 );
|
head.SetRank( 100000 );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), AddLine, head.CLine(), CYAN, head.Width(), "head, after shove" );
|
PNS_DBG( Dbg(), AddItem, &head, CYAN, 0, wxT( "head, after shove" ) );
|
||||||
|
|
||||||
if( head.EndsWithVia() )
|
if( head.EndsWithVia() )
|
||||||
{
|
{
|
||||||
|
@ -1757,10 +1766,9 @@ void SHOVE::runOptimizer( NODE* aNode )
|
||||||
|
|
||||||
if( area )
|
if( area )
|
||||||
{
|
{
|
||||||
if( Dbg() )
|
SHAPE_RECT r( *area );
|
||||||
{
|
|
||||||
Dbg()->AddBox( *area, BLUE, "opt-area" );
|
PNS_DBG( Dbg(), AddShape, &r, BLUE, 0, wxT( "opt-area" ) );
|
||||||
}
|
|
||||||
|
|
||||||
optFlags |= OPTIMIZER::RESTRICT_AREA;
|
optFlags |= OPTIMIZER::RESTRICT_AREA;
|
||||||
optimizer.SetRestrictArea( *area, false );
|
optimizer.SetRestrictArea( *area, false );
|
||||||
|
|
|
@ -67,14 +67,10 @@ WALKAROUND::WALKAROUND_STATUS WALKAROUND::singleStep( LINE& aPath, bool aWinding
|
||||||
|
|
||||||
bool s_cw = aPath.Walkaround( current_obs->m_hull, path_walk, aWindingDirection );
|
bool s_cw = aPath.Walkaround( current_obs->m_hull, path_walk, aWindingDirection );
|
||||||
|
|
||||||
PNS_DBG( Dbg(), BeginGroup, "hull/walk" );
|
PNS_DBG( Dbg(), BeginGroup, "hull/walk", 1 );
|
||||||
char name[128];
|
PNS_DBG( Dbg(), AddShape, ¤t_obs->m_hull, RED, 0, wxString::Format( "hull-%s-%d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), m_iteration ) );
|
||||||
snprintf( name, sizeof( name ), "hull-%s-%d", aWindingDirection ? "cw" : "ccw", m_iteration );
|
PNS_DBG( Dbg(), AddShape, &aPath.CLine(), GREEN, 0, wxString::Format( "path-%s-%d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), m_iteration ) );
|
||||||
PNS_DBG( Dbg(), AddLine, current_obs->m_hull, RED, 1, name );
|
PNS_DBG( Dbg(), AddShape, &path_walk, BLUE, 0, wxString::Format( "result-%s-%d", aWindingDirection ? wxT( "cw" ) : wxT( "ccw" ), m_iteration ) );
|
||||||
snprintf( name, sizeof( name ), "path-%s-%d", aWindingDirection ? "cw" : "ccw", m_iteration );
|
|
||||||
PNS_DBG( Dbg(), AddLine, aPath.CLine(), GREEN, 1, name );
|
|
||||||
snprintf( name, sizeof( name ), "result-%s-%d", aWindingDirection ? "cw" : "ccw", m_iteration );
|
|
||||||
PNS_DBG( Dbg(), AddLine, path_walk, BLUE, 10000, name );
|
|
||||||
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "Stat cw %d" ), !!s_cw ) );
|
PNS_DBG( Dbg(), Message, wxString::Format( wxT( "Stat cw %d" ), !!s_cw ) );
|
||||||
PNS_DBGN( Dbg(), EndGroup );
|
PNS_DBGN( Dbg(), EndGroup );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue