下面是我使用的代码:如何在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()需要几秒钟就可以完成:在〜调试和6S〜4S在Release模式。
表面更新后,旋转和平移操作非常流畅。
表面越小,更新速度越快。
是否有更高效的方法来更新曲面位置/颜色缓冲区?
注意:在Windows 7笔记本电脑上使用IlNumerics 3.2.2 Community Edition双显卡(Intel HD 4000 + GeForce GT 650M),并激活nvidia卡。
如果我正确猜测,耗时的操作是找出场景的哪些元素将被渲染。知道我的最终目标实际上是用TwoDMode = true绘制一个曲面,并且只使用一个颜色映射来表示高度,是不是可以更有效地绘制它?如果我绘制出平坦的表面并根据高度渲染颜色,那么处理速度会更快吗? (我目前无法测试,但会尽快尝试。) – ice
请回报您的结论!我编辑了答案以及.. –
从版本4.1 [ImageSCPlots](http://ilnumerics.net/imagesc-plots.html)有更多的苗条,应该解决您的问题。 –