
Wed, 04/15/2009 - 14:09
Forums:
How do I identify the class of a TDF_Attribute object read from a general OCAF document, where I don't have any prior knowledge of the document structure? I only need to deal with the attribute types built in to OCC.
I can get it's GUID easily enough, but I need to cast the handle to the appropriate underlying class? Is there a registry of TDF_Attribute types I can iterate over, to test against? Or maybe an easier method?
Wed, 04/15/2009 - 21:24
You can exploit at least two approaches. First is based on GUIDs() (what makes it difficult for you to get it, by the way ?):
Handle(TDF_Attribute) anAttr = ...;
if (anAttr->ID() == MyAttribute::GetID()) {
Handle(MyAttribute) aMyAttr = Handle(MyAttribute)::DownCast (anAttr);
}
Second is based on rtti offered by Handles:
if (anAttr->IsKind (STANDARD_TYPE (MyAttribute))) {
Handle(MyAttribute) aMyAttr = Handle(MyAttribute)::DownCast (anAttr);
}
And of course, there is always a standard way
Handle(MyAttr) aMyAttr;
if (aLab.FindAttribute (MyAttr::GetID(), MyAttr)) {
aMyAttr->....
}
Hope this helps.
Roman
---
opencascade.blogspot.com - the Open CASCADE blog
www.cadexchanger.com - CAD Exchanger, your 3D data translator
Wed, 04/15/2009 - 21:32
I think Bryan is using pythonOCC and some of the C++ idioms can be non-intuitive to map in Python.
I think this helps a lot though ( does it Bryan? )
Thanks,
-jelle