Refactored the way zones are kept in ratsnest model (GAL).
This commit is contained in:
parent
a2b8ab6b41
commit
a12ea29de8
|
@ -333,9 +333,9 @@ void RN_NET::clearNode( const RN_NODE_PTR& aNode )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RN_POLY::RN_POLY( const CPolyPt* aBegin, const CPolyPt* aEnd, const ZONE_CONTAINER* aParent,
|
RN_POLY::RN_POLY( const CPolyPt* aBegin, const CPolyPt* aEnd,
|
||||||
RN_LINKS& aConnections, const BOX2I& aBBox ) :
|
RN_LINKS& aConnections, const BOX2I& aBBox ) :
|
||||||
m_parent( aParent ), m_begin( aBegin ), m_end( aEnd ), m_bbox( aBBox )
|
m_begin( aBegin ), m_end( aEnd ), m_bbox( aBBox )
|
||||||
{
|
{
|
||||||
m_node = aConnections.AddNode( m_begin->x, m_begin->y );
|
m_node = aConnections.AddNode( m_begin->x, m_begin->y );
|
||||||
|
|
||||||
|
@ -455,8 +455,8 @@ void RN_NET::AddItem( const ZONE_CONTAINER* aZone )
|
||||||
|
|
||||||
if( point.end_contour )
|
if( point.end_contour )
|
||||||
{
|
{
|
||||||
m_zonePolygons[aZone].push_back( RN_POLY( &polyPoints[idxStart], &point, aZone,
|
m_zones[aZone].m_Polygons.push_back( RN_POLY( &polyPoints[idxStart], &point,
|
||||||
m_links, BOX2I( origin, end - origin ) ) );
|
m_links, BOX2I( origin, end - origin ) ) );
|
||||||
|
|
||||||
idxStart = i + 1;
|
idxStart = i + 1;
|
||||||
|
|
||||||
|
@ -559,7 +559,7 @@ void RN_NET::RemoveItem( const ZONE_CONTAINER* aZone )
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Remove all subpolygons that make the zone
|
// Remove all subpolygons that make the zone
|
||||||
std::deque<RN_POLY>& polygons = m_zonePolygons.at( aZone );
|
std::deque<RN_POLY>& polygons = m_zones.at( aZone ).m_Polygons;
|
||||||
BOOST_FOREACH( RN_POLY& polygon, polygons )
|
BOOST_FOREACH( RN_POLY& polygon, polygons )
|
||||||
{
|
{
|
||||||
const RN_NODE_PTR node = polygon.GetNode();
|
const RN_NODE_PTR node = polygon.GetNode();
|
||||||
|
@ -570,7 +570,7 @@ void RN_NET::RemoveItem( const ZONE_CONTAINER* aZone )
|
||||||
polygons.clear();
|
polygons.clear();
|
||||||
|
|
||||||
// Remove all connections added by the zone
|
// Remove all connections added by the zone
|
||||||
std::deque<RN_EDGE_MST_PTR>& edges = m_zoneConnections.at( aZone );
|
std::deque<RN_EDGE_MST_PTR>& edges = m_zones.at( aZone ).m_Edges;
|
||||||
BOOST_FOREACH( RN_EDGE_PTR edge, edges )
|
BOOST_FOREACH( RN_EDGE_PTR edge, edges )
|
||||||
m_links.RemoveConnection( edge );
|
m_links.RemoveConnection( edge );
|
||||||
edges.clear();
|
edges.clear();
|
||||||
|
@ -728,7 +728,7 @@ std::list<RN_NODE_PTR> RN_NET::GetNodes( const BOARD_CONNECTED_ITEM* aItem ) con
|
||||||
case PCB_ZONE_AREA_T:
|
case PCB_ZONE_AREA_T:
|
||||||
{
|
{
|
||||||
const ZONE_CONTAINER* zone = static_cast<const ZONE_CONTAINER*>( aItem );
|
const ZONE_CONTAINER* zone = static_cast<const ZONE_CONTAINER*>( aItem );
|
||||||
const std::deque<RN_POLY>& polys = m_zonePolygons.at( zone );
|
const std::deque<RN_POLY>& polys = m_zones.at( zone ).m_Polygons;
|
||||||
|
|
||||||
for( std::deque<RN_POLY>::const_iterator it = polys.begin(); it != polys.end(); ++it )
|
for( std::deque<RN_POLY>::const_iterator it = polys.begin(); it != polys.end(); ++it )
|
||||||
nodes.push_back( it->GetNode() );
|
nodes.push_back( it->GetNode() );
|
||||||
|
@ -770,7 +770,7 @@ void RN_NET::GetAllItems( std::list<BOARD_CONNECTED_ITEM*>& aOutput, RN_ITEM_TYP
|
||||||
|
|
||||||
if( aType & RN_ZONES )
|
if( aType & RN_ZONES )
|
||||||
{
|
{
|
||||||
BOOST_FOREACH( const BOARD_CONNECTED_ITEM* aItem, m_zoneConnections | boost::adaptors::map_keys )
|
BOOST_FOREACH( const BOARD_CONNECTED_ITEM* aItem, m_zones | boost::adaptors::map_keys )
|
||||||
aOutput.push_back( const_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
|
aOutput.push_back( const_cast<BOARD_CONNECTED_ITEM*>( aItem ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -828,12 +828,9 @@ void RN_NET::GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem,
|
||||||
|
|
||||||
if( aTypes & RN_ZONES )
|
if( aTypes & RN_ZONES )
|
||||||
{
|
{
|
||||||
for( ZONE_EDGE_MAP::const_iterator it = m_zoneConnections.begin();
|
for( ZONE_DATA_MAP::const_iterator it = m_zones.begin(); it != m_zones.end(); ++it )
|
||||||
it != m_zoneConnections.end(); ++it )
|
|
||||||
{
|
{
|
||||||
const std::deque<RN_EDGE_MST_PTR>& edges = it->second;
|
BOOST_FOREACH( const RN_EDGE_MST_PTR& edge, it->second.m_Edges )
|
||||||
|
|
||||||
BOOST_FOREACH( const RN_EDGE_MST_PTR& edge, edges )
|
|
||||||
{
|
{
|
||||||
if( edge->GetTag() == tag )
|
if( edge->GetTag() == tag )
|
||||||
{
|
{
|
||||||
|
@ -965,44 +962,36 @@ bool RN_DATA::AreConnected( const BOARD_CONNECTED_ITEM* aItem, const BOARD_CONNE
|
||||||
|
|
||||||
void RN_NET::processZones()
|
void RN_NET::processZones()
|
||||||
{
|
{
|
||||||
BOOST_FOREACH( std::deque<RN_EDGE_MST_PTR>& edges, m_zoneConnections | boost::adaptors::map_values )
|
BOOST_FOREACH( RN_ZONE_DATA& zoneData, m_zones | boost::adaptors::map_values )
|
||||||
{
|
{
|
||||||
BOOST_FOREACH( RN_EDGE_MST_PTR edge, edges )
|
// Reset existing connections
|
||||||
|
BOOST_FOREACH( RN_EDGE_MST_PTR edge, zoneData.m_Edges )
|
||||||
m_links.RemoveConnection( edge );
|
m_links.RemoveConnection( edge );
|
||||||
|
|
||||||
edges.clear();
|
zoneData.m_Edges.clear();
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_FOREACH( std::deque<RN_POLY>& polygons, m_zonePolygons | boost::adaptors::map_values )
|
// Compute new connections
|
||||||
{
|
|
||||||
RN_LINKS::RN_NODE_SET candidates = m_links.GetNodes();
|
RN_LINKS::RN_NODE_SET candidates = m_links.GetNodes();
|
||||||
RN_LINKS::RN_NODE_SET::iterator point, pointEnd;
|
RN_LINKS::RN_NODE_SET::iterator point, pointEnd;
|
||||||
|
|
||||||
// Sorting by area should speed up the processing, as smaller polygons are computed
|
// Sorting by area should speed up the processing, as smaller polygons are computed
|
||||||
// faster and may reduce the number of points for further checks
|
// faster and may reduce the number of points for further checks
|
||||||
std::sort( polygons.begin(), polygons.end(), sortArea );
|
std::sort( zoneData.m_Polygons.begin(), zoneData.m_Polygons.end(), sortArea );
|
||||||
|
|
||||||
for( std::deque<RN_POLY>::iterator poly = polygons.begin(), polyEnd = polygons.end();
|
for( std::deque<RN_POLY>::iterator poly = zoneData.m_Polygons.begin(),
|
||||||
poly != polyEnd; ++poly )
|
polyEnd = zoneData.m_Polygons.end(); poly != polyEnd; ++poly )
|
||||||
{
|
{
|
||||||
const RN_NODE_PTR& node = poly->GetNode();
|
const RN_NODE_PTR& node = poly->GetNode();
|
||||||
std::deque<RN_EDGE_MST_PTR>& connections = m_zoneConnections[poly->GetParent()];
|
|
||||||
|
|
||||||
point = candidates.begin();
|
point = candidates.begin();
|
||||||
pointEnd = candidates.end();
|
pointEnd = candidates.end();
|
||||||
|
|
||||||
while( point != pointEnd )
|
while( point != pointEnd )
|
||||||
{
|
{
|
||||||
if( *point == node )
|
if( *point != node && poly->HitTest( *point ) )
|
||||||
{
|
|
||||||
++point;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( poly->HitTest( *point ) )
|
|
||||||
{
|
{
|
||||||
RN_EDGE_MST_PTR connection = m_links.AddConnection( node, *point );
|
RN_EDGE_MST_PTR connection = m_links.AddConnection( node, *point );
|
||||||
connections.push_back( connection );
|
zoneData.m_Edges.push_back( connection );
|
||||||
|
|
||||||
// This point already belongs to a polygon, we do not need to check it anymore
|
// This point already belongs to a polygon, we do not need to check it anymore
|
||||||
point = candidates.erase( point );
|
point = candidates.erase( point );
|
||||||
|
|
|
@ -207,8 +207,8 @@ protected:
|
||||||
class RN_POLY
|
class RN_POLY
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RN_POLY( const CPolyPt* aBegin, const CPolyPt* aEnd, const ZONE_CONTAINER* aParent,
|
RN_POLY( const CPolyPt* aBegin, const CPolyPt* aEnd,
|
||||||
RN_LINKS& aConnections, const BOX2I& aBBox );
|
RN_LINKS& aConnections, const BOX2I& aBBox );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetNode()
|
* Function GetNode()
|
||||||
|
@ -220,16 +220,6 @@ public:
|
||||||
return m_node;
|
return m_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetParent()
|
|
||||||
* Returns pointer to zone that is the owner of subpolygon.
|
|
||||||
* @return Pointer to zone that is the owner of subpolygon.
|
|
||||||
*/
|
|
||||||
const ZONE_CONTAINER* GetParent() const
|
|
||||||
{
|
|
||||||
return m_parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function HitTest()
|
* Function HitTest()
|
||||||
* Tests if selected node is located within polygon boundaries.
|
* Tests if selected node is located within polygon boundaries.
|
||||||
|
@ -239,9 +229,6 @@ public:
|
||||||
bool HitTest( const RN_NODE_PTR& aNode ) const;
|
bool HitTest( const RN_NODE_PTR& aNode ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///> Owner of this subpolygon.
|
|
||||||
const ZONE_CONTAINER* m_parent;
|
|
||||||
|
|
||||||
///> Pointer to the first point of polyline bounding the polygon.
|
///> Pointer to the first point of polyline bounding the polygon.
|
||||||
const CPolyPt* m_begin;
|
const CPolyPt* m_begin;
|
||||||
|
|
||||||
|
@ -526,12 +513,20 @@ protected:
|
||||||
///> Flag indicating necessity of recalculation of ratsnest for a net.
|
///> Flag indicating necessity of recalculation of ratsnest for a net.
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
///> Subpolygons belonging to a zone
|
||||||
|
std::deque<RN_POLY> m_Polygons;
|
||||||
|
|
||||||
|
///> Connections to other nodes
|
||||||
|
std::deque<RN_EDGE_MST_PTR> m_Edges;
|
||||||
|
} RN_ZONE_DATA;
|
||||||
|
|
||||||
///> Helper typedefs
|
///> Helper typedefs
|
||||||
typedef boost::unordered_map<const D_PAD*, RN_NODE_PTR> PAD_NODE_MAP;
|
typedef boost::unordered_map<const D_PAD*, RN_NODE_PTR> PAD_NODE_MAP;
|
||||||
typedef boost::unordered_map<const VIA*, RN_NODE_PTR> VIA_NODE_MAP;
|
typedef boost::unordered_map<const VIA*, RN_NODE_PTR> VIA_NODE_MAP;
|
||||||
typedef boost::unordered_map<const TRACK*, RN_EDGE_MST_PTR> TRACK_EDGE_MAP;
|
typedef boost::unordered_map<const TRACK*, RN_EDGE_MST_PTR> TRACK_EDGE_MAP;
|
||||||
typedef boost::unordered_map<const ZONE_CONTAINER*, std::deque<RN_POLY> > ZONE_POLY_MAP;
|
typedef boost::unordered_map<const ZONE_CONTAINER*, RN_ZONE_DATA> ZONE_DATA_MAP;
|
||||||
typedef boost::unordered_map<const ZONE_CONTAINER*, std::deque<RN_EDGE_MST_PTR> > ZONE_EDGE_MAP;
|
|
||||||
|
|
||||||
///> Map that associates nodes in the ratsnest model to respective nodes.
|
///> Map that associates nodes in the ratsnest model to respective nodes.
|
||||||
PAD_NODE_MAP m_pads;
|
PAD_NODE_MAP m_pads;
|
||||||
|
@ -543,10 +538,7 @@ protected:
|
||||||
TRACK_EDGE_MAP m_tracks;
|
TRACK_EDGE_MAP m_tracks;
|
||||||
|
|
||||||
///> Map that associates groups of subpolygons in the ratsnest model to respective zones.
|
///> Map that associates groups of subpolygons in the ratsnest model to respective zones.
|
||||||
ZONE_POLY_MAP m_zonePolygons;
|
ZONE_DATA_MAP m_zones;
|
||||||
|
|
||||||
///> Map that associates groups of edges in the ratsnest model to respective zones.
|
|
||||||
ZONE_EDGE_MAP m_zoneConnections;
|
|
||||||
|
|
||||||
///> Visibility flag.
|
///> Visibility flag.
|
||||||
bool m_visible;
|
bool m_visible;
|
||||||
|
|
Loading…
Reference in New Issue