TPrsStd_AISPresentation Can't Select Shape

I use STEPCAFControl_Reader read STEP file , i can import STEP file and display, however i can't detect or select shape.
This is my code:
Handle(XCAFApp_Application) anApp=XCAFApp_Application::GetApplication();
Handle(TDocStd_Document) aDoc;
anApp->NewDocument("MDTV-XCAF",aDoc);

TCollection_AsciiString aFilePath("test.STEP");
STEPCAFControl_Reader aReader;
aReader.SetColorMode(true);
aReader.SetNameMode(true);
aReader.SetLayerMode(true);
aReader.SetPropsMode(true);
IFSelect_ReturnStatus aStatus= aReader.ReadFile(aFilePath.ToCString());
if (aStatus == IFSelect_RetDone) {
Standard_Boolean aRes = aReader.Transfer (aDoc);
}

TDF_Label aRootLabel = aDoc->Main();

aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aRootLabel);
aColorTool = XCAFDoc_DocumentTool::ColorTool(aRootLabel);

TDF_Label anAccess = aDoc->GetData()->Root();

Handle(TPrsStd_AISViewer) anAISViewer;
if (!TPrsStd_AISViewer::Find (anAccess, anAISViewer)) {

anAISViewer = TPrsStd_AISViewer::New (anAccess, GetDocument()->h_Viewer);
}
// collect sequence of labels to display
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (aDoc->Main());
TDF_LabelSequence seq;
aShapeTool->GetFreeShapes (seq);
// set presentations and show
for ( Standard_Integer i=1; i <= seq.Length(); i++ ) {
Handle(TPrsStd_AISPresentation) prs;

if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) ) {
prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
prs->SetMode(1);

}
prs->Update();
prs->Display(Standard_True);
}
TPrsStd_AISViewer::Update(aDoc->GetData()->Root());
}

gkv311 n's picture

Is there any reason for using TPrsStd_AISPresentation instead of XCAFPrs_AISObject?

ZHANG JIAN's picture

I use XCAFPrs_AISObject and it works!Thanks a lot!