Exemplo n.º 1
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)
        {
            InputChecker inputChecker = new InputChecker(this);

            List <Curve>  inCurves = new List <Curve>();
            List <double> inThres  = new List <double>();
            bool          succes   = DA.GetDataList <Curve>(0, inCurves) && DA.GetDataList <double>(1, inThres);

            inputChecker.StopIfConversionIsFailed(succes);
            ValuesAllocator.MatchLists(inCurves, inThres);

            List <Curve> culledCrvs = CurveProcessor.CullShortCrv(inCurves, inThres);

            #region SendOutputsToCanvas

            DA.SetDataList(0, culledCrvs);

            #endregion
        }
Exemplo n.º 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)
        {
            InputChecker inputChecker = new InputChecker(this);

            #region getDataFromCanvas
            List <Curve> inCurves     = new List <Curve>();
            bool         canGetCurves = DA.GetDataList(0, inCurves);
            inputChecker.StopIfConversionIsFailed(canGetCurves);

            List <int> inClosingTypes    = new List <int>();
            bool       canGetClosingType = DA.GetDataList(1, inClosingTypes);
            inputChecker.StopIfConversionIsFailed(canGetClosingType);
            ValuesAllocator.MatchLists(inCurves, inClosingTypes);

            List <double> inTollerances     = new List <double>();
            bool          canGetTollerances = DA.GetDataList(2, inTollerances);
            inputChecker.StopIfConversionIsFailed(canGetTollerances);
            ValuesAllocator.MatchLists(inCurves, inTollerances);
            #endregion

            List <Point3d> endPoints      = new List <Point3d>();
            List <Curve>   closedCurves   = new List <Curve>();
            List <bool>    closingResults = new List <bool>();

            for (int i = 0; i < inCurves.Count; i++)
            {
                Curve crv = inCurves[i];
                if (crv.IsClosed)
                {
                    closedCurves.Add(crv);
                    closingResults.Add(true);
                }
                else
                {
                    if (inClosingTypes[i] <= 0)
                    {
                        CurveProcessor.CloseCrvAddingLine(inTollerances, endPoints, closedCurves, closingResults, i, crv);
                    }
                    else if (inClosingTypes[i] >= 1)
                    {
                        bool success = crv.MakeClosed(inTollerances[i]);
                        if (!success)
                        {
                            List <Point3d> endPts = CurveProcessor.GetEndPtsFromOpenCurve(crv);
                            endPoints.AddRange(endPts);
                            closedCurves.Add(null);
                        }
                        else
                        {
                            closedCurves.Add(crv);
                        }

                        closingResults.Add(success);
                    }
                    //TODO: Add blend option for the future
                }
            }

            DA.SetDataList(0, endPoints);
            DA.SetDataList(1, closedCurves);
            DA.SetDataList(2, closingResults);
        }