[vtkusers] vtkAppendFilter not handling lookup tables

bengt at ctech.com bengt at ctech.com
Wed Oct 25 18:06:10 EDT 2017


Hi!

Take a look at the following code, why is the lookup table resulting
from a merge not copied? Number of inputs added doesn't seem to
matter. 
Is that intentional or is it an oversight?

Thanks!

vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();

points->SetNumberOfPoints(3);

points->SetPoint(0, 0.0, 0.0, 0.0);

points->SetPoint(1, 1.0, 0.0, 0.0);

points->SetPoint(2, 0.5, 1, 0.0);

vtkIdType cellIds[3] = { 0, 1, 2 };

vtkSmartPointer<vtkCellArray> cells =
vtkSmartPointer<vtkCellArray>::New();

cells->InsertNextCell(3, cellIds);

vtkSmartPointer<vtkLookupTable> lut =
vtkSmartPointer<vtkLookupTable>::New();

lut->SetRange(0, 1);

vtkSmartPointer<vtkIntArray> testPointData =
vtkSmartPointer<vtkIntArray>::New();

testPointData->SetName("TestPointData");

testPointData->SetLookupTable(lut);

testPointData->InsertNextValue(0);

testPointData->InsertNextValue(1);

testPointData->InsertNextValue(2);
    

assert(ugrid->GetCellData()->GetArray("TestCellData") != nullptr);

assert(ugrid->GetCellData()->GetArray("TestCellData")->GetLookupTable()
!= nullptr);

vtkSmartPointer<vtkUnstructuredGrid> ugrid =
vtkSmartPointer<vtkUnstructuredGrid>::New();

ugrid->SetPoints(points);

ugrid->SetCells(VTK_TRIANGLE, cells);

ugrid->GetPointData()->AddArray(testPointData);

vtkSmartPointer<vtkAppendFilter> append =
vtkSmartPointer<vtkAppendFilter>::New();

append->AddInputData(ugrid);

append->Update();

vtkUnstructuredGrid* outgrid = append->GetOutput();

assert(outgrid->GetNumberOfCells() == 1);

assert(outgrid->GetNumberOfPoints() == 3);

assert(outgrid->GetPointData()->GetNumberOfArrays() == 1);

assert(outgrid->GetPointData()->GetArray("TestPointData") != nullptr);

vtkLookupTable* outLut = outgrid->GetLookupTable();
    


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171025/db7977fb/attachment.html>


More information about the vtkusers mailing list