Saturday, November 12, 2016

Offsets and editing

As I mentioned in my post earlier, I've made some progress on algorithms for straight skeleton and offset calculation.  They're nowhere near done yet, but you can see some of the progress in the screenshot below.  There algorithms so far are my independent implementations based upon little more than simple explanations of the concepts found on Wikipedia.

The offset (inset or outset) code relies upon the use of cross-products of 3D vectors to displace copies of the line segments making up the polygon.  Then it calculates the intersections between the displaced copies, using the topological relationships from the original polygon to help.  The resulting line intersections then become the new end points of the displaced copy line segments.  In this way the line segments are extended or truncates as necessary.  As can be seen from the bottom left example, further work is needed to deal with concave polygons more comprehensively.

Offset and straight skeleton examples.  The upper right is incomplete.
The straight skeleton code relies upon the offset code to determine vectors from the vertices toward the "center" of that portion of the polygon.  The code works well with convex polygons, but a more complex implementation is required to address concave polygons properly.

I've also got the initial GUI work for the scripted model generation code into better shape.  It is still far from complete, but is at least presentable.  The main inspirations are the Windows GUI for POV-Ray and the OpenSCAD GUI.  I was aided by a tutorial at CodeProject, and by the MVVM example provided with the AvalonDock component (look under Version 2.0/AvalonDock.MVVMTestApp). Various bits of documentation for the AvalonEdit component, including forums, were also of some assistance.


Tabbed editor for PowerShell scripts that can create 3D models

I hope to have something more to show in the next few days.







No comments:

Post a Comment