Commit 85a8d7b6 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

Cleaning up more code as well all collaboration synchronization.

parent 4ad9cc79
......@@ -75,14 +75,7 @@
class vtkPVRenderView::vtkInternals
{
public:
std::map<void*, int> RepToIdMap;
std::map<int, vtkDataRepresentation*> IdToRepMap;
int UniqueId;
vtkInternals()
{
this->UniqueId = 0;
}
unsigned int UniqueId;
vtkNew<vtkRepresentedDataStorage> GeometryStore;
};
......@@ -105,8 +98,6 @@ vtkPVRenderView::vtkPVRenderView()
this->Internals = new vtkInternals();
this->Internals->GeometryStore->SetView(this);
this->CounterSynchronizedSuccessfully = true;
vtkPVOptions* options = vtkProcessModule::GetProcessModule()->GetOptions();
this->RemoteRenderingAvailable = vtkPVRenderView::RemoteRenderingAllowed;
......@@ -257,7 +248,6 @@ vtkPVRenderView::~vtkPVRenderView()
this->GetNonCompositedRenderer()->SetRenderWindow(0);
this->GetRenderer()->SetRenderWindow(0);
this->SetLastSelection(NULL);
this->Selector->Delete();
this->SynchronizedRenderers->Delete();
......@@ -347,23 +337,14 @@ void vtkPVRenderView::Initialize(unsigned int id)
//----------------------------------------------------------------------------
void vtkPVRenderView::AddRepresentationInternal(vtkDataRepresentation* rep)
{
if (vtk3DWidgetRepresentation::SafeDownCast(rep) == NULL)
vtkPVDataRepresentation* dataRep = vtkPVDataRepresentation::SafeDownCast(rep);
if (dataRep != NULL)
{
// We only increase that counter when widget are not involved as in
// collaboration mode only the master has the widget in its representation
this->SynchronizationCounter++;
unsigned int id = this->Internals->UniqueId++;
this->Internals->RepToIdMap[rep] = id;
this->Internals->IdToRepMap[id] = rep;
vtkPVDataRepresentation* dataRep =
vtkPVDataRepresentation::SafeDownCast(rep);
if (dataRep)
{
this->Internals->GeometryStore->RegisterRepresentation(id, dataRep);
}
this->Internals->GeometryStore->RegisterRepresentation(id, dataRep);
}
this->Superclass::AddRepresentationInternal(rep);
......@@ -372,19 +353,10 @@ void vtkPVRenderView::AddRepresentationInternal(vtkDataRepresentation* rep)
//----------------------------------------------------------------------------
void vtkPVRenderView::RemoveRepresentationInternal(vtkDataRepresentation* rep)
{
if (this->Internals->RepToIdMap.find(rep) !=
this->Internals->RepToIdMap.end())
vtkPVDataRepresentation* dataRep = vtkPVDataRepresentation::SafeDownCast(rep);
if (dataRep != NULL)
{
int id = this->Internals->RepToIdMap[rep];
this->Internals->IdToRepMap.erase(id);
this->Internals->RepToIdMap.erase(rep);
vtkPVDataRepresentation* dataRep =
vtkPVDataRepresentation::SafeDownCast(rep);
if (dataRep)
{
this->Internals->GeometryStore->UnRegisterRepresentation(dataRep);
}
this->Internals->GeometryStore->UnRegisterRepresentation(dataRep);
// We only increase that counter when widget are not involved as in
// collaboration mode only the master has the widget in its representation
......@@ -515,10 +487,6 @@ void vtkPVRenderView::Select(int fieldAssociation, int region[4])
this->MakingSelection = true;
// since setting this->MakingSelection to true may change data-delivery needs,
// we change the update time.
this->UpdateTime.Modified();
// Make sure that the representations are up-to-date. This is required since
// due to delayed-swicth-back-from-lod, the most recent render maybe a LOD
// render (or a nonremote render) in which case we need to update the
......@@ -557,7 +525,6 @@ void vtkPVRenderView::Select(int fieldAssociation, int region[4])
}
this->MakingSelection = false;
this->UpdateTime.Modified();
}
//----------------------------------------------------------------------------
......@@ -720,9 +687,9 @@ void vtkPVRenderView::ResetCamera(double bounds[6])
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SynchronizeForCollaboration()
bool vtkPVRenderView::SynchronizeForCollaboration()
{
this->CounterSynchronizedSuccessfully = false;
bool counterSynchronizedSuccessfully = false;
// Also, can we optimize this further? This happens on every render in
// collaborative mode.
......@@ -746,7 +713,7 @@ void vtkPVRenderView::SynchronizeForCollaboration()
r_controller->Send(stream, 1, 41000);
int server_sync_counter;
r_controller->Receive(&server_sync_counter, 1, 1, 41001);
this->CounterSynchronizedSuccessfully =
counterSynchronizedSuccessfully =
(server_sync_counter == this->SynchronizationCounter);
}
else
......@@ -758,21 +725,19 @@ void vtkPVRenderView::SynchronizeForCollaboration()
int client_sync_counter;
stream >> client_sync_counter >> this->RemoteRenderingThreshold;
r_controller->Send(&this->SynchronizationCounter, 1, 1, 41001 );
this->CounterSynchronizedSuccessfully =
counterSynchronizedSuccessfully =
(client_sync_counter == this->SynchronizationCounter);
}
if (p_controller)
{
p_controller->Broadcast(&this->RemoteRenderingThreshold, 1, 0);
int temp = this->CounterSynchronizedSuccessfully? 1 : 0;
int temp = counterSynchronizedSuccessfully? 1 : 0;
p_controller->Broadcast(&temp, 1, 0);
this->CounterSynchronizedSuccessfully = (temp == 1);
counterSynchronizedSuccessfully = (temp == 1);
}
}
// Force DoDataDelivery(). That should happen every time in collaborative
// mode.
this->UpdateTime.Modified();
return counterSynchronizedSuccessfully;
}
//----------------------------------------------------------------------------
......@@ -785,7 +750,12 @@ void vtkPVRenderView::Update()
this->Superclass::Update();
// check if any representation told us that it needed ordered compositing.
// After every update we can expect the representation geometries to change.
// Thus we need to determine whether we are doing to remote-rendering or not,
// use-lod or not, etc. All these decisions are made right here to avoid
// making them during each render-call.
// Check if any representation told us that it needed ordered compositing.
this->NeedsOrderedCompositing = false;
int num_reprs = this->ReplyInformationVector->GetNumberOfInformationObjects();
for (int cc=0; cc < num_reprs; cc++)
......@@ -830,11 +800,6 @@ void vtkPVRenderView::Update()
this->InteractiveRenderProcesses = vtkPVSession::CLIENT_AND_SERVERS;
}
// UpdateTime is used to determine if we need to redeliver the geometries.
// Hence the more accurate we can be about when to update this time, the
// better. Right now, we are relying on the client (vtkSMViewProxy) to ensure
// that Update is called only when some representation is modified.
this->UpdateTime.Modified();
vtkTimerLog::MarkEndEvent("RenderView::Update");
}
......@@ -891,13 +856,6 @@ void vtkPVRenderView::InteractiveRender()
//----------------------------------------------------------------------------
void vtkPVRenderView::Render(bool interactive, bool skip_rendering)
{
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
vtkPVSession* activeSession = vtkPVSession::SafeDownCast(pm->GetActiveSession());
if (activeSession && activeSession->IsMultiClients())
{
this->SynchronizeForCollaboration();
}
bool in_tile_display_mode = this->InTileDisplayMode();
bool in_cave_mode = this->SynchronizedWindows->GetIsInCave();
if (in_cave_mode && !this->RemoteRenderingAvailable)
......@@ -956,15 +914,6 @@ void vtkPVRenderView::Render(bool interactive, bool skip_rendering)
this->UsedLODForLastRender = use_lod_rendering;
if (interactive)
{
this->InteractiveRenderTime.Modified();
}
else
{
this->StillRenderTime.Modified();
}
if (skip_rendering)
{
// essential to restore state.
......
......@@ -245,9 +245,13 @@ public:
// Description:
// vtkDataRepresentation can use this key to publish meta-data about geometry
// bounds in the vtkPVView::REQUEST_UPDATE() or vtkPVView::REQUEST_UPDATE_LOD()
// passes. If this meta-data is available, then the view can make informed
// bounds in the vtkPVView::REQUEST_UPDATE().
// If this meta-data is available, then the view can make informed
// decisions when resetting camera to the bounds of visible data.
// If no bounds are specified by a representation then the data bounds are
// used, if possible.
// Note that all process don't have to report bounds. The view takes care of
// consolidating the bounds between all views.
static vtkInformationDoubleVectorKey* GEOMETRY_BOUNDS();
// Description:
......@@ -491,6 +495,9 @@ public:
// false
bool GetUseOrderedCompositing();
// Description:
// Synchronizes core ivars for multi-client setups.
bool SynchronizeForCollaboration();
//BTX
protected:
......@@ -546,10 +553,6 @@ protected:
// displaying an image in a viewport.
bool GetLocalProcessDoesRendering(bool using_distributed_rendering);
// Description:
// Synchronizes core ivars for multi-client setups.
virtual void SynchronizeForCollaboration();
vtkLight* Light;
vtkLightKit* LightKit;
vtkRenderViewBase* RenderView;
......@@ -577,7 +580,6 @@ protected:
// Used in collaboration mode to ensure that views are in the same state
// (as far as representations added/removed goes) before rendering.
int SynchronizationCounter;
bool CounterSynchronizedSuccessfully;
// In mega-bytes.
double RemoteRenderingThreshold;
......@@ -600,10 +602,6 @@ protected:
static bool RemoteRenderingAllowed;
vtkTimeStamp UpdateTime;
vtkTimeStamp StillRenderTime;
vtkTimeStamp InteractiveRenderTime;
vtkTypeUInt32 StillRenderProcesses;
vtkTypeUInt32 InteractiveRenderProcesses;
......
......@@ -23,7 +23,9 @@
#include "vtkObjectFactory.h"
#include "vtkOrderedCompositeDistributor.h"
#include "vtkPKdTree.h"
#include "vtkProcessModule.h"
#include "vtkPVRenderView.h"
#include "vtkPVSession.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkTimerLog.h"
......@@ -55,7 +57,7 @@ unsigned long vtkRepresentedDataStorage::GetVisibleDataSize(bool low_res)
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::RegisterRepresentation(
int id, vtkPVDataRepresentation* repr)
unsigned int id, vtkPVDataRepresentation* repr)
{
this->Internals->RepresentationToIdMap[repr] = id;
......@@ -145,7 +147,7 @@ vtkAlgorithmOutput* vtkRepresentedDataStorage::GetProducer(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::SetPiece(int id, vtkDataObject* data, bool
void vtkRepresentedDataStorage::SetPiece(unsigned int id, vtkDataObject* data, bool
low_res)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(id, low_res);
......@@ -161,7 +163,7 @@ void vtkRepresentedDataStorage::SetPiece(int id, vtkDataObject* data, bool
//----------------------------------------------------------------------------
vtkAlgorithmOutput* vtkRepresentedDataStorage::GetProducer(
int id, bool low_res)
unsigned int id, bool low_res)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(id, low_res);
if (!item)
......@@ -176,7 +178,7 @@ vtkAlgorithmOutput* vtkRepresentedDataStorage::GetProducer(
//----------------------------------------------------------------------------
bool vtkRepresentedDataStorage::NeedsDelivery(
unsigned long timestamp,
std::vector<int> &keys_to_deliver, bool use_low)
std::vector<unsigned int> &keys_to_deliver, bool use_low)
{
vtkInternals::ItemsMapType::iterator iter;
for (iter = this->Internals->ItemsMap.begin();
......@@ -194,9 +196,19 @@ bool vtkRepresentedDataStorage::NeedsDelivery(
}
//----------------------------------------------------------------------------
void vtkRepresentedDataStorage::Deliver(int use_lod, unsigned int size, int *values)
void vtkRepresentedDataStorage::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())
{
return;
}
}
// This method gets called on all processes with the list of representations
// to "deliver". We check with the view what mode we're operating in and
// decide where the data needs to be delivered.
......
......@@ -49,7 +49,7 @@ public:
// makes it possible for representations to communicate with the storage
// directly using a self pointer, while enables views on different processes
// to communicate information about representations using their unique ids.
void RegisterRepresentation(int id, vtkPVDataRepresentation*);
void RegisterRepresentation(unsigned int id, vtkPVDataRepresentation*);
void UnRegisterRepresentation(vtkPVDataRepresentation*);
// Description:
......@@ -57,14 +57,14 @@ public:
vtkAlgorithmOutput* GetProducer(vtkPVDataRepresentation*, bool low_res);
void SetDeliverToAllProcesses(vtkPVDataRepresentation*, bool flag, bool low_res);
void SetPiece(int, vtkDataObject* data, bool low_res);
vtkAlgorithmOutput* GetProducer(int, bool low_res);
void SetPiece(unsigned int, vtkDataObject* data, bool low_res);
vtkAlgorithmOutput* GetProducer(unsigned int, bool low_res);
// Description:
// Returns the size for all visible geometry.
unsigned long GetVisibleDataSize(bool low_res);
void Deliver(int use_low_res, unsigned int size, int *keys);
void Deliver(int use_low_res, unsigned int size, unsigned int *keys);
void SetView(vtkPVRenderView*);
......@@ -77,7 +77,7 @@ public:
//BTX
bool NeedsDelivery(unsigned long timestamp,
std::vector<int>& keys_to_deliver, bool use_low_res);
std::vector<unsigned int>& keys_to_deliver, bool use_low_res);
protected:
vtkRepresentedDataStorage();
......
......@@ -79,9 +79,9 @@ public:
}
};
typedef std::map<int, std::pair<vtkItem, vtkItem> > ItemsMapType;
typedef std::map<unsigned int, std::pair<vtkItem, vtkItem> > ItemsMapType;
vtkItem* GetItem(int index, bool use_second)
vtkItem* GetItem(unsigned int index, bool use_second)
{
if (this->ItemsMap.find(index) != this->ItemsMap.end())
{
......@@ -97,7 +97,7 @@ public:
this->RepresentationToIdMap.find(repr);
if (iter != this->RepresentationToIdMap.end())
{
int index = iter->second;
unsigned int index = iter->second;
return use_second? &(this->ItemsMap[index].second) :
&(this->ItemsMap[index].first);
}
......@@ -123,7 +123,7 @@ public:
return size;
}
typedef std::map<vtkPVDataRepresentation*, int>
typedef std::map<vtkPVDataRepresentation*, unsigned int>
RepresentationToIdMapType;
RepresentationToIdMapType RepresentationToIdMap;
......
......@@ -95,7 +95,7 @@ void vtkSMDataDeliveryManager::Deliver(bool interactive)
vtkTimeStamp& timeStamp = use_lod?
this->LODGeometryDeliveryStamp : this->GeometryDeliveryStamp;
std::vector<int> keys_to_deliver;
std::vector<unsigned int> keys_to_deliver;
......
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