For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

IGESControl_Reader - need to retreive names

Mike A's picture


I'm using IGESControl_Reader and I'm trying to retreive the names of the parts contained in the IGES file. Does anyone have any pointers/examples on how to acheive this?

I've seen posts about IGESCAFControl_Reader, but no complete answer, and I'm using the parent object type IGESControl_Reader.

Any help would be apprecieated,



Hugh Sorby's picture

Hi Mike,

I don't know all the ins and outs but extending something like this might help. First though you have to read IGESCAFControl_Reader, IGESControl_Reader only contains shape information no higher level info is stored (as far as I know). So to get started I would go with something like this:

Handle_TDocStd_Document doc = new TDocStd_Document( "MDTV-XCAF" );
IGESCAFControl_Reader reader;

if ( reader.ReadFile( fileName ) == IFSelect_RetDone )
if ( reader.Transfer( doc ) )
// now you have higher level information you can traverse the labels of the document and extract data
fishOutData( doc );

where fishOutData would look something like this:

Handle_XCAFDoc_ShapeTool shapeTool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() );

TDF_LabelSequence root_labels;
shapeTool->GetFreeShapes( root_labels );
for ( Standard_Integer i = 1; i {
TDF_Label label = root_labels.Value( i );
extractNameFromLabel( label ); // This label may have a name attached who knows?
extractEntryFromLabel( label ); // You can also pull out an entry from the label that identifies you place in the tree
TDF_Tool::Entry( aLabel, entry ); // Entry now contains a string I think something like this 0:1:1:1
labelTraversal( label )

where extractEntryFromLabel is something like:

TCollection_AsciiString entry;
TDF_Tool::Entry( aLabel, entry ); // Entry now contains a string I think something like this 0:1:1:1

and extractNameFromLabel is something like:

Handle_TDataStd_Name N;
if ( label.FindAttribute( TDataStd_Name::GetID(), N ) )
N->Get().ToUTF8CString( name );

name is a string that contains well a name possibly. Lastly you just need to traverse the labels in the tree which I do something similar to this:

// You have a label so do whatever you need with it. Get the shape or whatever

// Next have a look at sub-shapes
TDF_LabelSequence seq;
if (XCAFDoc_ShapeTool::GetSubShapes (aLabel, seq) )
for (i = 1; i labelTraversal( seq.Value( i );

// Then components
if (XCAFDoc_ShapeTool::GetComponents (aLabel, seq))
for (i = 1; i labelTraversal( label );

That's how I do it, though I haven't actually managed to extract any part names out as yet. A possibility there is because I haven't any iges files with parts that have names that I can test with. Whilst this isn't a complete answer to your problem I hope it helps. Maybe another forum member with more experience will be able to help.