POLY Files

POLY is a data directory which contains examples of POLY files, a format used by Jonathan Shewchuk to define PSLG's, planar straight line graphs, for use with his program TRIANGLE.

A Planar Straight Line Graph (PSLG) is a set of vertices and segments. Segments are simply edges, whose endpoints are vertices in the PSLG. Segments may intersect each other only at their endpoints.

POLY File Characteristics:

Comments are prefixed by the character '#'. Everything from the comment character to the end of the line is ignored.

Vertices, segments, holes, and regions must be numbered and listed consecutively, starting from either 1 or 0.

The first line lists

The vertex records must follow, with the format:

The next line lists

Segments should not cross each other; vertices should only lie on the ends of segments, and are never contained inside a segment.

The segments records must follow, with the format:

The third section lists holes (and concavities, if -c is selected) in the triangulation. Holes are specified by identifying a point inside each hole. After the triangulation is formed, Triangle creates holes by eating triangles, spreading out from each hole point until its progress is blocked by PSLG segments; you must be careful to enclose each hole in segments, or your whole triangulation might be eaten away. If the two triangles abutting a segment are eaten, the segment itself is also eaten. Do not place a hole directly on a segment; if you do, Triangle chooses one side of the segment arbitrarily.

The next line lists

The hole records must follow, with the format:

The optional fourth section lists regional attributes (to be assigned to all triangles in a region) and regional constraints on the maximum triangle area. Triangle reads this section only if the -A switch is used or the -a switch is used without a number following it, and the -r switch is not used. Regional attributes and area constraints are propagated in the same manner as holes; you specify a point for each attribute and/or constraint, and the attribute and/or constraint affects the whole region (bounded by segments) containing the point. If two values are written on a line after the x and y coordinate, the first such value is assumed to be a regional attribute (but is only applied if the -A switch is selected), and the second value is assumed to be a regional area constraint (but is only applied if the -a switch is selected). You may specify just one value after the coordinates, which can serve as both an attribute and an area constraint, depending on the choice of switches. If you are using the -A and -a switches simultaneously and wish to assign an attribute to some region without imposing an area constraint, use a negative maximum area.

The next line is optional. If given, it lists

The optional regional attributes records must follow, with the format:

A Sample POLY file:

Here is a sample file box.poly describing a square with a square hole.

    # A box with eight vertices in 2D, no attributes, one boundary marker.
    8 2 0 1
     # Outer box has these vertices:
     1   0 0   0
     2   0 3   0
     3   3 0   0
     4   3 3   33     # A special marker for this vertex.
     # Inner square has these vertices:
     5   1 1   0
     6   1 2   0
     7   2 1   0
     8   2 2   0
    # Five segments with boundary markers.
    5 1
     1   1 2   5      # Left side of outer box.
     # Square hole has these segments:
     2   5 7   0
     3   7 8   0
     4   8 6   10
     5   6 5   0
    # One hole in the middle of the inner square.
     1   1.5 1.5


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Sample Files:

A represents the capital letter A.

BICYCLE_SEAT is a region looking like a bicycle seat.

BOX is a box.

DOUBLE_HEX is a box with two hexagonal holes.

EXAMPLE is a 3D example used with TETGEN.

MESH01 is test mesh #1.

MESH02 is test mesh #2.

MESH03 is test mesh #3.

MESH04 is test mesh #4.

MESH05 is test mesh #5.

MESH06 is test mesh #6.

MESH07 is test mesh #7.

MESH08 is test mesh #8.

MESH09 is test mesh #9.

SHAPE is a simple shape with two hexagonal holes.

SQUARE_CIRCLE_HOLE is a mesh of 826 points in a square region with a circular hole.

You can go up one level to the DATA page.

Last revised on 25 February 2011.