예제 #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve        SiteCrv    = null;
            List <Curve> IntCrv     = new List <Curve>();
            int          numParcels = 0;
            double       devMean    = double.NaN;
            double       rot        = double.NaN;
            int          showItr    = 0;
            bool         reset      = false;

            if (!DA.GetData(0, ref SiteCrv))
            {
                return;
            }
            if (!DA.GetDataList(1, IntCrv))
            {
                return;
            }
            if (!DA.GetData(2, ref numParcels))
            {
                return;
            }
            if (!DA.GetData(3, ref devMean))
            {
                return;
            }
            if (!DA.GetData(4, ref rot))
            {
                return;
            }
            if (!DA.GetData(5, ref showItr))
            {
                return;
            }
            if (!DA.GetData(6, ref reset))
            {
                return;
            }

            /// global variables to keep track of iterations
            List <Curve> lowestDevCrv = new List <Curve>();
            double       minScore     = 100000.00;
            int          minIndex     = 0;

            // double score = 0;
            // string minIndexScore = minIndex.ToString() + ": " + minScore.ToString();

            if (reset == true)
            {
                // scoreLi = new List<double>();
                // scoreLiMsg = new List<string>();
                bspObjLi     = new List <BspUfgObj>();
                lowestDevCrv = new List <Curve>();
                minIndex     = 0;
                // score = 0;
                // minIndexScore = "";
                thisFCRVS = new List <Curve>();
            }

            // int NumIters = scoreLi.Count;  //(int)numItrs;
            double Rotation = Rhino.RhinoMath.ToRadians(rot);

            BspUfgAlg bspalg = new BspUfgAlg(SiteCrv, IntCrv, numParcels, devMean, Rotation);

            bspalg.RUN_BSP_ALG();
            BspUfgObj mybspobj = bspalg.GetBspObj();

            // score= mybspobj.GetScore();
            // string myscoreMsg = mybspobj.GetMsg();

            bspObjLi.Add(mybspobj);

            // scoreLiMsg.Add(myscoreMsg);

            for (int i = 0; i < bspObjLi.Count; i++)
            {
                double score2 = bspObjLi[i].GetScore();
                if (score2 < minScore)
                {
                    minScore = score2;
                    minIndex = i;
                }
            }

            // minIndexScore = bspalg.getMSG() + "\n\n\n";
            // minIndexScore += minIndex.ToString() + ": " + minScore.ToString();
            try { thisFCRVS = bspObjLi[showItr].GetCrvs(); } catch (Exception) { }
            try { lowestDevCrv = bspObjLi[minIndex].GetCrvs(); } catch (Exception) { }
            try { DA.SetDataList(0, lowestDevCrv); } catch (Exception) { }
            try { DA.SetDataList(1, thisFCRVS); } catch (Exception) { }
        }
예제 #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Curve  SiteCrv    = null;
            int    numParcels = 0;
            double devMean    = double.NaN;
            double rot        = double.NaN;
            int    showItr    = 0;
            bool   reset      = false;

            if (!DA.GetData(0, ref SiteCrv))
            {
                return;
            }
            if (!DA.GetData(1, ref numParcels))
            {
                return;
            }
            if (!DA.GetData(2, ref devMean))
            {
                return;
            }
            if (!DA.GetData(3, ref rot))
            {
                return;
            }
            if (!DA.GetData(4, ref showItr))
            {
                return;
            }
            if (!DA.GetData(5, ref reset))
            {
                return;
            }

            /// global variables to keep track of iterations
            List <Curve> lowestDevCrv = new List <Curve>();
            double       minScore     = 100000.00;
            int          minIndex     = 0;

            if (reset == true)
            {
                bspObjLi     = new List <BspUfgObj>();
                lowestDevCrv = new List <Curve>();
                minIndex     = 0;
                thisFCRVS    = new List <Curve>();
            }

            double Rotation = Rhino.RhinoMath.ToRadians(rot);

            BspUfgAlg bspalg = new BspUfgAlg(SiteCrv, numParcels, devMean, Rotation);

            bspalg.RUN_BSP_ALG(); // RECURSIVELY PARTITION
            BspUfgObj mybspobj = bspalg.GetBspObj();

            bspObjLi.Add(mybspobj);

            for (int i = 0; i < bspObjLi.Count; i++)
            {
                double score2 = bspObjLi[i].GetScore();
                if (score2 < minScore)
                {
                    minScore = score2;
                    minIndex = i;
                }
            }

            try { thisFCRVS = bspObjLi[showItr].GetCrvs(); } catch (Exception) { }
            try { lowestDevCrv = bspObjLi[minIndex].GetCrvs(); } catch (Exception) { }
            try { DA.SetDataList(0, lowestDevCrv); } catch (Exception) { }
            try { DA.SetDataList(1, thisFCRVS); } catch (Exception) { }

            /*
             * try
             * {
             *  List<Curve> DebugBBX = bspalg.DebugBBX;
             *  DA.SetDataList(2, DebugBBX);
             * }
             * catch (Exception) { }
             */
        }