Exemplo n.º 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Mesh   mesh  = new Mesh();
            double d     = 1;
            double step  = 0.25;
            double scale = 0.9;
            var    additionalPolylines = new GH_Structure <GH_Curve>();

            if (DA.GetData(0, ref mesh))
            {
                DA.GetData(1, ref d);
                DA.GetData(2, ref step);
                DA.GetData(3, ref scale);
                DA.GetDataTree(4, out additionalPolylines);

                var additionalPolylinesCopy = new GH_Structure <GH_Curve>(additionalPolylines, false);

                bool flag = true;
                if (additionalPolylines.Branches.Count != 2)
                {
                    flag = false;
                }
                else
                {
                    if (additionalPolylines[0].Count != mesh.Ngons.Count || additionalPolylines[1].Count != mesh.Ngons.Count)
                    {
                        flag = false;
                    }
                }
                if (!flag)
                {
                    var plines = Joinery.Miter(mesh, d, step, scale, ref additionalPolylinesCopy);

                    DA.SetDataTree(1, GrasshopperUtil.ListOfListsToTree(plines, DA.Iteration));
                    DA.SetDataTree(2, additionalPolylinesCopy);
                }
                else
                {
                    //public static List<List<Polyline>> Miter(Mesh M,  double D,double JointStep, double scale, ref GH_Structure<GH_Curve> additionalPlines)
                    var plines = Joinery.Miter(mesh, d, step, scale, additionalPolylinesCopy);
                    DA.SetDataTree(2, GrasshopperUtil.ListOfListsToTree(plines, DA.Iteration));
                    //DA.SetDataTree(2, additionalPolylinesCopy);
                }
            }
        }
Exemplo n.º 2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Mesh   mesh = new Mesh();
            double d    = 1;
            bool   f    = false;
            bool   n    = false;
            bool   c    = false;

            if (DA.GetData(0, ref mesh))
            {
                DA.GetData(1, ref d);
                DA.GetData(2, ref f);
                DA.GetData(3, ref n);
                DA.GetData(4, ref c);

                var meshes = new List <Mesh>();
                var plines = mesh.GetFlaps(d, f, n, c, ref meshes);
                DA.SetDataList(0, meshes);
                DA.SetDataTree(1, GrasshopperUtil.ListOfListsToTree(plines, DA.Iteration));
            }
        }