Commit f349e5fd authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

Cleaning up vtkAMRStreamingVolumeRepresentation code.

Cleaning up vtkAMRStreamingVolumeRepresentation code to match
vtkAMROutlineRepresentation for better readability.
parent c9c87027
......@@ -35,35 +35,30 @@ vtkStandardNewMacro(vtkAMRStreamingVolumeRepresentation);
//----------------------------------------------------------------------------
vtkAMRStreamingVolumeRepresentation::vtkAMRStreamingVolumeRepresentation()
{
this->VolumeMapper = vtkSmartVolumeMapper::New();
this->Property = vtkVolumeProperty::New();
this->Actor = vtkPVLODVolume::New();
this->Actor->SetProperty(this->Property);
this->Actor->SetMapper(this->VolumeMapper);
this->Resampler = vtkResampledAMRImageSource::New();
this->Resampler->SetMaxDimensions(32, 32, 32);
this->VolumeMapper->SetInputConnection(
this->Resampler->GetOutputPort());
vtkMath::UninitializeBounds(this->DataBounds);
this->StreamingCapablePipeline = false;
this->InStreamingUpdate = false;
this->PriorityQueue = vtkSmartPointer<vtkAMRStreamingPriorityQueue>::New();
this->Resampler = vtkSmartPointer<vtkResampledAMRImageSource>::New();
this->Resampler->SetMaxDimensions(32, 32, 32);
this->VolumeMapper = vtkSmartPointer<vtkSmartVolumeMapper>::New();
this->VolumeMapper->SetInputConnection(this->Resampler->GetOutputPort());
this->Property = vtkSmartPointer<vtkVolumeProperty>::New();
this->Actor = vtkSmartPointer<vtkPVLODVolume>::New();
this->Actor->SetProperty(this->Property);
this->Actor->SetMapper(this->VolumeMapper);
}
//----------------------------------------------------------------------------
vtkAMRStreamingVolumeRepresentation::~vtkAMRStreamingVolumeRepresentation()
{
this->Resampler->Delete();
this->VolumeMapper->Delete();
this->Property->Delete();
this->Actor->Delete();
}
//----------------------------------------------------------------------------
int vtkAMRStreamingVolumeRepresentation::FillInputPortInformation(int port,
int vtkAMRStreamingVolumeRepresentation::FillInputPortInformation(
int vtkNotUsed(port),
vtkInformation* info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkOverlappingAMR");
......@@ -89,41 +84,50 @@ int vtkAMRStreamingVolumeRepresentation::ProcessViewRequest(
if (request_type == vtkPVView::REQUEST_UPDATE())
{
// FIXME:STREAMING -- currently, only data-server rendering is supported and
// that too in non-parallel mode.
//vtkPVRenderView::SetPiece(inInfo, this,
// this->OutlineSource->GetOutputDataObject(0));
// outInfo->Set(vtkPVRenderView::NEED_ORDERED_COMPOSITING(), 1);
vtkPVRenderView::SetPiece(inInfo, this, this->InputData);
// 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);
// Just let the view know of out data bounds.
vtkPVRenderView::SetGeometryBounds(inInfo, this->DataBounds);
vtkPVRenderView::SetStreamable(inInfo, this, this->StreamingCapablePipeline);
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());
// in theory, we need ordered compositing, but we are not going to support
// parallel AMR volume rendering for now.
}
else if (request_type == vtkPVView::REQUEST_RENDER())
{
vtkAlgorithmOutput* producerPort = vtkPVRenderView::GetPieceProducer(inInfo, this);
vtkAlgorithm* producer = producerPort->GetProducer();
vtkOverlappingAMR* amr = vtkOverlappingAMR::SafeDownCast(
producer->GetOutputDataObject(producerPort->GetIndex()));
// FIXME:STREAMING - this needs to called only when the resampler hasn't
// been updated at all. Not for every render.
if (this->Resampler->NeedsInitialization())
{
vtkStreamingStatusMacro(<< this << ": cloning delivered data.");
vtkAlgorithmOutput* producerPort = vtkPVRenderView::GetPieceProducer(inInfo, this);
vtkAlgorithm* producer = producerPort->GetProducer();
vtkOverlappingAMR* amr = vtkOverlappingAMR::SafeDownCast(
producer->GetOutputDataObject(producerPort->GetIndex()));
assert (amr != NULL);
this->Resampler->UpdateResampledVolume(amr);
}
}
else if (request_type == vtkPVRenderView::REQUEST_STREAMING_UPDATE())
{
if (this->StreamingCapablePipeline)
if (this->GetStreamingCapablePipeline())
{
// this is a streaming update request. request next piece.
// This is a streaming update request, request next piece.
double view_planes[24];
inInfo->Get(vtkPVRenderView::VIEW_PLANES(), view_planes);
if (this->StreamingUpdate(view_planes))
{
vtkPVRenderView::SetNextStreamedPiece(inInfo, this, this->InputData);
// since we indeed "had" a next piece to produce, give it to the view
// so it can deliver it to the rendering nodes.
vtkPVRenderView::SetNextStreamedPiece(
inInfo, this, this->ProcessedPiece);
}
}
}
......@@ -149,7 +153,8 @@ int vtkAMRStreamingVolumeRepresentation::RequestInformation(
// 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 streamability.
// from the input pipeline which implies stream-ability.
this->StreamingCapablePipeline = false;
if (inputVector[0]->GetNumberOfInformationObjects() == 1)
{
......@@ -208,37 +213,60 @@ int vtkAMRStreamingVolumeRepresentation::RequestUpdateExtent(
}
//----------------------------------------------------------------------------
int vtkAMRStreamingVolumeRepresentation::RequestData(vtkInformation* request,
int vtkAMRStreamingVolumeRepresentation::RequestData(vtkInformation* rqst,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
vtkMath::UninitializeBounds(this->DataBounds);
if (inputVector[0]->GetNumberOfInformationObjects() == 1)
{
vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
if (inInfo->Has(vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA()) &&
vtkPVView::GetEnableStreaming() && !this->InStreamingUpdate)
this->GetStreamingCapablePipeline() &&
!this->GetInStreamingUpdate())
{
// Since the representation reexecuted, it means that the input changed
// and we should initialize our streaming.
vtkOverlappingAMR* amr = vtkOverlappingAMR::SafeDownCast(
inInfo->Get(vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA()));
this->PriorityQueue->Initialize(amr->GetAMRInfo());
}
}
if (!this->InStreamingUpdate)
if (!this->GetInStreamingUpdate())
{
this->Resampler->Reset();
}
if (inputVector[0]->GetNumberOfInformationObjects()==1)
this->ProcessedPiece = NULL;
if (inputVector[0]->GetNumberOfInformationObjects() == 1)
{
// Do the streaming independent "transformation" of the data here, in our
// case, generate the outline from the input data.
// To keep things simple here, we don't bother about the "flip-book" caching
// support used for animation playback.
vtkOverlappingAMR* input = vtkOverlappingAMR::GetData(inputVector[0], 0);
if (!this->GetInStreamingUpdate())
{
this->ProcessedData = input;
double bounds[6];
input->GetBounds(bounds);
this->DataBounds.SetBounds(bounds);
}
else
{
this->ProcessedPiece = input;
}
}
else
{
vtkOverlappingAMR* amr = vtkOverlappingAMR::GetData(inputVector[0], 0);
amr->GetBounds(this->DataBounds);
this->InputData = amr;
// create an empty dataset. This is needed so that view knows what dataset
// to expect from the other processes on this node.
this->ProcessedData = vtkSmartPointer<vtkOverlappingAMR>::New();
this->DataBounds.Reset();
}
return this->Superclass::RequestData(request, inputVector, outputVector);
return this->Superclass::RequestData(rqst, inputVector, outputVector);
}
//----------------------------------------------------------------------------
......@@ -322,8 +350,8 @@ void vtkAMRStreamingVolumeRepresentation::SetScale(double x, double y, double z)
//----------------------------------------------------------------------------
void vtkAMRStreamingVolumeRepresentation::SetVisibility(bool val)
{
this->Superclass::SetVisibility(val);
this->Actor->SetVisibility(val? 1 : 0);
this->Superclass::SetVisibility(val);
}
//***************************************************************************
......
......@@ -23,7 +23,7 @@
#include "vtkPVDataRepresentation.h"
#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
#include "vtkWeakPointer.h" // needed for vtkSmartPointer.
#include "vtkBoundingBox.h" // needed for vtkBoundingBox.
class vtkAMRStreamingPriorityQueue;
class vtkColorTransferFunction;
......@@ -128,47 +128,100 @@ protected:
// Fill input port information.
virtual int FillInputPortInformation(int port, vtkInformation* info);
virtual int RequestData(vtkInformation*,
vtkInformationVector**, vtkInformationVector*);
vtkWeakPointer<vtkOverlappingAMR> InputData;
vtkResampledAMRImageSource* Resampler;
vtkSmartVolumeMapper* VolumeMapper;
vtkVolumeProperty* Property;
vtkPVLODVolume* Actor;
double DataBounds[6];
//***************************************************************************
// For streaming support.
virtual int RequestUpdateExtent(vtkInformation* request,
// Description:
// Overridden to check if the input pipeline is streaming capable. This method
// should check if streaming is enabled i.e. vtkPVView::GetEnableStreaming()
// and the input pipeline provides necessary AMR meta-data.
virtual int RequestInformation(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
virtual int RequestInformation(vtkInformation* request,
// Description:
// Setup the block request. During StreamingUpdate, this will request the
// blocks based on priorities determined by the vtkAMRStreamingPriorityQueue,
// otherwise it doesn't make any specific request. AMR sources can treat the
// absence of specific block request to mean various things. It's expected
// that read only the root block (or a few more) in that case.
virtual int RequestUpdateExtent(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
// Description:
// Returns true if this representation has a "next piece" that it streamed.
// Process the current input for volume rendering (if anything).
// When not in StreamingUpdate, this also initializes the priority queue since
// the input AMR may have totally changed, including its structure.
virtual int RequestData(vtkInformation*,
vtkInformationVector**, vtkInformationVector*);
// Description:
// Returns true when the input pipeline supports streaming. It is set in
// RequestInformation().
vtkGetMacro(StreamingCapablePipeline, bool);
// Description:
// Returns true when StreamingUpdate() is being processed.
vtkGetMacro(InStreamingUpdate, bool);
// Description:
// Returns true if this representation has a "next piece" that it streamed.
// This method will update the PriorityQueue using the view planes specified
// and then call Update() on the representation, making it reexecute and
// regenerate the outline for the next "piece" of data.
bool StreamingUpdate(const double view_planes[24]);
// Description:
// Set to true if the input pipeline is streaming capable. Note, in
// client-server mode, this is valid only on the data-server nodes i.e. the
// nodes that have input pipelines connected to begin with.
bool StreamingCapablePipeline;
// This is the data object generated processed by the most recent call to
// RequestData() while not streaming.
// This is non-empty only on the data-server nodes.
vtkSmartPointer<vtkDataObject> ProcessedData;
// Description:
// Flag used to determine if RequestData() was called during streaming.
bool InStreamingUpdate;
// This is the data object generated processed by the most recent call to
// RequestData() while streaming.
// This is non-empty only on the data-server nodes.
vtkSmartPointer<vtkDataObject> ProcessedPiece;
// Description:
// vtkAMRStreamingPriorityQueue is a helper class we used to compute the order
// in which to request blocks from the input pipeline. Implementations can
// come up with their own rules to decide the request order based on
// application and data type.
vtkSmartPointer<vtkAMRStreamingPriorityQueue> PriorityQueue;
// Description:
// vtkImageData source used to resample an AMR dataset into a uniform grid
// suitable for volume rendering.
vtkSmartPointer<vtkResampledAMRImageSource> Resampler;
// Description:
// Rendering components.
vtkSmartPointer<vtkSmartVolumeMapper> VolumeMapper;
vtkSmartPointer<vtkVolumeProperty> Property;
vtkSmartPointer<vtkPVLODVolume> Actor;
// Description:
// Used to keep track of data bounds.
vtkBoundingBox DataBounds;
private:
vtkAMRStreamingVolumeRepresentation(const vtkAMRStreamingVolumeRepresentation&); // Not implemented
void operator=(const vtkAMRStreamingVolumeRepresentation&); // Not implemented
// Description:
// This flag is set to true if the input pipeline is streaming capable in
// RequestInformation(). Note that in client-server mode, this is valid only
// on the data-server nodes since all other nodes don't have input pipelines
// connected, they cannot indicate if the pipeline supports streaming.
bool StreamingCapablePipeline;
// Description:
// This flag is used to indicate that the representation is being updated
// during the streaming pass. RequestData() can use this flag to reset
// internal datastructures when the input changes for non-streaming reasons
// and we need to clear our streaming buffers since the streamed data is no
// longer valid.
bool InStreamingUpdate;
//ETX
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment