Commit 3391d39e authored by Allison Vacanti's avatar Allison Vacanti

Replace some old composite dataset iterator code with the new style.

parent 53caad7c
......@@ -16,8 +16,9 @@
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataPipeline.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataSetRange.h"
#include "vtkDataSet.h"
#include "vtkImplicitFunction.h"
#include "vtkInformation.h"
......@@ -33,7 +34,6 @@
#include <cmath>
#include "vtkObjectFactory.h"
#include "vtkCompositeDataIterator.h"
#include "vtkSmartPointer.h"
#include <cassert>
......@@ -108,17 +108,16 @@ int vtkCompositeCutter::RequestUpdateExtent(vtkInformation *, vtkInformationVect
std::vector<int> intersected;
vtkCompositeDataSet * meta= vtkCompositeDataSet::SafeDownCast(inInfo->Get(vtkCompositeDataPipeline::COMPOSITE_DATA_META_DATA()));
vtkSmartPointer<vtkCompositeDataIterator> iter;
iter.TakeReference(meta->NewIterator());
iter->SetSkipEmptyNodes(false);
for(iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
for (auto node : vtk::Range(meta))
{
double* bb = iter->GetCurrentMetaData()->Get(vtkDataObject::BOUNDING_BOX());
vtkInformation *info = node.GetMetaData();
double* bb = info->Get(vtkDataObject::BOUNDING_BOX());
for (int c=0; c < this->ContourValues->GetNumberOfContours(); c++)
{
if(IntersectBox(this->GetCutFunction(),bb,this->ContourValues->GetValue(c)))
{
intersected.push_back(iter->GetCurrentFlatIndex());
intersected.push_back(static_cast<int>(node.GetFlatIndex()));
break;
}
}
......@@ -141,16 +140,13 @@ int vtkCompositeCutter::RequestData(vtkInformation *request,
return Superclass::RequestData(request,inputVector,outputVector);
}
vtkSmartPointer<vtkCompositeDataIterator> itr;
itr.TakeReference(inData->NewIterator());
itr->SetSkipEmptyNodes(true);
vtkNew<vtkAppendPolyData> append;
int numObjects(0);
itr->GoToFirstItem();
while(!itr->IsDoneWithTraversal())
using Opts = vtk::CompositeDataSetOptions;
for (vtkDataObject *dObj : vtk::Range(inData, Opts::SkipEmptyNodes))
{
vtkDataSet* data = vtkDataSet::SafeDownCast(itr->GetCurrentDataObject());
vtkDataSet* data = vtkDataSet::SafeDownCast(dObj);
assert(data);
inInfo->Set(vtkDataObject::DATA_OBJECT(),data);
vtkNew<vtkPolyData> out;
......@@ -158,7 +154,6 @@ int vtkCompositeCutter::RequestData(vtkInformation *request,
this->Superclass::RequestData(request,inputVector,outputVector);
append->AddInputData(out);
numObjects++;
itr->GoToNextItem();
}
append->Update();
......
......@@ -17,9 +17,10 @@
#include "vtkCell.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkCompositeDataIterator.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataSetRange.h"
#include "vtkDataSet.h"
#include "vtkDataObjectTreeRange.h"
#include "vtkDoubleArray.h"
#include "vtkElevationFilter.h"
#include "vtkFloatArray.h"
......@@ -1742,14 +1743,15 @@ int vtkPlaneCutter::RequestData(vtkInformation* vtkNotUsed(request),
else if(hdInput)
{
mb->CopyStructure(hdInput);
vtkSmartPointer<vtkCompositeDataIterator> iter;
iter.TakeReference(hdInput->NewIterator());
iter->SkipEmptyNodesOn();
int ret = 0;
unsigned int treeIndex = 0;
for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
using Opts = vtk::CompositeDataSetOptions;
for (auto node : vtk::Range(hdInput, Opts::SkipEmptyNodes))
{
vtkDataSet* hdLeafInput = vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
vtkDataSet* hdLeafInput = vtkDataSet::SafeDownCast(node.GetDataObject());
vtkNew<vtkMultiPieceDataSet> output;
vtkSphereTree* tree = nullptr;
if (this->BuildTree)
......@@ -1762,7 +1764,7 @@ int vtkPlaneCutter::RequestData(vtkInformation* vtkNotUsed(request),
treeIndex++;
}
ret += this->ExecuteDataSet(hdLeafInput, tree, output);
mb->SetDataSet(iter, output);
node.SetDataObject(mb, output);
}
return ret;
}
......@@ -1926,11 +1928,12 @@ int vtkPlaneCutter::ExecuteDataSet(vtkDataSet* input, vtkSphereTree* tree, vtkMu
// Generate normals across all points if requested
if (this->ComputeNormals)
{
vtkSmartPointer<vtkCompositeDataIterator> iter;
iter.TakeReference(output->NewIterator());
for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
using Opts = vtk::DataObjectTreeOptions;
for (vtkDataObject *dObj : vtk::Range(output, Opts::SkipEmptyNodes |
Opts::TraverseSubTree |
Opts::VisitOnlyLeaves))
{
vtkDataSet* hdLeafOutput = vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
vtkDataSet* hdLeafOutput = vtkDataSet::SafeDownCast(dObj);
this->AddNormalArray(planeNormal, hdLeafOutput);
}
}
......
......@@ -16,8 +16,8 @@
#include "vtkCharArray.h"
#include "vtkCompositeDataProbeFilter.h"
#include "vtkCompositeDataIterator.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataSetRange.h"
#include "vtkIdList.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
......@@ -411,10 +411,10 @@ void vtkResampleToImage::ComputeDataBounds(vtkDataObject* data, double bounds[6]
bounds[0] = bounds[2] = bounds[4] = VTK_DOUBLE_MAX;
bounds[1] = bounds[3] = bounds[5] = -VTK_DOUBLE_MAX;
vtkCompositeDataIterator *iter = cdata->NewIterator();
for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
using Opts = vtk::CompositeDataSetOptions;
for (vtkDataObject *dObj : vtk::Range(cdata, Opts::SkipEmptyNodes))
{
vtkDataSet *ds = vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
vtkDataSet *ds = vtkDataSet::SafeDownCast(dObj);
if (!ds)
{
vtkGenericWarningMacro("vtkCompositeDataSet leaf not vtkDataSet. Skipping.");
......@@ -428,6 +428,5 @@ void vtkResampleToImage::ComputeDataBounds(vtkDataObject* data, double bounds[6]
bounds[2*i + 1] = vtkMath::Max(bounds[2*i + 1], b[2*i + 1]);
}
}
iter->Delete();
}
}
......@@ -17,8 +17,8 @@
#include "vtkCellData.h"
#include "vtkCharArray.h"
#include "vtkCompositeDataProbeFilter.h"
#include "vtkCompositeDataIterator.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataSetRange.h"
#include "vtkDataObject.h"
#include "vtkDataSet.h"
#include "vtkIdList.h"
......@@ -350,11 +350,10 @@ int vtkResampleWithDataSet::RequestData(vtkInformation *vtkNotUsed(request),
this->Prober->SetSourceData(source);
vtkSmartPointer<vtkCompositeDataIterator> iter;
iter.TakeReference(input->NewIterator());
for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
using Opts = vtk::CompositeDataSetOptions;
for (auto node : vtk::Range(input, Opts::SkipEmptyNodes))
{
vtkDataSet *ds = static_cast<vtkDataSet*>(iter->GetCurrentDataObject());
vtkDataSet *ds = static_cast<vtkDataSet*>(node.GetDataObject());
if (ds)
{
this->Prober->SetInputData(ds);
......@@ -367,7 +366,7 @@ int vtkResampleWithDataSet::RequestData(vtkInformation *vtkNotUsed(request),
{
this->SetBlankPointsAndCells(block);
}
output->SetDataSet(iter, block);
node.SetDataObject(output, block);
block->Delete();
}
}
......
......@@ -2,6 +2,8 @@
#include "vtkObjectFactory.h"
#include "vtkCell.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataSetRange.h"
#include "vtkDataSet.h"
#include "vtkDoubleArray.h"
#include "vtkIdTypeArray.h"
......@@ -14,8 +16,6 @@
#include "vtkSelection.h"
#include "vtkSelectionNode.h"
#include "vtkSmartPointer.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataIterator.h"
#include <vector>
......@@ -130,14 +130,11 @@ int vtkLinearSelector::RequestData( vtkInformation* vtkNotUsed( request ),
} // if ( ! compositeInput )
// Now traverse the input
vtkCompositeDataIterator* inputIterator = compositeInput->NewIterator();
inputIterator->SkipEmptyNodesOn();
inputIterator->InitTraversal();
inputIterator->GoToFirstItem();
for ( ; ! inputIterator->IsDoneWithTraversal(); inputIterator->GoToNextItem() )
using Opts = vtk::CompositeDataSetOptions;
for (auto node : vtk::Range(compositeInput, Opts::SkipEmptyNodes))
{
// Retrieve indices of current object
vtkDataSet* input = vtkDataSet::SafeDownCast( inputIterator->GetCurrentDataObject() );
vtkDataSet* input = vtkDataSet::SafeDownCast( node.GetDataObject() );
vtkIdTypeArray* indices = vtkIdTypeArray::New();
this->SeekIntersectingCells( input, indices );
......@@ -145,7 +142,8 @@ int vtkLinearSelector::RequestData( vtkInformation* vtkNotUsed( request ),
vtkSelectionNode* n = vtkSelectionNode::New();
n->SetContentType( vtkSelectionNode::INDICES );
n->SetFieldType( vtkSelectionNode::CELL );
n->GetProperties()->Set( vtkSelectionNode::COMPOSITE_INDEX(), inputIterator->GetCurrentFlatIndex() );
n->GetProperties()->Set( vtkSelectionNode::COMPOSITE_INDEX(),
static_cast<int>(node.GetFlatIndex()) );
n->SetSelectionList( indices );
output->AddNode( n );
......@@ -154,9 +152,6 @@ int vtkLinearSelector::RequestData( vtkInformation* vtkNotUsed( request ),
indices->Delete();
}
// Clean up
inputIterator->Delete();
return 1;
}
......
......@@ -17,7 +17,7 @@
#include "vtkCommand.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataIterator.h"
#include "vtkCompositeDataSetRange.h"
#include "vtkMath.h"
#include "vtkBox.h"
#include "vtkPiecewiseFunction.h"
......@@ -429,18 +429,15 @@ double vtkCellPicker::IntersectActorWithLine(const double p1[3],
vtkCompositeDataSet::SafeDownCast(mapper->GetInputDataObject(0,0));
if ( composite )
{
vtkSmartPointer<vtkCompositeDataIterator> iter;
iter.TakeReference( composite->NewIterator() );
for (iter->InitTraversal();
!iter->IsDoneWithTraversal();
iter->GoToNextItem())
using Opts = vtk::CompositeDataSetOptions;
for (auto node : vtk::Range(composite, Opts::SkipEmptyNodes))
{
vtkDataSet* ds = vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
vtkDataSet* ds = vtkDataSet::SafeDownCast(node.GetDataObject());
if (!ds)
{
vtkDebugMacro(<< "Skipping "
<< iter->GetCurrentDataObject()->GetClassName()
<< " block at index "<< iter->GetCurrentFlatIndex()
<< node.GetDataObject()->GetClassName()
<< " block at index " << node.GetFlatIndex()
<< ": not a dataset");
continue;
}
......@@ -475,7 +472,7 @@ double vtkCellPicker::IntersectActorWithLine(const double p1[3],
{
tMin = t;
flatIndex = iter->GetCurrentFlatIndex();
flatIndex = node.GetFlatIndex();
data = ds;
locator = loc;
......
......@@ -798,11 +798,11 @@ double* vtkGlyph3DMapper::GetBounds()
}
vtkBoundingBox bbox;
vtkCompositeDataIterator* iter = cd->NewIterator();
for (iter->InitTraversal(); !iter->IsDoneWithTraversal();
iter->GoToNextItem())
using Opts = vtk::CompositeDataSetOptions;
for (vtkDataObject *dObj : vtk::Range(cd, Opts::SkipEmptyNodes))
{
ds = vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
ds = vtkDataSet::SafeDownCast(dObj);
if (ds)
{
double tmpBounds[6];
......@@ -811,9 +811,8 @@ double* vtkGlyph3DMapper::GetBounds()
}
}
bbox.GetBounds(this->Bounds);
iter->Delete();
return this->Bounds;
return this->Bounds;
}
//-------------------------------------------------------------------------
......
......@@ -19,6 +19,7 @@
#include "vtkCompositeDataDisplayAttributes.h"
#include "vtkCompositeDataIterator.h"
#include "vtkCompositeDataSet.h"
#include "vtkCompositeDataSetRange.h"
#include "vtkDataObjectTree.h"
#include "vtkDataObjectTreeIterator.h"
#include "vtkHardwareSelector.h"
......@@ -335,12 +336,13 @@ void vtkOpenGLGlyph3DMapper::Render(vtkRenderer *ren, vtkActor *actor)
blockAct->SetProperty(blockProp.GetPointer());
double origColor[4];
blockProp->GetColor(origColor);
vtkCompositeDataIterator* iter = cd->NewIterator();
for (iter->InitTraversal(); !iter->IsDoneWithTraversal();
iter->GoToNextItem())
using Opts = vtk::CompositeDataSetOptions;
for (auto node : vtk::Range(cd, Opts::SkipEmptyNodes))
{
auto curIndex = iter->GetCurrentFlatIndex();
auto currentObj = iter->GetCurrentDataObject();
auto curIndex = node.GetFlatIndex();
auto currentObj = node.GetDataObject();
// Skip invisible blocks and unpickable ones when performing selection:
bool blockVis =
(this->BlockAttributes && this->BlockAttributes->HasBlockVisibility(currentObj)) ?
......@@ -352,7 +354,7 @@ void vtkOpenGLGlyph3DMapper::Render(vtkRenderer *ren, vtkActor *actor)
{
continue;
}
ds = vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
ds = vtkDataSet::SafeDownCast(currentObj);
if (ds)
{
if (selector)
......@@ -372,7 +374,6 @@ void vtkOpenGLGlyph3DMapper::Render(vtkRenderer *ren, vtkActor *actor)
this->Render(ren, blockAct.GetPointer(), ds);
}
}
iter->Delete();
}
if (selector)
......
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