STEP Colours Regression/Change

Hello everybody,

we have created a step file with colours in SolidWorks. When we use OCC dependent software to import that file (i.e. FreeCAD and GMSH) the reported colours are different to what we expect (e.g. 232/113/8 becomes 206/42/1). The colours in the step file have the correct values in the file. If we use old FreeCAD/GMSH versions the reported colours are correct. Oddly, the value 255 for any colour is not affected.

FreeCAD 0.17 (OCC 7.2) -> as expected
FreeCAD 0.18 (OCC 7.3) -> as expected
FreeCAD 0.19 (OCC 7.5) -> not as expected
GMSH 4.6/4.7 (OCC 7.4?) -> as expected
GMSH 4.8.4 (OCC 7.5?) -> not as expected

So I believe this change was somewhere >= OCC 7.5

Has there been introduced some mapping or is there something in the STEP standard? Otherwise I believe this is a bug.

Best,
Johannes

Kirill Gavrilov's picture

Hello Johannes.

OCCT 7.5.0 introduced changes in treating RGB color space conversion, which affected Quantity_Color class, file Import/Export routines (STEP, IGES, OBJ and others) and 3D Viewer.
These changes have to be considered at application level while upgrading to new version of OCCT as described in Upgrade Guide.

The main objective of these changes in OCCT is handling of sRGB / linear RGB conversion for proper color reproduction.
STEP standard does not clarifies details upon RGB color space, so that OCCT considers values to be stored in sRGB color space to preserve de-facto behavior of most STEP readers/writers (including older versions of OCCT itself) and converts values to linear RGB while defining Quantity_Color.

So that FreeCAD / GMSH code is expected to be updated to perform RGB/sRGB conversion in place.
The following code could be used to display color values within 0..255 range in conventional GUI controls:

Quantity_Color theColor;
double anSRgb[3] = {};
theColor.Values (anSRgb[0], anSRgb[1], anSRgb[2], Quantity_TOC_sRGB);
anSRgb[0] *= 255.0; anSRgb[1] *= 255.0; anSRgb[2] *= 255.0;

Quantity_TOC_sRGB has been introduced in OCCT 7.5.0 to help converting RGB triplet to and from sRGB, while Quantity_TOC_RGB passes RGB values as is (e.g. considers triplet to be in linear RGB space).

Regards,
Kirill

jenom's picture

Thank You very much Kirill,

this gives me a great point to start and find out, what we actually want.

Best,
Johannes