read colors/styles from step


New member
I am reading your example step-file wavy-cube.stp
The file has two STYLED_ITEM with name 'color':
#191 = COLOUR_RGB('',0.321568635616,0.341176475329,0.431372551983);
#206 = COLOUR_RGB('',0.745098043297,0.325490203104,0.133333336917);

my code:
STEPCAFControl_Reader Reader;
IFSelect_ReturnStatus stat = Reader.ReadFile(filename.ToCString());
// print all colors
TDF_LabelSequence colors;
for (TDF_LabelSequence::Iterator it_colors(colors); it_colors.More(); it_colors.Next())
TDF_Label label = it_colors.Value();
Quantity_ColorRGBA rgba;
_colorTool->GetColor(label, rgba);
Quantity_Color rgb = rgba.GetRGB();
Handle(TDataStd_Name) name;
label.FindAttribute(TDataStd_Name::GetID(), name);
TCollection_ExtendedString str = name->Get();
wprintf(L"%s ==>> RGBA = %.3f, %.3f, %.3f, %.3f\n", str.ToExtString(), rgb.Red(), rgb.Green(), rgb.Blue(), rgba.Alpha());
GRAY37 (#151827FF) ==>> RGBA = 0.084, 0.095, 0.156, 1.000
CHOCOLATE3 (#831604FF) ==>> RGBA = 0.515, 0.087, 0.016, 1.000

I have to questions
1) why names are changed?
2) why values of rgb are changed?


Staff member
I'd suspect you've faced one of the compatibility problems in OpenCascade, explained here:

To be brief, the devs of OpenCascade believe that the RGB components coming from a STEP file should undergo some weird sRGB conversion, and that results in the new values you're dealing with. It's hard for me to justify such a change as well as to explain it to you. I can only recommend you implementing a back conversion to the original RGB values once you have them in the Quantity_Color. Or not using XDE. Or not using OpenCascade 7.5 :D