OCAF and visualization

How does the visualization work with OCAF?

here are the steps i followed, but it doesnt work:

1. create new V3d_Viewer
2. create new V3d_View
3. create new AIS_InteractiveContext
4. create new Document
4. imported iges with IGESCAFControl_Reader

I found some hints about TPrsStd_AISViewer and TPrsStd_AISPresentation, but where to create/put them? In which lables do i need to set TPrsStd_AISPresentation?

my OCAF tree looks like this:

doc.Main[0:1]
|
|--Shape_Tool[0:1:1]
| |
| |--shape[0:1:1:1]
| | |
| | |--Attr.:TNaming_NamedShape, ..., TPrsStd_AISPresentation
| |
| |--shape[0:1:1:1]
| |
| |--Attr.:TNaming_NamedShape, ..., TPrsStd_AISPresentation
|
|--Color_Tool[0:1:2]
|
.
.
.

Thanks.

Marco Matt's picture

You need to create only once the attribute for the viewer.
Then, for each label which owns a shape attribute you set a TPrsStd_AISPresentation attribute.

Handle(TDocStd_Document) myDocument;
Handle(AIS_InteractiveContext) myAISContext;
Handle(TPrsStd_AISPresentation) myPrs;
...
TPrsStd_AISViewer::New(myDocument;>Main(), myAISContext);
...
if (!label.FindAttribute(TPrsStd_AISPresentation::GetID(), myPrs))
{
myPrs = TPrsStd_AISPresentation::Set(label, TNaming_NamedShape::GetID());
}