X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Frouting%2Falgorithm1%2FPenalty.java;fp=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Frouting%2Falgorithm1%2FPenalty.java;h=06cb8521a1cc1786f41c3bfa38fa299e7902bc68;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/routing/algorithm1/Penalty.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/routing/algorithm1/Penalty.java new file mode 100644 index 000000000..06cb8521a --- /dev/null +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/routing/algorithm1/Penalty.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g2d.routing.algorithm1; + +import org.simantics.g2d.routing.algorithm1.StaticRouter.Cost; + +public class Penalty { + static final double BEND_PENALTY = 1.0; + static final double CONNECTION_MARGINAL = 10.0; + static final Cost INFINITE_COST = new Cost(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); + + static final Penalty OBSTACLE_PENALTY = new Penalty(20.0, 0.0); + static final Penalty CONNECTION_SIDE_PENALTY = new Penalty(10.0, 0.0); + static final Penalty CONNECTION_CROSS_PENALTY = new Penalty(0.4, 2*CONNECTION_MARGINAL); + + double penalty; + double minDistance; + + public Penalty(double penalty, double minDistance) { + this.penalty = penalty; + this.minDistance = minDistance; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(minDistance); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(penalty); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Penalty other = (Penalty) obj; + if (Double.doubleToLongBits(minDistance) != Double + .doubleToLongBits(other.minDistance)) + return false; + if (Double.doubleToLongBits(penalty) != Double + .doubleToLongBits(other.penalty)) + return false; + return true; + } + + +}