[Fwd: [Paraview] vtkCompositeDataSet::COMPOSITE_DATA_SET()]

Randy Hudson hudson at mcs.anl.gov
Mon Aug 6 18:11:54 EDT 2007



I'll add, below, the whole of vtkFlashHDF5AMRReader::RequestData(), where vtkCompositeDataSet::COMPOSITE_DATA_SET() is called. 
It's called about a 1/3 of the way into that method in the following line:
    vtkDataObject* doOutput = info->Get(vtkCompositeDataSet::COMPOSITE_DATA_SET());



> -------- Original Message --------
> Date: Mon, 06 Aug 2007 15:27:45 -0500
> From: Randy Hudson <hudson at mcs.anl.gov>
> To: ParaView Users <paraview at paraview.org>
> 
> Some time ago, I wrote a reader for paraview 2x that reads flash AMR data into a vtkHierarchicalBoxDataSet.
> 
> When I try to build it for paraview 3.1.0, the build fails because vtkCompositeDataSet::COMPOSITE_DATA_SET() no longer exists.
> 
> Is there a replacement method I can use, or do I have to change more than just one call to get out of the woods here?
> 
> Thanks.
> 
> -- 
> 
> Randy.


int vtkFlashHDF5AMRReader::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
{
    double blockcorner[3], spacing[3];
    int celldims[3];

    vtkWarningMacro("[vtkFlashHDF5AMRReader::RequestData] - IN");

    vtkInformation* info = outputVector->GetInformationObject(0);

    if (!info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) ||
       !info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES())) {
        vtkErrorMacro("Expected information not found. " "Cannot provide update extent.");
        return 0;
     }

    vtkHierarchicalDataInformation* compInfo = vtkHierarchicalDataInformation::SafeDownCast(
       info->Get(vtkCompositeDataPipeline::COMPOSITE_DATA_INFORMATION()));
    if (!compInfo) {
       vtkErrorMacro("Expected information not found. " "Cannot provide update extent.");
       return 0;
    }

    vtkHierarchicalDataInformation* updateInfo = vtkHierarchicalDataInformation::New();
    info->Set(vtkCompositeDataPipeline::UPDATE_BLOCKS(), updateInfo);
    updateInfo->SetNumberOfLevels(compInfo->GetNumberOfLevels());

    this->updatePiece = static_cast<unsigned int>(
       info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()));
    this->updateNumPieces =  static_cast<unsigned int>(
       info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES()));

    this->loblock = this->nob * this->updatePiece / this->updateNumPieces;
    vtkWarningMacro("[vtkFlashHDF5AMRReader::RequestData] - this->loblock: " << this->loblock);

    this->hiblock = (this->nob * (this->updatePiece + 1) / this->updateNumPieces) - 1;
    vtkWarningMacro("[vtkFlashHDF5AMRReader::RequestData] - this->hiblock: " << this->hiblock);

    vtkDataObject* doOutput = info->Get(vtkCompositeDataSet::COMPOSITE_DATA_SET());
    vtkHierarchicalBoxDataSet* ds = vtkHierarchicalBoxDataSet::SafeDownCast(doOutput);
    if (!ds) {   //   THIS -- FROM ORIGINAL RequestData() -- SEEMS NEEDED
       vtkWarningMacro("[vtkFlashHDF5AMRReader::RequestData] - 1");
       return 0;
    }

    ds->SetHierarchicalDataInformation(compInfo);

    int count = 0;
    for (int k=0; k<this->numVarNames; k++) {
       if (this->PointDataArraySelection->ArrayIsEnabled(this->varNames[k])) {
          count++;
       }
    }

    int* indices_of_selected = new int[count];
    int j = 0;
    for (int k=0; k<this->numVarNames; k++) {
       if (this->PointDataArraySelection->ArrayIsEnabled(this->varNames[k])) {
          indices_of_selected[j] = k;
          j++;
       }
    }


    //   READ ALL BLOCKS AT ONCE AND SPLIT RESULTS INTO vtkUniformGrid's HERE
    //   ==============================================================================
    //   ASSURE BLOCK AND LEVEL ID'S AND INDICES ARE IMPLEMENTED CORRECTLY.
    //   ==============================================================================

    int runsize = this->hiblock - this->loblock + 1;
    int* levelPerBlockId = new int[runsize];
    for(int i=0; i<this->numLevels; i++) {
       for(int j=0; j<this->numBlocksPerLevel[i]; j++) {
          if ((this->loblock <= this->blockIdsPerLevel[i][j]) && (this->blockIdsPerLevel[i][j] <= this->hiblock)) {
             levelPerBlockId[this->blockIdsPerLevel[i][j] - this->loblock] = i;
          }
       }
    }
    vtkDoubleArray*** scalars;   //   vtkDataArray*[k][runsize]

    //   TRY ALLOCATING THE MIDDLE DIMENSION HERE, RATHER THAN IN flashVtkComponents
    scalars = new vtkDoubleArray**[count];
    for (int k=0; k<count; k++) {   //   FOR ALL SELECTED SCALAR VARIABLES
       scalars[k] = new vtkDoubleArray*[runsize];
       //   GET ARRAYS FOR ALL BLOCKS IN THIS PROCESS' RANGE
       this->AddBlockrunScalars(this->loblock, this->hiblock, indices_of_selected[k], scalars[k]);
    }

    for (int i=this->loblock; i<=this->hiblock; i++) {
       vtkUniformGrid* ug = vtkUniformGrid::New();
       this->aVTKAMRSetup->DefineUG(levelPerBlockId[i - this->loblock], i,
                                    blockcorner, spacing, celldims);//   LEV IDX, BLK ID, etc.
       ug->SetOrigin(blockcorner);
       ug->SetSpacing(spacing);
       ug->SetDimensions(celldims);
       for (int k=0; k<count; k++) {   //   FOR ALL SELECTED SCALAR VARIABLES
          scalars[k][i - this->loblock]->SetName(this->varNames[indices_of_selected[k]]);
          if (this->aVTKAMRSetup->GetDataLocation() == LocPoint) {
             ug->GetPointData()->AddArray((vtkDataArray*)(scalars[k][i - this->loblock]));
          } else if (this->aVTKAMRSetup->GetDataLocation() == LocCell) {
             ug->GetCellData()->AddArray((vtkDataArray*)(scalars[k][i - this->loblock]));
          }
          scalars[k][i - this->loblock]->Delete();
       }

       ds->SetDataSet(levelPerBlockId[i - this->loblock], i - this->loblock, ug);
       ug->Delete();
    }

    for (int k=0; k<count; k++) {   //   FOR ALL SELECTED SCALAR VARIABLES
       delete [] scalars[k];
    }
    delete [] scalars;

    for(int i=0; i<this->numLevels; i++) {
       ds->SetRefinementRatio(i, 2);
    }

    ds->GenerateVisibilityArrays();
}



-- 

Randy.




More information about the ParaView mailing list