Multi-Resolution Rendering with Overlapping AMR: Difference between revisions

From ParaQ Wiki
Jump to navigationJump to search
Line 91: Line 91:
</source>
</source>


New, we need to tell the view that this representation supports streaming. This is done in ProcessViewRequest() as follows:
Next, we need to tell the view that this representation supports streaming. This is done in ProcessViewRequest() as follows:


<source lang="cpp">
<source lang="cpp">

Revision as of 11:59, 10 October 2012

Motivation

With dataset sizes growing increasingly large, exploratory interactive visualization keeps on getting harder and harder. Multi-resoltuion visualization makes it possible to deal with large datasets while keeping the system requirements and response times low.

This document is for advanced developers and assumes familiarity with VTK data and execution model and ParaView architecture.

Design Overview

ParaView/VTK provides an infrastructure for multi-resolution analysis based on composite datasets (multiblock datasets or overlapping AMR datasets). The principle is as follows:

  1. Sources/Filters produce meta-data in their RequestInformation() pass. This meta-data can be used by any sink to decide what are the blocks in the dataset, how are they positioned, what is the cost for processing that block of dataset. For AMR datasets, this meta-data is properly defined by vtkAMRInformation. For other composite datasets, users are free to come up with their own convention. So long as the sink and source are aware of the convention, we are good.
  2. A Sink can request a particular block (or blocks) from the source by providing appropriate keys in the RequestUpdateExtent() pass. The source then delivers those blocks.

This general streaming principal can be extended to views and representations too, for rendering. The representations, in this case, act as the sinks that process meta-data and request blocks from the sources. The render view in ParaView (vtkPVRenderView), provides mechanisms for representations to leverage to render the dataset in a streaming fashion.

Implementation

While the framework is flexible enough to support any composite dataset, our current implementation only supports AMR datasets (vtkOverlappingAMR). This section provides an overview of the various components involved in multi-resolution rendering of AMR datasets.

Data Producer

The starting point is the data source. The source needs to provide meta-data about the data in RequestInformation() pass and then read blocks of data as requested in the RequestData() pass. Examples are vtkUniformGridAMRReader, and vtkAMRFlashReader. These readers read the "meta-data" in the files (without reading the heavy data) and produce an empty vtkOverlappingAMR in their RequestInformation pass with structure matching the expected blocks in the output.

//----------------------------------------------------------------------------
int vtkXMLUniformGridAMRReader::RequestInformation(vtkInformation *request,
  vtkInformationVector **inputVector, vtkInformationVector *outputVector)
{
  if (!this->Superclass::RequestInformation(request, inputVector, outputVector))
    {
    return 0;
    }

  // this->Metadata is of type vtkOverlappingAMR and is filled up before the control reaches
  // this point.
  if (this->Metadata)
    {
    // Pass the meta-data down the pipeline.
    outputVector->GetInformationObject(0)->Set(
      vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA(),
      this->Metadata);
    }
  else
    {
    outputVector->GetInformationObject(0)->Remove(
      vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA());
    }
  return 1;
}

Data Consumer / Representation

Now we need to provide a representation that can use this meta-data to request blocks in a streaming fashion. This representation can have any arbitrary code to manage multiple blocks and thus can employ arbitrary conventions about how the data is structured, how multiple resolutions are merged, etc. Examples are vtkAMROutlineRepresentation, and vtkAMRStreamingVolumeRepresentation. vtkAMROutlineRepresentation is a simple representation that simply renders blocks for datasets delivered. It is a good illustration for representation that support streaming since the rendering code itself is simple.

Let's look at vtkAMROutlineRepresentation in more detail.

First, this representation needs to check that the input pipeline is streaming capable. This is done by overriding RequestInformation() and checking for presence of the meta-data. vtkPVView::GetEnableStreaming() maybe removed in future. It is currently provided to allow enabling/disabling streaming support from command line. vtkPVView::GetEnableStreaming() returns true when the process is started with "--enable-streaming" command line argument.

//----------------------------------------------------------------------------
int vtkAMROutlineRepresentation::RequestInformation(vtkInformation *rqst,
    vtkInformationVector **inputVector,
    vtkInformationVector *outputVector)
{
  // Determine if the input is streaming capable. A pipeline is streaming
  // capable if it provides us with COMPOSITE_DATA_META_DATA() in the
  // RequestInformation() pass. It implies that we can request arbitrary blocks
  // from the input pipeline which implies stream-ability.

  this->StreamingCapablePipeline = false;
  if (inputVector[0]->GetNumberOfInformationObjects() == 1)
    {
    vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
    if (inInfo->Has(vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA()) &&
      vtkPVView::GetEnableStreaming())
      {
      this->StreamingCapablePipeline = true;
      }
    }

  vtkStreamingStatusMacro(
    << this << ": streaming capable input pipeline? "
    << (this->StreamingCapablePipeline? "yes" : "no"));
  return this->Superclass::RequestInformation(rqst, inputVector, outputVector);
}

Next, we need to tell the view that this representation supports streaming. This is done in ProcessViewRequest() as follows:

//----------------------------------------------------------------------------
int vtkAMROutlineRepresentation::ProcessViewRequest(
  vtkInformationRequestKey* request_type, vtkInformation* inInfo, vtkInformation* outInfo)
{
  // always forward to superclass first. Superclass returns 0 if the
  // representation is not visible (among other things). In which case there's
  // nothing to do.
  if (!this->Superclass::ProcessViewRequest(request_type, inInfo, outInfo))
    {
    return 0;
    }

  if (request_type == vtkPVView::REQUEST_UPDATE())
    {
    // Standard representation stuff, first.
    // 1. Provide the data being rendered.
    vtkPVRenderView::SetPiece(inInfo, this, this->ProcessedData);

    // 2. Provide the bounds.
    double bounds[6];
    this->DataBounds.GetBounds(bounds);
    vtkPVRenderView::SetGeometryBounds(inInfo, bounds);

    // The only thing extra we need to do here is that we need to let the view
    // know that this representation is streaming capable (or not).
    vtkPVRenderView::SetStreamable(inInfo, this, this->GetStreamingCapablePipeline());
    }
  
  ...
}