vtk中vtkDICOMImageReader调用流程分析

来源:互联网 发布:软件找不到指定模块 编辑:程序博客网 时间:2024/06/04 00:26

    vtkDICOMImageReader *reader=vtkDICOMImageReader::New();
    reader->SetDirectoryName("flodername");
    reader->Update();

int vtkStreamingDemandDrivenPipeline::Update(int port,

                                             vtkInformationVector* requests)

retval = retval && this->UpdateData(port);

vtkDemandDrivenPipeline
return this->ProcessRequest(this->DataRequest,
                              this->GetInputInformation(),
                              this->GetOutputInformation());

int vtkStreamingDemandDrivenPipeline
::ProcessRequest(vtkInformation* request,
                 vtkInformationVector** inInfoVec,
                 vtkInformationVector* outInfoVec)

    if(request->Has(REQUEST_DATA()))
  {

vtkDemandDrivenPipeline
int vtkDemandDrivenPipeline::ProcessRequest(vtkInformation* request,
                                            vtkInformationVector** inInfoVec,
                                            vtkInformationVector* outInfoVec)
   // Request data from the algorithm.
      result = this->ExecuteData(request,inInfoVec,outInfoVec);

// Handle REQUEST_DATA
int vtkCompositeDataPipeline::ExecuteData(vtkInformation* request,
                                          vtkInformationVector** inInfoVec,
                                          vtkInformationVector* outInfoVec)

 int vtkDemandDrivenPipeline::ExecuteData(vtkInformation* request,
                                         vtkInformationVector** inInfo,
                                         vtkInformationVector* outInfo)
{
  this->ExecuteDataStart(request, inInfo, outInfo);
  // Invoke the request on the algorithm.
//   vtkMTimeType mTimeBefore = this->Algorithm->GetMTime();
  int result = this->CallAlgorithm(request, vtkExecutive::RequestDownstream,
                                   inInfo, outInfo);
//   if (mTimeBefore != this->Algorithm->GetMTime())
//     {
//     vtkWarningMacro(<< this->Algorithm->GetClassName()
//                     << " modified it's MTime during RequestData(). "
//                     << "This may lead to unnecessary pipeline "
//                     << "executions");
//     }
  this->ExecuteDataEnd(request, inInfo, outInfo);

  return result;
}

//----------------------------------------------------------------------------
int vtkExecutive::CallAlgorithm(vtkInformation* request, int direction,
                                vtkInformationVector** inInfo,
                                vtkInformationVector* outInfo)
{
  // Copy default information in the direction of information flow.
  this->CopyDefaultInformation(request, direction, inInfo, outInfo);

  // Invoke the request on the algorithm.
  this->InAlgorithm = 1;
  int result = this->Algorithm->ProcessRequest(request, inInfo, outInfo);
  this->InAlgorithm = 0;

  // If the algorithm failed report it now.
  if(!result)
  {
    vtkErrorMacro("Algorithm " << this->Algorithm->GetClassName()
                  << "(" << this->Algorithm
                  << ") returned failure for request: "
                  << *request);
  }

  return result;
}

//----------------------------------------------------------------------------
int vtkImageAlgorithm::ProcessRequest(vtkInformation* request,
                                      vtkInformationVector** inputVector,
                                      vtkInformationVector* outputVector)
{
  // generate the data
  if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA()))
  {
    return this->RequestData(request, inputVector, outputVector);
  }

  // execute information
  if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION()))
  {
    return this->RequestInformation(request, inputVector, outputVector);
  }

  // propagate update extent
  if(request->Has(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT()))
  {
    return this->RequestUpdateExtent(request, inputVector, outputVector);
  }

  return this->Superclass::ProcessRequest(request, inputVector, outputVector);
}

//----------------------------------------------------------------------------
// This is the superclasses style of Execute method.  Convert it into
// an imaging style Execute method.
int vtkImageAlgorithm::RequestData(
  vtkInformation* request,
  vtkInformationVector** vtkNotUsed( inputVector ),
  vtkInformationVector* outputVector)
{
  // the default implimentation is to do what the old pipeline did find what
  // output is requesting the data, and pass that into ExecuteData

  // which output port did the request come from
  int outputPort =
    request->Get(vtkDemandDrivenPipeline::FROM_OUTPUT_PORT());

  // if output port is negative then that means this filter is calling the
  // update directly, in that case just assume port 0
  if (outputPort == -1)
  {
      outputPort = 0;
  }

  // get the data object
  vtkInformation *outInfo =
    outputVector->GetInformationObject(outputPort);
  // call ExecuteData
  this->SetErrorCode( vtkErrorCode::NoError );
  if (outInfo)
  {
    this->ExecuteDataWithInformation( outInfo->Get(vtkDataObject::DATA_OBJECT()),
                                      outInfo );
  }
  else
  {
    this->ExecuteData(NULL);
  }
  // Check for any error set by downstream filter (IO in most case)
  if ( this->GetErrorCode() )
  {
    return 0;
  }

  return 1;
}

void vtkDICOMImageReader::ExecuteDataWithInformation(vtkDataObject *output,
                                                     vtkInformation *outInfo)
{

0 0
原创粉丝点击