Elsevier

Computers & Graphics

Volume 27, Issue 5, October 2003, Pages 791-800
Computers & Graphics

Technical section
Polygon trapezoidation by sets of open trapezoids

https://doi.org/10.1016/S0097-8493(03)00151-1Get rights and content

Abstract

A new efficient algorithm is described for the simple trapezoidation of polygons based on a sweep-line paradigm. As the sweep-line glides over the plane, a set of so-called open trapezoids is generated and maintained. It is shown that a boundary case (more polygon vertices are located on the sweep-line) can be solved safely and does not slow down the algorithm. If desired, the polygon holes can be trapezoidated simultaneously. This proposed algorithm when compared with the fastest known algorithm developed by Seidel resulted in more efficiency for different classes of polygons.

Introduction

Polygons are the most fundamental entities for many applications in computational geometry. In some applications, polygons can achieve considerable complexity, and polygons defined by a few thousands of vertices are fairly common. In geographical information systems (GIS), for example, polygons represent roads, river banks, or borders between states and because of this, it is often desirable to perform decomposition of such large polygons into simpler ones. Depending on the particular problem, there are different ideas on how this decomposition should be performed. Planar polygons can be decomposed, for example, into triangles, trapezoids, monotone polygons, or even star-shaped polygons [1]. While polygon triangulation is the most widely investigated technique [2], splitting polygons into trapezoids is an interesting alternative (incidentally, this trapezoidation is frequently used as an intermediate step for polygon triangulation [3], [4]). In regards to modern hardware for operations such as region filling, painting trapezoids is just as fast as painting triangles. In fact, it is often faster due to the smaller number of primitives [5].

A trapezoid is a four-sided polygon, in which two of the edges are parallel. Note that a triangle can be considered as a degenerate trapezoid in which one of the parallel edges has zero length; hence, some triangles might result from applying any trapezoidation algorithm.

Among the first trapezoidation algorithms were those proposed by Chazelle and Incerpi [6] and Fournier and Montuno [7]. In 1991, Seidel developed a randomized trapezoidation algorithm with O(nlogn)1 time complexity [4]. This algorithm still exposes the best theoretical time complexity among the already-known solutions for trapezoidation. Recently, Žalik and Claphworthy [8] have introduced an interesting extension to polygon trapezoidation. Numerically stabilized implementation of their algorithm has now been used in a commercial product [9]. This approach can trapezoidate polygons and their holes at the same time. The algorithm also solves a limited class of non-simple polygons, which are acceptable in the GIS applications. The sweep-line approach is applied by the use of two arrays: the OldPoints array contains the intersection points between polygon edges and the previous sweep-line, while the CurrentPoints array stores the intersection points between polygon edges and the current sweep-line. The pairs of points in these arrays are connected, and trapezoids are obtained. Vertices from the CurrentPoints array become vertices of the OldPoints array using the introduced roles. The scan line is then moved to the next position, and the CurrentPoints array is filled again. The main drawback of this approach is the need for postprocessing. Postprocessing reduces the number of obtained trapezoids by merging trapezoids bounded by the same pair of polygon edges. The problem set in [8], i.e. to trapezoid polygon loop and polygon holes in one pass, recently inspired Lorenzetto et al. In their implementation, the postprocessing is eliminated by using red–black trees [5].

In this paper, a new algorithm is presented for the trapezoidation of simple polygons containing holes. The holes may also be trapezoidated simultaneously. The benefits of the algorithm are its universality, simplicity and efficiency. The algorithm does not need any postprocessing and uses simple data structures. The paper is constructed as follows. Section 2 introduces the basic terminology. The algorithm is described in detail in Section 3. Section 4 contains firstly an estimation of the algorithm's time and space complexity, then a comparison with Seidel's algorithm [4] using different classes of polygons is given. The paper is summarized in Section 5.

Section snippets

Background

Let us have n points p0,p1,…,pn−1 in the plane and n line segments l0=p0p1, l1=p1p2,…,ln−1=pn−1p0. They determine a simple polygon if [10]

  • the neighbouring line segments meet at only one common point,

  • non-neighbouring line segments do not have any point in common (they do not intersect or touch).

The line segments li are considered as edges (ei) and the points pi as vertices (vi). Any polygon satisfying these two conditions is considered a simple polygon (otherwise, it is non-simple, or an “ill

The algorithm

The proposed algorithm applies the sweep-line approach—a popular technique used for many problems of computational geometry and computer graphics [11]. The solution is found in three steps:

  • During the initialization, the algorithm analyzes and prepares the input data. This step typically requires sorting the involved geometric elements according to the specified criterion.

  • In the second step, the sweep-line is swept through the plane and it only stops at the so-called event points, where the

Time complexity estimation

Let us suppose, polygon P has n vertices and contains ρ rings. As explained in the previous section, the algorithm consists of two mains steps:

  • (a)

    Initialisation: It consists of three tasks: sorting the polygon vertices according to y coordinates, orientation of the polygon loops and rings, and classifying the polygon vertices. Sorting is terminated in O(nlogn), while the remaining two tasks require linear time O(n). Total time complexity of the initialization is ti(n)=O(nlogn).

  • (b)

    Sweeping: As seen

Conclusions

This paper describes a new efficient algorithm for decomposing planar polygons into trapezoids. This algorithm works with all types of simple polygons which may contain holes. The holes can be trapezoided, if desired.

The algorithm is based on the sweep-line paradigm. During the initialisation, the local properties of the polygon vertices are determined, and the vertices are sorted according to their y coordinates. In the second step, the sweep-line visits the polygon vertices and updates the

References (14)

There are more references available in the full text version of this article.

Cited by (0)

View full text