/// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object can be used to retrieve data from input parameters and 
        /// to store data in output parameters.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_Box box = null;
            if (!DA.GetData(0, ref box)) return;

            GH_Integer nx = null;
            if (!DA.GetData(1, ref nx)) return;

            GH_Integer ny = null;
            if (!DA.GetData(2, ref ny)) return;

            GH_Integer nz = null;
            DA.GetData(3, ref nz);

            List<GH_Number> vals = new List<GH_Number>();
            DA.GetDataList(4, vals);

            if (nz == null)
            {
                var d = box.Value.BoundingBox.ToInterval2d();
                var f = new GridScalarField2d(d, nx.Value, ny.Value, _wrapX, _wrapY, _sample);

                // set values
                if (vals != null)
                {
                    if (vals.Count == 1)
                        f.Set(vals[0].Value);
                    else
                        f.Set(vals.Select(x => x.Value));
                }

                DA.SetData(0, new GH_ObjectWrapper(f));
            }
            else
            {
                var d = box.Value.BoundingBox.ToInterval3d();
                var f = new GridScalarField3d(d, nx.Value, ny.Value, nz.Value, _wrapX, _wrapY, _wrapZ, _sample);

                // set values
                if (vals != null)
                {
                    if (vals.Count == 1)
                        f.Set(vals[0].Value);
                    else
                        f.Set(vals.Select(x => x.Value));
                }

                DA.SetData(0, new GH_ObjectWrapper(f));
            }
        }
        /// <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_ObjectWrapper costGoo = null;

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

            List <GH_Integer> sources = new List <GH_Integer>();

            if (!DA.GetDataList(1, sources))
            {
                return;
            }

            int metric = -1;

            if (!DA.GetData(2, ref metric))
            {
                return;
            }

            var cost = (GridScalarField2d)costGoo.Value;
            var dist = new GridScalarField2d(cost);

            switch (metric)
            {
            case 0:
                FieldSim.GeodesicDistanceL1(cost, sources.Select(x => x.Value), dist.Values);
                break;

            case 1:
                FieldSim.GeodesicDistanceL2(cost, sources.Select(x => x.Value), dist.Values);
                break;

            default:
                throw new NotSupportedException("The specified distance metric is not supported.");
            }

            DA.SetData(0, new GH_ObjectWrapper(dist));
        }