vtkAppendPolyData does not include the scalar information

Hello,

I am tryng to append two polydatas with scalar info so according to the class information if both have scalar information the output should also include it. But i am trying it of many ways and the results does not include colour in the polydata. I wonder if it is a bug or someone has the same problem. If I render it separatelly without append the colour is ok but with append no colour is added, Thanks

vtkSmartPointer<vtkIntArray> colors1 =
	vtkSmartPointer<vtkIntArray>::New();
colors1->SetNumberOfComponents(1);
  colors1->SetNumberOfTuples
    (LineAxisThroughImplant->
 GetNumberOfPoints());
colors1->SetName("Colors1");
colors1->FillComponent(0, 100);


vtkSmartPointer<vtkIntArray> colors2 =
	vtkSmartPointer<vtkIntArray>::New();
colors2->SetNumberOfComponents(1);
colors2->
  SetNumberOfTuples
  (contour_implant->GetNumberOfPoints());
colors2->SetName("Colors2");
colors2->FillComponent(0, 255);

LineAxisThroughImplant->
   GetPointData()->AddArray(colors1);
LineAxisThroughImplant->
   GetPointData()->AddArray(colors2);
LineAxisThroughImplant->
   GetPointData()->SetScalars(colors1);
LineAxisThroughImplant->
   GetPointData()->
  SetActiveScalars("Colors1");
LineAxisThroughImplant
   ->GetPointData()->Modified();

contour_implant->
   GetPointData()->AddArray(colors2);
contour_implant->
 GetPointData()->AddArray(colors1);
contour_implant->
GetPointData()->SetScalars(colors2);
contour_implant->GetPointData()->SetActiveScalars("Colors2");
contour_implant->Modified();

vtkNew<vtkAppendPolyData>    
   AppendPolyData;
AppendPolyData->
AddInputData(contour_implant);
AppendPolyData->
AddInputData(LineAxisThroughImplant);
AppendPolyData->Update();

I have also tried with tuples but without success

  double red[3] = { 255,0,0 };
  vtkSmartPointer<vtkIntArray> colors1 =
	vtkSmartPointer<vtkIntArray>::New();
  colors1->SetNumberOfComponents(3);
colors1->
  SetNumberOfTuples
 (LineAxisThroughImplant->   
  GetNumberOfPoints());
colors1->SetName("Colors1");



vtkSmartPointer<vtkIntArray> colors2 =
	vtkSmartPointer<vtkIntArray>::New();
colors2->SetNumberOfComponents(3);
colors2->SetNumberOfTuples(contour_implant->GetNumberOfPoints());
colors2->SetName("Colors2");

for (int i = 0; i < contour_implant->GetNumberOfPoints(); i++)
	colors2->SetTuple(i,red);

for (int i = 0; i < LineAxisThroughImplant
  ->GetNumberOfPoints(); i++)
	colors1->SetTuple(i, red);

LineAxisThroughImplant
 ->GetPointData()->AddArray(colors1);
LineAxisThroughImplant->
      GetPointData()->SetScalars(colors1);
LineAxisThroughImplant->
 GetPointData()->
 SetActiveScalars("Colors1");
LineAxisThroughImplant->
  GetPointData()->Modified();

contour_implant->
 GetPointData()->
 AddArray(colors2);
contour_implant
   ->GetPointData()->SetScalars(colors2);
contour_implant->
 GetPointData()->SetActiveScalars("Colors2");
contour_implant->Modified();

I believe only arrays with the same names are included in the result. Hope that helps.

Please check that both arrays (“Colors1” & “Colors2”) are correctly copied in the output mesh. If so, make sure that one of those is tagged as the Scalars array (I suspect it is not the case).