private void pReset() { drawing_.reset(); cell_ = null; resetModal(); valid = false; error_msgs.Clear(); }
private void pGCCellref(GCCell c, GeoLibPoint pos) { cell_ref = c; // Tag layer and datatype to allow this element to be filtered out from LD and geo lists. layer_nr = -1; datatype_nr = -1; point = pos; trans = new GCStrans(); trans.reset(); }
private static void defineAndWrite_Box(string outDir) { // Can the system define geometry and write it correctly to Oasis and GDS files. GeoCore g = new(); g.reset(); GCDrawingfield drawing_ = new("") { accyear = 2018, accmonth = 12, accday = 5, acchour = 2, accmin = 10, accsec = 10, modyear = 2018, modmonth = 12, modday = 5, modhour = 2, modmin = 10, modsec = 10, databaseunits = 1000, userunits = 1E-3, // 0.001 / 1E-6; libname = "noname" }; GCCell gcell = drawing_.addCell(); gcell.accyear = 2018; gcell.accmonth = 12; gcell.accday = 5; gcell.acchour = 2; gcell.accmin = 10; gcell.accsec = 10; gcell.modyear = 2018; gcell.modmonth = 12; gcell.modday = 5; gcell.modhour = 2; gcell.modmin = 10; gcell.modsec = 10; gcell.cellName = "test"; gcell.addBox(0, 0, 10, 20, 1, 0); g.setDrawing(drawing_); g.setValid(true); gds.gdsWriter gw = new(g, outDir + "simple_box.gds"); gw.save(); oasis.oasWriter ow = new(g, outDir + "simple_box.oas"); ow.save(); }
public GCCellRefArray(GCCell c, GeoLibPoint[] array, int xCount, int yCount) { cell_ref = c; point = array[0]; pitch = new GeoLibPoint((array[1].X - point.X) / xCount, (array[2].Y - point.Y) / yCount); count_x = xCount; count_y = yCount; // Tag layer and datatype to allow this element to be filtered out from LD and geo lists. layer_nr = -1; datatype_nr = -1; trans = new GCStrans(); trans.reset(); }
private static void defineAndWrite_Path(string outDir) { // Can the system define geometry and write it correctly to Oasis and GDS files. GeoCore g = new(); g.reset(); GCDrawingfield drawing_ = new("") { accyear = 2018, accmonth = 12, accday = 5, acchour = 2, accmin = 10, accsec = 10, modyear = 2018, modmonth = 12, modday = 5, modhour = 2, modmin = 10, modsec = 10, databaseunits = 1000, userunits = 0.001, libname = "noname" }; GCCell gcell = drawing_.addCell(); gcell.accyear = 2018; gcell.accmonth = 12; gcell.accday = 5; gcell.acchour = 2; gcell.accmin = 10; gcell.accsec = 10; gcell.modyear = 2018; gcell.modmonth = 12; gcell.modday = 5; gcell.modhour = 2; gcell.modmin = 10; gcell.modsec = 10; gcell.cellName = "test"; GeoLibPoint[] path = new GeoLibPoint[5]; path[0] = new GeoLibPoint(0, 0); path[1] = new GeoLibPoint(0, 10); path[2] = new GeoLibPoint(20, 10); path[3] = new GeoLibPoint(20, 40); path[4] = new GeoLibPoint(0, 40); gcell.addPath(path, 1, 0); gcell.elementList[^ 1].setWidth(5); // note that Oasis only supports factors of 2, so this gets rounded down to make a 4 unit path at the writer (for Oasis).
public GCCellRefArray(GCCell c, GeoLibPoint pos1, GeoLibPoint pos2, int xCount, int yCount) { cell_ref = c; point = pos1; GeoLibPoint p = new(pos2.X - pos1.X, pos2.Y - pos1.Y); pitch = new GeoLibPoint(p.X, p.Y); count_x = xCount; count_y = yCount; // Tag layer and datatype to allow this element to be filtered out from LD and geo lists. layer_nr = -1; datatype_nr = -1; trans = new GCStrans(); trans.reset(); }
private bool pDepend(GCCell cell) { bool b = false; foreach (GCCell cellhelp in from t in elementList where t != null select t.depend()) { if (cellhelp == cell) { b = true; } else { if (cellhelp != null && !b) { b = cellhelp.depend(cell); } } } return b; }
private bool pLoad(ref GCDrawingfield drawing) { drawing_ = drawing; layerNames = new Dictionary <string, string>(); valid = true; resetModal(); try { statusUpdateUI?.Invoke("Loading"); progressUpdateUI?.Invoke(0); Stream s = File.OpenRead(filename); if (filename.ToLower().EndsWith("gz")) { using GZipStream gzs = new(s, CompressionMode.Decompress); MemoryStream ms = new(); gzs.CopyTo(ms); ms.Seek(0, SeekOrigin.Begin); br = new EndianBinaryReader(EndianBitConverter.Big, ms); } else { br = new EndianBinaryReader(EndianBitConverter.Big, s); } System.Text.Encoding ascii = System.Text.Encoding.ASCII; cell_ = null; long pos = br.BaseStream.Position; long len = br.BaseStream.Length; long updateInterval = len / 100; double progress = 0; while (pos < len) { switch (pos % updateInterval) { case 0: progressUpdateUI?.Invoke(progress); progress += 0.01f; break; } reclen = br.ReadUInt16(); record = br.ReadByte(); type = br.ReadByte(); switch (type) { case 0: break; // no data case 1: items = (reclen - 4) / 2; // bit array break; case 2: items = (reclen - 4) / 2; // two byte signed int break; case 3: items = (reclen - 4) / 4; // four byte signed int break; case 4: items = (reclen - 4) / 4; // four byte real break; case 5: items = (reclen - 4) / 8; // eight byte real break; case 6: items = reclen - 4; // ASC break; } switch (record) { case 0: // header help16 = br.ReadInt16(); break; case 1: // bgnlib drawing_.modyear = br.ReadInt16(); drawing_.modmonth = br.ReadInt16(); drawing_.modday = br.ReadInt16(); drawing_.modhour = br.ReadInt16(); drawing_.modmin = br.ReadInt16(); drawing_.modsec = br.ReadInt16(); // drawing mod time above drawing_.accyear = br.ReadInt16(); drawing_.accmonth = br.ReadInt16(); drawing_.accday = br.ReadInt16(); drawing_.acchour = br.ReadInt16(); drawing_.accmin = br.ReadInt16(); drawing_.accsec = br.ReadInt16(); // drawing access time above break; case 2: // LIBNAM byte[] tmp_lbnbyte = br.ReadBytes(items); char[] tmplbnchars = new char[ascii.GetCharCount(tmp_lbnbyte, 0, tmp_lbnbyte.Length)]; ascii.GetChars(tmp_lbnbyte, 0, tmp_lbnbyte.Length, tmplbnchars, 0); drawing_.libname = new string(tmplbnchars); // br.ReadString(); // Some files have null termination issues. string[] lNTokens = drawing_.libname.Split(new [] { '\0' }); drawing_.libname = lNTokens[0]; break; case 3: // UNITS double_ = read8ByteReal(); drawing_.userunits = double_; double_ = read8ByteReal(); drawing_.databaseunits = double_; break; case 4: // ENDLIB break; case 5: // BGNSTR cell_ = drawing_.addCell(); cell_.modyear = br.ReadInt16(); cell_.modmonth = br.ReadInt16(); cell_.modday = br.ReadInt16(); cell_.modhour = br.ReadInt16(); cell_.modmin = br.ReadInt16(); cell_.modsec = br.ReadInt16(); cell_.accyear = br.ReadInt16(); cell_.accmonth = br.ReadInt16(); cell_.accday = br.ReadInt16(); cell_.acchour = br.ReadInt16(); cell_.accmin = br.ReadInt16(); cell_.accsec = br.ReadInt16(); break; case 6: // STRNAM byte[] tmp_strnbyte = br.ReadBytes(items); char[] tmpstrnchars = new char[ascii.GetCharCount(tmp_strnbyte, 0, tmp_strnbyte.Length)]; ascii.GetChars(tmp_strnbyte, 0, tmp_strnbyte.Length, tmpstrnchars, 0); cell_.cellName = new string(tmpstrnchars); // Some files have null termination issues. string[] tokens = cell_.cellName.Split(new [] { '\0' }); cell_.cellName = tokens[0]; break; case 7: // ENDSTR break; case 8: // BONDRY -> Polygon modal.elementmode = 110; break; case 9: //PATH modal.elementmode = 150; modal.angle = 0; modal.mag = 1; modal.mirror_x = false; modal.width = 0; modal.cap = 0; modal.endExt = 0; modal.beginExt = 0; break; case 10: //SREF modal.elementmode = 120; modal.angle = 0; modal.mag = 1; modal.mirror_x = false; modal.rotate = false; modal.mag_ = false; break; case 11: //AREF modal.elementmode = 130; modal.angle = 0; modal.mag = 1; modal.mirror_x = false; modal.rotate = false; modal.mag_ = false; break; case 12: //TEXT modal.elementmode = 140; modal.angle = 0; modal.mag = 1; modal.width = 0; modal.mirror_x = false; modal.rotate = false; modal.mag_ = false; modal.presentation = 0; break; case 13: //LAYER modal.layer = br.ReadInt16(); break; case 14: //DATATYPE modal.datatype = br.ReadInt16(); try { layerNames.Add("L" + modal.layer + "D" + modal.datatype, "L" + modal.layer + "D" + modal.datatype); } catch (Exception) { } break; case 15: //WIDTH modal.width = br.ReadInt32(); switch (modal.width) { case < 0: modal.width = -modal.width; break; } modal.width = modal.width switch { // Zero width is problematic for Variance and Quilt. 0 => 10, _ => modal.width }; break; case 16: //XY modal.point_array = new GeoLibPoint[items / 2]; for (int g = 0; g < modal.point_array.Length; g++) { int32x = br.ReadInt32(); int32y = br.ReadInt32(); modal.point_array[g] = new GeoLibPoint(int32x, int32y); } break; case 17: //ENDEL // Looks like some cases, we don't register the associated LD (e.g. layers with only text). Workaround for now until cause is understood. try { layerNames.Add("L" + modal.layer + "D" + modal.datatype, "L" + modal.layer + "D" + modal.datatype); } catch (Exception) { } switch (modal.elementmode) { case 100: addBox(); break; case 110: addPolygon(); break; case 120: addCellRef(); break; case 130: addCellRefArray(); break; case 140: addText(); break; case 150: addPath(); break; } resetModal(); break; case 18: //SNAME byte[] tmp_snamebyte = br.ReadBytes(items); char[] tmpnamechars = new char[ascii.GetCharCount(tmp_snamebyte, 0, tmp_snamebyte.Length)]; ascii.GetChars(tmp_snamebyte, 0, tmp_snamebyte.Length, tmpnamechars, 0); modal.sname = new string(tmpnamechars); // Some files have null termination issues. string[] sNtokens = modal.sname.Split(new [] { '\0' }); modal.sname = sNtokens[0]; break; case 19: //COLROW modal.anzx = br.ReadInt16(); modal.anzy = br.ReadInt16(); break; /*case 20: //TXTNOD * break; * case 21: //NODE * break;*/ case 22: //TXTTYP modal.textType = br.ReadInt16(); modal.datatype = modal.textType; // we don't treat text differently. break; case 23: //PRSTTN modal.presentation = br.ReadInt16() & 0x000F; break; /*case 24: //SPACNG * break;*/ case 25: //STRING byte[] tmp_strbyte = br.ReadBytes(items); char[] tmpstrchars = new char[ascii.GetCharCount(tmp_strbyte, 0, tmp_strbyte.Length)]; ascii.GetChars(tmp_strbyte, 0, tmp_strbyte.Length, tmpstrchars, 0); modal.sname = new string(tmpstrchars); // Some files have null termination issues. string[] sN2tokens = modal.sname.Split(new [] { '\0' }); modal.sname = sN2tokens[0]; break; case 26: //STRANS int16 = br.ReadInt16(); modal.mirror_x = (int16 & 0x8000) != 0; modal.rotate = (int16 & 0x0002) != 0; modal.mag_ = (int16 & 0x0004) != 0; break; case 27: //MAG modal.mag = read8ByteReal(); break; case 28: //ANGLE modal.angle = read8ByteReal(); break; /*case 29: //UINTEG * break; * case 30: //USTRNG * break; * case 31: //REFLIB * s=readString(&ts,items); * if (layout::debug){ * printf("REFLIB %s\n",s.latin1()); * } * break; * case 32: //FONTS * break;*/ case 33: //PTHTYP modal.cap = br.ReadInt16(); break; /*case 34: //GENRTS * break; * case 35: //ATRTBL * break; * case 36: //STPTBL * break; * case 37: //STRTYP * break; * case 38: //EFLAGS * break; * case 39: //ELKEY * break; * case 40: //LNKTYP * break; * case 41: //LNKKEYa * break; * case 42: //NODTYP * break; * case 43: //PROATR * break; * case 44: //PROVAL * break;*/ case 45: //BOX modal.elementmode = 100; break; case 46: //BOXTYP modal.boxType = br.ReadInt16(); break; /*case 47: //PLEX * break;*/ case 48: //BGNEXTN modal.beginExt = br.ReadInt32(); break; case 49: //ENDEXTN modal.endExt = br.ReadInt32(); break; /*case 50: //TAPNUM * break; * case 51: //TAPCOD * break; * case 52: //STRCLS * break; * case 53: //RESRVD * break; * case 54: //FORMAT * break; * case 55: //MASK * break; * case 56: //ENDMSK * break; * case 57: //LDIRSZ * break; * case 58: //SRFNAM * break; * case 59: //LIBSCR * break;*/ default: for (int i = 0; i < items; i++) { switch (type) { case 0: // No Data break; case 1: // Bit Array int16 = br.ReadInt16(); break; case 2: // Two Byte signed int int16 = br.ReadInt16(); break; case 3: // Four Byte signed int int32 = br.ReadInt32(); break; case 4: // Four byte real int32 = br.ReadInt32(); break; case 5: // Eight byte real int32 = br.ReadInt32(); break; case 6: // ASC help = br.ReadByte(); break; } } break; } pos = br.BaseStream.Position; } try { drawing_.active_cell = drawing.findCellIndex(cell_.cellName); drawing_.resize(drawing_.userunits / 1E-3); } catch (Exception) { const string err = "Unable to find any cells. Is this file legal GDS?"; error_msgs.Add(err); throw new Exception(err); } statusUpdateUI?.Invoke("Done"); progressUpdateUI?.Invoke(1.0f); } catch (Exception e) { valid = false; error_msgs.Add(e.Message); } return(valid); }
private static void defineAndWrite_Polygon(string outDir) { // Can the system define geometry and write it correctly to Oasis and GDS files. GeoCore g = new(); g.reset(); GCDrawingfield drawing_ = new("") { accyear = 2018, accmonth = 12, accday = 5, acchour = 2, accmin = 10, accsec = 10, modyear = 2018, modmonth = 12, modday = 5, modhour = 2, modmin = 10, modsec = 10, databaseunits = 1000, userunits = 0.001, libname = "noname" }; GCCell gcell = drawing_.addCell(); gcell.accyear = 2018; gcell.accmonth = 12; gcell.accday = 5; gcell.acchour = 2; gcell.accmin = 10; gcell.accsec = 10; gcell.modyear = 2018; gcell.modmonth = 12; gcell.modday = 5; gcell.modhour = 2; gcell.modmin = 10; gcell.modsec = 10; gcell.cellName = "test"; // L GeoLibPoint[] poly = new GeoLibPoint[6]; poly[0] = new GeoLibPoint(0, 0); poly[1] = new GeoLibPoint(0, 20); poly[2] = new GeoLibPoint(10, 20); poly[3] = new GeoLibPoint(10, 10); poly[4] = new GeoLibPoint(20, 10); poly[5] = new GeoLibPoint(20, 0); gcell.addPolygon(poly, 1, 0); // triangle poly = new GeoLibPoint[3]; poly[0] = new GeoLibPoint(0, 0); poly[1] = new GeoLibPoint(10, 20); poly[2] = new GeoLibPoint(20, 0); gcell.addPolygon(poly, 2, 0); // pentagram poly = new GeoLibPoint[5]; poly[0] = new GeoLibPoint(5, 0); poly[1] = new GeoLibPoint(0, 10); poly[2] = new GeoLibPoint(10, 20); poly[3] = new GeoLibPoint(20, 10); poly[4] = new GeoLibPoint(15, 0); gcell.addPolygon(poly, 3, 0); // trapezoid poly = new GeoLibPoint[4]; poly[0] = new GeoLibPoint(0, 0); poly[1] = new GeoLibPoint(5, 20); poly[2] = new GeoLibPoint(15, 20); poly[3] = new GeoLibPoint(20, 0); gcell.addPolygon(poly, 4, 0); // parallelogram poly = new GeoLibPoint[4]; poly[0] = new GeoLibPoint(0, 0); poly[1] = new GeoLibPoint(10, 20); poly[2] = new GeoLibPoint(20, 20); poly[3] = new GeoLibPoint(10, 0); gcell.addPolygon(poly, 5, 0); g.setDrawing(drawing_); g.setValid(true); gds.gdsWriter gw = new(g, outDir + "simple_polygon.gds"); gw.save(); oasis.oasWriter ow = new(g, outDir + "simple_polygon.oas"); ow.save(); }
private void pAddCellref(GCCell c, GeoLibPoint pos) { GCElement e = new GCCellref(c, pos); pAddElement(e); }
private void writeLayout_implant(Results_implant currentResult, int resultEntry, int numberOfCases, int type) { string layoutFileName = baseFileName; string paddingString = "D" + numberOfCases.ToString().Length; // count chars in the number of cases as a string, use that to define padding. layoutFileName += "_run" + resultEntry.ToString(paddingString); int scale = 100; // for 0.01 nm resolution GeoCore g = new(); g.reset(); GCDrawingfield drawing_ = new("") { accyear = (short)DateTime.Now.Year, accmonth = (short)DateTime.Now.Month, accday = (short)DateTime.Now.Day, acchour = (short)DateTime.Now.Hour, accmin = (short)DateTime.Now.Minute, accsec = (short)DateTime.Now.Second, modyear = (short)DateTime.Now.Year, modmonth = (short)DateTime.Now.Month, modday = (short)DateTime.Now.Day, modhour = (short)DateTime.Now.Hour, modmin = (short)DateTime.Now.Minute, modsec = (short)DateTime.Now.Second, databaseunits = 1000 * scale, userunits = 0.001 / scale, libname = "variance" }; GCCell gcell_root = drawing_.addCell(); gcell_root.accyear = (short)DateTime.Now.Year; gcell_root.accmonth = (short)DateTime.Now.Month; gcell_root.accday = (short)DateTime.Now.Day; gcell_root.acchour = (short)DateTime.Now.Hour; gcell_root.accmin = (short)DateTime.Now.Minute; gcell_root.accsec = (short)DateTime.Now.Second; gcell_root.modyear = (short)DateTime.Now.Year; gcell_root.modmonth = (short)DateTime.Now.Month; gcell_root.modday = (short)DateTime.Now.Day; gcell_root.modhour = (short)DateTime.Now.Hour; gcell_root.modmin = (short)DateTime.Now.Minute; gcell_root.modsec = (short)DateTime.Now.Second; gcell_root.cellName = "implantCase" + resultEntry; // Resist for (int i = 0; i < 2; i++) { List <GeoLibPointF[]> resistPolys = currentResult.getResistShapes()[i].getPoints(); g.addLayerName("L" + (i + 1) + "D0", "resistPolys" + i); foreach (GeoLibPoint[] ePoly in resistPolys.Select(t => GeoWrangler.resize_to_int(t, scale))) { gcell_root.addPolygon(ePoly.ToArray(), i + 1, 0); } } // Shadowing line List <GeoLibPointF[]> shadowLine = currentResult.getLine(Results_implant.lines.shadow).getPoints(); g.addLayerName("L2D0", "shadowLine"); foreach (GeoLibPoint[] ePoly in shadowLine.Select(t => GeoWrangler.resize_to_int(t, scale))) { gcell_root.addPolygon(ePoly.ToArray(), 2, 0); } g.setDrawing(drawing_); g.setValid(true); switch (type) { case (int)CommonVars.external_Type.gds: gdsWriter gw = new(g, layoutFileName + ".gds"); gw.save(); break; case (int)CommonVars.external_Type.oas: oasWriter ow = new(g, layoutFileName + ".oas"); ow.save(); break; } }
private bool pLoad(ref GCDrawingfield drawing) { drawing_ = drawing; valid = true; error_msgs.Clear(); layerNames = new Dictionary <string, string>(); try { statusUpdateUI?.Invoke("Loading"); progressUpdateUI?.Invoke(0); Stream stream = File.OpenRead(filename); if (filename.ToLower().EndsWith("gz")) { using GZipStream gzs = new(stream, CompressionMode.Decompress); MemoryStream ms = new(); gzs.CopyTo(ms); ms.Seek(0, SeekOrigin.Begin); br = new EndianBinaryReader(EndianBitConverter.Little, ms); } else { br = new EndianBinaryReader(EndianBitConverter.Little, stream); } string s; int i; string s1 = ""; zLibUsed = false; for (i = 0; i < 13; i++) { byte help = readRaw(); if (help == 0) { continue; } s = Encoding.UTF8.GetString(new [] { help }); s1 += s; } if (s1 != "%SEMI-OASIS\r\n") { const string err = "Invalid Format."; error_msgs.Add(err); throw new Exception(err); } int record; bool tableAtEnd = false; cell_ = null; int cellNameCount = 0; int textNameCount = 0; do { if (cellNameCount > cellNames.Length) { string err = "More cells (" + cellNameCount + ") than are able to be supported (" + cellNames.Length + ")!"; error_msgs.Add(err); throw new Exception(err); } if (textNameCount > textNames.Length) { string err = "More text names (" + textNameCount + ") than are able to be supported (" + textNames.Length + ")!"; error_msgs.Add(err); throw new Exception(err); } record = readUnsignedInteger(); byte info_byte; switch (record) { case 0: //pad break; case 1: //start s = readString(); if (s != "1.0") { string err2 = "Unknown/unsupported version of OASIS: " + s; error_msgs.Add(err2); throw new Exception(err2); } drawing_.databaseunits = readReal(); i = readUnsignedInteger(); switch (i) { case 0: { tableAtEnd = false; for (i = 0; i < 12; i++) { readUnsignedInteger(); } break; } default: tableAtEnd = true; break; } break; case 2: //end switch (tableAtEnd) { case true: { for (i = 0; i < 12; i++) { readUnsignedInteger(); } break; } } break; case 3: //cellname cellNames[cellNameCount] = readString(); cellNameCount++; break; case 4: //cellname s = readString(); i = readUnsignedInteger(); cellNames[i] = s; break; case 5: //textname textNames[textNameCount] = readString(); textNameCount++; break; case 6: //textname s = readString(); i = readUnsignedInteger(); textNames[i] = s; break; case 7: //property s = readString(); break; case 8: //property s = readString(); i = readUnsignedInteger(); break; case 9: //property string s = readString(); break; case 10: //property string s = readString(); i = readUnsignedInteger(); break; case 11: //layername textlayername case 12: s = readString(); i = readUnsignedInteger(); switch (i) { case 0: break; case 1: i = readUnsignedInteger(); break; case 3: i = readUnsignedInteger(); break; case 2: i = readUnsignedInteger(); break; case 4: i = readUnsignedInteger(); readUnsignedInteger(); break; } int l = i; //datatype i = readUnsignedInteger(); switch (i) { case 0: break; case 1: i = readUnsignedInteger(); break; case 2: i = readUnsignedInteger(); break; case 3: i = readUnsignedInteger(); break; case 4: i = readUnsignedInteger(); readUnsignedInteger(); break; } try { layerNames.Add("L" + l + "D" + i, s); } catch (Exception) { } break; case 13: // cellrecord cell_ = drawing_.addCell(); i = readUnsignedInteger(); cellNames[i] = cellNames[i] switch { "" => "layout#cell~" + i, _ => cellNames[i] }; cell_.cellName = cellNames[i]; resetModal(); break; case 14: // cellrecord cell_ = drawing_.addCell(); cell_.cellName = readString(); resetModal(); break; case 15: //xyabsolute modal.absoluteMode = true; break; case 16: //xyrelative modal.absoluteMode = false; break; case 17: //cellref modal.mag = 1; modal.angle = 0; modal.mirror_x = false; info_byte = readRaw(); if ((info_byte & 128) != 0) { if ((info_byte & 64) != 0) { i = readUnsignedInteger(); cellNames[i] = cellNames[i] switch { "" => "layout#cell~" + i, _ => cellNames[i] }; modal.placement_cell = cellNames[i]; } else { modal.placement_cell = readString(); } } if ((info_byte & 1) != 0) { modal.mirror_x = true; } modal.angle = (info_byte & 6) switch { 6 => 270, _ => (info_byte & 6) switch { 4 => 180, _ => (info_byte & 6) switch { 2 => 90, _ => modal.angle } } }; switch (modal.absoluteMode) { case true: { if ((info_byte & 32) != 0) { modal.placement_x = readSignedInteger(); } if ((info_byte & 16) != 0) { modal.placement_y = readSignedInteger(); } break; } default: { if ((info_byte & 32) != 0) { modal.placement_x += readSignedInteger(); } if ((info_byte & 16) != 0) { modal.placement_y += readSignedInteger(); } break; } } if ((info_byte & 8) != 0) { readRepetition(); processRepetition(elementType.cellrefElement); } else { addCellref(); } break; case 18: //cellref modal.mag = 1; modal.angle = 0; modal.mirror_x = false; info_byte = readRaw(); if ((info_byte & 128) != 0) { if ((info_byte & 64) != 0) { i = readUnsignedInteger(); cellNames[i] = cellNames[i] switch { "" => "layout#cell~" + i, _ => cellNames[i] }; modal.placement_cell = cellNames[i]; } else { modal.placement_cell = readString(); } } if ((info_byte & 1) != 0) { modal.mirror_x = true; } if ((info_byte & 4) != 0) { modal.mag = readReal(); } if ((info_byte & 2) != 0) { modal.angle = readReal(); } switch (modal.absoluteMode) { case true: { if ((info_byte & 32) != 0) { modal.placement_x = readSignedInteger(); } if ((info_byte & 16) != 0) { modal.placement_y = readSignedInteger(); } break; } default: { if ((info_byte & 32) != 0) { modal.placement_x += readSignedInteger(); } if ((info_byte & 16) != 0) { modal.placement_y += readSignedInteger(); } break; } } if ((info_byte & 8) != 0) { readRepetition(); processRepetition(elementType.cellrefElement); } else { addCellref(); } break; case 19: //text info_byte = readRaw(); if ((info_byte & 64) != 0) { if ((info_byte & 32) != 0) { i = readUnsignedInteger(); textNames[i] = textNames[i] switch { "" => "layout#text~" + i, _ => textNames[i] }; modal.text_string = textNames[i]; } else { modal.text_string = readString(); } } if ((info_byte & 1) != 0) { modal.textlayer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.texttype = readUnsignedInteger(); modal.datatype = modal.texttype; // we don't treat text differently. } switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.text_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.text_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.text_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.text_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); processRepetition(elementType.textElement); } else { addText(); } break; case 20: //rectangle/box info_byte = readRaw(); if ((info_byte & 1) != 0) { modal.layer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.datatype = readUnsignedInteger(); } if ((info_byte & 64) != 0) { modal.geometry_w = readUnsignedInteger(); } if ((info_byte & 32) != 0) { modal.geometry_h = readUnsignedInteger(); } if ((info_byte & 128) != 0) { modal.geometry_h = modal.geometry_w; } switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.geometry_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.geometry_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); processRepetition(elementType.boxElement); } else { addBox(); } break; case 21: //polygon info_byte = readRaw(); if ((info_byte & 1) != 0) { modal.layer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.datatype = readUnsignedInteger(); } if ((info_byte & 32) != 0) { readPointList(true); } switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.geometry_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.geometry_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); processRepetition(elementType.polygonElement); } else { addPolygon(); } break; case 22: //path info_byte = readRaw(); if ((info_byte & 1) != 0) { modal.layer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.datatype = readUnsignedInteger(); } if ((info_byte & 64) != 0) { modal.geometry_w = readUnsignedInteger(); switch (modal.geometry_w) { // Avoid zero width path. case 0: modal.geometry_w = 10; break; } } if ((info_byte & 128) != 0) { readExtension(); } if ((info_byte & 32) != 0) { readPointList(false); } switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.geometry_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.geometry_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); processRepetition(elementType.pathElement); } else { addPath(); } break; case 23: //trapezoid modal.trapezoid_delta_a = 0; modal.trapezoid_delta_b = 0; modal.trapezoid_orientation = false; info_byte = readRaw(); if ((info_byte & 1) != 0) { modal.layer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.datatype = readUnsignedInteger(); } if ((info_byte & 64) != 0) { modal.geometry_w = readUnsignedInteger(); } if ((info_byte & 32) != 0) { modal.geometry_h = readUnsignedInteger(); } if ((info_byte & 128) != 0) { modal.trapezoid_orientation = true; } modal.trapezoid_delta_a = read1Delta(false).X; modal.trapezoid_delta_b = read1Delta(false).X; switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.geometry_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.geometry_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); processRepetition(elementType.trapezoidElement); } else { addTrapezoid(); } break; case 24: case 25: // trapezoid info_byte = readRaw(); modal.trapezoid_delta_a = 0; modal.trapezoid_delta_b = 0; modal.trapezoid_orientation = false; if ((info_byte & 1) != 0) { modal.layer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.datatype = readUnsignedInteger(); } if ((info_byte & 64) != 0) { modal.geometry_w = readUnsignedInteger(); } if ((info_byte & 32) != 0) { modal.geometry_h = readUnsignedInteger(); } if ((info_byte & 128) != 0) { modal.trapezoid_orientation = true; } switch (record) { case 24: modal.trapezoid_delta_a = read1Delta(false).X; break; default: modal.trapezoid_delta_b = read1Delta(false).X; break; } switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.geometry_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.geometry_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); processRepetition(elementType.trapezoidElement); } else { addTrapezoid(); } break; case 26: // ctrapezoid info_byte = readRaw(); if ((info_byte & 1) != 0) { modal.layer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.datatype = readUnsignedInteger(); } if ((info_byte & 128) != 0) { modal.ctrapezoid_type = readUnsignedInteger(); } if ((info_byte & 64) != 0) { modal.geometry_w = readUnsignedInteger(); } if ((info_byte & 32) != 0) { modal.geometry_h = readUnsignedInteger(); } switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.geometry_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.geometry_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); processRepetition(elementType.ctrapezoidElement); } else { addCtrapezoid(); } break; case 27: // circle info_byte = readRaw(); if ((info_byte & 1) != 0) { modal.layer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.datatype = readUnsignedInteger(); } if ((info_byte & 32) != 0) { modal.circle_radius = readUnsignedInteger(); // unsure : need to check if scaling needed here. } switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.geometry_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.geometry_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); processRepetition(elementType.circleElement); } else { addCircle(); } break; case 28: //property case 29: info_byte = readRaw(); if ((info_byte & 4) != 0 && (info_byte & 2) != 0) { readUnsignedInteger(); } if ((info_byte & 4) != 0 && (info_byte & 2) == 0) { readString(); } switch (info_byte & 8) { case 0: { int count = info_byte >> 4; count = count switch { 15 => readUnsignedInteger(), _ => count }; for (int j = 0; j < count; j++) { readProperty(); } break; } } break; case 30: //Xname record readUnsignedInteger(); readString(); readUnsignedInteger(); break; case 31: //Xname record readUnsignedInteger(); readString(); break; case 32: //Xelement record readUnsignedInteger(); readString(); break; case 33: //xgeometry record info_byte = readRaw(); readUnsignedInteger(); if ((info_byte & 1) != 0) { modal.layer = readUnsignedInteger(); } if ((info_byte & 2) != 0) { modal.datatype = readUnsignedInteger(); } readString(); if ((info_byte & 32) != 0) { modal.circle_radius = readUnsignedInteger(); // unsure : need to check if scaling needed here. } switch (modal.absoluteMode) { case true: { if ((info_byte & 16) != 0) { modal.geometry_x = readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y = readSignedInteger(); } break; } default: { if ((info_byte & 16) != 0) { modal.geometry_x += readSignedInteger(); } if ((info_byte & 8) != 0) { modal.geometry_y += readSignedInteger(); } break; } } if ((info_byte & 4) != 0) { readRepetition(); } break; case 34: //compression // throw new Exception("Compression not supported at this time"); readUnsignedInteger(); uint before = (uint)readUnsignedInteger(); uint after = (uint)readUnsignedInteger(); // Arguments are switched around here. Not sure whether this is correct. zLibInit(after, before); break; default: string err = "Unknown/unsupported Record." + record; error_msgs.Add(err); throw new Exception(err); } }while (record != 2); // update cellref/text, if table at end foreach (GCCell t in drawing_.cellList.Where(t => t != null)) { s1 = t.cellName; if (s1.Left(12) != "layout#cell~") { continue; } s1 = s1.Substring(12, s1.Length - 12); t.cellName = cellNames[Convert.ToInt32(s1)]; } foreach (GCElement t1 in drawing_.cellList.Where(t => t != null).SelectMany(t => t.elementList)) { if (t1.isCellref() || t1.isCellrefArray()) { if (t1.depend() == null) { s1 = t1.getName(); if (s1 != null && s1.Left(12) == "layout#cell~") { s1 = s1.Substring(12, s1.Length - 12); t1.setName(cellNames[Convert.ToInt32(s1)]); t1.setCellRef(drawing_.findCell(cellNames[Convert.ToInt32(s1)])); } } } if (!t1.isText()) { continue; } s1 = t1.getName(); if (s1.Left(12) != "layout#text~") { continue; } s1 = s1.Substring(12, s1.Length - 12); t1.setName(textNames[Convert.ToInt32(s1)]); } try { drawing_.active_cell = drawing.findCellIndex(cell_.cellName); drawing_.resize(1000.0 / drawing_.databaseunits); } catch (Exception) { const string err = "Unable to find any cells. This library only supports Oasis saved in strict mode."; error_msgs.Add(err); throw new Exception(err); } statusUpdateUI?.Invoke("Done"); progressUpdateUI?.Invoke(1.0f); } catch (Exception e) { valid = false; switch (error_msgs.IndexOf(e.Message)) { case -1: error_msgs.Add(e.Message); break; } } return(valid); }
public void addCellrefArray(GCCell c, GeoLibPoint[] array, int anzx, int anzy) { pAddCellrefArray(c, array, anzx, anzy); }
private void pSetCellRef(GCCell cellRef) { cell_ref = cellRef; }
public override void setCellRef(GCCell cellRef) { pSetCellRef(cellRef); }
private void pAddCellrefArray(GCCell c, GeoLibPoint[] array, int anzx, int anzy) { GCElement e = new GCCellRefArray(c, array, anzx, anzy); pAddElement(e); }
public void addCellref(GCCell c, GeoLibPoint pos) { pAddCellref(c, pos); }
public GCCellref(GCCell c, GeoLibPoint pos) { pGCCellref(c, pos); }
public bool depend(GCCell cell) { return pDepend(cell); }
private void pAddCellrefArray(GCCell c, GeoLibPoint pos1, GeoLibPoint pos2, int anzx, int anzy) { GCElement e = new GCCellRefArray(c, pos1, pos2, anzx, anzy); pAddElement(e); }
public void addCellrefArray(GCCell c, GeoLibPoint pos1, GeoLibPoint pos2, int anzx, int anzy) { pAddCellrefArray(c, pos1, pos2, anzx, anzy); }