1

I'm a new ILNumerics Visualization Engine user and I'm still coming up to speed on how to use it well. I've searched extensively for how to update the z-values of an ILSurface and read the posts, but I'm still not clear on how to do this.

I'm able to generate a surface and set up a camera to view it (Hamyo Kutschbach told me that's the best way to ensure that the aspect ratios of the surface don't change when rotating the surface, which is important in my application). Here's the code that displays a sin(x)/x function:

        // Generate the data
        ILArray<double> z = SincFunc(rows, cols, 10, 50);
        ILArray<double> x = new double[cols];
        ILArray<double> y = new double[rows];
        for (int i = 0; i < cols; i++)
            x[i] = (double)i;
        for (int i = 0; i < rows; i++)
            y[i] = (double)i;

        // create the scene
        scene = new ILScene();
        pointCloudSurface = new ILSurface(z, x, y)
        {

            Colormap = Colormaps.Jet,
            UseLighting = true,
            Wireframe = { Visible = false },
            Children = { new ILColorbar()
            {
                Height = 0.5f,
                Location = new PointF(0.95f, 0.05f),
                Children = { new ILLabel("microns") { Position = new Vector3(0.5,1,0), Anchor = new PointF(0.5f,0) } } }
            },
            Alpha = 1.0f
        };
        // Configure the surface and display it
        scene.Camera.Add(pointCloudSurface);
        scene.Camera.Position = new Vector3(50, 50, 700);
        scene.Camera.LookAt = new Vector3(50, 50, 0);
        scene.Camera.Top = new Vector3(0, 0, 700);
        scene.Camera.Projection = Projection.Perspective;
        scene.Camera.ZNear = 1.0f;
        scene.Camera.ZFar = 0.0f;
        scene.Camera.Top = new Vector3(1, 0, 0);
        // Turn off the Powered by ILNumerics label
        scene.Screen.First<ILLabel>().Visible = false;
        ilPanel1.Scene = scene;
        ilPanel1.Configure();
        ilPanel1.Refresh();

And it works well. So now I want to change the z-values and update the plot without closing ilPanel1 because this plot is embedded in a Windows Form. Advice would be appreciated! Hopefully other newbies will find this post useful as well.

Dave R
  • 31
  • 4

1 Answers1

1

After further rummaging around, I came across a method, UpdateColormapped(), that does the trick. It's placed near the end of the code above like this:

        scene.Camera.First<ILSurface>().UpdateColormapped(z);
        ilPanel1.Scene = scene;
        ilPanel1.Configure();
        ilPanel1.Refresh();

It can be found in the API documentation here: UpdateColormapped()

It can also change the x and y data and perform other mods, but it requires that the z data be a float array, so if you're working double precision, you'll have to take the appropriate steps to get it into a float array.

Dave R
  • 31
  • 4