From 13a1bfcc2e30f063b63fd34be501820b77677bf5 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Tue, 13 Dec 2022 21:58:30 -0500 Subject: [PATCH] Discovered that reading in polygons as subcells and then flattening can be much, much faster than reading in polygons directly into a cell from GDS. Modified the handling of polygons so that they are *always* read into subcells. If the "polygon subcell flatten true" option is not enabled, then the subcells are flattened at the end of reading the cell, and the polygon cells are deleted. This method avoids most of the cases in which "polygon subcell flatten true" has ever needed to be set. --- calma/CalmaRdcl.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ calma/CalmaRdpt.c | 6 +++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/calma/CalmaRdcl.c b/calma/CalmaRdcl.c index 375b64d0..cfc527fd 100644 --- a/calma/CalmaRdcl.c +++ b/calma/CalmaRdcl.c @@ -56,6 +56,7 @@ bool CalmaRewound = FALSE; TileTypeBitMask *CalmaMaskHints = NULL; extern HashTable calmaDefInitHash; +extern int CalmaPolygonCount; /* forward declarations */ int calmaElementSref(); @@ -274,6 +275,45 @@ calmaExact() return parray; } +/* + * ---------------------------------------------------------------------------- + * + * calmaFlattenPolygonFunc -- + * + * Polygons have been dropped into subcells by default for + * efficiency in reading. If the "subcell polygons" option + * has not been selected, then flatten these cells into the + * layout and delete the cells. This seems inefficient but + * in fact can be much faster than reading the polygons + * directly into the cell from GDS. + * + * ---------------------------------------------------------------------------- + */ + +int +calmaFlattenPolygonFunc(use, parent) + CellUse *use; + CellDef *parent; +{ + int i; + CellUse dummy; + SearchContext scx; + + if (use->cu_def == NULL || use->cu_def->cd_name == NULL) return 0; + if (strncmp(use->cu_def->cd_name, "polygon", 7)) return 0; + + dummy.cu_transform = GeoIdentityTransform; + dummy.cu_id = NULL; + dummy.cu_def = parent; + scx.scx_use = use; + scx.scx_area = use->cu_bbox; + scx.scx_trans = GeoIdentityTransform; + DBCellCopyAllPaint(&scx, &DBAllButSpaceAndDRCBits, 0, &dummy); + DBDeleteCellNoModify(use); + DBCellDeleteDef(use->cu_def); + + return 0; /* Keep the search going */ +} /* @@ -547,6 +587,12 @@ calmaParseStructure(filename) CIFPaintCurrent(FILE_CALMA); } + if ((!CalmaSubcellPolygons) && (CalmaPolygonCount > 0)) + { + DBCellEnum(cifReadCellDef, calmaFlattenPolygonFunc, (ClientData)cifReadCellDef); + CalmaPolygonCount = 0; + } + DBAdjustLabelsNew(cifReadCellDef, &TiPlaneRect, (cifCurReadStyle->crs_flags & CRF_NO_RECONNECT_LABELS) ? 1 : 0); DBReComputeBbox(cifReadCellDef); diff --git a/calma/CalmaRdpt.c b/calma/CalmaRdpt.c index a9eff150..5fc9d83e 100644 --- a/calma/CalmaRdpt.c +++ b/calma/CalmaRdpt.c @@ -248,8 +248,12 @@ calmaElementBoundary() if (ciftype >= 0) plane = cifCurReadPlanes[ciftype]; /* Convert the polygon to rectangles. */ + /* NOTE: This was previously contingent on CalmaSubcellPolygons. */ + /* However, in practice it has been found to be much faster to read */ + /* polygons into subcells and then flatten into the layout instead */ + /* of reading polygons directly into the layout. I am unsure why. */ - if (CalmaSubcellPolygons && (calmaNonManhattan > 0)) + if (calmaNonManhattan > 0) { /* Place the polygon in its own subcell */ char newname[] = "polygonXXXXX";