Cell data to point data

I have a strcutured grid with colored cells like this:

which shows colors based on cells data. i want to have some sort of interpolation to make it smoother and have color transition, so i set points color of my structured grid using vtkCellDataToPointData class like this:

    vtkNew<vtkStructuredGrid> grid;
    // initialize grid with desired properties


    vtkSmartPointer<vtkCellDataToPointData> cellDataToPointData = 
    vtkSmartPointer<vtkCellDataToPointData>::New();
	cellDataToPointData->SetInputData(grid);
	cellDataToPointData->PassCellDataOn(); // Specify that cell data should be passed to points
	cellDataToPointData->Update();

	vtkPointData* interpolatedPointData = cellDataToPointData->GetOutput()->GetPointData();

	// Get the output grid with interpolated point data
	grid->GetPointData()->ShallowCopy(interpolatedPointData);

so the result is like this:

comparing the results with my previous cell based coloring we can see it is correct but i think the colros is somehow vague and i feel it is not the way it should be. becasue when i use paraview i see something like this:

what is wrong with my solution. do i miss some settings or i am using wrong way to reach my expectation. also i want to know if there is a way to set the interpolation scheme when i interpolate cell colors to points in VTK?

I’m curious as to why the coloring between the VTK C++ example, and the ParaView result are different. is this a function of the lookup table used, or something else? What does your PV pipeline look like (to make sure that the data averaging is the same).

The coloring difference is due to the fact i use my own colormap system. my issue is the appearence of the final result

Okay, so what does the PV pipeline look like? Can you provide data?

this is my pipeline
vtkStructuredGrid → vtkDataSetMapper → vtkActor
for colors i use:

vtkSmartPointer<vtkUnsignedCharArray> colors = vtkSmartPointer<vtkUnsignedCharArray>::New();
colors->SetName("Colors");
colors->SetNumberOfComponents(3); // RGB
double minValue = *std::min_element(data.begin(), data.end());
double maxValue = *std::max_element(data.begin(), data.end());

auto cellsCount = data.size();

for (int i = 0; i < cellsCount; i++)
{
	double scalar = (data[i] - minValue) / (maxValue - minValue);

	unsigned char color[3];
	GetCharColor(scalar, color);

	colors->InsertNextTypedTuple(color);
}

grid->GetCellData()->SetScalars(colors);

vtkSmartPointer<vtkCellDataToPointData> cellDataToPointData = vtkSmartPointer<vtkCellDataToPointData>::New();
cellDataToPointData->SetInputData(grid);
cellDataToPointData->PassCellDataOn(); // Specify that cell data should be passed to points
cellDataToPointData->Update();

vtkPointData* interpolatedPointData = interpolator->GetOutput()->GetPointData();
	// Get the output grid with interpolated point data
grid->GetPointData()->ShallowCopy(interpolatedPointData);

and to use point data i do this:

mapper->SetScalarModeToUsePointData();

@will.schroeder Sorry, but don’t you have any advice to solve my issue?

In your vtkDataSetMapper, you probably need to call InterpolateScalarsBeforeMappingOn(). That is on by default in ParaView, off by default in VTK. I suspect that is the difference.

Thank you for your reply but i tested it and i get the same result unfortunately

Looking at the image again, the scalar values look nearly random, and the resolution is poor. Averaging this sort of data (which is what cell data to point data does) is going to produce muddy results. The graphics rendering process is also going to shade across the resulting polygons, again mushing the colors.

When i compare my two images, one for cell and one for point, i see that the point based image is actually doing right based on coloring. if i am not wrong, there is no issue from averaging point of view. the issue seems to be related to rendering.
also i was searching and i encountered vtkPointInterpolator.h. do you think this can be solution? it also have kernel concept which is also what i wanted at the first place. but couldn’t find usage examples for it actually to use it in my case.