
Thu, 07/13/2023 - 09:54
I found some issues when I get colors from a STEP file (I created myself with FreeCad).
The method that I use is searching for all types of colors (gen, curv, surf) and then store them in data like:
Quantity_Color color; color.SetValues(0.5, 0.5, 0.5, Quantity_TOC_RGB); XCAFDoc_ColorType colorTypes[] = { XCAFDoc_ColorType::XCAFDoc_ColorGen, XCAFDoc_ColorType::XCAFDoc_ColorCurv, XCAFDoc_ColorType::XCAFDoc_ColorSurf, }; for (const XCAFDoc_ColorType& colorType : colorTypes) { if (colorTool->GetColor(label, colorType, color)) { //Save color....
When I compare the results with the ones that I get from saving the same STEP file as OBJ with CAD Asistant:
Colors from custom implementation:
newmtl Material0 Kd 0.4019778072834015 0 1 newmtl Material1 Kd 0.06847815960645676 0.06847815960645676 0.16202938556671143 newmtl Material2 Kd 1 1 0
Colors from CAD Assistant:
newmtl Material_2 Kd 0.6666667 0 1 newmtl Material_1 Kd 0.2901961 0.2901961 0.4392157 newmtl Material_3 Kd 1 1 0
I also attached images for a better comparison.
Best regards, Lorenzo
Attachments:
Thu, 07/13/2023 - 11:23
Hello
Problem with color format. The main format for CAD Assistant is sRGB and any colours from step saved as sRGB.
Please take a look into https://dev.opencascade.org/content/occt-3d-viewer-becomes-srgb-aware
Best regards, Dmitrii.
Thu, 07/13/2023 - 11:26
I find out that XCAF don't care about which format is saved. I think we need to analyse it and improve. Thank you. I will create a issue to keep this idea.
Best regards, Dmitrii.
Thu, 07/13/2023 - 12:08
Yes seems that changing from
Quantity_TOC_RGB
toQuantity_TOC_sRGB
doesn't fix the issue.I finally get the good values using
Quantity_Color::Convert_LinearRGB_To_sRGB()
, so anyone facing a similar issue, this should work.Thanks again for your work!
Best regards, Lorenzo.
Thu, 07/13/2023 - 13:39
OBJ relies on a legacy shading model with not well-defined color definition. If you are using some own OBJ writer - make sure to convert color components, as it is done by
RWObj_CafWriter
:Your code snippets are incomplete, so fill free to share more details if problem is still unclear.
Thu, 07/13/2023 - 12:11
As stated by Dimitrii, using
GetValues
withQuantity_TOC_sRGB
, return the same values as using it withQuantity_TOC_RGB
. The last upper message that I post works as a workaround until they fix it.Best regards, Lorenzo.
Thu, 07/13/2023 - 12:21
Quantity_Color::Values(aR,aG,aB, Quantity_TOC_sRGB)
calls internallyConvert_LinearRGB_To_sRGB
. The result should be the same(in latests version of occt)Best regards, Dmitrii.
Thu, 07/13/2023 - 13:15
With
Quantity_Color::Values(aR,aG,aB, Quantity_TOC_sRGB)
seems to work as well.Thanks!
Best regards, Lorenzo.