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 144 145 146 147 148 149
|
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkTrivialProducer.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 "vtkTrivialProducer.h"
#include "vtkImageData.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkGarbageCollector.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkTrivialProducer, "$Revision: 1.9 $");
vtkStandardNewMacro(vtkTrivialProducer);
//----------------------------------------------------------------------------
vtkTrivialProducer::vtkTrivialProducer()
{
this->SetNumberOfInputPorts(0);
this->SetNumberOfOutputPorts(1);
this->Output = 0;
}
//----------------------------------------------------------------------------
vtkTrivialProducer::~vtkTrivialProducer()
{
this->SetOutput(0);
}
//----------------------------------------------------------------------------
void vtkTrivialProducer::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
//----------------------------------------------------------------------------
void vtkTrivialProducer::SetOutput(vtkDataObject*newOutput)
{
vtkDataObject* oldOutput = this->Output;
if(newOutput != oldOutput)
{
if(newOutput)
{
newOutput->Register(this);
}
this->Output = newOutput;
this->GetExecutive()->SetOutputData(0, newOutput);
if(oldOutput)
{
oldOutput->UnRegister(this);
}
this->Modified();
}
}
//----------------------------------------------------------------------------
unsigned long vtkTrivialProducer::GetMTime()
{
unsigned long mtime = this->Superclass::GetMTime();
if(this->Output)
{
unsigned long omtime = this->Output->GetMTime();
if(omtime > mtime)
{
mtime = omtime;
}
}
return mtime;
}
//----------------------------------------------------------------------------
vtkExecutive* vtkTrivialProducer::CreateDefaultExecutive()
{
return vtkStreamingDemandDrivenPipeline::New();
}
//----------------------------------------------------------------------------
int vtkTrivialProducer::FillInputPortInformation(int, vtkInformation*)
{
return 1;
}
//----------------------------------------------------------------------------
int vtkTrivialProducer::FillOutputPortInformation(int, vtkInformation*)
{
return 1;
}
//----------------------------------------------------------------------------
int
vtkTrivialProducer::ProcessRequest(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()) &&
this->Output)
{
vtkInformation* outputInfo = outputVector->GetInformationObject(0);
vtkInformation* dataInfo = this->Output->GetInformation();
if(dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) == VTK_PIECES_EXTENT)
{
// There is no real source to change the output data, so we can
// produce exactly one piece.
outputInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(), 1);
}
else if(dataInfo->Get(vtkDataObject::DATA_EXTENT_TYPE()) == VTK_3D_EXTENT)
{
// The whole extent is just the extent because the output has no
// real source to change its data.
int extent[6];
dataInfo->Get(vtkDataObject::DATA_EXTENT(), extent);
outputInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
extent, 6);
}
}
if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA_NOT_GENERATED()))
{
// We do not really generate the output. Do not let the executive
// initialize it.
vtkInformation* outputInfo = outputVector->GetInformationObject(0);
outputInfo->Set(vtkDemandDrivenPipeline::DATA_NOT_GENERATED(), 1);
}
if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA()) && this->Output)
{
// Pretend we generated the output.
vtkInformation* outputInfo = outputVector->GetInformationObject(0);
outputInfo->Remove(vtkDemandDrivenPipeline::DATA_NOT_GENERATED());
}
return this->Superclass::ProcessRequest(request,inputVector,outputVector);
}
//----------------------------------------------------------------------------
void vtkTrivialProducer::ReportReferences(vtkGarbageCollector* collector)
{
this->Superclass::ReportReferences(collector);
vtkGarbageCollectorReport(collector, this->Output, "Output");
}
|