C++ parsing an Attribute with a SELECT data type

83 views
Skip to first unread message

Adam Gall

unread,
Apr 20, 2016, 5:28:18 PM4/20/16
to STEPcode - Developers Mailing List
Hello,

I'm writing a C++/CLI wrapper for interacting with STEPCode from a .NET application. What I'm looking to do is parse an AP214 STEP file, and return a list of entities with their attributes. This is going well for the most part, but I'm a bit stuck on how to get the underlying data out of a SELECT_TYPE attribute.

Below is a snippet of my method for parsing an attribute. I can identity from select->ValueType() if the SELECT is (for example) representing an entity, but I am not sure how to get the SDAI_Application_instance reference from this point? I understand that SDAI_Select is an abstract base class, but there seems no way to identify the sub class type.

void AttributeWrapper::CreateAttributeValue(STEPattribute * original) {
    switch (original->NonRefType()) {
        case INTEGER_TYPE:
            integerValue = (int)attribute->Integer();
            break;
        case REAL_TYPE:
            realValue = (double)*attribute->Real();
            break;
        case NUMBER_TYPE:
            numberValue = (double)*attribute->Number();
            break;
        case STRING_TYPE:
        {
            string value;
            SDAI_String* sdaiString = attribute->String();
            stringValue = marshal_as<String^>(sdaiString->asStr(value));
            break;
        }
        case ENTITY_TYPE:
        {
            SDAI_Application_instance* stepEntity = original->Entity();

            const EntityDescriptor* descriptor = stepEntity->getEDesc();
            String^ entityType = gcnew String(descriptor->Name());
            entityValue = gcnew EntityWrapper(stepEntity->GetFileId(), entityType, &stepEntity->attributes);
            break;
        }
        case SELECT_TYPE:
        {
            SDAI_Select* select = original->Select();
            BASE_TYPE selectType = select->ValueType();
 
            if (selectType == ENTITY_TYPE) {
               // How do I get the Entity?
            }
            break;
        }

        ... other data types...
    }
}

Any help would be appreciated. Feel free to correct me if I'm misunderstanding anything, I've only been working with STEP for the past week!

Thanks,
Adam

Anton Shabalin

unread,
Apr 21, 2016, 5:17:34 AM4/21/16
to STEPcode - Developers Mailing List
Hi Adam,

I believe that you can just reinterpret your SDAI_Select type to STEPentity.
Look an example: 

 if (cf_entity->IsA(e_plane_angle_measure_with_unit))
                {
                    auto val_comp = GetAttribute(cf_entity, "value_component");

                    SdaiMeasure_value *v = (SdaiMeasure_value *)val_comp->Select();
                    std::string vc_type = v->CurrentUnderlyingType()->Name();

                    if (v->IsPlane_angle_measure() == LTrue)
                    {
                        angle_factor = (double)*v;                        
                    }

                    //auto un_comp  = GetAttribute(cf_entity, "unit_component");                    
                }//if e_plane_angle_measure_with_unit
Reply all
Reply to author
Forward
0 new messages