2D Straight Skeleton and Offsetting demo

How to use 2D Straight Skeleton and Polygon Offseting Demo

Main Functionality

- Reset application
- Creating a new window
- Print
- Close the current window
- Quit the application

Input

- Draw a new simple polygon with holes

Generation

- Generate the straight skeleton on the exterior of the polygon
- Generate the straight skeleton in the interior of the polygon
- Generate offset polygons
- Set the offset distance

Persistance

- Load an existing polygon
- Save the current polygon
- Polygon with holes file format

Reset application

Press Ctrl+N combination keys or go to File menu and choose "New". All the elements will be erased, the window's visible area will be set to default. (-1, 1, -1, 1)

Create a new window

Press Ctrl+W combination keys or go to File menu and choose "New Window". A new window will appear, modifying the visible area to be the default (-1, 1, -1, 1).

Print

Press Ctrl+P combination keys or go to File menu and choose "Print". The visible area on the screen will be outputed to the print device of your choice.

Close the current window

Press Ctrl+X combination keys or go to File menu and choose "Close". You may do it for any window other than the initial one, this operation will close only the one you have choosen. If you do this for the initial parent window, it will close the others too.

Quit the application

Press Ctrl+Q combination keys or go to File menu and choose "Quit". When you quit the application, all the windows you have created will be destroyed.

Create a new simple polygon with holes

This package supports polygons with holes. To create a a polygon with holes you must first create the outer contour, then the holes. The orientation of the contours is unimportant, but you must create the outer contour first. The holes must be strictly in the interior of the outer contour. Holes cannot cross each other nor cross the outer contour and a hole cannot be inside any other hole.

To draw the outer contour or a hole, Left click on the "Input polygon" layer. Be sure there is no layer activated in standard toolbar that eat events. To be sure, press the arrow button situated on the standard toolbar. Left Click anywhere on the application's drawing area to insert points in the polygon. You may press "Esc" key if you want to erase the last point. Once you have completed the polygon press the right click to close the polygon. To deactivate this layer, just press the arrow button situated on the same toolbar.

Generate the straight skeleton on the exterior of the polygon

Press Ctrl+O combination keys or go to Generation menu, then choose "Generate Outer Skeleton". The Straight skeleton on the exterior of the polygon currently drawn will be created. (holes are ignored by this command).
As explained in the package's User Manual, the outer skeleton is constructed by placing the polygon as a hole of a big frame. That frame is placed sufficiently away from the polygon to guarantee that the frame will have its own independent offset. Therefore, the constructed exterior skeleton will reach out only as much as it needs in order to make sure the frame offset doesn't merge with the polygon offset. If you create the offset polygons, you will see the frame offset separatedly from the polygon offset.
If the construction fails for any reason, a critical dialog will pop up saying so.

Generate the straight skeleton in the interior of the polygon

Press Ctrl+I combination keys or go to Generation menu, then choose "Generate Inner Skeleton". The Straight skeleton in the interior of the polygon with holes currently drawn will be created. If the construction fails for any reason, a critical dialog will pop up saying so.

Set the offset distance

Press Ctrl+T combination keys or go to Generation menu, then choose "Set Offset Distance". A dialog box will pop up with a slot showing the actual offset distance. You can enter a new value there, and press the OK button; or press the Cancel button to leave the current distance unmodified.
The value that is shown initially corresponds to a 1% of the diagonal length of the bbox of the currently load or drawn polygon (or 0 if there is no current polygon).

Generate offset polygons

Press Ctrl+F combination keys or go to Generation menu, then choose "Generate Offset Polygons". If you have created the outer or inner skeleton, a sequence of offset polygons will be created. If not, a critical dialog box saying that you must first create the skeleton will pop up.
The offset polygons will be created in the same region were the skeleton was created (exterior or interior)
If you loaded or drawn a polygon, and after that, you have defined an offset distance, the offset polygons will be created for that distance. On the other hand, if you have not defined an offset distance since the last time you loaded or drawn the current polygon, the program will automatically pick up an offset distance corresponnding to a 1% of the diagonal length of the bbox of the polygon, and will create not 1 but 30 offset polygons stepping by that automatic distance.
If the construction fails for any reason, a critical dialog will pop up saying so.

Load an existing polygon wit holes

Press Ctrl+L combination keys or go to File menu and choose "Load Polygon". A load file dialog will appear, having a filter that displays only the files with "poly" extension. Choose a file then press "Open" button or hit "Enter" key.
The polygon saved does not contain the visible area. The application will change the current visible area to fit the bounding box of the polygon.

Save the current polygon with holes

Press Ctrl+S combination keys or go to File menu, then choose "Save Polygon". A save file dialog will appear. You may change the name then press "Save" or hit "Enter" key. To cancel the save process just press Esc key.

Polygon with holes file format

The files loaded and saved by this demo must have the extension ".poly" and follow this simple text-based format:

          (number of contours)[new-line]                           * integer
          (number of vertices in outer contout)[new-line]          * integer
          (x-coord) (y-coord)[new-line]                            * double
          (x-coord) (y-coord)[new-line]                            * double
          (x-coord) (y-coord)[new-line]                            * double
          ..
          (EOF) or (number of vertices in hole 0)[new-line]        * integer
          (x-coord) (y-coord)[new-line]                            * double
          (x-coord) (y-coord)[new-line]                            * double
          ..
          (EOF) or (number of vertices in hole 1)[new-line]        * integer
          (x-coord) (y-coord)[new-line]                            * double
          (x-coord) (y-coord)[new-line]                            * double
          ..
          ..

The package is distributed with some sample files you can look at

Last modified: Thu March, 2006