Ejemplo n.º 1
0
        List<GeoLibPointF> pMakeShape(bool returnEarly, ShapeLibrary shape)
        {
            List<GeoLibPointF> mcPoints = new List<GeoLibPointF>(); // overall points container. We'll use this to populate and send back our Point array later.

            Vertex = shape.Vertex;

            // If we have a complex shape, we cannot infer anything from it, so just take the geometry as-is and ship it out.
            if (shape.shapeIndex == (int)CommonVars.shapeNames.complex)
            {
                mcPoints.Clear();
                for (Int32 i = 0; i < Vertex.Count(); i++)
                {
                    if (Vertex[i] != null)
                    {
                        mcPoints.Add(new GeoLibPointF(Vertex[i].X, Vertex[i].Y));
                    }
                }
                return GeoWrangler.close(mcPoints);
            }

            round1 = shape.round1;

            // Iterate the corners to apply the bias from the edges.
#if !QUILTSINGLETHREADED
            Parallel.For(0, round1.Count(), (corner) =>
#else
            for (Int32 corner = 0; corner < round1.Count(); corner++)
#endif
            {
                Vertex[round1[corner].index].X = Vertex[round1[corner].verFace].X;
                Vertex[round1[corner].index].Y = Vertex[round1[corner].horFace].Y;
            }
Ejemplo n.º 2
0
    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;
        }
    }
Ejemplo n.º 3
0
    public void writePointArray(GeoLibPoint[] p, bool excludeImplicid)
    {
        bool type0 = true;
        bool type1 = true;
        bool type2 = true;
        bool type3 = true;

        switch (p.Length % 2)
        {
        case 0:
            type0 = false;
            type1 = false;
            break;
        }
        switch (p.Length)
        {
        case < 4:
            type0 = false;
            type1 = false;
            break;
        }
        for (int i = 0; i < p.Length - 1; i++)
        {
            GeoLibPointF pd = GeoWrangler.distanceBetweenPoints_point(p[i + 1], p[i]);
            if (pd.Y != 0 && i % 2 != 0)
            {
                type1 = false;
            }

            if (pd.X != 0 && i % 2 != 0)
            {
                type0 = false;
            }

            if (pd.X != 0 && i % 2 != 1)
            {
                type1 = false;
            }

            if (pd.Y != 0 && i % 2 != 1)
            {
                type0 = false;
            }

            if (pd.X != 0 && pd.Y != 0)
            {
                type2 = false;
            }

            if (pd.X != 0 && pd.Y != 0 && Math.Abs(pd.X - pd.Y) > double.Epsilon && Math.Abs(pd.X - -pd.Y) > double.Epsilon)
            {
                type3 = false;
            }
        }
        switch (type0)
        {
        case true:
        {
            writeUnsignedInteger(0);
            int count = excludeImplicid switch
            {
                true => p.Length - 3,
                _ => p.Length - 1
            };
            writeUnsignedInteger((uint)count);
            GeoLibPoint last = new(p[0]);
            for (int i = 1; i <= count; i++)
            {
                GeoLibPointF h = GeoWrangler.distanceBetweenPoints_point(p[i], last);
                write1Delta(h, i % 2 == 0);
                last = new GeoLibPoint(p[i]);
            }

            break;
        }

        default:
        {
            switch (type1)
            {
            case true:
            {
                writeUnsignedInteger(1);
                int count = excludeImplicid switch
                {
                    true => p.Length - 3,
                    _ => p.Length - 1
                };
                writeUnsignedInteger((uint)count);
                GeoLibPoint last = new(p[0]);
                for (int i = 1; i <= count; i++)
                {
                    GeoLibPointF h = GeoWrangler.distanceBetweenPoints_point(p[i], last);
                    write1Delta(h, i % 2 == 1);
                    last = new GeoLibPoint(p[i]);
                }

                break;
            }

            default:
            {
                switch (type2)
                {
                case true:
                {
                    writeUnsignedInteger(2);
                    int count = excludeImplicid switch
                    {
                        true => p.Length - 2,
                        _ => p.Length - 1
                    };
                    writeUnsignedInteger((uint)count);
                    GeoLibPoint last = new(p[0]);
                    for (int i = 1; i <= count; i++)
                    {
                        GeoLibPointF h = GeoWrangler.distanceBetweenPoints_point(p[i], last);
                        write2Delta(h);
                        last = new GeoLibPoint(p[i]);
                    }

                    break;
                }

                default:
                {
                    switch (type3)
                    {
                    case true:
                    {
                        writeUnsignedInteger(3);
                        int count = excludeImplicid switch
                        {
                            true => p.Length - 2,
                            _ => p.Length - 1
                        };
                        writeUnsignedInteger((uint)count);
                        GeoLibPoint last = new(p[0]);
                        for (int i = 1; i <= count; i++)
                        {
                            GeoLibPointF h = GeoWrangler.distanceBetweenPoints_point(p[i], last);
                            write3Delta(h);
                            last = new GeoLibPoint(p[i]);
                        }

                        break;
                    }

                    default:
                    {
                        writeUnsignedInteger(4);
                        int count = excludeImplicid switch
                        {
                            true => p.Length - 2,
                            _ => p.Length - 1
                        };
                        writeUnsignedInteger((uint)count);
                        GeoLibPoint last = new(p[0]);
                        for (int i = 1; i <= count; i++)
                        {
                            GeoLibPointF h = GeoWrangler.distanceBetweenPoints_point(p[i], last);
                            writeGDelta(h);
                            last = new GeoLibPoint(p[i]);
                        }

                        break;
                    }
                    }

                    break;
                }
                }

                break;
            }
            }

            break;
        }
        }
    }
Ejemplo n.º 4
0
        decimal pDoY(int i)
        {
            decimal y_ = 0m;

            int yRef = pGetRef(i, PatternElement.properties_i.yPosRef);

            // We have a relative positioning situation.
            // Note that this could be cascading so we need to walk the stack

            if (yRef >= 0)
            {
                int sRef = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRef);

                int sPosRef = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRefPos);

                bool refFlipped = pGetPatternElement(yRef).getInt(PatternElement.properties_i.flipV) == 1;

                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.yPos);

                // In the case of an array shape type for the reference, we may still have subshape relative references. To check this, we need to query for an array. If we don't have an array, we're good.
                // Then we also need to query whether the subshape reference is a higher value than the number of subshapes in the shape; the 'array' subshape reference is last in the list.
                bool doY = !pGetPatternElement(yRef).isYArray() || (pGetPatternElement(yRef).isYArray() && (sRef < pGetPatternElement(yRef).getSubShapeCount()));

                int aYRef = yRef;

                // Is the array reference a relative array?
                if (pGetPatternElement(yRef).getInt(PatternElement.properties_i.arrayRef) != 0)
                {
                    aYRef = pGetPatternElement(yRef).getInt(PatternElement.properties_i.arrayRef) - 1;

                    int PSSR = pGetPatternElement(i).getInt(PatternElement.properties_i.yPosSubShapeRef);
                    int PSSC = pGetPatternElement(yRef).getSubShapeCount();
                    if (PSSR == PSSC)
                    {
                        doY = false;
                    }
                }

                if (doY)
                {
                    y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 0);
                    if (sRef == 1)
                    {
                        y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 1);
                    }
                    if (sRef == 2)
                    {
                        y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0);
                        y_ -= pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2);
                        y_ -= pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verOffset, 2);
                    }
                }

                // Process the side case.
                if ((!refFlipped && (sPosRef == (int)CommonVars.subShapeVerLocs.T)) || (refFlipped && (sPosRef == (int)CommonVars.subShapeVerLocs.B)))
                {
                    if (doY)
                    {
                        switch (sRef)
                        {
                            case 0:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0);
                                break;
                            case 1:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 1);
                                break;
                            case 2:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2);
                                break;
                        }
                    }
                    else
                    {
                        y_ += Convert.ToDecimal(pBBDimension(bbDims.height, aYRef));
                    }
                }

                if (sPosRef == (int)CommonVars.subShapeVerLocs.M)
                {
                    if (doY)
                    {
                        switch (sRef)
                        {
                            case 0:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 0) / 2;
                                break;
                            case 1:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 1) / 2;
                                break;
                            case 2:
                                y_ += pGetPatternElement(yRef).getDecimal(PatternElement.properties_decimal.verLength, 2) / 2;
                                break;
                        }
                    }
                    else
                    {
                        y_ += Convert.ToDecimal(pBBDimension(bbDims.height, aYRef)) / 2;
                    }
                }

                // Is the reference flipped? If so, we need to flip our value to get the correct result
                if (refFlipped)
                {
                    ShapeLibrary t = new ShapeLibrary(pGetPatternElement(yRef));
                    GeoLibPointF pivot = t.getPivotPoint();

                    bool alignX = pGetPatternElement(yRef).getInt(PatternElement.properties_i.alignX) == 1;
                    bool alignY = pGetPatternElement(yRef).getInt(PatternElement.properties_i.alignY) == 1;
                    y_ = Convert.ToDecimal(GeoWrangler.flip(false, true, alignX, alignY, pivot, new[] { new GeoLibPointF(0, Convert.ToDouble(y_)) })[0].Y);
                }

                if (doY)
                {
                    switch (sRef)
                    {
                        case 0:
                            y_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.verOffset, 0);
                            break;
                        case 1:
                            y_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.verOffset, 1);
                            break;
                        case 2:
                            break;
                    }
                }

                // yRef = pGetRef(yRef, PatternElement.properties_i.yPosRef);
            }

            return y_;

        }
Ejemplo n.º 5
0
        decimal pDoX(int i)
        {
            decimal x_ = 0m;

            int xRef = pGetRef(i, PatternElement.properties_i.xPosRef);

            // We have a relative positioning situation.
            // Note that this could be cascading so we need to walk the stack
            if (xRef >= 0)
            {
                int sRef = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRef);

                int sPosRef = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRefPos);

                bool refFlipped = pGetPatternElement(xRef).getInt(PatternElement.properties_i.flipH) == 1;
                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.xPos);

                // In the case of an array shape type for the reference, we may still have subshape relative references. To check this, we need to query for an array. If we don't have an array, we're good.
                // Then we also need to query whether the subshape reference is a higher value than the number of subshapes in the shape; the 'array' subshape reference is last in the list.
                bool doX = !pGetPatternElement(xRef).isXArray() || (pGetPatternElement(xRef).isXArray() && (sRef < pGetPatternElement(xRef).getSubShapeCount()));

                int aXRef = xRef;
                // Is the array reference a relative array?
                if (pGetPatternElement(xRef).getInt(PatternElement.properties_i.arrayRef) != 0)
                {
                    aXRef = pGetPatternElement(xRef).getInt(PatternElement.properties_i.arrayRef) - 1;

                    int PSSR = pGetPatternElement(i).getInt(PatternElement.properties_i.xPosSubShapeRef);
                    int PSSC = pGetPatternElement(xRef).getSubShapeCount();
                    if (PSSR == PSSC)
                    {
                        doX = false;
                    }
                }

                if (doX)
                {
                    if (sRef == 1)
                    {
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                        if (pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Sshape)
                        {
                            if ((pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Ushape) && (pGetPatternElement(xRef).getInt(PatternElement.properties_i.shapeIndex) != (int)CommonVars.shapeNames.Xshape))
                            {
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0);
                            }
                            else
                            {
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 1);
                            }
                        }
                    }
                    if (sRef == 2)
                    {
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                        x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horOffset, 2);
                    }
                }

                // Process the side case.
                if ((!refFlipped && (sPosRef == (int)CommonVars.subShapeHorLocs.R)) || (refFlipped && (sPosRef == (int)CommonVars.subShapeHorLocs.L)))
                {
                    if (doX)
                    {
                        switch (sRef)
                        {
                            case 0:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0);
                                break;
                            case 1:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 1);
                                break;
                            case 2:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 2);
                                break;
                        }
                    }
                    else
                    {
                        x_ += Convert.ToDecimal(pBBDimension(bbDims.width, aXRef));
                    }
                }

                if (sPosRef == (int)CommonVars.subShapeHorLocs.M)
                {
                    if (doX)
                    {
                        switch (sRef)
                        {
                            case 0:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 0) / 2;
                                break;
                            case 1:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 1) / 2;
                                break;
                            case 2:
                                x_ += pGetPatternElement(xRef).getDecimal(PatternElement.properties_decimal.horLength, 2) / 2;
                                break;
                        }
                    }
                    else
                    {
                        x_ += Convert.ToDecimal(pBBDimension(bbDims.width, aXRef)) / 2;
                    }
                }

                // Is the reference flipped? If so, we need to flip our value to get the correct result
                if (refFlipped)
                {
                    ShapeLibrary t = new ShapeLibrary(pGetPatternElement(xRef));
                    GeoLibPointF pivot = t.getPivotPoint();

                    bool alignX = pGetPatternElement(xRef).getInt(PatternElement.properties_i.alignX) == 1;
                    bool alignY = pGetPatternElement(xRef).getInt(PatternElement.properties_i.alignY) == 1;
                    x_ = Convert.ToDecimal(GeoWrangler.flip(true, false, alignX, alignY, pivot, new[] { new GeoLibPointF(Convert.ToDouble(x_), 0) })[0].X);
                }

                if (doX)
                {
                    switch (sRef)
                    {
                        case 0:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 0);
                            break;
                        case 1:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 1);
                            break;
                        case 2:
                            x_ += pGetPatternElement(i).getDecimal(PatternElement.properties_decimal.horOffset, 2);
                            break;
                    }
                }

                // xRef = pGetRef(xRef, PatternElement.properties_i.xPosRef);
            }

            return x_;
        }