Hi, I’m a beginner of paraview, and now I’m developing a custom reader.
My paraview version is 3.14, so I followed this example: https://vtk.org/Wiki/ParaView/Examples/Plugins/Reader
After plugin loaded, I found RequestData not called.
I tried these things:
Draw a single point instead of reading file, show nothing;
Call RequestData in RequestInformation, now output has value, bu still show nothing.
Where is my mistake?
Here is part of my code:
class VTK_EXPORT SimworksGridReader : public vtkUnstructuredGridAlgorithm
{
public:
static SimworksGridReader *New();
vtkTypeMacro(SimworksGridReader,vtkUnstructuredGridAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// Get the output of this reader.
vtkUnstructuredGrid *GetOutput();
vtkUnstructuredGrid *GetOutput(int idx);
void SetOutput(vtkUnstructuredGrid *output);
protected:
SimworksGridReader();
~SimworksGridReader();
virtual int RequestData(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
virtual int RequestInformation(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
vtkInformationVector *);
virtual int FillOutputPortInformation(int, vtkInformation*);
private:
SimworksGridReader(const SimworksGridReader&); // Not implemented.
void operator=(const SimworksGridReader&); // Not implemented.
char* FileName;
};
int SimworksGridReader::FillOutputPortInformation(int,
vtkInformation* info)
{
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkUnstructuredGrid");
info->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(), -1);
return 1;
}
int SimworksGridReader::RequestInformation(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
vtkInformation* info = outputVector->GetInformationObject(0);
return 1;
}
int SimworksGridReader::RequestData(
vtkInformation *request,
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
vtkInformation *outInfo = outputVector->GetInformationObject(0);
int size, ncells=0;
vtkCellArray *cells=NULL;
int *types=NULL;
vtkIdType *idArray;
vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
points->InsertNextPoint(0,0,0);
output->SetPoints(points);
cells = vtkCellArray::New();
ncells = 1;
size =1;
idArray = cells->WritePointer(ncells, size);
idArray[0] = 0;
types = new int[ncells];
types[0] = 1;
output->SetCells(types, cells);
return 1;
}
Thanks in advance.