Can not Get the name of TDF_Label object by OCAF

hi, every one, I Ihave some questions to ask you guys! I use OCAF to read Igs File, some problem occured when i get the name of TDF_Label. if aLabel is not Assembly,the name can Get correctly, if aLabel is subLabel, the name get is display like "=>[0:1:1:5]", so I am confused, hope someone can help me,Thanks in advance! here the code and igs file attachment as follow:

BOOL REx3dDoc::ReadIgs(LPCTSTR lpszFile)

{

USES_CONVERSION;

Standard_CString strFileName = T2A(lpszFile);

 

IGESCAFControl_Reader Reader; 

IFSelect_ReturnStatus readstatus = Reader.ReadFile(strFileName); 

if (readstatus != IFSelect_RetDone) {

return FALSE;

}

 

//transfer doc

if (!Reader.Transfer(m_myStdDoc)) {

return FALSE;

 

//Get Shape Tool

m_myAssembly = XCAFDoc_DocumentTool::ShapeTool(m_myStdDoc->Main());

 

TDF_LabelSequence labels;

m_myAssembly->GetShapes(labels);

 

Standard_Integer iLen = labels.Length();

 

for (Standard_Integer i=1; i<=iLen; i++)

{

TDF_Label aLabel = labels.Value(i);

CollectShapeInfo(aLabel);

}

}

 

 

 

 

void REx3dDoc::CollectShapeInfo(TDF_Label aLabel)

{

if (m_myAssembly->IsAssembly(aLabel))

{

TDF_LabelSequence subLabels;

m_myAssembly->GetComponents(aLabel, subLabels);

int iLen = subLabels.Length();

for (Standard_Integer i=1; i<=iLen; i++)

{

    TDF_Label subLabel = subLabels.Value(i);

    CollectShapeInfo(subLabel);

}

}

else

{

//Get label name

Handle(TDataStd_Name) N;

if (!aLabel.FindAttribute(TDataStd_Name::GetID(), N)){

return;

}

TCollection_ExtendedString name = N->Get();

//if aLabel is not Assembly,the name can Get correct, if aLabel is subLabel, the name is display like "=>[0:1:1:5]", i am so confused.

CString sName = name.ToWideString();

        }

}

 

Attachments: 
Kirill Gavrilov's picture

Name like "=>[0:1:1:5]" means that the Label has no name at all assigned during shape import (e.g. it is empty within IGES file or there is some bug within IGES translator).
"=>[0:1:1:5]" is generated from TDF_Label identifier in case if XCAFDoc_ShapeTool::SetAutoNaming() is enabled (which is, by default) - otherwise FindAttribute() would return FALSE in your case.

XCAF may have different names attached to a Product and Instance of the Product in the document, which you can see on attached CAD Assistant 1.1 screenshots ("Assembly name format" in Main options controls which name to show).
For retrieving a Product name, you need to use a Label returned by XCAFDoc_ShapeTool::GetReferredShape() method (in case, if it is different).

JIN JIN's picture

Krill, Thanks for your help!

I checked the aerofoil_product.igs, found it has the sublabel instance name(see the attachment aerofoil_igs.jpg), so maybe there is some bug within IGES translator in OCC.

The aerofoil_product.igs is saved by CATIA, here I want to get all the instance name of part and assembly in aerofoil_product.igs, Do you have any other way to get them by OCC?

Attachments: 
Kirill Gavrilov's picture

If you think, that there is a bug - it is better reporting an issue on Bugtracker:
https://dev.opencascade.org/index.php?q=home/get_involved

I'm not an IGES expert, so I don't know if it is bug in OCCT or something wrong within IGES file itself.

JIN JIN's picture

OK,Thank you for your suggestion!

Best Regards!