Sample: Fracturing Polygons into Trapezoids
A sample calling application, trapezoid64.exe, reads polygons from a file and then fractures them into trapezoids. The resulting trapezoids are written back out to a ASCII file.
The Input Polygon File
For the input polygon data we are using a simple ASCII format. It looks like this:
LIBRARY RDL_1.GBS unit:MM grid:100000 header, units and grid STRUCT TOP BOUNDARY 1 0 start of boundary 125500 110217 vertex coord 125500 110200 140500 118500 140735 118518 140964 118573 141181 118663 141382 118786 141561 118939 141714 119118 141837 119319 141927 119536 141982 119765 142000 120000 141982 120235 141927 120464 141837 120681 . . ENDEL end of boundary BOUNDARY 1 0 125500 70217 125500 70200 140500 78500 140735 78518 140964 78573 141181 78663 141382 78786 141561 78939 141714 79118 141837 79319 141927 79536 141982 79765 142000 80000 ENDEL
A boundary may have hundreds or even thousands of vertices. The boundary shall not self-intersect but it is allowed to be "re-entrant". Boundaries may overlap.
The Output Polygon File
In syntax the output polygon file will look the same. However each polygon will have exactly 5 vertices (the first and last vertex are - by definition - identical.) This is because each output polygon is a trapezoid with 4 corners.
The trapezoids will "cover" exactly the same surface as the input boundaries.
Command Line Syntax
The trapezoid64.exe program is run from a command line with the following arguments:
trapezoid64.exe input_polygon_list_file -o:output_file (in DXF format) -convex:option convex options are one of: [none | x | full | trap]
Note - since it is difficult to view the polygons in their ASCII format, the trapezoid64.exe program takes the output polygons from the library and converts them into an AutoCAD DXF file.
Here is what the input polygons look like:
and here is what each of the options produces:
Convex in X
Convex Full (Both X and Y)
To see in more detail the difference between convex in X and convex full (both X and Y) we zoom in on one of the polygons where there is a noticeable difference.
Trapezoids have 4 vertices and parallel edges on top and bottom. (Note: a triangle can be considered as a trapezoid where two of the coordinates are identical.)
If you zoom in you can see that each polygon is a trapezoid.
Source code in C++ is provided for the the trapezoid64 application. This will aid the programmer in understanding the use of the QISBool library.
ARTWORK CONVERSION SOFTWARE, INC. Company Profile
417 Ingalls St., Santa Cruz, CA 95060 Tel (831) 426-6163 Fax 426-2824 email: firstname.lastname@example.org