Commit 7f3bf1be authored by Maciej Suminski's avatar Maciej Suminski

Added missing operators==/!= for RN_NODE_PTR.

Moved ClearSimple() functions back to the header file.
parent 7f464814
......@@ -35,7 +35,6 @@
#include <class_track.h>
#include <class_zone.h>
#include <boost/foreach.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/make_shared.hpp>
......@@ -75,10 +74,21 @@ bool sortArea( const RN_POLY& aP1, const RN_POLY& aP2 )
}
bool operator==( const RN_NODE_PTR& aFirst, const RN_NODE_PTR& aSecond )
{
return aFirst->GetX() == aSecond->GetX() && aFirst->GetY() == aSecond->GetY();
}
bool operator!=( const RN_NODE_PTR& aFirst, const RN_NODE_PTR& aSecond )
{
return aFirst->GetX() != aSecond->GetX() || aFirst->GetY() != aSecond->GetY();
}
bool isEdgeConnectingNode( const RN_EDGE_PTR& aEdge, const RN_NODE_PTR& aNode )
{
return ( aEdge->getSourceNode().get() == aNode.get() ) ||
( aEdge->getTargetNode().get() == aNode.get() );
return aEdge->getSourceNode() == aNode || aEdge->getTargetNode() == aNode;
}
......@@ -246,7 +256,7 @@ void RN_NET::compute()
return;
}
else if( boardNodes.size() == 1 || boardNodes.empty() ) // This case is even simpler
else if( boardNodes.size() <= 1 ) // This case is even simpler
{
m_rnEdges.reset( new std::vector<RN_EDGE_PTR>( 0 ) );
......@@ -566,17 +576,18 @@ const RN_NODE_PTR RN_NET::GetClosestNode( const RN_NODE_PTR& aNode,
for( it = nodes.begin(), itEnd = nodes.end(); it != itEnd; ++it )
{
RN_NODE_PTR baseNode = *it;
RN_NODE_PTR node = *it;
// Obviously the distance between node and itself is the shortest,
// that's why we have to skip it
if( *it != aNode && aFilter( baseNode ) )
if( node != aNode && aFilter( node ) )
{
unsigned int distance = getDistance( *it, aNode );
unsigned int distance = getDistance( node, aNode );
if( distance < minDistance )
{
minDistance = distance;
closest = *it;
closest = node;
}
}
}
......@@ -706,15 +717,6 @@ void RN_DATA::AddSimple( const BOARD_ITEM* aItem )
}
void RN_NET::ClearSimple()
{
BOOST_FOREACH( const RN_NODE_PTR& node, m_simpleNodes )
node->SetFlag( false );
m_simpleNodes.clear();
}
void RN_NET::processZones()
{
BOOST_FOREACH( std::deque<RN_EDGE_PTR>& edges, m_zoneConnections | boost::adaptors::map_values )
......@@ -935,10 +937,3 @@ void RN_DATA::Recalculate( int aNet )
updateNet( aNet );
}
}
void RN_DATA::ClearSimple()
{
BOOST_FOREACH( RN_NET& net, m_nets )
net.ClearSimple();
}
......@@ -37,6 +37,7 @@
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
#include <boost/foreach.hpp>
class BOARD;
class BOARD_ITEM;
......@@ -57,6 +58,9 @@ typedef hed::EdgeMST RN_EDGE_MST;
typedef boost::shared_ptr<hed::EdgeMST> RN_EDGE_MST_PTR;
typedef hed::Triangulation TRIANGULATOR;
bool operator==( const RN_NODE_PTR& aFirst, const RN_NODE_PTR& aSecond );
bool operator!=( const RN_NODE_PTR& aFirst, const RN_NODE_PTR& aSecond );
///> General interface for filtering out nodes in search functions.
struct RN_NODE_FILTER : public std::unary_function<const RN_NODE_PTR&, bool>
{
......@@ -83,7 +87,7 @@ struct RN_NODE_COMPARE : std::binary_function<RN_NODE_PTR, RN_NODE_PTR, bool>
{
bool operator()( const RN_NODE_PTR& aNode1, const RN_NODE_PTR& aNode2 ) const
{
return ( aNode1->GetX() == aNode2->GetX() && aNode1->GetY() == aNode2->GetY() );
return aNode1 == aNode2;
}
};
......@@ -461,7 +465,13 @@ public:
* Function ClearSimple()
* Removes all nodes and edges that are used for displaying ratsnest in simple mode.
*/
void ClearSimple();
void ClearSimple()
{
BOOST_FOREACH( const RN_NODE_PTR& node, m_simpleNodes )
node->SetFlag( false );
m_simpleNodes.clear();
}
protected:
///> Validates edge, ie. modifies source and target nodes for an edge
......@@ -556,7 +566,11 @@ public:
* Function ClearSimple()
* Clears the list of nodes for which ratsnest is drawn in simple mode (one line per node).
*/
void ClearSimple();
void ClearSimple()
{
BOOST_FOREACH( RN_NET& net, m_nets )
net.ClearSimple();
}
/**
* Function ProcessBoard()
......
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