⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractshapebuilder.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: AbstractShapeBuilder.java * Written by: Dmitry Nadezhin, Sun Microsystems. * * Copyright (c) 2003 Sun Microsystems and Static Free Software * * Electric(tm) 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. * * Electric(tm) 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.q * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.technology;import com.sun.electric.database.CellBackup;import com.sun.electric.database.CellRevision;import com.sun.electric.database.ImmutableArcInst;import com.sun.electric.database.ImmutableNodeInst;import com.sun.electric.database.geometry.DBMath;import com.sun.electric.database.geometry.EPoint;import com.sun.electric.database.geometry.GenMath;import com.sun.electric.database.geometry.Poly;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.id.NodeProtoId;import com.sun.electric.database.id.PrimitiveNodeId;import java.awt.geom.Point2D;/** * A support class to build shapes of arcs and nodes. */public abstract class AbstractShapeBuilder {    protected Layer.Function.Set onlyTheseLayers;//    private long onlyTheseLayersMask = -1L;    protected boolean reasonable;    protected boolean electrical;        protected double[] doubleCoords = new double[8];    protected int pointCount;     public int[] intCoords = new int[4];    private CellBackup.Memoization m;    private Shrinkage shrinkage;    private TechPool techPool;        /** Creates a new instance of AbstractShapeBuilder */    public AbstractShapeBuilder() {    }       public Layer.Function.Set getOnlyTheseLayers() { return onlyTheseLayers; }    public void setOnlyTheseLayers(Layer.Function.Set onlyTheseLayers) {        this.onlyTheseLayers = onlyTheseLayers;//        onlyTheseLayersMask = onlyTheseLayers != null ? onlyTheseLayers.bits : 0;    }    public void setReasonable(boolean b) { reasonable = b; }    public void setElectrical(boolean b) { electrical = b; }        public void setup(Cell cell) {        setup(cell.backupUnsafe());    }        public void setup(CellBackup cellBackup) {        this.m = cellBackup.getMemoization();        this.shrinkage = cellBackup.getShrinkage();        this.techPool = cellBackup.techPool;    }        public CellBackup.Memoization getMemoization() {        return m;    }    public Shrinkage getShrinkage() {        return shrinkage;    }    public TechPool getTechPool() {        return techPool;    }        public void genShapeOfArc(ImmutableArcInst a) {        if (genShapeEasy(a))            return;        pointCount = 0;        techPool.getTech(a.protoId.techId).getShapeOfArc(this, a);    }    	/**	 * Method to fill in an AbstractShapeBuilder a polygon that describes this ImmutableArcInst in grid units.	 * The polygon is described by its width, and style.     * @param a the arc information.	 * @param gridWidth the gridWidth of the Poly.	 * @param style the style of the Poly.	 */    public void makeGridPoly(ImmutableArcInst a, long gridWidth, Poly.Type style, Layer layer) {//        long[] result;        if (techPool.getArcProto(a.protoId).isCurvable()) {            // get the radius information on the arc            Double radiusDouble = a.getRadius();            if (radiusDouble != null && curvedArcGridOutline(a, gridWidth, DBMath.lambdaToGrid(radiusDouble))) {                pushPoly(style, layer);                return;            }        }                // zero-width polygons are simply lines        if (gridWidth <= 0) {            pushPoint(a.tailLocation);            pushPoint(a.headLocation);            if (style == Poly.Type.FILLED) style = Poly.Type.OPENED;            pushPoly(style, layer);            return;        }                // make the polygon		int w2 = ((int)gridWidth) >>> 1;        short shrinkT = a.isTailExtended() ? shrinkage.get(a.tailNodeId) : Shrinkage.EXTEND_0;        short shrinkH = a.isHeadExtended() ? shrinkage.get(a.headNodeId) : Shrinkage.EXTEND_0;        int angle = a.getAngle();        double w2x = DBMath.roundShapeCoord(w2*GenMath.cos(angle));        double w2y = DBMath.roundShapeCoord(w2*GenMath.sin(angle));        double tx = 0;        double ty = 0;        if (shrinkT == Shrinkage.EXTEND_90) {            tx = -w2x;            ty = -w2y;        } else if (shrinkT != Shrinkage.EXTEND_0) {            Point2D e = computeExtension(w2, -w2x, -w2y, a.getOppositeAngle(), shrinkT);            tx = e.getX();            ty = e.getY();        }        double hx = 0;        double hy = 0;        if (shrinkH == Shrinkage.EXTEND_90) {            hx = w2x;            hy = w2y;        } else if (shrinkH != Shrinkage.EXTEND_0) {            Point2D e = computeExtension(w2, w2x, w2y, angle, shrinkH);            hx = e.getX();            hy = e.getY();        }                pushPoint(a.tailLocation, tx - w2y, ty + w2x);        pushPoint(a.tailLocation, tx + w2y, ty - w2x);        pushPoint(a.headLocation, hx + w2y, hy - w2x);        pushPoint(a.headLocation, hx - w2y, hy + w2x);                // somewhat simpler if rectangle is manhattan        if (gridWidth != 0 && style.isOpened())            pushPoint(a.tailLocation, tx - w2y, ty + w2x);        pushPoly(style, layer);    }        /**     * Computes extension vector of wire,      */    public static Point2D computeExtension(int w2, double ix1, double iy1, int angle, short shrink) {        if (shrink == Shrinkage.EXTEND_90) return new Point2D.Double(ix1, iy1);        if (shrink == Shrinkage.EXTEND_0) return new Point2D.Double(0, 0);        assert shrink >= Shrinkage.EXTEND_ANY;        int angle2 = (shrink - Shrinkage.EXTEND_ANY) - angle;        if (angle2 < 0)            angle2 += 3600;        double x1 = ix1;        double y1 = iy1;        double s1;        if (y1 == 0) {            if (x1 > 0) {                s1 = x1;                x1 = 1;            } else if (x1 < 0) {                s1 = -x1;                x1 = -1;            } else {                return new Point2D.Double(0, 0);            }        } else if (x1 == 0) {            if (y1 > 0) {                s1 = y1;                y1 = 1;            } else {                s1 = -y1;                y1 = -1;            }        } else {            s1 = x1*x1 + y1*y1;        }                double x2 = DBMath.roundShapeCoord(w2*GenMath.cos(angle2));        double y2 = DBMath.roundShapeCoord(w2*GenMath.sin(angle2));        double s2;        if (y2 == 0) {            if (x2 > 0) {                s2 = x2;                x2 = 1;            } else if (x2 < 0) {                s2 = -x2;                x2 = -1;            } else {                return new Point2D.Double(0, 0);            }        } else if (x2 == 0) {            if (y2 > 0) {                s2 = y2;                y2 = 1;            } else {                s2 = -y2;                y2 = -1;            }        } else {            s2 = x2*x2 + y2*y2;        }                double det = x1*y2 - y1*x2;        if (det == 0) return new Point2D.Double(0, 0);        double x = (x2*s1 + x1*s2)/det;        double y = (y2*s1 + y1*s2)/det;        x = DBMath.roundShapeCoord(x);        y = DBMath.roundShapeCoord(y);        x = x + iy1;        y = y - ix1;        if (det < 0) {            x = -x;            y = -y;        }        return new Point2D.Double(x, y);    }    	/**	 * when arcs are curved, the number of line segments will be	 * between this value, and half of this value.	 */	private static final int MAXARCPIECES = 16;	/**     * Method to fill polygon "poly" with the outline in grid units of the curved arc in     * this ImmutableArcInst whose width in grid units is "gridWidth".     * If there is no curvature information in the arc, the routine returns false,     * otherwise it returns the curved polygon.     * @param a the arc information.     * @param gridWidth width in grid units.     * @param gridRadius radius in grid units.     * @return true if point were filled to the buuilder     */    public boolean curvedArcGridOutline(ImmutableArcInst a, long gridWidth, long gridRadius) {        // get information about the curved arc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -