Question

I want to dynamically calculate elements of Array and after each iteration put those points on the ILNumerics form. Is it possible?

UPDATE:

this is my code.

Initialize N:

 private const int N = 20000000;

This is a function that store data in array and then send it to the function named "Draw"

        public void Calc()
    {
        float o = (float) Math.PI/6;
        float lambda;
        const float hLambda = 0.02f;
         const float hAlpha = 0.02f;
        float alpha = (float) Math.PI/36;
        float[,] a;
        int i = 0;
        a = new float[N, 3];
            for (alpha = (float) 0; alpha < 6.2832; alpha += hAlpha)
                for (lambda = -1.8f; lambda <= 1.8f; lambda += hLambda)
                    for (var j = 0; j < 1000; j++)
                {
                    float xPaint = X_Sphere(lambda, o, alpha);
                    float yPaint = Y_Sphere(lambda, o, alpha);
                    float zPaint = Z_Sphere(lambda, o, alpha);


                    if (j > 900)
                    {
                        a[i, 0] = zPaint;
                        a[i, 1] = yPaint;
                        a[i, 2] = xPaint;
                        i++;
                    }
                    o = Calculate(o, lambda, alpha);
                }

            Draw(a, false);
    }

It's functon, which calculates data:

    public float Calculate(float o, float lambda, float alpha)
    {
        return (float) (lambda*Math.Sin(o + alpha));
    }

There I am transform coordinates from Spherical to Cartesian:

    public float X_Sphere(float r, float tetta, float a)
    {
        return (float) (r*Math.Sin(tetta)*Math.Cos(a));
    }

    public float Y_Sphere(float r, float tetta, float a)
    {
        return (float) (r*Math.Sin(tetta)*Math.Sin(a));
    }

    public float Z_Sphere(float r, float tetta, float a)
    {
        return (float) (r*Math.Cos(tetta));
    }

    private void Draw(float[,] obj, bool twodMode)
    {
        var cm = new ILColormap(Colormaps.Jet); 

        var scene = new ILScene();
        var pc = new ILPlotCube();
        var points = new ILPoints();
        points.Positions = obj;
        points.Size = 1f;
        ILArray<float> Z = ILSpecialData.sincf(10000000, 3, 4);
        var cmap = new ILColormap(Colormaps.Jet);
        points.Colors = cmap.Map(Z).T;
        points.Color = null;
        pc.TwoDMode = false;
        scene.Add(pc);
        pc.Add(points);
        pc.AllowRotation = true;
        pc.AllowZoom = true;
        scene.Screen.First<ILLabel>().Visible = false;
        ilPanel1.Scene = scene;
    }
Was it helpful?

Solution

There is an option for 'incremental updates'. You would modify the positions buffer for the shape via the ILShape.Positions.Update(int startColumn, int count, ILInArray<T> data) function. This saves performance by only updating the modified part of the video memory (expecting OpenGL renderer here).

However, the buffer must exist as one big memory segment in graphics memory. I suspect the bottleneck more to lay in drawing, not in the buffer definition. A profiler is your friend!

Don't forget to call ILShape.Configure() after all modifications!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top