Commit f7668d79 authored by Ken Martin's avatar Ken Martin

again try to fix this test

This is a mess because it seems like the pipeline created
has no indication of what nodes are what level in the
tree. So we end up having to iterate over the last
filters input to count non lowest level nodes and
then use that count when iterating over the mappers
input.
parent 3997b438
......@@ -18,6 +18,7 @@
#include <vtkAMRSliceFilter.h>
#include <vtkCamera.h>
#include <vtkColorTransferFunction.h>
#include <vtkCompositeDataDisplayAttributes.h>
#include <vtkCompositePolyDataMapper2.h>
#include <vtkDataObjectTreeIterator.h>
#include <vtkDataSetSurfaceFilter.h>
......@@ -32,6 +33,7 @@
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRTAnalyticSource.h>
#include <vtkUniformGridAMRDataIterator.h>
#include <array>
......@@ -84,27 +86,43 @@ int TestAMRSliceFilterCellData(int argc, char *argv[])
mapper->SetInterpolateScalarsBeforeMapping(1);
mapper->SelectColorArray("RTData");
vtkNew<vtkCompositeDataDisplayAttributes> cdsa;
mapper->SetCompositeDataDisplayAttributes(cdsa);
int nonLeafNodes = 0;
{
vtkOverlappingAMR *oamr = vtkOverlappingAMR::SafeDownCast(
slicer->GetOutputDataObject(0));
vtkSmartPointer<vtkUniformGridAMRDataIterator> iter =
vtkSmartPointer<vtkUniformGridAMRDataIterator>::New();
iter->SetDataSet(oamr);
for (iter->InitTraversal(); !iter->IsDoneWithTraversal();
iter->GoToNextItem())
{
if (iter->GetCurrentLevel() < 2)
{
nonLeafNodes++;
}
}
}
// only show the leaf nodes
vtkCompositeDataSet *input = vtkCompositeDataSet::SafeDownCast(
mapper->GetInputDataObject(0, 0));
surface->GetOutputDataObject(0));
if (input)
{
vtkSmartPointer<vtkDataObjectTreeIterator> iter =
vtkSmartPointer<vtkDataObjectTreeIterator>::New();
iter->SetDataSet(input);
for (iter->InitTraversal(); !iter->IsDoneWithTraversal();
iter->GoToNextItem())
{
unsigned int flatIndex = iter->GetCurrentFlatIndex();
mapper->SetBlockVisibility(flatIndex, false);
}
iter->SkipEmptyNodesOn();
iter->VisitOnlyLeavesOn();
int count = 0;
for (iter->InitTraversal(); !iter->IsDoneWithTraversal();
iter->GoToNextItem())
{
unsigned int flatIndex = iter->GetCurrentFlatIndex();
mapper->SetBlockVisibility(flatIndex, true);
mapper->SetBlockVisibility(flatIndex, count > nonLeafNodes);
count++;
}
}
......
......@@ -18,6 +18,7 @@
#include <vtkAMRSliceFilter.h>
#include <vtkCamera.h>
#include <vtkColorTransferFunction.h>
#include <vtkCompositeDataDisplayAttributes.h>
#include <vtkCompositePolyDataMapper2.h>
#include <vtkDataObjectTreeIterator.h>
#include <vtkDataSetSurfaceFilter.h>
......@@ -31,6 +32,7 @@
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRTAnalyticSource.h>
#include <vtkUniformGridAMRDataIterator.h>
#include <array>
......@@ -80,27 +82,43 @@ int TestAMRSliceFilterPointData(int argc, char *argv[])
mapper->SetInterpolateScalarsBeforeMapping(1);
mapper->SelectColorArray("RTData");
vtkNew<vtkCompositeDataDisplayAttributes> cdsa;
mapper->SetCompositeDataDisplayAttributes(cdsa);
int nonLeafNodes = 0;
{
vtkOverlappingAMR *oamr = vtkOverlappingAMR::SafeDownCast(
slicer->GetOutputDataObject(0));
vtkSmartPointer<vtkUniformGridAMRDataIterator> iter =
vtkSmartPointer<vtkUniformGridAMRDataIterator>::New();
iter->SetDataSet(oamr);
for (iter->InitTraversal(); !iter->IsDoneWithTraversal();
iter->GoToNextItem())
{
if (iter->GetCurrentLevel() < 2)
{
nonLeafNodes++;
}
}
}
// only show the leaf nodes
vtkCompositeDataSet *input = vtkCompositeDataSet::SafeDownCast(
mapper->GetInputDataObject(0, 0));
surface->GetOutputDataObject(0));
if (input)
{
vtkSmartPointer<vtkDataObjectTreeIterator> iter =
vtkSmartPointer<vtkDataObjectTreeIterator>::New();
iter->SetDataSet(input);
for (iter->InitTraversal(); !iter->IsDoneWithTraversal();
iter->GoToNextItem())
{
unsigned int flatIndex = iter->GetCurrentFlatIndex();
mapper->SetBlockVisibility(flatIndex, false);
}
iter->SkipEmptyNodesOn();
iter->VisitOnlyLeavesOn();
int count = 0;
for (iter->InitTraversal(); !iter->IsDoneWithTraversal();
iter->GoToNextItem())
{
unsigned int flatIndex = iter->GetCurrentFlatIndex();
mapper->SetBlockVisibility(flatIndex, true);
mapper->SetBlockVisibility(flatIndex, count > nonLeafNodes);
count++;
}
}
......
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