Removing Depth-Order Cycles Among Triangles: An Algorithm Generating Triangular Fragments

More than 25 years ago, inspired by applications in computer graphics, Chazelle et al. studied the following question: is it possible to cut any set of n lines or other objects in R3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathbb R}^3$$\end{document} into a subquadratic number of fragments such that the resulting fragments admit a depth order? They managed to prove an O(n9/5)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n^{9/5})$$\end{document} bound on the number of fragments, but only for the very special case of bipartite weavings of lines. Since then only little progress was made, until a breakthrough in 2016 by Aronov and Sharir, who showed that O(n3/2polylogn)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n^{3/2}{{\,\mathrm{polylog}\,}}n)$$\end{document} fragments suffice for any set of lines. In a follow-up paper Aronov et al. proved an O(n3/2+ε)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n^{3/2+\varepsilon })$$\end{document} bound for triangles, but their method uses high- (albeit constant-) degree algebraic arcs to perform the cuts. Hence, the resulting pieces have curved boundaries. Thus the following natural version of the problem is still wide open: is it possible to cut any collection of n disjoint triangles in R3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathbb R}^3$$\end{document} into a subquadratic number of triangular fragments that admit a depth order? And if so, can we compute the cuts efficiently? We answer this question by presenting an algorithm that cuts any set of n disjoint triangles in R3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$${\mathbb R}^3$$\end{document} into O(n7/4polylogn)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n^{7/4}{{\,\mathrm{polylog}\,}}n)$$\end{document} triangular fragments that admit a depth order. The running time of our algorithm is O(n3.69)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n^{3.69})$$\end{document}. We also prove a refined bound that depends on the number, K, of intersections between the projections of the triangle edges onto the xy-plane: we show that O(n1+ε+n1/4K3/4polylogn)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$O(n^{1+\varepsilon } + n^{1/4} K^{3/4}{{\,\mathrm{polylog}\,}}n)$$\end{document} fragments suffice to obtain a depth order. This result extends to xy-monotone surface patches bounded by a constant number of bounded-degree algebraic arcs in general position, constituting the first subquadratic bound for surface patches.


Introduction
Let T and T be two disjoint triangles (or other objects) in R 3 . We say that T is below T -or, equivalently, that T is above T -when there is a vertical line intersecting both T and T such that ∩ T is below ∩ T . We denote this relation by T ≺ T . Note that two triangles may be unrelated by the ≺-relation, namely when their vertical projections onto the x y-plane are disjoint. Now let T be a collection of n disjoint triangles in R 3 . A depth order on T (for the vertical direction) is an ordering that is consistent with the ≺-relation, that is, an ordering T 1 , . . . , T n of the triangles in T such that T i ≺ T j implies i < j.
Depth orders play an important role in many applications. For example, the Painter's Algorithm from computer graphics performs hidden-surface removal by rendering the triangles forming the objects in a scene one by one, drawing each triangle "on top of" the already drawn ones. To give a correct result the Painter's Algorithm must handle the triangles in depth order with respect to the viewing direction. Several object-space hidden-surface removal algorithms and ray-shooting data structures need a depth order as well. Depth orders also play a role when one wants to assemble a product by putting its constituent parts one by one into place using vertical translations [26]. The problem of computing a depth order for a given set of objects has therefore received considerable attention [1,12,15,16]. However, a depth order does not always exist since there can be cyclic overlap, as illustrated in Fig. 1 (i). In such cases the algorithms above simply report that no depth exists. We would then like to cut the triangles into fragments such that the resulting set of fragments is acyclic, that is, admits a depth order. This gives rise to the following problem: How many fragments are needed in the worst case to ensure that a depth order exists? And how efficiently can we compute a set of cuts resulting in a small set of fragments admitting a depth order?
The problem of bounding the worst-case number of fragments needed to remove all cycles from the depth-order relation has a long history. In the special case of lines (or line segments) one can easily get rid of all cycles using O(n 2 ) cuts: project the lines onto the x y-plane and cut each line at its intersection points with the other lines. (Here the cut points are removed from the fragments, so they become disjoint.) A lower bound on the worst-case number of cuts is (n 3/2 ) [11]. It turned out to be amazingly hard to get any subquadratic upper bound. In 1991 Chazelle et al. [11] obtained such a bound, but only for so-called bipartite weavings; see Fig. 1 (ii). Moreover, their O(n 9/5 ) bound is still far away from the (n 3/2 ) lower bound. Later Aronov et al. [6] obtained a subquadratic upper bound for general sets of lines, but they only get rid of all triangular (ii) (i) Fig. 1 (i) Three triangles with cycle overlap. (ii) A bipartite weaving cycles-that is, cycles consisting of three lines-and their bounds are only slightly subquadratic: they use O(n 2−1/69 log 16/69 n) cuts to remove all triangular cycles. Finally, several authors studied the algorithmic problem of computing a minimumsize complete cut set-a complete cut set is a set of cuts that removes all cycles from the depth-order relation-for a set of lines (or line segments). Solan [24] and Har-Peled and Sharir [19] gave algorithms that produce a complete cut sets of size roughly O(n √ opt), where opt is the minimum size of any complete cut set for the given lines. Aronov et al. [4] showed that computing a minimum-size complete cut set for a set of line segments is an np-hard problem, and they presented an algorithm that computes a complete cut set of size O(opt· log opt· log log opt) in O(n 4+2ω log 2 n) = O(n 8.764 ) time, where ω < 2.373 is the exponent of the best matrix-multiplication algorithm.
Eliminating depth cycles from a set of triangles is even harder than it is for lines. The trivial bound on the number of fragments is O(n 3 ), which can for instance be obtained by taking a vertical cutting plane containing each triangle edge. Paterson and Yao [21] showed already in 1990 that any set of disjoint triangles admits a so-called binary space partition (BSP) of size O(n 2 ). This immediately implies an O(n 2 ) bound on the number of fragments needed to remove all cycles. Indeed, a BSP ensures that the resulting set of triangle fragments is acyclic for any direction, not just for the vertical direction. Better bounds on the size of BSPs are known for fat objects (or, more generally, low-density sets) [13] and for axis-aligned objects [2,22,25], but for arbitrary triangles there is an (n 2 ) lower bound on the worst-case size of a BSP [9]. Hence, a different approach is necessary to get a subquadratic bound on the number of fragments needed to obtain a depth order.
Very recently, using Guth's polynomial partitioning technique [18], Aronov and Sharir [8] achieved a breakthrough by proving that any set of n lines in R 3 can be cut into O(n 3/2 polylog n) fragments that admit a depth order. A complete cut set of size O(n 3/2 polylog n) can then be computed using the algorithm of Aronov et al. [4] mentioned above. Aronov and Sharir also gave a more refined bound for line segments, which depends on the number of intersections, K , between the segments in the projection. More precisely, they show that O(n + n 1/2 K 1/2 polylog n) cuts suffice. The latter result extends to algebraic arcs [8,23]. In a follow-up paper, Aronov et al. [7] extended the result to triangles: they show that, for any fixed ε > 0, any set of disjoint triangles can be cut into O(n 3/2+ε ) fragments that admit a depth order. This may seem to almost settle the problem for triangles, but the technique of Aronov et al. has a fundamental drawback: 1 it does not result in triangular fragments, since it cuts the triangles using algebraic arcs whose degree is exponential in the parameter ε appearing in the O(n 3/2+ε ) bound.
Arguably, the natural way to pose the problem for triangles is to require the fragments to be triangular as well-polygonal fragments can always be decomposed further into triangles, without increasing the number of fragments asymptotically (a consequence of Euler's formula). Indeed, Aronov et  Our contribution We prove that any set T of n disjoint triangles in R 3 can be cut into O(n 7/4 polylog n) triangular fragments that admit a depth order. Thus we overcome the fundamental drawback of the method of Aronov et al. although admittedly our bound is not as sharp as theirs. We also present an algorithm to perform the cuts in O(n 5/2+ω/2 log 2 n) = O(n 3.69 ) time, where ω < 2.373 is, as above, the exponent of the best matrix-multiplication algorithm. As a byproduct of our technique, we improve the time to compute a complete cut set of size O(n 3/2 polylog n) for a collection of lines: we show that a simple trick reduces the running time from 3 O(n 4+2ω log 2 n) to O(n 3+ω log 2 n).
We also present a more refined approach that yields a bound of O(n 1+ε + n 1/4 K 3/4 polylog n) on the number of fragments, where K is the number of intersections between the triangle edges in the projection. This result extends to x y-monotone surface patches bounded by a constant number of bounded-degree algebraic arcs in general position. Thus we make progress on both open problems posed by Aronov et al.
Finally, as a minor contribution we describe a general method showing that bounds for eliminating cycles among segments in general position, carry over (up to a logarithmic factor) to segments not in general position. This is useful since dealing with degeneracies can be painful-indeed, the conference version of the paper by Aronov and Sharir [8] assumed the segments were in general position, and in the journal version such an assumption is still made for the algorithmic result. Most degeneracies can be handled by a straightforward perturbation argument, but one case-parallel segments that overlap in the projection-requires some new ideas. Being able to handle degeneracies for segments implies that our method for triangles can handle degeneracies as well.

Eliminating Cycles Among Triangles
Overview of the method. We first prove a proposition that gives conditions under which the existence of a depth order for a set of triangles is implied by the existence of a depth order for the triangle edges. The idea is then to take a complete cut set for the triangle edges-there is such a cut set of size O(n 3/2 polylog n) by the results of Aronov and Sharir-and "extend" the cuts (by taking vertical planes through the cut points) so that the conditions of the proposition are met. A straightforward extension would generate too many triangle fragments, however. Therefore our cutting procedure has two phases. In the first phase we localize the problem by partitioning space into regions such that (i) the collection of regions admits a depth order, and (ii) each region is intersected by only few triangles. (This localization is also the key to speeding up the algorithm for lines.) In the second phase we then locally extend the cuts from a complete cut set inside each region, so that the conditions of the proposition are met and we obtain an acyclic set of fragments.
Notation and terminology. Let T denote the given set of disjoint non-vertical triangles, let E denote the set of edges of the triangles in T , and let V denote the set of vertices of the triangles. We assume the triangles in T are closed. However, at the places where a triangle is cut it becomes open. Thus the edges of a triangle fragment that are (parts of) edges in E are part of the fragment, while edges that are induced by cuts are not. We denote the vertical projection of an object o in R 3 onto the x y-plane by o.
A proposition relating depth orders for edges to depth orders for triangles. We define a column to be a 3-dimensional region C := × (−∞, +∞), where is an open convex polygon on the x y-plane. Our cutting procedure is based on the following proposition. Proof For a triangle T i ∈ T , define P i := T i ∩ int(C ). Thus T = {P i : T i ∈ T }. Assume E admits a depth order and suppose for a contradiction that T does not.
Consider a cycle C := P 0 ≺ P 1 ≺ · · · ≺ P k−1 ≺ P 0 in T . As observed by Aronov et al. [7] we can associate a (not necessarily unique) closed curve in R 3 to C, as follows. For each pair P i , P i+1 of consecutive polygons in C-here and in the rest of the proof indices are taken modulo k-let b i ∈ P i and a i+1 ∈ P i+1 be points such that the segment b i a i+1 is vertical. We refer to the closed polygonal curve whose ordered set of vertices is b 1 , a 2 , b 2 , a 3 , . . . , a k , b k , a 1 as a witness curve for C. We call the vertical segments b i a i+1 the connections of (C), and we call the segments a i b i the links of (C). Since the connections are vertical, we have a i+1 = b i and so we can write (C) as a 1 , a 2 , . . . , a k , a 1 . (Recall that o denotes the projection of an object o onto the x y-plane.) Note that a i ∈ P i−1 ∩ P i for all i. In general, the points a i and b i can be chosen in many ways and so there are many possible witness curves. We will need a specific witness curve, as specified next. We say that a link a i b i is good if a i and b i lie on the same edge of their polygon P i -this edge is also an edge in E -and we say that a i b i is bad otherwise. We now define the weight of a witness curve to be the number of bad links in , and we define (C) to be any minimum-weight witness curve for C. Now consider a minimal cycle C * := P 0 ≺ P 1 ≺ · · · ≺ P k−1 ≺ P 0 in T , where a cycle is minimal if any strict subset of polygons from the cycle is acyclic. We will Fig. 2 The two cases in the proof of Proposition 2.1. Polygon P i is shown in green argue that we can find a cycle in E consisting of edges of the polygons in C * , thus contradicting that E admits a depth order.
Claim All links a i b i of (C * ) are good.
Proof Consider any link a i b i . Observe that a i−1 and a i+2 must both lie outside P i , otherwise C * is not minimal. Consider \ P i , the complement of P i inside the column base . The region \ P i consists of one or more connected components; it cannot be empty since then P i cannot be part of any cycle in T . Each connected component is separated from P i by a single edge of P i , since by assumption T i does not have a vertex inside C and so P i does not have a vertex inside either. We now consider two cases, as illustrated in Fig. 2.
Case A: a i−1 and a i+2 lie in different components of \ P i . Let p be the point where a i−1 a i enters P i . Let p ∈ P i project onto p and let e be the edge of P i containing p.
(Possibly p = a i .) Since a i+2 lies in a different connected component of \ P i than a i−1 , the projection (C * ) must cross e a second time, at some point q. This leads to a contradiction with the minimality of C * . To see this, let q ∈ (C * ) be a point projecting onto q and let P j be such that q ∈ P j . Then j / ∈ {i − 1, i, i + 1}, because a i−1 b i−1 , and a i b i , and a i+1 b i+1 are the only links of (C * ) on P i−1 , and P i , and P i+1 , respectively. But since P i ∩ P j = ∅ we have P i ≺ P j or P j ≺ P i , and so j / Case B: a i−1 and a i+2 lie in the same component of \ P i . In this case a i b i must be a good link, because a i and b i must both lie on the edge e bordering the component of \ P i that contains a i−1 and a i+2 . Indeed, if a i and/or a i+1 would not lie on e then we can obtain a witness curve of lower weight for C * , namely if we replace a i by the point p such that p = a i−1 a i ∩ e and we replace a i+1 by the point q such that q = a 1 a i+1 ∩ e. Note that if a i−1 = a i+2 , which happens when C * consists of only three polygons, then the argument still goes through.
Thus a i b i is a good link, as claimed.
If all links a i , b i of (C * ) are good then C * gives a cycle in E , contradicting that E admits a depth order. Hence, the assumption that T contains a cycle is false.
The cutting procedure. A naive way to apply Proposition 2.1 would be the following: compute a complete cut set X for the set E of triangle edges, and take a vertical plane parallel to the yz-plane through each point in V ∪ X . This subdivides R 3 into columns C , where each column base is an infinite strip. These columns do not contain triangle vertices and the edge fragments inside each column are acyclic, and so the triangle fragments we obtain are acyclic. Unfortunately this straightforward approach generates too many fragments: V ∪ X may have size (n √ n) and each of the planes through a point in V ∪ X may cut (n) triangles, resulting in a total of (n 2 √ n) fragments. Hence, we first subdivide space so that we do not cause too much fragmentation when we take the vertical planes through V ∪ X . The crucial idea is to create the subdivision based on the projections of the triangle edges. This allows us to use an efficient 2-dimensional partitioning scheme resulting in cells that are intersected by only few projected triangles edges. The 2-dimensional subdivision will then be extended into R 3 , to obtain 3-dimensional regions in which we can take vertical planes through V ∪ X without creating too many fragments. We cannot completely ignore the triangles themselves, however, when we extend the 2-dimensional subdivision into R 3 -otherwise we already create too many fragments in this phase. Thus we create a hierarchical 2-dimensional subdivision, and we use the hierarchy to avoid cutting the input triangles into too many fragments. Next we make these ideas precise.
Let L be a set of n lines in the plane. A (1/r )-cutting for L is a partition of the plane into triangular 4 cells such that the interior of any cell ∈ intersects at most n/r lines from L. We say that a cutting c-refines a cutting , where c is some constant, if every cell ∈ is contained in a unique parent cell ∈ , and each cell in contains at most c cells from . An efficient hierarchical (1/r )-cutting for L, as introduced by Matoušek [20], is a sequence := 0 , 1 , . . . , k of cuttings such that there are constants c, ρ such that the following four conditions are met: For any set L and any parameter r with 1 r n, an efficient hierarchical (1/r )cutting exists and can be computed in O(nr) time [10,20]. We can view as a tree in which each node u at level i corresponds to a cell u ∈ i , and a node v at level i is the child of a node u at level Our cutting procedure now proceeds in two steps. Recall that T denotes the given set of n triangles in R 3 , and E the set of 3n edges of the triangle in T . 1. We first construct an efficient hierarchical (1/r )-cutting for L, with r = n 3/4 , where L is the set of lines containing the edges in E. Next we cut the projection T of each triangle T ∈ T into pieces. This is done by executing the following recursive process on , starting at its root. Suppose we reach a node u of the tree. If u ⊆ T or u is a leaf, then u ∩ T is one of the pieces of T . Otherwise, we recursively visit all children v of u such that v ∩ T = ∅. After cutting each projected triangle T in this manner, we cut the original triangles T ∈ T accordingly. Let T 1 denote the resulting collection of polygonal pieces.
2. We extend the 2-dimensional cutting k into R 3 by erecting vertical walls through each of the edges in k . Thus we create a column C := × (−∞, ∞) for each cell ∈ k . Let K be the collection of created columns. For each column C ∈ K, we proceed as follows.
Let T 1 (C ) ⊆ T 1 be the set of pieces that have an edge intersecting the interior of C , and let E(C ) := {e ∩ int(C ) : e ∈ E}. Note that E(C ) is the set of edges of the pieces in T 1 (C ), where we only take the edges in the interior of C . Let X (C ) be a complete cut set for E(C ), and let V(C ) ⊆ V be the set of triangle vertices in the interior of C . For each point q ∈ X (C ) ∪ V(C ), take a plane h(q) containing q and parallel to the yz-plane, and let H (C ) be the resulting set of planes. Cut every piece P ∈ T 1 (C ) into fragments using the planes in H (C ).
We denote the set of fragments generated in Step 2 inside a column C by T 2 (C ), and we denote the set of pieces in T 1 that do not have an edge crossing the interior of any column C ∈ K by T * 1 . Note that T * 1 contains all pieces generated at internal nodes of . Then The set T 2 of triangle fragments resulting from the procedure above is acyclic and Proof For the sake of the proof, image cutting each column C ∈ K into vertical prisms by slicing it with each triangle T ∈ T that completely cuts through C . In other words, we slice C with each triangle T such that ⊆ T . Let S denote the resulting 3-dimensional subdivision. Define S * to be the set of (open) prisms in S, and consider the set S * ∪ T * 1 . Claim The set S * ∪ T * 1 admits a depth order. Proof By construction, for any object o i ∈ S * ∪ T * 1 there is a node u ∈ such that o i = u . Hence, for any two objects o 1 , o 2 ∈ S * ∪ T * 1 we have This implies that S * ∪ T * 1 is acyclic. Indeed, suppose for a contradiction that S * ∪ T * 1 does not admit a depth order, and consider a minimal cycle C * : Obviously k 3. But then (1) implies that we can remove o 1 or o 2 and still have a cycle, contradicting the minimality of C * .
For a prism σ ∈ S, let T 2 (σ ) denote the set of fragments in T 2 that have an edge in the interior of σ . The claim above implies that T 2 is acyclic if each set T 2 (σ ) is acyclic. The latter follows if we can show that each set T 2 (C ) is acyclic. To see that T 2 (C ) is acyclic, note that the planes in H (C ) partition C into sub-columns that do not contain a point from X (C ) in their interior. Hence, the set of edges of the fragments in such a sub-column is acyclic-if this were not the case, then there would be a cycle left in E(C ), contradicting that X (C ) is a complete cut set for E(C ). Moreover, a sub-column does not contain any point from V(C ) in its interior, and so it does not contain a vertex of any fragment in its interior. We can therefore use Proposition 2.1 to conclude that within each sub-column, the fragments are acyclic. Since the fragments in each sub-column of C are acyclic and the sub-columns are separated by vertical planes, T 2 (C ) must be acyclic. It remains to prove that |T 2 | = O(n 7/4 + |X | · n 1/4 ). We start by bounding |T 1 |. To this end, consider a triangle T ∈ T and let P ∈ T 1 be a piece generated for T in Step 1. Let v be the node in where P was created. Then the cell u of the parent u of v is intersected by an edge of T . Since each node in has O(1) children and each cell ∈ i intersects at most n/ρ i projected triangle edges, this means that The number of additional fragments created in Step 2 can be bounded by observing that each column C ∈ K intersects at most n/r = O(n 1/4 ) triangle edges, and so Hence, the total number of fragments is O(n 7/4 + |X | · n 1/4 ), which finishes the proof. Lemma 2.2 leads to the following result.

Corollary 2.3
Suppose that any set of n lines has a complete cut set of size γ (n). Then any set T of n disjoint triangles in R 3 can be cut into O(n 7/4 +γ (3n)·n 1/4 ) triangular fragments such that the resulting set of fragments admits a depth order.
Proof Consider the cutting procedure described above. Define opt to be the minimum size of a complete cut set for E and, for a column C ∈ K, define opt to be the minimum size of a complete cut for E(C ). Then C ∈K opt opt. Indeed, if X opt denotes a minimum-size complete cut set for E, then X opt ∩ C must eliminate all cycles from E(C ). Since opt γ (3n), the bound on the number of fragments generated by our cutting procedure is as claimed.
The procedure above cuts the triangles in T into constant-complexity polygonal fragments, instead of into triangles: the first step results in pieces that are the intersection a triangle with a constant-complexity column, and the second step only uses cutting planes parallel to the xz-plane. In a post-processing step we can then cut The result of Aronov and Sharir [8] thus implies that any set of n triangles can be cut into O(n 7/4 polylog n) fragments such that the resulting set of fragments is acyclic.

Remark 2.4
The total number of fragments we create is O(n 7/4 polylog n), while Aronov and Sharir only need O(n 3/2 polylog n) fragments for the case of lines. Observe that we already generate up to (n 7/4 ) fragments in Step 1, since we take r = n 3/4 . To reduce the total number of fragments to O(n 3/2 polylog n) using our approach, we would need to set r := √ n in Step 1. In Step 2 we could then only use the set V(C ) to generate the vertical planes in H (C ). This would lead to vertical columns that do not have any vertex in their interior, while only using O(n 3/2 ) fragments so far. Each such sub-column C ⊆ C can contain up to ( √ n) triangle fragments. Hence, we cannot afford to compute a cut set X (C) for E(C) and cut each triangle fragment in C with a vertical plane containing each q ∈ X (C). One may hope that if we can eliminate all cycles from E(C) using |X (C)| cuts, then we can also eliminate all cycles from T 1 (C) using |X (C)| cuts. Unfortunately this is not the case, as shown in Fig. 3.
In the example, there are two cycles in T 1 (C): the green triangle together with the blue segments and the green triangle with the red segments. The set E(C) also contains two cycles. The cycles from E(C) can be eliminated by cutting the green edge at the point indicated by the arrow. However, a single cut of the green triangle cannot eliminate both cycles from T 1 (C). Indeed, to eliminate the blue-green cycle the cut should separate (in the projection) the parts of the blue edges projecting onto the green triangle, while to eliminate the red-green cycle the cut should separate the parts of the red edges projecting onto the green triangle-but a single cut cannot do both. The example can be generalized to sets T 1 (C) of arbitrary size, so that all cuts in E(C) can be eliminated by a single cut, while eliminating cycles from T 1 (C) requires (|T 1 (C)|) cuts. Thus a more global reasoning is needed to improve our bound.

Efficient Algorithms to Compute Complete Cut Sets
The algorithm for triangles. The hierarchical cutting can be computed in O(nr) = O(n 7/4 ) time [10,20], and we can compute the set T 1 within the same time bound. The construction of the hierarchical cutting also gives us for each cell ∈ k the projected triangle edges intersecting and, hence, the sets T 1 (C ).
Next we need to compute the cut sets X (C ). To this end we use the algorithm by Aronov et al. [4], which computes a complete cut set of size O(opt · log opt · log log opt ), where opt is the minimum size of a complete cut set for E(C ). Thus |X |, the total size of all cut sets X (C ) we compute, is bounded by Hence, the total number of fragments we create is still O(n 7/4 polylog n). Finally, for each column C we cut all triangles in T 1 (C ) by the planes in H (C ) in a brute-force manner, in total time O(n 7/4 polylog n).
The following theorem summarizes our main result. Note that using ω < 2.373 gives a running time of O(n 3.69 ).

Theorem 3.1 Any set T of n disjoint non-vertical triangles in R 3 can be cut into O(n 7/4 polylog n) triangular fragments such that the resulting set of fragments admits a depth order.
The time needed to compute the cuts is O(n 5/2+ω/2 log 2 n), where ω < 2.373 is the exponent in the running time of the best matrix-multiplication algorithm.

Remark 3.2
The bottleneck in our algorithm is the computation of the local cut sets X (C ) inside the columns C , using the algorithm of Aronov et al. [4]. One can avoid this by computing a single global cut set for the set E of triangle edges, and then distributing the cut points over the columns. Computing a global cut set of size O(n 3/2+ε ) can be done in O(n 3/2+ε ) time, by combining the method of Aronov and Sharir [8] with the recent result of Agarwal et al. [3] on computing polynomial partitions; also see the paper by Aronov et al. [5] who obtain the same time bound for cutting triangles (using curved cuts). The total running time of the algorithm then becomes O(n 7/4+ε ). However, the number of fragments increases to O(n 7/4+ε ).
The algorithm for lines. The running time we obtain in Theorem 3.1 for triangles is better than the running time obtained by Aronov and Sharir [8] to compute a complete cut set of size O(n 3/2 polylog n) for lines. The reason is that we apply the algorithm of Aronov et al. [4] locally, on a set of segments whose size is significantly smaller than n. We can use the same idea to speed up the computation of a complete cut set of size O(n 3/2 polylog n) for lines, as explained next. (But see Footnote 3.) Let L be a set of n lines in R 3 . We project L onto the x y-plane, and compute a (1/r )-cutting for L of size O(r 2 ), with r := √ n. We then cut each line ∈ L at the points where its projection is cut by the cutting, that is, where crosses the boundary of a cell in . Up to this point we make only O(nr) = O(n 3/2 ) cuts, which does not affect the worst-case asymptotic bound on the number of cuts. Each cell of the cutting defines a column C , as before. Within each column, we apply the algorithm of Aronov et al. [4] to compute a cut set of size O(opt · log opt · log log opt ), where opt is the size of an optimal cut set inside the column. In total this gives O(opt · log opt · log log opt) This leads to the following result. Note that using ω < 2.373 gives a running time of O(n 5.38 ).

A More Refined Bound and an Extension to Surface Patches
Let T be a set of disjoint bounded-degree algebraic surface patches in R 3 . We assume each surface patch is x y-monotone, that is, each vertical line intersects a patch in a single point or not at all, and we assume each surface patch is bounded by a constant number of bounded-degree algebraic arcs. We refer to the arcs bounding a surface patch as the edges of the surface patch. We assume the edges are in general position as defined by Aronov and Sharir [8], except that adjacent edges of the same patch share endpoints. We will show how to cut the patches from T into a collection of fragments that admits a depth order, where each fragment is bounded by a constant number of bounded-degree algebraic arcs. More precisely, an arc bounding a fragment f of a patch T ∈ T is either (a portion of) an edge of T , or it is the intersection of T with a vertical wall through (a portion of) an edge of another patch or with a vertical wall through a line segment. The total number of fragments will depend on K , the number of intersections between the projections of the edges: for any fixed ε > 0, we can tune our procedure so that it generates O(n 1+ε + n 1/4 K 3/4 polylog n) fragments. Trivially this implies that the same intersection-sensitive bound holds for triangles.
The extension of our procedure to obtain an intersection-sensitive bound for surface patches is fairly straightforward. First we observe that the analog of Proposition 2.1 still holds, where the base of the column can now have curved edges. In fact, the proof holds verbatim, if we allow the links of the witness cycles (C) that connect points a i and b i on the same surface patch to be curved. Now, instead of using efficient hierarchical cuttings [10,20] we recursively generate a sequence of cuttings using the intersection-sensitive cuttings of de Berg and Schwarzkopf [17]. This is somewhat similar to the way in which Aronov and Sharir [8] obtain an intersection-sensitive bound on the number of cuts needed to eliminate all cycles for a set of line segments in R 3 . Below we give the details.
Let E denote the set of O(n) edges of the surface patches in T , and let E be the set of projections of the edges in E onto the x y-plane. A (1/r )-cutting for E is a subdivision of R 2 into trapezoidal cells, such that the interior of each cell intersects at most n/r edges from E. Here a trapezoidal cell is a cell bounded by at most two segments parallel to the y-axis, at most one piece of an edge in E bounding the cell from above, and at most one such piece bounding it from below. Set r := min(n 5/4 /K 1/4 , n). Let ρ be a sufficiently large constant, and let k be such that ρ k−1 < r ρ k ; the exact value of ρ depends on the desired value of ε in the final bound. We recursively construct a hierarchy := 0 , 1 , . . . , k of cuttings such that i is a (1/ρ i )-cutting for E, as follows. The initial cutting 0 is the entire plane R 2 . To construct i we take each cell of i−1 and we construct a (1/ρ)-cutting for the set E := {e ∩ : e ∈ E}. De Berg and Schwarzkopf [17] have shown that there is such a cutting consisting of O(ρ + K ρ 2 /n 2 ) cells, where n := |E | and K is the number of intersections inside . One can show by induction on i that for each cell in i−1 we have 5 n n/ρ i−1 . Hence, by combining the cuttings over all ∈ i−1 we obtain a (1/ρ i )-cutting i .
Let | i | be the number of cells in i . Then | 0 | = 1 and, for a suitable constant D-this constant depends on the degree of the edges and can be derived from the construction of de Berg and Schwarzkopf [17]-we have Now we can proceed exactly as before. Thus we first traverse the hierarchy with each patch T ∈ T , associating T to nodes u such that u ⊆ T and parent(u) T , and to the leaves that we reach. This partitions T into a number of fragments. The resulting set T 1 of fragments generated over all triangles T ∈ T has total size If we now set ρ := D 1/ε then D k = ρ kε = O(r ε ) = O(n ε ), and so |T 1 | = O(n 1+ε + K r/n). We then extend the trapezoids of k into R 3 , thus obtaining a set of columns that each intersect at most n/r surface-patch edges, take a minimum-size complete cut set X (C ) for the edges inside each column C , and generate a set H (C ) of cutting planes through the points in X (C ) ∪ V(C ). Here V(C ) is, as before, the set of vertices of the surface patches in the interior of C . Since Aronov and Sharir [8] proved that any set of n bounded-degree algebraic arcs in general position 6 By picking r := min(n 5/4 /K 1/4 , n) our final bound on the number of fragments becomes O(n 1+ε + n 1/4 K 3/4 polylog n). Observe that for K = n 2 the bound we get is the same as in Theorem 3.1, up to the constant in the exponent of the polylogarithmic factor hidden in the polylog-notation.
We obtain the following theorem, where the constant of proportionality and the exponent of the polylogarithmic factor in the bound depend on the degree of the patches and their edges.

Theorem 4.1 Let T be a set of n disjoint x y-monotone bounded-degree algebraic
surface patches in R 3 , each bounded by a constant number of bounded-degree algebraic arcs in general position. Then for any fixed ε > 0 we can cut T into O(n 1+ε + n 1/4 K 3/4 polylog n) fragments that admit a depth order, where K is the number of intersections between the projections of the surface-patch edges. The expected time needed to compute the cuts is O n 1+ε + K (3+ω)/2+ε /n (1+ω)/2 , where ω < 2.373 is the exponent in the running time of the best matrix-multiplication algorithm.
Proof The bound on the number of fragments follows from the discussion above. To prove the time bound we first note that an intersection-sensitive cutting of size O(ρ + K ρ 2 /n 2 ) can be computed in expected time O(n log ρ + K ρ/n ) [17]. Hence, constructing the hierarchy takes expected time The first term is the same as in equation (2) except for the extra log ρ-factor, which is a constant, so this term is still bounded by O(n 1+ε + K r/n). Since ρ k−1 r , the second term is bounded by O(K r/n), which is dominated by the first term. Thus the total expected time to compute the set T 1 is O(n 1+ε + K r/n).
In the second stage of the algorithm we use the algorithm of Aronov et al. [4] on the set E(C ) of edge fragments inside each column C ∈ K. Aronov et al. only explicitly state their result for line segments, but it is easily checked that it works for curves as well; the fact that, for example, there can already be cyclic overlap between a pair of curves has no influence on the algorithm's approximation factor or running time. (The crucial property still holds that cut points can be ordered linearly along a curve, and this is sufficient for the algorithm to work.) Thus the time needed to compute all cut where n is the number of edges inside C . Since n = O(n/r ) and C ∈K n = O(|T 1 |) = O(n 1+ε + K r/n), computing the cut sets takes O n 4+2ω+ε r 3+2ω + K n r 2+2ω+ε time (for a slightly larger ε than before). Because we picked r := min(n 5/4 /K 1/4 , n), the time to compute the cut sets is O n 1+ε + n 1/4−ω/2+ε · K 3/4+ω/2 + K 3/2+ω/2 + ε n 1/2+ω/2 = O n 1+ε + K 3/2+ω/2+ε /n 1/2+ω/2 , which dominates the time for the first stage. Finally, cutting the patches inside each column C in a brute-force manner takes time linear in the maximum number of fragments we generate, namely O(n 1+ε +n 1/4 K 3/4 polylog n). Thus the total expected time is O n 1+ε + K 3/2+ω/2+ε /n 1/2+ω/2 .

Dealing with Degeneracies
In this section we present a general method to deal with degeneracies when eliminating cycles from a set of segments in R 3 , and we argue that the method for triangles presented in the main text does not need any non-degeneracy assumptions either. We do not deal with removing the non-degeneracy assumptions for the case of surface patches. Degeneracies among segments. Let S = {s 1 , . . . , s n } be a set of disjoint segments in R 3 . (Even though we allow degeneracies, we do not allow the segments in S to intersect or touch, since then the problem is not well-defined. If the segments are defined to be relatively open, then we can also allow an endpoint of one segment to coincide with an endpoint of, or lie in the interior of, another segment.) We can assume without loss of generality that S does not contain vertical segments, since eliminating all cycles from the non-vertical segments in S also eliminates all cycles when we include the vertical segments. Consider the following non-degeneracy assumptions: (i) no endpoint of one segment projects onto any other segment; (ii) no three segments are concurrent (that is, pass through a common point) in the projection; (iii) no two segments in S are parallel.
The main difficulty in handling degeneracies arises with type (iii), in particular when there are parallel segments whose projections overlap. The problem is that a small perturbation will reduce the intersection in the projection to a single point, and cutting one of the segments at the intersection is effective for the perturbed segments but not necessarily for the original segments. Next we describe how we handle this as well as the other degeneracies.
First we slightly extend each segment in S-segments that are relatively open would be slightly shortened-to get rid of degeneracies of type (i), and we slightly translate each segment to make sure no two segments intersect in more than a single point in the projection. (The translations are not necessary, but they simplify the following description and bring out more clearly how the ≺-relations between parallel segments are treated.) Next, we slightly perturb each segment such that all degeneracies disappear and any two non-parallel segments whose projections intersect before the perturbation still do so after the perturbation. This gets rid of degeneracies of types (ii) and (iii). Let s i denote the segment s i after the perturbation, and define S := {s 1 , . . . , s n }. The set S has the following properties: • for any two non-parallel segments s i , s j ∈ S we have s i ≺ s j if and only if s i ≺ s j ; • the order of intersections along segments in the projection is preserved in the following sense: if s i ∩ s j lies before s i ∩ s k along s i as seen from a given endpoint of s i , then s i ∩s j does not lie behind s i ∩s k along s i as seen from the corresponding endpoint of s i ; • if s i and s j are parallel then s i and s j do not intersect.
We will show how to obtain a complete cut set for S from a complete cut set X for S . The cut set for S will consist of a cut set X that is derived from X plus a set Y of O(n log n) additional cuts, as explained next.
• Let q ∈ X be a cut point on a segment s i ∈ S . Let s j ∈ S be the segment such that s i ∩ s j is the intersection point on s i closest to q , with ties broken arbitrarily.
We can assume that s j exists, since if s i does not intersect any projected segment then the cut point q is useless and can be ignored. Now we put into X the point q ∈ s i such that q = s i ∩s j . (It can happen that several cut points along s i generate the same cut point along s i . Obviously we need to insert only one of them into X .) The crucial property of the cut point q ∈ X generated for q ∈ X is the following: -if q coincides with a certain intersection along s i then q coincides with the corresponding intersection along s i ; -if q separates two intersections along s i then q separates the corresponding intersections along s i or it coincides with at least one of them.
By treating all cut points in X in this manner, we obtain the set X . • The set Y deals with parallel segments in S whose projections overlap. It is defined as follows. Let S(X ) be the set of fragments resulting from cutting the segments in S at the cut points in X . Partition S(X ) into subsets S (X ) such that S (X ) contains all fragments from S(X ) projecting onto the same line . Consider such a subset S (X ) and assume without loss of generality that is the x-axis. Construct a segment tree [14] for the projections of the fragments in S (X ). Each projected fragment f is stored at O(log |S (X )|) = O(log n) nodes of the segment tree, which induces a subdivision of f into O(log n) intervals. We put into Y the O(log n) points on f whose projections define these intervals. The crucial property of segment trees that we will need is the following: -Let I v denote the interval corresponding to a node v. Then for any two nodes v, w we either have I v ⊆ I w (when v is a descendent of w), or we have I v ⊇ I w (when v is an ancestor of w), or otherwise the interiors of I v and I w are disjoint. Hence, a similar property holds for the projections of the sub-fragments resulting from cutting the fragments in S (X ) as explained above.
Doing this for all fragments s i ∈ S (X ) and for all subsets S (X ) gives us the extra cut set Y .

Lemma 5.1
The set X ∪ Y is a complete cut set for S.
Proof Let F denote the set of fragments resulting from cutting the segments in S at the points in X ∪ Y , and suppose for a contradiction that F still contains a cycle. Let C := f 0 ≺ f 1 ≺ · · · ≺ f k−1 ≺ f 0 be a minimal cycle in F, and let s i ∈ S be the segment containing f i . As explained above, the cut points in Y guarantee that for any two parallel fragments in F whose projections overlap, one is contained in the other in the projection. This implies that two consecutive fragments f i , f i+1 in C cannot be parallel: if they were, then f i ⊆ f i+1 (or vice versa) which contradicts that C is minimal. Hence, any two consecutive fragments are non-parallel. Now consider the witness curve (C) for C. Since consecutive fragments in C are non-parallel, (C) is unique. Let be the corresponding curve for S , that is, visits the segments s 0 , s 1 , . . . , s k−1 , s 0 from S in the given order-recall that f i ⊆ s i and that s i is the perturbed segment s i -and it steps from s i to s i+1 using vertical connections. Since X is a complete cut set for S , there must be a link of , say on segment s i , that contains a cut point q ∈ X . In other words, q separates s i−1 ∩ s i from s i ∩ s i+1 , or it coincides with one of these points. But then the cut point q ∈ X corresponding to q must separate s i−1 ∩ s i from s i ∩ s i+1 or coincide with one of these points, thus cutting the witness curve (C)-a contradiction.
Theorem 5.2 Suppose any non-degenerate set of n disjoint segments can be cut into γ (n) fragments in T (n) time such that the resulting set of fragments admits a depth order. Then any set of n disjoint segments can be cut into O(γ (n) log n) fragments in T (n) + O(n 2 ) time such that the resulting set of fragments admits a depth order.
Proof The bound on the number of fragments immediately follows from the discussion above. The overhead term in the running time is caused by the computation of the perturbed set S , which can be done in O(n 2 ) time if we compute the full arrangement in the projection.

Degeneracies among triangles.
Recall that the cuts we make on the triangles are induced by vertical planes, and that a triangle becomes open where it is cut. When a triangle is completely contained in the cutting plane, however, it is not well defined what happens. One option is to say that the triangle completely disappears; another option it to say that the triangle is not cut at all. Since vertical triangles can be ignored in the Painter's Algorithm, we will simply assume that no triangle in T is vertical. However, we can still have other degeneracies, such as edges of different triangles being parallel or triples of projected edges being concurrent. Fortunately, the fact that we do not need non-degeneracy assumptions for segments immediately implies that we can handle such cases. Indeed, degeneracies are not a problem for the hierarchical cuttings we use in Step 1 of our procedure, and in Step 2 we only assumed non-degeneracy when computing the cut set X (C ) for the edge set E( )-and Theorem 5.2 implies we can get rid of the non-degeneracy assumptions in this step. Note that the O(n 2 ) overhead term in Theorem 5.2 is subsumed by the time needed to apply the algorithm of Aronov et al. [4].

Concluding Remarks
We proved that any set of n disjoint triangles in R 3 can be cut into O(n 7/4 polylog n) triangular fragments that admit a depth order, thus providing the first subquadratic bound for this important setting of the problem. We also proved a refined bound that depends on the number of intersections of the triangle edges in the projection, and generalized the result to x y-monotone surface patches. The main open problem is to tighten the gap between our bound and the (n 3/2 ) lower bound on the worst-case number of fragments needed: is it possible to cut any set of triangles into roughly (n 3/2 ) triangular fragments that admit a depth order, or is this only possible by using curved cuts? One would expect the former, but curved cuts seem unavoidable in the approach of Aronov et al. [7] and it seems very hard to push our approach to obtain an o(n 7/4 ) bound.
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.