Exemple #1
0
        public static SolutionManifest Request(CiceroRequest req)
        {
            //payload = "#input_line:((6,1),(0,4))#input_line:((4,6),(6,1))#input_line:((1,6),(3,0))#box_paired/thicken:((4,4),(5,1))#box_decorated/regulate:((2,3),(4,5))#box_lazy/elevate:((1,4),(5,3))";
            var payload = req.Payload;
            var bounds  = req.InnerBounds;

            var data = payload.Split('#').ToList();

            var inputs = data.Where(x => x.Split('_')[0] == "input").ToList();
            var boxes  = data.Where(x => x.Split('_')[0] == "box").ToList();

            var inputCurves = new List <Curve>();
            var boxCurves   = new List <BoxElement>();

            foreach (string crvData in inputs)
            {
                inputCurves.Add(LineFromString(crvData, bounds));
            }

            foreach (string boxData in boxes)
            {
                boxCurves.Add(BoxFromString(boxData, bounds));
            }

            return(new SolutionManifest(inputCurves, boxCurves, bounds));
        }
Exemple #2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var   id          = "";
            var   data        = "";
            Curve innerBounds = null;
            Curve outerBounds = null;

            DA.GetData(0, ref id);
            DA.GetData(1, ref data);
            DA.GetData(2, ref innerBounds);
            DA.GetData(3, ref outerBounds);

            var req = new CiceroRequest(data, innerBounds, outerBounds);

            SolutionManifest res = Parse.Request(req);

            res.RunContainment();
            res.RunVerbs();
            res.RunAdverbs();

            var dwg = Compose.Drawing(res);

            dwg.Build();

            var path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\cicero\\svg\\" + id + ".svg";

            io.File.WriteAllText(path, dwg.SvgText.ToString());

            var crvs = new List <Curve>();

            res.BoxElements.ForEach(x => x.InputSegments.ForEach(y => crvs.Add(y)));

            DA.SetDataList(0, res.InputLines);
        }