Ejemplo n.º 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <Fiber> SortedFibers = new List <Fiber>();

            DA.GetDataList <Fiber>("Custom Sorted Fibers", SortedFibers);

            //double fiberCount = 0.0;
            //DA.GetData<double>("Fiber Count", ref fiberCount);

            List <Fiber>  ContinuousFibers = new List <Fiber>();
            List <string> PinIDsNote       = new List <string>();

            //initialize
            PathAgent PathAgent = new PathAgent(SortedFibers[0].PinA, SortedFibers[0], 0.0);

            ContinuousFibers.Add(SortedFibers[0]);
            PathAgent.MarkDownCurrentPin();

            for (int i = 0; i < SortedFibers.Count; i++)
            {
                PathAgent.GoToTheOtherPin(); //currentPin is changed
                PathAgent.MarkDownCurrentPin();
                // updated fiber
                PathAgent.SearchFiber(); //currentFiber & currentPin are changed
                PathAgent.MarkDownCurrentPin();
                ContinuousFibers.Add(PathAgent.CurrentFiber);
            }

            PinIDsNote = PathAgent.PinIDsNote;

            DA.SetDataList("Custom Fibers", ContinuousFibers);
            DA.SetDataList("Syntax Note", PinIDsNote);

            List <Curve> ContinousFiberCrv = new List <Curve>();

            ContinousFiberCrv = ContinuousFibers.Select(o => o.FiberCrv).ToList();

            DA.SetDataList("Fiber Curves", ContinousFiberCrv);

            List <double> FiberFabricationIndexs = PathAgent.FiberFabricationIndexes;

            DA.SetDataList("Fiber Fabrication Indexes", FiberFabricationIndexs);
        }
Ejemplo n.º 2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <Fiber> SortedFibersBigList = new List <Fiber>();

            DA.GetDataList <Fiber>("Sorted Custom Fibers", SortedFibersBigList);
            //double tolerance = 0.0;
            //DA.GetData<double>("Order Tolerance", ref tolerance);
            double pinCapacity = 0.0;

            DA.GetData <double>("Pin Capacity", ref pinCapacity);
            //double duplicateMax = 0.0;
            //DA.GetData<double>("Duplicate Maximum", ref duplicateMax);

            double fiberAmount = 0.0;

            DA.GetData <double>("Fiber Amount", ref fiberAmount);

            double skipRatio    = SortedFibersBigList.Count / fiberAmount;
            int    skipRatioInt = (int)skipRatio;

            List <Fiber> SortedFibers = new List <Fiber>();

            if (fiberAmount != 0)
            {
                for (int i = 0; i < SortedFibersBigList.Count; i++)
                {
                    if (i % skipRatioInt == 0)
                    {
                        SortedFibers.Add(SortedFibersBigList[i]);
                    }
                }
            }

            else
            {
                SortedFibers = SortedFibersBigList;
            }

            double RemoveEdge = 0.0;

            DA.GetData <double>("Remove Edge", ref RemoveEdge);

            // component output
            List <Fiber>  FiberSyntax = new List <Fiber>();
            List <string> PinIDsNote  = new List <string>();

            // initialize
            PathAgent PathAgent = new PathAgent(SortedFibers[0].PinA, SortedFibers[0], SortedFibers, RemoveEdge, pinCapacity); // the first pin is pinA of the first fiber on the list

            FiberSyntax.Add(SortedFibers[0]);
            SortedFibers[0].Direction  = "AB";
            SortedFibers[0].StartPinID = "A";
            SortedFibers[0].EndPinID   = "B";

            PathAgent.MarkDownCurrentPin();

            // add connected pins for first fiber, for duplicate check
            PathAgent.CurrentPin.ConnectedPins.Add(SortedFibers[0].PinB);
            SortedFibers[0].PinB.ConnectedPins.Add(SortedFibers[0].PinA);

            // mark down first fab index
            PathAgent.FiberFabricationIndexNote.Add(SortedFibers[0].FiberSortingIndex);

            // Loop of searching fibers begin
            for (int i = 0; i < SortedFibers.Count; i++)
            {
                PathAgent.GoToTheOtherPin(); // currentPin is changed according to current fiber
                PathAgent.MarkDownCurrentPin();
                // updated fiber

                // !!!
                PathAgent.SearchFiber(); // currentFiber & currentPin(may go to its neighbours) are changed
                // !!!
                if (PathAgent.CurrentPin.FrameID == "A")
                {
                    PathAgent.CurrentFiber.Direction  = "AB";
                    PathAgent.CurrentFiber.StartPinID = PathAgent.CurrentFiber.PinA.PinID;
                    PathAgent.CurrentFiber.EndPinID   = PathAgent.CurrentFiber.PinB.PinID;

                    //PathAgent.CurrentFiber.StartPin = PathAgent.CurrentFiber.PinA;
                    //PathAgent.CurrentFiber.EndPin = PathAgent.CurrentFiber.PinB;
                }

                else
                {
                    PathAgent.CurrentFiber.Direction  = "BA";
                    PathAgent.CurrentFiber.StartPinID = PathAgent.CurrentFiber.PinB.PinID;
                    PathAgent.CurrentFiber.EndPinID   = PathAgent.CurrentFiber.PinA.PinID;

                    //PathAgent.CurrentFiber.StartPin = PathAgent.CurrentFiber.PinB;
                    //PathAgent.CurrentFiber.EndPin = PathAgent.CurrentFiber.PinA;
                }

                PathAgent.MarkDownCurrentPin(); // because the current pin can go to its neighbours, mark down again
                FiberSyntax.Add(PathAgent.CurrentFiber);

                // evaluate
                //if (PathAgent.CurrentFiber.FiberSortingIndex - i > 0) // && intersect with each other
                //    PathAgent.SyntaxEvaluation += PathAgent.CurrentFiber.FiberSortingIndex - i;
            }
            List <Curve> ContinousFiberCrv = new List <Curve>();

            ContinousFiberCrv = FiberSyntax.Select(o => o.FiberCrv).ToList();
            List <double> FiberFabricationIndexs = PathAgent.FiberFabricationIndexNote;

            // Outputing
            PinIDsNote = PathAgent.PinIDsNote;

            DA.SetDataList("Custom Fibers", FiberSyntax);

            DA.SetDataList("Syntax Note", PinIDsNote);

            DA.SetDataList("Fiber Curves", ContinousFiberCrv);

            DA.SetDataList("Fiber Sorting Indexes", FiberFabricationIndexs);

            //DA.SetData("Syntax Evaluation", PathAgent.SyntaxEvaluation);

            DA.SetDataList("Skipped Fiber Curves", PathAgent.SkippedFibers.Select(o => o.FiberCrv).ToList());
        }