Skip to content

add color values to x3d output

I'd like to be able to specify a color profile to be added to the x3d output for isoSurfaces. For example, an isoSurface of fuel fraction can colored by temperature,

flame
{
    type surfaces;
    functionObjectLibs ("libsampling.so");
    enabled         true;
    writeControl   adjustableRunTime;
    writeInterval   $...animationOutputTime;
    interpolationScheme cellPoint;
    surfaceFormat x3d;
    // Fields to be sampled
    fields
    (
            T
    );
    surfaces
    (
            flame
            {
                type            isoSurfaceCell;
                isoField        ft;
                isoValue        0.06;
                interpolate     true;
                regularise      false;
            }
     );
}

and have the actual color associated with each temperature value stored within the x3d file. I currently do this by writing out a vtk surface with the corresponding interpolated field, then piping this through pvbatch/pvpython to apply a color profile:

# get color transfer function/color map for 'T'
tLUT = GetColorTransferFunction('T')
tLUT.RGBPoints = [291.96875, 0.231373, 0.298039, 0.752941, 1033.3699340820312, 0.865003, 0.865003, 0.865003, 1774.7711181640625, 0.705882, 0.0156863, 0.14902]

# or
tLUT.ApplyPreset('heated_object', True)

This creates a cumbersome extra postProcessing step that I'd like to avoid. Ideally the user would be able to specify either a locally saved color profile or a list of RGB points and associated scalar values and then OpenFOAM would directly add the color profile to the x3d output.