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)
        {
            GH_HeMesh3d hemGoo = null;
            int         start  = -1;

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

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

            // unroll
            HeMeshUnroller.Unroll(mesh, mesh.Faces[start]);

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

            mesh.Vertices.Action(v => v.Normal = fn);

            DA.SetData(0, new GH_HeMesh3d(mesh));
        }
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)
        {
            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 = hemGoo.Value.Duplicate();
            var f    = mesh.Faces[start];

            // unroll
            var last = factors.Count - 1;

            HeMeshUnroller.Unroll(mesh, mesh.Faces[start], he => factors[Math.Min(he >> 1, last)]);

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

            mesh.Vertices.Action(v => v.Normal = fn);

            DA.SetData(0, new GH_HeMesh3d(mesh));
        }
Exemplo n.º 3
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));
        }