Commit aec29ce8 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

vtkAttributeDataReductionFilter speed up data copying.

Using faster API to copy tuples between two DataSetAttributes instances.
parent 7f3b3871
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "vtkSmartPointer.h" #include "vtkSmartPointer.h"
#include "vtkTable.h" #include "vtkTable.h"
#include <cassert>
#include <vector> #include <vector>
vtkStandardNewMacro(vtkAttributeDataReductionFilter); vtkStandardNewMacro(vtkAttributeDataReductionFilter);
...@@ -135,16 +136,14 @@ static void vtkAttributeDataReductionFilterReduce(vtkDataSetAttributes* output, ...@@ -135,16 +136,14 @@ static void vtkAttributeDataReductionFilterReduce(vtkDataSetAttributes* output,
std::vector<vtkDataSetAttributes*> inputs, vtkAttributeDataReductionFilter* self) std::vector<vtkDataSetAttributes*> inputs, vtkAttributeDataReductionFilter* self)
{ {
int numInputs = static_cast<int>(inputs.size()); int numInputs = static_cast<int>(inputs.size());
assert(numInputs > 0);
vtkDataSetAttributes::FieldList fieldList(numInputs);
fieldList.InitializeFieldList(inputs[0]);
vtkDataSetAttributes* input0 = inputs[0]; vtkDataSetAttributes* input0 = inputs[0];
vtkIdType numTuples = inputs[0]->GetNumberOfTuples(); vtkIdType numTuples = input0->GetNumberOfTuples();
for (int cc = 1; cc < numInputs; ++cc) vtkDataSetAttributes::FieldList fieldList;
for (vtkDataSetAttributes* dsa : inputs)
{ {
vtkDataSetAttributes* dsa = inputs[cc];
// Include only field that have any arrays // Include only field that have any arrays
if (dsa->GetNumberOfArrays() > 0 && dsa->GetNumberOfTuples() == numTuples) if (dsa->GetNumberOfArrays() > 0 && dsa->GetNumberOfTuples() == numTuples)
{ {
...@@ -154,10 +153,7 @@ static void vtkAttributeDataReductionFilterReduce(vtkDataSetAttributes* output, ...@@ -154,10 +153,7 @@ static void vtkAttributeDataReductionFilterReduce(vtkDataSetAttributes* output,
output->CopyGlobalIdsOn(); output->CopyGlobalIdsOn();
output->CopyAllocate(fieldList, numTuples); output->CopyAllocate(fieldList, numTuples);
// Copy 0th data over first. // Copy 0th data over first.
for (vtkIdType idx = 0; idx < numTuples; ++idx) fieldList.CopyData(0, input0, 0, numTuples, output, 0);
{
output->CopyData(fieldList, input0, 0, idx, idx);
}
self->UpdateProgress(0.1); self->UpdateProgress(0.1);
double progress_offset = 0.1; double progress_offset = 0.1;
......
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