Exemple #1
0
        public static void PNGToLKH(string bmapPath = "bitmap/manga.png")
        {
            //var _crosshatch = FindObjectOfType<SVGCrosshatch>();
            var bmapToPoint = new BitMapPointGenerator(); // _crosshatch.GetBitMapPointGenerator();

            bmapToPoint.bmapName = bmapPath;

            var points = bmapToPoint.getPoints();

            for (int i = 0; i < points.Count; ++i)
            {
                string name    = bmapToPoint.GetBaseName() + i;
                var    tspProb = TSPLibProblem.FromPoints(points[i].GetEnumerator(), name);
                //string name = Path.GetFileNameWithoutExtension(bmapToPoint._bmapName);
                tspProb.WriteParamAndProbWithBaseName(name);
            }
        }
    void CreateGenerator()
    {
        SVGViewBox viewBox = SCCSSParser.ParseViewBox(svgFullPath);
        CSSLookup  lookup  = SCCSSParser.Parse(svgFullPath);

        SvgParser.SvgPath plist = getSvgPath(svgFullPath);

        for (var it = plist; it != null; it = it.next)
        {
            lookup.updatePath(it);
        }

        SCSvgFileData _svgFileData = new SCSvgFileData()
        {
            isYAxisInverted = yAxisInverted
        };
        StripeFieldConfig stripeFieldConfig = FindObjectOfType <StripeFieldConfig>();
        StripedPathSet    stripedPathSet    = new StripedPathSet(plist, stripeFieldConfig, _svgFileData);

        //
        // Configure generator
        //
        if (generatorType == GeneratorType.Crosshatch)
        {
            var crosshatchGenerator = new SCCrosshatchGenerator(machineConfig, new HatchConfig(), _svgFileData, viewBox, _generatorConfig);
            crosshatchGenerator.UsePathSet(stripedPathSet);
            generator = crosshatchGenerator;
        }
        else if (generatorType == GeneratorType.Triangles)
        {
            var pixelTree = bitMapPointGenerator.getPixelTriTree();
            //if (ShouldMeshPixelTree)
            //    pixelTreeDebugDisplay.GetComponent<MeshFilter>().mesh = pixelTree.getMesh();

            var pointSetGenerator = new SCTriangleCrosshatchGenerator(
                machineConfig,
                _generatorConfig,
                pixelTree,
                bitMapPointGenerator);

            generator = pointSetGenerator;
        }
        else
        {
            SCTSPCrosshatchGenerator tspGenerator;
            if (useBitMapPointGenerator)
            {
                tspGenerator = new SCTSPCrosshatchGenerator(machineConfig, bitMapPointGenerator.inputImageBox, _generatorConfig);
                tspGenerator.SetTSPPointSets(bitMapPointGenerator.getPoints());

                tspGenerator.BaseFileName = Path.GetFileNameWithoutExtension(bitMapPointGenerator.bmapName);
            }
            else
            {
                List <Vector2f> points;
                tspGenerator = new SCTSPCrosshatchGenerator(machineConfig, viewBox, _generatorConfig);
                points       = stripedPathSet.AllPathsToPoints();
                tspGenerator.AddPoints(points);
            }

            generator = tspGenerator;
        }
    }