2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2015 CERN
|
2016-08-29 14:38:11 +00:00
|
|
|
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-02-18 00:29:54 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pns_line.h"
|
|
|
|
#include "pns_segment.h"
|
|
|
|
#include "pns_node.h"
|
|
|
|
#include "pns_joint.h"
|
|
|
|
#include "pns_solid.h"
|
|
|
|
#include "pns_router.h"
|
2015-07-02 14:10:49 +00:00
|
|
|
#include "pns_utils.h"
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
#include "pns_diff_pair.h"
|
|
|
|
#include "pns_topology.h"
|
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
namespace PNS {
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool TOPOLOGY::SimplifyLine( LINE* aLine )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 18:36:05 +00:00
|
|
|
if( !aLine->IsLinked() || !aLine->SegmentCount() )
|
2015-02-18 16:53:46 +00:00
|
|
|
return false;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
LINKED_ITEM* root = aLine->GetLink( 0 );
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE l = m_world->AssembleLine( root );
|
2015-08-03 19:11:51 +00:00
|
|
|
SHAPE_LINE_CHAIN simplified( l.CLine() );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
simplified.Simplify();
|
|
|
|
|
2015-08-03 19:11:51 +00:00
|
|
|
if( simplified.PointCount() != l.PointCount() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-30 17:01:30 +00:00
|
|
|
m_world->Remove( l );
|
2017-01-18 14:52:35 +00:00
|
|
|
LINE lnew( l );
|
2015-08-03 19:11:51 +00:00
|
|
|
lnew.SetShape( simplified );
|
2016-08-30 15:28:35 +00:00
|
|
|
m_world->Add( lnew );
|
2015-02-18 00:29:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const TOPOLOGY::JOINT_SET TOPOLOGY::ConnectedJoints( JOINT* aStart )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
std::deque<JOINT*> searchQueue;
|
2015-02-18 00:29:54 +00:00
|
|
|
JOINT_SET processed;
|
|
|
|
|
|
|
|
searchQueue.push_back( aStart );
|
|
|
|
processed.insert( aStart );
|
|
|
|
|
|
|
|
while( !searchQueue.empty() )
|
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
JOINT* current = searchQueue.front();
|
2015-02-18 00:29:54 +00:00
|
|
|
searchQueue.pop_front();
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( ITEM* item : current->LinkList() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
if( item->OfKind( ITEM::SEGMENT_T ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
SEGMENT* seg = static_cast<SEGMENT*>( item );
|
|
|
|
JOINT* a = m_world->FindJoint( seg->Seg().A, seg );
|
|
|
|
JOINT* b = m_world->FindJoint( seg->Seg().B, seg );
|
|
|
|
JOINT* next = ( *a == *current ) ? b : a;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
if( processed.find( next ) == processed.end() )
|
|
|
|
{
|
|
|
|
processed.insert( next );
|
|
|
|
searchQueue.push_back( next );
|
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return processed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool TOPOLOGY::LeadingRatLine( const LINE* aTrack, SHAPE_LINE_CHAIN& aRatLine )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE track( *aTrack );
|
2015-02-18 00:29:54 +00:00
|
|
|
VECTOR2I end;
|
|
|
|
|
|
|
|
if( !track.PointCount() )
|
|
|
|
return false;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
std::unique_ptr<NODE> tmpNode( m_world->Branch() );
|
2016-08-30 15:28:35 +00:00
|
|
|
tmpNode->Add( track );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
JOINT* jt = tmpNode->FindJoint( track.CPoint( -1 ), &track );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( !jt )
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( ( !track.EndsWithVia() && jt->LinkCount() >= 2 ) || ( track.EndsWithVia() && jt->LinkCount() >= 3 ) ) // we got something connected
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
end = jt->Pos();
|
2015-02-18 16:53:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
int anchor;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
TOPOLOGY topo( tmpNode.get() );
|
|
|
|
ITEM* it = topo.NearestUnconnectedItem( jt, &anchor );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
if( !it )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
end = it->Anchor( anchor );
|
|
|
|
}
|
|
|
|
|
|
|
|
aRatLine.Clear();
|
2015-02-18 16:53:46 +00:00
|
|
|
aRatLine.Append( track.CPoint( -1 ) );
|
|
|
|
aRatLine.Append( end );
|
2015-02-18 00:29:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-02 14:11:15 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM* TOPOLOGY::NearestUnconnectedItem( JOINT* aStart, int* aAnchor, int aKindMask )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
std::set<ITEM*> disconnected;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
m_world->AllItemsInNet( aStart->Net(), disconnected );
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( const JOINT* jt : ConnectedJoints( aStart ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
for( ITEM* link : jt->LinkList() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
if( disconnected.find( link ) != disconnected.end() )
|
|
|
|
disconnected.erase( link );
|
2015-02-18 16:53:46 +00:00
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int best_dist = INT_MAX;
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM* best = NULL;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( ITEM* item : disconnected )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
if( item->OfKind( aKindMask ) )
|
|
|
|
{
|
2016-08-15 15:16:53 +00:00
|
|
|
for( int i = 0; i < item->AnchorCount(); i++ )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
VECTOR2I p = item->Anchor( i );
|
|
|
|
int d = ( p - aStart->Pos() ).EuclideanNorm();
|
|
|
|
|
|
|
|
if( d < best_dist )
|
|
|
|
{
|
|
|
|
best_dist = d;
|
|
|
|
best = item;
|
|
|
|
|
|
|
|
if( aAnchor )
|
|
|
|
*aAnchor = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool TOPOLOGY::followTrivialPath( LINE* aLine, bool aLeft, ITEM_SET& aSet, std::set<ITEM*>& aVisited )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 18:36:05 +00:00
|
|
|
assert( aLine->IsLinked() );
|
|
|
|
|
2019-05-17 00:13:21 +00:00
|
|
|
VECTOR2I anchor = aLeft ? aLine->CPoint( 0 ) : aLine->CPoint( -1 );
|
|
|
|
LINKED_ITEM* last =
|
2020-04-15 20:16:24 +00:00
|
|
|
aLeft ? aLine->Links().front() : aLine->Links().back();
|
2019-05-17 00:13:21 +00:00
|
|
|
JOINT* jt = m_world->FindJoint( anchor, aLine );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
assert( jt != NULL );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
aVisited.insert( last );
|
|
|
|
|
2015-11-05 09:20:08 +00:00
|
|
|
if( jt->IsNonFanoutVia() || jt->IsTraceWidthChange() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM* via = NULL;
|
|
|
|
SEGMENT* next_seg = NULL;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( ITEM* link : jt->Links().Items() )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
if( link->OfKind( ITEM::VIA_T ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
via = link;
|
2015-02-18 16:53:46 +00:00
|
|
|
else if( aVisited.find( link ) == aVisited.end() )
|
2016-08-29 17:31:13 +00:00
|
|
|
next_seg = static_cast<SEGMENT*>( link );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
if( !next_seg )
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE l = m_world->AssembleLine( next_seg );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-08-03 19:11:51 +00:00
|
|
|
VECTOR2I nextAnchor = ( aLeft ? l.CLine().CPoint( -1 ) : l.CLine().CPoint( 0 ) );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( nextAnchor != anchor )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-08-03 19:11:51 +00:00
|
|
|
l.Reverse();
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( aLeft )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-11-05 09:20:08 +00:00
|
|
|
if( via )
|
|
|
|
aSet.Prepend( via );
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
aSet.Prepend( l );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-05 09:20:08 +00:00
|
|
|
if( via )
|
|
|
|
aSet.Add( via );
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
aSet.Add( l );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-08-03 19:11:51 +00:00
|
|
|
return followTrivialPath( &l, aLeft, aSet, aVisited );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const ITEM_SET TOPOLOGY::AssembleTrivialPath( ITEM* aStart )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
ITEM_SET path;
|
|
|
|
std::set<ITEM*> visited;
|
|
|
|
SEGMENT* seg;
|
|
|
|
VIA* via;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
seg = dyn_cast<SEGMENT*> (aStart);
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
if(!seg && (via = dyn_cast<VIA*>( aStart ) ) )
|
2016-08-15 15:16:47 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
JOINT *jt = m_world->FindJoint( via->Pos(), via );
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2016-08-15 15:16:53 +00:00
|
|
|
if( !jt->IsNonFanoutVia() )
|
2016-08-29 17:31:13 +00:00
|
|
|
return ITEM_SET();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2019-12-05 15:20:59 +00:00
|
|
|
for( const auto& entry : jt->Links().Items() )
|
2016-08-29 17:31:13 +00:00
|
|
|
if( ( seg = dyn_cast<SEGMENT*>( entry.item ) ) )
|
2016-08-15 15:16:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !seg )
|
2016-08-29 17:31:13 +00:00
|
|
|
return ITEM_SET();
|
2016-08-15 15:16:47 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE l = m_world->AssembleLine( seg );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
path.Add( l );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-08-03 19:11:51 +00:00
|
|
|
followTrivialPath( &l, false, path, visited );
|
|
|
|
followTrivialPath( &l, true, path, visited );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const ITEM_SET TOPOLOGY::ConnectedItems( JOINT* aStart, int aKindMask )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
return ITEM_SET();
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const ITEM_SET TOPOLOGY::ConnectedItems( ITEM* aStart, int aKindMask )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
return ITEM_SET();
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2018-10-08 14:30:17 +00:00
|
|
|
bool commonParallelProjection( SEG p, SEG n, SEG &pClip, SEG& nClip );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-07-02 14:11:15 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
bool TOPOLOGY::AssembleDiffPair( ITEM* aStart, DIFF_PAIR& aPair )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
int refNet = aStart->Net();
|
2016-08-15 15:16:47 +00:00
|
|
|
int coupledNet = m_world->GetRuleResolver()->DpCoupledNet( refNet );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
|
|
|
if( coupledNet < 0 )
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
std::set<ITEM*> coupledItems;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
m_world->AllItemsInNet( coupledNet, coupledItems );
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
SEGMENT* coupledSeg = NULL, *refSeg;
|
2015-02-18 00:29:54 +00:00
|
|
|
int minDist = std::numeric_limits<int>::max();
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
if( ( refSeg = dyn_cast<SEGMENT*>( aStart ) ) != NULL )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
for( ITEM* item : coupledItems )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
if( SEGMENT* s = dyn_cast<SEGMENT*>( item ) )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
if( s->Layers().Start() == refSeg->Layers().Start() && s->Width() == refSeg->Width() )
|
|
|
|
{
|
|
|
|
int dist = s->Seg().Distance( refSeg->Seg() );
|
2016-08-29 14:38:11 +00:00
|
|
|
bool isParallel = refSeg->Seg().ApproxParallel( s->Seg() );
|
2015-07-02 14:10:49 +00:00
|
|
|
SEG p_clip, n_clip;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-07-02 14:10:49 +00:00
|
|
|
bool isCoupled = commonParallelProjection( refSeg->Seg(), s->Seg(), p_clip, n_clip );
|
|
|
|
|
|
|
|
if( isParallel && isCoupled && dist < minDist )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
|
|
|
minDist = dist;
|
|
|
|
coupledSeg = s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-03 19:11:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
2015-08-03 19:11:51 +00:00
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( !coupledSeg )
|
2015-02-18 00:29:54 +00:00
|
|
|
return false;
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
LINE lp = m_world->AssembleLine( refSeg );
|
|
|
|
LINE ln = m_world->AssembleLine( coupledSeg );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-15 15:16:47 +00:00
|
|
|
if( m_world->GetRuleResolver()->DpNetPolarity( refNet ) < 0 )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2015-02-18 16:53:46 +00:00
|
|
|
std::swap( lp, ln );
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-08-03 19:11:51 +00:00
|
|
|
int gap = -1;
|
|
|
|
|
2015-07-02 14:11:15 +00:00
|
|
|
if( refSeg->Seg().ApproxParallel( coupledSeg->Seg() ) )
|
|
|
|
{
|
|
|
|
// Segments are parallel -> compute pair gap
|
|
|
|
const VECTOR2I refDir = refSeg->Anchor( 1 ) - refSeg->Anchor( 0 );
|
|
|
|
const VECTOR2I displacement = refSeg->Anchor( 1 ) - coupledSeg->Anchor( 1 );
|
2015-08-03 19:11:51 +00:00
|
|
|
gap = (int) std::abs( refDir.Cross( displacement ) / refDir.EuclideanNorm() ) - lp.Width();
|
2015-07-02 14:10:02 +00:00
|
|
|
}
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
aPair = DIFF_PAIR( lp, ln );
|
2015-08-03 19:11:51 +00:00
|
|
|
aPair.SetWidth( lp.Width() );
|
|
|
|
aPair.SetLayers( lp.Layers() );
|
2015-07-02 14:10:02 +00:00
|
|
|
aPair.SetGap( gap );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-08-19 16:07:16 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
const std::set<ITEM*> TOPOLOGY::AssembleCluster( ITEM* aStart, int aLayer )
|
2015-08-19 16:07:16 +00:00
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
std::set<ITEM*> visited;
|
|
|
|
std::deque<ITEM*> pending;
|
2015-08-19 16:07:16 +00:00
|
|
|
|
|
|
|
pending.push_back( aStart );
|
|
|
|
|
|
|
|
while( !pending.empty() )
|
|
|
|
{
|
2016-08-29 17:31:13 +00:00
|
|
|
NODE::OBSTACLES obstacles;
|
|
|
|
ITEM* top = pending.front();
|
2015-08-19 16:07:16 +00:00
|
|
|
|
|
|
|
pending.pop_front();
|
|
|
|
|
|
|
|
visited.insert( top );
|
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
m_world->QueryColliding( top, obstacles, ITEM::ANY_T, -1, false );
|
2015-08-19 16:07:16 +00:00
|
|
|
|
2016-08-29 17:31:13 +00:00
|
|
|
for( OBSTACLE& obs : obstacles )
|
2015-08-19 16:07:16 +00:00
|
|
|
{
|
|
|
|
if( visited.find( obs.m_item ) == visited.end() && obs.m_item->Layers().Overlaps( aLayer ) && !( obs.m_item->Marker() & MK_HEAD ) )
|
|
|
|
{
|
|
|
|
visited.insert( obs.m_item );
|
|
|
|
pending.push_back( obs.m_item );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return visited;
|
|
|
|
}
|
2016-08-29 14:38:11 +00:00
|
|
|
|
|
|
|
}
|