Ejemplo 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)
        {
            Curve polyline = null;

            if (!DA.GetData(0, ref polyline))
            {
                return;
            }
            List <Point3d> pts   = ViperClass.Ptsss(polyline);
            List <Line>    lines = new List <Line>();

            if (pts.Count > 3)
            {
                for (int i = 0; i < pts.Count; i++)
                {
                    for (int j = i + 2; j < pts.Count; j++)
                    {
                        if (i == 0 && j == pts.Count - 1)
                        {
                            break;
                        }
                        Line l = new Line(pts[i], pts[j]);
                        lines.Add(l);
                    }
                }
            }
            DA.SetDataList(0, lines);
        }
Ejemplo 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)
        {
            ///////////////////////////////////////////////////////////////////////////////////////////////////声明变量
            Curve c1 = null;
            Curve c2 = null;

            ///////////////////////////////////////////////////////////////////////////////////////////////////检测输入端是否合理
            if (!DA.GetData(0, ref c1))
            {
                return;
            }
            if (!DA.GetData(1, ref c2))
            {
                return;
            }
            List <Point3d> ptcor1    = ViperClass.Ptsss(c1);
            List <Point3d> ptcor2    = ViperClass.Ptsss(c2);
            Polyline       polylineA = new Polyline(ptcor1);
            Polyline       polylineB = new Polyline(ptcor2);
            List <double>  angles1   = new List <double>();
            List <double>  angles2   = new List <double>();
            List <double>  ag1       = new List <double>();
            List <double>  ag2       = new List <double>();
            int            n1        = polylineA.SegmentCount;
            int            n2        = polylineB.SegmentCount;
            bool           flag      = false;

            if (n1 == n2)
            {
                flag = true;
                Line[] ls1 = polylineA.GetSegments();
                Line[] ls2 = polylineB.GetSegments();
                for (int i = 0; i < n1; i++)
                {
                    if (i == n1 - 1)
                    {
                        Line   la11 = ls1[i];
                        Line   la22 = ls1[0];
                        double aa   = Math.Round(ViperClass.getangle(la11, la22), 3);
                        angles1.Add(aa);
                        Line   lb11 = ls2[i];
                        Line   lb22 = ls2[0];
                        double bb   = Math.Round(ViperClass.getangle(lb11, lb22), 3);
                        angles2.Add(bb);
                        continue;
                    }
                    Line   la1 = ls1[i];
                    Line   la2 = ls1[i + 1];
                    double a   = Math.Round(ViperClass.getangle(la1, la2), 3);
                    angles1.Add(a);
                    Line   lb1 = ls2[i];
                    Line   lb2 = ls2[i + 1];
                    double b   = Math.Round(ViperClass.getangle(lb1, lb2), 3);
                    angles2.Add(b);
                }
                angles1.Sort();
                angles2.Sort();
                for (int i = 0; i < n1; i++)
                {
                    if (angles1[i] != angles2[i])
                    {
                        flag = false;
                        break;
                    }
                }
            }
            DA.SetData(0, flag);
        }