Active Zones in CSG for Accelerating Boundary Evaluation...

37
Active Zones in CSG for Accelerating Boundary Evaluation, Redundancy Elimination, Interference Detection, and Shading Algorithms JAROSLAW R. ROSSIGNAC IBM Research Division and HERBERT B. VOELCKER Cornell University Solids defined by Boolean combinations of solid primitives may be represented in constructive solid geometry (CSG) as binary trees. Most CSG-based algorithms (e.g., for boundary evaluation, graphic shading, interference detection) do various forms of set-membership classification by traversing the tree associated with the solid. These algorithms usually generate intermediate results that do not contribute to the final result, and hence may be regarded as redundant and a source of inefficiency. To reduce such inefficiencies, we associate with each primitive A in a tree S an active zone 2 that represents the region of space where changes to A affect the solid represented by S, and we use a representation of 2 instead of S for set-membership classification. In the paper we develop a mathematical theory of active zones, prove that they correspond to the intersection of certain nodes of the original trees, and show how they lead to efficient new algorithms for boundary evaluation, for detecting and eliminating redundant nodes in CSG trees, for interference (null-set) detection, and for graphic shading. Categories and Subject Descriptors: B.6.3 [Design Aids]: Optimization; F.2.2 [Nonnumerical Algorithms and Problems]: Geometrical problems and computations; G.2.2 [Graph Theory]: Trees; 1.1.1 [Expressions and their Representations]: Simplification of Expressions; 1.3.3 [Picture/Image Generation]: Display Algorithms; 1.3.7 [Three-Dimensional Graphics and Realism]: Shading; Visible Surface Algorithms; J.6 [Computer-Aided Engineering]: Computer- aided design General Terms: Algorithms, Design, Performance, Theory Additional Key Words and Phrases: Boolean algebra, boundary evaluation, constructive solid geom- etry, interference detection, redundancy elimination, representation simplification, solid modeling This research was supported by the National Science Foundation under Grants ECS-81-04646 and ECS-84-03882, and by the Industrial Associates of the Production Automation Project. Authors’ addresses: J. R. Rossignac, IBM Research Division, Yorktown Heights, NY 10598; and H. B. Voelcker, Cornell University, Ithaca, NY 14853. Permission to copy without fee all or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission. 0 1989 ACM 0730-0301/89/0100-0051$01.50 ACM Transactions on Graphics, Vol. 8, No. 1, January 1989, Pages 51-87.

Transcript of Active Zones in CSG for Accelerating Boundary Evaluation...

Page 1: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG for Accelerating Boundary Evaluation, Redundancy Elimination, Interference Detection, and Shading Algorithms

JAROSLAW R. ROSSIGNAC IBM Research Division and HERBERT B. VOELCKER Cornell University

Solids defined by Boolean combinations of solid primitives may be represented in constructive solid geometry (CSG) as binary trees. Most CSG-based algorithms (e.g., for boundary evaluation, graphic shading, interference detection) do various forms of set-membership classification by traversing the tree associated with the solid. These algorithms usually generate intermediate results that do not contribute to the final result, and hence may be regarded as redundant and a source of inefficiency. To reduce such inefficiencies, we associate with each primitive A in a tree S an active zone 2 that represents the region of space where changes to A affect the solid represented by S, and we use a representation of 2 instead of S for set-membership classification. In the paper we develop a mathematical theory of active zones, prove that they correspond to the intersection of certain nodes of the original trees, and show how they lead to efficient new algorithms for boundary evaluation, for detecting and eliminating redundant nodes in CSG trees, for interference (null-set) detection, and for graphic shading.

Categories and Subject Descriptors: B.6.3 [Design Aids]: Optimization; F.2.2 [Nonnumerical Algorithms and Problems]: Geometrical problems and computations; G.2.2 [Graph Theory]: Trees; 1.1.1 [Expressions and their Representations]: Simplification of Expressions; 1.3.3 [Picture/Image Generation]: Display Algorithms; 1.3.7 [Three-Dimensional Graphics and Realism]: Shading; Visible Surface Algorithms; J.6 [Computer-Aided Engineering]: Computer- aided design

General Terms: Algorithms, Design, Performance, Theory

Additional Key Words and Phrases: Boolean algebra, boundary evaluation, constructive solid geom- etry, interference detection, redundancy elimination, representation simplification, solid modeling

This research was supported by the National Science Foundation under Grants ECS-81-04646 and ECS-84-03882, and by the Industrial Associates of the Production Automation Project. Authors’ addresses: J. R. Rossignac, IBM Research Division, Yorktown Heights, NY 10598; and H. B. Voelcker, Cornell University, Ithaca, NY 14853. Permission to copy without fee all or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission. 0 1989 ACM 0730-0301/89/0100-0051$01.50

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989, Pages 51-87.

Page 2: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

52 l J. R. Rossignac and H. B. Voelcker

1. INTRODUCTION

1 .l CSG Representation

Boolean operations are convenient for incrementally designing solids, for mod- eling the geometric effects of certain manufacturing operations, and for express- ing interferences between parts to be assembled. A user’s specification that combines simple solid primitives through a sequence of Boolean operations yields Boolean expressions, which, for further processing, may be parsed and stored as a binary tree, called the CSG (constructive solid geometry) representation of the resulting solid (Figure 1).

Some modelers, for example TIPS [15], BUILD [9], and GDP [38], represent solids by N-way trees, where each node may have more than two children. Results described in this paper also apply to such representations, because the N children of a node may be processed by our algorithms (say, left to right), as if they were encoded in an unbalanced binary tree. For example, the primitives B, C, and D of Figure 1 could be viewed as the three children of a single intersection node, but were encoded for uniformity as a binary subtree.

The leaves of the CSG tree represent instances of simple parameterized primitive solids, such as blocks, cylinders, spheres, and cones in 3-D, or rectangles and disks in 2-D. Primitives represent regular’ subsets of some universal set w, for example, the 2- or 3-D Euclidean spaces E2 or E3. They are often modeled mathematically as intersec:tions of half-spaces.’ The internal nodes of the CSG tree represent potentially more elaborate regular sets and are associated with regularized3 Boolean opera.tors: union, intersection, and difference, respectively denoted +, ., and -. For terseness of notation, we attribute to the . operator a higher priority than to the + and - operators. CSG expressions combining bounded primitives correspond to bounded sets. The symbol 0 denotes the empty set, and the regularized complement of a set S is denoted Is.

1.2 General Research Issues

Guaranteed validity is one of the major advantages of CSG: It enables CSG representations to be parameterized, composed almost arbitrarily, and edited interactively without danger of producing an invalid model (a representation corresponding to a “nonsense object”). CSG also has disadvantages. Some of these are intrinsic, while others are transitory and dissolve gradually as our understanding of CSG and its associated algorithms grows. We list below some perceived problem areas together with examples of pertinent research:

(1) Practical implementations of CSG restrict the represented objects to be semialgebraic sets specified as regularized Boolean combinations of algebraic

’ A regular set is equal to the topological closure of its interior (defined in the topology of some universal set w) [lS].

’ Typically, a half-space is a set of points for which some algebraic function that takes points of w into R is negative or null. For example, a ball of radius 1 centered at the origin is defined by the function F(x, y, z) 5 x2 + y* + z2 - 1.

3 The regularized operators perform the standard Boolean operations followed by the topological interior and closure operations [IS], and therefore always return regular sets, which contain their boundary, but no dangling faces, edges, or vertices.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 3: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 53

A=REC(3.4); B=REC(Z.Z): C=B.turn(60); o=c.turn(60j; S=A-B*C*D;

A ”

3

.

B ‘C

‘D

Fig. 1. CSG representation: The text input (left) defines two rectangles, A and B, of different dimensions, both centered at the origin; two other rectangles, C and D, obtained by rotating copies of B; and a Boolean expression S that combines all four rectangles. Parsing the Boolean expression according to the precedence rules of Boolean operators yields a binary tree (cen- ter), which corresponds to a 2-D region (right).

inequalities. It is often inconvenient, and sometimes impossible, to specify cer- tain well-defined operations (such as offsetting and blending) in these terms. Rossignac and Requicha added constant radius blending [24] and offsetting operations [25] to the CSG scheme. Shirma et al. [30] studied tools for modeling Boolean combinations of sweeps, and Van Wijk [36] developed tools for display- ing them.

(2) The design in CSG of complex 3-D solids requires that the users produce sequences of rotations and translations that will correctly position the solid primitives. This task is particularly hard when it is necessary to achieve complex 3-D arrangements of primitives bounded by curved surfaces. Rossignac [22] and Anderson [l] incorporated constraint-based specifications in the CSG represen- tation, and Peterson [16] and Vossler [37] described techniques for converting 2-D contours into CSG representations of 2-D regions and 3-D swept volumes.

(3) Most CSG-based systems were developed for representing and manipulat- ing homogeneously 2-D regions or 3-D solids. Certain CAD/CAM applications, however, deal with multi-dimensional collections of open geometric elements. Cameron [5] used 4-D CSG representations to compute intersections of moving objects, and Rossignac and O’Connor [23] proposed algorithms for performing Boolean operations on nonhomogeneous, not necessarily closed, n-dimensional sets.

(4) A CSG representation of a given solid is not unique (e.g., see Figure 2), and thus, it is expensive to determine whether two CSG trees represent the same solid and whether any particular CSG tree represents the empty set. Tilove [33, 341 dealt with efficient .methods for comparing sets represented by two different (possibly empty) CSG trees, and Cameron [6] proposed improvements to some of Tilove’s results. Woodwark [39] described a different method, which simplifies CSG representations by reasoning on geometric approximations of combinations of half-spaces.

(5) A CSG representation, although informationally complete, does not con- tain explicit information about the boundary of the represented solid. Some applications, such as mass-property calculation [ 121 and null-object detection [33, 341, do not require such information and may be said to operate directly on

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 4: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

54 l J. FL Rossignac and H. B. Voelcker

(a) (b) (c) (4

Fig. 2. A CSG representation is not unique: A solid (a) can be represented as A + B (b), A + C (c), D - F(d), and so on.

CSG. Other applications require that some form of partial or complete boundary eualuation be done. Requic:ha and Voelcker [20] described the basic techniques for boundary evaluation, which is inherently computationally intensive, and Woodwark and Quinlan [40] (and many others) proposed improvements to speed up boundary evaluation. The generation of shaded pictures from CSG has received a great deal of attention; many references may be found in [lo] and [26].

1.3 Specific Problems Addressed in this Paper

This paper focuses mainly on the last two points and seeks to improve the performance of boundary evaluation and several other CSG-based algorithms by reducing redundant computation. The essential notion may be summarized as follows: Compute only on entities and over regions of space that can affect the desired final result.

The main tool we introduce is the active zone 2 of a node A in a CSG representation of a solid S. 2, which is formally defined later, is the spatial region in which changes to A affect S and hence &S. We note that the active zone of a node A is not an intrinsic property of the set represented by A and in fact is independent of that set.

We summarize below, in an informal manner, how active-zone notions may be used in four specific problems that are addressed in the body of this paper.

1.3.1 Improve BoundaQ Evaluation Algorithms. For a solid defined in CSG, boundary evaluation algorithms compute intersection of the primitives’ bounda- ries with the solid’s boundary. Typically, candidate elements (faces, edges, points that are subsets of primitives’ boundaries) are classified against all primitives, and the results combined according to the Boolean expression that defines the solid. However, the classification of a particular candidate element with respect to certain primitives or subtrees may be irrelevant to the final result. Such redundant computation may be easily avoided in simple cases (e.g., given an element X and two primitives A and B, if X @ A, then there is no need to compute whether X E B in order ‘to determine that X 4 A . B). When the standard classification approach is used, a systematic elimination of redundant computa- tions in the general case is difficult, because what is redundant while classifying a subset of the boundary of one primitive might not be redundant while classify- ing a subset of the boundary of another primitive. To improve the performance of boundary evaluation algorithms, we use different CSG trees for the classifica- tion of boundary elements of different primitives. Specifically, when classifying ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 5: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG - 55

Fig. 3. A redundant primitive: In the solid defined in CSG by (B - A) + C, the primitive A is redundant because the same solid can be defined by B + C.

Fig. 4. Redundant half-spaces: In the CSG representation of the solid A - B, the primitive B is modeled by the intersection, H, . H2 . H3 . H4, of the four half-spaces. Two of these half-spaces, H3 and H4, are redundant.

Fig. 5. Boundary evaluation and redundancy detec- tion: The region S (left) is defined in CSG as the union of four disk primitives A, B, C, and D (right). A is not redundant, even though aA does not intersect 8%

a candidate element of a primitive A in the CSG representation of a solid S, we use a CSG representation of 2.

1.3.2 Eliminate Redundant Primitives. A CSG representation may contain many redundant primitives (Figure 3) or half-spaces (Figure 4) that can be eliminated without altering the represented solid. The detection of such redun- dancies is relatively expensive, but in some applications it provides a one-time preprocessing step that enables all subsequent calculations to be speeded up. Note that the redundancy of primitives cannot be calculated by performing boundary evaluation and keeping track, for each resulting boundary element, of the primitives it lies on (see Figure 5 for a counterexample). The notion of active zones developed in this paper provides a simple, but fully general formulation of primitive redundancy and leads to improvements of the performance of redundancy-detection algorithms. Our algorithms may be used in conjunction with the spatial decomposition techniques proposed in [4], [33], and [39].

1.3.3 Improve Null-Object Detection. Null (empty) solids provide a blatant example of redundancy, because they may have arbitrarily elaborate CSG repre- sentations in which all primitives and subtrees are redundant [34]. Null-object

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 6: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

56 l J. R. Rossignac and H. 6. Voelcker

detection (abbreviated NOD) is an important problem in solid modeling. Good examples are found in interference-detection algorithms [5] essential in robotics, and in the automatic verification of machining processes, where both invasive machining andgoal attainment can be tested through the detection of null objects4 [31]. Same-object detection ,tests, such as “Is P equal R?,” can clearly be expressed as a NOD test on the symmetric difference (P - R) + (R - P), or equivalently on P + R - P . R. A standard approach to NOD is boundary evaluation (a bounded set that has no boundary is null). Since a null object may have an elaborate CSG representation, NOD via boundary evaluation may be computa- tionally expensive. A more efficient method proposed by Tilove [34] eliminates redundant primitives until the CSG expression is reduced to an empty tree or until a nonredundant primitive is found (which implies that the solid is not empty). Tilove invented a simple redundancy test that is sufficient for NOD,5 and used spatial localization preprocessing techniques to improve its average performance. Our results described in this paper lead to further performance improvements of Tilove’s NOD algorithm and can easily be combined with preprocessing techniques based on spatial localization [6, 331. Specifically, when testing the redundancy of a particular primitive A, we use I, a superset of 2, formally defined later as the I-zone of A in S. I may be represented by a portion of the CSG tree of 2.

1.3.4 Improve Shading from CSG. Shaded pictures of solids defined in CSG may be produced by computing the solids’ boundaries and by using boundary- oriented display algorithms, which are often supported by dedicated hardware. Owing to the high cost of boundary evaluation for large CSG representations involving curved surfaces, such approaches are too slow for interactive sessions, where users design solids in CSG by trial and error, and expect immediate graphic feedback from the program. Recent efforts on producing good-quality shaded pictures directly from CSG use special-purpose (parallel) hardware to speed up computationally intensive tasks [7, 111. A different approach, partly described in [26], combines commercially available depth-buffer hardware with a software preprocessing step based on the results reported here.

1.4 Feasibility of the Problems

A CSG representation is defined by

-a graph that encodes an expression that represents a Boolean function of several variables; and

-a semantics, which maps the variables (primitives) into subsets of w and interprets the internal nodes as Boolean set-theoretic operations.

A Boolean function may have many algebraic representations; for example, A . B + C can be represented by A . I3 . c + C or (A + C) . (B + C). The canonical

4 Invasive matching can be detected by testing whether P . S represents the empty set, given that P represents the final part or fixture, and that S is the region swept by a cutter. Goal attainment compares a model of the desired part P with the result R of proposed machining operations applied to a model of the original stock.

5 Tilove’s redundancy test for NOD is, in general, insufficient for detecting redundancy in nonempty sets and hence cannot replace the redundancy test based on active zones described in this paper.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 7: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 57

form used in the well-known Boolean algebra on binary variates (“switching- circuits algebra”), such as truth tables, Karnaugh maps, and normal sum-of- product form [B], has a number of terms that grows exponentially with the number of variables. Most, but not all, Boolean functions may be represented more concisely in a factored form [2] or in disjunctive form (reduced sums of products) [B]. These generally more compact algebraic representations, however, are not canonical forms and thus are not unique. Consequently, in binary Boolean algebra, satisfiability (testing whether there exists an assignment of variables such that the Boolean expression evaluates to 1) and equivalence (testing whether two algebraic expressions denote the same Boolean function), which are the Boolean counterpart of the null-object and same-object tests in CSG, require solutions to NP-complete problems [3].

In CSG, however, where variables are mapped into primitive sets that are intersections of a finite number of semialgebraic [ 171 half-spaces, these tests can be done through boundary evaluation, which has polynomial complexity [35], and hence are not NP-complete.

1.5 Organization of the Paper

In the remainder of this paper, we first introduce some conventions and termi- nology, and define the I-zone and active zone for each node of a CSG tree. Then, using standard results from Boolean algebra, we derive some fundamental prop- erties of these zones. Finally, we show how these properties may be exploited to improve the performance of trimming algorithms essential to boundary evalua- tion, redundancy detection, null-object detection, and shading. The Appendix describes in detail algorithms that trim candidate boundary elements against I-zones and against active zones.

2. PRELIMINARIES

2.1 CSG Tree Conventions and Terminology

Although a given set may have infinitely many CSG representations, we assume throughout this paper that to each set S is attached a particular CSG tree, called “the tree of S” or “the CSG representation of S.” Furthermore, to simplify the phrasing, when the meaning is obvious from the context, we use the name of the set to refer to its CSG tree and often omit expressions such as “CSG represen- tation of.” For example, instead of “the CSG representation of the primitive A in the CSG representation of the solid S,” we simply write “A in S.” Similarly, instead of “the active zone of the leaf node associated with the set A in the CSG representation of the solid S,” we simply write “the active zone of A in S.”

A general Boolean expression might contain several instances of the same primitive. For example, in Figure 1, C and D are rotated copies of I?, and could be stored in CSG as rigid motion nodes whose children are, respectively, B and C. The Appendix provides algorithms that accommodate CSG graphs with multiple references to the same node by processing each reference separately. For the sake of clarity, we consider here that each reference corresponds to a different node. Similarly, the algorithms based on results reported here fully support rigid motion operators attached to intermediate nodes of the CSG tree.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 8: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

58 l J. R. Rossignac iand H. B. Voelcker

However, since these operators play no role in the discussion below, we shall simply assume that rigid motion operators have been applied to appropriate subexpressions and consider primitives in their final positions and orientations, as in Figure 1.

Let S be a solid associated with a CSG representation that contains a node A. Although A will be treated as a primitive (leaf node), all results developed throughout this paper will hold if A is replaced by any CSG expression. Conse- quently, they can be applied, for example, to test directly whether an internal node is redundant.

The term literal will denote a primitive or its complement. An internal node F of the tree of S is a Boolean combination of two expressions represented by two subtrees: L and R. ‘We say that F is the parent of L and of R, which are, respectively, its left and right children, and that L and R are siblings. The path from the root S to the primitive A is defined as the set of nodes traversed by moving from S to A following the “parent-child” links of the tree. The path includes both S and A.

Nodes, whose path to the root contains an odd number of right children of a - node, are said to be negative. Nodes that are not negative are positive.

2.2 Positive Form

Our results apply to any CSG tree. However, to simplify definitions and proofs, we replace each algebraic representation of the Boolean function associated with a CSG tree by its positive form, which uses only regularized + and . operators, but represents rigorously the same Boolean function and thus the same solid as the original tree.

The three regularized operators, union, intersection, and complement, form a Boolean algebra over regular sets [18]. Therefore, De Morgan’s laws [28] can be invoked to manipulate CSG expressions.

Any CSG tree may be converted into its positive form by a preorder traversal of the tree applying, when appropriate, the following transformations to each node:

X-Y-X. 7, x+y+x. 7, x.y*X+P

x --, x.

This reformulation (illustrated in Figure 6) exchanges the . and + operators at negative internal nodes, replaces - operators by . if the corresponding node is positive and by + otherw.ise, and replaces negative primitives by their regularized complements. The resulting positive form contains only . and + operators. In a positive form, all nodes are positive, but may represent unbounded regular sets. However, the set represented by the entire positive form is equal to the solid represented by the original CSG tree, and hence is bounded (assuming the original primitives are bounded).

Any CSG tree can be expressed in a positive form, and thus, without loss of generality, we shall use a positive form throughout the rest of this paper. In ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 9: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG - 59

Tree reformulation: (A + B) - (C - D)

practice, however, the positive form need never be generated; our algorithms operate on the original tree.

Branching nodes associated with a primitive A in S are nodes whose parents are in the path from 5’ to A, but who are not, themselves, in that path. All branching nodes that are arguments of an . operator in the positive form of S are called i-nodes, and branching nodes that are arguments of a + operator in the positive form of S are called u-nodes (see Figure 9).

Let B be a branching node of A in S. We define the trimming set of B as the set represented by B, if B is an i-node, and as the complement of that set otherwise.

3. ACTIVE ZONES

The I-zone, respectively the U-zone, and the active zone of A in S will always be denoted I, respectively U, and 2. We define I, U, and 2 in terms of branching nodes:

Definition 1. I is the intersection of the universal set w with all the i-nodes of A in S.

Definition 2. U is the union of all the u-nodes of A in S.

Definition 3. Z is I - U.

These definitions yield CSG expressions that are easily derived from (the positive form of) S. For example, 2 is obtained by replacing A by w and interpreting + nodes of the path from S to A as - nodes. Consequently, classifying candidate elements against I, U, and 2 can be done by using a slightly modified version of set-membership classification algorithms developed for CSG [32].

We derive below some useful properties of I, II, and 2, and prove that Z (defined as I - U) is the region where changes to A affect S. An intuitive understanding of this property can be gained from the following considerations: The active zone of A in A . B is B, and the active zone of A in A + B is B (see Figure 7). For more complex trees, 2 is the intersection of active zones of path nodes with respect to their parents. For instance, in S = F + C, where F = A . B, the active zone Z of A in S is the intersection of the active zone c of F in

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 10: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

60 l J. R. Rossignac a.nd H. 6. Voelcker

Fig. 7. Simple active zones: In S = A . B (left), the active zone Z of A is B, because modifications to A out of B do not affect S and modifications to A in B affect S. Similarly, in S = A + B (right), the active zone of A is B.

Fig. 8. Combining active zones: In the tree A . B + C of S (left), the active zone of A is 2 = B . c = B - C (center). Changes to the shape of A outside of Z do not affect S, as shown by the broken boundary line of A outside of Z (right).

S with the active zone B of A in F, because changes to A will affect S only if they change F in its active zone (see Figure 8).

Note that I, U, and Z may be unbounded. If there are no i-nodes, then I = w, and if there are no u-nodes, then U = 0. For instance, if S is reduced to a single primitive A, then 2 = w - 0 = w, and in S = A + B, 2 = w - B = B.

By definition of the - operator, 2 = I - U = I . 0, and B is the intersection of the complements of all u-nodes. Consequently, I and 2 are expressed as intersections of the trimming sets of the branching nodes of A in S. We show in the following sections how this fact is exploited to speed up application algo- rithms.

If all primitives in S but A are fixed, the CSG tree of S may be viewed as a mapping from w to w that maps the set represented by A to the set S. Let S@, respectively S,, denote the sets corresponding to the CSG expressions derived by replacing A with 0, respectively w, in S. There is no negative node in the positive form of S, and therefore, adding material to any primitive may only add material to S (see Lemma 1 in [34] for a proof). Consequently, we present the following lemma:

LEMMA 1. S, c S c S,,

where C denotes set inclusion (note that X C Y does not imply that X is a proper subset of Y). Because + and . are commutative, we can consider an equivalent version of the positive form of the tree of S, where A corresponds to the leftmost leaf (see Figure 9). Distributing . over + produces a disjunctive form (union of products), where each product is the intersection of primitives. The first product contains the only instance of A intersected with all i-nodes. Since, by definition, I is the intersection of all i-nodes, S can be written as A . I + X, where X denotes the union of all other products that do not contain A. Clearly, when A is 0, we have S, = 0 . I + X; thus, X = SD, and we have the following proposition:

PROPOSITION 1. S = A . I + S,.

Similarly, distributing + over . in the positive form of the CSG tree of S, where A is the leftmost leaf, produces a conjunctive form (intersection of sums, where each sum is the union of primitives). The first sum contains the only instance of A combined through + operators with all u-nodes. Let Y denote the ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 11: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 61

Fig. 9. Branching nodes: Using the commutativity of the + and . operations, the tree (top) can be permuted to express the sequence of operations applied to the primitive A (bottom). The path to A is indicated by thicker lines. B, and B, are i-nodes, and B, and B, are u-nodes.

intersection of all other sums that do not contain A. Since U is defined as the union of all u-nodes, S can be written as (A + U) . Y. When A is w, we have S, = (w + U) . Y; thus, Y = S,, and we have the following proposition:

PROPOSITION 2. S = (A + U) . S,.

In Figure 9, S = Bq . ((B2 + A . B,) + B3), where the branching nodes Bi, for i E [l, 41, denote primitives or complex subexpressions. The tranformation described above yields S = ((A . B, + B,) + B3) . Bq, which can be rewritten as A . (B1 . B4) + (B2 + B3) . Bq, where B, and B4 are the only i-nodes. Consequently, S = A . I + S,, where 1= B, . B4 and S, = (B, + B3) . B4. Similarly, B2 and B3 are the only u-nodes for A in S, and the conversion to the conjunctive form produces S = (A + B2 + B3) . (B, + B, + B3) + B4, yielding S = (A + U) . S,, withS,=(B,+B,+Bg) .B4andU=B2+Bg.

Propositions 1 and 2 imply the following propositions:

PROPOSITION 3. A . I c S.

PROPOSITION 4. S C A + U.

Replacing A with w, respectively 0, in Proposition 1, respectively 2, yields Propositions 5 and 6:

PROPOSITION 5. S, = I + SD.

PROPOSITION 6. Se, = U . S,. ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 12: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

62 l J. R. Rossignac and H. B. Voelcker

By Proposition 5, S, - Se, = (I + S,) - Sa, and hence,

SW - se, = I - SD.

By Proposition 6, S, - Se, = S, - S, . U, and hence,

s, - s, = SW - u.

Consequently, we have the following proposition:

PROPOSITION 7. SW - &, = I - SD = S,., - U.

(1)

(2)

Note, however, that, although I C S, and Sp) C U, in general, I # S, and U # SD. For instance, in our previous example, where S = & . ((& + A . B,) + B3), we have

I = 131 . Bq C S, = (Bp + B3) . Bq + B1 . Bq, SD = (B, + Bs) . Bq c U = B, + Bz.

2 was defined as I - U, yielding a CSG tree that is convenient for trimming candidate sets (see the Appendix). However, a different, but equivalent, expres- sion for 2 is also useful:

PROPOSITION 8. 2 = S, - S,.

PROOF. By definition, i? = I - U. Because, for any set X, X . X = X, combining (1) and (2) yields S, - SC1 = (I - &) . (S, - U), and thus, S, - SD = I . & . SW * D. By Proposition 5, however, I C S,, and hence, I . S, = I. Similarly, by Proposition 6, SD C U, and thus, u C L%, implying SD . D = 0. Consequently,

s,, - S,=I. O=I-u=z. (3)

0

PROPOSITION 9. S = A . S, + S,.

PROOF

A . S,,. + Se, = A . (I + SE,) + SE,, by Proposition 5; = (A . I + A . S,) + Sra, =A . I+ &,, because a + a . b = a, for any a and b; = s, by Proposition 1. q

Proposition 9 was derived in [34] and also follows directly from Shannon’s expansion theorem [29]. It is used here to prove the following proposition:

PROPOSITION 10. S = A4 . 2 + So.

PROOF

S=A. S,+S,, by Proposition 9; =A. S,. &,+S,,, because a + b = a . 6 + b, for any a and b; = A . (S,., - S,) + SD, =A. Z+S,, by Proposition 8. 0

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 13: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 63

By Proposition 8, A . Z . SD = A . S, . SD . SD. But .!!?a + SD = 0, and thus, we have the following proposition:

PROPOSITION 11. A . 2 . SD = 0.

Propositions 10 and 11 imply that S is composed of two disjoint sets: S,, which is independent of A, and A . Z, which is “the contribution of A to S.” It follows clearly that all changes to A in Z will affect S, and conversely, changes to A outside of Z will not affect S. This is why we call Z the “active zone” of A in S.

Furthermore, Propositions 10 and 11 suggest a scheme for decomposing any solid represented in CSG into a union of disjoint sets, such that each set is defined by a product, that is, an intersection of literals (primitives or their complements). We call such a decomposition an augmented disjunctive form. It can be derived from any expression of the Boolean function of S by

(1) choosing a primitive A that is not factored out, (2) replacing S by A . Z + SD, (3) decomposing Z and Se, recursively, and (4) distributing A over the disjunctive augmented form of Z.

This recursive process always terminates, since Z and Sp) have smaller CSG representations than S.

A can be chosen to minimize the number of terms or the maximum of the number of literals found in any one term. We have not investigated the compu- tational costs of making such optimal choices.

4. BOUNDARY EVALUATION

This section shows how to use active zones to speed up boundary evaluation algorithms.

4.1 General Approach

The boundary of a CSG solid is contained6 in the union of the boundaries of its primitives. Simple, nonincremental boundary evaluation algorithms compute the boundary of a CSG solid directly from its tree by generating candidate elements (faces of all primitives in 3-D or edges of all primitives in 2-D), one at a time, and classifying them against the tree [20]. To classify a candidate element X that is a subset of the boundary aA of a primitive A against the solid S, the standard approach is to decompose7 X into three subsets:

-XinS, which lies in the interior of S; -XonS, which lies on the boundary of S; and -XoutS, which lies in the complement of S.

6 The boundary of a solid obtained by combining two solids through a regularized Boolean operation is contained in the union of the boundaries of these two solids [35]. For instance, a(A + B) C aA + aB. ’ The decomposition of X is the collection of connected open subsets of the set theoretic difference between X and its lower dimensional intersections with the boundaries of all other primitives [23].

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 14: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

64 l J. R. Rossignac and H. B. Voelcker

+

ff

. \ C

A B

S z

Fig. 10. Redundant boundary element: Given S = A . B + C (left), the point E of aA is on 6’s (center). E, however, is out of the active zone, Z = B - C, of A in S (right), and thus could be removed from aA without changing 5’.

Only the subset XonS is retained.8 However, boundary evaluation requires subsets of X that contribute to dS, and not the subset XonS, portions of which may happen to lie on dS but could be removed from aA (by adding or subtracting material to A) without changing the shape of S (see Figure 10). As shown below, computing these contributing subsets is sufficient and never more expensive- but often much cheaper-than computing XonS.

The redundant computa.tions inherent in nonincremental boundary evaluation are avoided in incremental boundary evaluation, which starts at the bottom of the tree and computes the boundary of each node by merging the boundaries of its two children. Unfortunately, even when intermediate boundaries are discarded as soon as they are used, incremental boundary evaluation may still require a large amount of storage for intermediate boundaries (see Figure 11). The nonin- cremental version, on the other hand, does not use more space than the minimum required to store &S.

We propose a new approach to boundary evaluation that combines the storage advantage of the nonincremental scheme with the efficiency of the incremental version.

Propositions 10 and 11 imply that only the shape of A-and thus of dA-inside .Z is relevant to the shape of S-and thus of dS. Therefore, if a subset X of c3A lies outside of 2, it need not be considered while evaluating dS. On the other hand, if X lies in the interior of 2, it will contribute to dS, because modifying aA in 2 will modify the shape of dS. Consequently, we can use the nonincremental boundary evaluation approach, if we replace the standard approach of classifying a candidate element X with respect to S, by an approach that trims X with respect to 2. The active zone is expressed as the intersection of trimming sets. Therefore, X may in the average case be reduced to (a-and thus discarded- after only a few trimming operations, and the trimming process stops without classifying X against all branching nodes. On the other hand, S contains all nodes of 2, and thus, our approach can never require more steps (which classify X against intermediate nodes and primitives) than the standard approach.

a In 3-D the union of the subsets XonS, for all faces X of all primitives of S, is equal to the boundary of S. Note that, unless coincident primitive faces are processed simultaneously, different XonS subsets may overlap and for many applications should be merged.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 15: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 65

Fig. 11. Cost of incremental boundary evaluation: Preorder traversal of the above tree for incremental boundary evaluation requires that five composite boundaries (nodes 3, 6, 9, 12, and 15) be stored at the same time, even though the final boundary may be empty.

Fig. 12. Redundant on/on element: The active zone of A in S = A . B is 2 = B (dashed). E lies on 2, but out of 2 . A. E is not part of KS, which is empty.

4.2 On/On Cases

To ensure that only boundaries of regular sets are produced, cases where X lies on dZ require a more detailed analysis. Let us consider the example of Figure 12, where E is a point of a subset X of dA. E is on the boundary of 2, but is not on dS. In a similar situation, depicted in Figure 13, E is also on the boundary of 2, but here it contributes to dS and cannot be ignored, because the corresponding point of dB would also be ignored-A and B play symmetrical roles-and &S would be incomplete. Such situations are typically handled by neighborhood evaluation [32]. Let N be a closed ball around a point E of aA, such that N is sufficiently small to be disjoint from all closed sets that are relevant for the classification of E and do not contain E. E will lie on dS, if and only if 0 # N . S # N; that is, N is partly in S and partly out of S.

An intuitive approach toward addressing the on/on cases described above could be to consider the relative positions of the intersections of N with A and with 2. Unfortunately, this information is not always sufficient to determine whether E is on &!5’ or not, as demonstrated in Figure 12, where E is not on dS, and in

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 16: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

66 l J. FL Rossignac and H. B. Voelcker

Fig. 13. Active on/on element: The active zone of A in S = A + B is 2 = B (dashed). E lies on 2, hut out of Z . A. However, here E is important for X?.

Figure 13, where E is on as. In both cases, the relative positions of the inter- sections of N with A and with Z are the same: N = N . A + N . 2 and (N . A) . (N . 2) = 0. Instead of considering N . A and N . 2, we use the following results to correctly process such singular cases.

4.3 Theoretical Background

Definition 4. Let E be a point on the boundary of a primitive A in the CSG representation of a solid S. E is redundant if it can be “removed” from dA without changing S, and E is active otherwise.

A point E may be “removed” from dA by adding N to A, which makes E an interior point [18] of A, or by subtracting N from A, which makes E an interior point of x. Note that Definition 4 does not apply to points of w, unless they are points on the boundary of a specified primitive in a specified CSG tree.

Let S(A t X) denote the solid defined by the CSG tree of S, in which the primitive A is replaced by the set X. For any set X, we have the following proposition:

PROPOSITION 12. X c :F+ S(A t A - X) = S.

PROOF. Let X C E It follows that I C X and I . X = I. Consequently,

S(A t A - X) = A . x . I + SD, obtained by replacing A with A - X in .Proposition 1; =A. I+&,, since I . X = I; = S, by Proposition 1. cl

PROPOSITION 13. X c U + S (A c A + X) = S.

PROOF. Let X C U. It follows that X + U = U. Consequently,

S(A t A + X) = S,, . (A + X + U), obtained by replacing A with A + X in Proposition 2; = ser * (A + U), since X + U = U; = S, by Proposition 2. 0

Proposition 12 implies that one can subtract from A pieces that are out of I without changing S. Similarly, Proposition 13 indicates that adding to A pieces in U does not change S. ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 17: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 67

Let Ni = N . A and ND = N . x, where N is a sufficiently small ball around a point E of dA, as defined above. Ni C T@ Ni . I = 0, and ND C U H Na . 0 = 0. Consequently, by Definition 4, substituting Ni for X in Proposition 12 and N@ for X in Proposition 13 yields the following proposition:

PROPOSITION 14. (Ni . I = 0 or Na . 0 = 0) + E is redundant.

Complementing Proposition 14 yields Proposition 15:

PROPOSITION 15. E is active + (Ni - I # 0 and Na . .!? # 0).

On the other hand, we have Proposition 16:

PROPOSITION 16. Ni . I # 0 + E E S.

PROOF. Let Ni . I # 0. By definition, Ni = N . A and thus N . A . I # 0. 0

Suppose E 4 N . A . I. It follows that E must be in the interior of N . A . I. However, by definition, E is on aA and in N, and therefore E E N . A. Consequently, E must be in the interior of z and we can choose a smaller N containing E, such that N C rand for which N . A . I = 0. This contradicts the assumption that the original N was sufficiently small. Consequently, Ni . I # 0 + E E N . A . I, and since by Proposition 3, N . A - I C A - I C S, we have

Ni*I#Q*EES.

PROPOSITION 17. Ne, . 0 # 0 + E E 3.

PROOF. By definition, NG = N . A and E E N . A. As in the proof of Proposition 16, No . 0 = N . x . u # 0 + E E N . A + u. Complementing Proposition 4 yields N . K . u C A . i!? C $ and therefore, E E 3. 0

Because dS is the (nonregularized) intersection of S with $ Propositions 16 and 17 imply Proposition 18:

PROPOSITION 18. (Ni - I # 0 and ND - u # 0) + E E X3.

Let Bpriiitives be the union of the boundaries of the primitives of S. -Let Bactive be the set of points E of the boundary of each primitive A of S such that Ni . I # 0 and Ne, . D # 0. Proposition 18 implies that Bactive C dS, and Proposition 15 implies that Bactive contains all active points of Bprimitives and, therefore, that dS C Bactivea Consequently, we have the following proposition:

PROPOSITION 19. Bactiue = X3.

,Note that, by definition of 2, when E is not on both dI and dU, -

(Ni* I#~u&N~* U#~)WEEZ.

4.4 Algorithm for Boundary Evaluation

The above results lead to algorithms, described in the Appendix, that correctly perform boundary evaluation by trimming candidate sets (that are subsets of primitives boundaries) using the I-zones and U-zones of the corresponding primitives. Let X be a candidate set coming from the boundary of a primitive A

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 18: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

68 l J. R. Rossignac atrld H. B. Voelcker

in S. We trim X against each branching node of A in S until X becomes empty or until all branching nodes are processed.

To trim X against any p,articular branching node B, we first decompose X into full-dimensional connected subsets, such that the neighborhood of each interior’ point of a given subset x of X is constant with respect to the trimming set of the branching node B (i.e., the interior of x is either entirely inside B, entirely outside of B, or entirely on dB). Then, we check whether the condition

Ni - If0 and Ner. D#0

still holds for the interior points E of each subset x, and we discard subsets for which it does not. At each node we only need to test for one of the two inequalities: For i-nodes, test Ni . I # 0, and for u-nodes, test Na . o# 0. The decomposition of X described above ensures that, at each node, both Ni and NpI can only take two values (Ni . I = 0 or Ni . I = Ni, and ND . 0 = 0 or ND s rf = ND). Furthermore, these values are constant for all interior points E of x. The subset x is rejected as soon as Ni or Na becomes empty.

For 2-D faces of 3-D models, the decomposition with respect to any trimming set of a node B may be done through face/solid classification [20], or simply by first decomposing the face at its 1-D intersections with all primitive faces of B and then computing the binary neighborhood of any interior point of an element of this decomposition.”

Consequently, to classify a full-dimensional subset X of the boundary of a primitive A, we need not rnanipulate complex neighborhoods but simply trim X against the trimming set of each branching node B, as follows:

(1) classify X against B using a standard approach [20, 321; (2) between the two sets .XinB and XoutB, discard the one that lies out of the

trimming set of B; (3) discard portions of XonB that separate the interior of A from the interior of

the trimming set.

On the other hand, lower dimensional subsets of the boundary of S (edges in 3-D and vertices in 2-D) may be obtained by retaining the boundaries of the subsets x, produced as explained above, when these boundaries do not separate two such adjacent subsets [23], or for 3-D solids, directly in a more standard fashion, by generating 1-D intersections of all pairs of primitive faces, and then classifying each one of such intersections C against the I-zones and the U-zones of all the primitives whose boundary contains C. This classification can be done in a single traversal of the tree. It uses edge neighborhoods [20] to combine results obtained by invoking a standard curve membership classifications proce- dure at each branching node.

Curve membership classification of a curve C against a CSG representation of some trimming set T associated with a branching node B segments C into three

’ “Interior of x” refers to the relative topology of X as a subset of w. lo A naive approach to this decomposition separates a face X into cells (open connected subsets) that are disjoint from the boundaries of the primitives [23] of B. If B is defined in terms of n half-spaces, X could theoretically be decomposed into 2” cells. For simple ha!f-spaces, however, we obtain only quadratic asymptotic complexity.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 19: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 69

subsets: CinT, ConT, and CoutT, which, respectively, lie in the interior of T, on the boundary of T, and in the complement of T. Curve membership classification may be implemented in a divide-and-conquer manner, which, according to the Boolean expression associated with the CSG tree of T, combines results of classifying C against the primitives of T [20]. Curve/primitive classification requires the computation of O-D curve/surface intersections. Combining is done at each node by merging 1-D interval lists in a Boolean manner. When a subset of C lies on more than one primitive face, the evaluation of an edge neighborhood [20] for each segment may be required to produce correct classification results. An edge neighborhood is the intersection with T of an infinitely small disk around some interior point P of the curve segment. The disk lies in the plane orthogonal to the tangent to the curve at P. Only edges with neighborhoods that are neither full nor empty are kept.

Note that, in practice, the candidate set X is often reduced to 0 after being trimmed against only a few branching nodes, and the trimming process stops before the whole path is traversed. The order of traversal along the path may be chosen to first-visit branching nodes that offer the best compromise between the probability of annihilating X and the classification cost. Choice strategies leading to minimum trimming costs are not discussed here.

5. REDUNDANCY ELIMINATION

This section describes a new method for detecting redundancy in CSG.

5.1 Definition

Tilove distinguishes two kinds of primitive redundancy [34]:

Definition 5. A primitive A is 0-redundant in S, if and only if S = S,. A primitive A is w-redundant in S, if and only if S = S,.

We shall simply say that a primitive is redundant if it is 0-redundant or W-

redundant. Simple cases of redundancy are illustrated in Figure 14.

5.2 Elimination

In a positive form of a CSG tree of S, if a primitive A is O-redundant, it can be replaced by 0, and the CSG expression of S can be simplified by applying bottom- up the following rewriting rules to the nodes of the path from A to S:

B - 040 and B+04B,

where B is any branching node. Similarly, if a primitive A is w-redundant, it can be replaced by w, and the expression S can be simplified by applying

B. w-+B and B+w+w.

For example, the above simplification transforms (B + C . 0) + D . (E + W)

into B + D.

5.3 Detection

Definition 5 suggests that one can determine whether a primitive A is 0- redundant by testing whether S = S 9, or equivalently whether the symmetric difference (S - SD) + (& - S) represents the empty set. Note that, since by

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 20: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

70 l J. R. Rossignac and H. B. Voelcker

(a) (b) (c) (d)

Fig. 14. Redundancy examples: In S = A + B (a), A is 0-redundant because A C B, and therefore, S = A’, = B. In S = A . B (b), A . B = 0; therefore, S = 0, and A and B are both Id-redundant. In S = A . B (c), B C A and S = S, = B; therefore, A is w-redundant, but not O-redundant. In S = A . B + C (d), A is both (a-redundant and w-redundant because S = SD = S, = C.

Lemma 1, SD C S, it is sufficient to test (S - So). A similar approach can be used to test for w-redundancy; namely, check if S, - S represents the empty set. However, the above NOD tests involve CSG expressions that are unnecessarily complex, and the two following propositions indicate how active zones can be used for more efficient redundancy detection:

PROPOSITION 20. A is w-redundant if and only if it contains its active zone.

PROOF

S=S,*A. S,+S,=S,, by Proposition 9; H s, * (A + 5’~) = Sw, since S@ c S, and SD = S, . SD; H S, c A + SD, because Vatlb, a . b = a H a c b; w s, - A * ;(:a = 0, because VaVb, a C b w a . b = 0, * 2 - K = 0, by Proposition 8; wZCA. Cl

PROPOSITION 21. A is 0-redundant if and only if it does not intersect its active zone.

PROOF

S=&,HA. S,+S,=S,, by Proposition 9; WA. S,cS,, because VaVb, a + b = b M a C b; w A . S, . &, = 0, because Vatlb, a C b H a . F = 0; w Z . A = 0, by Proposition 8. 0

When Z = 0, A is both 0-,redundant and w-redundant (e.g., see Figure 15). Although these tests pertain to the NOD problem discussed later, they offer

an approach to redundancy detection that is more efficient than testing whether S - S, or S, - S represent 0, because the trees Z . A and Z - A are simpler than S - S, and S, - S, and because most of the work necessary for testing each tree for nullity can be done simultaneously for both trees, as follows. ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 21: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 71

B=C

fi

Fig. 15. Double redundancy: In 5’ = A . B + C, where

. C B = C, A is both 0-redundant and w-redundant, becauseZ=IZI;thus,Z.A=0andZ-A=0.

A B

Fig. 16. Early rejection in redundancy detection: In S = (A + C) . B (left), where A . B = 0 (right), A is 0-redundant. Trim- ming the edges of A against Z (following the path from S to A) results in early rejections, because all edges of A are out of B and thus need not be classified against C.

A

5.4 Algorithm for Redundancy Detection

Let A be a primitive in a positive form representing a 3-D solid S.” To test A for (a-redundancy and w-redundancy, we first use the algorithm in the Appendix to trim the faces of A against 2. The trimming operation segments the boundary elements of A into connected full-dimensional subsets, called regions, such that each retained region falls into exactly one of the following three categories:

-Frozen region, whose interior” points are in the interior13 of 2; -No-grow region, which is coincident with dZ and separates the interior of Z

from the interior of A; and -No-shrink region, which is coincident with dZ and is disjoint from the no-grow

region.

For each face, the trimming process visits all branching nodes of A in S. The order may be chosen to maximize the probability of early rejection. At each node the process divides the regions along their 1-D intersection with the boundary elements of the corresponding trimming set. Subregions that do not fall into any of the above three categories are discarded. The process stops as soon as the set of remaining regions is empty. Figure 16 illustrates a 2-D case where the trimming process for boundary elements of A always stops before all branching nodes are visited.

At the end of this process,

-if there is at least one frozen region, then A is not redundant (see Figure 17a, b, and c).

-if there is at least one no-shrink region, then A is not 0-redundant, because shrinking A to 0 would modify its intersection with 2 and thus would modify S (see Figure 17g and i); and

‘I The same algorithm may be used in 2-D.

I* If a 2-D region R1 is contained in a surface S,, “interior” points of R1 are defined in the relative topology of S, in w. I3 The “interior” of a 3-D region Z is the set of points P contained in some open subset of Z.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 22: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

72 l J. R. Rossignac and H. B. Voelcker

\ G \ (a) @ 0 w

b)

k)

(cl \‘ \ Q \ \ \

(h)

(d)

(9

0 \ \ \\ (4 \ \

Q \\ \ \ A \ (3

Fig. 17. Topological situations for redundancy detection: For each case, the active zone is dashed, and the primitive A is a disk with a thick boundary. Test 1: In (a), (b), and (c), A is not redundant because dA intersects the interior of 2. In (g) and (i), A is not PI-redundant because 8A is a no-shrink region. In (h) and (j), A is not w-redundant because c?A is a no-grow region. Test 2: In (d), (e), and (j), A is not (a-redundant because a2 intersects the interior of A. In (d), (f), and (i), A is not w-redundant because 82 intersects the exterior of A. Conclusion: A is (a-redundant in (f) and (h) and w-redundant in (e) and (g).

-if there is at least one no-grow region, then A is not w-redundant, because growing A to w would modify its intersection with 2 and thus would modify 5 (see Figure 17h and j).

Consequently, if there is at least one frozen region, or one no-shrink and one no- grow region, then A is not redundant, and the test stops. However, as demon- strated by Figure 17d, primitives not rejected by the first test need not be redundant. For these primitives, results of the first test must be complemented with a second test, in which one computes the intersections of the boundary of 2 with the interiors of A and x. This second test can be performed in a variety of ways, but one should avoid testing for cases already rejected in the first test. Specifically, faces and edges of Z that intersect the boundary of A have already been processed. Consequently, the second test in 3-D amounts to generating the edges of 2, and, for each connected edge segment, testing whether it lies in A or in A. This inclusion test can be done by simply generating an interior point of each edge segment and classifying it against A. (For simplicity, we assume each face has at least one edge. E.g., a ball primitive would be bounded by two semispherical faces separated by a fake circular edge.) Edge classification may stop as soon as the nonredundancy of A can be determined. For example, if the first test indicates that A is not w-redundant, the second test stops as soon as an edge of 2 is found inside A. The computational complexity of the process of ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 23: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 73

generating the edges of Z and several spatial decomposition techniques for improving its efficiency are described in [33, chap. 31.

Note that, when a primitive appears more than once in a CSG representation, it is possible that some, but not all, of its instances are redundant. To reduce the tree as much as possible, we suggest that all instances of each primitive be tested for redundancy independently using the method described here.

5.5 Order Sensitivity Redundancy detection and elimination must be done for one primitive at a time because redundancy conditions can be altered by tree simplifications resulting from the elimination of redundant primitives. For example, in 5’ = A + B, if A = B, both A and B are O-redundant, but if A or B is replaced by 0, the remaining primitive is not redundant any more in the simplified tree.

If the simplicity of a CSG tree is measured by the number of primitives, then the simplicity of the tree resulting from redundancy elimination is dependent on the order in which primitives are tested for redundancy and possibly eliminated. For example, in S = A + (B + C), where A represents the same set as B + C, A is 0-redundant because (2 = B + C and A . 2 = 0), and can be replaced by 0, which reduces S to B + C. The simpler expression, S = A, could be obtained by first eliminating B, which is 0-redundant in S, and then C, which is 0-redundant in the tree A + C resulting from the elimination of B.

We do not propose optimal strategies for ordering redundancy tests in algo- rithms that automatically simplify CSG representations. Nevertheless, the results derived below should be taken into consideration when developing such strategies.

We show that a primitive A, not 0-redundant (respectively, w-redundant) in S, cannot become 0-redundant (respectively, w-redundant) in a simplified ver- sion of S obtained by removing another (a-redundant (respectively, w-redundant) primitive B.

PROPOSITION 22. A is 0-redundant in S, and B is O-redundant in S(A t Ca), if and only if B is 0-redundant in S and A is 0-redundant in S(B t 0).

PROOF. The form

S=A.J+B.K+A.B.L+M, (4)

where the terms J, K, L, and M contain no references to A or B, is obtained by ordering and factoring the disjunctive normal form of S in terms of A and B. Let A be 0-redundant in S, and B be 0-redundant in S(A t 0). Substituting 0 for A in (4) yields

S=B.K+M, (5)

and substituting 0 for B in (5) yields

S = M. (6)

Combining (4) and (6) yields A . J C M, and therefore,

M=A.J+M, (7) ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 24: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

74 - J. FL Rossignac and H. 8. Voelcker

implying that A is 0-redundant in S(B t 0), which is equal to A . J + M. Substituting (7) in (6) yields

S=A.J+M, (8)

implying that B is O-redundant in S. We have shown that “A 0-redundant in S, and B 0-redundant in S(A t 0)” implies “B 0-redundant in S, and A 0- redundant in S(B t 0).” The converse implication is true by symmetry of (4) with respect to A and B. 0

PROPOSITION 23. A is w-redundant in S, and B is w-redundant in S(A t w), if and only if B is w-redundant in S, and A is w-redundant in S(B t w).

PROOF. The form

S = (A -t. J) . (B + K) . (A + B + L) . M, (9)

where the terms J, K, L, and M contain no references to A or B, is obtained by ordering and factoring the conjunctive normal form of S in terms of A and B. Let A be w-redundant in S, and B be w-redundant in S(A t w). Substituting w for A in (9) yields

S = (B + K) . M,

and substituting w for B in (10) yields

(10)

S = M.

Combining (9) and (11) yields M C A + J, and therefore,

(11)

M = (A + J) . M, (12)

implying that A is w-redundant in S(B t w), which is equal to (A + J) . M. Substituting (12) in (11) yields

S = (A + J) + M, (13)

implying that B is w-redundant in S. We have shown that “A w-redundant in S, and B w-redundant in S(A t w)” implies “B w-redundant in S, and A W-

redundant in S(B t w).” The converse implication is true by symmetry of (9) with respect to A and B. 0

By Proposition 22, if A is 0-redundant in S, and B is not 0-redundant in S(A t 0), then inverting the order in which primitives A and B are tested will not lead to the elimination of both A and B. Proposition 23 implies a similar result for w-redundancy. TJnfortunately, a primitive that is not w-redundant in S might become w-redund.ant in a simplified version of S obtained by replacing in S a O-redundant primitive by 0 (e.g., see Figure 18). Consequently, testing each primitive of a CSG t:ree S only once for w-redundancy and O-redundancy will not necessarily lead to the simplest equivalent tree. Therefore, to simplify a CSG tree and obtain a tree where no single primitive is redundant, one must test repeatedly all the primitives for O-redundancy and w-redundancy until none of the remaining primitives is redundant. As indicated earlier, for each primitive, [a-redundancy and w-redundancy tests are done simultaneously. ACM Transactions on Graphics, Vol. ,3, No. 1, January 1989.

Page 25: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 75

Fig. 18. Order-sensitive redundancy elimina- tion: The primitive B is not w-redundant in the CSG expression S = (A + C) . (B + D,) that corresponds to the hatched region on the left, because it does not contain its active zone (A + C) - D. However, B becomes w-redundant in the simplified expression C . (B + D) obtained by eliminating the 0-redundant primitive A from S.

6. NULL OBJECT DETECTION

This section demonstrates how I-zones can be used to improve NOD in CSG.

6.1 Tilove’s Test

A null object can have a complex CSG representation; therefore, NOD based on boundary evaluation can be slow. Tilove [ 341 proved that in a CSG representation of a null object all positive14 primitives are O-redundant and developed a more efficient approach to NOD based on a redundancy test. The 0-redundancy test described above was not known at that time. Tilove used for NOD the following test based on a sufficient, but not necessary, condition for redundancy:

if A . S = 0 then A is (a-redundant else S # 0.

Tilove’s Q-redundancy test (A . S = 0?) works in NOD but cannot be used for systematic 0-redundancy detection in nonnull objects (e.g., see Figure 19). Furthermore, even in NOD, the performance of Tilove’s test can be improved by eliminating certain redundant calculations illustrated in Figure 20.

6.2 I-Zone Test

Since 2 = I - U C 1, A . I = 0 implies that A . 2 = 0, which, by Proposition 21, implies that A is (a-redundant. On the other hand, by Proposition 3, A . I # 0 implies S # 0. Consequently, one can replace Tilove’s test with a generally more efficient test:

if A - I = 0 then A is O-redundant else S # 0.

Although the positive form of S may contain subexpressions that correspond to unbounded sets, it is equivalent to a standard CSG expression and thus always defines a bounded solid. Consequently, by Proposition 3, A . I is also bounded. A bounded solid is empty if and only if its boundary is empty; therefore, we propose to test A . I for nullity by evaluating its boundary.

In the boundary evaluation of A . I, boxing techniques described in [6], [34], and [39] can be used efficiently to prune the tree I by first replacing by 0 all primitives guaranteed not to intersect A, and then simplifying the resulting tree. Similarly, all primitives containing A could be replaced by w.

A . I = 0 may be tested by first trimming the faces of A against I (see the Appendix). If the resulting set is not empty, then S # 0. On the other hand, if

l4 Remember that all primitives are positive in the positive form of a CSG expression.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 26: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

76 l J. FL Rossignac and H. B. Voelcker

Fig. 19. Redundancy not detected by Tilove’s test: In S = (A + B) . C (left), A . S # 0, but A is 0-redundant, because Z=C-BandA. Z=0(right).

Fig. 20. Improving redundancy detection in NOD: The solid S defined by A . B + C . D is null, because A . B = 0 and c . D = 0. To conclude that A is 0-redundant, a straightforward implemen- tation of Tilove’s test (A . S = O?) requires processing C and D, which are skipped by our test (A . Z = 0?).

all faces of A are trimmed to 0, we must still check that there is no boundary of I in A. Here again, as discussed in the preceding section, in 3-D we construct the edges of I and classify against A an interior point of each connected edge segment.

The trimming algorithms for redundancy tests in NOD do not require visiting subtrees spanned by u-nodes, and in general, reduce the candidate elements to 0 before all i-nodes are traversed. In the worst case, there are no u-nodes, and our test leads to the same amount of computation as Tilove’s test and, therefore, exhibits the same worst-case complexity.

6.3 Strategies for Ordering Redundancy Tests

The order in which primitives are tested for Q-redundancy may influence the overall performance of NOD algorithms.

6.3.1 O-Order Primitive:; Only. Primitives that are negative in the original tree (before conversion to the positive form) are replaced, in the positive form, by their complements. Since in most systems solid primitives are bounded, their complements are unbounded sets, which are expensive to process, since they typically intersect most other primitives, and thus, the rejecting power of boxing techniques is less effective in this case. Tilove proved that, in NOD, one only needs to consider primitives that are positive in the original tree. In fact, as shown by Cameron, one only needs to consider O-order primitives, that is, primitives whose path does not branch to the right child of a difference operator in the original tree. Eliminating a O-order primitive rather than a non-O-order primitive generally results in greater reduction of the tree (Figure 21). Selecting only O-order primitives is easily achieved by always picking the leftmost primitive in the current tree. However, this choice may lead to more calculations than necessary.

6.3.2 Maximizing Tree Reduction. Eliminating a 0-redundant primitive A eliminates at the same time all “early” i-nodes of A. Early i-nodes are defined as the branching nodes that are children of . nodes (in the positive form) encoun- ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 27: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG . 77

D D

A

m 0 D

B C

Fig. 21. Testing O-order primitives first: In the tree S = A - (B - (C + II)), on the left, A, C, and II are positive, as indicated in the equivalent positive form (center). The corresponding solid (right) is empty, and thus, A, B, and C are Id-redundant. A is the only O-order primitive, and its elimination suffices to pro- duce an empty tree. On the other hand, the elimina- tions of both C and D are insufficient to determine that S = 0.

tered by moving up the path (from A to S) until the first + node is reached. Clearly, if A is 0-redundant, then each . node encountered during this ascension is also O-redundant, because it is the intersection of A with other i-nodes. Consequently, the tree reduction that results from the elimination of a 0- redundant primitive A is proportional to the number of primitives in the early i-nodes of A.

To eliminate the maximum number of primitives at each 0-redundancy test, one could always pick the primitive that has the maximum number of primitives in its early i-nodes. This choice may lead, however, to suboptimal results (Figure 22), because, as discussed below, the number of operations involved in merging sorted interval lists during a 0-redundancy test is a nonlinear function of the number of primitives in the i-nodes of A. Consequently, picking the primitive that has most early i-nodes may be more expensive than the algorithm we propose later.

6.3.3 Minimizing the Worst-Case Cost. The NOD redundancy test for a single primitive A is done by trimming tentative boundary elements against the i-nodes of that primitive. Trimming is done through set-membership classification [32].

6.3.3.1 Cost of Trimming Against an i-Node. In 2-D the tentative elements are the edges of A. Edge classification against an i-node 23 may be done in a divide- and-conquer manner by first classifying the edge against each primitive of B, and then merging the classification results up the tree spanned by B. Typically, classification against a primitive return a possibly empty interval in some parameterization of the edge. Merging i- Aone by combining two sorted interval lists accordingly to the Boolean operator at each node. In the worst case, merging two interval lists of length L, and L, can produce an interval of length L, + Lz, and the merging cost is P log(P), where P denotes the number of primitives in the tree of B [33]. Consequently, the cost of classifying an edge X of A against B that has P primitives is, in the worst case, equal to P times the cost of computing the intersection of X with a primitive, plus P log(P) times the cost of comparing two numbers and possibly inserting a number in a sorted list.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 28: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

78 l J. R. Rossignac and H. B. Voelcker

Fig. 22. Minimizing the NOD cost: In the tree A . (B . X + C . Y), X and Y are balanced trees that represent the union of eight primitives. A is the prim- itive that has most primitives in its early i-nodes, and eliminating A suffices to declare that the object is null. In the worst case, however, testing A for 0-redundancy involves roughly twice the cost that would be incurred in merging interval lists while testing both B and C.

In 3-D the tentative elements are faces of A. They may be classified, for example, by computing their 1-D boundaries, that is, first computing and then classifying tentative edges that are intersections of the faces of A with the faces of all other primitives. In the worst case, there are order P tentative edges, because we must intersect the faces of A with the faces of each primitive. Thus, the worst-case asymptotic classification cost in 3-D is P times the worst-case asymptotic classification cost in 2-D.

Experience shows, however, that worst-case asymptotic complexity is too pessimistic to be useful. The average-case complexity depends on the geometric organization of the primit:ives [33] and can be reduced, as mentioned earlier, by using a pruning tree obtained by replacing by 0 all nodes that represent sets clearly disjoint from A.

6.3.3.2 Total Cost of Testing a Node for 0-Redundancy. The cost of testing for 0-redundancy a node T that corresponds to a + operator in the positive form of S is equal to the sum of the costs of testing its two children for 0-redundancy. (T can be replaced by 0 only if both its children are (a-redundant.) On the other hand, the cost of testing for 0-redundancy a node T that corresponds to an . operator in the positive form of S is equal to the minimum of the costs of testing each one of its children for redundancy. (T can be replaced by 0 if any one of its children is 0-redundant.)

These remarks suggest a simple two-pass algorithm that will recursively estimate the cost of testing a node for redundancy. The first pass computes the number of primitives spanned by each node. The second pass computes the total number of primitives in the I-zone of each primitive, then estimates the worst- case cost of testing each primitive, and finally merges this cost up the tree. At each node the best alternative is produced, that is, a collection of primitives to be tested for 0-redundancy. In the worst-case configuration, when the object is ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 29: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG - 79

null, testing these primitives will be the cheapest process for deciding on nullity. Furthermore, we also know that, if the object is null, we will not be able to assert that fact until all the selected primitives are tested.

Note that our analysis does not take into account any geometric considerations, which strongly influence the cost of testing a single primitive.

7. SHADING

Shaded pictures of a solid S defined in CSG can be obtained, among others, by ray casting or by depth buffering [lo, 261. For both ray casting and depth buffering, one can design shading algorithms that classify points against S, and that do not require distinguishing between points on dS and points in the interior of s.

7.1 Ray Casting

Ray casting in CSG [27] can be organized as follows:

(1) Compute rays from the view point through each pixel of the screen; (2) for each ray, compute its O-D intersections with the boundary of the primi-

tives of the CSG representation of S; and (3) sort these intersection points along the ray, remembering what primitive is

intersected at each point and whether the ray enters or leaves the correspond- ing primitive.

The intersection point is said to be front-facing if at that point the ray enters a positive primitive or leaves a negative primitive. It is easy to show that only front-facing points may be visible.

These intersections divide the ray into connected segments that are either entirely in the interior of S, out of S, or on the boundary of S. Finding which intersection point is visible can be done as follows:

-Starting from the front-facing intersection closest to the view point, classify the ray segment immediately behind the intersection;

-stop if it is on or in S; -otherwise, go to the next front-facing intersection point, and continue this

process until a segment in or on S is found, or until all segments are processed.

If a segment on or in S is found, compute the light reflected by the surface associated with the front vertex of the segment (the vertex closest to the view point) and write the appropriate colors and intensities at the pixel associated with the ray.

A segment X that starts at a front-facing intersection of the ray with the boundary of a single primitive A lies entirely in the primitive that corresponds to A in the positive form of S.15 Consequently, because X C A, by Proposition 3, if X C I, then X C S. On the other hand, let X P I and suppose X C S. By Proposition 1, X C SD, implying that the ray was already inside S before it intersected the front-facing point of the boundary of A, which is impossible,

I5 This primitive is either A or d

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 30: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

80 l J. FL Rossignac and H. B. Voelcker

because we check the segments in order, starting from the view point, which is assumed to lie outside of S. Consequently, if our algorithm reaches a segment that does not lie in the I-zone of a primitive that it just entered, then this segment is not in S, and its front vertex is not visible.

If X starts at the intersection of the ray with the boundaries of more than one primitive, we classify X simultaneously against the I-zones of all these primitives. Boundaries of primitives that correspond to positive results of this classification are all visible at the front vertex of X (either because this vertex lies on an edge or a vertex of S or because it lies on two or more coincident primitive faces) and can be used to determine the intensity at that corresponding pixel.

To classify X against one or several I-zones, it suffices to classify the midpoint of X against them, as described in this paper.

7.2 Depth-Buffer Shading

Computing the intersection of a ray with the boundary of a primitive A is expensive, especially when A is bounded by nonquadric curved surfaces. Inter- section calculation may be avoided by covering the boundary of S with a dense grid of points and by using depth-buffer hardware for checking which points are visible. Since computing the boundary of S is generally expensive, the depth- buffer shading technique was adapted for CSG [26] as follows: Cover each primitive A with a dense grid of points, and then check whether these points are in S before considering them for display.

Because the depth-buffer test will automatically reject points that are in the interior of S, we can reduce classification costs by classifying only the Ni neighborhood of a candidate point E of dA against I. If Ni . I # 0, then, by Proposition 16, E E S, and thus, E is either on dS (in which case it will be displayed, unless it is hidden by some other part of S) or in the interior of S (in which case it must be hidden by points on dS and will ultimately be rejected by the depth-buffer test). On the other hand, if Ni . I = 0, then, by Proposition 14, E is redundant and should be discarded.

Consequently, candidate points of dA need only be classified with respect to I instead of 2, and u-nodes can be skipped, which on average considerably reduces the cost of set-menibership classification. For example, displaying solids com- posed of unions of primitives does not require any classification at all.

7.3 Complexity

The asymptotic complexity of the two shading schemes mentioned above is not altered by the use of I-zones instead of the original tree. However, because solids, or their subcomponents, are often defined as unions of simpler solids, the use of I-zones saves a considerable proportion of point-primitive classification.

Our approach based on I-zones is advantageously combined with other effi- ciency enhancements such as tree pruning, sampling, and hardware depth buff- ering and polygon filling, which considerably improve performance [26].

8. CONCLUSION

To improve the average efficiency of boundary evaluation algorithms in CSG, we introduced the concept of active zones. To each primitive or node A in a given CSG representation of a solid S, we associate the two sets I and U. These sets ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 31: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG - 81

do not depend on the shape of A, but on its position in the particular CSG representation of S, and on the shape of certain other primitives in that repre- sentation. CSG representations for I and U are readily available as combinations of certain nodes of the tree of S. The active zone Z of A in S is defined by I - U and is the region where changes to A affect the shape of S. A is redundant if it contains Z or if it does not intersect 2. The boundary of S can be computed by trimming the boundary of each primitive using the trees of I and U associated with that particular primitive. On average, this approach leads to early rejection of the classified elements and thus permits the reduction of the amount of redundant computation performed by various boundary evaluation algorithms. However, it does not change the worst-case asymptotic complexity of the problem. In fact, in the worst case, our trimming algorithms perform the same amount of work as the more popular algorithms that classify all candidate sets against the tree of S. Our approach to boundary evaluation combines the computational performance of the incremental methods with the storage advantages of the nonincremental methods.

We show that, for shading and NOD, classification algorithms may be replaced, without additional cost, by algorithms that trim candidate elements against I only, and thus, we do not need to consider the whole tree of S.

To illustrate our approach, we provide a detailed description of algorithms, which trim candidate elements of the boundary of each primitive against its I- zone and U-zone for boundary evaluation, redundancy detection, NOD, and shading. These algorithms are meant to be used in conjunction with known algorithms for performing geometric calculations and set-membership classifi- cations and with performance-improving preprocessing steps, based, for example, on an analysis of the spatial position of the primitives.

The concepts reported in this paper have been successfully implemented by the authors in experimental systems for redundancy detection, boundary evalu- ation [21], and shaded picture generation [26]. They also provided a theoretical foundation for some improvements of Tilove’s NOD algorithm.

APPENDIX. Classification Algorithms

The positive form can be obtained by changing certain operators and comple- menting certain primitives in the original tree. In practice, however, such changes need not be stored and can be simply recomputed on the fly by all application algorithms that traverse the tree top down. It is sufficient to keep track of the sign of the current node. For internal nodes, from the sign of the node and the associated Boolean operator, one computes the signs of its children, and the equivalent operator in the positive form of the tree (it can only be + or .). For that, we use a simple table derived from de Morgan’s laws. For example, when the sign is negative and the operator is -, the equivalent operator in the positive form would be +, and the sign of the left child is negative, but the sign of the right child is positive. For leaves, if the sign is negative the primitive is treated as if it.were replaced by its complement. Consequently, trimming a subset of the boundary of some primitive A with respect to the I-, U-, or Z-zones of A in S can be done on the original tree of S and does not require building CSG trees for I, U, or 2. The possibility of processing the equivalent positive form on the fly, without altering the original tree is particularly important when solids defined

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 32: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

82 l J. FL Rossignac and H. B. Voelcker

by combining several instances of the same subsolid are encoded in a directed graph, rather than in a binary tree. Converting a graph into a tree requires replicating trees spanned by nodes used more than once and can significantly increase the size of the CSG representation and complicate the support of parameterized models and editing operations.

We suggest here a possible organization of trimming algorithms for the various applications described in this paper. We use a pidgin version of the AML/X high-level programming language [13, 411, which we believe to be both compact and intuitive. The uncommon syntactic features used in our algorithm are that

-the brackets ( and ) denote aggregates (arrays), which may be concatenated using the # operator;

-eq and ne denote the standard logical equality and inequality operators; - ] denotes string concatenation; - “path(l)” denotes the first character of the string “path,” and “path(2..)”

denotes the rest of it; -the symbol ## precedes comments on a line; - “node.oper” designates the operator at “node,” which is represented by a single

character, and “node.left” and “node.right” designate its left and right children; and

-if-then-else structures return values.

The boundary of the solid represented by a CSG tree with root S is the union of the set of boundary elements returned by a call to the procedure bval, defined below. However, these elements are not necessarily mutually disjoint, and some “cleaning” may be required for certain applications. For example, partly overlap- ping faces may be merged.

The bval procedure traverses the tree recursively, propagating the path and the sign. (The positive sign is represented by the Boolean value true.) Each time a primitive A is reached, the procedure trimPrimitiveBdry is called with the appropriate parameters: the primitive, the root of the whole tree, the path to the primitive in that tree, and the sign of the primitive in that tree. bval concatenates the results of recursive calls.

bval: subr(node, root, path, sign) return(

if isprimitive (node) then (trimPrimitiveBdry (node, root, path, sign)) else bvaZ(node.left, root, path 1 ‘L’, sign) #

bvaZ(node.right, root, path 1 ‘R’, sign ne (node.oper eq ‘-7) 1;

end;

The procedure isprimitive returns the Boolean value true if its argument is a primitive and false otherwise. The procedure trimPrimitiveBdry described below calls makeOrientedPrimitiveBdry, which computes the boundary of the primitive and, if the argument “sign” is false, inverts the “orientation” of this boundary, which defines the “left,” or “interior,” and the “right,” or “exterior” side of each highest dimension boundary element. Then, this boundary is trimmed by calling trimWithZ, and the result is returned. ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 33: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 83

trimPrimitiueBdry: subr(primitive, root, path, sign) bdry = makeOrientedPrimitiveBdry(primitive, sign); return(trimWithZ(bdry, root, path, true)); end,

The procedure trimWith& shown below, takes as argument “bdry,” which is whatever remains of the aggregate of candidate sets originated on some primitive A, and trims them down by traversing the path from the root to A using a recursive call.

For the recursive calls, trimWith computes and propagates the next node in the path (called “child”), its “sign” (called “childsign”), and the “newpath” from “child” to A.

To trim the candidate sets of “bdry,” the procedure computes the operator “eqoper” at the current node in the equivalent positive form. Then it classifies the candidate sets against the branching node “br” and only retains certain subsets. The criteria for deciding which subsets should be retained were described in this paper; they are different for boundary evaluation, redundancy detection, and NOD and shading, and depend on the sign of the branching node (“brsign”) and on whether “br” is an i-node or not.

trim WithZ: subr(bdry, node, path, sign) if i.sEmpty(bdry) then return(( )); ## early out if isPrimitiue(node) then return(bdry); ## done (reached A) goLeft = path(l) eq ‘L’; ## path goes left newPath = path(2..); child = if goLeft then node.left else node.right; ## next node in path br = if not goLeft then node.left else node.right; ## branching node

## children signs = sign, except when right child of “-“: childsign = sign ne((not goleft) and (node.oper eq ‘-‘)); brSign = sign ne(goLeft and (node.oper eq ‘-‘));

## Boolean operator in the positive form: eqOper = if node.oper eq ‘-’ then ‘*’ else node.oper; if not sign then eqOper = if eqOper eq ‘. ’ then ‘+’ else ‘ . ‘; islnode = eqOper eq ‘ . ’ trimmedBdry = trimBdry(bdry, islnode, brSign, br); return( trim With2 (trimmedBdry, child, newPath, childsign)); end,

The procedure trimBdry can take various forms, depending on the desired result (whether we perform boundary evaluation, redundancy detection, or trim- ming with respect to I). In all three cases, each candidate element of “bdry” is decomposed into smaller subsets that have a uniform set-membership classifi- cation with respect to all the primitives of the branching node “br.” Details of such a decomposition (procedure subdivide) are domain dependent and fall outside the scope of this paper. Particular approaches are described in [20] and [32] as “set membership classification” and in [23] as “compatible subdivision.”

In 3-D the decomposition simply splits the 2-D elements in “bdry” at their 1-D intersections with boundary elements of the primitives of the particular branching node. For each one of the elements resulting from the decomposition,

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 34: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

a4 l J. R. Rossignac and H. B. Voelcker

the binary “left” and “right” neighborhoods are set. They indicate whether E such an element, is adjacent to the interior of the set B represented by the branching node and, if so, whether B is on the “left side,” on the “right side,” or on both sides of E. (We d!efine the “left side” of E as the side connected to the interior of the primitive bounded by E and the “right side” of E as the side connected to the exterior of that primitive. The procedure call nbhd(b, flag) returns the “left” neighborhood of the element b if “flag” is true and the “right” neighborhood otherwise.

To trim candidate boundary elements of some primitive A against the active zone of A, we use the following version of trimBdry:

trimBdry: subr(bdry, islnode, brSign, br); splitBdry = subdivide (bdry, br); trimmedBdry = ( ); foreach b in splitBdry do

if isInode eq(brSign eq nbhd(b, isInode)) then add (b, trimmedBdry);

return(trimmedBdry); end;

The Boolean expression “islnode eq(brSign eq nbhd(b, isInode))” checks whether the classification of “b” is compatible with the role “br” plays with respect to A in S.

To trim candidate elements against the I-zone only (as for NOD or depth- buffer shading), we use the following version of trimBdry:

trimBdry: subr(bdry, isInode, brSign, br); if not isInode then return(bdry); ## skip u-nodes splitBdry = subdivide (bdry, br); trimmedBdry = ( ); foreach b in splitBdry do

if brSign eq nbhd(b, islnode) then add(b, trimmedBdry);

return(trimmedBdry); end,

To trim candidate elements for redundancy detection, we use the following version of trimBdry:

trimBdry: subr(bdry, islnode, brSign, br); splitBdry = subdivide (bdry, br); trimmedBdry = ( ); foreach b in bdry do

begin b.Ni = b.N; and (isInode eq (brSign eq nbhd(b, true))); b.No = b.No and (islnode eq (brSign eq nbhd(b, false))); if b.N; or b&, then add(b, trimmedBdry); end;

return(trimmedBdry); end,

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 35: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 85

makeOrientedPrimitiveBdry initializes the “Ni” and “No” attributes of each boundary element to true and subdivides duplicates these attributes, when it splits a boundary element.

ACKNOWLEDGMENTS

Bob Tilove’s pioneering work provided the original motivation for this research, which started in 1984 at the Production Automation Project. Paul Borrel helped with the implementation of some trimming algorithms in AML/X. We also thank Paul Borrel, Stephen Cameron, Pierre Darmon, Erik Jansen, Catherine Milon, Lee Nackman, Ari Requicha, Vijay Srinivasan, John Woodwark, and several other colleagues and friends for reviewing this manuscript in detail at different stages of its development and for suggesting improvements. The views expressed here are solely those of the authors.

REFERENCES

1. ANDERSON, D. C. Closing the gap: A workstation-mainframe connection. Comput. Mech. Eng. 4,6 (May 1986), 16-24.

2. BRAYTON, R. K. Factoring logic functions. IBM J. Res. Dev. 31, 2 (Mar. 1987), 187-198. 3. BRYANT, R. E. Graph-based algorithms for Boolean function manipulation. IEEE Trans.

Comput. C-35,8 (Aug. 1986), 677-691. 4. CAMERON, S. A. Modelling solids in motion. Ph.D. thesis, Dept. of Artificial Intelligence, Univ.

of Edinburgh, Scotland, 1984. 5. CAMERON, S. A. A study of the clash detection problem in robotics. In Proceedings of the

International Conference on Robotics and Automation (St. Louis, Mar.). IEEE, 1985, pp. 488-493. 6. CAMERON, S. A. Efficient intersection tests for objects defined constructively. Int. J. Rob. Res.

To be published. 7. GOLDFEATHER, J., HULTQUIST, J. P. M., AND FUCHS, H. Fast constructive solid geometry

display in the pixel-power graphics system. SIGGRAPH 86 Proc. Comput. Graph. 20, 4 (Aug. 1986), 107-116.

8. HILL, F. J., AND PETERSON, G. R. Introduction to Switching Theory and Logical Design. Wiley, New York, 1974.

9. HILLYARD, R. C. The BUILD group of solid modellers. IEEE Comput. Graph. Appl. 2, 2 (Mar. 1982), 43-52.

10. JANSEN, F. W. Solid modelling with faceted primitives. Doctoral dissertation, Dept. of Industry Design, Technische Universiteit Delft, The Netherlands, Sept. 1987.

11. KEDEM, G., AND ELLIS, J. L. Computer structures for curve-solid classification in geometric modelling. Tech. Rep. TR84-37, Microelectronic Center of North Carolina, Research Triangle Park, N.C., 1984.

12. LEE, Y. T., AND REQUICHA, A. A. G. Algorithms for computing the volume and other integral properties of solids; 1: Known methods and open issues; and 2: A family of algorithms based on representation conversion and cellular approximation. Commun. ACM 25, 9 (Sept. 1982), 635-650.

13. NACKMAN, L. R., LAVIN, M. A., TAYLOR, R. H., AND DIETRICH, W. C. AML/X user’s manual. Res. Rep. RA 175, IBM T. J. Watson Research Center, Yorktown Heights, N.Y., 1986.

14. NACKMAN, L. R., LAVIN, M. A., TAYLOR, R. H., DIETRICH, W. C., AND GROSSMAN, D. D. AML/X: A programming language for design and manufacturing. In Proceedings of the IEEE Full Joint Computer Conference (Dallas, Tex., NGV. 2-6). IEEE, New York, 1986, pp. 145-159.

15. OKINO, N., et al. TIPS-l. Institute of Precision Engineering, Hokkaido University, Sapporo, Japan, 1978.

16. PETERSON, D. P. Boundary and constructive solid geometry mapping: A focus on 2-D issues. Comput. Aided Des. 18, 1 (Jan.-Feb. 1986), 3-14.

17. REQUICHA, A. A. G. Mathematical models of rigid solid objects. Tech. Memo. 28, Production Automation Project, Univ. of Rochester, Rochester, N.Y., Nov. 1977. (Reports of the Production

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 36: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

86 ’ J. R. Rossignac and H. B. Voelcker

Automation Project are no longer available from the University of Rochester, but may be obtained from CPA, 304 Kimball Hall, Cornell University, Ithaca, NY 14853.)

18. REQUICHA, A. A. G., AND TILOVE, R. B. Mathematical foundation of constructive solid geom- etry: General topology of closed regular sets. Tech. Memo. 27a, Production Automation Project, Univ. of Rochester, Rochester, N.Y., June 1978. (Reports of the Production Automation Project are no longer available from the University of Rochester, but may be obtained from CPA, 304 Kimball Hall, Cornell University, Ithaca, NY 14853.)

19. REQUICHA, A. A. G., AND VOELCKER, H. B. Constructive solid geometry. Tech. Memo. 25, Production Automation Project, Univ. of Rochester, Rochester, N.Y., Nov. 1977. (Reports of the Production Automation Projlect are no longer available from the University of Rochester, but may be obtained from CPA, :304 Kimball Hall, Cornell University, Ithaca, NY 14853.)

20. REQUICHA, A. A. G., AND VOELCKER, H. B. Boolean operations in solid modelling: Boundary evaluation and merging algorithms. In Proc. IEEE 73, 1 (Jan. 1985), 30-44.

21. ROSSIGNAC, J. R. Blending and offsetting solid models. Ph.D. dissertation, Tech. Memo. 54, Production Automation Project, Univ. of Rochester, Rochester, N.Y., June 1985. (Reports of the Production Automation Pro:iect are no longer available from the University of Rochester, but may be obtained from CPA, 304 Kimball Hall, Cornell University, Ithaca, NY 14853.)

22. ROSSIGNAC, J. R. Constraints in constructive solid geometry. In Proceedings of the 1986 Workshop on Interactive 30 Graphics (Chapel Hill, N.C., October 23-24). ACM Press, New York, 1986, pp. 93-110. (Also available as Res. Rep. RC 12356, IBM Research Division, T. J. Watson Research Center, Yorktown Heights, N.Y., Sept. 1986).

23. ROSSIGNAC, J. R., AND O’CONNOR, M. A. Selective geometric complexes: Representations and algorithms for processing and combining mixed dimensional geometric objects. IBM Research Division, T. J. Watson Research Center, Yorktown Heights, N.Y. In preparation.

24. ROSSIGNAC, J. R., AND REQUICHA, A. A. G. Constant radius blending in solid modelling. Comput. Mech. Eng. 3, 1 (July 1984), 65-73.

25. ROSSIGNAC, J. R., AND REQWICHA, A. A. G. Offsetting operations in solid modelling. Comput. Aided Geom. Des. 3,2 (Aug. ‘X986), 129-148.

26. ROSSIGNAC, J. R., AND REQ~IICHA, A. A. G. Depth buffering display techniques for constructive solid geometry. IEEE Cornput. Graph. Appl. 6,9 (Sept. 1986), 29-39.

27. ROTH, S. D. Ray casting for modeling solids. Comput. Graph. Image Process. 18, 2 (Feb. 1982), 109-144.

28. RUDEANU, S. Boolean Functions and Equutions. North-Holland, Amsterdam, 1974. 29. SHANNON, C. E. A symbolic analysis of relay and switching circuits. Trans. A.Z.E.E. 57 (1938),

713-723. 30. SHIRMA, Y., OKINO, N., APED KAKAZU, Y. Research on 3-D geometric modelling by sweep

primitives. In Proceedings of CAD ‘82 (Brighton, U.K., Mar. 30-Apr. 17). 1982, pp. 671-680. 31. SUNGURTEKIN, U. A., AND VOELCKER, H. B. Graphical simulation and automatic verification

of NC machining programs. In Proceedings of the IEEE International Conference on Robots and Automation, vol. 1 (San Francisco, Apr. 7-10). 1986, IEEE, New York, pp. 156-165.

32. TILOVE, R. B. Set membership classification: A unified approach to geometric intersection problems. IEEE Trans. Comput. C-29,10 (Oct. 1980), 874-883.

33. TILOVE, R. B. Exploiting spatial and structural locality in geometric modelling. Tech. Memo. 38, Production Automation Project, University of Rochester, Rochester, N.Y., Oct. 1981. (Reports of the Production Automation Project are no longer available from the University of Rochester, but may be obtained from C.PA, 304 Kimball Hall, Cornell University, Ithaca, NY 14853.)

34. TILOVE, R. B. A null-object detection algorithm for constructive solid geometry. Commun. ACM 27,7 (July 1984), 684-694.

35. TILOVE, R. B., REQUICHA, PL. A. G., AND HOPKINS, M. R. Efficient editing of solid models by exploiting structural and spatial locality. Tech. Memo. 46, Production Automation Project, Univ. of Rochester, Rochester, N.Y., May 1984. (Reports of the Production Automation Project are no longer available from the University of Rochester, but may be obtained from CPA, 304 Kimball Hall, Cornell University, Ithaca, NY 14853.)

36. VAN WIJK, J. J. Ray tracing objects defined by sweeping a sphere. In Proceedings of Eurographics ‘84 (Copenhagen, Sept. 12-14). Elseviers Science Publishers, Amsterdam, 1984, pp. 73-82.

37. VOSSLER, D. L. Sweep-to-CSG conversion using pattern recognition techniques. IEEE Comput. Graph. Appl. 5,8 (Aug. 1985), 61-68.

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.

Page 37: Active Zones in CSG for Accelerating Boundary Evaluation ...jarek/papers/CSGActiveZones.pdfmathematical theory of active zones, prove that they correspond to the intersection of certain

Active Zones in CSG l 87

38. WOLFE, R. N., WESLEY, M. A., KYLE, J. C., GRACER, F., AND FITZGERALD, W. J. Solid modelling for production design. IBM J. Res. Den 31, 3 (May 1987), 277-295.

39. WOODWARK, J. R. Eliminating redundant primitives from set-theoretic solid models by a consideration of constituents. IEEE Comput. Graph. Appl. 8,3 (May 1988), 38-47.

40. WOODWARK, J. R., AND QUINLAN, K. M. Reducing the effect of complexity on volume model evaluation. Cornput-Aided Des. 14, 2 (Mar. 1982), 89-95.

Received January 1987; revised December 1987; accepted February 1988

ACM Transactions on Graphics, Vol. 8, No. 1, January 1989.