Skip to content
Snippets Groups Projects
Commit 2e1174ef authored by Spiros Tsalikis's avatar Spiros Tsalikis
Browse files

vtkExtractSelection: When input is AMR create PDC

Also fix issue with using amr iterator.
parent 18feca43
No related branches found
No related tags found
No related merge requests found
......@@ -120,8 +120,8 @@ int vtkExtractSelection::RequestDataObject(
}
else if (vtkCompositeDataSet::SafeDownCast(inputDO))
{
// For other composite datasets, we create a vtkMultiBlockDataSet as output;
outputType = VTK_MULTIBLOCK_DATA_SET;
// For other composite datasets, we create a vtkPartitionedDataSetCollection as output;
outputType = VTK_PARTITIONED_DATA_SET_COLLECTION;
}
else if (vtkDataSet::SafeDownCast(inputDO) ||
(this->HyperTreeGridToUnstructuredGrid && vtkHyperTreeGrid::SafeDownCast(inputDO)))
......@@ -314,8 +314,7 @@ int vtkExtractSelection::RequestData(vtkInformation* vtkNotUsed(request),
assert(outputCD != nullptr);
outputCD->CopyStructure(inputCD);
vtkSmartPointer<vtkCompositeDataIterator> inIter;
inIter.TakeReference(inputCD->NewIterator());
auto inIter = vtk::TakeSmartPointer(inputCD->NewIterator());
// Initialize the output composite dataset to have blocks with the same type
// as the input.
......@@ -365,39 +364,31 @@ int vtkExtractSelection::RequestData(vtkInformation* vtkNotUsed(request),
vtkLogStartScope(TRACE, "evaluate expression and extract output");
// Now iterate again over the composite dataset and evaluate the expression to
// combine all the insidedness arrays and then extract the elements.
vtkSmartPointer<vtkCompositeDataIterator> outIter;
outIter.TakeReference(outputCD->NewIterator());
bool globalEvaluationResult = true;
// input iterator is needed because if inputCD is subclass of vtkUniformGridAMR,
// GetDataSet requires the iterator to be vtkUniformGridAMRDataIterator
vtkTypeBool isUniformGridAMR = outputCD->IsA("vtkUniformGridAMR");
if (isUniformGridAMR)
{
inIter->GoToFirstItem();
}
for (outIter->GoToFirstItem(); !outIter->IsDoneWithTraversal(); outIter->GoToNextItem())
// we use the input iterator instead of the output one, because if inputCD is subclass of
// vtkUniformGridAMR, GetDataSet requires the iterator to be vtkUniformGridAMRDataIterator
for (inIter->GoToFirstItem(); !inIter->IsDoneWithTraversal(); inIter->GoToNextItem())
{
if (this->CheckAbort())
{
break;
}
auto outputBlock = outIter->GetCurrentDataObject();
if (outputBlock)
auto inBlock = inIter->GetCurrentDataObject();
auto outBlock = outputCD->GetDataSet(inIter);
if (inBlock && outBlock)
{
// Evaluate the expression.
auto evaluationResult = this->EvaluateSelection(outputBlock, assoc, selection, selectors);
auto evaluationResult = this->EvaluateSelection(outBlock, assoc, selection, selectors);
if (evaluationResult != EvaluationResult::INVALID)
{
vtkSmartPointer<vtkUnsignedCharArray> colorArray =
this->EvaluateColorArrayInSelection(outputBlock, assoc, selection);
this->EvaluateColorArrayInSelection(outBlock, assoc, selection);
// Extract the elements.
auto iter = isUniformGridAMR ? inIter : outIter;
auto extractResult =
this->ExtractElements(inputCD->GetDataSet(iter), assoc, evaluationResult, outputBlock);
auto extractResult = this->ExtractElements(inBlock, assoc, evaluationResult, outBlock);
this->AddColorArrayOnObject(extractResult, colorArray);
outputCD->SetDataSet(outIter, extractResult);
outputCD->SetDataSet(inIter, extractResult);
}
else
{
......@@ -405,19 +396,15 @@ int vtkExtractSelection::RequestData(vtkInformation* vtkNotUsed(request),
break;
}
}
if (isUniformGridAMR)
{
inIter->GoToNextItem();
}
}
vtkLogEndScope("evaluate expression and extract output");
// check for evaluate result errors
if (!globalEvaluationResult)
{
// If the expression evaluation failed, then we need to set all the blocks to null.
for (outIter->GoToFirstItem(); !outIter->IsDoneWithTraversal(); outIter->GoToNextItem())
for (inIter->GoToFirstItem(); !inIter->IsDoneWithTraversal(); inIter->GoToNextItem())
{
outputCD->SetDataSet(outIter, nullptr);
outputCD->SetDataSet(inIter, nullptr);
}
return 0;
}
......
......@@ -5,14 +5,23 @@
* @brief extract a subset from a vtkDataSet.
*
* vtkExtractSelection extracts some subset of cells and points from
* its input dataobject. The dataobject is given on its first input port.
* its input data object. The data object is given on its first input port.
* The subset is described by the contents of the vtkSelection on its
* second input port. Depending on the contents of the vtkSelection
* this will create various vtkSelectors to identify the
* selected elements.
*
* This filter supports vtkCompositeDataSet (output is vtkMultiBlockDataSet),
* vtkTable and vtkDataSet (output is vtkUnstructuredGrid).
* This filter supports vtkCompositeDataSet, vtkDataSet, vtkHyperTreeGrid and vtkTable.
*
* 1. If preserve topology is on, the output type is the same as the input.
* 2. If preserve topology is on.
* 1. If input is a subclass of vtkDataObjectTree, the output is the same subclass.
* 2. If input is vtkUniformGridAMR, the output is vtkPartitionedDataSetCollection.
* 3. If input is vtkDataSet, the output is vtkUnstructuredGrid.
* 4. If input is vtkHyperTreeGrid, the output is vtkHyperTreeGrid or vtkUnstructuredGrid
* depending on the HyperTreeGridToUnstructuredGrid flag.
* 5. If input is vtkTable, the output is vtkTable.
*
* Other types of input are not processed and the corresponding output is a
* default constructed object of the input type.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment