Esempio n. 1
0
        /// <inheritdoc />
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_HeMesh3d hemGoo = null;

            if (!DA.GetData(0, ref hemGoo))
            {
                return;
            }

            int start = -1;

            if (!DA.GetData(1, ref start))
            {
                return;
            }

            List <double> factors = new List <double>();

            DA.GetDataList(2, factors);

            var mesh = new HeMesh3d(hemGoo.Value);
            var f    = mesh.Faces[start];

            // ensures mesh is unrollable
            HeMeshUnroller.DetachFaceCycles(mesh, f);

            // perform unroll
            var unrolled = new Vec3d[mesh.Vertices.Count];
            var last     = factors.Count - 1;

            HeMeshUnroller.Unroll(mesh, f, (v, p) => unrolled[v] = p, he => factors[Math.Min(he >> 1, last)]);

            // set vertex attributes
            var fn = f.GetNormal(v => v.Position);

            mesh.Vertices.Action(v =>
            {
                v.Position = unrolled[v];
                v.Normal   = fn;
            });

            DA.SetData(0, new GH_HeMesh3d(mesh));
        }