vtkPlaneSources as faces for vtkCubeSource

Hello

I want to streamline a plane source in each of the faces of a cube source. The objective is to have a rectangular grid which I can use to paint some scalars. I need control on the resolution, but in theory each axis keeps the same resolution (same resolution for all xs, same for all ys, etc). Also, the cube source controls the dimensions.

This is probably too complicated and there is an easier way to achieve, but I can’t think of any other easy way to do it than manually decimate the cube source itself. This last option does not preserve the axis resolution and does not preserve the rectangular grid.

At the end, I expect a polydata with painted faces (A cube with scalars in its surface with a defined resolution per axis) to be displayed in my js scene. Obviously the scalars will vary with some interactions, therefore, generating several polygons is not optimal.

Is there some easier way to achieve this?

Adding more, I have tried so far the following

function buildTestModelSource()
    {
        let appendPolyData = vtkAppendPolyData.newInstance();
        const dimensions = [30, 30, 20]; // cm
        const translation = [0, 0, -20]; // translation to patient model center

        // Plane -Z
        const PlaneZ1Data = {
            xResolution: 300,
            yResolution: 300,
            origin: [-dimensions[0] / 2 + translation[0], -dimensions[1] / 2 + translation[1], -dimensions[2] / 2 + translation[2]],
            point1: [dimensions[0] / 2 + translation[0], -dimensions[1] / 2 + translation[1], -dimensions[2] / 2 + translation[2]],
            point2: [-dimensions[0] / 2 + translation[0], dimensions[1] / 2 + translation[1], -dimensions[2] / 2 + translation[2]],
            pointType: 'Float64Array'
        };
        let PlaneZ1 = vtkPlaneSource.newInstance(PlaneZ1Data);
        appendPolyData.addInputData(PlaneZ1.getOutputData());

        // Plane +Z
        const PlaneZ2Data = {
            xResolution: 300,
            yResolution: 300,
            origin: [-dimensions[0] / 2 + translation[0], -dimensions[1] / 2 + translation[1], dimensions[2] / 2 + translation[2]],
            point1: [-dimensions[0] / 2 + translation[0], dimensions[1] / 2 + translation[1], dimensions[2] / 2 + translation[2]],
            point2: [dimensions[0] / 2 + translation[0], -dimensions[1] / 2 + translation[1], dimensions[2] / 2 + translation[2]],
            pointType: 'Float64Array'
        };
        let PlaneZ2 = vtkPlaneSource.newInstance(PlaneZ2Data);
        appendPolyData.addInputData(PlaneZ2.getOutputData());

        // Plane -X
        const PlaneX1Data = {
            xResolution: 200,
            yResolution: 300,
            origin: [-dimensions[0] / 2 + translation[0], -dimensions[1] / 2 + translation[1], -dimensions[2] / 2 + translation[2]],
            point1: [-dimensions[0] / 2 + translation[0], dimensions[1] / 2 + translation[1], -dimensions[2] / 2 + translation[2]],
            point2: [-dimensions[0] / 2 + translation[0], -dimensions[1] / 2 + translation[1], dimensions[2] / 2 + translation[2]],
            pointType: 'Float64Array'
        };
        let PlaneX1 = vtkPlaneSource.newInstance(PlaneX1Data);
        appendPolyData.addInputData(PlaneX1.getOutputData());

        // Plane +X
        const PlaneX2Data = {
            xResolution: 200,
            yResolution: 300,
            origin: [dimensions[0] / 2 + translation[0], -dimensions[1] / 2 + translation[1], -dimensions[2] / 2 + translation[2]],
            point1: [dimensions[0] / 2 + translation[0], -dimensions[1] / 2 + translation[1], dimensions[2] / 2 + translation[2]],
            point2: [dimensions[0] / 2 + translation[0], dimensions[1] / 2 + translation[1], -dimensions[2] / 2 + translation[2]],
            pointType: 'Float64Array'
        };
        let PlaneX2 = vtkPlaneSource.newInstance(PlaneX2Data);
        appendPolyData.addInputData(PlaneX2.getOutputData());

        // Planes -Y and +Y are not used
        appendPolyData.setOutputPointsPrecision(0);
        return appendPolyData.getOutputData();
    }

Which draws the Box, but it does not allow me to draw the scalars as it doesn’t define the polys (cells).
I get Uncaught TypeError: Cannot read properties of undefined (reading 'getCellType')

I have to pass it through a filter to get the proper polydata

let smoother = vtk.Filters.Core.vtkPolyDataNormals.newInstance();
let model = buildTestModelSource();
model.buildCells();
model.buildLinks();
smoother.setInputData(model);
mapper.setInputConnection(smoother.getOutputPort());

And now it works. Really hard for something that should be easy.