Shape decomposition

Hi all,

I need selection of parts of geometric primitives (e. g. if I have a box, I need to be able to select the faces or edges individually). AFAIK I need an AIS_Shape for this purpose. My BoxDriver (similar to the drivers in SampleOCAF) creates a TopoDS_Shape and I don't know how to retrieve it.
The display is done through:

Handle(TPrsStd_AISPresentation) prs = TPrsStd_AISPresentation::Set(
L, TNaming_NamedShape::GetID());

prs->SetColor(Quantity_NOC_GOLDENROD);
prs->Display(1);

I do not seem to be able to select any one part of the box, although I set the selection mode of the viewer correctly.

Does anyone know how to achieve the things I need?

Thanks in advance.

Björn

try to open a local context with AIS_InteractiveContext::OpenLocalContext();

bjoernh's picture

Dear Christophe,

thanks for your reply. As described in the documentation, I tried to open a local context using the default arguments (shape decomposition). Still I wouldn't be able to select a single face, only the entire box.

Björn

mbd's picture

Hi,

First, you open a local context : myAIScontext->OpenLocalContext();

Then you activate face selection mode : myAISContext->Activate (AnAISObject, aMode).

aMode is an index representing the kind of shape you want to detect. For faces, aMode is 4.

0 - Shape
1 - Vertex
2 - Edge
3 - Wire
4 - Face
5 - Shell
6 - Solid
7 - Compsolid
8 - Compound

mbd

bjoernh's picture

So far I had used myAIScontext->SetSelectionMode(...)
What is the difference between Activate and SetSelectionMode?

Björn

Francois Lauzon's picture

Hi Björn,
all the difference and much more is explained in the Visualization Manual of Open Cascade (visu.pdf), have a look!

Francois.