1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkPCellDataToPointData.cxx,v $
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkPCellDataToPointData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkPolyData.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkUnstructuredGrid.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkPCellDataToPointData, "$Revision: 1.5 $");
vtkStandardNewMacro(vtkPCellDataToPointData);
//----------------------------------------------------------------------------
vtkPCellDataToPointData::vtkPCellDataToPointData()
{
this->PieceInvariant = 1;
}
//----------------------------------------------------------------------------
int vtkPCellDataToPointData::RequestData(
vtkInformation* request,
vtkInformationVector** inputVector ,
vtkInformationVector* outputVector)
{
vtkInformation* info = outputVector->GetInformationObject(0);
vtkDataSet *output = vtkDataSet::SafeDownCast(
info->Get(vtkDataObject::DATA_OBJECT()));
if (!output) {return 0;}
if ( !this->Superclass::RequestData(request, inputVector, outputVector) )
{
return 0;
}
// Remove the extra (now ivalid) ghost cells.
// This is only necessary fro unstructured data.
if (this->PieceInvariant)
{
vtkInformation* outInfo = outputVector->GetInformationObject(0);
int ghostLevel = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS());
vtkPolyData *pd = vtkPolyData::SafeDownCast(output);
vtkUnstructuredGrid *ug = vtkUnstructuredGrid::SafeDownCast(output);
if (pd)
{
pd->RemoveGhostCells(ghostLevel+1);
}
if (ug)
{
ug->RemoveGhostCells(ghostLevel+1);
}
}
return 1;
}
//--------------------------------------------------------------------------
int vtkPCellDataToPointData::ComputeInputUpdateExtent(
vtkInformation*,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
if (this->PieceInvariant == 0)
{
// I believe the default input update extent
// is set to the input update extent.
return 1;
}
vtkInformation* opInfo = this->GetOutputPortInformation(0);
int extentType = opInfo->Get(vtkDataObject::DATA_EXTENT_TYPE());
vtkInformation* outInfo = outputVector->GetInformationObject(0);
vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
int piece, numPieces, ghostLevel;
int* wholeExt;
int* upExt;
int ext[6];
switch (extentType)
{
case VTK_PIECES_EXTENT:
piece = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER());
numPieces = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES());
ghostLevel = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS()) + 1;
inInfo->Set(
vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER(), piece);
inInfo->Set(
vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES(), numPieces);
inInfo->Set(
vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS(),
ghostLevel);
return 1;
break;
case VTK_3D_EXTENT:
wholeExt = inInfo->Get(
vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
upExt = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT());
memcpy(ext, upExt, 6*sizeof(int));
for (int i = 0; i < 3; ++i)
{
--ext[i*2];
if (ext[i*2] < wholeExt[i*2])
{
ext[i*2] = wholeExt[i*2];
}
++ext[i*2+1];
if (ext[i*2+1] > wholeExt[i*2+1])
{
ext[i*2+1] = wholeExt[i*2+1];
}
}
inInfo->Set(
vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), ext, 6);
return 1;
break;
}
return 0;
}
//----------------------------------------------------------------------------
void vtkPCellDataToPointData::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "PieceInvariant: "
<< this->PieceInvariant << "\n";
}
|