Commit 5dca988d authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

For BUG #10828. Added API to set region assignments.

vtkDistributedDataFilter had API to set user-defined cuts, but not the region
assignments. This was needed to ensure that the cuts were assignmed to processes
as expected when volume rendering image data. This commit exposes that API.
parent 6c6370a7
......@@ -78,6 +78,12 @@ public:
vtkstd::multimap<int, int> IntMultiMap;
};
class vtkDistributedDataFilter::vtkInternals
{
public:
vtkstd::vector<int> UserRegionAssignments;
};
//----------------------------------------------------------------------------
vtkDistributedDataFilter::vtkDistributedDataFilter()
{
......@@ -103,6 +109,7 @@ vtkDistributedDataFilter::vtkDistributedDataFilter()
this->UseMinimalMemory = 0;
this->UserCuts = 0;
this->Internals = new vtkDistributedDataFilter::vtkInternals();
}
//----------------------------------------------------------------------------
......@@ -139,6 +146,8 @@ vtkDistributedDataFilter::~vtkDistributedDataFilter()
this->UserCuts->Delete();
this->UserCuts = NULL;
}
delete this->Internals;
this->Internals = 0;
}
//----------------------------------------------------------------------------
......@@ -166,6 +175,22 @@ void vtkDistributedDataFilter::SetCuts(vtkBSPCuts* cuts)
this->Modified();
}
//----------------------------------------------------------------------------
void vtkDistributedDataFilter::SetUserRegionAssignments(
const int *map, int numRegions)
{
vtkstd::vector<int> copy(this->Internals->UserRegionAssignments);
this->Internals->UserRegionAssignments.resize(numRegions);
for (int cc=0; cc < numRegions; cc++)
{
this->Internals->UserRegionAssignments[cc] = map[cc];
}
if (copy != this->Internals->UserRegionAssignments)
{
this->Modified();
}
}
//----------------------------------------------------------------------------
vtkIdTypeArray *vtkDistributedDataFilter::GetGlobalElementIdArray(vtkDataSet *set)
{
......@@ -759,8 +784,7 @@ int vtkDistributedDataFilter::PartitionDataAndAssignToProcesses(vtkDataSet *set)
this->Kdtree->SetController(this->Controller);
this->Kdtree->SetNumberOfRegionsOrMore(this->NumProcesses);
this->Kdtree->SetMinCells(0);
this->Kdtree->SetDataSet(set);
this->Kdtree->SetDataSet(set);
// BuildLocator is smart enough to rebuild the k-d tree only if
// the input geometry has changed, or the k-d tree build parameters
......@@ -787,6 +811,22 @@ int vtkDistributedDataFilter::PartitionDataAndAssignToProcesses(vtkDataSet *set)
return 1;
}
if (this->Internals->UserRegionAssignments.size() > 0)
{
if (
static_cast<int>(this->Internals->UserRegionAssignments.size()) !=
nregions)
{
vtkWarningMacro("Mismatch in number of user-defined regions and regions"
" the in KdTree. Ignoring user-defined regions.");
}
else
{
this->Kdtree->AssignRegions(
&this->Internals->UserRegionAssignments[0], nregions);
}
}
return 0;
}
......
......@@ -229,6 +229,16 @@ public:
vtkBSPCuts* GetCuts() {return this->UserCuts;}
void SetCuts(vtkBSPCuts* cuts);
// Description:
// vtkBSPCuts doesn't have information about process assignments for the cuts.
// Typically D3 filter simply reassigns the processes for each cut. However,
// that may not always work, sometimes the processes have be pre-assigned and
// we want to preserve that partitioning. In that case, one sets the region
// assignments explicitly. Look at vtkPKdTree::AssignRegions for details about
// the arguments. Calling SetUserRegionAssignments(NULL, 0) will revert to
// default behavior i.e. letting the KdTree come up with the assignments.
void SetUserRegionAssignments(const int *map, int numRegions);
protected:
vtkDistributedDataFilter();
~vtkDistributedDataFilter();
......@@ -289,9 +299,9 @@ protected:
// Description:
// Implementation for request data.
int RequestDataInternal(vtkDataSet* input, vtkUnstructuredGrid* output);
//BTX
private:
//BTX
enum{
DeleteNo = 0,
DeleteYes = 1
......@@ -310,7 +320,6 @@ private:
enum{
UnsetGhostLevel = 99
};
//ETX
// Description:
// ?
......@@ -549,5 +558,9 @@ private:
vtkDistributedDataFilter(const vtkDistributedDataFilter&); // Not implemented
void operator=(const vtkDistributedDataFilter&); // Not implemented
class vtkInternals;
vtkInternals* Internals;
//ETX
};
#endif
......@@ -132,6 +132,16 @@ public:
// will be assigned after BuildLocator executes.
int AssignRegionsContiguous();
// Description:
// Returns the region assignment map where index is the region and value is
// the processes id for that region.
const int* GetRegionAssignmentMap()
{ return this->RegionAssignmentMap; }
// Description:
/// Returns the number of regions in the region assignment map.
vtkGetMacro(RegionAssignmentMapLength, int);
// Description:
// Writes the list of region IDs assigned to the specified
// process. Regions IDs start at 0 and increase by 1 from there.
......
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