
Fri, 07/01/2005 - 06:19
Hello everybody,
I'm trying to import iges files in my ocaf application. And I'm using the following code.
IGESCAFControl_Reader reader;
Standard_Integer status;
status = reader.Perform(myFileName, myOcafDoc);
Then I want to view the content of the file in the viewer using the following code.
TDF_Label LabSat = myOcafDoc->Main();
for (TDF_ChildIterator it(LabSat); it.More(); it.Next())
{
TDF_Label L = it.Value();
Handle(TPrsStd_AISPresentation) prs = TPrsStd_AISPresentation::Set(L, TNaming_NamedShape::GetID());
prs->SetColor(Quantity_NOC_ORANGE);
prs->Display(1);
TDataStd_Integer::Set(L, 1);
}
Fit3DViews();
myAISContext->UpdateCurrentViewer();
But I don't see anything on the screen.
What is wrong with this code?
Can anybody help me?
Thanks,
Carmen
Fri, 07/01/2005 - 08:42
Hi,
try the following:
1) add XCAFPrs_Driver to your drivers:
Handle(XCAFPrs_Driver) myPresDriver = new XCAFPrs_Driver();
TPrsStd_DriverTable::Get();
TPrsStd_DriverTable::Get()->InitStandardDrivers();
TPrsStd_DriverTable::Get()->AddDriver(XCAFPrs_Driver::GetID(), myPresDriver);
2) for adding a shape I do the following:
Standard_Boolean Im_Presentation3DAIS::AddShape(const TDF_Label &lab)
{
if (!m_pViewerAIS.IsNull())
{
if (!m_pViewerAIS->m_pAISContext.IsNull())
{
Handle(TPrsStd_AISPresentation) TPrsPresentation;
if (! lab.FindAttribute ( TPrsStd_AISPresentation::GetID(), TPrsPresentation ) )
{
// TPrsPresentation = TPrsStd_AISPresentation::Set(lab,TNaming_NamedShape::GetID());
TPrsPresentation = TPrsStd_AISPresentation::Set(lab,XCAFPrs_Driver::GetID());
}
TPrsPresentation->SetMaterial ( Graphic3d_NOM_SATIN );
XCAFPrs::SetViewNameMode(Standard_False);
TPrsPresentation->Display(Standard_True);
if (!m_pDocRoot.IsNull())
TPrsStd_AISViewer::Update(m_pDocRoot->GetData()->Root());
return Standard_True;
}
return Standard_False;
}
return Standard_False;
HTH,
Patrik
Mon, 07/04/2005 - 15:33
Thank you,
Vasile