Commit 5eedecb2 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Make redistribution mode customizible.

We have come across representations that need different ways of handling
boundary cells when data is redistributed for ordered compositing.
Now a new API on vtkPVRenderView can be used by representation to mark
its data to be handle boundary cells differently. Default is still to
split the cells. A representation can choose to have those cells
duplicated or assigned to a unique region instead.
parent 5463c19c
......@@ -131,6 +131,7 @@ public:
bool GatherBeforeDeliveringToClient;
bool Redistributable;
bool Streamable;
int RedistributionMode;
vtkItem()
: Producer(vtkSmartPointer<vtkPVTrivialProducer>::New())
......@@ -141,6 +142,7 @@ public:
, GatherBeforeDeliveringToClient(false)
, Redistributable(false)
, Streamable(false)
, RedistributionMode(vtkOrderedCompositeDistributor::SPLIT_BOUNDARY_CELLS)
{
}
......@@ -388,6 +390,38 @@ void vtkPVDataDeliveryManager::MarkAsRedistributable(
}
}
//----------------------------------------------------------------------------
void vtkPVDataDeliveryManager::SetRedistributionMode(
vtkPVDataRepresentation* repr, int mode, int port)
{
vtkInternals::vtkItem* item = this->Internals->GetItem(repr, false, port, true);
vtkInternals::vtkItem* low_item = this->Internals->GetItem(repr, true, port, true);
if (item)
{
item->RedistributionMode = mode;
low_item->RedistributionMode = mode;
}
else
{
vtkErrorMacro("Invalid argument.");
}
}
//----------------------------------------------------------------------------
void vtkPVDataDeliveryManager::SetRedistributionModeToSplitBoundaryCells(
vtkPVDataRepresentation* repr, int port)
{
this->SetRedistributionMode(repr, vtkOrderedCompositeDistributor::SPLIT_BOUNDARY_CELLS, port);
}
//----------------------------------------------------------------------------
void vtkPVDataDeliveryManager::SetRedistributionModeToDuplicateBoundaryCells(
vtkPVDataRepresentation* repr, int port)
{
this->SetRedistributionMode(
repr, vtkOrderedCompositeDistributor::ASSIGN_TO_ALL_INTERSECTING_REGIONS, port);
}
//----------------------------------------------------------------------------
void vtkPVDataDeliveryManager::SetStreamable(vtkPVDataRepresentation* repr, bool val, int port)
{
......@@ -680,6 +714,7 @@ void vtkPVDataDeliveryManager::RedistributeDataForOrderedCompositing(bool use_lo
redistributor->SetInputData(item.GetDeliveredDataObject());
redistributor->SetPKdTree(this->KdTree);
redistributor->SetPassThrough(0);
redistributor->SetBoundaryMode(item.RedistributionMode);
redistributor->Update();
item.SetRedistributedDataObject(redistributor->GetOutputDataObject(0));
}
......
......@@ -121,6 +121,20 @@ public:
*/
void MarkAsRedistributable(vtkPVDataRepresentation*, bool value = true, int port = 0);
//@{
/**
* For representations that have indicated that the data is redistributable
* (using MarkAsRedistributable), this control the mode for redistribution.
* Specifically, it indicates how to handle cells that are on the boundary of
* the redistribution KdTree. Default is to split the cells, one can change it
* to duplicate cells instead by using mode as
* `vtkDistributedDataFilter::ASSIGN_TO_ALL_INTERSECTING_REGIONS`.
*/
void SetRedistributionMode(vtkPVDataRepresentation*, int mode, int port = 0);
void SetRedistributionModeToSplitBoundaryCells(vtkPVDataRepresentation* repr, int port = 0);
void SetRedistributionModeToDuplicateBoundaryCells(vtkPVDataRepresentation* repr, int port = 0);
//@}
/**
* Returns the size for all visible geometry. If low_res is true, and low-res
* data is not available for a particular representation, then it's high-res
......
......@@ -1676,6 +1676,48 @@ void vtkPVRenderView::MarkAsRedistributable(
view->GetDeliveryManager()->MarkAsRedistributable(repr, value, port);
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SetRedistributionMode(
vtkInformation* info, vtkPVDataRepresentation* repr, int mode, int port)
{
vtkPVRenderView* view = vtkPVRenderView::SafeDownCast(info->Get(VIEW()));
if (!view)
{
vtkGenericWarningMacro("Missing VIEW().");
return;
}
view->GetDeliveryManager()->SetRedistributionMode(repr, mode, port);
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SetRedistributionModeToSplitBoundaryCells(
vtkInformation* info, vtkPVDataRepresentation* repr, int port)
{
vtkPVRenderView* view = vtkPVRenderView::SafeDownCast(info->Get(VIEW()));
if (!view)
{
vtkGenericWarningMacro("Missing VIEW().");
return;
}
view->GetDeliveryManager()->SetRedistributionModeToSplitBoundaryCells(repr, port);
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SetRedistributionModeToDuplicateBoundaryCells(
vtkInformation* info, vtkPVDataRepresentation* repr, int port)
{
vtkPVRenderView* view = vtkPVRenderView::SafeDownCast(info->Get(VIEW()));
if (!view)
{
vtkGenericWarningMacro("Missing VIEW().");
return;
}
view->GetDeliveryManager()->SetRedistributionModeToDuplicateBoundaryCells(repr, port);
}
//----------------------------------------------------------------------------
void vtkPVRenderView::SetStreamable(vtkInformation* info, vtkPVDataRepresentation* repr, bool val)
{
......
......@@ -454,6 +454,12 @@ public:
vtkInformation* info, vtkPVDataRepresentation* repr, int port = 0);
static void MarkAsRedistributable(
vtkInformation* info, vtkPVDataRepresentation* repr, bool value = true, int port = 0);
static void SetRedistributionMode(
vtkInformation* info, vtkPVDataRepresentation* repr, int mode, int port = 0);
static void SetRedistributionModeToSplitBoundaryCells(
vtkInformation* info, vtkPVDataRepresentation* repr, int port = 0);
static void SetRedistributionModeToDuplicateBoundaryCells(
vtkInformation* info, vtkPVDataRepresentation* repr, int port = 0);
static void SetGeometryBounds(
vtkInformation* info, double bounds[6], vtkMatrix4x4* transform = NULL);
static void SetStreamable(vtkInformation* info, vtkPVDataRepresentation* repr, bool streamable);
......
......@@ -63,6 +63,7 @@ vtkCxxSetObjectMacro(vtkOrderedCompositeDistributor, Controller, vtkMultiProcess
//-----------------------------------------------------------------------------
vtkOrderedCompositeDistributor::vtkOrderedCompositeDistributor()
{
this->BoundaryMode = SPLIT_BOUNDARY_CELLS;
this->PKdTree = NULL;
this->Controller = NULL;
this->PassThrough = false;
......@@ -82,6 +83,7 @@ vtkOrderedCompositeDistributor::~vtkOrderedCompositeDistributor()
void vtkOrderedCompositeDistributor::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "BoundaryMode: " << this->BoundaryMode << endl;
os << indent << "PKdTree: " << this->PKdTree << endl;
os << indent << "Controller: " << this->Controller << endl;
os << indent << "PassThrough: " << this->PassThrough << endl;
......@@ -200,8 +202,18 @@ int vtkOrderedCompositeDistributor::RequestData(vtkInformation* vtkNotUsed(reque
cbc->SetClientData(this);
cbc->SetCallback(D3UpdateProgress);
d3->AddObserver(vtkCommand::ProgressEvent, cbc.GetPointer());
d3->SetBoundaryModeToSplitBoundaryCells();
switch (this->BoundaryMode)
{
case SPLIT_BOUNDARY_CELLS:
d3->SetBoundaryModeToSplitBoundaryCells();
break;
case ASSIGN_TO_ONE_REGION:
d3->SetBoundaryModeToAssignToOneRegion();
break;
case ASSIGN_TO_ALL_INTERSECTING_REGIONS:
d3->SetBoundaryModeToAssignToAllIntersectingRegions();
break;
}
d3->SetInputData(input);
d3->SetCuts(cuts);
......
......@@ -92,10 +92,32 @@ public:
vtkGetStringMacro(OutputType);
//@}
/**
* Boundary mode values. Note, the deliberately match
* vtkDistributedDataFilter. However we can't include vtkDistributedDataFilter
* here here it's not available in non-MPI builds.
*/
enum BoundaryModes
{
ASSIGN_TO_ONE_REGION = 0,
ASSIGN_TO_ALL_INTERSECTING_REGIONS = 1,
SPLIT_BOUNDARY_CELLS = 2
};
//@{
/**
* Get/Set the mode to use to handle cells on the boundary of the KdTree.
* Default is SPLIT_BOUNDARY_CELLS.
*/
vtkSetClampMacro(BoundaryMode, int, ASSIGN_TO_ONE_REGION, SPLIT_BOUNDARY_CELLS);
vtkGetMacro(BoundaryMode, int);
//@}
protected:
vtkOrderedCompositeDistributor();
~vtkOrderedCompositeDistributor() override;
int BoundaryMode;
char* OutputType;
bool PassThrough;
vtkPKdTree* PKdTree;
......
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