Commit 8eb13121 authored by Cory Quammen's avatar Cory Quammen
Browse files

vtkProbeFilter now sets active attributes when passing point and cell arrays

Active attributes were not being set in the output to match the active
attributes in the input. This patch fixes that and adds a test to see
that attribute activation in point data works as expected.
parent 6393cf96
Pipeline #6323 passed with stage
......@@ -27,6 +27,7 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestPolyDataConnectivityFilter.cxx,NO_VALID
TestProbeFilter.cxx,NO_VALID
TestProbeFilterImageInput.cxx
TestProbeFilterOutputAttributes.cxx,NO_VALID
TestResampleToImage.cxx,NO_VALID
TestSmoothPolyDataFilter.cxx,NO_VALID
TestSMPPipelineContour.cxx,NO_VALID
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestProbeFilterOutputAttributes.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This is a test to check that the active attributes are set
// appropriately in the output when passing attribute data to the
// output.
#include "vtkProbeFilter.h"
#include "vtkNew.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkProbeFilter.h"
#include "vtkRTAnalyticSource.h"
#include "vtkSphereSource.h"
#include "vtkSmartPointer.h"
//----------------------------------------------------------------------------
int TestProbeFilterOutputAttributes(int, char*[])
{
vtkNew<vtkSphereSource> sphere;
sphere->SetRadius(4.0);
static const int dim = 48;
double center[3];
center[0] = center[1] = center[2] = static_cast<double>(dim)/2.0;
int extent[6] = { 0, dim - 1, 0, dim - 1, 0, dim - 1 };
vtkNew<vtkRTAnalyticSource> imageSource;
imageSource->SetWholeExtent(extent[0], extent[1], extent[2], extent[3],
extent[4], extent[5]);
imageSource->SetCenter(center);
vtkNew<vtkProbeFilter> probe;
probe->PassPointArraysOn();
probe->SetSourceConnection(imageSource->GetOutputPort());
probe->SetInputConnection(sphere->GetOutputPort());
probe->Update();
vtkPolyData* pd = probe->GetPolyDataOutput();
vtkPointData* spherePointData = sphere->GetOutput()->GetPointData();
vtkPointData* probePointData = pd->GetPointData();
std::cout << spherePointData->GetNormals() << " " << probePointData->GetNormals() << std::endl;
if (probePointData->GetNormals() != spherePointData->GetNormals())
{
std::cout << "The normals array does not match!\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
......@@ -141,6 +141,16 @@ void vtkProbeFilter::PassAttributeData(
{
output->GetPointData()->AddArray(input->GetPointData()->GetArray(i));
}
// Set active attributes in the output to the active attributes in the input
for (int i = 0; i < vtkDataSetAttributes::NUM_ATTRIBUTES; ++i)
{
vtkAbstractArray* da = input->GetPointData()->GetAttribute(i);
if (da)
{
output->GetPointData()->SetAttribute(da, i);
}
}
}
// copy cell data arrays
......@@ -151,6 +161,16 @@ void vtkProbeFilter::PassAttributeData(
{
output->GetCellData()->AddArray(input->GetCellData()->GetArray(i));
}
// Set active attributes in the output to the active attributes in the input
for (int i = 0; i < vtkDataSetAttributes::NUM_ATTRIBUTES; ++i)
{
vtkAbstractArray* da = input->GetCellData()->GetAttribute(i);
if (da)
{
output->GetCellData()->SetAttribute(da, i);
}
}
}
if (this->PassFieldArrays)
......
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