// Cellrefarrays also have to resolve to integer placement. // Placement errors will occur if the x, y instance counts do not divide the array X, Y values cleanly. private void pSaveGDS(gdsWriter gw) { //SRef gw.bw.Write((ushort)4); gw.bw.Write((byte)0x0B); gw.bw.Write((byte)0); gw.writeString(cell_ref.cellName, 0x12); int strans_ = 0; switch (trans.mirror_x) { case true: strans_ |= 0x8000; break; } //STRANS gw.bw.Write((ushort)6); gw.bw.Write((byte)0x1A); gw.bw.Write((byte)1); gw.bw.Write((short)strans_); //mag gw.bw.Write((ushort)12); gw.bw.Write((byte)0x1B); gw.bw.Write((byte)5); gw.write8ByteReal(trans.mag); //angle gw.bw.Write((ushort)12); gw.bw.Write((byte)0x1C); gw.bw.Write((byte)5); switch (trans.mirror_x) { case true when trans.angle != 0: gw.write8ByteReal(360 - trans.angle); break; default: gw.write8ByteReal(trans.angle); break; } //colrow gw.bw.Write((ushort)8); gw.bw.Write((byte)0x13); gw.bw.Write((byte)2); gw.bw.Write((short)count_x); gw.bw.Write((short)count_y); //xy gw.bw.Write((ushort)(3 * 2 * 4 + 4)); gw.bw.Write((byte)0x10); gw.bw.Write((byte)3); gw.bw.Write(point.X); gw.bw.Write(point.Y); GeoLibPoint pos = new(pitch.X * count_x + point.X, pitch.Y + point.Y); gw.bw.Write(pos.X); gw.bw.Write(pos.Y); pos = new GeoLibPoint(pitch.X * +point.X, pitch.Y * count_y + point.Y); gw.bw.Write(pos.X); gw.bw.Write(pos.Y); // endel gw.bw.Write((ushort)4); gw.bw.Write((byte)0x11); gw.bw.Write((byte)0); }
private void pMinimum(GeoLibPoint p) { for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { GeoLibPoint pos3 = point; pos3.Offset(new GeoLibPoint(pitch.X * x * (count_x - 1), pitch.Y * y * (count_y - 1))); GeoLibPoint pos1 = new(p.X - pos3.X, p.Y - pos3.Y); pos1.Y = trans.mirror_x switch { true => -pos1.Y, _ => pos1.Y }; GeoLibPoint pos2 = pos1; cell_ref.maximum(pos1); cell_ref.minimum(pos2); switch (trans.mirror_x) { case true: pos1.Y = -pos1.Y; pos2.Y = -pos2.Y; break; } pos1.Offset(pos3); pos2.Offset(pos3); p.X = Math.Min(p.X, pos2.X); p.X = Math.Min(p.X, pos1.X); p.Y = Math.Min(p.Y, pos2.Y); p.Y = Math.Min(p.Y, pos1.Y); } } }
public static GeoLibPoint[] getnegS() { GeoLibPoint[] S = new GeoLibPoint[] { new(0, 0), new(0, 20), new(20, 20), new(20, 50), new(0, 50), new(0, 110), new(100, 110), new(100, 80), new(80, 80), new(80, 60), new(100, 60), new(100, 0), new(0, 0) }; for (int i = 0; i < S.Length; i++) { S[i] = new GeoLibPoint(S[i].X, S[i].Y - 200); } return(S); }
private double pAngle(GeoLibPoint p1, GeoLibPoint p2, GeoLibPoint p3) { double a1, a2; GeoLibPointF dif1 = new(p2.X - p1.X, p2.Y - p1.Y); GeoLibPointF dif2 = new(p3.X - p2.X, p3.Y - p2.Y); if (dif1.X != 0) { a1 = Math.Atan(dif1.Y / dif1.X) / 2 / Math.PI * 360; switch (dif1.X) { case < 0: a1 -= 180; break; } switch (a1) { case < -180: a1 += 360; break; } } else { a1 = dif1.Y switch {
private GCElement pAddCircle(int layer, int datatype, GeoLibPoint center, double radius) { GCElement e = new(); GeoLibPoint[] points = e.ellipse(center, radius, GCSetup.circularDefault); e = new GCPolygon(points, layer, datatype); return e; }
private void setOtherProps() { Left = X; Top = Y; Location = new GeoLibPoint(X, Y); Bottom = Top + Height; Right = Left + Width; }
private void pMoveSelect(GeoLibPoint pos) { point = select switch { true => new GeoLibPoint(point.X + pos.X, point.Y + pos.Y), _ => point }; }
private void pMoveSelect(GeoLibPoint p) { switch (select) { case true: point.Offset(p); break; } }
private void pGCCellref() { cell_ref = null; // Tag layer and datatype to allow this element to be filtered out from LD and geo lists. layer_nr = -1; datatype_nr = -1; point = new GeoLibPoint(0, 0); trans = new GCStrans(); trans.reset(); }
private void pGCTxt(int l, int d, GeoLibPoint p, string s) { name = s; point = p; layer_nr = l; datatype_nr = d; trans = new GCStrans(); presentation = 0; width = 10; }
private void pMaximum(GeoLibPoint pos) { if (point.X > pos.X) { pos.X = point.X; } if (point.Y > pos.Y) { pos.Y = point.Y; } }
private void pMinimum(GeoLibPoint pos) { if (point.X < pos.X) { pos.X = point.X; } if (point.Y < pos.Y) { pos.Y = point.Y; } }
private static double pAngleBetweenPoints(GeoLibPoint interSection_A, GeoLibPoint interSection_B, GeoLibPoint interSection_C, bool allowNegative) { GeoLibPoint cBVector = new(interSection_B.X - interSection_C.X, interSection_B.Y - interSection_C.Y); GeoLibPoint cAVector = new(interSection_A.X - interSection_C.X, interSection_A.Y - interSection_C.Y); long xComponents = cBVector.X * cAVector.X; long yComponents = cBVector.Y * cAVector.Y; long scalarProduct = xComponents + yComponents; return(angleCalc(cAVector.X, cAVector.Y, cBVector.X, cBVector.Y, scalarProduct, allowNegative)); }
private List <GCPolygon> pConvertToPolygons() { List <GCPolygon> ret = new(); GeoLibPoint[] points = new GeoLibPoint[5]; points[0] = new GeoLibPoint(rect.Left, rect.Top); points[1] = new GeoLibPoint(rect.Right, rect.Top); points[2] = new GeoLibPoint(rect.Right, rect.Bottom); points[3] = new GeoLibPoint(rect.Left, rect.Bottom); points[4] = new GeoLibPoint(rect.Left, rect.Top); ret.Add(new GCPolygon(points, layer_nr, datatype_nr)); return(ret); }
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).
private void pMove(GeoLibPoint p) { int elementListCount = elementList.Count; #if !GCSINGLETHREADED Parallel.For(0, elementListCount, f => #else for (int f = 0; f < elementListCount; f++) #endif { if (elementList[f] != null) { elementList[f].move(p); } }
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 void pMinimum(GeoLibPoint p) { GeoLibPoint pos1 = new(p.X - point.X, p.Y - point.Y); pos1.Y = trans.mirror_x switch { true => -pos1.Y, _ => pos1.Y }; switch (Math.Abs(trans.angle - 180)) { case <= double.Epsilon: pos1.Y = -pos1.Y; pos1.X = -pos1.X; break; } GeoLibPoint pos2 = pos1; cell_ref.maximum(pos1); cell_ref.minimum(pos2); switch (trans.mirror_x) { case true: pos1.Y = -pos1.Y; pos2.Y = -pos2.Y; break; } switch (Math.Abs(trans.angle - 180)) { case <= double.Epsilon: pos1.Y = -pos1.Y; pos1.X = -pos1.X; break; } switch (Math.Abs(trans.angle - 180)) { case <= double.Epsilon: pos2.Y = -pos2.Y; pos2.X = -pos2.X; break; } pos1.Offset(point); pos2.Offset(point); p.X = Math.Min(p.X, pos2.X); p.X = Math.Min(p.X, pos1.X); p.Y = Math.Min(p.Y, pos2.Y); p.Y = Math.Min(p.Y, pos1.Y); }
private List <GCPolygon> pConvertToPolygons() { List <GCPolygon> ret = new(); GeoLibPoint[] points = new GeoLibPoint[5]; points[0] = new GeoLibPoint(point.X - 1, point.Y - 1); points[1] = new GeoLibPoint(point.X - 1, point.Y + 1); points[2] = new GeoLibPoint(point.X + 1, point.Y + 1); points[3] = new GeoLibPoint(point.X + 1, point.Y - 1); points[4] = new GeoLibPoint(points[0]); ret.Add(new GCPolygon(points, layer_nr, datatype_nr)); ret[0].text = true; ret[0].name = name; return(ret); }
private static GeoLibPoint[] pRotate(GeoLibPoint pivot, GeoLibPoint[] pointList, double angleDegree) { switch (Math.Abs(angleDegree)) { // essentially a zero rotation clamp at 0.01 degrees case < 1E-2: return pointList; } int pointListLength = pointList.Length; GeoLibPoint[] returnList = new GeoLibPoint[pointListLength]; #if !GWSINGLETHREADED Parallel.For(0, pointListLength, i => #else for (Int32 i = 0; i < pointList.Count(); i++) #endif { returnList[i] = Rotate(pivot, pointList[i], angleDegree); }
private void pTransformPoints(GeoLibPoint[] source) { double m11 = m[0]; double m12 = m[1]; double m21 = m[2]; double m22 = m[3]; double dx = m[4]; double dy = m[5]; int sLength = source.Length; #if !GEOLIBSINGLETHREADED Parallel.For(0, sLength, pt => #else for (int pt = 0; pt < sLength; pt++) #endif { double x1 = m11 * source[pt].X + m21 * source[pt].Y + dx; double y1 = m12 * source[pt].X + m22 * source[pt].Y + dy; source[pt] = new GeoLibPoint(x1, y1); }
public static GeoLibPoint[] Rotate(GeoLibPoint pivot, GeoLibPoint[] pointList, double angleDegree) { return pRotate(pivot, pointList, angleDegree); }
private void pOffset(GeoLibPoint offset) { X += offset.X; Y += offset.Y; setOtherProps(); }
public void Offset(GeoLibPoint offset) { pOffset(offset); }
public override void maximum(GeoLibPoint pos) { pMaximum(pos); }
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 pMove(GeoLibPoint pos) { point = new GeoLibPoint(point.X + pos.X, point.Y + pos.Y); }
public override void move(GeoLibPoint pos) { pMove(pos); }
public override void moveSelect(GeoLibPoint pos) { pMoveSelect(pos); }