Writing edges in to step file

I want to write edges in to step file to so that when the file is read, they are read as edges and not compound shapes. This shows up in the hierarchy. Attached (desired.png) the desired hierarchy - Currently, I am writing it like this -

    BRep_Builder builder;
    TopoDS_Compound compound;

    builder.MakeCompound(compound);

    std::for_each(shapes.begin(), shapes.end(), [&compound, &builder](const TopoDS_Shape& shape)
    {
        if (shape.IsNull())
            throw std::runtime_error("Empty shape encountered");

        builder.Add(compound, shape);
    });

    const TDF_Label freeShape = shapeTool->AddShape(compound, Standard_False);

    // set the catalogName on each Shape in the assembly
    const TCollection_ExtendedString aName(catalogName.data());
    TDataStd_Name::Set(freeShape, aName);

    shapeTool->AddComponent(label, freeShape, transform);

        TDF_Label colorLabel;
        Standard_Boolean isFound = shapeTool->SearchUsingMap(coloredShape.first, colorLabel, Standard_False, Standard_True);
        if (isFound)
        {
            colorTool->SetColor(colorLabel, color.first, XCAFDoc_ColorGen);
        }

This is giving me undesired hierarchy. Any pointers on how to write the edges so that they do not become compounds? I do not understand why even if I am writing individual edge as TopoDS_Edge, it is coming up as a compound when reading the file.

Attachments: 
Dmitrii Pasukhin's picture

Hello. To make assembly, not a compaund - need to make flag to true to AddShape:
 

  //! Adds a new top-level (creates and returns a new label)
  //! If makeAssembly is True, treats TopAbs_COMPOUND shapes
  //! as assemblies (creates assembly structure).
  //! NOTE: <makePrepare> replace components without location
  //! in assembly by located components to avoid some problems.
  //! If AutoNaming() is True then automatically attaches names.
  Standard_EXPORT TDF_Label AddShape (const TopoDS_Shape& S, const Standard_Boolean makeAssembly = Standard_True, const Standard_Boolean makePrepare = Standard_True);
  

Additionally Add component will work if you will force add "makePrepare" force.

Best regards, Dmitrii.