如何在ILNumerics中有效地绘制大表面(例如1000x1000)? [英] How to efficiently plot a large surface (e.g., 1000x1000) in ILNumerics?

查看:153
本文介绍了如何在ILNumerics中有效地绘制大表面(例如1000x1000)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我使用的代码:

public partial class Form1 : Form
{
    private ILPlotCube plotcube_ = null;
    private ILSurface surface_ = null;

    public Form1()
    {
        InitializeComponent();

        ilPanel1.Driver = RendererTypes.OpenGL;
    }

    private void ilPanel1_Load(object sender, EventArgs e)
    {
        var scene = new ILScene();
        plotcube_ = scene.Add(new ILPlotCube(twoDMode: false));
        plotcube_.MouseDoubleClick += PlotCube_MouseDoubleClick;

        ilPanel1.Scene = scene;
    }

    private void PlotCube_MouseDoubleClick(object sender, ILMouseEventArgs e)
    {
        ResetSurface();
        e.Cancel = true;
        e.Refresh = true;
    }

    private void ResetSurface()
    {
        using (ILScope.Enter())
        {
            ILArray<float> array = ILMath.tosingle(ILSpecialData.sincf(1000, 1000));

            if (surface_ == null)
            {
                surface_ = new ILSurface(0);
                surface_.Fill.Markable = false;
                surface_.Wireframe.Visible = false;
                plotcube_.Add(surface_);
            }

            surface_.UpdateColormapped(array);
            surface_.UseLighting = false;
        }

        plotcube_.Plots.Reset();
    }
}

对ResetSurface()的每次调用都需要几秒钟才能完成:在Debug中约为6s,在Release模式中约为4s.

Each call to ResetSurface() takes a few seconds to complete: ~6s in Debug and ~4s in Release mode.

但是,一旦更新了曲面,旋转和平移操作就非常流畅.

Once the surface is updated, though, rotation and pan operations are very fluid.

表面越小,更新越快.

是否有更有效的方法来更新表面位置/颜色缓冲区?

Is there a more efficient way to update the surface positions/colors buffers?

注意:在具有双显卡(Intel HD 4000 + GeForce GT 650M)的Windows 7笔记本电脑上使用IlNumerics 3.2.2 Community Edition,并激活了nvidia卡.

Note: using IlNumerics 3.2.2 Community Edition on Windows 7 laptop with dual graphics (Intel HD 4000 + GeForce GT 650M), with nvidia card activated.

推荐答案

您的代码显然没有错.常见的陷阱是线框颜色.如果保留为半透明(默认),则必要的排序将减慢渲染速度.但是您已经将其设置为Visible = false.

There is nothing obviously wrong with your code. A common pitfall is the wireframe color. If it is left to be semitransparent (default), the necessary sorting would slow the rendering down. But you have already set it to Visible = false.

因此,在我的机器(Windows 7,T430笔记本电脑,i7和类似图形)上,更新需要不到2秒的时间(发布时未连接调试器!).恐怕就是这样.后面有很多东西……

So on my machine (win 7, T430 notebook, i7 and similar graphics) it takes <2 sec to update (Release with no debugger attached!). I am afraid, that's just what it takes. There is a lot of stuff going on in the back ...

@Edit使用ILSurface.UpdateRGBA()预先计算颜色并将其提供为离散颜色可能会更快.您将不得不尝试使用探查器来调查瓶颈.另一个选择-因为您追求的是简单的imagesc-style绘图,所以您可以自行构建imagesc:ILTriangles(-strip)更加苗条,并且可能提供了更多选择来提高更新速度.但是,您将必须自己进行大量的重新排序/顶点生成/颜色计算.另外,这不会为您提供ILSurface的颜色栏支持.

@Edit It might be faster to precompute the colors and provide them as discrete color using ILSurface.UpdateRGBA(). You will have to try and use a profiler to investigate the bottleneck. Another option - since you are after a simple imagesc-style plot - is to build the imagesc on your own: ILTriangles(-strip) ist much more slim and probably gives more option to increase the update speed. However, you will have to do a considerable amount of reordering / vertex generation / color computation on your own. Also, this won't give you the colorbar support of ILSurface.

@Edit:您可以使用 ILImageSCPlot 类替代ILSurface.该文档位于: http://ilnumerics.net/imagesc-plots.html

@ You can use the ILImageSCPlot class as a slim replacement for ILSurface. The documentation is here: http://ilnumerics.net/imagesc-plots.html

这篇关于如何在ILNumerics中有效地绘制大表面(例如1000x1000)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆