290 36 3MB
English Pages 344 Year 1989
GEOMETRIC AND SOLID MODELING CHRISTOPH
M.
HOFFMANN
Foreword
Today, our imagination is limited by the omputer systems we have built. The demand for sophisti ated tools has grown faster than the orresponding developments of the supporting s ien e base. Written by one of the leading experts in the eld of solid-modeling systems, Geometri and Solid Modeling: An Introdu tion provides the start of a s ienti basis to support the oming revolution in omputer-aided design. It deals with the on epts and tools needed to design and implement solidmodeling systems, and makes this information a
essible to the novi e, as well as to the experien ed designer. Man has always distinguished himself from other animals with the aid of language, art, and tools. Language and art remain man's way of representing ideas, either for ommuni ating them to other people or for giving them permanen e. Tools extend his strength and mobility. In early so iety, tools were simple and the ideas behind their fun tion and manufa ture were easily ommuni ated, either verbally or by example. As the
omplexity of tools in reased, written drawings and other do uments be ame an essential omponent of design. In today's te hnologi ally advan ed so iety, in whi h tools have rea hed the omplexity of a spa e raft, the development of a design requires a team of engineers. Writing, and even drawing and s ulpting, are found to be inadequate; they are stati and of too limited a dimension for expressing omplex designs. Computers are revolutionizing our ability to represent, develop, and omiii
iv
muni ate knowledge. By abstra ting knowledge into pro edures, omputers provide dynami and powerful representations, and enhan e our ability to manipulate and expand our thoughts. In the past, a new produ t was reated by investigating a design in the abstra t, using paper, pen il and whatever other tools were available. The design was ommuni ated through the medium of engineering drawings to a manufa turer who built the devi e. In the future, omputers will be used to explore mu h larger design spa es, and designs will be ommuni ated dire tly to ma hines manufa turing the produ t. The result will be a wider sele tion of produ ts of higher quality and lower ost. Imagine using a omputer model of an obje t instead of a physi al prototype to validate a omplex design. The omputer prototype would allow
hanges with a few key strokes, as well as allow engineering analyses to be automati ally arried out. For example, a multi ngered gripper ould be modeled and ele troni ally simulated in various manipulation tasks, exploring the advantage of the number and pla ement of ngers. In the early stages of a new te hnology, the te hniques and methods of the older te hnology are simply simulated. Gradually the full power of the new te hnology is a hieved as new methods utilizing the natural advantages of the te hnology are developed. Thus it was not surprising that the initial usage of Computer Aided Design systems was in automating drafting. Today, omputer-aided-design (CAD) systems provide new representations of obje ts as three-dimensional entities rather than as two-dimensional proje tions. Ultimately we will realize that an obje t is de ned by something more intrinsi than its shape. Solid modeling and omputer-aided design are qui kly be oming vital to e onomi produ tiveness. The sophisti ation of new produ ts has ne essitated a oin iding sophisti ation in su h engineering tools as omputer-aided design systems and analysis programs. The Boeing 767 ould not have been designed without su h automated tools. Similarly, omplex parts for spa e raft, roboti work ells and VLSI te hnology are a
elerating this need. Geometri and Solid Modeling: An Introdu tion is a wel ome introdu tion to an in reasingly sophisti ated and fast-growing eld. John E. Hop roft Cornell University Itha a 1989
A knowledgements
John Hop roft has hallenged omputer s ien e to involve itself in the problems of geometri and solid modeling. I wish to a knowledge his eloquen e and persuasiveness as he set forth the foundation for omputer s ien e to have a unique and valuable perspe tive on these problems. I want to parti ularly thank Bruno Bu hberger, Ray Sarraga, Jarek Rossigna , Kevin Weiler, Dan Gottlieb, Ari Requi ha, Mike Karasi k, and Chee Yap, for the many fo used and pre ise suggestions they made, and I wish to re ognize the signi ant amount of time they spent to do so. From their valuable feedba k, this book bene ts greatly. Thanks to my students, Bill Bouma, Ching-Shoei Chiang, Jung-Hong Chuang, Neelam Jasuja, Chris S herbert, Pam Vermeer, Jia-Xun Yu, and Jianhua Zhou, who have he ked the manus ript for a
ura y, and who served as a \Turing test" for larity. My resear h has been supported by the National S ien e Foundation under grants DCR 85-12443, CCR 86-12590, CCR 86-19817, and DMC 88-07550; by the OÆ e of Naval Resear h, under ontra t N00014-86-K-0465; and by a grant from the ATT Foundation.
v
vi
Contents
1 Introdu tion 1.1 A Brief Histori al Perspe tive of Solid Modeling . . . 1.2 Three Levels of Abstra tion . . . . . . . . . . . . . . 1.2.1 User Interfa es . . . . . . . . . . . . . . . . . 1.2.2 Mathemati al and Algorithmi Infrastru ture 1.2.3 The Substratum Problem . . . . . . . . . . . 1.3 About This Book . . . . . . . . . . . . . . . . . . . . 1.4 Notes and Referen es . . . . . . . . . . . . . . . . . . 2 Basi Con epts 2.1 Con eptual Operations and Primitives . . . . . . . . 2.1.1 Primitives . . . . . . . . . . . . . . . . . . . . 2.1.2 Lo al Modi ations . . . . . . . . . . . . . . . 2.1.3 Global Operations . . . . . . . . . . . . . . . 2.1.4 Undoing and Redoing . . . . . . . . . . . . . . 2.2 CSG Representation . . . . . . . . . . . . . . . . . . 2.2.1 CSG Standard Primitives . . . . . . . . . . . 2.2.2 Regularized Boolean Operations . . . . . . . . 2.2.3 Constru tion of a CSG Obje t . . . . . . . . . 2.2.4 Point/Solid Classi ation and Neighborhoods 2.2.5 Curve/Solid Classi ation . . . . . . . . . . . vii
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .
. . . . . . .
1 2 4 5 6 7 9 11
. . . . . . . . . . .
13 14 14 17 19 19 21 21 22 23 23 30
viii
2.3
2.4
2.5 2.6
2.2.6 Surfa e/Solid Classi ation, Conversion to B-rep 2.2.7 Redundan ies and Approximations in CSG Trees 2.2.8 Nonstandard Primitives . . . . . . . . . . . . . . Boundary Representations . . . . . . . . . . . . . . . . . 2.3.1 Manifold Versus Nonmanifold Representation . . 2.3.2 Winged-Edge Representation . . . . . . . . . . . 2.3.3 The Euler{Poin are Formula . . . . . . . . . . . . 2.3.4 Euler Operators . . . . . . . . . . . . . . . . . . . Topologi al Validity of B-rep Solids . . . . . . . . . . . . 2.4.1 Topologi al Polyhedra . . . . . . . . . . . . . . . 2.4.2 Manifold Solids . . . . . . . . . . . . . . . . . . . 2.4.3 Nonmanifold Solids . . . . . . . . . . . . . . . . . Spatial De omposition . . . . . . . . . . . . . . . . . . . Notes and Referen es . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
32 33 34 36 36 38 39 42 46 47 54 60 61 63
3 Boolean Operations on Boundary Representation 67 3.1 Chapter Organization . . . . . . . . . . . . . . . . . . . . . . . 68 3.2 Representation Conventions . . . . . . . . . . . . . . . . . . . 69 3.2.1 Fa e Representation . . . . . . . . . . . . . . . . . . . 70 3.2.2 Edge Representation . . . . . . . . . . . . . . . . . . . 72 3.2.3 Vertex Representation . . . . . . . . . . . . . . . . . . 72 3.2.4 Surfa e Stru ture . . . . . . . . . . . . . . . . . . . . . 73 3.3 Geometri Operations . . . . . . . . . . . . . . . . . . . . . . 73 3.3.1 Fa e Dire tion Ve tor . . . . . . . . . . . . . . . . . . . 73 3.3.2 Splitting an Area- or Volume-En losing Pair . . . . . . 74 3.3.3 Ordering Points Along a Line and Pairing Them . . . . 75 3.3.4 Line/Solid Classi ation . . . . . . . . . . . . . . . . . 76 3.4 Interse tion of Two Shells . . . . . . . . . . . . . . . . . . . . 80 3.4.1 Robustness Considerations . . . . . . . . . . . . . . . . 81 3.4.2 Interse ting-Pairs Determination and Shell Containment 82 3.4.3 Fa e Interse tion and Neighborhood Analysis . . . . . 83 3.4.4 Neighborhood Analysis . . . . . . . . . . . . . . . . . . 86 3.4.5 Fa e Subdivision . . . . . . . . . . . . . . . . . . . . . 92 3.4.6 Adja en ies in the Result . . . . . . . . . . . . . . . . 93 3.4.7 Single-Shell Interse tion Summary . . . . . . . . . . . . 94 3.5 Multishell Obje ts . . . . . . . . . . . . . . . . . . . . . . . . 94 3.6 Complement, Union, and Dieren e . . . . . . . . . . . . . . . 96 3.7 Fa e-Boxing Te hniques . . . . . . . . . . . . . . . . . . . . . 96 3.7.1 The Stati Interval Tree . . . . . . . . . . . . . . . . . 97 3.7.2 Stati Interval Query . . . . . . . . . . . . . . . . . . . 100 3.7.3 Re tangle Interse tion . . . . . . . . . . . . . . . . . . 102 3.7.4 The Segment Tree . . . . . . . . . . . . . . . . . . . . 104 3.7.5 Interval, Re tangle, and Box Interse tion . . . . . . . . 105 3.7.6 Red-Blue Interse tion . . . . . . . . . . . . . . . . . . . 107 3.7.7 Implementation Remarks . . . . . . . . . . . . . . . . . 107
ix
3.8 Notes and Referen es . . . . . . . . . . . . . . . . . . . . . . . 108 4
5
Robust and Error-Free Geometri Operations
4.1 Chapter Overview . . . . . . . . . . . . . . . . . . . . . . . . 4.2 Floating-Point Arithmeti . . . . . . . . . . . . . . . . . . . 4.2.1 Numeri al Errors in Floating-Point Arithmeti . . . . 4.2.2 Geometri Failures Due to Floating-Point Arithmeti 4.2.3 Line-Interse tion Conditioning . . . . . . . . . . . . . 4.2.4 Compound Geometri Operations . . . . . . . . . . . 4.3 Exa t Rational Arithmeti . . . . . . . . . . . . . . . . . . . 4.3.1 The Grid of Representable Elements . . . . . . . . . 4.3.2 Boolean Operations . . . . . . . . . . . . . . . . . . . 4.3.3 Rigid Motions . . . . . . . . . . . . . . . . . . . . . . 4.3.4 Rational Approximations . . . . . . . . . . . . . . . . 4.3.5 Obje t Re onstru tion . . . . . . . . . . . . . . . . . 4.3.6 Remarks on Using Rational Arithmeti . . . . . . . . 4.4 Representation and Model . . . . . . . . . . . . . . . . . . . 4.4.1 Models of Purely Symboli Representations . . . . . 4.4.2 The Role of De ision Making . . . . . . . . . . . . . 4.4.3 Irredundant De ision Making . . . . . . . . . . . . . 4.4.4 Preserving Symboli Data . . . . . . . . . . . . . . . 4.4.5 Altering the Symboli Data . . . . . . . . . . . . . . 4.5 Dis ussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.6 Notes and Referen es . . . . . . . . . . . . . . . . . . . . . . Representation of Curved Edges and Fa es
5.1 Chapter Overview . . . . . . . . . . . . . . . . 5.2 AÆne and Proje tive Spa es . . . . . . . . . . 5.3 Impli it Representations . . . . . . . . . . . . 5.3.1 Impli it Surfa es . . . . . . . . . . . . 5.3.2 Impli it Curves . . . . . . . . . . . . . 5.3.3 Bezout's Theorem . . . . . . . . . . . . 5.4 Parametri Representations . . . . . . . . . . 5.4.1 Parametri Surfa es . . . . . . . . . . . 5.4.2 Parametri Curves . . . . . . . . . . . 5.4.3 Computer-Aided Geometri Design . . 5.5 Conversion from Impli it to Parametri Form 5.5.1 Coni s . . . . . . . . . . . . . . . . . . 5.5.2 Quadri s . . . . . . . . . . . . . . . . . 5.5.3 Cubi Curves . . . . . . . . . . . . . . 5.5.4 Monoids . . . . . . . . . . . . . . . . . 5.5.5 Parametri Domains . . . . . . . . . . 5.6 Conversion from Parametri to Impli it Form 5.6.1 Resultants . . . . . . . . . . . . . . . . 5.6.2 Impli itization of Curves and Surfa es 5.7 Edge Identi ation . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
111
112 113 114 114 118 122 124 124 125 128 130 134 137 138 139 143 144 144 147 149 151
155
156 157 160 160 163 164 166 166 167 168 169 170 180 181 185 187 189 190 192 193
x 5.7.1 5.7.2 5.7.3 5.7.4 5.8 Notes
Topologi al Aspe ts . . . . . . . Edge Orientation . . . . . . . . Singularities on Edges . . . . . Edge-Identi ation Information and Referen es . . . . . . . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
194 194 197 200 203
6 Surfa e Interse tions 6.1 Chapter Overview . . . . . . . . . . . . . . . . . . . . . . 6.2 Interse ting Two Impli it Surfa es Numeri ally . . . . . 6.2.1 Constru tion of the Approximant . . . . . . . . . 6.2.2 Sele tion of Step Size . . . . . . . . . . . . . . . . 6.2.3 Newton Iteration . . . . . . . . . . . . . . . . . . 6.2.4 Singular Value De omposition . . . . . . . . . . . 6.3 Tra ing in Higher Dimensions . . . . . . . . . . . . . . . 6.3.1 The Method . . . . . . . . . . . . . . . . . . . . . 6.3.2 Numeri ally Interse ting Two Parametri Surfa es 6.3.3 Surfa e Operations in Higher Dimensions . . . . . 6.4 Mapping Surfa e Interse tions to Plane Curves . . . . . . 6.4.1 Substitution Maps . . . . . . . . . . . . . . . . . 6.4.2 Proje tion Methods . . . . . . . . . . . . . . . . . 6.5 Plane Algebrai Curves . . . . . . . . . . . . . . . . . . . 6.5.1 Pla e of a Curve . . . . . . . . . . . . . . . . . . 6.5.2 Quadrati Transformations . . . . . . . . . . . . . 6.5.3 Bran h and Curve Desingularization . . . . . . . 6.5.4 Tra ing with Desingularization . . . . . . . . . . 6.5.5 Lo ating Singularities . . . . . . . . . . . . . . . . 6.5.6 Bringing the Singularity to the Origin . . . . . . 6.5.7 Preserving the Dire tion of Tra ing . . . . . . . . 6.6 Remarks on Surfa e Interse tion . . . . . . . . . . . . . . 6.7 Notes and Referen es . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . .
205 206 207 209 214 215 216 220 220 222 224 230 230 235 237 238 243 244 246 247 250 250 253 254
. . . . . . . . . . . .
257 258 259 259 260 262 263 264 268 269 269 270 272
7 Grobner Bases Te hniques 7.1 Chapter Overview . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Algebrai Con epts . . . . . . . . . . . . . . . . . . . . . . . 7.2.1 Fields, Rings, and Polynomials . . . . . . . . . . . . 7.2.2 Field Extensions and Rational Fun tions . . . . . . . 7.2.3 Multivariate Polynomials and Ideals . . . . . . . . . . 7.2.4 The Residue Class Ring of an Ideal . . . . . . . . . . 7.2.5 Algebrai Sets and Varieties . . . . . . . . . . . . . . 7.2.6 Prime Ideals and Radi als . . . . . . . . . . . . . . . 7.3 Grobner Bases . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.1 Lexi ographi Term Ordering and Leading Terms . . 7.3.2 Rewriting and Normal-Form Algorithms . . . . . . . 7.3.3 A Membership Test for Ideals . . . . . . . . . . . . . 7.3.4 Bu hberger's Theorem and Constru tion of Grobner Bases . . . . . . . . . . . . . . . . . . . . . . . . . . .
. 272
xi
7.4
7.5 7.6
7.7
7.8
7.9
7.3.5 Improved Basis Constru tion and Redu ed Grobner Bases . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.6 Admissible Term Orderings . . . . . . . . . . . . . . Solving Algebrai Equations . . . . . . . . . . . . . . . . . . 7.4.1 Triangularizing Algebrai Equations . . . . . . . . . . 7.4.2 Finding Surfa e Interse tions . . . . . . . . . . . . . 7.4.3 Lo ating Singularities . . . . . . . . . . . . . . . . . . 7.4.4 Basis Determination with Symboli Quantities . . . . Operations on Curves and Surfa es . . . . . . . . . . . . . . 7.5.1 Impli itization and Inversion . . . . . . . . . . . . . . 7.5.2 Oset Surfa es . . . . . . . . . . . . . . . . . . . . . Geometri Theorem Proving . . . . . . . . . . . . . . . . . . 7.6.1 Outline of the Proof Method . . . . . . . . . . . . . . 7.6.2 Translating Geometri Con gurations . . . . . . . . . 7.6.3 Formula Manipulation . . . . . . . . . . . . . . . . . 7.6.4 Choi e of Coordinate Axes and Other Heuristi s . . . Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.7.1 Simple Basis Experiments . . . . . . . . . . . . . . . 7.7.2 Large Basis Computations . . . . . . . . . . . . . . . 7.7.3 CoeÆ ient Growth . . . . . . . . . . . . . . . . . . . Basis Conversion . . . . . . . . . . . . . . . . . . . . . . . . 7.8.1 Computing in the Residue Class Ring . . . . . . . . . 7.8.2 Basis Conversion for Zero-Dimensional Ideals . . . . . 7.8.3 Variable Elimination . . . . . . . . . . . . . . . . . . Notes and Referen es . . . . . . . . . . . . . . . . . . . . . .
8 Bibliography
. . . . . . . . . . . . . . . . . . . . . . . .
275 276 277 277 279 280 281 282 282 283 285 286 287 289 290 290 290 291 292 292 293 294 299 300 303
xii
List of Figures
1.1
Ambiguous Wireframe Obje t
. . . . . . . . . . . . . . . . . .
3
1.2
Two Slot Positions
. . . . . . . . . . . . . . . . . . . . . . . .
6
1.3
Piston Engine
. . . . . . . . . . . . . . . . . . . . . . . . . . .
6
2.1
Shape Variation Due to Parameter Values
. . . . . . . . . . .
15
2.2
A Cir ular Disk Swept Along a Line . . . . . . . . . . . . . . .
16
2.3
Sweep Degenera ies . . . . . . . . . . . . . . . . . . . . . . . .
16
2.4
Extruding a Fa e
. . . . . . . . . . . . . . . . . . . . . . . . .
18
2.5
Beveling a Vertex . . . . . . . . . . . . . . . . . . . . . . . . .
18
2.6
Altering Edge and Fa e Shape . . . . . . . . . . . . . . . . . .
18
2.7
Error in Fa e Extrusion
2.8
History Tree of Design
. . . . . . . . . . . . . . . . . . . . .
19
. . . . . . . . . . . . . . . . . . . . . .
20
2.9
Indexing a History Tree
. . . . . . . . . . . . . . . . . . . . .
20
2.10 Coordinate Frames for Two Standard Primitives . . . . . . . .
21
2.11 Pro edure for Regularized Interse tion
. . . . . . . . . . . . .
22
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
24
2.13 Tree Representation of CSG Expression . . . . . . . . . . . . .
24
2.14 Neighborhood of an Interior Fa e Point . . . . . . . . . . . . .
27
2.12 Bra ket
2.15 Neighborhood of an Interior Edge Point . . . . . . . . . . . . .
27
2.16 Simple Neighborhoods of a Vertex . . . . . . . . . . . . . . . .
28
2.17 General Neighborhood of a Vertex . . . . . . . . . . . . . . . .
28
xiii
xiv
2.18 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.35 2.36 2.37 2.38 2.39 2.40 2.41 2.42 2.43 2.44 2.45 2.46 2.47 2.48 2.49 2.50 2.51 2.52 2.53 2.54 3.1 3.2 3.3 3.4
Edge-Neighborhood Merge, General Position . . . . . . . . . . Edge-Neighborhood Merge Produ ing an Edge . . . . . . . . . Edge-Neighborhood Merge Produ ing a Fa e . . . . . . . . . . Vertex-Neighborhood Merge, General Position . . . . . . . . . Vertex-Neighborhood Merge Produ ing an Edge . . . . . . . . Vertex-Neighborhood Merge Produ ing a Fa e . . . . . . . . . Sorting Curve Points on a Parametri Surfa e . . . . . . . . . A Is -Redundant in A [ B . . . . . . . . . . . . . . . . . . . C Is -Redundant in C \ D . . . . . . . . . . . . . . . . . . Approximation of (A [ B ) (C [ D): Y = (C [ D) and X = (A [ B ) = ((A [ B ) (C [ D)). . . . . . . . . . . A Nonmanifold Obje t . . . . . . . . . . . . . . . . . . . . . . Two Possible Topologies . . . . . . . . . . . . . . . . . . . . . Winged-Edge Data Stru ture . . . . . . . . . . . . . . . . . . Tetrahedron . . . . . . . . . . . . . . . . . . . . . . . . . . . . An Obje t with Two Holes and with Fa es Homeomorphi to Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A Surfa e of Genus 2 . . . . . . . . . . . . . . . . . . . . . . . A Fa e with Four Bounding Loops . . . . . . . . . . . . . . . Solid with 24 Verti es, 36 Edges, 16 Fa es, 18 Loops, 2 Shells, and Genus Sum 1 . . . . . . . . . . . . . . . . . . . . . . . . . Surfa e with 8 Verti es, 12 Edges, and 6 Fa es . . . . . . . . . me Operation . . . . . . . . . . . . . . . . . . . . . . . . . . mekl Operation . . . . . . . . . . . . . . . . . . . . . . . . . . meks Operation . . . . . . . . . . . . . . . . . . . . . . . . . . A Simpli ial Complex C . . . . . . . . . . . . . . . . . . . . . Simpli es Not Forming a Simpli ial Complex . . . . . . . . . . Topologi al Polyhedra of Dimension 2 . . . . . . . . . . . . . . Opposite Fa es in a 3-Simplex . . . . . . . . . . . . . . . . . . Link of S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Vertex Stru ture in Triangulated 2-Manifold . . . . . . . . . . A Wildly Embedded Simple Ar . . . . . . . . . . . . . . . . . Orientations (p0; p1; p2) and (p0; p2; p1) of a 2-Simplex . . . . . Coherent and In oherent Orientations . . . . . . . . . . . . . . Interior Point p and Exterior Point q . . . . . . . . . . . . . . In onsistently and Consistently Oriented Boundaries of Orientable 2-Manifolds . . . . . . . . . . . . . . . . . . . . . . . . Resolution of Nonmanifold Stru tures . . . . . . . . . . . . . . Cir le Represented by Uniform Subdivision of Spa e . . . . . . O tree Subdivision of Spa e . . . . . . . . . . . . . . . . . . . Irregular Subdivision of Spa e . . . . . . . . . . . . . . . . . . Legal Fa e Cy les . . . . . . . . . . . . . . . . . . . . . . . . . Illegal Fa e Cy les . . . . . . . . . . . . . . . . . . . . . . . . Fa e Dire tion Ve tor . . . . . . . . . . . . . . . . . . . . . . . Splitting an Area-En losing Pair . . . . . . . . . . . . . . . . .
29 29 30 30 31 31 32 33 33 35 37 37 39 40 42 43 43 44 45 46 46 47 51 51 52 53 54 54 55 56 57 59 60 61 62 63 64 71 71 74 75
xv 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 3.20 3.21 3.22 3.23 3.24 3.25 3.26 3.27 3.28 3.29 3.30 3.31 3.32 3.33 3.34
Interse tion-Point Sorting and Pairing . . . . . . . . Classi ation of Multiple-Boundary Components . . . The Classi ations \in f, in g " and \in f, out g " . . . The Classi ations \out f, in g " and \out f, out g " . . Classi ation for Fa e Interior . . . . . . . . . . . . . Classi ation for Edge Interior . . . . . . . . . . . . . Classi ation for Vertex Interse tion . . . . . . . . . Lo ally In onsistent Interse tion Analysis . . . . . . . Two Interse ting Boxes . . . . . . . . . . . . . . . . . Coplanar Fa es with Opposite Orientation . . . . . . Pla ing Points and Segments . . . . . . . . . . . . . . Line-Segment Orientation . . . . . . . . . . . . . . . Fa e/Fa e Interse tion . . . . . . . . . . . . . . . . . Edge/Fa e Interse tion . . . . . . . . . . . . . . . . . Transfer for Degenerate Edge/Fa e Interse tion to f . Transfer for Degenerate Edge/Fa e Interse tion to gi Edge/Edge Interse tion . . . . . . . . . . . . . . . . . Transfer for Degenerate Edge/Edge Interse tion . . . Vertex/Fa e Interse tion . . . . . . . . . . . . . . . . Vertex/Edge Interse tion . . . . . . . . . . . . . . . . Vertex/Vertex Interse tion . . . . . . . . . . . . . . . A Multishell Polyhedron in Two Dimensions . . . . . Polyhedron as Interse tion of Single-Shell Polyhedra . Range Tree T . . . . . . . . . . . . . . . . . . . . . . Interval Tree T . . . . . . . . . . . . . . . . . . . . . Node Sets Used for Querying for Interval Interse tion Interval Insertion During Re tangle Interse tion . . . Segment Tree Tseg . . . . . . . . . . . . . . . . . . . . Segment Tree Tseg with Intervals . . . . . . . . . . . . Sear h Tree Tbin with Intervals . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
76 77 78 78 79 79 80 81 84 85 85 86 87 88 88 89 90 90 91 91 92 94 95 98 99 100 103 105 106 107
4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12 4.13 4.14 4.15
Vertex In iden e Regions . . . . . . . . . . . . . . . . . . . . Topologi al In onsisten y When Interse ting Edges . . . . . going in and going out Operations . . . . . . . . . . . . . . Example Pentagon . . . . . . . . . . . . . . . . . . . . . . . Grid of Lines ax + by + = 0; Where jaj; jbj; j j < 3 . . . . . Grid of Lines ax + by + = 0; Where jaj; jbj < 3; and j j < 9 Parameter Interpretation of t . . . . . . . . . . . . . . . . . Union of 150 Random Triangles . . . . . . . . . . . . . . . . Border, Magni ed Three Times . . . . . . . . . . . . . . . . Border, Magni ed 500 Times . . . . . . . . . . . . . . . . . . Possible Feature Alteration Through Translation or Rotation Realizable Point/Line Con guration . . . . . . . . . . . . . . In iden e Con guration Requiring Irrational Points . . . . . Interse ting Two n-Gons . . . . . . . . . . . . . . . . . . . . Repositioning the Fa e f Requires Changing Adja ent Fa es
. . . . . . . . . . . . . . .
117 119 122 123 126 126 129 135 136 136 137 141 142 145 147
xvi
4.16 4.17 4.18 4.19
Sequen e Dependen e of Positional Perturbation . . Vertex Shifting . . . . . . . . . . . . . . . . . . . . Edge Cra king . . . . . . . . . . . . . . . . . . . . . Additive Positional Perturbation in Edge Cra king
. . . .
. . . .
148 149 149 150
5.1 5.2 5.3 5.4 5.5 5.6 5.7 5.8
Embedding Proje tive Spa e into AÆne Spa e . . . . . . . . AÆne Transformation of a Cir le . . . . . . . . . . . . . . . Proje tive Transformation of a Cir le . . . . . . . . . . . . . Parameterization of the Unit Cir le . . . . . . . . . . . . . . Parameterizing a Singular Cubi Curve . . . . . . . . . . . . Pat h Corners in Parameter Spa e . . . . . . . . . . . . . . . Impli it Edge Orientation as Left Fa e Right Fa e . . . . Interse tion of f : z = 0 and g : z + y 2 x2 x3 = 0; Oriented as rf rg . . . . . . . . . . . . . . . . . . . . . . . . . . . Grooved Toroidal Obje t . . . . . . . . . . . . . . . . . . . . The Cartesian Cylinder C . . . . . . . . . . . . . . . . . . . Obje t (((T1 \ H ) T2 ) T3 ) \ C . . . . . . . . . . . . . . . Complete Torus/Cylinder Interse tion . . . . . . . . . . . . . Se ond Interpretation of the Representation . . . . . . . . . Bran h Identi ation by Interior Point . . . . . . . . . . . . Cuspidal Singularity of y 2 x3 + z = 0 \ z = 0 . . . . . . . Ta nodal Singularity of z x4 y 4 = 0 \ z y 2 = 0 . . . . .
. . . . . . .
158 159 160 176 182 189 196
. . . . . . . . .
196 196 198 198 201 201 202 202 203
5.9 5.10 5.11 5.12 5.13 5.14 5.15 5.16 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 6.10 6.11 6.12 6.13 6.14 6.15 6.16 6.17 6.18
. . . .
. . . .
. . . .
. . . .
The Spa e-Curve Triad . . . . . . . . . . . . . . . . . . . . . . 212 Lo al Curve Proje tions . . . . . . . . . . . . . . . . . . . . . 213 The Ve tor n . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Sequen e of Givens Rotations in Phase 2 of Singular Value De omposition . . . . . . . . . . . . . . . . . . . . . . . . . . 220 Oset Curve as Envelope of Cir les . . . . . . . . . . . . . . . 225 Interior Oset Part at Self-Interse tions . . . . . . . . . . . . . 228 Additional Oset Points at Singularity . . . . . . . . . . . . . 228 Interse ting a Cylinder with an Oset of an Ellipsoid . . . . . 229 Tra e of (u2 v 2 )4 4u2 v 2 (u2 + v 2 ) = 0 . . . . . . . . . . . . 232 Spa e Curve and Its Planar Image in Parameter Spa e of Monoid234 Ellipsoid/Torus Interse tion in Parameter Spa e . . . . . . . . 235 Proje tion of the Cylinder/Sphere Interse tion . . . . . . . . . 236 Quadrati Transformation T1 : (x; y ) ! (x; y=x) . . . . . . . . 244 Resolution of a Nodal Singularity . . . . . . . . . . . . . . . . 245 Resolution of a Cuspidal Singularity . . . . . . . . . . . . . . . 245 Tra ing with Desingularization . . . . . . . . . . . . . . . . . . 246 Curve Orientation of f = y 2 x2 x3 by ( fy ; fx ) . . . . . . 251 Correlation of Standard Curve Orientations . . . . . . . . . . 252
7.1 Twisted Cubi (t; t2 ; t3 ) . . . . . . . . . . . . . . . . . . . . . . 265 7.2 Redu ible Interse tion of Two Cylinders . . . . . . . . . . . . 266 7.3 Irredu ible Interse tion of Two Cylinders . . . . . . . . . . . . 267
xvii
7.4
Geometri Example Theorem
7.5
Stair ase of Leading Power Produ ts
. . . . . . . . . . . . . . . . . . 285 . . . . . . . . . . . . . . 296
7.6
Power-Produ t Generation Sequen e
. . . . . . . . . . . . . . 297
xviii
List of Tables
2.1 Naive Neighborhood Combination for Booleans . . . . . . . . 26 2.2 Edge Table of the Tetrahedron, Winged-Edge Methodology . . 39 3.1 Containment Classi ation for f and
g
. . . . . . . . . . . . . 77
4.1 Absolute Error for Iterating going in and going out . . . . . . 123 5.1 5.2 5.3 5.4 5.5
Standard Parameterization of Coni s . . . . . . Proje tive Parameterization of Quadri Surfa es Vertex Tables of (((T1 \ H ) T2 ) T3 ) \ C . . Fa e Tables of (((T1 \ H ) T2 ) T3 ) \ C . . . Edge Table of (((T1 \ H ) T2 ) T3 ) \ C . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
170 181 199 199 200
7.1 Times for Constru ting Small Grobner Bases . . . . . . . . . . 291 7.2 Times for Constru ting Large Grobner Bases . . . . . . . . . . 291
xix
Chapter 1 Introdu tion
Solid modeling is rapidly emerging as a entral area of resear h and development in su h diverse appli ations as engineering and produ t design,
omputer-aided manufa turing, ele troni prototyping, o-line robot programming, and motion planning. All these appli ations require representing the shapes of solid physi al obje ts, and su h representations and basi operations on them an be provided by solid modeling. As a eld, solid modeling spans several dis iplines, in luding mathemati s, omputer s ien e, and engineering. In onsequen e, it is a broad subje t that must a
ommodate a diversity of viewpoints and has to meet a diversity of goals. Sometimes, this diversity of goals an lead to on i ting demands. Current thinking on the subje t views the proper resolution of these on i ts to be appli ation-dependent. That is, it is no longer thought realisti to envision a omprehensive solid-modeling system that satis es the needs of all potential users. Rather, as it is argued, we should on entrate on onstru ting a software environment in whi h many tools for geometri and solid
omputation are available and an be ombined with ease as appropriate for the spe i appli ation under onsideration. Whether we seek to build a omplete system or wish to a
umulate a set of tools, we need to study and implement many geometri algorithms. In this book, we explain what is needed for this task. Of ne essity, we must therefore over te hniques from omputer s ien e, numeri al analysis, symboli omputation, and many other areas. The relevant fa ts from these
1
2
Introdu tion
areas are brought together as they are needed. Not only do we develop them te hni ally, we also explain their intuitive ontent as mu h as possible, for we have found that intuitive explanations a
elerate absorbing the material. Moreover, an intuitive understanding of the ideas underlying a parti ular subje t serves as a guide when spe ial topi s are pursued further by reading the pertinent literature, be it for resear h purposes or for spe ializing ertain methods as demanded by some appli ation. Geometri or surfa e modeling traditionally identi es a body of te hniques that an model ertain lasses of pie ewise parametri surfa es, subje t to parti ular onditions of shape and smoothness. It developed as a separate eld in several industries, in luding automobile, aerospa e, and shipbuilding, and has some of its intelle tual roots in approximation theory. It is our view that the streams of geometri and solid modeling are onverging. As solid modeling strives to extend the geometri overage, there is an emerging need to resear h the use of surfa e forms and the te hniques to interrogate them. Similarly, as geometri modeling ontemplates building omplete solid representations from surfa e pat hes, the usefulness of traditional solid-modeling te hniques is more widely re ognized. In anti ipation of the growing importan e of this onvergen e, a large part of this book is devoted to geometri investigations of impli it and parametri surfa es. Although we will develop a lot of ma hinery to deal with surfa e geometries, we do not over the traditional body of knowledge on parametri surfa es developed by lassi al geometri modeling. Instead, we on entrate on the fundamental issues that are at the fo al point of the possible integration of geometri and solid modeling, and develop te hniques that have the potential to bridge the urrent gaps between the two areas of a tivity. Thus, we understand geometri modeling in the more generi sense. 1.1 A Brief Histori al Perspe tive of Solid Modeling
As a eld, solid modeling is the outgrowth of several onvergent developments. These in lude automati drafting systems, free-form surfa e design, and graphi s and animation. Computer drafting systems repla e manual engineering drawing. Some of the bene ts are that ele troni drawings an be modi ed and ar hived more easily, and that one may verify automati ally the validity of a design by a program rather than by human inspe tion. Compli ated engineering drawings may ontain errors. Su h errors in the ele troni ounterpart may, in prin iple, be orre ted without the risk of introdu ing new errors elsewhere. However, programs to verify design validity are nontrivial, and resear h on this subje t ontinues. Early eorts in automated drawing resulted in wireframe modeling systems | that is, in systems in whi h only the edges and verti es of obje ts are represented. This would be a natural representation, assuming that the obje tive is to generate line drawings of the design, proje ted in ertain
1.1 A Brief Histori al Perspe tive of Solid Modeling
Figure 1.1
3
Ambiguous Wireframe Obje t
dire tions. Unfortunately, there may be ambiguities in interpreting the representation. A simple, well-known example of this phenomenon is shown in Figure 1.1. The gure shows a blo k with a beveled hole through its enter. It is not possible to dedu e the dire tion of the hole, sin e it ould lie in any of the three prin ipal dire tions. For this reason, wireframes are not the preferred obje t representation. On the other hand, wireframe obje ts have small storage requirements and an be a
essed and displayed qui kly. The resulting line drawings onstitute an a
eptable visualization aid in many situations, and an provide a qui k feedba k between the modeling system and the designer. For this reason, many modeling systems retain the apability to generate wireframe drawings. A se ond ontributor to solid modeling has been free-form surfa e design, using parametri surfa e pat hes and, in parti ular, various types of spline surfa es. Surfa e design with splines originated in the automobile industry, prin ipally for ar body design; in the shipbuilding industry, for the design of ship hulls; and in the air raft industry, for the design of wings, fuselages, and so on. Free-form surfa e design in these areas has led to the eld of
omputer-aided geometri design (CAGD), primarily fo using on methodologies for designing urved surfa es subje t to aestheti or fun tional onstraints. Resear h in CAGD has dis overed many useful lasses of parametri surfa es and has developed a large repertoire of algorithms for their design, analysis, and manipulation. These surfa es would be most useful in solid modeling. As we stated, we over basi on epts underlying the use of these surfa es in solid modeling. Many books are available that over the more
lassi al te hniques of modifying the shapes of spe i surfa es lasses, and we ite some of them at the end of this hapter. The diÆ ulty of evaluating and representing the interse tion of parametri surfa e pat hes has hindered the development of solid modelers that in orporate parametri surfa es. Roughly speaking, the topology of a surfa e pat h be omes quite ompli ated when Boolean operations are performed. Finding a onvenient representation for these topologies ontinues to be a major
hallenge. It might seem pe uliar to identify omputer graphi s as an area ontributing to solid modeling. Indeed, the primary fo us of omputer graphi s is to
4
Introdu tion
render realisti images of obje ts, and this an be done from data stru tures that do not represent omplete solids. However, there is a need in solid design to obtain visual feedba k, so we want to render images from solid representations, and thus an understanding of graphi s algorithms and the surfa e representations used by them an be useful. Conversely, onstru ting images from solid models is gaining in importan e in animation and is also used by rendering algorithms that support image generation in s enes from
hanging points of view. Thus, omputer graphi s is beginning to deal with solid models as data and ould make useful ontributions to visualization te hniques and to user-interfa e design.
1.2 Three Levels of Abstra tion
Con eptually, a solid-modeling system spans three levels of abstra tion: 1. The user of the modeling system is presented the highest level of abstra tion, the user interfa e. He or she intera ts with the system through a design language that may be textual, visual, or both. On this level, on eptual tools for onstru ting, modifying, ar hiving, and destroying designs are available. Also, there may be various tools for analyzing a design, perhaps even for reasoning about some of its properties. 2. Next, there is a lower level of abstra tion omprising the mathemati al and algorithmi infrastru ture. The infrastru ture implements the
on eptual operations available in the user interfa e, as well as a wide range of auxiliary tools needed by these operations. Examples in lude algorithms for onstru ting the interse tion of two obje ts, or tools for determining whether and how two urved surfa es interse t. 3. On the lowest level, there is the substratum of arithmeti and symboli
omputations that are used as primitives by the algorithmi infrastru ture. In the most basi sense, this substratum onsists of the hardware
apabilities for integer and oating-point arithmeti , and the logi al operations the hosen programming language oers for expressing omputations and viewing storage. Computer s ien e tea hes that levels of abstra tion should be kept logi ally separate, and that lower levels must not unduly in uen e higher levels. Yet, as we shall see, this ideal situation appears to be presently unattainable, ex ept at the great expense in urred by exa t arithmeti , so ertain operations done at the highest on eptual level take their parti ular form essentially be ause of unreliabilities on the lowest level.
1.2 Three Levels of Abstra tion
5
1.2.1 User Interfa es
Mu h of the interest in solid modeling is due to the per eived value of automating the design and analysis of solid obje ts. If the eld is to reap the bene ts that good solid-modeling systems ould provide, then modeling must be made as widely a
essible as possible, and must be developed into as exible an instrument as possible. Mu h of this would be the result of having good user interfa es that su
essfully engage people with minimum training and in rease the produ tivity of experien ed designers. It is widely a
epted that user interfa es should have a strong visual omponent, but learly a textual intera tion is also required; for instan e, for the sake of pre ision. Furthermore, if the modeling system is interfa ed to an analysis system, a more ma hine-oriented interfa e must also be present. A major task of the interfa e is to present the user with a set of operations for solid design and modi ation. Among these operations are the well-known Boolean operations, global modi ations su h as rounding and osetting, and lo al modi ations su h as edge beveling or fa e extrusion. In many ases, the operations are not fully understood. For example, when sweeping an area along a spa e urve to de ne a volume, should we allow possible selfinterse tion? In doing detail design, we would like to on entrate our eort on lo al areas of interest and to design them more or less without paying attention to the rest of the design. Having ompleted the design of su h features, we ould then spe ify their position and orientation in the larger design through onstraints. Mu h urrent resear h explores these goals of interfa e design. It is not lear how best to de ne features, yet we know that the
on ept is needed. The notion of features is probably not a stati on ept; that is, the same geometri design of an obje t will have dierent features, depending on the view point. For instan e, if we onsider how to evaluate stress on entrations, then features su h as sharp edges are of interest. If we onsider ma hining operations, we might be interested in the geometry of holes and slots found on the obje t. The main diÆ ulty, it seems, is to identify a atalog of forms de ning a set of features of interest, and to understand how these forms may intera t. For example, if a slot is pla ed at the edge of an obje t, as shown in Figure 1.2 to the right, should we still
onsider it a slot? Current thinking also stresses the need for on eptual design; that is, for a oarse design laying out the overall stru ture without various details. It is argued that a more eÆ ient approa h to engineering design is an overall outlay of the rough shape, with rapid visual feedba k, exploration of the suitability of the design through some suite of analysis omputations, followed by a omputationally intensive detailed design. This approa h should not only alleviate some of the delays in urred by ertain expensive detailed design operations, but also bring us loser to the long-term goal of design by fun tionality. In the abstra t, we may not are about a parti ular shape, as long as it realizes a ertain fun tionality. For example, in designing a
6
Introdu tion
Figure 1.2
Two Slot Positions
piston engine like the one shown in Figure 1.3, our fun tional goals might in lude that the engine develop a ertain power while not running too hot or being too heavy. As design parameters, we might wish to vary piston size, stroke length, wall thi kness, and ooling-line pla ement. It seems ertain that design by fun tionality is a possibility, but we have no systemati body of knowledge establishing this onne tion pre isely in a range of appli ations. 1.2.2 Mathemati al and Algorithmi Infrastru ture
Infrastru ture is traditionally the strongest and most prominent resear h subje t in solid modeling. Among the many questions addressed is the development of eÆ ient and robust algorithms and representations for solving
H P
Figure 1.3
Piston Engine
1.2 Three Levels of Abstra tion
7
the geometry problems that arise in solid modeling. We mention a few: 1. Given two solid models, test whether they interfere with ea h other. If so, determine the volume of their interse tion. 2. Given two urved fa es interse ting in a sharp edge, nd a surfa e that smoothly onne ts the two urved fa es, thereby blending the edge. 3. Given a urved fa e of a solid model and a point on the surfa e, determine whether this point lies within the fa e boundary. 4. Given a losed pie ewise algebrai urve in the plane, sweep it along a spa e urve and determine the surfa e of the volume so swept. Sin e eÆ ient algorithms depend on suitable representations for solids and their onstituting elements (i.e., for their fa es, edges, and verti es), it is
ru ial to study dierent s hemata for representing them. Moreover, sin e there are typi ally no uniform best hoi es, onversion algorithms between dierent representations must be designed. In all these algorithms, we must a
ount for eÆ ien y in spa e and time, as well as for numeri al stability and a
ura y. 1.2.3 The Substratum Problem
The distin tion between substratum and infrastru ture may appear arbitrary, and we should larify why it is made here. When implementing many of the geometri algorithms found in the literature, one en ounters a fundamental diÆ ulty: Even though an algorithm may have been meti ulously implemented, it need not be ompletely free from errors. But these errors seem to be due neither to arelessness in the implementation, nor to a mistake in the algorithm design. Rather, the error is due to an oversight | we take for granted that the arithmeti operations in the geometri omputation are pre ise. Of ourse, we realize that oating-point arithmeti is approximate, but we might have assumed that the errors so in urred are insigni ant. This is not always the ase, and the distin tion between substratum and infrastru ture helps to on eptualize the nature of the diÆ ulty. A omputer does two types of omputation: symbol manipulation, whi h
an be done exa tly, and numeri al omputation. The latter is exa t only for integer and rational arithmeti , and is subje t to impre ision in oating-point arithmeti . Floating-point error is due to the limited pre ision to whi h the
al ulations are done and suers from roundo and digit- an ellation errors. The two problems are well known in numeri al analysis and have given rise to extensive resear h into designing algorithms that exhibit greater a
ura y and numeri al stability, besides solving a problem eÆ iently. The vast majority of geometri omputations in solid modeling are performed in oating-point arithmeti . Sin e logi al de isions are made based on these al ulations, errors in urred by the arithmeti should be of great
8
Introdu tion
on ern. In parti ular, sin e the same logi al de ision may re ur throughout a omputation but may have been based on dierent al ulations, there is the possibility of making in onsistent de isions. It is pre isely this possible in onsisten y that auses solid-modeling systems to fail on ertain inputs. The interplay of symboli and arithmeti omputation is a riti al dimension in solid modeling and appears to be unparalleled. It raises fundamental problems of profound mathemati al ontent, and there is a growing sense in the eld that these problems need to be addressed urgently. At this time, it appears that there are three hoi es: 1. Create a substratum implementing exa t arithmeti . Typi ally, this slows down all omputations una
eptably, but in some situations a priori pre ision bounds exist, and then this approa h may lead to a
eptable speeds. 2. Use an inexa t arithmeti substratum, and hope for the best. This is the traditional hoi e of system designers, and a great deal of eort is subsequently expended to tune the system su h that the o
asional
atastrophi failures do not happen in typi al appli ations. 3. Augment an inexa t arithmeti substratum with spe i algorithmi steps that avoid atastrophi failure and are apable of delivering valid results for all inputs. This alternative has been proposed only re ently and is the subje t of mu h urrent resear h. Note that an exa t arithmeti substratum does allow a lean separation of the various levels of abstra tion. However, urrent te hnology does not have the ne essary tools to make this approa h attra tive in the urved-surfa e domain, and we have to wait with this alternative until more progress has been made. The se ond hoi e does not permit a lean separation of substratum, infrastru ture, and user interfa e. Systems implemented in this way will fail o
asionally, so the rst phase of an implementation is usually followed by a se ond, time- onsuming phase in whi h the system is ne-tuned to avoid failures on ommon inputs. Although this ne-tuning is often done by trial and error, it an be ameliorated by areful onsideration of the geometri signi an e of ea h error as it is en ountered. Su h systems are diÆ ult to maintain and hanges to them are risky. The third alternative, nally, is to redesign a substratum in whi h operations su h as point/surfa e in iden e are supplemented by pro essing steps that a
ount for ina
ura ies. At this time, it is hard to assess the impa t this approa h may have on the omplexity of the algorithm, and whether the approa h an a hieve a stri t separation of the levels of abstra tion. Known
omplexity bounds seem to be overly pessimisti , and mu h further work will be needed before we an judge the ultimate utility of this approa h. Resear h on this subje t is, of ourse, fueled by the hope that in this way we an rea h a middle ground somewhere between the expensive exa t approa h and the
ompli ated and unsatisfa tory traditional approa h.
1.3 About This Book
9
1.3 About This Book
This book deals primarily with the on epts and tools needed to design and implement solid-modeling systems, their infrastru tures, and their substrata. Of ne essity, this subje t requires a onsiderable amount of mathemati al fa t and thinking. We have made every eort to make the material a
essible even to the novi e. The reader should be able to absorb the intuitive ontent without mu h diÆ ulty. Going into the details may require some patien e, perhaps, but should not be daunting. Throughout the book, algorithms and the underlying theory needed to design them are in the foreground. Thus, designers, implementors, te hni al leaders of solid-modeling groups, and a ademi resear hers onstitute the primary audien e of this book. Nevertheless, a prospe tive user of a solidmodeling system should read Chapters 1 and 2 to gain an appre iation of the eld and of the basi on epts it exer ises. Armed with these insights, he or she should then be able to assess the true apabilities of the systems under
onsideration. Chapter 4 provides an understanding of the ner points, and is useful when judging whether the system an provide the needed a
ura y and robustness. Chapter 2 explains the basi on epts. It dis usses rst the on eptual operations that one expe ts to nd in a user interfa e, ex ept for visualization and ar hiving operations. The presentation is kept on eptual, rather than te hni al, and is well suited to the asual reader who wishes to gain an overview. The hapter then presents the two dominant representation s hemata used in solid modeling | namely, onstru tive solid geometry (CSG), and boundary representation (B-rep). Basi geometri operations in CSG are also sket hed. The se tion on topologi al validity presents te hni al material needed for devising algorithms that test whether a given boundary representation is orre t. There are other representation s hemata, and they are brie y summarized at the end of Chapter 2. In Chapter 3, we design an algorithm for Boolean operations on solids given in a boundary representation. This algorithm serves as a useful frame for developing an appre iation of the subtleties of representing and manipulating solids. Representing, analyzing, and manipulating solid models by
omputer is not a simple matter, and to implement ompetently modeling operations su h as the determination of the interse tion of two solids is a proje t of onsiderable omplexity. For this reason, the interse tion operation is dis ussed in depth. We restri t Chapter 3 to the interse tion of polyhedra with nonmanifold boundaries. Ex ept for the treatment of tangen ies and singularities, polyhedral interse tion requires dealing with virtually all aspe ts of this operation, so our restri tion does not oversimplify the problem. The polyhedral-interse tion algorithm an be used as the basis for an extension to urved solids. The added diÆ ulties en ountered relate to mathemati al issues and a
ura y questions that are dis ussed in Chapters 5 and 6. Chapter 4 addresses the important substratum problem. There is at present mu h dis ussion as to the true origin of the problem; hen e, the hap-
10
Introdu tion
ter looks at dierent manifestations of a
ura y and robustness problems and surveys a number of approa hes proposed for solving them. It seems that the polyhedral ase is already very diÆ ult, and we have restri ted our presentation to this ase only. As already mentioned, resear h on this subje t is relatively re ent and has not yet matured, so the hapter on entrates more on making the problems intelligible rather than on giving re ommendations for a \best" solution. The balan e of the book is devoted to the treatment of urved surfa es. Chapter 5 begins this topi by looking at the representational requirements. Surfa es an be represented parametri ally or impli itly. Both representation styles have strengths and weaknesses. For example, for an impli itly represented surfa e f (x; y; z ) = 0, the problem of testing whether a given point p lies on the surfa e is simple. If the same surfa e is represented parametri ally, then this question is diÆ ult. On the other hand, it is simple to generate points on a parametri surfa e. On an impli it surfa e, this would be mu h harder. Hen e, we will examine methods for onverting between parametri and impli it surfa e forms. Curve and surfa e singularities add spe i subtleties to boundary representations of urved solids. If they are ignored, geometri ambiguities may arise that are due to the fa t that, between two points in spa e, there might be dierent onne ting urve segments, both belonging to the interse tion of the same pair of urved surfa es. An example of this phenomenon is also dis ussed in Chapter 5, along with re ommendations on how to avoid it. When we are dealing with urved surfa es, the evaluation of their interse tion is a fundamental operation. Chapter 6 looks at a number of te hniques used to implement this operation. Spe i ally, by ombining traditional numeri al te hniques with symboli omputations from algebrai geometry, it is possible to deal with ompli ated singularities. For plane urves, these algebrai te hniques are simple and ee tive. Su h urves ould be trimming
urves when interse ting parametri surfa es. For spa e urves presented as the interse tion of two impli it surfa es, ompli ations arise that ontinue to be resear h topi s. Here, one expe ts that more sophisti ated symboli
omputations will be needed. Sin e symboli algebrai omputations require a working knowledge of ideal theory, we have added a hapter on Grobner bases te hniques. These te hniques in lude some very powerful algorithms for impli itization and inversion, and provide ompletely general and omprehensive methods for solving systems of algebrai equations. The great generality of the algorithms make them too slow to be of immediate routine use in produ tion systems. However, they hold mu h potential for providing spe ializations that ould play a major role in the manipulation and analysis of urved surfa es. We tou h on some of these spe ializations in the se tion on basis onversion. This se tion also des ribes a strategy for impli itizing urves and surfa es that an handle problem sizes that ould not be atta ked su
essfully by other te hniques known to us.
1.4 Notes and Referen es
11
1.4 Notes and Referen es
As A. Requi ha pointed out, the term solid modeling is of relatively re ent
oinage: Early work used the term geometri modeling to refer to solid modeling, and reserved the term surfa e modeling to refer to work on parametri
urves and surfa es. There are several surveys dealing with solid modeling, in luding Requi ha and Voel ker (1983). The survey by Requi ha (1988) is a re ent update. Voel ker, Requi ha, and Conway (1988) is another survey of the area that fo uses on how solid modeling ould be integrated into the manufa turing pro ess and on what the problems raised by this prospe t are. Geometri modeling in the urrent sense is the subje t of the books by Bartels, Beatty, and Barsky (1987), Farin (1988), and Mortensen (1985). These books give good introdu tions to the rather large literature on the subje t. In his book on solid modeling, Mantyla (1988) des ribes how to represent manifold polyhedral obje ts and how to implement Boolean operations on them. He also des ribes a fa ility for storing and undoing previous designs. Chiyokura (1988) des ribes the implementation of Designbase, a spe i modeling system with some urved-surfa e apabilities. Brie y, urved solids an be designed and modi ed by lo al operations, su h as altering the shape of ertain edges and fa es, but Boolean operations require that one of the interse ting obje ts be polyhedral. All obje ts will have manifold surfa es. Chiyokura's book also dis usses several lasses of parametri urves and surfa es. The ambiguity of wireframes shown in Figure 1.1 was found by J. Shapiro at the University of Ro hester.
12
Introdu tion
Chapter 2
Basi Con epts
This hapter reviews the on eptual operations one expe ts to be present in the user interfa e. Also dis ussed are onstru tive solid geometry and boundary representation, two major representation s hemata used in solid modeling. In onstru tive solid geometry (CSG) a solid is represented as a settheoreti Boolean expression of primitive solid obje ts, of a simpler stru ture. Both the surfa e and the interior of an obje t are de ned, albeit impli itly. A boundary representation (B-rep), on the other hand, des ribes only the oriented surfa e of a solid as a data stru ture omposed of verti es, edges, and fa es. The orientation onvention permits us to de ide on whi h side of the surfa e the solid's interior is lo ated.1 This suÆ es to des ribe the solid's interior and exterior unambiguously, provided the surfa e and its geometri embedding satisfy ertain geometri and topologi al requirements. CSG and B-rep have dierent inherent strengths and weaknesses. For instan e, a CSG obje t is always valid in the sense that its surfa e is losed and orientable and en loses a volume, provided the primitives are valid in this sense. A B-rep obje t, on the other hand, is easily rendered on a graphi display system. In onsequen e, there is a dis ernible tenden y to ombine both CSG and B-rep in an eort to take advantage of the dierent strong points aorded by ea h. Su h modelers are alled dual-representation modelers. 1 If
only ob je ts of bounded volume are represented, then a surfa e orientation is un-
ne essary. However, we shall permit unbounded ob je ts.
13
Basi Con epts
14
To develop an understanding of the properties and algorithmi aspe ts of these representations, we des ribe some of the basi operations on them. For CSG, these in lude lassifying points, urves, and surfa es with respe t to a solid; dete ting redundan ies in the representation; and approximating CSG obje ts systemati ally. For B-rep, we review the possible surfa e types, the winged-edge representation s hema, and the Euler operators. A more exible B-rep s hema is given later in Chapter 3, where we dis uss how to interse t two polyhedra given in this representation. Given a boundary representation, the question of whether it represents a solid is of obvious pra ti al interest. Algorithms for testing topologi al validity an be given, but should be based on pre ise mathemati al de nitions. We develop formal de nitions of what onstitutes a valid solid in the topologi al sense, and derive from it a validity he k. This material is intri ate and uses methods from algebrai topology. Although the intuitive ontent is fairly obvious, it is ne essary to develop the material arefully, sin e there are many subtleties that are not apparent at rst glan e. There are other solid representation s hemata based on spatial subdivision; for example, o trees. We omment on them brie y at the end of the
hapter, but do not go into the algorithmi aspe ts entailed by them. 2.1 Con eptual Operations and Primitives
Irrespe tive of the representation s hema hosen, we must make available
on eptual tools for de ning obje ts, for modifying them, and, eventually, for ar hiving them. We dis uss these operations now. 2.1.1 Primitives
A solid design is usually reated in several steps that begin with an existing design and modify it, or reate a new design from primitive obje ts. The former situation presupposes an earlier design that is retrieved from a database. The latter situation depends on a suitable notion of what onstitutes a primitive. Primitive obje ts are sele ted from a universe of possible shapes. A shape is instantiated by assigning values to ertain parameters. Some systems allow delaying parameter assignment. We give three examples of primitive obje t de nition. 1. Ea h primitive is sele ted from a set of solid shapes and is instantiated by hoosing values for ertain dimensioning parameters that ontrol the nal shape. For instan e, a CSG modeler may use blo ks, ylinders, spheres, ones, and tori. The parameters in this ase in lude the side lengths of blo ks, the diameter and length of ylinders, and so on. 2. A primitive is reated by sweeping a ontour along a spa e urve. Both the shape of the ontour and the shape of the spa e urve are de ned
2.1 Con eptual Operations and Primitives
Figure 2.1
15
Shape Variation Due to Parameter Values
by parameters. For instan e, we an sweep a disk of radius r along a line segment of length l, thus reating a solid ylinder. This approa h lends itself to generating and verifying utting paths for numeri ally
ontrolled ma hining. 3. All primitives are algebrai halfspa es; that is, point sets de ned as
f(
x; y; z
) j f (x; y; z ) 0g
where f is an irredu ible polynomial.2 The oeÆ ients of the polynomial an be onsidered the shape parameters. This approa h has been used in several resear h systems. We will dis uss the rst approa h in the se tion on onstru tive solid geometry (CSG). Note that, in a pure CSG modeler, the instantiation of the shape parameters an be delayed. It is then possible to onstru t generi designs. However, a generi design annot be displayed or onverted to boundary representation, sin e dierent parameter assignments ould lead to totally dierent shapes. See also Figure 2.1, where we have varied the diameter of the ylinder de ning the hole. In some modelers, the parameters
arry default values that an be used to visualize generi designs. In the se ond approa h, various elementary operations have been proposed for reating primitive solids. A typi al example is sweeping: We are given an obje t to be swept, and a path along whi h to sweep it, and thereby we de ne some volume. The obje t S to be swept ould be a nite area delimited by a
losed urve, or a solid. The path of the sweep typi ally would be a segment of a spa e urve C, and ould be open or losed. The primitive solid reated by this operation onsists of the volume swept by S as it is moved along C. An example is shown in Figure 2.2. The mathemati s of sweeping is more deli ate and demanding than it might seem at rst glan e. Foremost, it depends on ertain onventions. We 2 As
explained in Chapters 5 and 7, a polynomial is irredu ible if the point set de ned in the text annot be de omposed into the union of simpler omponents. Te hni ally, the polynomial f is irredu ible if it annot be fa tored.
Basi Con epts
16
Figure 2.2
A Cir ular Disk Swept Along a Line
need to x a referen e point on S that will traverse the urve C. We also must de ne how, if at all, the orientation of S varies as S moves along C, and what the initial orientation is. These onventions must be determined by default or by suitable parameters to the sweep operations. Then, there
ould be degenera y problems: If a planar area S with xed orientation is moved along a path C that has a tangent parallel to the plane ontaining S, then the interior of the resulting volume ould have self-interse tions. In the three-dimensional example shown in Figure 2.3, this is indi ated by the
rease in the enter that is the result of a self-interse tion. Figure 6.6 in Chapter 6 shows a two-dimensional example. Moreover, if the entire path C is parallel to the plane of S, then we have de ned an area instead of a volume. If su h ases are onsidered an error, we need algorithms for their dete tion. If they are allowed, we need to give proper meaning to the results. Usually, there is no losed-form mathemati al des ription of the surfa e bounding the swept volume. For example, the ylinder in Figure 2.2 is bounded by nite areas on two linear surfa es and on one quadrati surfa e. Moreover, if the surfa e ontains self-interse tions or other types of singularities, the areas of interest may not have a simple de nition. Important spe ial ases in lude sweeping a sphere along a spa e urve or a ross a surfa e of another solid. In the rst ase, we obtain a partial des ription of the volume removed by a ball utter as the utting tool is
Figure 2.3
Sweep Degenera ies
2.1 Con eptual Operations and Primitives
17
moved along the path of the sweep.3 Thus, this ase has appli ations in numeri ally ontrolled ma hining, and an be used to represent the ee t of utting operations, either for automati generation of utter paths or for veri ation that su h paths do not interfere with other parts of the solid to be manufa tured. When a sphere is moved a ross a surfa e, we obtain a volume bounded by the oset of the surfa e. Osetting an be viewed as an operation on solids or on surfa es, and has been used to de ne global blending operations on solids in whi h all edges are rounded or lleted. We return to the subje t of osets and spheri al sweeps in Chapters 6 and 7. The third approa h of using algebrai halfspa es as primitives raises dif ult algorithmi problems and is the subje t of urrent resear h. Unless additional restri tions are pla ed on f, the generality of the primitives an be overwhelming, and general algorithms su h as the ones dis ussed in Chapter 7 should be onsidered. Note that variations of the third approa h have also been used. For example, we ould require that the polynomial f have degree no greater than 2 or 3. Doing so has the advantage that the spe ialized te hniques dis ussed in Chapter 5 suÆ e to manipulate the resulting obje ts.
2.1.2 Lo al Modi ations Numerous lo al modi ations to solids have been proposed. Most of them operate on a boundary representation, and an be implemented using Euler operations (see also Se tion 2.3.4). Figures 2.4 through 2.6 show several examples. If we operate on boundary representations with simple shape elements, then lo al modi ations ould be inexpensive, provided that the geometri shapes we manipulate are suÆ iently simple. Lo al modi ations do, however, require validity he ks to avoid errors su h as the one shown in Figure 2.7. Here, the fa e is extruded too far and interferes with other parts of the solid.
3 Stri tly
speaking, a ball utter annot physi ally remove the entire volume swept by
the sphere, sin e we must a
ommodate the shaft of the utter.
Basi Con epts
18
Figure 2.4
Extruding a Fa e
Figure 2.5
Beveling a Vertex
Figure 2.6
Altering Edge and Fa e Shape
2.1 Con eptual Operations and Primitives
Figure 2.7
19
Error in Fa e Extrusion
2.1.3 Global Operations
There are several trivial global operations, in luding rotating and translating solids. Regularized Boolean operations, explained in Se tion 2.2, are also
onsidered global operations, as are the operations of osetting solids, and of rounding all onvex and lleting all on ave edges. 2.1.4 Undoing and Redoing
Ideally, solid design is an intera tive pro ess in whi h the designer experiments with alternatives, modi es them, orre ts errors, and so on. Whereas intera tivity demands qui k response time, exploring alternative designs and
orre ting errors requires the possibility of undoing a sequen e of operations, or redoing some of them. Undoing an operation requires minimally a history that re ords all operations leading, in sequen e, to the present design. Then, in prin iple, we ould re onstru t the entire sequen e of operations, from the beginning up to some prior point. Ee tively, this undoes all subsequent operations. If alternatives should be explored and if we wish to return to some of them, then the history re ord must be a tree. An example of a history tree of designs is shown in Figure 2.8. Redoing a design from the root up to a spe i alternative is inferior to using a more dire t undo apable of reversing the ee t of an operation. The diÆ ulty of the undo will depend on the way obje ts are represented. The operation is easy in pure CSG. In boundary representation, lo al modi ations are easy to undo, but Boolean operations are not. For diÆ ult undo operations, it is better to he k point; that is, we store the representation of the design prior to the operation, and then on e more after its ompletion. Then, undoing is simply a retrieval. The ost of he k pointing has to be balan ed against the ost of inverting the operation. If an undo is heap, it is probably better not to he k point, espe ially in B-rep, where the data stru tures des ribing the urrent design may be very large. Having undone a partial design, we may wish to re onstru t a design alternative previously de ned. Sin e most operations in lude onsisten y
Basi Con epts
20
(0.1)
(1.2)
Figure 2.8
History Tree of Design
(1.1)
(2.1)
(2.2)
(3.1) (3.3)
(3.2)
Figure 2.9
Indexing a History Tree
he king for their results, an expli it redo operation has the advantage that su h he ks are not needed. Thus, a redo operation an be faster. Moreover, for expensive operations su h as union or interse tion, redo an simply a
ess the he k-pointed representation and is therefore also heap. The history tree should be presented to the user as an aid to remember the various versions of design already explored. The presentation an be augmented by an indexing s heme that generates default names for the design based on the position in the history tree. Thus, instead of issuing a sequen e of undo and redo ommands to rea h a spe i alternative, we an retrieve the alternative dire tly by giving its name. A simple indexing s heme is as follows:
Ea h tree vertex is indexed by a pair of numbers (i; j ), where i is the depth of the vertex, and j enumerates all verti es of equal depth in the order of reation.
The depth of a vertex is determined as follows: The root has depth 0; if v des ends from a vertex w, then depth(v ) = depth(w) + 1. Figure 2.9 shows an example.
21
2.2 CSG Representation
z a
r
b
h
c
box (a,b,c)
Figure 2.10
y
x
z−cylinder (r,h)
Coordinate Frames for Two Standard Primitives
2.2 CSG Representation
In the stri t sense, CSG is a method of representation, a design methodology, and a ertain standard set of primitive obje ts. So, a CSG obje t is \built" from the standard primitives, using regularized Boolean operations and rigid motions. We will sket h this methodology rst, and will present some of the properties and algorithms it entails. Later on, we will onsider the possibility of greatly enlarging the set of allowed primitives.
2.2.1 CSG Standard Primitives
The CSG standard primitives are the parallelepiped (blo k), the triangular prism, the sphere, the ylinder, the one, and the torus.4 They are generi in the sense that they represent shapes that must be instantiated by the user to
hosen dimensions. Thus, to obtain a parallelepiped of edge lengths 1, 1, and 3, one might spe ify blo k(1; 1; 3), where the lengths are expressed in units depending on onventions, or, perhaps, are given expli itly. Also depending on onvention would be the pla ement of the resulting obje t in spa e: With ea h primitive obje t there is asso iated a lo al oordinate frame. Here, we will pla e this oordinate frame as shown in Figure 2.10. These dierent lo al oordinate frames must be related to one another, by pla ing them with respe t to a ommon world oordinate frame, dis ussed later. All standard primitives have a nite domain. For example, the ylinder always has a nite radius and a nite length. This onvention seems to be rooted in the thought that we always model nite solids. We will see later that it an be onvenient to onsider in nite solids, at least as intermediate steps, in the pro ess of de ning omplex, nite solids. 4 Note
that the prism or the parallelepiped is redundant.
Basi Con epts
22
A Step 1
Step 2
Step 3
B
Figure 2.11
Pro edure for Regularized Interse tion
2.2.2 Regularized Boolean Operations
After instantiation, primitive obje ts an be ombined using regularized Boolean operations. The operations are the regularized union, denoted [ ; regularized interse tion, denoted \ ; and regularized dieren e, denoted . They dier from the orresponding set-theoreti operations in that the result is the losure of the operation on the interior of the two solids, and they are used to eliminate \dangling" lower-dimensional stru tures. For example, to ompute A \ B , we pro eed on eptually as follows: 1. We ompute A \ B in the set-theoreti sense. The result is a olle tion of volumes, and additional fa es, edges, and verti es. These additional fa es, edges, and verti es are lower-dimensional stru tures that we will eliminate. 2. We now take the interior of A \ B . The interior onsists of all those points p 2 A \ B su h that an open ball of radius , entered at p,
onsists only of points of A \ B , for a suÆ iently small radius . 3. We form the losure of this interior, by adding all boundary points adja ent to some interior neighborhood. A point q that is not an interior point of A \ B is adja ent to the interior if we an nd a urve segment (q; r) of suÆ iently small length , between q and another point r of A \ B , su h that all points of this segment are interior points of A \ B , ex ept q. Note that the lower-dimensional stru tures do not en lose volume and are therefore not adja ent to the interior of A \ B . The resulting solid is the regularized interse tion. Figure 2.11 illustrates the pro edure. Note that, in pra ti e, regularized Boolean operations are not implemented in this manner. Rather, A \ B is implemented by lassifying the surfa e elements of A \ B and eliminating lower-dimensional stru tures. This expli it lassi ation is delayed until a geometri query requires it, as explained later, or until a onversion from CSG to B-rep is arried out; see also Se tion 2.2.6. Eliminating the lower-dimensional stru tures is desirable for de ning solids. However, in some appli ations, it may be desirable to retain them, possibly
23
2.2 CSG Representation
even in the interior of obje ts. For example, when onsidering solids as doin nite element analysis, interior lower-dimensional stru tures might represent ertain onstraints on how to dis retize the domain, or might de ne the domain dis retization outright. At present, this is a resear h topi , and we do not explore this line of thought further. Before the two obje ts are interse ted, they must be positioned appropriately with respe t to ea h other. This is done by translations and rotations, as needed. To make this positioning meaningful, we must establish a relationship between the lo al oordinate frames of the obje ts. A simple method is to identify the lo al frames with a single, universal oordinate frame. The universal frame is often referred to as the world oordinate frame. Suppose we have positioned the two primitives, and have onstru ted an interse tion. Then, the resulting obje t should have a lo al oordinate frame of its own, needed for subsequent positioning operations we might wish to perform. By onvention, we will use (a opy of) the world oordinate frame for this purpose. mains
2.2.3 Constru tion of a CSG Obje t The CSG representation of the simple bra ket shown in Figure 2.12 is easily worked out. We think of the bra ket as the union of two blo ks of respe tive dimensions (1,4,8) and (8,4,1) with the hole subtra ted by a ylinder of radius 1. Without the hole, we an spe ify the bra ket as blo k(1; 4; 8)
[ x-translate(blo k(8 4 1) 1) ;
;
The hole is removed by subtra ting a ylinder about the the expression
;
z
axis, resulting in
(blo k(1; 4; 8) [ x-translate(blo k(8; 4; 1); 1)) x-translate(y-translate(z- ylinder(1; 1); 2); 5)
The expression is onveniently drawn as a tree, as shown in Figure 2.13. This tree an be onsidered to be the representation of the obje t, and is
ustomarily alled a CSG tree. We see that the leaves of the CSG tree are primitive solids, and the interior nodes are rigid motions and Boolean operations. In our example, the two blo ks joined are tou hing, and the ylinder length mat hes the bra ket thi kness. In pra ti e, this is an unsafe spe i ation for nonintegral dimensions be ause of the possibility of oating-point ina
ura ies. It is thus advisable to allow for a safe amount of overlap when spe ifying union operations. Here, then, is one pla e where substratum problems have intruded into the higher design levels.
2.2.4 Point/Solid Classi ation and Neighborhoods Having built a CSG obje t, we might wish to interrogate its geometry in various ways. The most elementary su h query is to test whether a point
Basi Con epts
24
z 1 4 8
4 y
2
9
1 R=1
x
Bra ket
Figure 2.12
(x; y; z ) is inside a solid, is on its surfa e, or is outside of it. This query is usually referred to as a point/solid lassi ation. Other su h queries in lude a lassi ation of how a line interse ts a solid, a lassi ation of how a surfa e interse ts a solid, and a test of whether two solids interse t in a nonempty volume. These operations will be dis ussed later.
_∗ x−translate (.,5) ∗ y−translate (.,2) x−translate (.,1) z−cylinder (1,1) box (1,4,8)
Figure 2.13
box (8,4,1)
Tree Representation of CSG Expression
2.2 CSG Representation
25
Point/solid lassi ation an be done with an algorithm that has a simple
on eptual stru ture. Despite its apparent straightforwardness, however, we soon realize that a diÆ ulty may arise when the point lies on the surfa e of a primitive, and this diÆ ulty ne essitates the introdu tion of neighborhoods. The basi idea underlying this and other su h algorithms is to redu e the point/solid lassi ation to a query of the primitives in the CSG tree. The respe tive answers, one for ea h primitive, are then ollated at ea h operation node as appropriate. Thus, the algorithm is based on the divide-and- onquer paradigm familiar from the literature.
Downward Propagation Point/solid lassi ation is naturally implemented as a set of re ursive pro edures, but it might be simpler to think of it as passing messages between the tree nodes. At the outset, the point oordinates are sent to the root of the tree. From there, they are propagated into the tree down to the leaves, possibly altered. At ea h leaf, the nal oordinates des ribe the same point, but with respe t to the lo al oordinate frame of the primitive solid that the leaf represents. At the leaf, we lassify the point as one of in, on, or out, depending on whether the point is, respe tively, in the interior, on the surfa e, or on the outside of the primitive solid. This lassi ation is passed ba k up the tree, to the root. At an operation node, the results from the subtree are oordinated. So, we spe ify the rst phase of the algorithm as follows. 1. If (x; y; z ) arrives at a node spe ifying a Boolean operation, then it is passed un hanged to the two des endants of the node. 2. If (x; y; z ) arrives at a node spe ifying a translation or rotation, the inverse translation or rotation is applied to (x; y; z ), yielding a new point (x ; y ; z ), whi h is sent to the node's des endant. 0
0
0
3. If (x; y; z ) arrives at a leaf, then the point is lassi ed with respe t to that primitive solid, and the lassi ation is returned to the parent of the leaf. When lassifying the point (2; 1; 0:3) with respe t to the bra ket, for instan e, we lassify the point (2; 1; 0:3) with respe t to blo k(1; 4; 8), the point (1; 1; 0:3) with respe t to blo k(8; 4; 1), and the point ( 3; 1; 0:3) with respe t to z- ylinder(1; 1). The respe tive lassi ations are out, in, and out.
Upward Propagation In the se ond phase of the algorithm, the messages ontain point lassi ations that must be ombined at the Boolean operation nodes. No work is done at nodes representing translation or rotation. Table 2.1 shows what to do for union and interse tion operation nodes.
Basi Con epts
26
[
in
on
out
\
in
on
in on
in in in on?
in on
in on
in on
on out on? out
out
in
out
out
out
out
Table 2.1
on
out
out
Naive Neighborhood Combination for Union and Interse tion
Neighborhoods
Implemented in this way, the algorithm will be in orre t. For example, lassifying the point (1; 1; 0:5) with respe t to the bra ket yields an in orre t on. The problem here is the lassi ation of points that lie on the surfa e of a primitive solid. These points may lie on a primitive surfa e area that remains a part of the surfa e of the solid des ribed by the tree, and then using the table yields the orre t result. If, however, the point is on a surfa e area that is not on the nal surfa e | for example, be ause it be omes solid interior as the point (1; 1; 0:5) does | then the tables do not suÆ e. What is needed in addition to the lassi ation as one of in, on, or out is the lo al geometry of the solid in the vi inity of the point. The additional information is given by a neighborhood of the point, as explained next. A neighborhood of a point p = (x; y; z ), with respe t to the solid S, is the interse tion with S of an open ball of in nitesimal radius entered at p. We used this on ept to de ne the interior of a solid, and re all that p is inside S, i the neighborhood is a full ball. The point p is on the outside, i the neighborhood is an empty ball. If p is on the surfa e of S, then the stru ture of the neighborhood depends on the lo al topology of S at p. We explain the possible topologies of these neighborhoods by restri ting the lo al geometry to planar surfa es; that is, by onsidering only polyhedra for the moment. We de ompose the surfa e of the solid into fa es, edges, and verti es. Here, a fa e is a losed subset of the surfa e all of whose points lie in the same plane.5 An edge is the interse tion of two adja ent fa es, and a vertex is the
ommon interse tion of three or more fa es. For example, the surfa e of a
ube onsists of 6 fa es, 12 edges, and 8 verti es. If a surfa e point is in the interior of a fa e, then its neighborhood is a halfspa e whose surfa e in the ball is a subset of the fa e. In Figure 2.14, the ball neighborhood of su h a point is shown, and the solid part of the neighborhood has been shaded. Next, onsider a point on an edge dierent from the two verti es. In the simplest ase, the edge is adja ent to exa tly two fa es, so the neighborhood is a wedge. For some CSG obje ts, however, it 5 Stri tly
speaking, we may have to split the losed subset into two maximal omponents
su h that the solid interior lies lo ally on the same side of the plane, for ea h omponent. In this ase, ea h omponent is a separate fa e.
27
2.2 CSG Representation
. Figure 2.14
P
Neighborhood of an Interior Fa e Point
is possible that an edge is adja ent to an even number of fa es that is greater than two. In that ase, the neighborhood of the point is a union of su h wedges, all with the edge in ommon, as exempli ed in Figure 2.15. Again, the solid part of the neighborhood is indi ated by the shading. Finally, onsider a vertex. Again the simplest ase is when all fa es in ident to the vertex are edge adja ent in a single y le. In that ase, the vertex neighborhood is a one. Some possibilities are shown in Figure 2.16. In general, the fa es in ident to a vertex are organized in several y les. In this general form, the vertex neighborhood onsists of a olle tion of ones, possibly with oni al holes and tou hing along ertain edges. All ones have the vertex as ommon apex; see also Figure 2.17 for an example. Su h a neighborhood an be represented as a set of urves on the surfa e of a sphere. The
urves represent the interse tion of the one surfa es with the sphere, and the resulting map on the sphere is two- olorable, with one olor representing solid interior, the other representing solid exterior. In the ase of urved surfa e elements, the neighborhood stru ture remains topologi ally the same as in the polyhedral ase, but the geometri stru ture is more ompli ated. Often, we an approximate the urved surfa es with the tangent planes at p. However, in situations where surfa e elements mat h and ombine in ways that alter the topology qualitatively, we must onsider the urved-surfa e geometry. Some of these situations are dis ussed in the next se tion.
P
.
Figure 2.15
P
.
Neighborhood of an Interior Edge Point
Basi Con epts
28
P
Figure 2.16
of a Vertex
.
.
P
Simple Neighborhoods
Figure 2.17
of a Vertex
General Neighborhood
Re ned Upward Propagation The problem with Table 2.1 is that no geometri information on the neighborhood stru ture is taken into onsideration. Thus, although the union of two halfspa es in general forms a wedge, it may remain a halfspa e or be ome a full solid ball. Sin e this geometri information is ignored, the tables
annot always produ e the orre t answer. Thus, to repair our method for pro essing the information during the se ond phase of point/solid lassi ation, we must perform the respe tive Boolean operation on the neighborhoods themselves. Only then do we obtain
orre t answers. This requires a
ounting for the lo al geometry, devising suitable data stru tures to represent neighborhoods, and transforming the geometri data appropriately at the rigid motion nodes in the tree. Again, we onsider the polyhedral ase rst. Representing the neighborhoods of interior or exterior points is trivial. So, let p be a point on the surfa e of the solid de ned by a subtree. If p is in the interior of a fa e, then the neighborhood an be represented by the plane equation of the fa e, oriented su h that the plane normal points to the exterior of the halfspa e. If p is on the interior of an edge, then the neighborhood is represented by a set of se tors in a plane ontaining p that is perpendi ular to the edge. Vertex neighborhoods, nally, are inferred from the adja ent edge neighborhoods. When performing Boolean operations on boundary representations, it will again be useful to think in terms of neighborhoods, so we will dis uss this subje t again in the next hapter. At a union node, we must ompute the union of the two neighborhoods of p that rea h the node from its left and right des endants. Ex ept for the trivial ases where one or the other neighborhood is the empty or the full ball, we must merge the two data stru tures and inspe t the result. We des ribe this pro edure on eptually. Essentially, the following rules apply for merging neighborhoods at a union node. Let NL and NR be the two neighborhoods at the des endants to the left and to the right. Then the neighborhood N at the node is as follows:
NL is the full ball, then N N = NR .
1. If
=
NL .
If
NL
is the empty ball, then
29
2.2 CSG Representation
P
. P
Figure 2.18
2. If
NL
and
NR
P
.
.
Edge-Neighborhood Merge, General Position
are fa e neighborhoods, then
N
is an edge neighborhood
unless the two fa es oin ide. This ase in ludes oplanar fa es; then,
N
will be a fa e neighborhood or the full ball, depending on how the
fa es are oriented.
3. If
NL
and
NR
are edge neighborhoods, then
N
is in general a vertex
neighborhood whose ones are formed from the wedges of see Figure 2.18. If the edges oin ide,
N
NL
and
NR
;
will be an edge neighborhood,
unless the wedges mat h up to form a single fa e with
p
in the interior;
see also Figures 2.19 and 2.20.
4. If
N
NL
is a vertex neighborhood, and
an edge neighborhood, then
is a vertex neighborhood unless ea h of its solid ones is ontained
in a wedge of
5. If
NR
NL
and
NR
NR
.
are vertex neighborhoods, then
N
is a vertex neigh-
borhood, as shown in Figure 2.21, unless the ones mat h up to form wedges or a fa e with
p
in the interior; see also Figures 2.22 and 2.23.
The remaining ases an be worked out easily, and analogous rules are formulated for the other Boolean operations. Clearly, the geometri pro essing required to over all ases is not trivial, even when we restri t our attention to polyhedral obje ts only.
The
vertex-neighborhood merge is inherently ompli ated be ause the neighborhood stru ture an be omplex. The other ases gain in omplexity be ause of the ex eptions that arise when the various geometri elements are in spe ial positions with respe t to one another.
P
.
. .
P
P
Figure 2.19
Edge-Neighborhood Merge Produ ing an Edge
Basi Con epts
30 P
. P
Figure 2.20
.
P
.
Edge-Neighborhood Merge Produ ing a Fa e
2.2.5 Curve/Solid Classi ation A useful interrogation primitive is the lassi ation of a spa e urve against a solid. The spe ial ase of the straight line an be used to generate shaded images as follows. Consider a line through the view point and a s reen pixel. Classify that line against the solid, pi k the nearest interse tion point, and, re alling whi h primitive is interse ted at that point, ompute the intensity from the surfa e normal and the lighting information. Sin e this appli ation uses the algorithm a large number of times, it is important to implement it as eÆ iently as possible. The approximation te hniques dis ussed here provide additional strategies for speeding up the omputations. The algorithm for lassifying a line or urve against the solid is organized exa tly like the point/solid lassi ation. 1. Send the line or urve des ription to the leaves. Partition the urve into segments labeled inside, outside, or on the surfa e of the primitive. 2. Propagate the segments ba k upward, and merge them appropriately. To lassify a line against a primitive, we may parameterize the line and substitute the parametri form into the impli it surfa e equations bounding the primitive, thereby deriving a polynomial in one variable for ea h surfa e. The roots of the polynomial de ne the interse tion points. Only those points that lie on the primitive are onsidered further. The points are then sorted along the line and are paired into segments with the appropriate labeling. Example 2.1: We lassify a line against a primitive ylinder. The
ylinder is z- ylinder(1; 2), and the line is
x = 2 y = 0
P
.
Figure 2.21
P
.
2
P
.
Vertex-Neighborhood Merge, General Position
31
2.2 CSG Representation
p
p
Figure 2.22
p
Vertex-Neighborhood Merge Produ ing an Edge
z = The ylinder's perimeter is given by x2 + y 2 1 = 0, so the line/perimeter interse tion points orrespond to the roots of (2 2)2 1 = 0. The two roots are = 1=2 and = 3=2, orresponding to the points p = (1; 0; 1=2) and q = ( 1; 0; 3=2). Both points are on the primitive, sin e they are above the plane z = 0 and below the plane z = 2 that bounds the ylinder domain. The interse tions of the line with these planes are outside the primitive, and hen e are irrelevant. We sort and pair the two interse tions found, and on lude that the segment (p; q ) is inside the primitive, and the unbounded segments with parametri values ( 1; 1=2) and (3=2; +1) are outside. 3 Classifying a urve against a primitive an be done in the same way, provided the urve has a parametri form. For su h urves, we sort the interse tion points by their parameter values. However, even when we onsider only those spa e urves that arise as the interse tion of two standard CSG primitives, we need not obtain urves that possess a parameterization. For those urves, more ompli ated sorting pro edures are needed. Brie y, if the urve lies on a parameterizable surfa e, then we may equivalently sort the points by sorting the orresponding points in parameter spa e. That is, instead of onsidering the point p = (x(s; t); y (s; t); z (s; t)) in threedimensional spa e, we onsider the point q = (s; t) in parameter spa e. If p is on the interse tion with another surfa e, then q is on a plane algebrai
urve C in parameter spa e. This urve C is onsidered. The urve C is de omposed into onvex segments not ontaining any singularities. Points Pk on a spe i segment may be sorted by the angle between the se ant RPk onne ting Pk with a suitable referen e point R and a referen e dire tion; see also Figure 2.24. All interse tion urves between standard
P
.
Figure 2.23
.
P
.
P
Vertex-Neighborhood Merge Produ ing a Fa e
Basi Con epts
32
. .. . C
Figure 2.24
. . . . .. . .
R
Sorting Curve Points on a Parametri Surfa e
primitives an be pro essed in this way. See Chapter 6 for information on how to deal with singularities on plane algebrai urves. How to sort points on a general spa e urve is not well understood.
2.2.6 Surfa e/Solid Classi ation, Conversion to B-rep A surfa e will interse t a solid in a number of areas. Ea h su h area is bounded by urve segments, where ea h segment is on the interse tion of the surfa e with one of the primitives of the solid. A general strategy for determining the segments, and from them the respe tive areas, is therefore as follows: 1. Interse t the surfa e with ea h of the primitives from whi h the solid has been onstru ted. 2. Classify the resulting urves, thereby determining the bounding edges of those surfa e areas that are inside or outside the solid, or are on the solid's surfa e. 3. Combine the segments, appropriately oriented, onstru ting a boundary representation of the respe tive surfa e areas. Elaboration of this on eptual method leads to many details but is straightforward. The resulting algorithms are similar to, or use outright, the algorithms for point/solid and for urve/solid lassi ation. Surfa e/solid lassi ation, in turn, an be used to devise a method for
onverting from a CSG to a boundary representation. Su h a onversion algorithm is based on the generate-and-test paradigm: We onsider all pairs of interse ting primitives in the CSG obje t A, obtaining for ea h a set of spa e urves in whi h they interse t. By lassifying ea h urve against the solid, we an determine those segments that are on the surfa e of A. Ea h segment will be an edge of the boundary representation. These segments now de ne, on the surfa e of the primitives, areas that will be the fa es of the boundary representation of A. By onsidering the neighborhoods, we derive the topologi al information needed to determine the adja en ies and in iden es of the various fa es.
33
2.2 CSG Representation
B
Figure 2.25
A [ B
A
A Is -Redundant in
D
Figure 2.26
C \ D
C
C Is -Redundant in
2.2.7 Redundan ies and Approximations in CSG Trees
Sin e a geometri query of a CSG tree grows at least linearly, and in some
ases quadrati ally, with the number of primitives, we investigate whether a given CSG tree ontains redundant subtrees that an be eliminated without altering the obje t de ned by the tree. The most blatant redundan y would be a subtree that represents empty spa e. Su h a subtree is said to de ne the null obje t, , and a dete tion algorithm for an be used to test whether two CSG obje ts interfere: Let T1 and T2 be two CSG trees de ning the obje ts. Then the two obje ts do not interfere i T1 \ T2 represents the null obje t. More generally, a subtree T 0 of the CSG tree T is redundant if repla ing T 0 with the null obje t , or with the omplement of the null obje t, does not alter the shape de ned by T. In the rst ase, we say that T 0 is -redundant. In the other ase, we say that T 0 is -redundant. Example 2.2: In Figure 2.25, the primitive A is -redundant in the CSG expression A [ B , be ause A [ B = [ B . In Figure 2.26, the primitive C is -redundant in the CSG expression C \ D, be ause C \ D = \ D.
3
Redundan ies arise in ontexts other than interferen e dete tion. It is possible that a CSG tree T ontains redundan ies be ause it was onstru ted by modi ation of another CSG tree T1. Possibly, the obje t de ned by T1
ontains ertain parts that are unne essary for the obje t de ned by T. In su h a situation, the designer may simply obliterate the entire unwanted substru ture, say by utting it away using a dieren ing operation. If the eliminated stru ture was de ned by a ompli ated subtree in T1, then that subtree would be redundant. A general approa h to redundan y dete tion is to approximate CSG obje ts by en losing them in simple geometri shapes, and to derive riteria for redundan y based on the approximations. When the approximating shapes are suÆ iently simple and are easily onstru ted, this approa h leads to eÆ ient redundan y tests. Based on approximations, however, it an only yield suÆ ient riteria for redundan y. Hen e, ertain redundan ies would remain
Basi Con epts
34
undete ted. As approximating shapes, we ould use spheres or boxes that are oriented in a parti ular way. The advantage of spheres is that they are invariant under rotation. This would not be true for boxes, whose edges are parallel to the oordinate axes, but there are elegant data stru tures for using su h boxes, as explained in Chapter 3. We des ribe an approximation algorithm for CSG obje ts whose stru ture is independent of the parti ular hoi e of approximating shape. However, we shall assume that the CSG obje t is
ompletely ontained within the approximating shape. We x a lass of approximating shapes. The algorithm begins by approximating all primitives P in the tree with a shape (P ) 2 . By pro essing the trees from the leaves to the root, we then determine the approximations at all interior nodes by the following three rules. 1. If T = T1 [ T2 , then (T ) = ((T1 ) [ (T2)). 2. If T = T1 \ T2 , then (T ) = ((T1 ) \ (T2)). 3. If T = T1
T2 , then (T ) = (T1 ).
We eliminate translations and rotations from onsideration by distributing them over the leaves. That is, we require that all primitives are positioned with respe t to the oordinate system of the nal solid. Thus, we need only a method for omputing (P ), where P is a primitive, suitably rotated and translated, and an algorithm for approximating the union, interse tion, and dieren e of two approximations. It is now straightforward to show that every point of the obje t de ned by the CSG tree T must be ontained in the approximating shape. Example 2.3: We let be the lass of all re tangles whose sides are parallel to the axes. Then the approximation of (A [ B ) (C [ D) is as shown in Figure 2.27. The intermediate approximations are also shown. 3 The approximation algorithm yields a riterion for when a primitive or a subtree in T is redundant. We noted that the approximation at the root
ontains the entire obje t. Hen e, if T 0 is any subtree of T, then only points in (T 0) \ (T ) an ontribute to the obje t de ned by T. In parti ular, if (T 0 ) \ (T ) = ;, then the subtree T 0 does not ontribute to the nal shape and an be deleted from T. For example, the primitive D shown in Figure 2.27 is redundant by this riterion, and an be deleted. 2.2.8 Nonstandard Primitives
We an extend the primitives by adding other shapes to our repertoire. For instan e, we might add all quadri halfspa es | that is, ellipsoids, paraboloids, hyperboloids, and ylinders and ones with oni base urves. We ould require that in nite halfspa es, su h as the hyperboloids, be restri ted to nite domains, as we did with ir ular ylinders and ones, or
35
2.2 CSG Representation
B
C
Y
D A
X Figure 2.27
Approximation of (A
(A [ B ) = ((A [ B )
(C
[ D)).
[ B )
(C
[ D):
Y
=
(C
[ D) and
X
=
we ould work with in nite halfspa es. Less modest extensions might in lude various lasses of s ulptured surfa es, or even all irredu ible algebrai surfa es. We an assess the diÆ ulties this enterprise raises by reviewing the basi CSG algorithms we have presented. Re all that the basi lassi ation algorithms follow the divide-and- onquer paradigm. The attra tiveness of su h a strategy depends on the ease with whi h we an do the various lassi ations with respe t to primitives, and the algorithmi omplexity entailed by analyzing neighborhoods, sorting points on surfa e interse tions, determining adja en ies, and so on. With greater geometri omplexities at the primitive level, the diÆ ulty of these operations qui kly in reases, and even the lassi ation against primitives an no longer be taken for granted. In su h a situation, a ase-by- ase analysis may be ome too omplex, and more general algorithms will be needed. Su h algorithms are the subje t of Chapters 5, 6, and 7. They ontinue to be resear h topi s. In geometri and solid modeling, these algorithms are exer ised many times. Ea h one of them must be suÆ iently fast, yield results of adequate a
ura y, and exhibit unfailing robustness. How best to negotiate these sometimes on i ting demands is not lear at this time, and probably depends not only on the geometri overage, but also on the individual appli ations for whi h the modeler is needed.
36
Basi Con epts
2.3 Boundary Representations
We an represent a solid unambiguously by des ribing its surfa e and topologi ally orienting it su h that we an tell, at ea h surfa e point, on whi h side the solid interior lies. This des ription has two parts, a topologi al des ription of the onne tivity and orientation of verti es, edges, and fa es, and a geometri des ription for embedding these surfa e elements in spa e. Histori ally, the representation evolved from a des ription of polyhedra. Brie y, the topologi al des ription spe i es verti es, edges, and fa es abstra tly, and indi ates their in iden es and adja en ies. The geometri representation spe i es, for example, the equations of the surfa es of whi h the fa es are a subset. The equations have been written su h that, at a point p in the interior of a fa e f , the surfa e normal points to the exterior of the solid. More details are given later in Se tion 2.3.2, in this hapter, and in Se tion 3.2, in Chapter 3. 2.3.1 Manifold Versus Nonmanifold Representation
A large segment of the literature requires that the surfa e represented by a boundary representation be a losed, oriented manifold embedded in 3spa e. Intuitively, a manifold surfa e has the property that, around every one of its points, there exists a neighborhood that is homeomorphi to the plane. That is, we an deform the surfa e lo ally into a plane without tearing it or identifying separate points with ea h other. Thus, surfa es that interse t or tou h themselves are ex luded. A manifold surfa e is orientable if we an distinguish two dierent sides. The pro edure for de iding orientability an be thought of as follows. Pi k any point p, and de ne arbitrarily a lo kwise orientation around it. Maintaining this orientation, move along any losed path on the surfa e. If there exists a path su h that it is possible to return to p with an opposite orientation, then the surfa e is not orientable; otherwise, it is orientable. Examples of nonorientable surfa es in lude the Mobius strip and the Klein bottle. Orientable surfa es in lude the sphere and the torus. Closed, orientable manifolds partition the spa e into three regions that we may all the interior, the surfa e, and the exterior, respe tively. In Se tion 2.4.2 we explain these
on epts in greater detail. The topologi al properties of manifolds are well understood. Thus, restri ting attention to manifold solids has the advantage that one an draw on a ri h mathemati al theory for su h obje ts. However, systemati work to relate this topologi al theory to spe i representation s hemata is relatively re ent. It is only re ently that the requirement for manifold surfa e obje ts in B-rep is being revised, partly be ause a regularized Boolean operation on two manifold obje ts may yield a nonmanifold result. An example is shown in Figure 2.28, where we have taken the regularized union of two L-bra kets. The problem is the edge (P; Q) that is adja ent to four fa es. Three ap-
37
2.3 Boundary Representations
Q
Q1
P
Q1 Q2
P1
P1
P2
P2
Figure 2.28
A Non-
Figure 2.29
Two Possible Topologies
manifold Obje t
proa hes to treating nonmanifold stru tures have been developed: 1. Obje ts must be manifolds, so operations on solids with nonmanifold results are not allowed and are onsidered an error. 2. Obje ts are topologi al manifolds, but their embedding in 3-spa e permits geometri oin iden e of topologi ally separate stru tures. 3. Nonmanifold obje ts are permitted, both as input and as output. Not mu h needs to be said about the rst approa h. It is straightforward and appears to be satisfa tory in many appli ations. Note, however, that it unduly restri ts modelers arrying out Boolean operations. Moreover, depending on the internals of the modeling system, operations that produ e a nonmanifold obje t as an intermediate result might be disallowed even when the nal result would be a manifold obje t. Su h restri tions might not be onvenient for the user. In the se ond approa h, we must give a topologi al interpretation of the nonmanifold stru tures. In the example of Figure 2.28, we must interpret the nonmanifold edge as two separate edges that happen to oin ide. Two possibilities exist, and Figure 2.29 shows them side by side. Whi h interpretation should be hosen is dis ussed in Se tion 2.4. In this example, the left interpretation is more natural. Brie y, we hoose an interpretation in whi h the surfa e is triangulable without degenerate triangles. Note that su h a triangulation is possible for the left, but not for the right, interpretation shown in Figure 2.29: In the right interpretation, the triangulation of the front fa e must in lude an edge (P1 ; P2 ), sin e those two points are topologi ally distin t. They are, however, geometri ally oin ident; hen e, this edge has zero length | that is, the adja ent triangles are degenerate. From a robustness point of view, the se ond approa h is likely to lead to diÆ ult geometri problems, and analyzing them in the presen e of geometri ally oin ident but topologi ally separate surfa e elements ould be intri ate. These diÆ ulties would be further exa erbated in the urved-surfa e domain, in whi h the numeri al problems are more severe. Moreover, no eÆ ient general algorithm for triangulating urved fa es is known.
Basi Con epts
38
In the third approa h, nonmanifold edges and verti es are a
epted. It is our experien e that this approa h ultimately leads to the simplest algorithms be ause it requires neither testing for the presen e of the disallowed on gurations, nor spe ial pro essing that derives topologi al disambiguations. The algorithm for Boolean operations on polyhedra des ribed in the next hapter is based on this approa h. 2.3.2 Winged-Edge Representation
The oldest formalized s hema for representing the boundary of a polyhedron and its topology appears to be the winged-edge representation. It des ribes manifold polyhedral obje ts by three tables, re ording information about verti es, fa es, and edges. We will des ribe a nonmanifold representation s heme in Chapter 3. The topologi al information is as follows. Ea h fa e is bounded by a set of disjoint edge y les, one of whi h is the outside boundary of the fa e, the others bounding holes. In the fa e table, therefore, a representative edge of ea h y le is re orded. Ea h vertex is adja ent to a ir ularly ordered set of edges, so the vertex table spe i es one of these edges for ea h vertex. Finally, for ea h edge, the following information is given: 1. In ident verti es 2. Left and right adja ent fa e 3. Pre eding and su
eeding edge in lo kwise order (explained later) 4. Pre eding and su
eeding edge in ounter lo kwise order The edge is oriented by giving the two in ident verti es in order, the rst being the from vertex, the se ond the to vertex. Left and right, as well as
lo kwise and ounter lo kwise, are interpreted with respe t to viewing the oriented edge from the solid exterior. The information is shown s hemati ally in Figure 2.30. Various restri tions may be pla ed on fa es. For example, we may require that ea h fa e be bounded by a single y le of edges, or even that ea h fa e be triangular. Su h restri tions might be imposed to in rease the uniformity of data stru tures, or to simplify pro essing for ertain operations on B-rep obje ts. The geometri information onsists typi ally of oordinates of the verti es and plane equations for the fa es. Ea h fa e equation has been written su h that its normal, at an interior fa e point, is dire ted toward the outside of the solid. Thus, if two fa es lie on the same plane P = 0, but in opposite orientation, then both P = 0 and P = 0 must be spe i ed. The geometri information may also in lude parametri equations for spe ifying the edges in 3-spa e. In the ase of urved solids, other information may be required to avoid ambiguities, as dis ussed in Chapter 5.
39
2.3 Boundary Representations
ccw−pred
ccw − succ left face u
v right face ccw − succ
ccw − pred Figure 2.30
Winged-Edge Data Stru ture
Figure 2.31 shows a tetrahedron, where verti es, edges, and fa es are labeled as shown. The topologi al data in its winged-edge representation is summarized in Table 2.2.
2.3.3 The Euler{Poin are Formula As we have seen, the topologi al data of a B-rep solid is symboli information. Unless are is exer ised, this pres ribed topology might be in onsistent in the sense that there annot exist a manifold solid whose verti es, edges, and fa es satisfy the pres ribed in iden e relationships. This problem be omes espe ially a ute when the topologi al data are derived from geometri information that is only approximate, due to oating-point errors. Hen e, there is interest in maintaining onsistent topologi al data, and a number of formulae have been found that must be obeyed by the number of verti es,
Edge
Counter lo kwise Name from to left right pred su
pred su
a 1 2 A D d e f b b 2 3 B D e
a f f 3 1 C D
d b a
3 4 B C b e f d d 1 4 C A f
a e e 2 4 A B a d b
Table 2.2
Verti es
Fa es
Clo kwise
Edge Table of the Tetrahedron, Winged-Edge Methodology
Basi Con epts
40
4
C
e c
d A
B
1 3 b
a
D 2 Figure 2.31
Tetrahedron
edges, and fa es. Note that these formulae provide ne essary onditions, but not suÆ ient ones. In Se tion 2.4, we will derive ne essary and suÆ ient
onditions. From a topologi al viewpoint, the simplest solids are those that have a
losed orientable surfa e and no holes or interior voids. We assume that ea h fa e is bounded by a single loop of adja ent verti es; that is, the fa e is homeomorphi to a losed disk. Then the number of verti es V, edges E, and fa es F of the solid satisfy the Euler formula: V E+F 2=0
This fa t is easily proved by indu tion on the surfa e stru ture. Extensions to this formula have been made that a
ount for fa es not being homeomorphi
2.3 Boundary Representations
41
to losed disks, the solid surfa e not being without holes, and the solid having interior voids, as reviewed next. We onsider the possibility that the solid has holes, but that it remains bounded by a single, onne ted surfa e. Moreover, ea h fa e is assumed to be homeomorphi to disk. For example, the torus has one hole, and the obje t in Figure 2.32 has two. It is a well-known fa t that su h solids are topologi ally equivalent, i.e., homeomorphi , to a sphere with zero or more handles. For example, the obje t of Figure 2.32 is homeomorphi to a sphere with two handles, the latter shown in Figure 2.33. The number of handles is
alled the genus of the surfa e. In general, with a genus G, the numbers of verti es, edges, and fa es obey the Euler{Poin are formula:
V E +F
2(1
G) = 0
Next, we further generalize by adding the possibility of internal voids. These voids are bounded by separate losed manifold surfa es, alled shells. The number of shells will be denoted by S. Finally, we relax the requirement that a fa e is bounded by a single loop of verti es, but require that ea h fa e
an be mapped to the plane. Thus, a sphere missing at least one point an be a fa e. In Figure 2.34, a fa e is shown with four bounding loops. Note that one of these loops onsists of a single vertex, and another one of two verti es onne ted by an edge. To a
ount for fa es of this omplexity, we must ount, for ea h fa e, the number of bounding vertex loops. For the fa e in Figure 2.34, this number is four. With L the total number of loops, the relationship among the number of fa es, edges, verti es, loops, and shells, and the sum G of ea h shell's genus, is then
V E+F
(L
F)
2(S
G) = 0
An example solid illustrating this relationship is shown in Figure 2.35. We may think of the quantities V, E, F, L, S, and G as existing in an abstra t six-dimensional spa e. The relationship among them is then the equation of a hyperplane. Sin e the values of the variables must be nonnegative integers, we might view the relation as de ning a latti e on this hyperplane. For ea h solid with a given topologi al stru ture, there orresponds a point in this latti e. Although a manifold solid must satisfy the extended Euler{Poin are formula, not every surfa e satisfying the formula will be the surfa e of a manifold solid. For example, the ube is a manifold obje t with 6 fa es, 12 edges, and 8 verti es. It has a single shell surfa e of genus zero. However, the surfa e shown in Figure 2.36 has the same number of fa es, edges, and verti es, yet it is not the surfa e of any manifold solid, sin e it has a \dangling" quadrilateral fa e atta hed to the prismati part by a nonmanifold edge.
Basi Con epts
42
Figure 2.32
An Obje t with Two Holes and with Fa es Homeomorphi to Disks
2.3.4 Euler Operators
Con eptually,
Euler operators
an be thought of as reating and modifying
onsistently the topology of manifold obje t surfa es. In parti ular, they an
reate losed surfa es, and modify these surfa es by adding or deleting fa es, edges, and verti es. They also modify the surfa e genus by adding or deleting
43
2.3 Boundary Representations
Figure 2.33
handles.
mxky,
A Surfa e of Genus 2
Euler operations are traditionally named by a string of the form
where
m
stands for
make,
and
k
stands for
kill.
The strings
x
and
y
name the topologi al element types that are reated or destroyed. The types are vertex, edge, loop, fa e, and shell.
Ordinarily, only one new element of
ea h type is reated or destroyed, but sometimes several elements of the same type are reated or destroyed. For example, a fa e and a loop, whereas
me
mek
adds an edge and deletes
adds an edge, a fa e, and a loop.
Euler operators are used as an intermediate language in some modeling systems. Using them has the advantage of insulating, to a degree, the operations implemented on top of them from details of the data stru tures used to represent the surfa e topology. Thus, in prin iple, the underlying representation ould be hanged with minimal impa t on the modeling system's implementation. Another advantage is that Euler operators ensure topologi-
Figure 2.34
A Fa e with Four Bounding Loops
44
Figure 2.35
Basi Con epts
Solid with 24 Verti es, 36 Edges, 16 Fa es, 18 Loops, 2 Shells, and Genus
Sum 1
al onsisten y throughout the modeling pro ess. This an be advantageous when the pre ise topology of the result of a modeling operation may be in doubt be ause of impre ision of the numeri al model data, as dis ussed in Chapter 4. As example of spe i Euler operators, onsider the operation of adding an edge between two existing verti es. Depending on the two verti es designated, this operation has diering topologi al ee ts. In onsequen e, different Euler operations would be used to implement the operation. The
.
2.3 Boundary Representations
45
. .
.
. . . . Figure 2.36
Surfa e with 8 Verti es, 12 Edges, and 6 Fa es
possibilities are as follows. 1. The new edge loses o one part of a fa e from the rest. In this ase, the operation is alled me . Its ee t is to in rease the number of edges, fa es, and loops by one ea h. An example is shown in Figure 2.37. 2. The new edge onne ts two dierent loops bounding the same fa e. In this ase, the operation is alled mekl. Here we have added one edge and deleted one loop; see also Figure 2.38. 3. The new edge onne ts two verti es on two dierent shells. In this ase, the operation is alled meks. It merges the two shells, whi h in ludes deleting a fa e on ea h shell and reating a new fa e that makes a
onne tion between the two surfa es. Figure 2.39 shows an example of the meks operation. The interior shell is onne ted with the exterior shell, opening the interior void to the outside by a oni al fa e. Note that for polyhedra, more than one edge would have to be reated. Note that these operations need additional spe i ations to ensure an unambiguous pla ement of the new onstru ts. For example, in the meks operation, it is not lear whi h fa es should be deleted on ea h shell. Suitable
46
Basi Con epts
Figure 2.37
me
Operation
onventions for ommuni ating this geometri information to the operation are readily worked out, say via ertain parameters. The implementation of Euler operations in reases in diÆ ulty with the geometri overage of the modeling system. We mentioned that there are no eÆ ient general algorithms that triangulate urved fa es. Clearly, triangulation of urved fa es an be based on the me operation. Hen e, this operation will be diÆ ult to implement unless the geometri overage is suitably restri ted.
2.4 Topologi al Validity of B-rep Solids
A basi assumption underlying solid modeling is that we deal with topologi ally valid solid obje ts. The meaning of topologi al validity needs to be made pre ise, for otherwise we annot be assured that the omputer representations of solids and the algorithms using them are orre t. This task is espe ially important in B-rep, where we must infer, from a des ription of the two-dimensional boundary, that a solid is de ned. In this se tion, we give a de nition of topologi al validity. Based on this de nition, it is possible to derive an algorithm that tests whether a given data stru ture, intended as a boundary representation of a solid, does in fa t des ribe a solid. Su h an
Figure 2.38
mekl
Operation
2.4 Topologi al Validity of B-rep Solids
Figure 2.39
meks
47
Operation
algorithm is also sket hed, but no deep onsideration has been given to its implementation. Rather, it serves to elu idate the various aspe ts of topologi al validity. Initially, we onsider manifold solids. Thereafter, we dis uss how to hara terize nonmanifold solids topologi ally. The material is fairly detailed, as is ne essary: The tools provided by topology are very general, and their naive use an lead to subtle errors. Hen e, it is important to develop the material
arefully and expli itly. Che king topologi al validity has a geometri dimension. For instan e, ea h fa e in a B-rep must onsist of manifold points. In the ase of planar fa es, this ondition is trivial; for urved fa es, however, it is by no means a straightforward omputation. Moreover, the geometri dimension naturally suggests broadening the topologi al-validity problem to a proper mathemati al de nition of the term solid that en ompasses the other aspe ts as well. Although we do not develop su h a omprehensive de nition, we dis uss some of the issues that are needed for for su h a task. These issues arise from the intera tion of geometri and topologi al fa tors. 2.4.1 Topologi al Polyhedra
Our obje tive is to hara terize a solid as a topologi al polyhedron. We initially think of a solid as a 3-manifold with boundary, and then impose a triangulation to grasp better the stru ture of these manifolds. The resulting de nition of a topologi al solid is preliminary be ause we hara terize the solid as an obje t without a
ounting for the surrounding spa e. By
hara terizing subsequently the relationship between the solid and Eu lidian 3-spa e, we re ne this de nition to a de nition of manifold solids in the sense
Basi Con epts
48
dis ussed in Se tion 2.3.1. Topologi al Spa es
A topologi al spa e (X; T ) is a set X along with a system of subsets T, alled the open sets of X. The system T must satisfy the following two properties: 1. The interse tion of nitely many sets in T is again in T. 2. The union of sets in T is also in T. Note that in nite unions of open sets are permitted. Therefore, T must be
losed under nite interse tion and arbitrary union. A subset of X is losed if its omplement is open. In the following dis ussion, we spe ialize the set X and assume that it is the n-dimensional Eu lidian spa e En or a subset thereof. En onsists of all points (x1 ; :::; xn ), where the oordinates xk are real numbers. In En , we
onsider the natural topology, using as our system of open sets all those sets that an be obtained as the union of open balls. The open ball B (p; r), of radius r > 0 entered at the point p = (x1 ; :::; xn ), is de ned as (
B p; r
) = fq = (y1 ; :::; yn) j d(p; q
vuuX )=t ( n
k=1
xk
yk
)2 < rg
That is, B (p; r) onsists of all points whose Eu lidian distan e from p is less than r. A neighborhood of a point p is any open set U that ontains p. Note that this de nition of neighborhood has a dierent meaning from that introdu ed in Se tion 2.2.4. It an be shown that a subset of En is open pre isely when X ontains a neighborhood of every point p in X. The interior of a set U, denoted int (U ), onsists of all points p 2 U su h that U ontains a neighborhood of p. The losure of a set U, denoted l (U ), is the omplement of the interior of the omplement of U. Let :U denote the set-theoreti omplement of U. Then
l ( ) = :int (: ) U
U
A map f from a topologi al spa e (X; T ) to another topologi al spa e (X 0 ; T 0 ) is ontinuous if every neighborhood of f (p) in (X 0 ; T 0 ) is mapped by f 1 to a neighborhood of p in (X; T ). If f is bije tive (i.e., is one to one and onto), and if both f and its inverse f 1 are ontinuous, then f is a homeomorphism. Two topologi al spa es are topologi ally equivalent if there is a homeomorphism between them.
2.4 Topologi al Validity of B-rep Solids
49
In En , we identify topologi al subspa es. A subspa e is a subset Y of En along with the relative topology onsisting of the interse tion of the open sets of En with Y. Examples in lude open balls of any radius, but also losed sets su h as the unit ube onsisting of all points p = (x1 ; :::; xn ) su h that, for k = 1; :::; n, we have 0 xk 1. Note that an open set in the relative topology need not be open in the ontaining topologi al spa e. For example, the (relatively) open set U in the unit ube in E3 , obtained as the interse tion with the open ball of radius 1 entered at (1; 1; 1); is not an open set in E3 sin e no neighborhood of (1; 1; 1), in E3 , is ontained in U. An n-manifold M in Em , where m n, is a subspa e that is lo ally homeomorphi to En. That is, for every point p of M, there exists a neighborhood U of p that is homeomorphi to En . An n-manifold with boundary is a subspa e whose boundary point neighborhoods are lo ally homeomorphi to the positive halfspa e
En+ = f(x1 ; :::; xn ) 2 En j x1 0g and whose interior point neighborhoods are lo ally homeomorphi to En . The hyperplane x1 = 0 is the boundary of En+ . Note that, in an n-manifold M with boundary, we an distinguish between interior and boundary points: A point p 2 M is an interior point if there is a neighborhood U of p that is homeomorphi to En . A point p 2 M is a boundary point if it has a neighborhood U that is homeomorphi to a neighborhood of the point (0; :::; 0) in En+ . In ontrast, an n-manifold
onsists of only interior points. The boundary of an n-manifold with boundary an be shown to be homeomorphi to an (n 1)-manifold without boundary. Intuitively, a manifold is onne ted if it annot be de omposed into two disjoint manifolds. A set in En is bounded if it is ontained in an open ball. When a set is both losed and bounded, it is ompa t. We wish to de ne a solid as a onne ted 3-manifold with boundary where, in addition, the boundary is ompa t. This de nition is too restri tive in that it ex ludes nonmanifold solids. At the same time, it is also too general, be ause it pla es no requirements on the spa e surrounding the solid.
Simpli ial Complexes We explain how to onstru t 3-manifolds ombinatorially. The basi building blo ks are simpli es of various dimensions that are put together in parti ular ways to obtain manifolds. We explain how this is done. Let p0 and p1 be two distin t points. The onvex ombination spanned by p0 and p1 is the set
hp0; p1 i = fp0 + (1
)p1 j 0 1g
Basi Con epts
50
Geometri ally, hp0 ; p1 i is the losed line segment [p0 ; p1 ℄ in Eu lidian spa e. Similarly, we de ne the onvex ombination spanned by three distin t points as
hp0; p1; p2i
= =
f(p0 + (1 )p1) + (1 )p2 j 0 ; 1g fq + (1 )p2 j q 2 hp0; p1i; 0 1g
If the pi are not ollinear, then hp0 ; p1 ; p2 i is a triangle with verti es p0 , p1 , and p2 . The notion of onvex ombination generalizes to arbitrary dimension: The onvex ombination of the points p0 ; :::; pd+1 is
hp0; :::; pd+1 i = fq + (1
)pd+1 j q 2 hp0 ; :::; pd i; 0 1g
We say that d + 1 points in d-dimensional real spa e Rd are linearly independent if none of the points is ontained in the onvex ombination of the others. It is not diÆ ult to show that we an de ne hp0 ; :::; pd i equivalently as
hp0; :::; pd i = f
d X
k=0
k pk j k 0 and
d X
k=0
k = 1g
P
Here, the numbers k are the bary entri oordinates of the point dk=0 k pk . If the pk are linearly independent, then it an be shown that the bary entri
oordinates of every point in hp0 ; :::; pd i are unique. A d-simplex is the onvex ombination of d +1 linearly independent points. Moreover, d is the dimension of the d-simplex. Clearly, a 0-simplex is a point, a 1-simplex is a line segment, a 2-simplex is a triangle, and a 3-simplex is a tetrahedron. The boundary of a d-simplex S onsists of all (d k)-simpli es ontained in S, where k > 0, and is denoted S: Every simplex in the boundary of S is a fa e of S. A k-simplex that is a fa e is also alled a k-fa e. The following theorem is elementary.
0 1 d + 1 A k-simpli es as fa es. A d-simplex ontains exa tly Theorem
k+1
Moreover, two d-simpli es are homeomorphi . A simpli ial omplex C is a nite set of simpli es satisfying the following restri tions: 1. Let S be a simplex in C, and let S be one of its fa es. Then S is also in C. 0
0
2. Let S1 and S2 be two simpli es of C. Then their interse tion is either empty or is a simplex of C.
2.4 Topologi al Validity of B-rep Solids
Figure 2.40
51
A Simpli ial Complex C
Figure 2.40 shows a simpli ial omplex; Figure 2.41 shows a set of simpli es that do not form a simpli ial omplex. The dimension of the simpli ial omplex C is de ned as the maximum dimension of the simpli es in C. The dimension of the simpli ial omplex in Figure 2.40 is 2. It an be proved that the dimension of a simpli ial omplex is invariant under ontinuous maps. If S is a d-simplex and d > 0, then the boundary S of S is a simpli ial omplex of dimension d 1. A subset of En is triangulable if it is homeomorphi to a simpli ial omplex. A triangulable set is also alled a topologi al polyhedron. Note that the term is not used in a geometri sense, be ause a homeomorphism may map a linear surfa e to a urved surfa e. Hen e, the losed unit ball in E3 is a topologi al polyhedron sin e it is homeomorphi to a 3-simplex. Figure 2.42 shows several topologi al polyhedra of dimension 2. Moreover, given a topologi al polyhedron M, the homeomorphism from a simpli ial omplex onto M is a triangulation of M.
Figure 2.41
Simpli es Not Forming a Simpli ial Complex
Basi Con epts
52
Topologi al Polyhedra of Dimension 2
Figure 2.42
Abstra t Simpli ial Complexes and Geometri Realization Sin e we de ned simpli es as onvex ombinations of points, it is on eivable that this de nition is too narrow. That is, when onstru ting a simpli ial
omplex, an we obtain more ompli ated stru tures using simpli es that are only homeomorphi to onvex ombinations? From a topologi al point of view, the answer is no, and is justi ed as follows. We de ne an abstra t simplex S as a nite set of points, alled the verti es of S. Every proper subset of S is a fa e of S. If S onsists of d + 1 points, then we say that it has the dimension d. An abstra t simpli ial omplex C is de ned as follows: 1. There is a nite set of verti es V. 2.
is a set of subsets in C. C
S
of V with the property that all subsets of S are
Intuitively, the subsets S are the simpli es in C. It an be proved that every abstra t simpli ial omplex C has a geometri realization jC j in Eu lidian spa e as a omplex of simpli es that are onvex
ombinations. That is, given an abstra t omplex C with verti es fv1 ; :::; vm g, we an nd m points in Eu lidian n-dimensional spa e E su h that, for every abstra t simplex S = hp0 ; :::; pd i in C, the points in E orresponding to the pk are linearly independent and hen e de ne a simplex jS j in E that is a
onvex ombination of those points.
Theorem If C is an abstra t simpli ial omplex of dimension n, then C an be realized by a orresponding on rete simpli ial omplex jC j in E2n+1 , where the verti es are points and the simpli es are onvex
ombinations of them. In other words, the abstra t omplex C has a \ni e" pie ewise linear realization in a Eu lidian spa e of suÆ iently high dimension. Thus, we do not lose generality by using the on rete de nition of simpli es as onvex
ombinations.
53
2.4 Topologi al Validity of B-rep Solids
Figure 2.43
Opposite Fa es in a 3-Simplex
Manifold Triangulations We return to the problem of hara terizing manifolds as topologi al polyhedra, and des ribe the lo al stru ture of a simpli ial omplex triangulating the manifold. Be ause of the above, we may assume that the simpli ial omplexes are pie ewise linear in a suitable Eu lidian spa e. Let S be a d-simplex with verti es p0 ; :::; pd . A proper subset q0 ; :::; qr of the verti es of S de nes an r-simplex that is a fa e S1 of S. Let qr+1 ; :::; qd be the remaining verti es of S. Then these verti es de ne another fa e S2 . We say that S1 and S2 are opposite fa es of S. Figure 2.43 shows examples in the ase of d = 3. Let S and S be two simpli es in a simpli ial omplex. Then S and S are adja ent if they have a ommon fa e. If S is a fa e in whi h S and S are adja ent, then S and S are in ident to S . Finally, a simpli ial omplex C is onne ted, if for all pairs of simpli es S and S in C, we an nd a sequen e of simpli es S1 ; :::; Sr in C su h that, for 1 k < r, we have S = S1 and S = Sr ; and Sk is in ident to Sk+1 , or vi e versa. Let S be a simplex in some simpli ial omplex. S will be in ident to a nite set of simpli es S1 ; :::; Sr in C. For ea h simplex Si of whi h S is a fa e, let Ti be the fa e of Si opposite S. The set of all su h opposite fa es is the link of S in C; see Figure 2.44 for an example. We are now in a position to
hara terize 2- and 3-manifolds in terms of simpli ial omplexes. Although stated as de nitions, these hara terizations an be proved formally. A 2-manifold without boundary is homeomorphi to a simpli ial omplex C of dimension 2 satisfying the following restri tions: 0
0
00
0
0
00
0
0
1. Every 1-simplex in C is in ident to exa tly two 2-simpli es. 2. The link of every 0-simplex in C is a triangulation of the ir le. See also Figure 2.45 for an illustration of the vertex stru ture in a 2-manifold without boundary. Similarly, a 3-manifold without boundary is homeomorphi to a simpli ial
omplex C of dimension 3 satisfying the following restri tions:
Basi Con epts
54
T1 S2
T7
T6 T5
S
T2
S S6
S3
T8
T4
S4
T3
T6
T5 T4 Figure 2.44
T1 Link of
S
Figure
2.45
T2
T3
Vertex Stru ture in
Triangulated 2-Manifold
1. Every 2-simplex in C is in ident to exa tly two 3-simpli es. 2. The link of every 0-simplex in C is a triangulation of the sphere. To so hara terize 3-manifolds with boundary, we need to distinguish between simpli es that are on the boundary of the manifold and ones that are interior. We dis uss only 3-manifolds with boundary. Let S be a 2-simplex in the omplex C. Then S is an interior fa e if it is in ident to exa tly two 3-simpli es of C, and is a boundary fa e if it is in ident to exa tly one 3-simplex. Similarly, a 0-simplex is interior if its link is a triangulation of the sphere, and is a boundary point if its link is a triangulation of the disk. Note that we do not give an analogous hara terization of 1-simpli es; su h a hara terization is not needed. Formally, then, a 3-manifold with boundary is homeomorphi to a simpli ial omplex C of dimension 3 satisfying the following restri tions: 1. Every 2-simplex is adja ent to one or two 3-simpli es. 2. The link of every 0-simplex is a triangulation of the disk or the sphere. This ompletes the explanation of the polyhedral stru ture of 2- and 3manifolds. 2.4.2 Manifold Solids
We wish to de ne a topologi al solid as a 3-manifold with boundary, where, in addition, the boundary should be ompa t. The intuition is that we should have a nite surfa e, but that in nite volumes are permitted. As pointed out before, this de nition will not onstrain the relationship between the topologi al solid and the surrounding 3-spa e. Moreover, sin e in B-rep a solid is impli itly des ribed by a spe i ation of its surfa e, we must also
55
2.4 Topologi al Validity of B-rep Solids
P2
P1
Figure 2.46
A Wildly Embedded Simple Ar
larify the relationship between a topologi al solid and its surfa e. We do this now.
Embeddings in E3 We onsider the relationship between a 3-manifold with boundary and the surrounding spa e. This relationship needs to be examined be ause there are \unreasonable" 3-manifolds in E3 that are homeomorphi to well-behaved topologi al polyhedra. For example, a manifold an be unreasonable be ause it has a fra tal-like surfa e. The diÆ ulty is rooted in the fa t that the hara terization of manifolds as topologi al polyhedra requires only that there be a homeomorphism from a simpli ial omplex of suitable stru ture onto the manifold, without onsideration of whether this homeomorphism
an be extended to the surrounding Eu lidian spa e. An embedding of the topologi al spa e (X; T ) into a topologi al spa e (Y; T ) is a homeomorphism between (X; T ) and a subspa e Y of Y. In parti ular, let X and Y be subspa es of En. Depending on whether and how the homeomorphism extends to a homeomorphism of the entire surrounding spa e we all embeddings tame or wild. Wild embeddings lead to unreasonable 3-manifolds in E3 . A simple example is depi ted in Figure 2.46, whi h shows a wildly embedded ar in E3 . By giving \thi kness" to the ar , we obtain a 3-manifold with ompa t boundary that an be shown to be homeomorphi to a sphere. Clearly, this would not be a reasonable solid. In view of this fa t, we require, in addition, that a topologi al solid be tamely embedded into E3 . Rather than giving a formal de nition, we will argue later on that the primitives used in CSG and in B-rep guarantee that we are working with tame embeddings. 0
0
0
Orientability So far, we have hara terized a topologi al solid in its entirety; that is, as a three-dimensional obje t. In B-rep, however, we have only a des ription of the boundary. We need to make a onne tion between the topologi al stru ture of the solid and the topologi al stru ture of its boundary. This
onne tion requires the on ept of orientability. Brie y, we an prove the following theorem.
Basi Con epts
56
P2
P2
P1
P1 P0
P0 Orientations (p0 ; p1 ; p2 ) and (p0 ; p2 ; p1 ) of a 2-Simplex
Figure 2.47
Theorem Let M be a onne ted 3-manifold with boundary embedded in E3 . Then the boundary of M is an embedded orientable 2-manifold without boundary.
Note that we do not need to assume a tame embedding. A onverse of this theorem an be formulated whi h allows us to on lude from boundary properties that a topologi al polyhedron is en losed. However, su h a theorem requires additional assumptions. These additional assumptions will involve geometri properties of the embedding and are explained later. Orientability is best visualized in terms of a triangulation of the manifold. It an be shown that the orientability of a manifold is independent of the parti ular triangulation. That is, if the manifold is orientable, then every one of its triangulations is orientable. Conversely, if the manifold has an orientable triangulation, then the manifold is orientable. So, we explain orientability of 2-manifolds by orienting simpli ial omplexes that are a triangulation of the manifold. We orient a 2-simplex by y li ally ordering its verti es. For example, the simplex hp0 ; p1 ; p2 i an be oriented (p0 ; p1 ; p2 ). Figure 2.47 shows the two possible orientations of the 2-simplex. Note that the orientation of a 2-simplex indu es an orientation of every one of its 1-fa es. More generally, any d-simplex an be oriented in exa tly one of two ways. Let S and S be two adja ent 2-simpli es in a omplex C, and assume that they are adja ent in a 1-fa e S . Then S and S are oherently oriented if the orientations of S indu ed by the orientations of S and S are opposite. Figure 2.48 shows two pairs of adja ent 2-simpli es. The left pair is oriented
oherently, whereas the right pair is not. Let C be a triangulation of a onne ted 2-manifold with or without boundary. Then C is orientable i all of its adja ent 2-simpli es an be oriented
oherently. It an be shown that, if C is orientable, then it an be oriented in 0
00
00
0
0
57
2.4 Topologi al Validity of B-rep Solids
Figure 2.48
Coherent and In oherent Orientations
exa tly two ways, and for this reason there is a simple algorithm for testing orientability. Roughly speaking, we pi k any 2-simplex and orient it arbitrarily. Thereafter, we orient an adja ent 2-simplex oherently, ontinuing iteratively until the manifold has been oherently oriented, or until we rea h a 2-simplex adja ent to two other simpli es that are already oriented in a way that pre ludes orienting oherently with both. We return to the problem of formulating the onverse of the pre eding theorem. We would like to obtain a hara terization that is roughly as follows.
S
S
Theorem Let be a ompa t, onne ted 2-manifold without boundary that is tamely embedded into E3 and is oriented. If satis es a property P , then is the boundary of a onne ted 3-manifold that is tamely embedded in E3 .
M
0
M
M
0
0
SuÆ ient properties P are readily formulated. One possibility is to require that E3 is triangulated in its entirety su h that this triangulation also triangulates . However, rather than making P a global property, we formulate a more lo al property of the embedding. Intuitively, wild embeddings (and some tame embeddings) are unsatisfa tory be ause the manifold is \rued." It appears that there is no purely topologi al hara terization of this intuitive notion, and we need to introdu e geometry to make the idea pre ise. Let be an embedded 3-manifold 3 with ompa t boundary in E . We say that is of bounded variation if 3 every line in E interse ts in nitely many segments and every plane in nitely many areas. Analogously, we say that a ompa t 2-manifold in E3 is of bounded variation if every line interse ts it in nitely many points and every plane in nitely many urves. Throughout this book, we assume that the boundaries of solids an be des ribed by nitely many subsets of algebrai surfa es. It is easy to show that algebrai surfa es are always of bounded variation;6 hen e, we do not
M
0
M
6 Cf.
M M
Bezout's theorem in Se tion 5.3.3 of Chapter 5.
Basi Con epts
58
have to make additional requirements on B-rep to a hieve embeddings of bounded variation. This simpli es verifying topologi al validity. Note also that embeddings of bounded variation are always tame.
Topologi al Validity of Manifold Solids Consider a 3-manifold M with boundary embedded in E3 . Its boundary is an embedded orientable 2-manifold M without boundary, but M need not be
onne ted. Thus, when given an embedded oriented 2-manifold M without boundary, we need to satisfy a ompatibility ondition so that its onne ted
omponents will olle tively de ne a solid. The ompatibility ondition depends on the given orientation of the omponents. Let M be an oriented, onne ted 2-manifold in E3 . We all a point p not on M interior to M if there is a triangulation C of M satisfying the following
onditions: 0
0
0
1. There is a 2-simplex S of C oriented as (p0 ; p1 ; p2 ) su h that the orresponding points on M are seen from p in a ounter lo kwise orientation. 2. There is a point q in the image of does not interse t M ex ept at q.
S
su h that the line segment (p; q )
Figure 2.49 illustrates the de nition. It is not diÆ ult to show that, with this de nition, the manifold partitions E3 into two open sets, one onsisting of all points that are interior, the other onsisting of points that are neither interior nor on M. The latter set is the set of exterior points. Note that the de nition of interior and exterior points agrees lo ally with the onvention of outward-pointing normals explained in Se tion 3.2 of Chapter 3. Let (p0 ; p1 ; p2 ) be an oriented 2-simplex. For an a ute angle, say at p0 , de ne a normal dire tion as the ross produ t of the ve tors (p0 ; p2 ) and (p0 ; p1 ). Then this normal dire tion points lo ally to the exterior. Given this de nition of interior and exterior points, we an de ne a manifold solid as follows:
De nition
A single-shell manifold solid A is a onne ted 3-manifold with boundary embedded in E3 . The boundary A of A is a ompa t,
onne ted 2-manifold without boundary, embedded in E3 with bounded variation, and is oriented su h that A onsists of the set of interior points of A along with A . 0
0
0
Now assume that we have two disjoint onne ted oriented 2-manifolds, M1 and M2 , in E3 . Ea h de nes a set of interior points. We say that M1 and M2 are oriented onsistently if M1 onsists of interior points of M2 whenever M2 onsists of interior points of M1 . Figure 2.50 illustrates the de nition for the two-dimensional ase. The bounding y les on the left are in onsistently oriented, those on the right are onsistently oriented. Consequently, the following is a de nition of a multishell manifold solid. 0
0
0
0
0
0
0
0
59
2.4 Topologi al Validity of B-rep Solids
p p2
p1
p0 q Interior Point p and Exterior Point q
Figure 2.49
De nition
A multishell manifold solid A is a 3-manifold with boundary in E3 . The boundary A of A is a ompa t, oriented 2-manifold without boundary, embedded in E3 with bounded variation. Let A1 ; :::; Ar be the onne ted omponents of A . Then, for ea h pair (i; k), where 1 i < k r, the omponents Ai and Ak are
onsistently oriented. 0
0
0
0
0
0
Topologi al validity of a manifold B-rep solid is veri ed as follows. We assume that we are given a boundary representation spe ifying nitely many verti es, edges, and fa es. Moreover, we assume that ea h fa e is a ompa t subset of an algebrai surfa e, and that edges and verti es are interse tions of fa es. These assumptions guarantee that the surfa e is of bounded variation and that it is ompa t. Let A1 ; :::; Ar be the onne ted surfa e omponents des ribed by the representation. Perform the following steps. 0
0
1. Verify that the
0
Ak
are pairwise disjoint and that they do not self-
Basi Con epts
60
Figure 2.50
In onsistently and Consistently Oriented Boundaries of Orientable 2-
Manifolds
interse t. 2. Triangulate ea h Ak and verify that it is a 2-manifold without boundary, using the triangulability onditions explained previously. 0
3. For ea h pair Ai and Ak of omponents, verify that their orientation is
onsistent. 0
0
A topologi ally valid B-rep must satisfy all these riteria. Step 1 tests that the geometri embedding into E3 makes sense. Selfinterse tions reate nonmanifold points on the boundary; hen e, they must not o
ur. This is primarily a geometri property of the embedding. Step 2 veri es that the boundary is a 2-manifold without boundary. The assumptions on fa es imply that the boundary is ompa t. It an be proved that a
losed 2-manifold embedded in E3 must be orientable. Hen e, orientability need not be tested expli itly. Note, however, that the triangulation of the surfa e is omputationally easy only for planar fa es. Step 3, nally, tests whether the individual shells are oriented su h that they olle tively de ne the solid's interior and exterior. All algebrai surfa es have bounded variation, and a B-rep des ribes nitely many ompa t subsets of algebrai surfa es. Therefore, the theorem above implies that a B-rep satisfying the onditions he ked for in the algorithm de nes a topologi ally valid solid. 2.4.3 Nonmanifold Solids
We sket h how to hara terize nonmanifold solids from a topologi al perspe tive. Brie y, we onsider a nonmanifold solid as an immersion of several manifold solids; that is, we allow the manifolds to interse t in E3 . However, we restri t interse tions to sets of dimension 1 or 0. This point of view was explained in Se tion 2.3.1 as the se ond approa h to de ning valid boundary representations. That is, ea h su h interse tion is onsidered a geometri
oin iden e of topologi ally dierent parts of the manifold boundary.
2.5 Spatial De omposition
Figure 2.51
61
Resolution of Nonmanifold Stru tures
To identify the various manifold solids, we triangulate the nonmanifold solid and onsider the interior points of the resulting simpli ial omplex. They de ompose into several onne ted, open sets, ea h of whi h an be understood as the interior of an immersed 3-manifold with boundary. Reversing this pro ess, we de ne a nonmanifold solid as homeomorphi to an oriented simpli ial omplex of dimension 3, su h that the interior points are an embedded 3-manifold of bounded variation. The losure of the set
reates a boundary that is ompa t and of bounded variation. In parti ular, this implies that the surfa e of a nonmanifold solid an be triangulated without degenerate 2-simpli es of zero area. We adapt the validity test for manifold solid boundary representations to test whether a given B-rep des ribes a valid nonmanifold solid. Brie y, we must \split" nonmanifold edges and verti es by lo ally onsidering the solid interior, as implied by the given surfa e orientation. In ee t, we onstru t a set of surfa e omponents, ea h a 2-manifold without boundary. Ea h of these omponents are then tested as des ribed previously. Intuitively, the splitting pro ess \shrinks" the volume of the solid in nitesimally. After shrinking, the nonmanifold edges and verti es disappear. See also Figure 2.51 for a two-dimensional example. Note, however, that this topologi al resolution of nonmanifold edges and verti es will be dierent in a solid A and its omplement solid, :A, be ause we shrink the interior of the solid. Hen e, shrinking the omplement solid :A is equivalent to expanding the solid A.
2.5 Spatial De omposition
Apart from CSG and B-rep, there exist a number of solid representation s hemata, based, loosely speaking, on spatial de omposition. We brie y mention these s hemata now. Most of them play a peripheral role in solid modeling be ause of ertain limitations. Nevertheless, many of them have important spe ial appli ations, in luding numeri al analysis and geographi databases. The simplest de omposition s hema is a uniform subdivision of spa e into
Basi Con epts
62
Figure 2.52
Cir le Represented by Uniform Subdivision of Spa e
a grid of ubes of spe i ed size, and marks all ubes that interse t the solid interior. The solid would thus be represented by all marked ubes. Figure 2.52 illustrates the idea in two dimensions. This representation is approximate, and the size of the ubes will de ne the degree of a
ura y. In prin iple, only the marked ubes need to be stored. Adja en y of two ubes ould be represented expli itly, or ould be inferred from a ube's lo ation in spa e. Representations of this type are used in numeri al analysis for domain dis retization. When a high degree of a
ura y is required, the number of ubes may be too great for this data stru ture to be onsidered onvenient. O trees ameliorate this problem by aggregating ertain marked ubes into larger ones. Con eptually, we partition spa e by several grids, ea h with mesh size twi e that of the previous one. Eight adja ent marked ubes are ombined into a larger marked ube, provided the larger ube lies in the next larger mesh. Figure 2.53 illustrates the idea in two dimensions. O trees are stored as trees that essentially re ord this adja en y information. The interior nodes represent ube aggregations where not all omponent ubes are marked, whereas
2.6 Notes and Referen es
Figure 2.53
63
O tree Subdivision of Spa e
the leaves represent ubes that are marked or that do not interse t the solid interior at all. So far, we have dis ussed spa e de ompositions in whi h the spa e elements are in a spe i impli it relationship with the oordinate system. This makes it unattra tive to rotate obje ts so represented. At the expense of more
omplex adja en y and shape pro essing, we an drop this relationship and allow irregular shape elements. In nite element analysis, triangular and tetrahedral spa e elements are used, as illustrated by Figure 2.54.
2.6 Notes and Referen es
Early work on onstru tive solid geometry in ludes the work on TIPS by Okino, Kakazu, and Kubo (1973), and the work on PADL by Voel ker et al. (1974) and Requi ha and Voel ker (1977). Most of the CSG material
Basi Con epts
64
Figure 2.54
Irregular Subdivision of Spa e
presented here follows the various publi ations by that group, whi h relied heavily on an algebrai formulation of the algorithms. See the bibliography under the author names Brown, Tilove, Requi ha, Rossigna , and Voel ker. The approximation algorithm to CSG obje ts is due to Cameron (1985). By onsidering dierent approximation strategies, in luding approximating only some of the primitives, Cameron devises several redundan y tests. Cameron's algorithm also in ludes a downward phase in whi h the approximation at the root of the CSG tree is propagated downward toward the leaves, possibly further re ning the approximation. Rossigna and Voel ker (1988) onsider redundan y determination without approximating primitives. Their idea is to identify those surfa e areas of a primitive P that ontribute to the surfa e of the nal solid de ned by a CSG tree T. By analyzing the volumes de ned by the subtrees des ending from the nodes on the path from P to the root of T, they derive a des ription of a volume that must ontain the surfa e area of interest. They all this volume the a tive zone of P, and show how knowledge of the a tive zone an be used to improve onversion from CSG to
2.6 Notes and Referen es
65
B-rep, dete tion of redundan ies, and other operations on CSG trees. The relationship between the a tive zone and the approximation approa hes to redundan y testing is des ribed in Cameron and Rossigna (1988). The winged-edge style of boundary representation is due to Baumgart (1975). Many variants of the method, as well as several alternatives, have been proposed and used in B-rep{based modeling systems sin e then. For a survey of the various representation s hemata, see Weiler (1986). Weiler's thesis also ontains mu h material on Euler operators, and on the problem of whether a spe i representation method is minimally topologi ally omplete. Nonmanifold boundary representations were apparently rst proposed by Wesley (1980). They were again advo ated by Weiler (1986) and by Homann, Hop roft, and Karasi k (1987). In ea h ase, the motivation seems to have been the observation that the internals of a number of geometri operations on polyhedra simplify when nonmanifold stru tures are permitted. Paoluzzi et al. (1986 and 1988) implement Boolean operations on B-rep solids by disambiguating the topology, as dis ussed in Se tion 2.3.1. They assume that all fa es have been triangulated before onstru ting the interse tion or union of two polyhedra. With this restri tion, they obtain a uniform data stru ture representing polyhedra. They show that the needed storage is at most 50 per ent more than that of a winged-edge representation with untriangulated fa es. Mantyla (1984) proves that Euler operations form a omplete set of modeling primitives for manifold solids. That is, every topologi ally valid polyhedron an be onstru ted from an initial polyhedron by a nite sequen e of Euler operations. In Mantyla (1988), the use of Euler operations to implement Boolean operations on polyhedra is explained. The explanation of Euler operators in Chiyokura (1988) is more expli it on the intera tion of the topologi al and geometri aspe ts. The se tion on topologi al validity reviews standard material from algebrai topology. Good sour es on the subje t in lude Aleksandrov (1956), Ho king and Young (1961), S hubert (1964), and Seifert and Threlfall (1947). Ho king and Young (1961) give pi tures of wildly embedded manifolds, in luding Alexander's horned sphere and Antoine's ne kla e. The Euler{Poin are formula an be generalized to manifolds of arbitrary dimension; it is then alled the Euler{Poin are hara teristi of the manifold. It is related to the dimensions of the homology groups of the manifold. Requi ha (1977) de nes solids not only topologi ally but also geometri ally. The topologi al hara terization is similar to ours. Requi ha also shows how the Euler{Poin are hara teristi an be derived from homology
omputations. O tree and other spatial subdivision s hemata are presented in depth in Samet (1989a,b).
66
Basi Con epts
Chapter 3
Boolean Operations on Boundary Representation
Algorithms for determining the regularized union, interse tion, or set differen e of two solids an be used in B-rep and dual-representation modelers. They an be used also to onvert solids represented by CSG trees to an equivalent B-rep. Thus, algorithms for Boolean operations on B-rep are sometimes
alled boundary evaluation and merging algorithms. These algorithms are not diÆ ult on eptually, but their implementation requires substantial work for several reasons. Layers of primitive geometri and topologi al operations to implement them have to be designed. Finding a good stru ture for these layers is not simple, and a
ounting for the many spe ial positions of in ident stru tures in three dimensions an be tedious. Moreover, the presen e of urved surfa es introdu es nontrivial mathemati al problems, and, sin e most of the algorithms require numeri al te hniques, there is inevitably the problem of numeri al pre ision and stability of the
al ulations. In this hapter, we onsider the regularized interse tion of two nonmanifold polyhedral solids given in B-rep. This avoids presenting up front the mathemati al problems arising from nonlinear geometri obje ts. The algorithm presented here has not been spe ialized to the point where its stru ture makes it unsuitable for extension to the urved ase. Moreover, the majority of geometri operations to be formulated will, with ertain extensions, ap67
68
Boolean Operations on Boundary Representation
ply to the urved-surfa e ase. However, the need for high pre ision is more exa ting in the urved-surfa e ase, and the possibility of urve and surfa e singularities is a new dimension that ne essitates additions to the algorithm. It is desirable to use a B-rep in whi h the topologi al information is separated from the geometri representation of the surfa es elements. Moreover, as far as possible, the algorithm ought to be made independent of the spe i details of the geometri representation, sin e then extensions of the overage or alternatives to the hosen representation an be explored with minimum programming. This is espe ially important in the urved-surfa e domain, where dierent geometri representations oer dierent advantages. 3.1 Chapter Organization
The interse tion algorithm to be des ribed has many details and depends on many onventions. We begin the des ription by explaining the representation, and introdu ing a number of low-level operations used repeatedly throughout. The heart of the algorithm is a method for interse ting two polyhedra, A and B, ea h of whi h has one shell. Con eptually, the method subdivides the fa es of the two polyhedra along the urves in whi h their surfa es interse t. This subdivision is re ned to fa es of the output polyhedron, and the adja en ies of these fa es are determined. Thereafter, the surfa e of the interse tion is ompleted by adding ertain fa es of A and of B. Two aspe ts
ompli ate this des ription: 1. The analysis and subsequent transfer of results must a
ount for many spe ial ases that ome about when surfa e elements on the two polyhedra align in spe i ways. 2. The fa e subdivision does not pro eed independently, fa e by fa e, on ea h solid. Rather, ea h interse ting fa e pair is subje ted to a neighborhood analysis whose results are immediately transferred to all adja ent surfa e elements. The rst ompli ation is intrinsi to the problem. Often, des riptions in the literature will omit many of these details to simplify the narrative, leaving the reader to invent his or her own methods for handling them. The se ond
ompli ation trades programming eort against robustness, and is dis ussed later on. Our organization in reases robustness, but at the pri e of additional programming. After the des ription of how to interse t single-shell polyhedra, we explain how to interse t polyhedra with multiple shells. This requires fairly easy extensions. We also mention how the union and dieren e operations an be implemented by a simple modi ation of the interse tion algorithm. In the form rst sket hed, the interse tion algorithm requires testing of ea h fa e pair for interse tion. This is not eÆ ient, and there should be
3.2 Representation Conventions
69
a pre eding omputation that lters out fa e pairs that annot interse t. A simple way to do this is to en lose ea h fa e in a box whose sides are aligned with the oordinate axes, and to onstru t a list of interse ting boxes. Clearly, if two en losing boxes do not interse t, the fa es inside them annot interse t and need not be onsidered together. A fast algorithm for box interse tion is des ribed at the end of the hapter. Note that su h prepro essing steps annot speed up ertain ases of interse ting polyhedra. However, they do speed up the algorithm on average and should therefore be in orporated. At rst reading, it may be advisable to skim or skip parts of the hapter. Se tion 3.4, whi h des ribes how to interse t single-shell polyhedra, is the key part. It requires a on eptual understanding of the representation and of some of the geometri subroutines; this understanding an be obtained by skimming Se tions 3.2 and 3.3. Se tion 3.4.4 may be skipped, postponing the various situations arising in neighborhood analysis. On subsequent reading, Se tions 3.5 and 3.6 explain multishell polyhedra and the redu tion of other Boolean operations to interse tion. Se tion 3.7 is self- ontained. It presents box-interse tion te hniques without assuming any ba kground in omputational geometry. The algorithm is developed in stages, reviewing the needed data stru tures and dis ussing rst the simpler problems of interval and re tangle interse tion. Subse tion 3.4.4, on neighborhood analysis, maps out the many positional spe ial ases that are en ountered when implementing Boolean operations. It is in luded for the less experien ed system developer who may be ome stymied by the many details. There is a se ond, less obvious purpose to this subse tion. When we study the various ases arefully, we form a on eptual understanding of positional degenera y as a umulative impression, and we develop a valuable ability to organize the algorithm on isely.
3.2 Representation Conventions
We assume that polyhedra have nonmanifold surfa es of nite area. The topologi al representation xes the following information: 1. For ea h vertex, the adja ent edges and fa es are given. 2. For ea h edge, the bounding verti es and the adja ent fa es are spe i ed. Moreover, the adja ent fa es are y li ally ordered a
ording to how they interse t a plane normal to the edge, and pairs of adja ent fa es that en lose volume in between are identi ed. 3. For ea h fa e, the bounding edges and verti es are given. They are organized in a set of y les lo ally en losing the fa e area to the right, as seen from the outside. Ordering information is given that spe i es how the boundary graph is embedded in the fa e plane.
70
Boolean Operations on Boundary Representation
The logi al stru ture of this information is as des ribed later. In the des ription, we do not distinguish between, for example, a fa e and a referen e to that fa e, sin e this distin tion is unne essary for understanding the algorithms. For the sake of spe i ity, we des ribe how the geometri information is stored. However, in the subsequent algorithm des ription, the exa t format of the geometri data is not essential. The geometri information is irredundant, spe ifying only the equations for the planes ontaining fa es. These equations are oriented by the onvention that the normal dire tion points lo ally to the solid exterior. Edges are de ned geometri ally as the line segment onne ting the bounding verti es. Note that an edge may be adja ent to more than two fa es. Verti es are given as the interse tion of spe i planes ontaining in ident fa es. Irredundan y of the geometri information redu es the possibility of ontradi tory data and therefore in reases robustness. Moreover, sin e the planes ontaining the fa es of A \ B are a subset of the fa e planes of A and B, no new geometri data are ever onstru ted. Hen e, no ina
ura y
an be introdu ed through omputed geometri information. On the other hand, irredundan y of geometri data in the urved-surfa e domain must be weighed against the omputational ost of deriving oordinates for verti es. Note that fa es may onsist of disjoint areas, provided these areas lie in the same plane with the same orientation. Some Boolean algorithms have been proposed that require that ea h fa e be a onne ted region, or a region homeomorphi to a disk, or a onvex polygon, or a triangle. Typi ally, su h
onstraints simplify the algorithms. However, one would then have to devise an algorithm that subdivides ertain surfa e areas of the result polyhedron, sin e inputs with restri ted fa e topologies do not always yield results that satisfy these onstraints as well. Thus, the work is shifted from the interse tion algorithm to a postpro essing step that onstru ts legal fa es for the result obje t. In the polyhedral ase, this strategy is not without merit, even though it may lead to unne essary edges in repeated Boolean operations on an obje t. It is un lear, however, whether the approa h remains viable in the urvedsurfa e domain, be ause in that ase triangulation or other forms of fa e subdivision an be quite diÆ ult. 3.2.1 Fa e Representation
A fa e is a nite, nonzero area in a plane, bounded by one or more y les of verti es and edges. Edges are dire ted su h that the fa e area lo ally lies to the right, as seen from the exterior of the solid. Fa e planes have been written su h that the normal ve tor points lo ally to the solid's exterior. We refer to this as the onvention of outward-pointing normals, and use it, for example, when determining the fa e dire tion ve tor as explained in Se tion 3.3.1.
71
3.2 Representation Conventions
11 5 14
7 3
4
9
1
13 8
6 12
2 Figure 3.1
Legal Fa e Cy les (1; 2; 3; 4; 3; 5), (6; 7; 8), (9), and (10; 11; 12; 10; 13; 14)
A bounding y le may be degenerate, ontaining the same vertex more than on e, or ontaining only one or two verti es. In these ases, the y le should not en lose zero fa e area. Thus, a single vertex may bound a zeroarea pun ture in a fa e, but may not lie outside the fa e area. In parti ular, edges must bound a nonzero area immediately to the right. Example 3.1: Figure 3.1 shows several legal degenerate fa e y les; Figure 3.2 shows illegal ones. 3 Together, the edge y les form an embedded dire ted, planar graph. Separate onne ted omponents may be nested. This nesting stru ture is re orded in a separate forest of trees. Ea h tree node orresponds to a onne ted boundary omponent. Nested omponents are in subtrees. For example, for the fa e shown in Figure 3.1, we have three trees in the forest. Two trees onsist of a single vertex ea h, and represent the y les (1; 2; 3; 4; 3; 5) and (10; 11; 12; 10; 13; 14), respe tively. A third tree has two nodes. Its root represents the y le (6; 7; 8), and its des endant represents the y le (9). Consider a vertex u of the fa e f. The in ident edges of u de ne se tors in the fa e plane that are alternately inside and outside the fa e f. Sin e edges are oriented, the in ident edges must alternate in dire tion, one being oriented away from u, the other being oriented toward u. We order the edges
2
7
3
10 8
4
9
5 1
6 Figure 3.2
Illegal Fa e Cy les (1; 2; 3; 4; 3), (5) and (6; 7; 8; 9; 10; 11; 9; 8)
11
72
Boolean Operations on Boundary Representation
lo kwise about u and onsider them paired su h that ea h pair en loses a se tor in f. Ea h pair is alled an area-en losing pair. Note that the lo kwise orientation is with respe t to the solid exterior; that is, it depends on the fa e-plane normal. We think of this pairing as a representation of the twodimensional neighborhood of u in the fa e plane. Example 3.2: In the fa e y le (1; 2; 3; 4; 3; 5) shown in Figure 3.1, the vertex 3 is in ident to the four dire ted edges (3; 5), (4; 3), (3; 4), and (2; 3). There are two area-en losing pairs at u; namely, (3; 5); (4; 3) and (3; 4); (2; 3).
3
Re all from Se tion 2.4 that the surfa e of a solid should be orientable. Sin e all fa es are planar, the orientation of the edge y les ensures that every triangulation of a fa e an be oherently oriented, assuming the orientation is onsistent. Here, onsisten y is exa tly analogous to onsisten y of orientation of the boundary omponents of topologi al solids. 3.2.2 Edge Representation
Consider an oriented edge e = (u; v ). The adja ent fa es de ne wedges of volume that are alternately inside and outside the solid. We order the adja ent fa es lo kwise about e as seen in the dire tion (u; v ), and pair adja ent fa es that en lose a wedge of solid interior. Ea h pair is alled a volumeen losing pair. Again, we think of this pairing as a representation of the three-dimensional neighborhood of points in the interior of the edge. Representing this information expli itly, we thus give the following information for ea h edge: 1. Beginning and ending verti es, establishing a default orientation 2. An ordered, ir ular list of adja ent fa es 3. A pairing establishing whi h fa e pairs en lose volume The ir ular ordering and pairing an be represented by a single stru ture. Note that the adja ent fa es use the edge in alternating dire tion. We expli itly annotate the fa e referen e, indi ating whether the edge is used in the default orientation (u; v ) or in the opposite orientation (v; u). This alternation of edge dire tions implies that lo ally the surfa e of the solid an be oriented oherently in the sense of Se tion 2.4 of Chapter 2. 3.2.3 Vertex Representation
Given a vertex, we must know all in ident edges and adja ent fa es. As dis ussed in the previous hapter, the adja ent fa es form ones that an be nested, and the logi al stru ture is a spheri al map. Instead of representing this stru ture expli itly, we let the algorithm infer it when needed; see also Se tion 3.3.4.
3.3 Geometri Operations
73
3.2.4 Surfa e Stru ture
We require nite surfa e area for polyhedra, but permit in nite volume. This is onvenient for redu ing the union operation to an interse tion and several
omplementation operations. A polyhedron an have internal voids, and is thus, in general, an obje t with several surfa e omponents. Ea h surfa e
omponent is a olle tion of verti es, edges, and fa es that are adja ent. These omponents are its shells and are organized into a forest of trees re e ting spatial ontainment and shell orientation.1 A fa e onsisting of two or more disjoint areas must not belong to dierent shells. Ea h shell is given as a list of fa es and an indi ation of whether the shell, taken separately, represents a polyhedron with nite or in nite volume. This information is stored at the nodes of the shell trees. A node s is a des endant of another node t if the shell stored at s is spatially ontained by the shell stored at t. Consider the shell stru ture of a ube with two internal voids. The exterior surfa e is the shell s represented at the root. By itself, it des ribes a solid of nite volume, and is marked as su h. The two shells bounding the interior voids are t1 and t2 . Separately, ea h des ribes a polyhedron of in nite volume. Both shells are nested in s, but not within ea h other. In onsequen e, the shell forest is a single tree whose root is s and whose two leaves are t1 and t2 . 3.3 Geometri Operations
The interse tion algorithm is developed in terms of simpler geometri operations that are used as subroutines. The most trivial ones, su h as omputing vertex oordinates and testing point/line in iden e are not des ribed here. Note, however, that in the ontext of robustness they will have to be onsidered in some detail, as dis ussed in the next hapter. 3.3.1 Fa e Dire tion Ve tor
Given an edge e of a fa e f, we will need to know the orientation of the edge and the dire tion in the plane of f in whi h the interior of f lies. Suppose the edge is de ned by two in ident verti es u and v, and we know an equation ax + by + z + d = 0 for the plane P ontaining the fa e f. The orientation of the edge with respe t to f is determined from the topologi al data that spe ify how the edge is referen ed by f. The fa e dire tion ve tor is a ve tor fd in the plane P. The ve tor is perpendi ular to the edge tangent ve tor te and points to the interior of f (Figure 3.3). It is de ned for every point p on the edge. Sin e the edge is a line segment, the ve tor does not depend on p. It is omputed from the edge orientation as referen ed by f and from the normal ve tor nP = (a; b; ) of 1 Ea h
shell is a onne ted omponent of the 2-manifold bounding the solid, as dis ussed
in Se tion 2.4 of Chapter 2.
Boolean Operations on Boundary Representation
74
np
te
p
fd
u
Figure 3.3
the plane
v
Fa e Dire tion Ve tor
as the ross-produ t te nP . Here, te is the edge tangent ve tor, oriented by the edge dire tion. This omputation also works for urved edges, P
but then the surfa e normal
n
P and the edge tangent te depend on the point
p.
It is possible that the same edge is referen ed twi e by f, on e in ea h dire tion. In this ase, we know that there is fa e interior on both sides of the edge, and whi h of the two sides is needed must be determined from the
ontext; see also Se tion 3.3.3.
3.3.2 Splitting an Area- or Volume-En losing Pair
In the neighborhood analysis, we have to determine whether a fa e lo ally extends to the interior or exterior of the other solid. This question is redu ed to determining whether a ertain ve tor splits two paired ve tors. Similarly, in two dimensions, we may determine whether a line segment extends into the interior of a fa e, whi h we do by determining whether the segment splits an area-en losing pair of edges. Given an area-en losing pair of edges (v1 ; u) and (u; v2 ), we wish to determine whether a ve tor t = (u; w ) lies in the area en losed by the pair. If so, we say that
t
splits an area-en losing pair; see Figure 3.4 for an example.
To determine this, we order lo kwise the three ve tors t, (u; v1 ), and (u; v2 ) about u, beginning with (u; v2 ). If, after sorting,
t
lies between the pair, then
it splits the pair. Given a volume-en losing pair of adja ent fa es, we determine whether the ve tor
t
lies inside the volume so bounded. If so, we say that
t
splits a
volume-en losing pair. The test an be redu ed to a test for splitting area-
en losing pairs by proje ting ve tors of the fa es.
t
onto the plane spanned by the fa e dire tion
75
3.3 Geometri Operations
v
2
t
v
u Figure 3.4
1
Splitting an Area-En losing Pair
3.3.3 Ordering Points Along a Line and Pairing Them
The transversal interse tion of two fa es is a set of segments on a line. The segments are obtained by rst interse ting ea h fa e with the plane ontaining the other fa e, followed by interse ting the segments. We address how to interse t one fa e with the plane ontaining the other fa e. Given a line representing the interse tion of two fa e planes P and Q,
ontaining, respe tively, the fa es f and g, we order sequentially the points in whi h the bounding edges of g interse t the plane P. Assuming no arithmeti problem, the ordering of points is straightforward and an be done by sorting them by one of the oordinates, depending on the slope of the line. Having ordered the points, we now pair onse utive points su h that the line segment bounded by ea h pair represents an interse tion of the fa e g with the plane P (Figure 3.5). Sin e fa es have nite area, there annot be in nite line segments, and so we pair onse utive points in sorted order. For
urved surfa es P and Q, the problem is mu h more ompli ated be ause their interse tion may be a ompli ated spa e urve. We orient the line P \ Q (arbitrarily) by the ross-produ t of the plane normals, t = nP nQ , and order the interse tion points a
ordingly. Compli ations arise from spe ial positions where verti es of g lie on the line P \ Q, and from interse tions with edges that must be onsidered in both orientations. Let (u; v ) be an oriented edge of g. If u is below P while v is above it, then the interse tion point is paired with the subsequent point in sorted order; otherwise, it is paired with the previous point. If both (u; v ) and (v; u) must be onsidered, then the two interse tion points must not be paired with ea h other. If a vertex of g is on the line P \ Q, it is onsidered as a double interse tion point. Call the two interse tions u1 and u2 , in sorting order. Then, u1 is paired with the pre eding point if t splits an area-en losing pair of edges in ident to u, and u2 is paired with the su
eeding point if t splits an area-
76
Boolean Operations on Boundary Representation n
Q
Q
P g
1
2
3
t
n P
Figure 3.5
Interse tion-Point Sorting and Pairing
en losing pair of in ident edges. If t or t is ollinear to an in ident edge of g, then that edge is used to onne t the respe tive opy of u with its prede essor or su
essor. If neither t nor t split an area-en losing pair, then u is an isolated point. For example, in Figure 3.5, the rst opy 21 of point 2 is paired with the pre eding point 1, but the se ond opy is not paired and is therefore ignored. The interse tion point 3 is isolated. Note that isolated points must be re alled in later stages of the algorithm, and annot be dis arded outright.
3.3.4 Line/Solid Classi ation A general method for determining possible ontainment of two noninterse ting bounding stru tures A and B is to onne t a point on the boundary of A by a line segment with a point on the boundary of B, and then to analyze how this line segment interse ts the boundaries of the two stru tures. However, the stru ture A may onsist of several dis onne ted omponents, as may B. Therefore, any ontainment on lusions drawn apply to only those
omponents of A and B that the line segment a tually interse ts. For example, the line segment (p; q ) in Figure 3.6 allows us to on lude that both the omponent ontaining p and the omponent ontaining q will bound the interse tion of the two areas A and B, but it annot reveal that the other
omponent of A is not part of the nal boundary. For the nal boundary, the omponents are assembled by a sequen e of the tests now des ribed; see also Se tion 3.5 on multishell obje ts. We explain the test rst in the ase of fa es. Consider a fa e f and a fa e g, both in the same plane and oriented the same way. We assume that the boundaries of f and g do not interse t, and wish to test whether one fa e boundary ontains the other. We sele t a point
3.3 Geometri Operations
77
B
p
q
A Figure 3.6
Classi ation of Multiple-Boundary Components
on the boundary of f and a point q on the boundary of g, and onne t them with a line segment (p; q ). The segment interse ts the boundaries of f and g in a number of points that must be ordered linearly and that then partition the line (p; q ) into intervals. Ea h interval is lassi ed as being outside of f or in f, and, likewise, as being outside of g or in g. Sin e p is on the boundary of f and q is on the boundary of g, there is some interval with one endpoint that is an interse tion of the line (p; q ) with the boundary of f, and the other endpoint that is an interse tion with the boundary of g. We pi k the rst su h interval en ountered, s anning the intervals in order beginning at p. There are four possible lassi ations of this interval, as shown in Table 3.1. Asso iated with ea h is a position of the two fa es relative to ea h other. Figures 3.7 and 3.8 illustrate the four ases, with the interior as implied by the orientation of the bounding y les. The interval lassi ation is essentially the same operation that was done in the interse tion-point pairing along the line P \ Q des ribed previously. As with that operation, are has to be exer ised when the segment (p; q ) interse ts a boundary at a vertex. Now onsider testing the possible ontainment of two solids A and B p
Test Example in f, in g f and g interse t in f, out g g is ontained in f out f, in g f is ontained in g out f, out g f and g do not interse t Table 3.1
A tion both omponents are kept the g omponent is kept the f omponent is kept neither omponent is kept
Containment Classi ation for f and g
Boolean Operations on Boundary Representation
78
p
q
g
g q
f
f p
In/Out
In/In
The Classi ations \in f, in g " and \in f, out g "
Figure 3.7
whose boundaries do not interse t. In spirit, we pro eed exa tly as for fa es, sele ting a point p on the surfa e of A and a point q on the surfa e of B, and
onne ting these two points with a line segment. As before, the interse tion of (p; q ) with the boundaries of A and B indu es an interval partition, and the individual intervals are again lassi ed as being inside or outside of the solids. Again, Table 3.1 governs the out ome of the test, based on the rst interval en ountered, going from p to q, that is bounded by an interse tion with the boundary of A and an interse tion with the boundary of B. The lassi ation of intervals in the solid ase is more ompli ated, however, and we explain it further. Con eptually, it is an analysis of the neighborhood of the interse tion points. Thus, it is easiest for interior fa e points, more ompli ated for interior edge points, and hardest for verti es. First, if the segment interse ts in the interior of a fa e f of A, then the dire tion ve tor t = (p; q ) is ompared in angle against the fa e normal Æ nf of f. If the angle is less than 90 | that is, if the dot produ t nf t
p
q
q
p
g
g
f
f Out/In Figure 3.8
Out/Out The Classi ations \out f, in g " and \out f, out g "
79
3.3 Geometri Operations
q
q n
n f
t
2
n
t f
e f
2
Figure 3.9
Classi ation for Fa e
f
1
p
p
Interior
1
Figure 3.10
Interior
Classi ation for Edge
is positive | then the interval pre eding the interse tion is in A, and the interval su
eeding it is outside of A. Otherwise, the pre eding interval is outside, and the su
eeding interval is inside, of A; see also Figure 3.9. Next, assume that (p; q ) interse ts at the interior of an edge e of A. Here we must determine whether t and t split volume-en losing pairs. That is, if t splits a volume-en losing pair of the fa es adja ent to e, then the su
eeding interval is inside of A. If not, it is outside of A. The same analysis of the ve tor t lassi es the pre eding interval with respe t to A; see also Figure 3.10. Note that both t and t must be lassi ed. Finally, assume that (p; q ) interse ts at the vertex u of A. Here we must determine whether t, and t, are in the interior of a solid one de ned by the fa es in ident to u. Sin e this neighborhood is not expli itly represented, we investigate the stru ture by interse ting it with a suitable plane. We pi k a plane R that ontains the line (p; q ) and an interior point w of some fa e adja ent to u. Sin e u is in the plane R, the vertex appears on R as a point with lines radiating outward. Ea h line represents the interse tion of some adja ent fa e of u with R. The se tors de ned by these lines are lassi ed as inside or outside of A. Sin e R ontains w, there is at least one nonempty se tor. Then t and t are lassi ed by the se tor in whi h they lie. A
ordingly, we now lassify the interval on (p; q ). See Figure 3.11 for an illustration of the pro ess. Sin e the lassi ation is fairly omplex and expensive for vertex interse tions, we may wish to hoose a dierent point q to avoid this ase. Thus, it is a good idea to hoose p and q to lie in the interior of fa es. Although this does not guarantee that all other interse tion points are lo ated favorably, subsequent random perturbations of the positions of p and q will usually
80
Boolean Operations on Boundary Representation q
u
q
R
R
u w w
p
p Figure 3.11
Classi ation for Vertex Interse tion
su
eed in reating well-behaved interse tions everywhere. Typi ally, one or two perturbations suÆ e. Re all from Se tion 2.4 that the onne ted omponents of the boundary of a multishell solid should be onsistently oriented. The shell- ontainment test just des ribed an be used to test whether the omponents are onsistently oriented. It is not diÆ ult to prove that two omponents are onsistently oriented i the ontainment test determines an \in/in" or an \out/out" lassi ation. 3.4 Interse tion of Two Shells
We onsider rst the interse tion of two polyhedra, A and B, ea h with a surfa e onsisting of a single shell. The interse tion of multishell polyhedra will be onsidered subsequently. We on eptualize the pro ess of interse tion as follows: 1. Determine whi h pairs of fa es f 2 A and g 2 B interse t. If there are none, test shell ontainment only and skip steps 2 through 4. 2. For ea h fa e f of A that interse ts a fa e of B, onstru t the rossse tion of B with the plane ontaining f. Then determine the surfa e area of A \ B that is ontained in f. 3. By transferring the relevant line segments dis overed in step 2, determine the fa es of B that ontain some of the surfa e area of A \ B
3.4 Interse tion of Two Shells
81
u e
f1
e f2
v
Figure 3.12
Lo ally In onsistent Interse tion Analysis
and must be subdivided. Subdivide these fa es, and by exploring the fa e adja en ies of B, nd and add all those fa es of B ontained in the interior of A. Likewise, nd and addall fa es of A ontained in the interior of B. 4. Assemble all fa es so found into the solid A \ B . This on eptual stru ture is also suited to the urved-surfa e domain. 3.4.1 Robustness Considerations
A drawba k of the organization just presented is its sensitivity to failure be ause of numeri al impre ision. If step 2 onsiders ea h fa e of A independently, ertain interse tion stru tures may be in onsistently analyzed for adja ent fa es. In onsequen e, the algorithm ould fail for legitimate inputs. Example 3.3: Figure 3.12 illustrates the problems numeri al error ould
ause when implementing the proposed on eptual algorithm. We analyze whether and how the edge e = (u; v ) of B interse ts two adja ent fa es f1 and f2 of A. When onsidering these fa es, the edge e is interse ted with the respe tive fa e planes. When this is done independently, the interse tion-point
oordinates ould have dierent pre ision. In onsequen e, it is possible that e will be judged to interse t the edge between f1 and f2 when onsidering fa e f1 , but that e will not be re ognized to interse t the edge when onsidering f2 . This apparent in onsisten y ould ause a atastrophi failure of the implemented algorithm. 3 Similar robustness problems are endemi to the following popular algorithm for Boolean operations. First, mark on the surfa e of A the urves in whi h B interse ts A. Then, reverse the roles of A and B, and repeat
82
Boolean Operations on Boundary Representation Thereafter, assemble the surfa e of A \ B by adja en y explo-
this step. ration. This method is attra tive be ause it redu es the programming eort. However, the independent subdivision of the surfa es of A and B gives many opportunities for in onsisten ies due to numeri al error. Thus, this paradigm is also not robust. We re ne the on eptual stru ture of our algorithm with the goal of a hieving lo al onsisten y and avoiding problems su h as the one illustrated in Figure 3.12. Our strategy is to avoid asking the same geometri question more than on e. That is, all interse tion information is immediately posted to all adja ent fa es: 1. Determine whi h pairs of fa es f 2 A and g 2 B interse t. If there are none, then do a shell- ontainment test only and skip steps 2 through 4. 2. For ea h interse ting pair of fa es, f of A and g of B, onstru t the points and urves in whi h they interse t. For ea h interse tion, analyze the three-dimensional neighborhood and transfer its elements to all adja ent fa es of A and of B. 3. By exploring the fa e adja en ies of A and of B, nd and add all those fa es of either solid that are in the interior of the other. 4. Assemble all fa es into the solid A \ B . 3.4.2 Interse ting-Pairs Determination and Shell Containment
We elaborate on step 1 of the algorithm, dete ting pairs of interse ting fa es. The obvious method for determining whether the fa e f 2 A interse ts the fa e g 2 B is a tually to interse t these fa es. Sin e all fa e pairs would be so tested, there is no hope that the algorithm ould perform well in those situations where A and B have many fa es but only a few of them a tually interse t. Instead, it is onvenient to en lose ea h fa e in a box whose sides are parallel to the oordinate planes, and to ask whether the box ontaining f interse ts the box ontaining g. If the boxes do not interse t, then the fa es annot interse t. If the boxes do interse t, then the fa es may or may not interse t, and we ontinue with the remaining steps. There is an O(n log2 (n) + J ) algorithm for interse ting the boxes, where n is the number of boxes and J is the number of interse ting box pairs found. Sin e J may be quadrati in n, we annot improve the worst- ase running time for polyhedral interse tion, but we an signi antly improve the average running time. A box-interse tion algorithm with this time performan e is des ribed later in this hapter. Sin e box interse tion an determine only that two fa es do not interse t, we may arrive at a situation where some boxes interse t, yet later in step 2, we determine that the surfa es of A and B do not interse t after all. In this
ase, we must run the shell- ontainment test following step 2.
3.4 Interse tion of Two Shells
Assuming that the surfa es of four possibilities:
83
A and B do not interse t, we distinguish
1. The surfa e of A \ B onsists of both the surfa e of A and the surfa e of B. 2.
A \ B = B .
3.
A \ B = A.
4.
A \ B is empty.
These four situations are pre isely the four possibilities of the line/solid lassi ation, dis ussed previously, orresponding, respe tively, to \in A, in B," \in A, out B," \out A, in B," and \out A, out B." 3.4.3 Fa e Interse tion and Neighborhood Analysis
Having found all andidates of interse ting fa e pairs, we pro eed to step 2 of the algorithm and onstru t their interse tion. Although this step is on eptually not hard, the details tend to get in the way. Moreover, it requires intermediate data stru tures that are in omplete edge and fa e subdivisions. Con eptually, we repeat the following tasks for the interse ting fa es f of A and g of B : 1. Constru t and analyze the points and line segments of their interse tion. 2. Transfer the results to all adja ent fa es of A and of B. 3. Link up the interse tion elements into omplete fa e and edge subdivisions. After this operation has been performed for all interse ting fa es, we know impli itly the surfa e area of A \ B that lies on the surfa e of A and of B, ex ept the fa es of A that lie inside B and the fa es of B that lie inside A. Example 3.4: Consider the interse ting boxes A and B shown in Figure 3.13. Four fa es of B and one fa e of A are subdivided in the pro ess of fa epair interse tion. In the end, we have dis overed ve of the six fa es bounding A \ B . The sixth fa e is dis overed in a later step of the algorithm. The important point is that, when interse ting the fa es f and g, both f and g are subdivided by a line segment. A te hni al diÆ ulty is that the interse tion line segment introdu ed on f does not yet de ne a valid subdivision of f. The subdivision of f is ompleted only after f has been interse ted with four fa es of B. 3
Boolean Operations on Boundary Representation
84
A
B f
Figure 3.13
Two Interse ting Boxes
Determining and Pla ing Interse ting Elements
g be a fa e of B that we suspe t interse ts the fa e f of A. We interse t the bounding edges of g with the plane P ontaining f. Ex luding for the moment the ase that g is ontained in P (i.e., that every edge of g is ontained in the plane), the edges will interse t P in a number of points that lie on a line l. The line l is the interse tion of the plane Q ontaining g and the plane P. If an edge e of g is ontained in P but g is not, then the verti es of e are onsidered the interse tion points of the edge with P. The interse tion points are sorted along l and are paired as des ribed previously. Thereafter, we interse t the line l with f, obtaining a se ond set of segments. The two sets are then interse ted, and the resulting segments are pla ed on f, g, and, Let
possibly, other adja ent fa es, as appropriate.
f and g are in the same plane, then they must be interse ted as polygons. The result area is on the surfa e of A \ B , provided both fa es have the same orientation. If the fa es have opposite normals, then f \ g will be a lowerIf
dimensional stru ture that is eliminated by regularization. See Figure 3.14 for an example. The interse tion of
f and g onsists of line segments and points. Segments
are either edges or edge segments, or they represent the interse tion of two fa e interiors. Note that there may be isolated verti es. Points and lines both are analyzed. In parti ular, the points bounding a segment are analyzed, as is the segment interior. The results of this analysis are 1. The pla ement of oriented segments on fa es 2. The segmentation of edges 3. The pla ement of ertain points on fa es and edges
85
3.4 Interse tion of Two Shells
g
f
Figure 3.14
Coplanar Fa es with Opposite Orientation
4. The reation of adja en y onstraints between points and segments Pla ing points on an edge de nes a segmentation of the edge. Segments so de ned may have to be re ned later, when other points on the edge are dis overed. Example 3.5: Consider Figure 3.15, assuming that the fa es f and g are interse ted rst. Here, the segment (w1 ; w2 ) is pla ed on f in the orientation (w2 ; w1) and on g in the opposite orientation. The edge (u1; v1 ) of g is subdivided by pla ing the point w1 on it. The resulting segment
f1 f w3
u2 w2
u1
w1 g v2 B
A
Figure 3.15
Pla ing Points and Segments
v1
Boolean Operations on Boundary Representation
86
g
ng
g u u
n f
v
v
u
v
f
f
Figure 3.16
Line-Segment Orientation
(u1 ; w1 ) would have to be further subdivided if another fa e of A interse ted it. This is not the ase in the gure. Similarly, the segment (u2 ; w2 ) is reated by pla ing w2 , and is not further subdivided later. Now assume we interse t next the fa es f1 and g. Then the edge (u2; v2 ) of g is ollinear with the edge (w3 ; w2 ) of f1 . Both edges are subdivided by pla ing the segment (w2 ; u2). Here we know that the segment annot be further subdivided, sin e the two edges overlap. On g, the segment is pla ed in the orientation (w2 ; u2), onsistent with the orientation in whi h g uses the edge (u2; v2 ). An analysis of the three-dimensional neighborhood reveals, moreover, that the segment should not be pla ed on f1 , sin e the area of f1 adja ent to the segment lies in the exterior of B. 3 Segment Orientation
A segment that is pla ed on a fa e f represents part of the boundary of the interse tion A \ B . It will be oriented su h that the interior of the fa e of A \ B bounded by it is lo ally to the right. The orre t orientation is dedu ed from the orientation of the two fa e planes. Figure 3.16 shows a simple example. In some ases, two oriented line segments are pla ed on f, indi ating that the nal bounding y le of edges is degenerate. 3.4.4 Neighborhood Analysis
To analyze the interse tion of fa e pairs, we onsider the three-dimensional neighborhoods of the interse tion line segments and points in the subdivision. We re all that the interior and the endpoints of a segment must be analyzed. There are six major ases, indexed by the interse ting stru tures: 1. A fa e of one solid interse ts the fa e of another solid at a point interior to both.
87
3.4 Interse tion of Two Shells
g
g
u v
f
f
Fa e/Fa e Interse tion
Figure 3.17
2. An edge of one solid interse ts a fa e of the other solid at a point interior to both edge and fa e. 3. An edge of one solid interse ts an edge of the other solid at a point interior to both edges. 4. A vertex of one solid interse ts a fa e of the other solid in the interior. 5. A vertex of one solid interse ts an edge of the other solid in the interior. 6. A vertex of one solid interse ts a vertex of the other solid. All ases exhibit a on eptual similarity in that the progression from fa e to edge and then to vertex entails similar pro essing, but involves more and more fa es.
Fa e/Fa e Interse tion The generi ase arises from a transversal interse tion of two fa es, shown on the left in Figure 3.17. The segment (u; v ) generates two oriented line
f
segments, one on , the other on
g.
The orientation is omputed from fa e
normals. See also Figure 3.16. The interior of (u; v ) will be only on on
f
and
g, but the endpoints require further analysis as des ribed later, and this
analysis involves additional fa es.
For the degenerate ase, arising when
f
and
g
are in the same plane, we
analyze the interior of a region by omparing the fa e normals. Normals of equal dire tion mean that the area is on the surfa e of
A
\ B .
opposite dire tion mean that the area is not on the surfa e of
Normals of
A
\ B .
See
also Figure 3.16.
Edge/Fa e Interse tion Assume that the edge
e
= (u; v ) of
B
interse ts the interior of the fa e
f
of
A. Ordinarily, the edge interse ts the fa e in one point, as shown in Figure
Boolean Operations on Boundary Representation
88
v
w f
f u Figure 3.18
Edge/Fa e Interse tion
f w. There must be a segment of e, bounded by w, that lies inside
3.18 on the left. We assume this point is in the interior of . The edge is subdivided by
A. Whether this segment is ontained in (
u; w )
or in (w; v ) is determined by
omputing the dot produ t of the dire tion ve tor (u; v ) and the fa e normal
nf .
We also know that the fa es of
B
adja ent to
e
f
all interse t , so we must
make sure that the respe tive segments are re ognized as adja ent to In the degenerate ase, the edge
e
f
3.18 on the right. The edge is then subdivided by the boundary of a number of segments. These segments must be transferred to fa es
g
adja ent to
f
e.
w.
lies in the plane of , as shown in Figure f
f
Transfer and orientation is determined as follows.
For the fa e , we onsider ve tors perpendi ular to
e
into
and to all
f
in the plane of , in
ea h dire tion. We ask whether these ve tors split a volume-en losing pair of
w 2
n 2
v
n 1 w 2 f u
w 1 Figure 3.19
w 1 Transfer for Degenerate Edge/Fa e Interse tion to f
89
3.4 Interse tion of Two Shells
n
g1 g 1
g fd
1
nf 1
e
f fd 2
g
g2
2 n
g2
Figure 3.20
Transfer for Degenerate Edge/Fa e Interse tion to gi
fa es adja ent to e. If so, the segment is transferred to f with the appropriate orientation. In onsequen e, f re eives zero, one, or two dire ted lines for ea h segment of e ontained in f. Figure 3.19 shows an example in whi h two segments of opposite orientation are transferred. Next, onsider the fa e g adja ent to e. By omputing the dot produ t of the fa e dire tion ve tor of g with the normal of f, we determine whether g extends lo ally into the interior of A. If so, every segment of e is transferred to g, in the same orientation as e has on the boundary of g. Otherwise, no segment is transferred. See also Figure 3.20.
Edge/Edge Interse tion Assume that edge e of A interse ts edge e of B. In the generi ase, shown on the left of Figure 3.21, the edges interse t in a single point w that subdivides both edges. This ase an be onsidered as several edge/fa e interse tions, one for ea h fa e f adja ent to e. At most two of these ases an be degenerate. Thereafter, we determine whether e and/or e ontain segments bounded by w that lie in the interior of the other solid. This requires the line/solid lassi ation des ribed previously. The degenerate edge/edge interse tion ase arises when the two edges are
ollinear and overlap, as shown in Figure 3.21 to the right. The ase generalizes degenerate edge/fa e interse tion. The segment of overlap is transferred in the appropriate dire tion to ea h of the adja ent fa es whose fa e dire tion ve tor(s) split a volume-en losing pair of fa es of the other solid. See also Figure 3.22. 0
0
Boolean Operations on Boundary Representation
90
e’
e’ e
w
Figure 3.21
e
Edge/Edge Interse tion
Vertex/Fa e Interse tion When a vertex u is in the interior of a fa e f, we have to satisfy adja en y
onstraints. Figure 3.23 shows an example. The fa es gk adja ent to u may interse t f in segments that must be in ident to u. In addition, ertain edges in ident to u will extend into the interior of f. They are determined by omputing dot produ ts, and de ne edge segments interior to the other solid. Note that su h segments may be further subdivided, as dis ussed before. Here u plays the role of w in the edge/fa e interse tion analysis.
Vertex/Edge Interse tion Assume that vertex u of A interse ts the interior of edge e of B. This ase is on eptually a olle tion of vertex/fa e interse tions, one for ea h fa e
f
g1
1
f1 f2
g
2
g 2
Figure 3.22
Transfer for Degenerate Edge/Edge Interse tion
91
3.4 Interse tion of Two Shells
f u
f u
Figure 3.23
Vertex/Fa e Interse tion
adja ent to the edge. The analysis of whi h edges of u extend into the interior of B is more ompli ated and is done as des ribed in the edge/edge interse tion analysis. In addition, the edge e = (v; w) is subdivided by u, and we need to determine whether the segments (v; u) and (u; w) extend into the interior of A. See also Figure 3.24.
Vertex/Vertex Interse tion Assume that vertex v of A oin ides with vertex u of B, as in Figure 3.25. We determine all edges in ident to u that extend into the interior of B and,
onversely, all edges in ident to v that extend into the interior of A. This is essentially a line/solid lassi ation; see Se tion 3.3.4. However, sin e the line is indu ed by the position of the interse ting solids, we annot simplify the lassi ation pro edure by perturbing its position. In addition, we must
u
Figure 3.24
Vertex/Edge Interse tion
Boolean Operations on Boundary Representation
92
u,v
Vertex/Vertex Interse tion
Figure 3.25
make sure that all interse tion segments of adja ent fa es are in ident to and
v.
u
3.4.5 Fa e Subdivision
We have pla ed points and line segments subdividing edges and fa es. We think of the points and segments as verti es and edges of a graph.
We
ontinue to refer to the graph verti es as points and to the graph edges as segments, to distinguish them from the edges and verti es of
A
and
B. The
purpose of neighborhood analysis has been to embed the graph onsistently on both surfa es, and to obtain orre t in iden es at its points. After all fa e pairs have been interse ted, the graph has the following properties:
1. If (u; v ) is a segment that is not a omplete edge, then the in iden es at the points
u
and
v
are ompletely known.
2. If (u; v ) is a segment and the in iden es at then
u
is a vertex of, say,
segments of all edges of
u
are not ompletely known,
A, and the missing in iden es at in ident to u.
u
are initial
A
Property 1 follows from the neighborhood analysis. For property 2, observe that (u; v ) must be an edge of
A
that is in luded in the graph be ause
interse ts the surfa e of B and (u; v ) extends into the interior of
A. Sin e (
v
u; v )
is not subdivided further, no other point of it an interse t the boundary of
B. Hen e the vertex must be an interior point of B. Let ( ) be any edge of A. Sin e is in the interior of B, either ( ) is ontained in B, or an initial segment ( ) of it is in B . In the latter
ase, the point 1 is an 1 interse tion with the surfa e of B, and has already been dis overed. u
u; w
u
u; w
u; w
Thus, we an subdivide all fa es of
w
A
and of
B
that interse t the boundary
of the other solid by exploring the subgraph onsisting of all points and
3.4 Interse tion of Two Shells
93
segments ontained in a fa e f, adding, when needed, undivided edges (u; w) of f adja ent to a vertex u that is not a point in the subgraph: 1. Initialize a list L of all points in f. 2. If L is empty, stop. Otherwise, initialize the sta k S to ontain a point u in L. 3. If S is empty, return to step 2. Otherwise, pop u from S and delete it from L. Mark u as explored. 4. Let E1 be the set of all segments in ident to u ontained in f. If u is not a point, then let E2 be all edges of f not ontaining a point; otherwise, E2 is empty. 5. Order the edges and segments in E1 [ E2 y li ally about u in the plane of f, and onstru t area-en losing pairs. 6. For ea h (u; w) or (w; u) in return to step 3.
E1
[ E2 , sta k w if it is unexplored. Then
When the exploration is nished, we have a omplete subdivision of f from whi h we obtain fa es of A \ B by organizing into y les the segments and edges onsidered and determine how they may be nested. Note that the algorithm is organized as a depth- rst sear h. 3.4.6 Adja en ies in the Result
After ompletion of step 2, we are now ready to nd the missing fa es of A \ B . The missing fa es are those fa es of A that are in the interior of B , and, vi e versa, the fa es of B that are in the interior of A. They are found by onsidering edge adja en ies. We re all from the neighborhood analysis that the fa e adja en ies of ea h segment must be known, sin e at least one point of the segment is on the boundary of one of the solids. Hen e, missing fa es are pre isely those fa es that are edge adja ent to an undivided edge (u; w), added in the fa esubdivision phase just des ribed, or fa es that are vertex adja ent to an undivided edge (u; v ) that is a segment with u not being a point. Again, by exploration of the adja en y stru ture, all su h fa es an be found: 1. Let F1 be the set of all fa es of A \ B onstru ted by the subdivision given previously, and mark them as unpro essed. Set F2 to the empty set. 2. If all fa es in F1 [ F2 have been pro essed, then stop. We have found all fa es of A \ B . 3. For all unpro essed fa es f in F1 [ F2 , mark f as pro essed. For ea h edge (u; v ) of f where u is not a point, add to F2 all fa es in ident
94
Boolean Operations on Boundary Representation
Figure 3.26
to u in A or in unpro essed.
B
A Multishell Polyhedron in Two Dimensions that have not been subdivided, and mark them as
Note that F2 a
umulates all fa es of A and of B that are ontained in the interior of the solid. When implementing the algorithm, it is useful to remember whi h verti es u have already been onsidered, to avoid redundant pro essing. 3.4.7 Single-Shell Interse tion Summary
By analyzing the three-dimensional neighborhoods of fa e-pair interse tions, we have found segments and points making up the urves of interse tion. The omplete neighborhood analysis implies that the graph is onsistently embedded on the two surfa es, and that the adja en ies have been orre tly determined, ex ept for ertain adja en ies that are inherited from the boundary y les of the fa es. Considering ea h fa e interse ting the boundary of the other solid, we have ompleted the graph and have onstru ted a onsistent subdivision of those fa es of ea h solid that are not ompletely in the interior of the other solid. Finally, by onsidering ertain undivided edges, we ompleted the surfa e of A \ B , adding those fa es that are ompletely in the interior of the other solid.
3.5 Multishell Obje ts
In general, a multishell polyhedron A onsists of several disjoint polyhedra P1 ; P2 ; : : : Pm . At most one of these polyhedra has in nite volume, and the remaining ones have nite volume, sin e we required that solids have a nite, bounded surfa e. Figure 3.26 illustrates this in two dimensions. Consider the in nite polyhedron P1 . It lls the entire spa e ex ept for a nite number r of voids that ontain the remaining polyhedra P2 ; : : : Pm .
95
3.5 Multishell Ob je ts
= Figure 3.27
Polyhedron as Interse tion of Single-Shell Polyhedra
Ea h void is bounded by a shell S that, taken separately, bounds a singleshell in nite polyhedron; see also Figure 3.27. Moreover, the forest of shell trees of A ontains r trees, ea h root representing one of the voids of P1 . We think of su h a polyhedron as the interse tion of r single-shell polyhedra with disjoint shells. The nite polyhedra Pi are bounded by an exterior, positive shell and may have internal voids in turn. Again, we think of ea h polyhedron as the interse tion of several single-shell polyhedra. One of them, bounded by the external shell, has nite volume. The others are of in nite volume and are bounded by the shells of the internal voids. We therefore write A = P1 [ P2 [ : : : [ Pm , where ea h omponent is the interse tion of single-shell polyhedra. Likewise, B = Q1 [ Q2 [ : : : [ Qr . Sin e the Pi are pairwise disjoint, as are the Qi , the interse tion of A and B is
A
\ B = (P1 \ Q1 ) [ (P1 \ Q2 ) [ : : : [ (P1 \ Q ) [ (P2 \ Q1 ) [ : : : [ (P \ Q ) r
m
r
Ea h interse tion Cik = Pi \ Qk is the interse tion of a set of single-shell polyhedra. Moreover, the polyhedra Cik must be disjoint; thus, their union is trivially determined. It follows that the interse tion of multishell polyhedra redu es to the simultaneous interse tion of several single-shell polyhedra. Now it is simple to modify the single-shell interse tion algorithm to interse t more than two shells at on e, be ause the algorithm makes no essential use of the fa t that the surfa e of single-shell polyhedra is onne ted, ex ept for the on lusion that two shells either interse t or else must be analyzed with a shell- ontainment test. In the more general setting, therefore, the algorithm is run as before, subdividing the appropriate fa es of interse ting shells and merging these shells through surfa e exploration. Thereafter, we onsider the remaining, noninterse ting shells, lassifying them by the shell- ontainment test, adding or deleting shells as required.
96
Boolean Operations on Boundary Representation
3.6 Complement, Union, and Dieren e To omplement an obje t, we must reverse the surfa e orientation. This is done as follows: 1. Multiply ea h fa e equation by of the fa e interior.
1, thereby inverting the orientation
2. Reverse the orientation of every boundary vertex y le of a fa e. 3. Change the pairing of volume-en losing pairs by moving it over by one entry, reverse the edge dire tion, and reverse the y li order of adja ent fa es. Thus, the pairing ((a; b); ( ; d)) in the y li al order (a; b; ; d) is
hanged to ((a; d); ( ; b)). The forest of shell trees is modi ed by omplementing at ea h node the indi ation of whether the shell at that node en loses nite or in nite volume. Note that omplementation takes time proportional to the size of the boundary representation; that is, it is linear in the number of fa es. To ompute the union of two obje ts, we apply de Morgan's law and
ompute instead :(:A\ :B ). The dieren e A B is omputed as A\ :B .
3.7 Fa e-Boxing Te hniques An iso-oriented box is a parallelepiped whose sides are parallel to the oordinate planes. We seek a fast algorithm for reporting all interse ting pairs among a set of iso-oriented boxes, so as to reje t as noninterse ting ertain fa e pairs in polyhedral interse tion. For ea h fa e, the smallest iso-oriented box is used that ompletely ontains the fa e. For a planar fa e, the box is found by determining the maximum and minimum oordinates of the verti es of the fa e, and ea h box an be spe i ed as three intervals, [x0 ; x1 ℄, [y0 ; y1℄, [z0 ; z1 ℄, that spe ify the extreme oordinate values. The algorithm developed here solves the following problem: Problem Given n iso-oriented boxes, report in O(n log2 (n) + J ) steps all interse ting pairs of boxes, where J is the number of pairs reported.
First, we develop the algorithm by onsidering one- and two-dimensional versions. In the two-dimensional ase, we seek a fast algorithm for reporting interse tions among iso-oriented re tangles. This problem an be solved in O (n log(n) + J ) steps, as an the one-dimensional interval-interse tion problem. After giving an O(n log(n) + J ) algorithm for re tangle interse tion, we then develop an O(n log2 (n) + J ) algorithm for the same problem. Although slower, this algorithm then allows us to interse t boxes within the same time bound. Various data stru tures will be needed, and these are explained rst.
3.7 Fa e-Boxing Te hniques
97
3.7.1 The Stati Interval Tree
This se tion develops an algorithm for the interval-interse tion problem: Problem
Given a set S of intervals I1 ; :::; In of the real line, store them in a data stru ture su h that, for any given query interval Q, we an determine all intervals in S that interse t Q. Moreover, the time needed to nd the interse ting intervals is proportional to log(n) and to the number of interse ting intervals. This problem is stati in the sense that the set S is xed. Eventually, the solution is adapted to a situation in whi h the set S hanges, thus solving a dynami version of the problem. This hange will be easy after the stati solution has been understood. The algorithm for interval interse tion uses a tree as basi data stru ture, to dire t the sear h for interse ting pairs. The nodes of the tree are annotated with various additional data stru tures. The underlying tree will be alled a range tree. After suitable embellishments, we obtain from it an interval tree. We explain the stru ture and onstru tion of these trees in stages. The algorithm will integrate these stages. Assume that the intervals are given as the pairs of numbers [a1 ; b1 ℄; : : : ; [an ; bn ℄ The range tree T arrying the interval information is a binary tree whose leaves are the distin t values ak and bk , in as ending order. Let u be an interior node of T, with left subtree T1 and right subtree T2 . Then the node u ontains a number x that lies between the maximum leaf value in T1 and the minimum leaf value in T2 . This number is alled the split value of u, and will be denoted split(u). Example 3.6: Assume we have intervals I1 = [ 1; 6℄, I2 = [ 2; 3℄, I3 = [0; 4℄, I4 = [2; 7℄, I5 = [3; 4℄, and I6 = [ 2; 1℄. The range tree T is shown in Figure 3.28. As split values, we have hosen the arithmeti mean of the maximum and minimum leaf values in the left and right subtree, respe tively. 3 Re all that the half-open interval (x; y ℄ is the set fz jx < z y g. Ea h node in the tree represents a half-open interval (x; y ℄ of the real line, alled its range. The tree root represents the half-open real line ( 1; 1℄. Let u be a node in the tree representing the range (x; y ℄, and assume that split(u) = s. Then the left hild of u represents the range (x; s℄, and the right hild represents the range (s; y ℄. In the pre eding example, the root represents the range ( 1; 1℄. The left hild, with split value 0:5, represents the range ( 1; 2:5℄, and the right hild, with split value 5, represents the range (2:5; 1℄. The interior node with split value 3.5 represents the range (2:5; 5℄.
Boolean Operations on Boundary Representation
98
2.5
5
−0.5
−2
3.5
1.0
−1.5
−1
0 Figure 3.28
2
3
6.5
4
6
7
Range Tree T
Given a set S of intervals, the range tree is easy to onstru t: Sort all interval endpoints in as ending order into a list L = (x1 ; x2 ; : : : ; xm ), where m 2n. For L we onstru t a range tree top-down by splitting L into two lists of equal size, L1 = (x1 ; : : : ; xp) and L2 = (xp+1 ; : : : ; xm ), where p = dm=2e. The tree's root has the split value (xp + xp+1 )=2. The left and right subtrees are now onstru ted from L1 and L2 , respe tively, in the same way. Note that the range-tree onstru tion requires O(n log(n)) steps. At the nodes of the range tree, we store the intervals of S. The interval [a; b℄ is stored at the unique node u satisfying the following: 1. [a; b℄ is ontained in the range of u. 2. [a; b℄ ontains split(u), but does not ontain the split value of any an estor of u. All intervals at u are stored in two lists, with the left endpoints in the list left sear h(u), sorted in as ending order, and the right endpoints in the list right sear h(u), sorted in des ending order. Example 3.7: In the range tree of Example 3.6, the intervals I1 ; I2 ; I3 ; and I4 are all stored at the tree root, the interval I5 is stored at the node with split value 3.5, and the interval I6 at the node with split value 1:5. 3 The intervals are stored in the tree in two phases. In the rst phase, the left sear h lists are onstru ted. Then, by an obvious modi ation, the right sear h lists are onstru ted. 1. Sort all intervals of S by the left endpoint ak in as ending order into a list L. 2. Propagate the list down into the tree, beginning at the root.
99
3.7 Fa e-Boxing Te hniques
(−2,−1,0,2)
(7,6,4,3) 2.5*
5*
−0.5* (3) (−2)
(−1)
−2
−1
0
2
Figure 3.29
3 Interval Tree
6.5
(4)
3.5*
1.0
−1.5*
4
6
7
T
3. At ea h node u, break the in oming list L into the lists L1 , L2 and L3 , where L1 ontains the intervals [a; b℄ with b < split(u), L2 ontains the intervals ontaining split(u), and L3 ontains the intervals [a; b℄ with split(u) < a. 4. Propagate the list L1 to the left des endant of u, propagate the list L3 to the right des endant of u, and store the intervals in L2 at u. The list L is split by sequentially s anning it. Ea h entry in it is s anned on e at ea h node at whi h the ontaining list is onsidered. Thus, it is s anned at most log(n) times. Therefore, all intervals are added to the range tree in O (n log(n)) steps. Re all that in a preorder traversal of a binary tree, the root of a subtree is visited, followed by its left and right subtrees being visited. By applying this rule re ursively, beginning with the root of the tree, all nodes are visited in preorder. The data stru ture, as developed, is not suÆ iently exible. The problem, brie y, is that the intervals may be lustered at very few tree nodes, so lo ating nodes with stored intervals may require too mu h sear hing. Thus, we link all nodes ontaining stored intervals in a doubly linked list. In this list, the nodes are in preorder. Furthermore, ea h tree node is marked if it, or any des endant of it, ontains stored intervals. It is lear that these annotations
an be added in O(n log(n)) steps. After we add these annotations, we have now onstru ted an interval tree. The interval tree for the intervals of the example is shown in Figure 3.29. The node marks are represented by asterisks. The doubly linked list of nonempty tree nodes is shown by dashed arrows.
Boolean Operations on Boundary Representation
100
P 1
P
P C
2
3
Node Sets Used for Querying for Interval Interse tion
Figure 3.30
3.7.2 Stati Interval Query
The problem of stati interval query is solved using an interval tree. Let be the set of intervals, tree for
S.
Q
S
= [a; b℄ the query interval. We onstru t an interval
P,
In the interval tree, we identify a node set
onsisting of all nodes
u
whose range has a nonempty interse tion with the query interval but is not
Q. We also identify a set C of nodes ea h of whose Q. Sin e, at ea h level in the tree, the set of represented
ompletely ontained in range is ontained in
ranges is a partition of the root range, the set ea h depth, and onsists of three paths, all nodes whose ranges ontain at the node
u1
P
P1 , P2 ,
has at most two nodes at
and
P3 .
Here
P1
onsists of
Q. The path P1 begins at the root and ends
whose split value is in
Q;
the path
P2
onsists of all nodes
Q, but not all of Q; and the path P3 onsists of all nodes whose range ontains the right endpoint b of Q, but not all of Q. Figure 3.30 shows these node sets s hemati ally. Note that the whose range ontains the left endpoint
nodes of
C
a
of
are in subtrees rooted in right des endants of nodes in
subtrees rooted in left des endants of nodes in point (i.e., if
a
= b) then the sets
Example 3.8:
Let
Q
P2 , P3 ,
and
P3 .
C
P2 ,
or in
If the query interval is a
are empty.
= [2; 5:5℄ be a query interval to be tested against
the intervals I1 through I6 . In the interval tree of Figure 3.29, the root is the only member of the set P1 , sin e its split value is in . The set P2 onsists
Q
of the nodes with split value
0:5 and 1, and the leaf labeled 2. The set
P3
onsists of the nodes with split value 5, 6.5, and the leaf labeled 6. The set C
ontains only those nodes in the subtree whose root has split value 3.5.
3
The overall stru ture of the algorithm for reporting all interse tions with the query interval is now as follows:
3.7 Fa e-Boxing Te hniques
101
1. Constru t an interval tree for S. 2. Identify the path P1 . 3. Identify the paths P2 and P3 . 4. By pro essing the path nodes and their des endants appropriately, identify all interse ting intervals. Step 2 is performed as follows. With u initially the tree root, identify the path P1 by sele ting the left (resp., right) des endant of u provided the split value s = split(u) satis es b < s (resp., s < a). We ontinue until we en ounter the rst node u1 whose split value is ontained in the interval Q. At u1 , we initiate onstru tion of P2 and P3 . The path P2 begins at the left des endant of u1 and is identi ed as follows. At node u, sele t the left (resp., right) des endant of u as the next node provided that a split(u) (resp., a > split(u)). The path P3 begins at the right des endant of u1 . To identify the remaining nodes, pi k at node u the left (resp., right) des endant provided that b split(u) (resp., b > split(u)). For degenerate query intervals [a; a℄, the paths P2 and P3 are empty. In this ase, are must be exer ised if a = split(u) for an interior node u. We now dis uss how to identify interse ting intervals along the paths Pi , i = 1; 2; 3. Let u be a node on one of the paths and s = split (u). If s < a, then an interval stored at u interse ts Q i its right endpoint y satis es a y . Hen e, by s anning the right endpoints of intervals stored at u, in des ending order, we identify all interse ting intervals in time proportional to their number. If b < s, then an interval at u interse ts Q i its left endpoint x satis es x b. These intervals are found by s anning the left endpoints in as ending order, in time proportional to their number. Finally, if s is in Q, then all intervals at u interse t Q. The nodes in C are in subtrees rooted in right des endants from nodes in P2 , and in left des endants of nodes in P3 . They are hara terized by the fa t that the range represented at any node in C is ompletely ontained within Q. Hen e, all intervals stored at su h nodes will interse t Q. For the sake of speed, we must avoid sear hing through all nodes of these subtrees. Intuitively, we nd the rst node in the set C that ontains intervals, using the node marks. To do so, we examine the nodes in P2 , beginning at the leaf and ending at the left des endant of u1 , until we nd a marked node that has a marked right des endant not ontained in P2 . If no su h node an be found, we try the analogous pro edure with the nodes in P3 , beginning at the right des endant of u1 and ending at the leaf, sear hing for a left des endant not in P3 . If no su h node an be found, then C ontains no intervals. Otherwise, we have found the leftmost node in C that ontains intervals. The remaining nodes in C ontaining intervals are found by following the linked list. It is not diÆ ult to see that the entire pro edure requires O(n log(n)) steps for onstru ting the interval tree, plus O(log(n) + J ) steps to report all interse tions, assuming J intervals interse t Q.
102
Boolean Operations on Boundary Representation
3.7.3 Re tangle Interse tion
We are given a set of re tangles whose interse ting pairs we want to nd. Ea h re tangle is given as the pair of intervals [x0 ; x1 ℄ [y0 ; y1 ℄, the re tangle's proje tion on the x and y axis, respe tively. The algorithm will use interval interse tion as one of its operations. Re tangle interse tion will be based on the line-sweep paradigm: By sweeping a line that is parallel to the x axis, in in reasing y dire tion, any interse ting re tangle pair must appear as an interse ting pair of x intervals. These intervals are the interse tion of the re tangles with the line. As the line sweeps upward, the interval [x0 ; x1 ℄ of the re tangle [x0 ; x1 ℄ [y0 ; y1 ℄ appears at the line position y0 , and disappears at the line position y1 . We sort the numbers xi and build an interval tree from them that initially does not ontain any stored intervals. In this way, we will be able to store ea h interval at some time during re tangle interse tion. Next, we sort the numbers yi in as ending order, and onsider them in sequen e. For ea h parti ular number y, we have a set of re tangles [x0 ; x1 ℄ [y; y1℄ beginning at y, and another set of re tangles [x0 ; x1 ℄ [y0 ; y ℄ ending at y. The beginning re tangles de ne a set of x intervals that must be inserted into the interval tree. Before insertion, ea h of these intervals is tested for interse tion with the intervals already in the tree. Interse ting intervals orrespond to re tangle interse tions. Thereafter, the x intervals of ending re tangles are deleted from the tree. It is lear that the outlined algorithm is
orre t, and that it does not report an interse ting pair of re tangles more than on e. Moreover, re tangle interse tion an be reported qui kly, based on the algorithm for interval interse tion, provided we an insert and delete intervals eÆ iently. Example 3.9: In Figure 3.31, we are at a y position at whi h we must insert the interval I4 orresponding to re tangle 4, and delete the interval I2
orresponding to re tangle 2. Before deleting I2 , we use I4 as query interval and report all interse tions. Then we delete I2 and insert I4 . 3 To support qui k interval insertion and deletion, we must modify the left sear h and right sear h lists, organizing them as balan ed sear h trees rather than as lists. These trees must support logarithmi -time insertion and deletion, and they must allow linear-time sequential a
ess to the stored values in sorted order. For example, a 2-3 tree will satisfy these requirements. An interval Q = [a; b℄ is inserted as follows: The interval is added to the node u1 that is last in the path P1 . Note that P1 was found as part of nding all intervals in the tree that interse t Q. Insertion into the left sear h and right sear h trees is routine. If there are already intervals stored at u1 , we are now done. Otherwise, we must update the linked list of nonempty tree nodes and, possibly, the node marks on the path from u1 to the tree root. Clearly, updating the node marks is trivial. Re all how to visit the nodes of a binary tree in inorder. Beginning at the root of the tree, a node v is visited as follows: If v is a leaf, then visit 0
0
103
3.7 Fa e-Boxing Te hniques
y
4
1
3
sweep line
2
x Figure 3.31
Interval Insertion During Re tangle Interse tion
it; otherwise, visit re ursively all nodes of the left subtree, then visit v, and nally visit the nodes of the right subtree. The order in whi h the tree nodes are en ountered is alled inorder. To lo ate where to insert u1 into the list of nonempty tree nodes, we sear h for the rst nonempty node su
eeding u1 in inorder. This node is found using the node marks. If u1 's right des endant uR is marked, then the needed nonempty tree node is found by exploring the leftmost marked path beginning with uR . If that node is not marked, we must ba k up toward the root until we nd a marked an estor who is not empty or whose right des endant is not in P1 and is marked. Clearly, lo ating this node requires no more than O(log(n)) steps. Now onsider deleting an interval Q. We rst nd the node u1 at whi h the interval is stored, and delete its endpoints from the sear h stru tures unless other intervals at u1 share that endpoint. If Q was the only interval at u1 , we must delete u1 from the linked list of nonempty nodes, and, possibly, delete the node mark of u1 and some of its an estors. Be ause the node list is doubly linked, node deletion is simple. In summary, we have shown that intervals an be inserted and deleted in time proportional to log(n). In onsequen e, interse tions among a set of n re tangles an be reported in O(n log(n) + J) steps, where J is the number of interse ting pairs. The simpli ity of the algorithm makes its implementation quite pra ti al.
104
Boolean Operations on Boundary Representation
3.7.4 The Segment Tree
The re tangle-interse tion algorithm des ribed previously is based on dynami interval interse tion. In prin iple, a similar extension to three dimensions is possible: Sweep a plane in the z dire tion and test, at ertain positions, whether there are interse tions among the re tangles in whi h the boxes interse t the sweep plane. We do not use the O(n log(n) + J ) re tangle interse tion for this purpose, sin e the re ursive line sweeps for nding interse ting re tangles would onsume too mu h time. Instead, we develop a more exible data stru ture that supports re tangle interse tion without a line sweep. This data stru ture is alled a segment tree, and is an annotated balan ed binary sear h tree, re ording a set of intervals. We are given n intervals [ak ; bk ℄ with distin t endpoints i , where 1 i m and m = 2n. We assume that the k are enumerated in as ending order. The underlying binary sear h tree has 2m + 1 leaves representing, from left to right, the partition of the real line indu ed by the endpoints.
(
1
) [ ℄ ( 1 ; 2 ); [ 2 ℄; : : : ; [ m ℄; ( m ; +1)
; 1 ; 1 ;
The tree is onstru ted in mu h the same way as the range tree. Like the range tree, the interior nodes have split values to support binary sear h, only now we must indi ate, at ea h node, whether the left des endant is hosen if the query value is less than, or not greater than, the split value. An interior node represents a segment that is the union of the segments of its des endants. We store an interval Ik = [ak ; bk ℄ in this tree at a node u provided Ik ontains the range of u but not the range of u's an estor. When we have ompleted this annotation, we have onstru ted a segment tree. Note that Ik an be stored at more than one tree node, but not at more than 2h nodes, where h is the tree height. The ranges at whi h a given interval is stored are a partition of the interval. It is not diÆ ult to see that a segment tree an be
onstru ted in O(n log(n)) steps. Example 3.10: The segment tree for the intervals I1 = [2; 3℄, I2 = [5; 7℄, I3 = [2; 4℄, and I4 = [3; 5℄ is shown in Figure 3.32. The interval [3,5℄ is stored at the two nodes marked with asterisks. 3 Now onsider the problem of lo ating all those intervals in a set S that
ontain a query point q. We pro eed as follows. From S, we onstru t a segment tree. Using this tree as a binary sear h tree, we lo ate the leaf in whose range q lies. Clearly, all intervals stored at the nodes on the path from the tree root to the leaf ontaining q will ontain q. Furthermore, sin e leaves represent disjoint segments, no other interval of S an ontain q. Note also that no interval stored along the path is repeated. Therefore, all
ontaining intervals an be found in O(log(n) + J ) steps, ignoring the time for onstru ting the segment tree.
3.7 Fa e-Boxing Te hniques
105