Skip to content

Inset Extrude algorithm organization

Christopher M Overton edited this page Apr 26, 2015 · 1 revision

The Algorithm goes as follows:

First collecting all the user selected polygons. Second, mapping selected polygons with: face to vertices maps vertices to face maps face to faces (neighboring) faces for polygons on vertices intersection test to determine neighboring face relations.

Once maps have been laid out, the map key of the face to faces map is pulled and a list is constructed of this, I scan all map buckets for each to see what the minimum bucket size in inferring the type of operations to be performed. For instance, a bucket size of 1 infers that a user may have a non contiguous boundary for a given face selection area where, for instance, at the selection map end points a given face has only one neighbor, or a 1 dimensional surface selection area. On the other hand a 2 minimum bucket, matches the corner endpoints potentially of a defined selection area, for instance, on a square or rectangular surface area that is non repeating (that is not where the selection area loops back on itself...say a rectangular area matched on a cylinder where there are no endpoints). I set the minimum as a starting point regardless for constructing the processing selection areas.

Next I set up the process of creating 2x2 areas of a given starting polygon followed by its neighbors, and then a matching neighbor of the two neighbors that complete the square. I also employ direction sensing where by a direction is formulated (outside the row boundary) by the logic that the square that has the most open occupied neighbors is in the opposite direction of process adding buckets. Thus avoiding the condition of randomly attempting to fill the map, idling in random direction, with direction, one can orient the structure in populating the 2x2 selections on the whole of the given selection map. Iterating is given by column by column 2x2 selection filling followed by iterating to the next directed neighbor and repeating column by column, until filling the row, and then having filled the row repeating the operation to a specified next row 1rst column position. This continually reiterates effectively like a linked list until populating the entire user selection area.
This finishes a 2x2 selections list.

Here is an occupancy diagram that shows the construction of a 2x2 selection area: [](Untitled drawing.jpg) ![](https://github.com/christophermoverton/BlenderPythonScripts/wiki/Untitled drawing.jpg)

There are cases when the rules for direction yield a false positive, that is, where the direction is changed relative to the general orientation of the column by column 2x2 list population. Mostly this occurs either leading to an ambiguous condition at the outset of a given new row, where either neighbor may have the same degrees of freedom, or at the row space boundary conditions leads to the same ambiguity. In this case where the row space boundary has been encountered, I simply tossed out the zero degrees of freedom in determining direction. Elsewhere this condition is left open.

Now in working with the arbitrary M x N selections list case, I make use of the 2x2 selections lists. One would note that any odd number is merely an even number +/- 1 . Thus any user selection area defined as greater than 2 can be defined by some multiple of a 2x2 selection area followed by an odd or halving of a 2x2 selection area if the user defined mxn selection has an odd component. The trickier parts in the odd cases are in ensuring that halving assignments of a given 2x2 selection area from one MxN selection area to the next are properly shared. And then next, noting that in more generalized circumstances, an odd MxN selection may not evenly divide (remainder zero) a given total section area. In this case, one employs a remainder method for filling in a best fit K x L selection area (where K, L < = M,N). I usually created continues on the iterator, thus when attempting to access, for instance, coordinates outside of the total section area (or a coordinate value namely outside of the column space) in solving this problem, and row space likewise.

Once having selection lists set, then its a matter of passing the selection list off to the processing iterator which completes operator's operations.