For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

XCAFDoc_ShapeTool losing colour after transformation

Bob Jones's picture
Forums: 

Hello,

I am using STEPCAFControl_Reader to read in a STEP file with coloured parts, when I then load these shapes and access them using SetShape(alabel) to peform a transformation on them and return them back to the assembly using SetShape(alabel, new_shape) (and then UpdateAssembly) the colour of the shape is being lost when I later use STEPCAFControl_Writer. If i avoid the transformation step then the output STEP file retains the colours correctly.

Is there an extra step I must take? Or is there a way to preform a transformation without Get/SetShape?

// Read in the shape(s) and the colours present in the STEP File
Handle_XCAFDoc_ShapeTool step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(this->interfaceDoc->Main());

// Get each shape with the part we imported
TDF_LabelSequence step_shapes;
step_shape_contents->GetShapes(step_shapes);
TopoDS_Shape shape = step_shape_contents->GetShape(step_shapes.Value(1));

gp_Trsf transformation;

transformation.SetTranslation(gp_Vec(xOffset, yOffset, zOffset));
TopoDS_Shape transformed_shape = BRepBuilderAPI_Transform(shape, transformation);
step_shape_contents->SetShape(step_shapes.Value(1), transformed_shape);

step_shape_contents->UpdateAssembly(step_shapes.Value(1));