How to read STEP layer description


I have the following content in my STEP file:


I'm using the XCAFDoc_DocumentTool::LayerTool to read the layers:

        Handle(XCAFDoc_LayerTool) myLayers = XCAFDoc_DocumentTool::LayerTool(hDoc->Main());

        for (int i = 1; i < layers.Length(); ++i)
            // const Standard_GUID nameGuid("TDataStd_Name");
            Handle(TDataStd_Name) nameAttr = new TDataStd_Name();
            Handle(XCAFDoc_GraphNode) graphNodeAttr = new XCAFDoc_GraphNode();


            auto l = layers.Value(i);

            l.FindAttribute(nameAttr->ID(), nameAttr);
            bool found = l.FindAttribute(graphNodeAttr->ID(), graphNodeAttr);

            LOG_INFO("nb label children: " << l.NbChildren());
            LOG_INFO("nb label attributes: " << l.NbAttributes());
            LOG_INFO("name: " << nameAttr->Get());
            LOG_INFO("nb graph node children: " << graphNodeAttr->NbChildren());

I can read the layer name and "content" just fine. But the PRESENTATION_LAYER_ASSIGNMENT entity also includes a description field.

I need to read that description field. How can I do that?

Thank you for your help,

jeanmarc.leroux_153338's picture

Answering my own question after a few hours poking around in the OpenCascade code:

    Handle(XSControl_WorkSession) session = aReader.Reader().WS();
    Handle(Standard_Type) tSVPLA = STANDARD_TYPE(StepVisual_PresentationLayerAssignment);
    Handle(Interface_InterfaceModel) Model = session->Model();
    Standard_Integer nb = Model->NbEntities();

    for (Standard_Integer i = 1; i <= nb; i ++)
        Handle(Standard_Transient) enti = Model->Value(i);
        if (!enti->IsKind(tSVPLA))
        Handle(StepVisual_PresentationLayerAssignment) SVPLA = Handle(StepVisual_PresentationLayerAssignment)::DownCast(enti);
        Handle(TCollection_HAsciiString) descr = SVPLA->Description();
        Handle(TCollection_HAsciiString) hName = SVPLA->Name();

        layerNameToDescription[hName->ToCString()] = descr->ToCString();