? Do CreateGroupBegin / CreateGroupEnd nest so that higher order groupings can apply properties such as fill and edging to the sub-groups?

My task is to emulate HP-GL/2 polygon buffer rendering to PDF. A list of render commands define the polygon. Then an EP (Edge Polygon) will create an outline of the area. Or an FP will create a solid filled area. The area being defined by a series of render sub-commands; the polygon buffer.

I do have logic to implement various plot commands, Pen-Up, Pen-Down, Arcs, Lines, etc. My thought was to organize EP and FP as 1) CreateGroupBegin, 2) PathBegin, 3) render all commands in the polygon buffer, 4) ClosePath, 5) PathEnd, and finally 6) Apply fill or edge properties to the PathEnd element, and write it, 7) CreateGroupEnd.

I see nothing rendered from this. I suspect there may be something about how I have implemented various command renderings that stand well on their own, but for whatever reason do not propagate to the group to which I am trying to treat in aggregate as a single polygon shape.

In the example I am debugging the polygon buffer consists of 7 HP-GL/2 commands;

  1. PU - PEN UP
  2. PD - PEN DOWN
  3. AA - ABSOLUTE ARC
    4, 5, 6) PD - PEN DOWN
  4. AA - ABSOLUTE ARC

As in the example of sequential PD, I render line segments wrapped as a group, path begin, and then render the line segments starting with a MOVETO and then a series of LINETO. Line attributes are applied to the path/group and we end with a CreateGroupEnd.

Now to my question; Should I anticipate CreateGroupBegin / CreateGroupEnd nest so that higher order groupings can apply properties such as fill and edging to the sub-groups? If not I suspect my solution will be to inhibit grouping done in individual render commands when rendered as part of a polygon buffer.

Should I anticipate CreateGroupBegin / CreateGroupEnd nest so that higher order groupings can apply properties such as fill and edging to the sub-groups?

Yes, you can nest has many groups as you like, just note that you need to Write them also before starting a new one.

elementWriter.WriteElement(builder.CreateGroupBegin()); elementWriter.WriteElement(builder.CreateGroupBegin()); elementWriter.WriteElement(builder.CreateGroupEnd()); elementWriter.WriteElement(builder.CreateGroupEnd());

When you write a group to the PDF content stream, you are pushing a new graphics state on top of the graphics state stack, similar to OpenGL.