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

📄 polymerge.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			if (sourceAreaB != null)			{				destArea = new Area(sourceAreaA);				destArea.subtract(sourceAreaB);				if (destArea.isEmpty()) destArea = null;			}		}		if (destArea == null) layers.remove(dest); else			layers.put(dest, destArea);	}	/**	 * Method to subtract another Merge to this one.	 * @param other the other Merge to subtract.	 */	public void subtractMerge(PolyMerge other)	{		for(Layer subLayer : other.layers.keySet())		{			Area area = (Area)layers.get(subLayer);			if (area == null) continue;			Area subArea = (Area)other.layers.get(subLayer);			area.subtract(subArea);		}	}	/**	 * Method to inset one layer by a given amount and create a second layer.	 * @param source the Layer to inset.	 * @param dest the destination layer to place the inset geometry.	 * @param amount the distance to inset the layer.	 */	public void insetLayer(Layer source, Layer dest, double amount)	{		Area sourceArea = (Area)layers.get(source);		if (sourceArea == null) layers.remove(dest); else		{			layers.put(dest, sourceArea.clone());			if (amount == 0) return;			List<PolyBase> orig = getAreaPoints(sourceArea, source, true);			Point2D [] subtractPoints = new Point2D[4];			for(PolyBase poly : orig)			{				Point2D [] points = poly.getPoints();				for(int i=0; i<points.length; i++)				{					int last = i-1;					if (last < 0) last = points.length-1;					Point2D lastPt = points[last];					Point2D thisPt = points[i];					if (DBMath.areEquals(lastPt, thisPt)) continue;					int angle = DBMath.figureAngle(lastPt, thisPt);					int perpAngle = (angle + 2700) % 3600;					double offsetX = DBMath.cos(perpAngle) * amount;					double offsetY = DBMath.sin(perpAngle) * amount;					Point2D insetLastPt = new Point2D.Double(lastPt.getX() + offsetX, lastPt.getY() + offsetY);					Point2D insetThisPt = new Point2D.Double(thisPt.getX() + offsetX, thisPt.getY() + offsetY);					subtractPoints[0] = lastPt;					subtractPoints[1] = thisPt;					subtractPoints[2] = insetThisPt;					subtractPoints[3] = insetLastPt;					PolyBase subtractPoly = new PolyBase(subtractPoints);					subtract(dest, subtractPoly);				}			}		}	}	/**	 * Method to delete all geometry on a given layer.	 * @param layer the Layer to clear in this merge.	 */	public void deleteLayer(Layer layer)	{		layers.remove(layer);	}	/**	 * Method to tell whether there is any valid geometry on a given layer of this merge.	 * @param layer the layer to test.	 * @return true if there is no valid geometry on the given layer in this merge.	 */	public boolean isEmpty(Layer layer)	{		Area area = (Area)layers.get(layer);		if (area == null) return true;		return area.isEmpty();	}	/**	 * Method to determine whether a rectangle exists in the merge.	 * @param layer the layer being tested.	 * @param rect the rectangle being tested.	 * @return true if all of the rectangle is inside of the merge on the given layer.	 */	public boolean contains(Layer layer, Rectangle2D rect)	{		Area area = (Area)layers.get(layer);		if (area == null) return false;		if (area.contains(rect)) return true;		Area rectArea = new Area(rect);		rectArea.subtract(area);				// if the new area is empty, then the poly is completely contained in the merge		if (rectArea.isEmpty()) return true;		double remainingArea = getAreaOfArea(rectArea);		if (DBMath.areEquals(remainingArea, 0)) return true;		return false;	}	/**	 * Method to determine whether a polygon exists in the merge.	 * @param layer the layer being tested.	 * @param poly the polygon being tested.	 * @return true if all of the polygon is inside of the merge on the given layer.	 */	public boolean contains(Layer layer, PolyBase poly)	{		// find the area for the given layer		Area area = (Area)layers.get(layer);		if (area == null) return false;		// create an area that is the new polygon minus the original area		Area polyArea = new Area(poly);		polyArea.subtract(area);				// if the new area is empty, then the poly is completely contained in the merge		if (polyArea.isEmpty()) return true;		double remainingArea = getAreaOfArea(polyArea);		if (DBMath.areEquals(remainingArea, 0)) return true;		return false;	}	/**	 * Method to see if an arc fits in this merge with or without end extension.	 * @param layer the layer of the arc being examined.	 * @param headLoc the head location of the arc.	 * @param tailLoc the tail location of the arc.	 * @param wid the width of the arc.	 * @param headExtend the head extension of the arc (is set false if extension not possible).	 * @param tailExtend the tail extension of the arc (is set false if extension not possible).	 * @return true if the arc fits in the merge.  May change "noHeadExtend" and "noTailExtend".	 * Returns false if the arc cannot fit.	 */	public boolean arcPolyFits(Layer layer, Point2D headLoc, Point2D tailLoc, double wid,		MutableBoolean headExtend, MutableBoolean tailExtend)	{		// try arc with default end extension		int ang = 0;		if (headLoc.getX() != tailLoc.getX() || headLoc.getY() != tailLoc.getY())			ang = GenMath.figureAngle(tailLoc, headLoc);		double endExtensionHead = headExtend.booleanValue() ? wid/2 : 0;		double endExtensionTail = tailExtend.booleanValue() ? wid/2 : 0;		Poly arcPoly = Poly.makeEndPointPoly(headLoc.distance(tailLoc), wid, ang, headLoc, endExtensionHead,			tailLoc, endExtensionTail, Poly.Type.FILLED);		if (contains(layer, arcPoly)) return true;		// try removing head extension		if (headExtend.booleanValue())		{			arcPoly = Poly.makeEndPointPoly(headLoc.distance(tailLoc), wid, ang, headLoc, 0,				tailLoc, endExtensionTail, Poly.Type.FILLED);			if (contains(layer, arcPoly)) { headExtend.setValue(false);   return true; }		}		// try removing tail extension		if (tailExtend.booleanValue())		{			arcPoly = Poly.makeEndPointPoly(headLoc.distance(tailLoc), wid, ang, headLoc, endExtensionHead,				tailLoc, 0, Poly.Type.FILLED);			if (contains(layer, arcPoly)) { tailExtend.setValue(false);   return true; }		}		// try removing head and tail extension		if (headExtend.booleanValue() && tailExtend.booleanValue())		{			arcPoly = Poly.makeEndPointPoly(headLoc.distance(tailLoc), wid, ang, headLoc, 0,				tailLoc, 0, Poly.Type.FILLED);			if (contains(layer, arcPoly)) { headExtend.setValue(false);   tailExtend.setValue(false);   return true; }		}		return false;	}	/**	 * Method to return the area on a given layer.	 * @param layer the layer to query.	 * @return the area of geometry on the given layer.	 */	public double getAreaOfLayer(Layer layer)	{		Area area = (Area)layers.get(layer);		if (area == null) return 0;		return getAreaOfArea(area);	}	private double getAreaOfArea(Area area)	{		List<PolyBase> pointList = getAreaPoints(area, null, true);		double totalArea = 0;		for(PolyBase p : pointList)		{			totalArea += p.getArea();		}		return totalArea;	}	/**	 * Method to determine whether a point exists in the merge.	 * @param layer the layer being tested.	 * @param pt the point being tested.	 * @return true if the point is inside of the merge on the given layer.	 */	public boolean contains(Layer layer, Point2D pt)	{		Area area = (Area)layers.get(layer);		if (area == null) return false;		return area.contains(pt);	}	public Collection<PolyBase> getObjects(Object layer, boolean modified, boolean simple)	{		// Since simple is used, correct detection of loops must be guaranteed		// outside.		return getMergedPoints((Layer)layer, simple);	}    /**	 * Method to return list of Polys on a given Layer in this Merge.	 * @param layer the layer in question.	 * @param simple	 * @return the list of Polys that describes this Merge.	 */    public List<PolyBase> getMergedPoints(Layer layer, boolean simple)	{		Area area = (Area)layers.get(layer);		if (area == null) return null;		return getAreaPoints(area, layer, simple);	}   	/**	 * Method to return a list of polygons in this merge for a given layer.	 * @param area the Area object that describes the merge.	 * @param layer the desired Layer.	 * @param simple true for simple polygons, false to allow complex ones.	 * @return a List of PolyBase objects that describes the layer in the merge.	 */    public static List<PolyBase> getAreaPoints(Area area, Layer layer, boolean simple)    {        return PolyBase.getPointsInArea(area, layer, simple, true);	}}

⌨️ 快捷键说明

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