Single Entities with XCAF

Hello,

I try to import some special entities from an IGES-file. I would like to dispaly them as individual elements. But with the following methode I get only one big element:

Handle(TDocStd_Application) anApp = XCAFApp_Application::GetApplication();
Handle(TDocStd_Document) aDoc;
anApp->NewDocument ("XmlXCAF", aDoc);

IGESCAFControl_Reader aReader;
IFSelect_ReturnStatus aStatus = aReader.ReadFile ((char*)fileName.c_str());

TopoDS_Shape shape;
if (aStatus == IFSelect_RetDone)
{
Standard_Boolean aRes = aReader.Transfer (aDoc);
shape=aReader.OneShape();
if(!aRes)
{
cout }
}

Does anyone knows how can I do that?

Futhermore, I display the element(s) like this:
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 Handle(TPrsStd_AISPresentation) prs;
if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) )
{
Handle_TPrsStd_AISPresentation prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
prs->Display(Standard_True);
qsViewer->getContext()->Display(prs->GetAIS());
}
}

I call this methode after every new element. Is it a good way?

Thanks and regards,
Franz

Franz Engel's picture

O.k. I will answer by my own. With the following code I import the detached entities from an IGES:
IGESCAFControl_Reader reader;
IFSelect_ReturnStatus aStatus = reader.ReadFile ((char*)fileName.c_str());

const Handle(XSControl_WorkSession)& theSession = reader.WS();
const Handle(Interface_InterfaceModel)& theModel = theSession->Model();
const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader();
const Handle(Transfer_TransientProcess)& tp = aReader->TransientProcess();

Standard_Integer nb = theModel->NbEntities();
TopoDS_Shape retShape;
IGESToBRep_BasicCurve basicCurve;
basicCurve.Init();

IGESToBRep_BRepEntity rep;
rep.Init();

TopTools_SequenceOfShape listOfShapes;

Handle_TopTools_HSequenceOfShape shapes= new TopTools_HSequenceOfShape();

std::string pointName;

for(Standard_Integer i=1; i<=nb; i++)
{
Handle(IGESData_IGESEntity) ent = Handle(IGESData_IGESEntity)::DownCast(theModel->Value(i));

if (ent.IsNull()) continue;
if (ent->HasName() || ent->IGESType().Type()==116)
{

reader.ClearShapes () ;
bool isTransfered=reader.TransferEntity(ent);
TopoDS_Shape retShape=reader.OneShape();

TDF_Label lab1 = XCAFDoc_DocumentTool::ShapeTool (this->mainXcafDocument->Main ())->NewShape();
TDataStd_Name::Set(lab1, ent->NameValue()->String().ToCString());

XCAFDoc_DocumentTool::ShapeTool (this->mainXcafDocument->Main ())->SetShape(lab1, retShape);
}
else {}
}

Franz Engel's picture

Hi,

With that code, I have the problem that the detached entities are not transfered. I see in the IGES-code that every of my 116 entities has an link to a transfer matrix. But with my import that matrix gets no notice.
Does somebody knows what I have to do?

regards,
Franz