Hide face from box shape in the view

Hi All, I am using XCAFPrs_AISObject to store main shape (the box shape) and use TDocStd_Document to store shape labels; both main shape and sub shapes. Here I saved main shape label and add faces as child as sub shapes.

Now I want to hide face from the view which is a sub shape. But I could not find any possible solution for that. There was a forum thread discussing to hide shape using AISColored_shape. But that do not work for me. https://dev.opencascade.org/content/display-how-hide-face-within-aiscolored-shape

I have tried following code snippet.

Handle(XCAFPrs_AISObject) thePrs;
Handle(AIS_ColoredDrawer) aDrawer = thePrs->CustomAspects(theSubShape);
aDrawer->SetHidden(true);        
Handle(AIS_InteractiveContext) context;
context->UpdateCurrentViewer();

It would be very helpful if anyone can help me on this.

Lahiru Dilshan's picture

See the image of code snippet here.

Attachments: 
Mikhail Sazonov's picture

This theme is offtopic for this forum. You should ask such question in https://dev.opencascade.org/forums/visualization-and-3d-viewer.

Lahiru Dilshan's picture

Sorry for that. I'll post that to correct thread.

Kirill Gavrilov's picture
Handle(XCAFPrs_AISObject) thePrs;
Handle(AIS_ColoredDrawer) aDrawer = thePrs->CustomAspects(theSubShape);
aDrawer->SetHidden(true);      

Although XCAFPrs_AISObject inherits from AIS_ColoredShape, it takes presentation parameters from XCAF document, so that sub-shape attributes manually overridden using AIS_ColoredShape::CustomAspects() will be withdrawn when XCAFPrs_AISObject will be recomputed.

Either, you need changing presentation attributes within XCAF document itself (e.g. if you want it to be preserved), or prevent overriding attributes via theToSyncStyles flag for XCAFPrs_AISObject::DispatchStyles().

Lahiru Dilshan's picture

Thank you for the reply. Your reply is highly appreciated. I have another question.
What kind of sub shape attributes in XCAF document can be used to hide or remove sub shapes from the view.