• No results found

Boolean Set-Operations

In document TELAVIVUNIVERSITY (Page 108-112)

In some sense and to some extent this thesis attempts to close gaps between theoretical results and practical needs. It is not accidental that great parts of the thesis are closely related to Cgal, as one of the goals of Cgal stated in the Introduction chapter of the thesis is to translate (theoretical) results into useful, reliable, and efficient programs for industrial and academic applications. Evidently, the Boolean set operations package of Cgal, which is based on the Arrangement on surface 2 package (see Section 2.7.1) is one of the most popular packages among Cgal packages in the commercial market. Naturally, we would like to continue improving this package. The problems addressed in the next two subsections were raised during the 3rd Cgal User Workshop [dW08] [1].

6.3. Boolean Set-Operations 95

6.3.1 Fixing the Data

Input data of Boolean set operations, namely, a set of one or more polygons, used in real-world applications is occasionally corrupted, as it originates from measuring devices that are susceptive to noise and physical disturbances. In some other cases, it contains many degeneracies, which either disable computations based on fixed-precision arithmetic, or slow down further computation using exact geometric computation.

Invalid Data

A polygon P is said to be simple (or Jordan), if the only points of the plane belonging to two edges of P are vertices of consecutive edges P [23]. Namely, no two edges intersect, except for every two consecutive edges, which share one endpoint. A simple polygon is topologically equivalent to a disk. A polygon P is said to be weakly simple, if the chain of the edges of P does not cross itself. A polygon P is said to be relatively simple, if it is weakly simple and the edges of P do not intersect in their relative interior. Observe, that a relatively simple polygon, the vertices of which appear only once in the boundary (the degree of each vertex is two), is simple.

a b c

Input data for any Boolean set operation represents points set that may be bounded or unbounded, and may have holes. Items of such input take the form of general polygons or general polygons with holes with well-defined interiors and exteriors. A valid polygon must be weakly simple (but not necessarily simple) and its vertices must be ordered in counterclockwise direction around its interior. A valid polygon with holes that represents a bounded point set, has an outer boundary represented as a weakly simple (but not necessarily simple) polygon, the vertices of which are oriented in counterclock-wise order around its interior. In addition, the set may contain holes, where each hole is represented as a simple polygon, the ver-tices of which are oriented in clockwise order around the interior of the hole. Note that an unbounded polygon without holes spans the entire plane. Vertices of holes may coincide with vertices of the boundary.

As mentioned above, real-world data is often corrupted. Naturally, passing invalid poly-gons (polypoly-gons with holes, respectively) as input to a Boolean set operation must be avoided.

Apparently, automatically “fixing” corrupted data, that is, converting invalid input polygons or polygons with holes to valid ones, is not a simple task. Consider, for example, the self intersecting star depicted in Figure 6.3(a). A point is considered inside the point set, if and only if the number of counterclockwise turns the oriented boundary makes around the point, also called the winding number, is greater than zero. It can be efficiently calculated using an Arrangement 2 data structure as follows. We extend each halfedge h with a Boolean flag that indicates whether the winding number increases or decreases when we cross h, that is,

a

Figure 6.3: (a) A self crossing polygon given by {a, b, c, d, e}. (b) The Arrangement 2 data structure constructed from the polygon edges. (c) The Arrangement 2 data structure with updated face winding-numbers. (d) The Arrangement 2 data structure with internal edges removed.

when we move from the face incident to h to the face incident to the twin of h. Observe that twin halfedges always have opposite flag values. We extend each face with an integer that counts the winding number of every point in the face. Finally, we apply a Breath-First Search (BFS) on all the arrangement faces starting from the unbounded face and updating the face counters as we cross halfedges. The BGL, for example, can be employed for this task. Figure 6.3 illustrates the process. Once the winding number of every face is updated, we remove internal edges, as they are redundant, and convert the arrangement back into a valid polygon or polygon with holes.

The problem becomes more complicated when the input polygons or polygons with holes violate several validity properties at the same time. Naturally, converting corrupted data into valid data consumes time. The challenge is to perform this task flawlessly and efficiently, while presenting a convenient interface to the user.

Degenerate Data

In computational geometry there are two main techniques to eliminate degeneracies and near-degeneracies. One is snap rounding [GM95, GGHT97, Hob99] and the other is controlled perturbation [HL04, MO06]. Both techniques aim at processing geometric data, e.g., curves of the boundaries of general polygons, to yield new data that can be further robustly and more efficiently processed, perhaps using only limited precision. Traditionally, snap rounding has been applied to linear objects embedded in the plane [HP01, HP02], where it replaces sets of linear segments with sets of polylines. It can be extended though to other types of curves in the plane, such as B´ezier curves [EKW07], or even other curve types embedded on other surfaces that have a well defined grid (and perhaps other properties), such as geodesic arcs embedded on the sphere. Controlled perturbation has even a larger spectrum of applicable platforms. With respect to our polygons, applying any one of the two techniques above may result with (partially) overlapping curves, which belong to two different polygons, respectively. In this case, we need to merge the incremental winding contributions of the original curves mentioned above.

6.3. Boolean Set-Operations 97

6.3.2 Improving the Efficiency

The Boolean set operations 2 package provides efficient operations that compute the reg-ularized union or the regreg-ularized intersection of a set of input polygons. There is no restric-tion on the polygons in the set; naturally, they may intersect each other. The package also provides an efficient predicate that determines whether all polygons in a given set intersect.

Figure 6.4: The union of eight discs.

There are at least three different methods to compute the union of a set of polygons P1, . . . Pm. We can do it incrementally as fol-lows. At each step we compute the union of Sk−1 =Sk−1

i=1 Pi with Pk

and obtain Sk. A second option is to use a divide-and-conquer ap-proach. First, we divide the set of polygons into two subsets. Then, we compute the union of each subset recursively, and obtain the partial results in S1 and S2, respectively. Finally, we compute the union S1∪ S2. A third option aggregately computes the union of all polygons. We construct an arrangement inserting the polygon edges at once, utilizing the sweep-line framework, (see Section 2.4.1) and extract the result from the arrangement. Similarly, it is also possi-ble to aggregately compute the intersectionTm

i=1Pi of a set of input polygons.

The incremental method is more efficient for a small (constant) size of input polygons, and the aggregate method is more efficient for sparse polygons with a relatively small number of intersections. It is also possible to mix between the three methods, reaping the benefits of them all. We would like to figure out what are the exact conditions that should be used to determine when to use each method, or when to switch from one to another.

6.3.3 Non Regularized Operations

The Cgal package Nef 2 supports ordinary set-operations on point sets in R2 [See07]. The point-set operands and results are rectilinear polygonal model. Such a point set can be defined by a finite set of open halfspaces, or obtained by set complement and set intersection operations. The package supports operations that consume and produce linear polygons defined by linear edges. The Boolean set operations package, on the other hand, supports only regularized set-operations, but the operations consume and produce general polygons.

Recall, that a general polygon is a point set in R2 that has a topology of a polygon, but its boundary edges map to arcs of curves, which are not necessarily linear. Extending the package to support not only regularized operations, but also ordinary ones, will make it useful for more applications; see, for example, Section 5.3.6.

6.3.4 Operating in 3-Space

Boolean set operations are intuitive and therefore popular in many fields. For example, CSG is a representation model for solids based on Boolean set operations. Solids represented using CSG result from Boolean set operations applied to elementary solids called primitives, e.g., cubes, spheres, cones, and cylinders. A CSG solid is represented in a tree structure, where

the leaves represent primitives, and internal nodes represent Boolean operations.

The Cgal package Nef 3 supports ordinary set-operations on point sets in R3 [HK07].

Similar to the planar case, the package supports operations that consume and produce (lin-ear) polyhedra defined by (lin(lin-ear) halfspaces. Having the ability to construct and maintain arrangements in R3, will enable the development of a new package, that will support either regularized, or even non-regularized, robust Boolean set-operations that consume and pro-duce general (curved) polyhedra in R3, the boundaries of which are general surfaces. Many fundamental problems in solid modeling, motion planning, and other domains, can benefit from such a package.

In document TELAVIVUNIVERSITY (Page 108-112)