Skip to content

Commit

Permalink
Add idealNudgingDistance routing parameter.
Browse files Browse the repository at this point in the history
This replaces the previous orthogonalNudgeDistance methods.  It is used
to control the ideal nudging distance used for spacing out connector
corners and segments that overlap each other.
  • Loading branch information
mjwybrow committed Aug 10, 2012
1 parent 2aa2169 commit c64d677
Show file tree
Hide file tree
Showing 55 changed files with 54 additions and 94 deletions.
2 changes: 1 addition & 1 deletion cola/libavoid/junction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Rectangle JunctionRef::makeRectangle(Router *router, const Point& position)
{
COLA_ASSERT(router);

double nudgeDist = router->orthogonalNudgeDistance();
double nudgeDist = router->routingParameter(idealNudgingDistance);

Point low = position;
low.x -= nudgeDist;
Expand Down
6 changes: 3 additions & 3 deletions cola/libavoid/orthogonal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class NudgingShiftSegment : public ShiftSegment
}
double nudgeDistance(void) const
{
return connRef->router()->orthogonalNudgeDistance();
return connRef->router()->routingParameter(idealNudgingDistance);
}
bool immovable(void) const
{
Expand Down Expand Up @@ -2145,7 +2145,7 @@ static void buildOrthogonalNudgingSegments(Router *router,
const size_t n = router->m_obstacles.size();
shapeLimits = std::vector<RectBounds>(n);

double nudgeDistance = router->orthogonalNudgeDistance();
double nudgeDistance = router->routingParameter(idealNudgingDistance);

ObstacleList::iterator obstacleIt = router->m_obstacles.begin();
for (unsigned i = 0; i < n; i++)
Expand Down Expand Up @@ -2821,7 +2821,7 @@ static void nudgeOrthogonalRoutes(Router *router, size_t dimension,
{
bool nudgeFinalSegments = router->routingOption(
nudgeOrthogonalSegmentsConnectedToShapes);
double baseSepDist = router->orthogonalNudgeDistance();
double baseSepDist = router->routingParameter(idealNudgingDistance);
COLA_ASSERT(baseSepDist >= 0);
// If we can fit things with the desired separation distance, then
// we try 10 times, reducing each time by a 10th of the original amount.
Expand Down
22 changes: 5 additions & 17 deletions cola/libavoid/router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ Router::Router(const unsigned int flags)
m_largest_assigned_id(0),
m_consolidate_actions(true),
m_currently_calling_destructors(false),
m_orthogonal_nudge_distance(4.0),
m_slow_routing_callback(NULL),
m_topology_addon(new TopologyAddonInterface()),
// Mode options:
Expand Down Expand Up @@ -89,6 +88,7 @@ Router::Router(const unsigned int flags)
m_routing_parameters[segmentPenalty] = 10;
m_routing_parameters[clusterCrossingPenalty] = 4000;
m_routing_parameters[portDirectionPenalty] = 100;
m_routing_parameters[idealNudgingDistance] = 4.0;

m_routing_options[nudgeOrthogonalSegmentsConnectedToShapes] = false;
m_routing_options[improveHyperedgeRoutesMovingJunctions] = true;
Expand Down Expand Up @@ -710,19 +710,6 @@ void Router::deleteCluster(ClusterRef *cluster)
}


void Router::setOrthogonalNudgeDistance(const double dist)
{
COLA_ASSERT(dist >= 0);
m_orthogonal_nudge_distance = dist;
}


double Router::orthogonalNudgeDistance(void) const
{
return m_orthogonal_nudge_distance;
}


unsigned int Router::newObjectId(void) const
{
return m_largest_assigned_id + 1;
Expand Down Expand Up @@ -1662,7 +1649,7 @@ void Router::setRoutingParameter(const RoutingParameter parameter,
COLA_ASSERT(parameter < lastRoutingParameterMarker);
if (value < 0)
{
// Set some sensible parameter value for the parameter being 'active'..
// Set some sensible parameter value for the parameter being 'active'.
switch (parameter)
{
case segmentPenalty:
Expand All @@ -1680,6 +1667,9 @@ void Router::setRoutingParameter(const RoutingParameter parameter,
case clusterCrossingPenalty:
m_routing_parameters[parameter] = 4000;
break;
case idealNudgingDistance:
m_routing_parameters[parameter] = 4.0;
break;
default:
m_routing_parameters[parameter] = 50;
break;
Expand Down Expand Up @@ -2063,8 +2053,6 @@ void Router::outputInstanceToSVG(std::string instanceName)
fprintf(fp, " router->setRoutingOption((RoutingOption)%lu, %s);\n",
(unsigned long)p, (m_routing_options[p]) ? "true" : "false");
}
fprintf(fp, " router->setOrthogonalNudgeDistance(%g);\n\n",
orthogonalNudgeDistance());
ClusterRefList::reverse_iterator revClusterRefIt = clusterRefs.rbegin();
while (revClusterRefIt != clusterRefs.rend())
{
Expand Down
38 changes: 16 additions & 22 deletions cola/libavoid/router.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,19 @@ enum RoutingParameter
//! as a method of checking progress or cancelling overly slow
//! operations.
portDirectionPenalty,

// Used for determining the size of the routing parameter array..
//! @brief This parameter defines the spacing distance that will be added
//! to the sides of each shape when determining obstacle sizes for
//! routing. This controls how closely connectors pass shapes, and
//! can be used to prevent connectors overlapping with shape
//! boundaries. By default, this distance is set to a value of 0.
//! @note Currently used.
shapeBufferDistance,
//! @brief This parameter defines the spacing distance that will be used
//! for nudging apart overlapping corners and line segments of
//! connectors. By default, this distance is set to a value of 4.
idealNudgingDistance,

// Used for determining the size of the routing parameter array.
// This should always we the last value in the enum.
lastRoutingParameterMarker
};
Expand Down Expand Up @@ -453,25 +464,6 @@ class Router {
void moveJunction(JunctionRef *junction, const double xDiff,
const double yDiff);

//! @brief Sets a spacing distance for overlapping orthogonal
//! connectors to be nudged apart.
//!
//! By default, this distance is set to a value of 4.
//!
//! This method does not re-trigger post-processing of connectors.
//! The new distance will be used the next time rerouting is performed.
//!
//! @param[in] dist The distance to be used for orthogonal nudging.
//!
void setOrthogonalNudgeDistance(const double dist);

//! @brief Returns the spacing distance that overlapping orthogonal
//! connectors are nudged apart.
//!
//! @return The current spacing distance used for orthogonal nudging.
//!
double orthogonalNudgeDistance(void) const;

//! @brief Sets values for routing parameters, including routing
//! penalties.
//!
Expand All @@ -492,6 +484,9 @@ class Router {
//! when calling this method, then a sensible penalty value will
//! be automatically chosen.
//!
//! This method does not re-trigger processing of connectors. The new
//! parameter value will be used the next time rerouting is performed.
//!
//! @param[in] parameter The type of penalty, a RoutingParameter.
//! @param[in] value The value to be set for that parameter.
//!
Expand Down Expand Up @@ -665,7 +660,6 @@ class Router {
unsigned int m_largest_assigned_id;
bool m_consolidate_actions;
bool m_currently_calling_destructors;
double m_orthogonal_nudge_distance;
double m_routing_parameters[lastRoutingParameterMarker];
bool m_routing_options[lastRoutingOptionMarker];

Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/2junctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int test()
router1->setRoutingPenalty(Avoid::crossingPenalty);
router1->setRoutingPenalty(Avoid::fixedSharedPathPenalty);
router1->setRoutingOption(Avoid::penaliseOrthogonalSharedPathsAtConnEnds, true);
router1->setOrthogonalNudgeDistance(25);
router1->setRoutingParameter(idealNudgingDistance, 25);
poly = Avoid::Polygon(4);
poly.setPoint(0, Avoid::Point(51410, 50640));
poly.setPoint(1, Avoid::Point(51410, 50960));
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/buildOrthogonalChannelInfo1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void test()
router1->setRoutingPenalty(Avoid::crossingPenalty);
router1->setRoutingPenalty(Avoid::fixedSharedPathPenalty, 9000);
router1->setRoutingOption(Avoid::penaliseOrthogonalSharedPathsAtConnEnds, true);
router1->setOrthogonalNudgeDistance(25);
router1->setRoutingParameter(idealNudgingDistance, 25);
poly = Avoid::Polygon(4);
poly.setPoint(0, Avoid::Point(50760, 50691));
poly.setPoint(1, Avoid::Point(50760, 50775));
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/checkpointNudging1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ int main(void) {
router->setRoutingOption((RoutingOption)0, true);
router->setRoutingOption((RoutingOption)1, true);
router->setRoutingOption((RoutingOption)2, false);
router->setOrthogonalNudgeDistance(4);


#ifdef ALL
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/checkpointNudging2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ int main(void) {
router->setRoutingOption((RoutingOption)0, true);
router->setRoutingOption((RoutingOption)1, true);
router->setRoutingOption((RoutingOption)2, false);
router->setOrthogonalNudgeDistance(4);


Polygon poly1(4);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/checkpoints01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 105);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);
Rectangle rect478845150(Point(50695, 51070), Point(50705, 51080));
JunctionRef *junctionRef478845150 = new JunctionRef(router,
Point(50700, 51075), 478845150);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/connectionpin03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 200);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 110);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

Polygon poly219926511(4);
poly219926511.ps[0] = Point(50760, 51240);
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/finalSegmentNudging1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ int main(void) {
router->setRoutingOption((RoutingOption)0, true);
router->setRoutingOption((RoutingOption)1, true);
router->setRoutingOption((RoutingOption)2, false);
router->setOrthogonalNudgeDistance(4);

/*
Polygon poly1(4);
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/finalSegmentNudging2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ int main(void) {
router->setRoutingOption((RoutingOption)0, true);
router->setRoutingOption((RoutingOption)1, true);
router->setRoutingOption((RoutingOption)2, false);
router->setOrthogonalNudgeDistance(4);

/*
Polygon poly1(4);
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/finalSegmentNudging3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ int main(void) {
router->setRoutingOption((RoutingOption)1, true);
router->setRoutingOption((RoutingOption)2, false);
router->setRoutingOption((RoutingOption)3, false);
router->setOrthogonalNudgeDistance(4);

#ifdef ALL
Polygon poly1(4);
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/freeFloatingDirection01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 0);
router->setOrthogonalNudgeDistance(4);

Polygon poly2(4);
poly2.ps[0] = Point(348, 1286.05);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/hyperedge01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main(void) {
//router->setRoutingPenalty((PenaltyType)2, 200);
router->setRoutingPenalty((PenaltyType)3, 4000);
//router->setRoutingPenalty((PenaltyType)4, 110);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

JunctionRef *shapeRef171026375 = new JunctionRef(router, Point(51075, 51225), 171026375);

Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/hyperedgeLoop1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void test()
router1->setRoutingPenalty(Avoid::segmentPenalty);
router1->setRoutingPenalty(Avoid::crossingPenalty);
router1->setRoutingPenalty(Avoid::fixedSharedPathPenalty, 9000);
router1->setOrthogonalNudgeDistance(25);
router1->setRoutingParameter(idealNudgingDistance, 25);

poly = Avoid::Polygon(4);
poly.setPoint(0, Avoid::Point(50760, 50620));
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/improveHyperedge01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int test()
router->setRoutingPenalty(Avoid::segmentPenalty);
router->setRoutingPenalty(Avoid::crossingPenalty);
router->setRoutingPenalty(Avoid::fixedSharedPathPenalty);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);
router->setRoutingOption(Avoid::improveHyperedgeRoutesMovingJunctions, true);
poly = Avoid::Polygon(4);
poly.setPoint(0, Avoid::Point(51160, 50670));
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/infinity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using namespace Avoid;
int main(void) {
Router *router = new Router(OrthogonalRouting);
router->setRoutingPenalty(segmentPenalty, 50);
router->setOrthogonalNudgeDistance(10);
router->setRoutingParameter(idealNudgingDistance, 10);
Rectangle rect47(Point(51145, 50195), Point(51145+360, 50195+685));
new ShapeRef(router, rect47);
Rectangle rect46(Point(51920, 49770), Point(51920+360, 49770+310));
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/inlineShapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 0);
router->setOrthogonalNudgeDistance(4);

Polygon poly1(4);
poly1.ps[0] = Point(52, 188);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/inlineoverlap01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ int main(void) {
Router *router = new Router(OrthogonalRouting);
router->setRoutingPenalty(segmentPenalty);
router->setRoutingPenalty(fixedSharedPathPenalty);
router->setOrthogonalNudgeDistance(20);
router->setRoutingParameter(idealNudgingDistance, 20);
Rectangle rect335855988(Point(51140, 50190), Point(51510, 50885));
new ShapeRef(router, rect335855988, 335855988);
Rectangle rect548374163(Point(51915, 50415), Point(52285, 50885));
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/inlineoverlap02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 110);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

Polygon poly548374163(4);
poly548374163.ps[0] = Point(52285, 50415);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/inlineoverlap03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 110);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

Polygon poly421433292(4);
poly421433292.ps[0] = Point(51335, 50215);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/inlineoverlap04.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 110);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

Polygon poly170253204(4);
poly170253204.ps[0] = Point(50450, 50190);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/inlineoverlap05.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 110);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

Polygon poly231469760(4);
poly231469760.ps[0] = Point(6385, 9390);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/inlineoverlap06.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 210);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

Polygon poly170253204(4);
poly170253204.ps[0] = Point(50450, 50190);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/inlineoverlap07.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 110);
router->setRoutingPenalty((PenaltyType)5, 100);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

Polygon poly186982048(4);
poly186982048.ps[0] = Point(52660, 50490);
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/inlineoverlap08.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ int main(void) {
router->setRoutingOption((RoutingOption)1, true);
router->setRoutingOption((RoutingOption)2, false);
router->setRoutingOption((RoutingOption)3, false);
router->setOrthogonalNudgeDistance(4);

Polygon poly1(4);
poly1.ps[0] = Point(99, -20);
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/junction01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 105);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);
Rectangle rect478845150(Point(50695, 51070), Point(50705, 51080));
ShapeRef *shapeRef478845150 = new ShapeRef(router, rect478845150, 478845150);
ShapeConnectionPin *pin = new Avoid::ShapeConnectionPin(shapeRef478845150,
Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/junction02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 105);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);

JunctionRef *junction478845150 = new JunctionRef(router, Point(50700, 51075));

Expand Down
2 changes: 1 addition & 1 deletion cola/libavoid/tests/junction03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 105);
router->setOrthogonalNudgeDistance(25);
router->setRoutingParameter(idealNudgingDistance, 25);
Rectangle rect478845150(Point(50695, 51070), Point(50705, 51080));
JunctionRef *junctionRef478845150 = new JunctionRef(router,
Point(50700, 51075), 478845150);
Expand Down
1 change: 0 additions & 1 deletion cola/libavoid/tests/lineSegWrapperCrash1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ int main(void) {
router->setRoutingPenalty((PenaltyType)2, 0);
router->setRoutingPenalty((PenaltyType)3, 4000);
router->setRoutingPenalty((PenaltyType)4, 0);
router->setOrthogonalNudgeDistance(4);

Polygon poly29(4);
poly29.ps[0] = Point(1038.92, 415.557);
Expand Down
Loading

0 comments on commit c64d677

Please sign in to comment.