这是我使用的代码:
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() 都需要几秒钟才能完成:调试模式下约为 6 秒,发布模式下约为 4 秒。
然而,一旦表面更新,旋转和平移操作就非常流畅。
表面越小,更新越快。
是否有更有效的方法来更新表面位置/颜色缓冲区?
注意:在具有双显卡(Intel HD 4000 + GeForce GT 650M)且已激活 nvidia 卡的 Windows 7 笔记本电脑上使用 IlNumerics 3.2.2 Community Edition。
您的代码没有任何明显的错误。一个常见的陷阱是线框颜色。如果将其保留为半透明(默认),则必要的排序会减慢渲染速度。但你已经将其设置为Visible = false
.
因此,在我的机器(win 7、T430 笔记本、i7 和类似显卡)上,更新需要
@Edit 预先计算颜色并使用 ILSurface.UpdateRGBA() 将它们提供为离散颜色可能会更快。您必须尝试使用分析器来调查瓶颈。另一个选择 - 因为您正在追求简单的 imagesc 风格的绘图 - 是自己构建 imagesc:ILTriangles(-strip) 更苗条,并且可能提供更多选项来提高更新速度。但是,您必须自己进行大量的重新排序/顶点生成/颜色计算。此外,这不会为您提供 ILSurface 的颜色条支持。
@编辑:您可以使用IL图像SCP图 http://ilnumerics.net/imagesc-plots.html类作为 ILSurface 的纤薄替代品。文档在这里:http://ilnumerics.net/imagesc-plots.html http://ilnumerics.net/imagesc-plots.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)