private void writeSVG(Results_implant currentResult, int resultEntry, int numberOfCases)
    {
        string svgFileName = baseFileName;

        string paddingString = "D" + numberOfCases.ToString().Length; // count chars in the number of cases as a string, use that to define padding.

        svgFileName += "_run" + resultEntry.ToString(paddingString) + ".svg";

        SVGBuilder svg = new()
        {
            style =
            {
                brushClr = currentResult.getResistShapes()[0].getColor(),
                penClr   = currentResult.getResistShapes()[0].getColor()
            }
        };

        // Active resist contour
        svg.AddPolygons(currentResult.getResistShapes()[0].getPoints());

        // Background resist contour
        svg.style.brushClr = currentResult.getResistShapes()[1].getColor();
        svg.style.penClr   = currentResult.getResistShapes()[1].getColor();
        svg.AddPolygons(currentResult.getResistShapes()[1].getPoints());

        // Shadow
        svg.style.brushClr = currentResult.getLine(Results_implant.lines.shadow).getColor();
        svg.style.penClr   = currentResult.getLine(Results_implant.lines.shadow).getColor();
        svg.AddPolygons(currentResult.getLine(Results_implant.lines.shadow).getPoints());

        svg.SaveToFile(svgFileName);
    }
Exemple #2
0
 private void pSet(Results_implant newResult)
 {
     resistShapes = newResult.resistShapes.ToList();
     shadowLine.setPoints(newResult.shadowLine.getPoints());
     shadowLine.setColor(newResult.shadowLine.getColor());
     minShadowLine.setPoints(newResult.minShadowLine.getPoints());
     minShadowLine.setColor(newResult.minShadowLine.getColor());
     maxShadowLine.setPoints(newResult.maxShadowLine.getPoints());
     maxShadowLine.setColor(newResult.maxShadowLine.getColor());
     valid = newResult.valid;
 }
    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 void entropyRunCore_implant_multipleThread(bool previewMode, int numberOfCases)
    {
        setSampler_implant(numberOfCases, previewMode);
        sampler.sample(true, false);

        const int numberOfResultsFields = 1;

        implantResultPackage = new SimResultPackage(ref varianceContext.implantPreviewLock, numberOfCases, numberOfResultsFields);

        multithreadWarningFunc?.Invoke();

        // Set up timers for the UI refresh
        commonVars.m_timer = new Timer {
            AutoReset = true, Interval = CentralProperties.timer_interval
        };
        updateImplantSimUIMTFunc?.Invoke();
        commonVars.m_timer.Start();

        // Set our parallel task options based on user settings.
        ParallelOptions po = new();
        // Attempt at parallelism.
        CancellationTokenSource cancelSource      = new();
        CancellationToken       cancellationToken = cancelSource.Token;

        switch (varianceContext.numberOfThreads)
        {
        case -1:
            po.MaxDegreeOfParallelism = commonVars.HTCount;
            break;

        default:
            po.MaxDegreeOfParallelism = varianceContext.numberOfThreads;
            break;
        }

        if (commonVars.getImplantSettings_nonSim().getInt(EntropySettings_nonSim.properties_i.greedy) == 0)
        {
            if (po.MaxDegreeOfParallelism > 1) // avoid setting to 0
            {
                po.MaxDegreeOfParallelism -= 1;
            }
        }

        try
        {
            Parallel.For(0, numberOfCases, po, (i, loopState) =>
            {
                try
                {
                    ChaosSettings_implant cs      = sampler_implant.getSample(i);
                    Results_implant currentResult = entropyEval_implant(cs);

                    if (currentResult.isValid())     // only update if result is valid.
                    {
                        try
                        {
                            {
                                if (commonVars.getImplantSettings_nonSim().getInt(EntropySettings_nonSim.properties_i.external) == 1 && baseFileName != "")
                                {
                                    switch (commonVars.getImplantSettings_nonSim().getInt(EntropySettings_nonSim.properties_i.externalType))
                                    {
                                    case (int)CommonVars.external_Type.svg:
                                        writeSVG(currentResult, i, numberOfCases);
                                        break;

                                    default:
                                        writeLayout_implant(currentResult, i, numberOfCases, commonVars.getImplantSettings_nonSim().getInt(EntropySettings_nonSim.properties_i.externalType));
                                        break;
                                    }
                                }
                                implantResultPackage.Add(currentResult);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                    Interlocked.Increment(ref currentProgress);

                    forceImplantRepaintFunc?.Invoke();

                    abortRunFuncMT?.Invoke(implantResultPackage, cancelSource, cancellationToken);
                }
                catch (OperationCanceledException)
                {
                    implantResultPackage.setState(false);
                    // ReSharper disable once AccessToDisposedClosure
                    commonVars.m_timer.Stop();
                    commonVars.runAbort = false;     // reset state to allow user to abort save of results.
                    sw.Stop();
                    loopState.Stop();
                }
            }
                         );
        }
        catch (OperationCanceledException)
        {
            implantResultPackage.setState(false);
            commonVars.runAbort = false; // reset state to allow user to abort save of results.
            commonVars.m_timer.Stop();
            sw.Stop();
        }
        catch (AggregateException)
        {
            commonVars.m_timer.Stop();
            sw.Stop();
        }
        catch (Exception)
        {
        }
        commonVars.m_timer.Stop();
        commonVars.m_timer.Dispose();
        implantResultPackage.setRunTime(swTime);
        sw.Stop();
        sw.Reset();
    }
Exemple #5
0
 public void set(Results_implant newResult)
 {
     pSet(newResult);
 }