Commit abbdb477 authored by Yuanxin Liu's avatar Yuanxin Liu

Changes to be compatible with VTK amr data structure changes

Change-Id: I5eb7acea4fc149be4c87906cd77991ca17479120
parent 2537cabb
......@@ -112,7 +112,7 @@ public:
{ }
void SetDataObject(vtkDataObject* data)
{
{
this->DataObject = data;
this->ActualMemorySize = data? data->GetActualMemorySize() : 0;
......@@ -141,7 +141,7 @@ public:
}
vtkPVTrivialProducer* GetProducer(bool use_redistributed_data)
{
{
if (use_redistributed_data && this->Redistributable)
{
this->Producer->SetOutput(this->RedistributedDataObject);
......@@ -467,7 +467,7 @@ void vtkPVDataDeliveryManager::SetPiece(
vtkPVDataRepresentationPipeline::SafeDownCast(repr->GetExecutive());
// SetPiece() is called in every REQUEST_UPDATE() or REQUEST_UPDATE_LOD()
// pass irrespective of whether the data has actually changed.
// pass irrespective of whether the data has actually changed.
// (I think that's a mistake, but the fact that representations can be
// updated without view makes it tricky since we cannot set the data to
// deliver in vtkPVDataRepresentation::RequestData() easily). Hence we need
......@@ -550,7 +550,7 @@ vtkAlgorithmOutput* vtkPVDataDeliveryManager::GetProducer(
//----------------------------------------------------------------------------
bool vtkPVDataDeliveryManager::NeedsDelivery(
unsigned long timestamp,
unsigned long timestamp,
std::vector<unsigned int> &keys_to_deliver, bool use_low)
{
vtkInternals::ItemsMapType::iterator iter;
......@@ -602,12 +602,12 @@ void vtkPVDataDeliveryManager::Deliver(int use_lod, unsigned int size, unsigned
{
// we are dealing with AMR datasets.
// We assume for now we're not running in render-server mode. We can
// ensure that at some point in future.
// ensure that at some point in future.
// So we are either in pass-through or collect mode.
// FIXME: check that the mode flags are "suitable" for AMR.
}
vtkNew<vtkMPIMoveData> dataMover;
dataMover->InitializeForCommunicationForParaView();
dataMover->SetOutputDataType(data->GetDataObjectType());
......@@ -694,7 +694,7 @@ void vtkPVDataDeliveryManager::RedistributeDataForOrderedCompositing(
// delivered object can be null in case we're updating lod and the
// representation doeesn't have any LOD data.
item.GetDeliveredDataObject() == NULL)
item.GetDeliveredDataObject() == NULL)
{
continue;
}
......@@ -782,8 +782,8 @@ bool vtkPVDataDeliveryManager::BuildPriorityQueue(double planes[24])
{
if (oamr->GetDataSet(level, index) == NULL)
{
vtkAMRBox amrBox;
if (!oamr->GetMetaData(level, index, amrBox))
vtkAMRBox amrBox = oamr->GetAMRBox(level,index);
if (amrBox.IsInvalid())
{
vtkWarningMacro("Missing AMRBox meta-data for "
<< level << ", " << index);
......@@ -797,7 +797,7 @@ bool vtkPVDataDeliveryManager::BuildPriorityQueue(double planes[24])
item.Index = index;
double bounds[6];
amrBox.GetBounds(bounds);
oamr->GetBounds(level,index,bounds);
double depth = 1.0;
double coverage = vtkComputeScreenCoverage(planes, bounds, depth);
//cout << level <<"," << index << "(" << item.BlockId << ")" << " = " << coverage << ", " << depth << endl;
......
......@@ -14,7 +14,6 @@
=========================================================================*/
#include "vtkAMRFileSeriesReader.h"
#include "vtkAMRBaseReader.h"
#include "vtkInformationVector.h"
#include "vtkInformation.h"
#include "vtkStreamingDemandDrivenPipeline.h"
......
......@@ -574,6 +574,7 @@ int vtkSpyPlotReader::AddAttributes(vtkNonOverlappingAMR *hbds)
return 1;
}
//-----------------------------------------------------------------------------
int vtkSpyPlotReader::RequestData(
vtkInformation *request,
......@@ -803,8 +804,6 @@ int vtkSpyPlotReader::RequestData(
this->AddBlockIdArray(cds);
}
return 1;
}
......@@ -2100,16 +2099,13 @@ void vtkSpyPlotReader::SetGlobalLevels(vtkCompositeDataSet *composite)
}
}
}
if(numberOfLevels>hbDS->GetNumberOfLevels())
{
hbDS->SetNumberOfLevels(numberOfLevels);
}
}
// At this point, the global number of levels is set in each processor.
// Update each level
// i.e. for each level synchronize the number of datasets (or pieces).
unsigned int level;
std::vector<int> blocksPerLevel(numberOfLevels,0); //collect this
std::vector<int> globalIndices(numberOfLevels);
for (level = 0; level<numberOfLevels; level++)
{
int intMsgValue;
......@@ -2161,6 +2157,8 @@ void vtkSpyPlotReader::SetGlobalLevels(vtkCompositeDataSet *composite)
globalIndex=intMsgValue;
}
globalIndices[level] = globalIndex;
// Send it to children.
if(left<numProcessors)
{
......@@ -2186,6 +2184,7 @@ void vtkSpyPlotReader::SetGlobalLevels(vtkCompositeDataSet *composite)
}
}
}
blocksPerLevel[level] = totalNumberOfDataSets;
// Update the level.
if(totalNumberOfDataSets>numberOfDataSets)
......@@ -2193,34 +2192,6 @@ void vtkSpyPlotReader::SetGlobalLevels(vtkCompositeDataSet *composite)
// save the current datasets
if (hbDS)
{
if (globalIndex==0)
{
hbDS->SetNumberOfDataSets(level, totalNumberOfDataSets);
}
else
{
std::vector<vtkSmartPointer<vtkUniformGrid> > datasets;
std::vector<vtkAMRBox> boxes;
int kk;
for (kk=0; kk < numberOfDataSets; kk++)
{
// vtkAMRBox box;
// vtkUniformGrid* ug = hbDS->GetDataSet(level, kk, box);
vtkUniformGrid* ug = hbDS->GetDataSet(level, kk);
datasets.push_back(ug);
// boxes.push_back(box);
}
hbDS->SetNumberOfDataSets(level, 0); // removes all current datasets.
hbDS->SetNumberOfDataSets(level, totalNumberOfDataSets);
// put the datasets back starting at globalIndex.
// All other indices are in their initialized state.
for (kk=0; kk < numberOfDataSets; kk++)
{
hbDS->SetDataSet(level,kk+globalIndex,datasets[kk]);
// hbDS->SetDataSet(level, kk+globalIndex, boxes[kk], datasets[kk]);
}
}
}
else // if (mbDS)
{
......@@ -2248,6 +2219,36 @@ void vtkSpyPlotReader::SetGlobalLevels(vtkCompositeDataSet *composite)
}
}
}
if(hbDS)
{
hbDS->Initialize(numberOfLevels,&blocksPerLevel[0]);
for(unsigned int level = 0; level<numberOfLevels; level++)
{
int totalNumberOfDataSets=blocksPerLevel[level];
int numberOfDataSets= hbDS->GetNumberOfDataSets(level);
int globalIndex = globalIndices[level];
if (globalIndex!=0)
{
std::vector<vtkSmartPointer<vtkUniformGrid> > datasets;
std::vector<vtkAMRBox> boxes;
int kk;
for (kk=0; kk < numberOfDataSets; kk++)
{
vtkUniformGrid* ug = hbDS->GetDataSet(level, kk);
datasets.push_back(ug);
}
// put the datasets back starting at globalIndex.
// All other indices are in their initialized state.
for (kk=0; kk < numberOfDataSets; kk++)
{
hbDS->SetDataSet(level,kk+globalIndex,datasets[kk]);
}
}
}
}
}
//-----------------------------------------------------------------------------
......
......@@ -159,7 +159,7 @@ vtkPVGeometryFilter::vtkPVGeometryFilter ()
this->SetController(vtkMultiProcessController::GetGlobalController());
this->GenerateProcessIds = (this->Controller &&
this->Controller->GetNumberOfProcesses() > 1);
this->OutlineSource = vtkOutlineSource::New();
this->PassThroughCellIds = 1;
......@@ -649,20 +649,19 @@ void vtkPVGeometryFilter::AddHierarchicalIndex(vtkPolyData* pd,
}
//----------------------------------------------------------------------------
bool vtkPVGeometryFilter::IsAMRDataVisible(
vtkAMRBox &amrBox, vtkAMRBox &rootBox, bool extractface[6] )
bool vtkPVGeometryFilter::IsAMRDataVisible(vtkOverlappingAMR* amr,
unsigned int level,
unsigned int id,
bool extractface[6] )
{
vtkAMRBox amrBox = amr->GetAMRBox(level,id);
// Sanity check
assert( "pre: AMR box dimensionality must match!" &&
(amrBox.GetDimensionality() == rootBox.GetDimensionality() ) );
assert( "pre: AMR dimension out-of-bounds!" &&
(amrBox.GetDimensionality() >= 1) &&
(amrBox.GetDimensionality() <= 3) );
(amrBox.ComputeDimension() >= 1) &&
(amrBox.ComputeDimension() <= 3) );
// STEP 1: If it's 2-D all blocks are visible
if( amrBox.GetDimensionality() <= 2)
if( amrBox.ComputeDimension() <= 2)
{
for( int i=0; i < 6; ++i )
{
......@@ -685,13 +684,14 @@ bool vtkPVGeometryFilter::IsAMRDataVisible(
// -- Get the root cartesian box bounds
int ndim[3];
ndim[0]=ndim[1]=ndim[2]=0;
double min[3]; double max[3];
rootBox.GetMinBounds( min );
rootBox.GetMaxBounds( max );
double min[3],max[3];
amr->GetMin(min);
amr->GetMax(max);
// -- Get the data spacing
double spacing[3];
amrBox.GetGridSpacing( spacing );
amr->GetGridSpacing(level, spacing );
// -- Compute the number of CELLS in tmpBox
for( int i=0; i < 3; ++i )
......@@ -706,17 +706,11 @@ bool vtkPVGeometryFilter::IsAMRDataVisible(
lo[0]=lo[1]=lo[2]=0;
vtkAMRBox tmpBox;
tmpBox.SetDimensionality( 3 );
tmpBox.SetDataSetOrigin( min );
tmpBox.SetGridSpacing( spacing );
tmpBox.SetDimensions( lo, ndim );
tmpBox.SetLevel( 0 );
tmpBox.SetBlockId( 0 );
tmpBox.SetProcessId( -1 );
// STEP 3: Check if the box is on the boundary
bool render = false;
for( int i=0; i < 3; ++i )
{
if( amrBox.GetLoCorner()[i] == 0 )
......@@ -762,7 +756,9 @@ int vtkPVGeometryFilter::RequestAMRData(
if( this->UseOutline )
{
vtkOutlineSource *outline = vtkOutlineSource::New();
outline->SetBounds( input->GetBounds() );
double bb[6];
input->GetBounds(bb);
outline->SetBounds(bb);
outline->Update();
vtkPolyData *AMRDataOutline = vtkPolyData::New();
......@@ -803,9 +799,6 @@ int vtkPVGeometryFilter::RequestAMRData(
// NOTE: We assume that the root node covers the entire domain & that it
// is stored @ (0,0)
vtkAMRBox rootAMRBox;
input->GetRootAMRBox( rootAMRBox );
// Get the whole extent
int* wholeExtent =
vtkStreamingDemandDrivenPipeline::GetWholeExtent(
......@@ -830,16 +823,15 @@ int vtkPVGeometryFilter::RequestAMRData(
}
else
{
vtkAMRBox amrBox;
input->GetMetaData( level, dataIdx, amrBox );
vtkAMRBox amrBox = input->GetAMRBox( level, dataIdx);
bool extractface[6];
if( this->IsAMRDataVisible(amrBox,rootAMRBox,extractface) )
if( this->IsAMRDataVisible(input,level,dataIdx,extractface) )
{
vtkPolyData* tmpOut = vtkPolyData::New();
this->ExecuteAMRBlock(ug,tmpOut,0,0,1,0, wholeExtent, extractface);
this->CleanupOutputData(tmpOut, 0);
this->AddCompositeIndex(
tmpOut,input->GetFlatIndex(level,dataIdx));
tmpOut,input->GetCompositeIndex(level,dataIdx));
mpds->SetPiece( dataIdx, tmpOut );
tmpOut->Delete();
} // END if AMR data is visible
......@@ -931,10 +923,10 @@ int vtkPVGeometryFilter::RequestCompositeData(vtkInformation*,
{
// This will be used later by vtkSelectionConverter to realize that this
// multi-block of polydatas is actually coming from an AMR.
vtkInformation* metadata = output->GetMetaData(iter);
metadata->Set(vtkSelectionNode::HIERARCHICAL_LEVEL(),
vtkDataObject* dataset = output->GetDataSet(iter);
dataset->GetInformation()->Set(vtkSelectionNode::HIERARCHICAL_LEVEL(),
hdIter->GetCurrentLevel());
metadata->Set(vtkSelectionNode::HIERARCHICAL_INDEX(),
dataset->GetInformation()->Set(vtkSelectionNode::HIERARCHICAL_INDEX(),
hdIter->GetCurrentIndex());
if (tmpOut)
{
......
......@@ -41,6 +41,7 @@ class vtkStructuredGrid;
class vtkUnstructuredGrid;
class vtkUnstructuredGridGeometryFilter;
class vtkAMRBox;
class vtkOverlappingAMR;
class VTKPVVTKEXTENSIONSRENDERING_EXPORT vtkPVGeometryFilter : public vtkDataObjectAlgorithm
{
......@@ -144,10 +145,10 @@ protected:
// Description:
// A helper method which, given the AMR box of the data in question
// and the root AMR box, determines whether or not the block is visible.
bool IsAMRDataVisible( vtkAMRBox &amrBox,
vtkAMRBox &rootBox,
bool faceextract[6] );
bool IsAMRDataVisible(vtkOverlappingAMR* amr,
unsigned int level,
unsigned int id,
bool extractface[6] );
// Description:
// Overridden to create vtkMultiBlockDataSet when input is a
// composite-dataset and vtkPolyData when input is a vtkDataSet.
......
VisItBridge @ e224f862
Subproject commit 0c5c75bc21c2e2582d19b2dfb5d1c67fdb5dbdd8
Subproject commit e224f862e765fb5a6d525ef06a0e57db8b6a13fa
VTK @ 3d262959
Subproject commit 5592cbda186f42afec7b3299059975af868423a3
Subproject commit 3d262959cf2355d9a26d05679234e611dca73d5c
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