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";