read colors/styles from step

goldv72

New member
Hello!
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;
_colorTool->GetColors(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());
}
Result:
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?
 

Quaoar

Administrator
Staff member
I'd suspect you've faced one of the compatibility problems in OpenCascade, explained here: https://dev.opencascade.org/content/occt-3d-viewer-becomes-srgb-aware

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
 
Top