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

How to add multiple integer to a TDF_Label

Mimosa Olive's picture

Hi, I have a label (associated with a shape) which I give a name. I'd like to attach more than one integer to the label, each having a specific purpose of course, and I'd like to have a name associated with the integer so I can retrieve it by name later.

This is how I put a name for the label:
TDataStd_Name::Set(aLabel, "bottle");
and this would be how to add an integer (with value of 12 as example), but it appear that the label only accept one integer attribute and I cannot give this integer a name:
Handle(TDataStd_Integer) intImage = TDataStd_Integer::Set(aLabel, 12);
TDataStd_Name::Set(intImage, "image"); //this does not work..

Benjamin Bihler's picture

I cannot help you with that, but if you want to add arbitrary additional information to a label, you might want to create your own special purpose attributes for that (subclass TDF_Attribute).


Mimosa Olive's picture

Yes Benjamin, I think this would be the best, something like a struct, or even a class of my own. I will look into that. Thanks

Lincoln Nxumalo's picture


Why not attach TDataStd_ExtStringArray and TDataStd_IntegerArray attributes on the same label? What you can then do, is use your array Index to link a string in TDataStd_ExtStringArray with the corresponding integer value in  TDataStd_IntegerArray . Basically TDataStd_IntegerArray::Value(Index) will be the integer value that corresponds to string in TDataStd_ExtStringArray::Value(Index).

You'll just need to make sure you synchronize the two arrays i.e. if you add or remove an entry from one array at a certain index position, you'll need to do the same on the other array. This to me will be the easiest way to do it using standard attributes.



Lincoln Nxumalo's picture

For completeness I'll add the following:

If you want to know the integer corresponding to a certain name, you will first traverse the elements in TDataStd_ExtStringArray and locate the name you are looking for. When you've found the name, you'll note the Index value of that name in TDataStd_ExtStringArray. You will then use this Index to retrieve the corresponding integer in TDataStd_IntegerArray i.e. TDataStd_IntegerArray::Value(Index).

I hope this helps.