Merge small item of Planogram sample into a Polygon

Hi,
i’m trying to use the planogram sample to create custom shape.
The idea is very simple: from the small item dropped into grid i would to construct a geometryString that “draw” the perimeter of my figure.
I’m using three function to do this:
getTopLeft that return the top left element of shape array, my starting “parsing” element

getNext that return the “next” element on diagram: if i’m parsing horizontal, it return the next adiacent node, if it exist. Same for vertical parse

createString that use the value of getNext to create the geometryString.

This, unfortunatelly, didn’t work for “difficult” shape that has an empty tile on the bottom or on the top because i can’t parse this kind of perimeter because the pos property of single shape identify only the top left edge, and this is terrible for the bottom of shape.

There are some tool or property that give me the geometryString of entire shape, or similar, that help me in this work?

Thanks :)

Can you draw us some mockup pictures of what you’re trying to do? I don’t quite get how you intend this polygon to be created.

From this:

To this:

I see. I also see what you mean by “difficult” shape with empty tiles, or that form a crescent, etc.

Unfortunately this is more of a math question than a GoJS question, so I’m going to have to leave the solution up to you.

Exactily…
For example, this is the most difficult shape to draw because is plent of “particular” case, expecially for the bottom side.

This is my solution for the problem:

Maybe i can compact some parts of the code, but it works.
Conditions for drawing shape:
-No circle with “hole” in the center
-ONLY square(or rect) adjacent.

Thanks! I hope people find it useful.