KootK - Here is a brief algorithm for generating the trapezoidal layers for any shape defined by node coordinates:
Add node index numbers to the node coordinate list
Sort node coordinates and index numbers by increasing Y, then increasing X
List Y values for the bottom/top of each layer
For the base point(s) of the first layer:
_Count nodes with minimum Y value
_Check for vertex points; add a dummy node for each vertex
_List X values for each node
For each subsequent Y value
_Find IP X values for each line segment at or crossing this Y
_Where more than one end node has the same Y check for:
__Horizontal line segments defining the base or top of a layer
__Vertex points at the base or top of a layer
__Count nodes for the layer below and above Y (if any)
_List X values for the top of the layer below level Y
_List X values for the base of the layer above level Y, if any
Sort X values for each row in ascending order
I have also added that to the spreadsheet.
The basic algorithm is quite simple, but the code gets fairly complicated in checking situations where there are horizontal line segments or a top or bottom vertex. The code requires a check of the direction of the preceding and following line segments to check if the line forms part of the trapezium above or below the line. It also gets complicated at the end getting the node numbers right.
Doug Jenkins
Interactive Design Services