Why does the opacity get changed when using vtkLookupTable to set cell color?

Hello,blow code was used to set cell color:

void SceneObject::coloringSelectedCells() {
vtkNew nc;
auto orbg = property()->GetColor();
double originalColor[4] = { orbg[0] * 255, orbg[1] * 255, orbg[2] * 255, 1 };
auto newColor = nc->GetColor4d(“Red”).GetData();
auto const originalColorIdx = 0;
auto const newColorIdx = 1;
auto size = data()->GetNumberOfCells();

//setup scalars
vtkNew scalars;
scalars->SetNumberOfTuples(size); //LP why can’t size be 2 here?
//preserve surface color
for (vtkIdType i = 0; i < size; i++) {
scalars->SetTuple1(i, originalColorIdx);
}

//set cell color
for (auto const id : selectedCells) {
scalars->SetTuple1(id, newColorIdx);
}
data()->GetCellData()->SetScalars(scalars);
asActor()->GetMapper()->SetScalarRange(0, size - 1);

//setup lookup table
vtkNew lut;
lut->SetNumberOfTableValues(size);
lut->SetTableValue(originalColorIdx, originalColor);
lut->SetTableValue(newColorIdx, newColor);
// lut->SetVectorModeToRGBColors();
lut->Build();
asActor()->GetMapper()->SetLookupTable(lut);

_parent->rerender(this);
}

Strangely,opacity got changed,how to prevent opactiy change?

Hello,

Is there any reason to multiply the RGB components by 255? Those values should vary between 0.0 and 1.0. VTK is likely proportionally unitizing values greater than 1.0, so the last component, the alpha channel, rescales to 1/255, which results in a highly translucent color.

I suggest doing either:

double originalColor[4] = { orbg[0], orbg[1], orbg[2], 1 };

or

double originalColor[4] = { orbg[0] * 255, orbg[1] * 255, orbg[2] * 255, 255 };

regards,

Paulo