Paraview与VTK学习笔记(五)

本文是Paraview与VTK学习笔记的第五部分,主要讨论了AccumulationBuffer的管理。内容涉及检查并确保AccumulationBuffer的正确性,当其不存在或小于bufferSize时,会删除原有内容并重新分配空间。同时提到了内存释放以及Renderers中的vtkRendererCollection,通过遍历获取RenderWindow和Layer的数量。
摘要由CSDN通过智能技术生成

上一节最后执行到:

this->GetRenderWindow()->Render();
也就是执行到了vtkRenderWindow::Render()了,我们可以看到这个函数是告诉这个RenderWindow下的每一个renderer去渲染他的图像,并且保持进程同步
// Ask each renderer owned by this RenderWindow to render its image and
// synchronize this process
void vtkRenderWindow::Render()
{
  int *size;
  int x,y;
  float *p1;
  // if we are in the middle of an abort check then return now
  if (this->InAbortCheck)
    {
    return;
    }

如果是在中止的中间过程,则check并且返回

// if we are in a render already from somewhere else abort now
  if (this->InRender)
    {
    return;
    }
如果从其他某个地方现在已经在渲染了,那么立即中止

 // if SetSize has not yet been called (from a script, possible off
  // screen use, other scenarios?) then call it here with reasonable
  // default values
  if (0 == this->Size[0] && 0 == this->Size[1])
    {
    this->SetSize(300, 300);
    }
如果SetSize还没有被使用(通过一个脚本,或者关闭屏幕,或者其他情况),那么在这里调用它,并赋值默认值
// reset the Abort flag
  this->AbortRender = 0;
  this->InRender = 1;

  vtkDebugMacro(<< "Starting Render Method.\n");
  this->InvokeEvent(vtkCommand::StartEvent,NULL);

  this->NeverRendered = 0;

  if ( this->Interactor && ! this->Interactor->GetInitialized() )
    {
    this->Interactor->Initialize();
    }
重置中止符号,开始渲染,设置InRender为1。调用开始事件。并且初始化关联器

 // CAUTION:
  // This method uses this->GetSize() and allocates buffers using that size.
  // Remember that GetSize() will returns a size scaled by the TileScale factor.
  // We should use GetActualSize() when we don't want the size to be scaled.

  // if there is a reason for an AccumulationBuffer
  if ( this->SubFrames || this->AAFrames || this->FDFrames)
    {
    // check the current size
    size = this->GetSize();
    unsigned int bufferSize = 3*size[0]*size[1];
    // If there is not a buffer or the size is too small
    // re-allocate it
    if( !this->AccumulationBuffer
        || bufferSize > this->AccumulationBufferSize)
      {
      // it is OK to delete null, no sense in two if's
      delete [] this->AccumulationBuffer;
      // Save the size of the buffer
      this->AccumulationBufferSize = 3*size[0]*size[1];
      this->AccumulationBuffer = new float [this->AccumulationBufferSize];<span style="font-family: Arial, Helvetica, sans-serif;">memset(this->AccumulationBuffer,0,this->AccumulationBufferSize*sizeof(float));}}</span>
这个方法使用this->GetSize(),并且分配buffers从而使用这个size。这个GetSize()函数会根据TileScale调整比例。如果我们不希望这个size被调整,那么调用GetActualSize()。

上面这段代码我们可以看出,主要是为了确保AccumulationBuffer的正确性,如果过不存在或者比bufferSize小。则给它删除原有的,重新赋值并且分配空间。

  // handle any sub frames
  if (this->Su
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值