Commit 87bf513b authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

fix vtkPVProminentValuesInformation.

This fixes a few issues with how "prominent values" were handled.

1. `vtkSMRepresentationProxy::GetProminentValuesInformation` always
   looked are represented data and never and it's input's data. That is
   different from how info for non-prominent values is handled.
   When coloring etc, we first look at the array range for the array
   from input, if present and then from represented data if the array
   was not present on the input. This was causing the molecule
   representation to not have any atomic numbers related information on
   creation. fixed that.

2. `vtkPVProminentValuesInformation` didn't have correct code in
   `CopyFromObject`. It was just a copy-paste from vtkPVDataInformation
   which didn't make sense for vtkPVProminentValuesInformation. Fixed
   that.
parent 813247c2
......@@ -203,66 +203,42 @@ int vtkPVProminentValuesInformation::Compare(vtkPVProminentValuesInformation* in
//----------------------------------------------------------------------------
void vtkPVProminentValuesInformation::CopyFromObject(vtkObject* obj)
{
vtkPVDataRepresentation* repr = vtkPVDataRepresentation::SafeDownCast(obj);
// Locate named array in dataset(s).
// (This bit adapted from vtkPVDataInformation.)
vtkDataObject* dobj = vtkDataObject::SafeDownCast(repr->GetRenderedDataObject(0));
vtkInformation* info = NULL;
// Handle the case where the a vtkAlgorithmOutput is passed instead of
// the data object. vtkSMPart uses vtkAlgorithmOutput.
if (!dobj)
// vtkPVProminentValuesInformation may be collected info from a
// `vtkPVDataRepresentation` subclass (in which case we're collecting
// representation data information) or a `vtkAlgorithm`.
// So we handle the two cases here.
vtkDataObject* dobj = nullptr;
if (vtkPVDataRepresentation* repr = vtkPVDataRepresentation::SafeDownCast(obj))
{
dobj = vtkDataObject::SafeDownCast(repr->GetRenderedDataObject(0));
}
else if (auto algo = vtkAlgorithm::SafeDownCast(obj))
{
vtkAlgorithmOutput* algOutput = vtkAlgorithmOutput::SafeDownCast(obj);
vtkAlgorithm* algo = vtkAlgorithm::SafeDownCast(obj);
if (algOutput && algOutput->GetProducer())
// We don't use vtkAlgorithm::GetOutputDataObject() since that calls a
// UpdateDataObject() pass, which may raise errors if the algo is not
// fully setup yet.
if (strcmp(algo->GetClassName(), "vtkPVNullSource") == 0)
{
if (strcmp(algOutput->GetProducer()->GetClassName(), "vtkPVNullSource") == 0)
{
// Don't gather any data information from the hypothetical null source.
return;
}
if (algOutput->GetProducer()->IsA("vtkPVPostFilter"))
{
algOutput = algOutput->GetProducer()->GetInputConnection(0, 0);
}
info = algOutput->GetProducer()->GetOutputInformation(this->PortNumber);
dobj = algOutput->GetProducer()->GetOutputDataObject(algOutput->GetIndex());
// Don't gather any data information from the hypothetical null source.
return;
}
else if (algo)
auto info = algo->GetExecutive()->GetOutputInformation(this->PortNumber);
if (!info || vtkDataObject::GetData(info) == NULL)
{
// We don't use vtkAlgorithm::GetOutputDataObject() since that calls a
// UpdateDataObject() pass, which may raise errors if the algo is not
// fully setup yet.
if (strcmp(algo->GetClassName(), "vtkPVNullSource") == 0)
{
// Don't gather any data information from the hypothetical null source.
return;
}
info = algo->GetExecutive()->GetOutputInformation(this->PortNumber);
if (!info || vtkDataObject::GetData(info) == NULL)
{
return;
}
dobj = algo->GetOutputDataObject(this->PortNumber);
return;
}
dobj = algo->GetOutputDataObject(this->PortNumber);
}
if (!dobj)
if (vtkCompositeDataSet* cds = vtkCompositeDataSet::SafeDownCast(dobj))
{
vtkErrorMacro(
"Could not cast object to a known data set: " << (obj ? obj->GetClassName() : "(null)"));
return;
this->CopyFromCompositeDataSet(cds);
}
vtkCompositeDataSet* cds = vtkCompositeDataSet::SafeDownCast(dobj);
if (cds)
else if (dobj)
{
this->CopyFromCompositeDataSet(cds);
return;
this->CopyFromLeafDataObject(dobj);
}
this->CopyFromLeafDataObject(dobj);
}
//----------------------------------------------------------------------------
......
......@@ -335,6 +335,7 @@ bool vtkSMParaViewPipelineControllerWithRendering::RegisterRepresentationProxy(v
mgr->GetColorTransferFunction(arrayName, proxy->GetSessionProxyManager());
vtkSMPropertyHelper(lutProperty).Set(lutProxy);
vtkSMPVRepresentationProxy::RescaleTransferFunctionToDataRange(proxy, true);
proxy->UpdateVTKObjects();
}
}
}
......
......@@ -342,7 +342,7 @@ vtkPVProminentValuesInformation* vtkSMRepresentationProxy::GetProminentValuesInf
{
vtkTimerLog::MarkStartEvent("vtkSMRepresentationProxy::GetProminentValues");
this->CreateVTKObjects();
this->UpdatePipeline();
// Initialize parameters with specified values:
this->ProminentValuesInformation->Initialize();
this->ProminentValuesInformation->SetFieldAssociation(
......@@ -354,7 +354,23 @@ vtkPVProminentValuesInformation* vtkSMRepresentationProxy::GetProminentValuesInf
this->ProminentValuesInformation->SetForce(force);
// Ask the server to fill out the rest of the information:
this->GatherInformation(this->ProminentValuesInformation);
// Now, we need to check if the array of interest is on the input or
// produced as an artifact by the representation.
vtkSMPropertyHelper inputHelper(this, "Input");
vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy());
const unsigned int port = inputHelper.GetOutputPort();
if (input &&
input->GetDataInformation(port)->GetArrayInformation(name.c_str(), fieldAssoc) != nullptr)
{
this->ProminentValuesInformation->SetPortNumber(port);
input->GatherInformation(this->ProminentValuesInformation);
}
else
{
this->GatherInformation(this->ProminentValuesInformation);
}
vtkTimerLog::MarkEndEvent("vtkSMRepresentationProxy::GetProminentValues");
this->ProminentValuesFraction = fraction;
this->ProminentValuesUncertainty = uncertaintyAllowed;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment