Commit 3f015705 authored by Tomasz Włostowski's avatar Tomasz Włostowski

working on shove fix for DPs

parent 4fb9bce3
......@@ -190,15 +190,6 @@ bool PNS_DIFF_PAIR::BuildInitial( PNS_DP_GATEWAY& aEntry, PNS_DP_GATEWAY &aTarge
SHAPE_LINE_CHAIN p = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorP(), aTarget.AnchorP(), aPrefDiagonal );
SHAPE_LINE_CHAIN n = DIRECTION_45().BuildInitialTrace ( aEntry.AnchorN(), aTarget.AnchorN(), aPrefDiagonal );
if( !checkGap ( p, n, m_gapConstraint ) )
return false;
if( p.SelfIntersecting() || n.SelfIntersecting() )
return false;
if( p.Intersects( n ) )
return false;
int mask = aEntry.AllowedAngles() | DIRECTION_45::ANG_STRAIGHT | DIRECTION_45::ANG_OBTUSE;
SHAPE_LINE_CHAIN sum_n, sum_p;
......@@ -241,6 +232,15 @@ bool PNS_DIFF_PAIR::BuildInitial( PNS_DP_GATEWAY& aEntry, PNS_DP_GATEWAY &aTarge
m_p = sum_p;
m_n = sum_n;
if( !checkGap ( p, n, m_gapConstraint ) )
return false;
if( p.SelfIntersecting() || n.SelfIntersecting() )
return false;
if( p.Intersects( n ) )
return false;
return true;
}
......
......@@ -149,7 +149,7 @@ bool PNS_DIFF_PAIR_PLACER::attemptWalk ( PNS_NODE* aNode, PNS_DIFF_PAIR* aCurren
PNS_WALKAROUND walkaround( aNode, Router() );
PNS_WALKAROUND::WALKAROUND_STATUS wf1;
Router()->GetClearanceFunc()->OverrideClearance( true, aCurrent->NetP(), aCurrent->NetN(), aCurrent->Gap() - 20 );
Router()->GetClearanceFunc()->OverrideClearance( true, aCurrent->NetP(), aCurrent->NetN(), aCurrent->Gap() );
walkaround.SetSolidsOnly( aSolidsOnly );
walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );
......@@ -167,23 +167,29 @@ bool PNS_DIFF_PAIR_PLACER::attemptWalk ( PNS_NODE* aNode, PNS_DIFF_PAIR* aCurren
int mask = aSolidsOnly ? PNS_ITEM::SOLID : PNS_ITEM::ANY;
//Router()->DisplayDebugLine( aCurrent->CP(), 4, 10000 );
//Router()->DisplayDebugLine( aCurrent->CN(), 5, 10000 );
Router()->DisplayDebugLine( aCurrent->CP(), 4, 10000 );
Router()->DisplayDebugLine( aCurrent->CN(), 5, 10000 );
printf("WStart\n");
do
{
PNS_LINE preWalk = ( currentIsP ? cur.PLine() : cur.NLine() );
PNS_LINE preShove = ( currentIsP ? cur.NLine() : cur.PLine() );
PNS_LINE postWalk;
printf("iter %d\n", iter);
if( !aNode->CheckColliding ( &preWalk, mask ) )
{
printf("PreWalkIsColl\n");
currentIsP = !currentIsP;
if( !aNode->CheckColliding( &preShove, mask ) )
break;
else
{
printf("PreShoveIsColl\n");
continue;
}
}
wf1 = walkaround.Route( preWalk, postWalk, false );
......@@ -193,7 +199,7 @@ bool PNS_DIFF_PAIR_PLACER::attemptWalk ( PNS_NODE* aNode, PNS_DIFF_PAIR* aCurren
PNS_LINE postShove( preShove );
shove.ForceClearance( true, cur.Gap() - 12 );
shove.ForceClearance( true, cur.Gap() );
PNS_SHOVE::SHOVE_STATUS sh1;
......@@ -610,9 +616,6 @@ void PNS_DIFF_PAIR_PLACER::initPlacement( bool aSplitSeg )
setWorld( rootNode );
TRACE( 1, "world %p, intitial-direction %s layer %d\n",
m_world % m_direction.Format().c_str() % aLayer );
m_lastNode = NULL;
m_currentNode = rootNode;
m_currentMode = Settings().Mode();
......
......@@ -42,7 +42,7 @@ class PNS_SOLID;
class PNS_VIA;
class PNS_RATSNEST;
class PNS_INDEX;
class PNS_ROUTER;
/**
* Class PNS_CLEARANCE_FUNC
......@@ -60,15 +60,22 @@ public:
class PNS_PCBNEW_CLEARANCE_FUNC : public PNS_CLEARANCE_FUNC
{
public:
PNS_PCBNEW_CLEARANCE_FUNC( BOARD *aBoard );
PNS_PCBNEW_CLEARANCE_FUNC( PNS_ROUTER *aRouter );
virtual ~PNS_PCBNEW_CLEARANCE_FUNC();
virtual int operator()( const PNS_ITEM* aA, const PNS_ITEM* aB );
virtual void OverrideClearance (bool aEnable, int aNetA = 0, int aNetB = 0, int aClearance = 0);
private:
struct CLEARANCE_ENT {
int coupledNet;
int clearance;
};
PNS_ROUTER *m_router;
int localPadClearance( const PNS_ITEM* aItem ) const;
std::vector<int> m_clearanceCache;
std::vector<CLEARANCE_ENT> m_clearanceCache;
int m_defaultClearance;
bool m_overrideEnabled;
int m_overrideNetA, m_overrideNetB;
......
......@@ -44,6 +44,7 @@
#include "pns_router.h"
#include "pns_shove.h"
#include "pns_dragger.h"
#include "pns_topology.h"
#include "pns_diff_pair_placer.h"
#include "pns_meander_placer.h"
#include "pns_meander_skew_placer.h"
......@@ -63,20 +64,33 @@
static PNS_ROUTER* theRouter;
PNS_PCBNEW_CLEARANCE_FUNC::PNS_PCBNEW_CLEARANCE_FUNC( BOARD* aBoard )
PNS_PCBNEW_CLEARANCE_FUNC::PNS_PCBNEW_CLEARANCE_FUNC( PNS_ROUTER *aRouter ) :
m_router( aRouter )
{
m_clearanceCache.resize( aBoard->GetNetCount() );
BOARD *brd = m_router->GetBoard();
PNS_NODE *world = m_router->GetWorld();
for( unsigned int i = 0; i < aBoard->GetNetCount(); i++ )
PNS_TOPOLOGY topo( world );
m_clearanceCache.resize( brd->GetNetCount() );
for( unsigned int i = 0; i < brd->GetNetCount(); i++ )
{
NETINFO_ITEM* ni = aBoard->FindNet( i );
NETINFO_ITEM* ni = brd->FindNet( i );
if( ni == NULL )
continue;
CLEARANCE_ENT ent;
ent.coupledNet = topo.DpCoupledNet( i );
printf("net %d coupled %d\n", i, ent.coupledNet);
wxString netClassName = ni->GetClassName();
NETCLASSPTR nc = aBoard->GetDesignSettings().m_NetClasses.Find( netClassName );
NETCLASSPTR nc = brd->GetDesignSettings().m_NetClasses.Find( netClassName );
int clearance = nc->GetClearance();
m_clearanceCache[i] = clearance;
ent.clearance = clearance;
m_clearanceCache[i] = ent;
TRACE( 1, "Add net %d netclass %s clearance %d", i % netClassName.mb_str() %
clearance );
}
......@@ -104,11 +118,21 @@ int PNS_PCBNEW_CLEARANCE_FUNC::localPadClearance( const PNS_ITEM* aItem ) const
int PNS_PCBNEW_CLEARANCE_FUNC::operator()( const PNS_ITEM* aA, const PNS_ITEM* aB )
{
int net_a = aA->Net();
int cl_a = ( net_a >= 0 ? m_clearanceCache[net_a] : m_defaultClearance );
int cl_a = ( net_a >= 0 ? m_clearanceCache[net_a].clearance : m_defaultClearance );
int net_b = aB->Net();
int cl_b = ( net_b >= 0 ? m_clearanceCache[net_b] : m_defaultClearance );
int cl_b = ( net_b >= 0 ? m_clearanceCache[net_b].clearance : m_defaultClearance );
if( m_overrideEnabled && aA->OfKind( PNS_ITEM::SEGMENT ) && aB->OfKind( PNS_ITEM::SEGMENT ) )
bool segsOnly = aA->OfKind( PNS_ITEM::SEGMENT ) && aB->OfKind( PNS_ITEM::SEGMENT );
#if 0
if( segsOnly && net_a >= 0 && net_b >= 0 && m_clearanceCache[net_a].coupledNet == net_b )
{
cl_a = cl_b = m_router->Sizes().DiffPairGap() - 3 * PNS_HULL_MARGIN;
printf("Cl %d\n", cl_a);
}
#endif
if( m_overrideEnabled && segsOnly )
{
if( net_a == m_overrideNetA && net_b == m_overrideNetB )
return m_overrideClearance;
......@@ -248,9 +272,6 @@ PNS_ITEM* PNS_ROUTER::syncTrack( TRACK* aTrack )
PNS_SEGMENT* s =
new PNS_SEGMENT( SEG( aTrack->GetStart(), aTrack->GetEnd() ), aTrack->GetNetCode() );
if( aTrack->GetFlags( ) & DP_COUPLED )
s->Mark ( MK_DP_COUPLED );
s->SetWidth( aTrack->GetWidth() );
s->SetLayers( PNS_LAYERSET( aTrack->GetLayer() ) );
s->SetParent( aTrack );
......@@ -293,12 +314,7 @@ void PNS_ROUTER::SyncWorld()
ClearWorld();
int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
m_clearanceFunc = new PNS_PCBNEW_CLEARANCE_FUNC( m_board );
m_world = new PNS_NODE();
m_world->SetClearanceFunctor( m_clearanceFunc );
m_world->SetMaxClearance( 4 * worstClearance );
for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
{
......@@ -324,7 +340,13 @@ void PNS_ROUTER::SyncWorld()
if( item )
m_world->Add( item );
}
int worstClearance = m_board->GetDesignSettings().GetBiggestClearanceValue();
m_clearanceFunc = new PNS_PCBNEW_CLEARANCE_FUNC( this );
m_world->SetClearanceFunctor( m_clearanceFunc );
m_world->SetMaxClearance( 4 * worstClearance );
}
PNS_ROUTER::PNS_ROUTER()
......
......@@ -18,6 +18,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define PNS_DEBUG
#include <deque>
#include <cassert>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment