MCPcopy Create free account
hub / github.com/Kitware/VTK / CheckDataObject

Method CheckDataObject

Common/ExecutionModel/vtkDemandDrivenPipeline.cxx:589–642  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

587
588//------------------------------------------------------------------------------
589int vtkDemandDrivenPipeline::CheckDataObject(int port, vtkInformationVector* outInfoVec)
590{
591 // Check that the given output port has a valid data object.
592 vtkInformation* outInfo = outInfoVec->GetInformationObject(port);
593 vtkDataObject* data = outInfo->Get(vtkDataObject::DATA_OBJECT());
594 vtkInformation* portInfo = this->Algorithm->GetOutputPortInformation(port);
595 if (const char* dt = portInfo->Get(vtkDataObject::DATA_TYPE_NAME()))
596 {
597 int incorrectdata = data && (!data->IsA(dt));
598 // The output port specifies a data type. Make sure the data
599 // object exists and is of the right type.
600 if (!data || incorrectdata)
601 {
602 if (data)
603 {
604 vtkDebugMacro(<< "CHECKDATAOBJECT Replacing " << data->GetClassName());
605 }
606 // Try to create an instance of the correct type.
607 data = vtkDataObjectTypes::NewDataObject(dt);
608 this->SetOutputData(port, data, outInfo);
609 if (data)
610 {
611 vtkDebugMacro(<< "CHECKDATAOBJECT Created " << dt);
612 data->FastDelete();
613 }
614 }
615 if (!data)
616 {
617 // The algorithm has a bug and did not create the data object.
618 vtkErrorMacro("Algorithm " << this->Algorithm->GetObjectDescription()
619 << " did not create output for port " << port
620 << " when asked by REQUEST_DATA_OBJECT and does not"
621 << " specify a concrete DATA_TYPE_NAME.");
622 return 0;
623 }
624 return 1;
625 }
626 else if (data)
627 {
628 // The algorithm did not specify its output data type. Just assume
629 // the data object is of the correct type.
630 return 1;
631 }
632 else
633 {
634 // The algorithm did not specify its output data type and no
635 // object exists.
636 vtkErrorMacro("Algorithm " << this->Algorithm->GetObjectDescription()
637 << " did not create output for port " << port
638 << " when asked by REQUEST_DATA_OBJECT and does not"
639 << " specify any DATA_TYPE_NAME.");
640 return 0;
641 }
642}
643
644//------------------------------------------------------------------------------
645int vtkDemandDrivenPipeline::InputCountIsValid(vtkInformationVector** inInfoVec)

Callers 1

ExecuteDataObjectMethod · 0.95

Calls 8

GetInformationObjectMethod · 0.80
IsAMethod · 0.80
SetOutputDataMethod · 0.80
FastDeleteMethod · 0.80
GetMethod · 0.45
GetClassNameMethod · 0.45
GetObjectDescriptionMethod · 0.45

Tested by

no test coverage detected