Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit a8100e8b authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Cleaning up View/Representation API.

Adding a new key, VIEW(), to the ProcessViewRequest() call to make it easier for
representations to access the view that is calling the passes.
parent 488ffef9
......@@ -58,6 +58,9 @@ SET (Kit_SRCS
vtkPVDataInformation.cxx
vtkPVDataRepresentation.cxx
vtkPVDataRepresentationPipeline.cxx
vtkProcessModuleAutoMPI.cxx
vtkProcessModule.cxx
vtkPVDataDeliveryManager.cxx
vtkPVDataSetAttributesInformation.cxx
vtkPVDataSizeInformation.cxx
vtkPVDisplayInformation.cxx
......@@ -77,24 +80,24 @@ SET (Kit_SRCS
vtkPVOptionsXMLParser.cxx
vtkPVParallelCoordinatesChartView.cxx
vtkPVParallelCoordinatesRepresentation.cxx
vtkPVPlotMatrixView.cxx
vtkPVPlotMatrixRepresentation.cxx
vtkPVPlotMatrixView.cxx
vtkPVPlugin.cxx
vtkPVPluginLoader.cxx
vtkPVPluginTracker.cxx
vtkPVPluginsInformation.cxx
vtkPVPluginTracker.cxx
vtkPVProgressHandler.cxx
vtkPVPythonModule.cxx
vtkPVPythonPluginInterface.cxx
vtkPVRenderView.cxx
vtkPVRepresentedDataInformation.cxx
vtkPVSILInformation.cxx
vtkPVSingleOutputExtractSelection.cxx
vtkPVSelectionInformation.cxx
vtkPVServerInformation.cxx
vtkPVServerManagerPluginInterface.cxx
vtkPVServerOptions.cxx
vtkPVSession.cxx
vtkPVSILInformation.cxx
vtkPVSingleOutputExtractSelection.cxx
vtkPVSynchronizedRenderer.cxx
vtkPVSynchronizedRenderWindows.cxx
vtkPVSystemInformation.cxx
......@@ -102,9 +105,6 @@ SET (Kit_SRCS
vtkPVTimerInformation.cxx
vtkPVView.cxx
vtkPVXYChartView.cxx
vtkProcessModule.cxx
vtkProcessModuleAutoMPI.cxx
vtkRepresentedDataStorage.cxx
vtkSelectionDeliveryFilter.cxx
vtkSelectionRepresentation.cxx
vtkSession.cxx
......
......@@ -196,23 +196,36 @@ int vtkGeometryRepresentation::ProcessViewRequest(
{
// provide the "geometry" to the view so the view can delivery it to the
// rendering nodes as and when needed.
// When this process doesn't have any valid input, the cache-keeper is setup
// to provide a place-holder dataset of the right type.
vtkPVRenderView::SetPiece(
inInfo, this, this->CacheKeeper->GetOutputDataObject(0));
// to provide a place-holder dataset of the right type. This is essential
// since the vtkPVRenderView uses the type specified to decide on the
// delivery mechanism, among other things.
vtkPVRenderView::SetPiece(inInfo, this,
this->CacheKeeper->GetOutputDataObject(0));
// Since we are rendering polydata, it can be redistributed when ordered
// compositing is needed. So let the view know that it can feel free to
// redistribute data as and when needed.
vtkPVRenderView::MarkAsRedistributable(inInfo, this);
// Tell the view if this representation needs ordered compositing. We need
// ordered compositing when rendering translucent geometry.
if (this->Actor->GetProperty()->GetOpacity() < 1.0)
{
// We need to extend this condition to consider translucent LUTs once we
// start supporting them,
outInfo->Set(vtkPVRenderView::NEED_ORDERED_COMPOSITING(), 1);
}
// Set the data-bounds.
//double bounds[6];
// Finally, let the view know about the geometry bounds. The view uses this
// information for resetting camera and clip planes. Since this
// representation allows users to transform the geometry, we need to ensure
// that the bounds we report include the transformation as well.
vtkNew<vtkMatrix4x4> matrix;
this->Actor->GetMatrix(matrix.GetPointer());
vtkPVRenderView::SetGeometryBounds(
inInfo, this->DataBounds, matrix.GetPointer());
vtkPVRenderView::SetGeometryBounds(inInfo, this->DataBounds,
matrix.GetPointer());
}
else if (request_type == vtkPVView::REQUEST_UPDATE_LOD())
{
......@@ -229,6 +242,9 @@ int vtkGeometryRepresentation::ProcessViewRequest(
}
this->Decimator->Update();
// Pass along the LOD geometry to the view so that it can deliver it to
// the rendering node as and when needed.
vtkPVRenderView::SetPieceLOD(inInfo, this,
this->Decimator->GetOutputDataObject(0));
}
......
......@@ -12,13 +12,15 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkRepresentedDataStorage.h"
#include "vtkRepresentedDataStorageInternals.h"
#include "vtkPVDataDeliveryManager.h"
#include "vtkAlgorithmOutput.h"
#include "vtkAMRBox.h"
#include "vtkAMRVolumeRepresentation.h"
#include "vtkBSPCutsGenerator.h"
#include "vtkCamera.h"
#include "vtkDataObject.h"
#include "vtkMath.h"
#include "vtkMPIMoveData.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkMultiProcessController.h"
......@@ -29,19 +31,156 @@
#include "vtkPKdTree.h"
#include "vtkPointData.h"
#include "vtkProcessModule.h"
#include "vtkPVDataRepresentation.h"
#include "vtkPVDataRepresentationPipeline.h"
#include "vtkPVRenderView.h"
#include "vtkPVSession.h"
#include "vtkPVTrivialProducer.h"
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkTimerLog.h"
#include "vtkUniformGridAMRDataIterator.h"
#include "vtkUniformGrid.h"
#include "vtkUnsignedIntArray.h"
#include "vtkAMRBox.h"
#include "vtkMath.h"
#include "vtkWeakPointer.h"
#include <assert.h>
#include <map>
#include <queue>
#include <utility>
//*****************************************************************************
class vtkPVDataDeliveryManager::vtkInternals
{
public:
class vtkPriorityQueueItem
{
public:
unsigned int RepresentationId;
unsigned int BlockId;
unsigned int Level;
unsigned int Index;
double Priority;
vtkPriorityQueueItem() :
RepresentationId(0), BlockId(0),
Level(0), Index(0), Priority(0)
{
}
bool operator < (const vtkPriorityQueueItem& other) const
{
return this->Priority < other.Priority;
}
};
typedef std::priority_queue<vtkPriorityQueueItem> PriorityQueueType;
PriorityQueueType PriorityQueue;
class vtkItem
{
vtkSmartPointer<vtkPVTrivialProducer> Producer;
vtkWeakPointer<vtkDataObject> DataObject;
unsigned long TimeStamp;
unsigned long ActualMemorySize;
public:
vtkWeakPointer<vtkPVDataRepresentation> Representation;
bool AlwaysClone;
bool Redistributable;
bool Streamable;
vtkItem() :
Producer(vtkSmartPointer<vtkPVTrivialProducer>::New()),
TimeStamp(0),
ActualMemorySize(0),
AlwaysClone(false),
Redistributable(false),
Streamable(false)
{ }
void SetDataObject(vtkDataObject* data)
{
this->DataObject = data;
this->Producer->SetOutput(data);
// the vtkTrivialProducer's MTime is is changed whenever the data itself
// changes or the data's mtime changes and hence we get a good indication
// of when we have a new piece for real.
this->TimeStamp = this->Producer->GetMTime();
this->ActualMemorySize = data? data->GetActualMemorySize() : 0;
}
vtkPVTrivialProducer* GetProducer() const
{ return this->Producer.GetPointer(); }
vtkDataObject* GetDataObject() const
{ return this->DataObject.GetPointer(); }
unsigned long GetTimeStamp() const
{ return this->TimeStamp; }
void SetTimeStamp(unsigned long ts)
{ this->TimeStamp = ts; }
unsigned long GetVisibleDataSize()
{
if (this->Representation && this->Representation->GetVisibility())
{
return this->ActualMemorySize;
}
return 0;
}
};
typedef std::map<unsigned int, std::pair<vtkItem, vtkItem> > ItemsMapType;
vtkItem* GetItem(unsigned int index, bool use_second)
{
if (this->ItemsMap.find(index) != this->ItemsMap.end())
{
return use_second? &(this->ItemsMap[index].second) :
&(this->ItemsMap[index].first);
}
return NULL;
}
vtkItem* GetItem(vtkPVDataRepresentation* repr, bool use_second)
{
RepresentationToIdMapType::iterator iter =
this->RepresentationToIdMap.find(repr);
if (iter != this->RepresentationToIdMap.end())
{
unsigned int index = iter->second;
return use_second? &(this->ItemsMap[index].second) :
&(this->ItemsMap[index].first);
}
return NULL;
}
unsigned long GetVisibleDataSize(bool use_second_if_available)
{
unsigned long size = 0;
ItemsMapType::iterator iter;
for (iter = this->ItemsMap.begin(); iter != this->ItemsMap.end(); ++iter)
{
if (use_second_if_available && iter->second.second.GetDataObject())
{
size += iter->second.second.GetVisibleDataSize();
}
else
{
size += iter->second.first.GetVisibleDataSize();
}
}
return size;
}
typedef std::map<vtkPVDataRepresentation*, unsigned int>
RepresentationToIdMapType;
RepresentationToIdMapType RepresentationToIdMap;
ItemsMapType ItemsMap;
};
//*****************************************************************************
namespace
{
// this code is stolen from vtkFrustumCoverageCuller.
......@@ -137,40 +276,42 @@ namespace
}
};
vtkStandardNewMacro(vtkRepresentedDataStorage);
//*****************************************************************************
vtkStandardNewMacro(vtkPVDataDeliveryManager);
//----------------------------------------------------------------------------
vtkRepresentedDataStorage::vtkRepresentedDataStorage()
vtkPVDataDeliveryManager::vtkPVDataDeliveryManager()
: Internals(new vtkInternals())
{
}
//----------------------------------------------------------------------------
vtkRepresentedDataStorage::~vtkRepresentedDataStorage()
vtkPVDataDeliveryManager::~vtkPVDataDeliveryManager()
{
delete this->Internals;
this->Internals = 0;
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::SetView(vtkPVRenderView* view)
void vtkPVDataDeliveryManager::SetRenderView(vtkPVRenderView* view)
{
this->View = view;
this->RenderView = view;
}
//----------------------------------------------------------------------------
vtkPVRenderView* vtkRepresentedDataStorage::GetView()
vtkPVRenderView* vtkPVDataDeliveryManager::GetRenderView()
{
return this->View;
return this->RenderView;
}
//----------------------------------------------------------------------------
unsigned long vtkRepresentedDataStorage::GetVisibleDataSize(bool low_res)
unsigned long vtkPVDataDeliveryManager::GetVisibleDataSize(bool low_res)
{
return this->Internals->GetVisibleDataSize(low_res);
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::RegisterRepresentation(
void vtkPVDataDeliveryManager::RegisterRepresentation(
unsigned int id, vtkPVDataRepresentation* repr)
{
this->Internals->RepresentationToIdMap[repr] = id;
......@@ -185,7 +326,7 @@ void vtkRepresentedDataStorage::RegisterRepresentation(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::UnRegisterRepresentation(
void vtkPVDataDeliveryManager::UnRegisterRepresentation(
vtkPVDataRepresentation* repr)
{
vtkInternals::RepresentationToIdMapType::iterator iter =
......@@ -200,7 +341,7 @@ void vtkRepresentedDataStorage::UnRegisterRepresentation(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::SetDeliverToAllProcesses(
void vtkPVDataDeliveryManager::SetDeliverToAllProcesses(
vtkPVDataRepresentation* repr, bool mode, bool low_res)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(repr, low_res);
......@@ -215,7 +356,7 @@ void vtkRepresentedDataStorage::SetDeliverToAllProcesses(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::MarkAsRedistributable(
void vtkPVDataDeliveryManager::MarkAsRedistributable(
vtkPVDataRepresentation* repr)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(repr, false);
......@@ -232,7 +373,7 @@ void vtkRepresentedDataStorage::MarkAsRedistributable(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::SetStreamable(
void vtkPVDataDeliveryManager::SetStreamable(
vtkPVDataRepresentation* repr, bool val)
{
if (!repr->IsA("vtkAMRVolumeRepresentation") && val == true)
......@@ -256,13 +397,18 @@ void vtkRepresentedDataStorage::SetStreamable(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::SetPiece(
void vtkPVDataDeliveryManager::SetPiece(
vtkPVDataRepresentation* repr, vtkDataObject* data, bool low_res)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(repr, low_res);
if (item)
{
item->SetDataObject(data);
vtkPVDataRepresentationPipeline* executive =
vtkPVDataRepresentationPipeline::SafeDownCast(repr->GetExecutive());
if (executive && executive->GetDataTime() > item->GetTimeStamp())
{
item->SetDataObject(data);
}
}
else
{
......@@ -271,7 +417,7 @@ void vtkRepresentedDataStorage::SetPiece(
}
//----------------------------------------------------------------------------
vtkAlgorithmOutput* vtkRepresentedDataStorage::GetProducer(
vtkAlgorithmOutput* vtkPVDataDeliveryManager::GetProducer(
vtkPVDataRepresentation* repr, bool low_res)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(repr, low_res);
......@@ -285,7 +431,7 @@ vtkAlgorithmOutput* vtkRepresentedDataStorage::GetProducer(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::SetPiece(unsigned int id, vtkDataObject* data, bool
void vtkPVDataDeliveryManager::SetPiece(unsigned int id, vtkDataObject* data, bool
low_res)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(id, low_res);
......@@ -300,7 +446,7 @@ void vtkRepresentedDataStorage::SetPiece(unsigned int id, vtkDataObject* data, b
}
//----------------------------------------------------------------------------
vtkAlgorithmOutput* vtkRepresentedDataStorage::GetProducer(
vtkAlgorithmOutput* vtkPVDataDeliveryManager::GetProducer(
unsigned int id, bool low_res)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(id, low_res);
......@@ -314,7 +460,7 @@ vtkAlgorithmOutput* vtkRepresentedDataStorage::GetProducer(
}
//----------------------------------------------------------------------------
bool vtkRepresentedDataStorage::NeedsDelivery(
bool vtkPVDataDeliveryManager::NeedsDelivery(
unsigned long timestamp,
std::vector<unsigned int> &keys_to_deliver, bool use_low)
{
......@@ -334,14 +480,14 @@ bool vtkRepresentedDataStorage::NeedsDelivery(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::Deliver(int use_lod, unsigned int size, unsigned int *values)
void vtkPVDataDeliveryManager::Deliver(int use_lod, unsigned int size, unsigned int *values)
{
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
vtkPVSession* activeSession = vtkPVSession::SafeDownCast(pm->GetActiveSession());
if (activeSession && activeSession->IsMultiClients())
{
if (!this->View->SynchronizeForCollaboration())
if (!this->RenderView->SynchronizeForCollaboration())
{
return;
}
......@@ -363,9 +509,9 @@ void vtkRepresentedDataStorage::Deliver(int use_lod, unsigned int size, unsigned
"LowRes Data Migration" : "FullRes Data Migration");
bool using_remote_rendering =
use_lod? this->View->GetUseDistributedRenderingForInteractiveRender() :
this->View->GetUseDistributedRenderingForStillRender();
int mode = this->View->GetDataDistributionMode(using_remote_rendering);
use_lod? this->RenderView->GetUseDistributedRenderingForInteractiveRender() :
this->RenderView->GetUseDistributedRenderingForStillRender();
int mode = this->RenderView->GetDataDistributionMode(using_remote_rendering);
for (unsigned int cc=0; cc < size; cc++)
......@@ -400,7 +546,7 @@ void vtkRepresentedDataStorage::Deliver(int use_lod, unsigned int size, unsigned
// There's a possibility that we'd need to do ordered compositing.
// Ask the view if we need to redistribute the data for ordered compositing.
bool use_ordered_compositing = using_remote_rendering &&
this->View->GetUseOrderedCompositing();
this->RenderView->GetUseOrderedCompositing();
if (use_ordered_compositing && !use_lod)
{
......@@ -468,13 +614,13 @@ void vtkRepresentedDataStorage::Deliver(int use_lod, unsigned int size, unsigned
}
//----------------------------------------------------------------------------
vtkPKdTree* vtkRepresentedDataStorage::GetKdTree()
vtkPKdTree* vtkPVDataDeliveryManager::GetKdTree()
{
return this->KdTree;
}
//----------------------------------------------------------------------------
bool vtkRepresentedDataStorage::BuildPriorityQueue(double planes[24])
bool vtkPVDataDeliveryManager::BuildPriorityQueue(double planes[24])
{
cout << "BuildPriorityQueue" << endl;
// just find the first visible AMR dataset and build priority queue for that
......@@ -511,7 +657,7 @@ bool vtkRepresentedDataStorage::BuildPriorityQueue(double planes[24])
// now build a priority queue for absent blocks using the current camera.
//double planes[24];
//vtkRenderer* ren = this->View->GetRenderer();
//vtkRenderer* ren = this->RenderView->GetRenderer();
//ren->GetActiveCamera()->GetFrustumPlanes(
// ren->GetTiledAspectRatio(), planes);
......@@ -556,7 +702,7 @@ bool vtkRepresentedDataStorage::BuildPriorityQueue(double planes[24])
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::StreamingDeliver(unsigned int key)
void vtkPVDataDeliveryManager::StreamingDeliver(unsigned int key)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(key, false);
vtkOverlappingAMR* oamr = vtkOverlappingAMR::SafeDownCast(item->GetDataObject());
......@@ -609,7 +755,7 @@ void vtkRepresentedDataStorage::StreamingDeliver(unsigned int key)
vtkAMRVolumeRepresentation* repr = vtkAMRVolumeRepresentation::SafeDownCast(
item->Representation);
repr->SetStreamingBlockId(qitem.BlockId);
this->View->StreamingUpdate();
this->RenderView->StreamingUpdate();
repr->ResetStreamingBlockId();
oamr = vtkOverlappingAMR::SafeDownCast(item->GetDataObject());
......@@ -652,7 +798,7 @@ void vtkRepresentedDataStorage::StreamingDeliver(unsigned int key)
}
//----------------------------------------------------------------------------
unsigned int vtkRepresentedDataStorage::GetRepresentationIdFromQueue()
unsigned int vtkPVDataDeliveryManager::GetRepresentationIdFromQueue()
{
if (!this->Internals->PriorityQueue.empty())
{
......@@ -663,7 +809,7 @@ unsigned int vtkRepresentedDataStorage::GetRepresentationIdFromQueue()
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::PrintSelf(ostream& os, vtkIndent indent)
void vtkPVDataDeliveryManager::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
......@@ -12,20 +12,21 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkRepresentedDataStorage
// .NAME vtkPVDataDeliveryManager - manager for data-delivery.
// .SECTION Description
// vtkRepresentedDataStorage is used by views and representations in ParaView to
// manage datasets that are "represented" by the representations. Typically
// representations use data-store instead of directly use the data from its
// input to ensure that data delivery mechanisms can provide data to the
// processes that need it.
// vtkPVDataDeliveryManager manages geometry delivering for rendering. It is
// used by vtkPVRenderView to manage the delivery of geometry to the nodes where
// rendering is happening. This class helps us consolidate all the code for
// delivering different types of geometries to all the nodes involved as well we
// a managing idiosyncrasies like requiring delivering to all nodes,
// redistributing for ordered compositing, etc.
#ifndef __vtkRepresentedDataStorage_h
#define __vtkRepresentedDataStorage_h
#ifndef __vtkPVDataDeliveryManager_h
#define __vtkPVDataDeliveryManager_h
#include "vtkObject.h"
#include "vtkWeakPointer.h"
#include "vtkSmartPointer.h"
#include "vtkSmartPointer.h" // needed for iVar.
#include "vtkWeakPointer.h" // needed for iVar.
class vtkAlgorithmOutput;
class vtkDataObject;
......@@ -37,11 +38,11 @@ class vtkPKdTree;
#include <vector>
//ETX
class VTK_EXPORT vtkRepresentedDataStorage : public vtkObject
class VTK_EXPORT vtkPVDataDeliveryManager : public vtkObject
{
public:
static vtkRepresentedDataStorage* New();
vtkTypeMacro(vtkRepresentedDataStorage, vtkObject);
static vtkPVDataDeliveryManager* New();
vtkTypeMacro(vtkPVDataDeliveryManager, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......@@ -53,55 +54,98 @@ public:
void UnRegisterRepresentation(vtkPVDataRepresentation*);
// Description:
void SetPiece(vtkPVDataRepresentation*, vtkDataObject* data, bool low_res);
// Representations (indirectly via vtkPVRenderView::SetPiece()) call this
// method to register the geometry type they are rendering. Every
// representation that requires delivering of any geometry must register with
// the vtkPVDataDeliveryManager and never manage the delivery on its own.
void SetPiece(vtkPVDataRepresentation* repr, vtkDataObject* data, bool low_res);
void SetPiece(unsigned int repr_id, vtkDataObject* data, bool low_res);
// Description:
// Provides access to the producer port for the geometry of a registered
// representation. Representations use these methods (indirectly via
// vtkPVRenderView::GetPieceProducer() and GetPieceProducerLOD()) to obtain
// the geometry producer for the geometry to be rendered.
vtkAlgorithmOutput* GetProducer(vtkPVDataRepresentation*, bool low_res);
vtkAlgorithmOutput* GetProducer(unsigned int, bool low_res);
// Description:
// By default, this class only delivers geometries to nodes that are doing the
// rendering at a given stage. However, certain representations, such as
// data-label representation, or cube-axes representation, need to the
// geometry to be delivered to all nodes always. That can be done by using
// this method (via vtkPVRenderView::SetDeliverToAllProcesses()).
void SetDeliverToAllProcesses(vtkPVDataRepresentation*, bool flag, bool low_res);
void SetPiece(unsigned int, vtkDataObject* data, bool low_res);
vtkAlgorithmOutput* GetProducer(unsigned int, bool low_res);
// Description:
// Under certain cases, e.g. when remote rendering in parallel with
// translucent geometry, the geometry may need to be redistributed to ensure
// ordered compositing can be employed correctly. Marking geometry provided by
// a representation as redistributable makes it possible for this class to
// redistribute the geometry as needed. Only vtkPolyData, vtkUnstructuredGrid
// or a multi-block comprising of vtkPolyData is currently supported.
void MarkAsRedistributable(vtkPVDataRepresentation*);
// Description: