Surface or Face level colors in OpenCascade.

Hi,

I am facing problem to get surface level colors in OpenCascade.

Here is the scenario;

I am trying to read STEP file with STEPCAFControl_Reader.
I am able to get number or all the colors available in a STEP file. Suppose i have 1 cube(STEP file) with all 6 faces with 6 different colors.
I able to get correct information about colors or color count with XCAFDoc_ColorTool.
When i traverse the step file with XCAFDoc_ShapeTool i get 1 body as TopoDS_Shape and when i get color of that body with XCAFDoc_ColorTool.

if (colorTool.GetColor(refShape, XCAFDoc_ColorType.XCAFDoc_ColorGen, ref col))
                                {
                                    colName = col.Name();
                                }
                                else if (colorTool.GetColor(refShape, XCAFDoc_ColorType.XCAFDoc_ColorSurf, ref col))
                                {
                                    colName = col.Name();
                                }

I get color of only one face (Inside else if (colorTool.GetColor(refShape, XCAFDoc_ColorType.XCAFDoc_ColorSurf, ref col))).

Now, i have 3 questions;

1. How do we know the TopoDS_Shape has surface level colors? &

2. How can we get surface level colors in a TopoDS_Shape?

3. Also i want to know how can i create a TopoDS_Shape(Single body) with multiple or differrent face level colors?

Thank you in advance.

-Vishwas.

 

 

 

vishwas.mane_144577's picture

Hello All,
Can anyone please at least suggest me a way to know if TopoDS_Shape has surface level colors or not.

Your time would be appreciated greatly in advance.
Thanks

yuanxm0220_152233's picture

encounter the the same issue, cannot know how to get the color of the relative surface . seems the interface colorTool.GetColor(refShape, XCAFDoc_ColorSurf, ref col) failed. hoping someone help too

pierre-olivier_149114's picture

I confirm that the interface colorTool.GetColor() is broken since 7.4.0 (or since 7.x.x as i was using 6.9.1). The 7.4.0 broke all my pipeline with the colours.

The following code is broken since 7.4.0 :

bool CAD_reader::queryColor(const TopoDS_Shape& shape, Quantity_Color& color)
{
	color.SetValues(0.5, 0.5, 0.5, Quantity_TOC_RGB);

	if (aColorTool->GetColor(shape, XCAFDoc_ColorGen, color))
		return true;
	else if (aColorTool->GetColor(shape, XCAFDoc_ColorCurv, color))
		return true;
	else if (aColorTool->GetColor(shape, XCAFDoc_ColorSurf, color))
		return true;

	return false;
};