Вы находитесь на странице: 1из 111

Solid modelling with faceted primitives

F.W. Jansen

Delft University Press TR diss 1555


J

U y tp

Solid modelling with faceted primitives

Solid modelling with faceted primitives

Proefschrift ter verkrijging van de graad van doctor aan de Technische Universiteit Delft, op gezag van de Rector magnificus prof. dr. J.M. Dirken, in het openbaar te verdedigen ten overstaan van een commissie aangewezen door het College van Dekanen op dinsdag 1 september 1987 te 16.00 uur door Frederik Willem Jansen geboren te Amsterdam ingenieur Industrile Vormgeving

TR diss 1555

Dit proefschrift is goedgekeurd door de promotoren Prof. W.H. Crouwel Prof. dr. D.J. McConalogue

Solid modelling with faceted primitives

vn

Contents Preface xi Part 1: Design and visualisation of solid models 1. Design representations 3 1.1 Modelling 1.2 Systematic methods 1.3 Types of design representations 1.4 CAD representations 1.5 Summary and conclusions 2. Solid modelling 11 2.1 Geometric representations 2.2 Constructive Solid Geometry 2.3 Internal representations 2.4 Visualisation of the solid model 2.5 Solid modelling with faceted primitives Part 2: Display of CSG polygon models 3. Faceted modelling 25 3.1 Internal and external data structures 3.2 Faceted primitives 3.3 Integrity checking 4. CSG evaluation 37 4.1 Introduction 4.2 Tree-pruning 4.3 CSG-tree traversal methods 4.4 CSG-tree evaluation by bitwise operations 4.5 Exploiting CSG coherence 4.6 Experiments and conclusions 5. Display and conversion algorithms 57 5.1 Spatial subdivision 5.2 CSG list priority algorithm 5.3 CSG ray tracing algorithm 5.4 Conversions 5.5 Summary and conclusions

vm Solid modelling with faceted primitives

Part 3: Display of CSG halfspace models 6. CSG depth-buffering techniques 73 6.1 Introduction 6.2 Active tree 6.3 Tree restructuring 6.4 A tree traversal algorithm 7. Hardware implementations 83 7.1 Introduction 7.2 Display systems 7.3 CSG halfspace models 7.4 A multi-processor implementation Part 4: Conclusions 8. Conclusions 97 8.1 Solid modelling and industrial design 8.2 Further research References 99 Summary 103 Samenvatting 104 Curriculum vitae 10S Acknowledgements 106 The pictures on the backpages are generated with the program FACET, an experimental program incorporating the algorithms described in part 2 and part 3. Plate 1. Wire-frame drawing of primitives. Plate 2. Wire-frame drawing of sweep object. Plate 3. Two cylinders at different modelling accuracy. Plate 4. Boolean operations. Plate 5. Primitive solids. Plate 6. Projective display and ray tracing. Plate 7. Carburettor. Plate 8. Car. Plate 9. Rietveld house.

Solid modelling with faceted primitives D C

Parts of this thesis are revised versions of earlier published material:

Part 2: Jansen, F.W. [1985], A CSG list priority hidden-surface algorithm, Proceedings Eurographics'85 Conference, 51-62, Elseviers Science Publishers, Amsterdam. Tamminen, M., and Jansen, F.W. [1985], An integrity filter for recursive subdivision meshes, Computer and Graphics 9(4), 351-363. Jansen, F.W. [1986], Data structures for ray tracing, In: Data structures for raster graphics, Kessener, L.R.A., Peters, F.J., Lierop, M.L.P. van (eds), Springer Verlag, 57-73. Jansen, F.W., Evaluation of Boolean object expressions for CSG hidden-surface algorithms. Submitted for publication. Part 3: Jansen, F.W [1986], A pixel-parallel hidden-surface algorithm for constructive solid geometry, Proceedings Eurographics'86 Conference, 29-40, Elseviers Science Publishers, Amsterdam. Jansen, F.W. [1987], CSG hidden-surface algorithms for VLSI hardware systems, In: Advances on Graphics Hardware I, W. Strasser (ed.), Springer Verlag. Jansen, F.W. and Sutherland, R.J. [1987], Display of solid models with a multiprocessor system, Proceedings Eurographics'87, Elseviers Science Publishers, Amsterdam.

Solid modelling with faceted primitives

XI

Preface

The subject of the research described in this thesis is the visualisation of solid models for Computer-Aided Design (CAD). Solid modelling is concerned with the computer representation of three-dimensional objects. For the description of solids in terms of their surfaces, two approaches can be taken: the boundary of a solid can be described with an exact surface representation or be approximated with flat surface elements (facets). The second approach has the following advantages: the shape domain is fairly unrestricted, the processing of the surface elements is intrinsically simple, and the amount of processing is dependent on the faceting tolerance (accuracy of the approximation). However, the number of facets needed to give a visual quality that is comparable with an exact representation will be very large. The central theme of this thesis is: given the fairly unrestricted shape domain, and the large number of facets necessary to give the same image quality as with the exact representation, what techniques can be developed to process the large number of facets efficiently? Two approaches have been investigated: a software-oriented approach that is described in part 2, and a hardware oriented approach that is described in part 3. Part 1 provides a general introduction to modelling for industrial design, the background of this research. The role of design representations in the design process and their counterparts in CAD are discussed. Further, the basic concepts of solid modelling and the techniques for display of solid models are introduced. The solid modelling method described in part 2 is based on polygon approximation. The main theme there is that the large number of polygons needed for an accurate description of curved surfaces makes it necessary to use additional data structures. Two methods are applied for enhancing the processing, sorting and search of these surface elements: a filter for processing recursive subdivided surface meshes and a spatial index for efficient geometric search. A third method reduces the number of logical computations involved in the display of solid models. Algorithms for the input, visualisation and conversion of solid models are given. The development of VLSI-based display systems has stimulated the development of algorithms that would not have been feasible for a single processor configuration, but which give nearly real-time performance with these new display systems. A depth-buffer algorithm that can be used with these systems is described in part 3. Algorithms are given for linear halfspace models, but the same techniques also apply for higher-order surface representations. Further a version for a multi-processor system is given. In part 4, the results are summarised, conclusions are drawn and directions for further research are suggested.

Part 1 Design and visualisation of solid models

CAD techniques offer facilities to enter, manipulate and interrogate design representations (descriptions and models of the design product). Three design representations are discussed: the design process representation, the functional model and the representational model. The representational model is the description of the design as it is documented and visualised by the designer in drawings and threedimensional models. These design representations are comparable with the CAD representations that are currently proposed for use within CAD systems: the conceptual model, the assembly model and the geometric model. For our subject, we focus on the input and display of the geometric model. Solid modelling representations are discussed and methods for the design and visualisation of solid models are described. This leads to a scenario for the input, interactive viewing and highquality rendering of solid models, and the central theme of this thesis: the display of faceted models.

Design representations

1. Design representations The application of computer techniques to industrial design requires intermediate representations of the design. This situation is not new for designers. Designers have always used text, graphical representations and three-dimensional models to describe and visualise their intentions, because it is seldom possible or most of the time too expensive, to produce a real-world product immediately. Computer techniques extend the possibilities for the designer to 'model' the design and design performances. The introduction of these new methods and representations to complement or replace conventional techniques poses the question of their role in the design process and of their effect on the quality and efficiency of the design process. Several design representations and CAD techniques to generate and manipulate them are discussed.
1.1 Modelling

A model is a description of an object or process that describes a limited set of the attributes and relationships possessed by the original object or process. The use of the computer for design requires a computational model that replaces the original objects and object representations by a computationally convenient representation that captures those attributes possessed of the original object that permit the efficient performance of the relevant tasks within the planned scope or function of the model [Faux, 1986]. The question is whether the computational model models the characteristic properties of objects sufficiently to be useful in the design practice. In other words, is it possible to design with a computer representation of the design and the design process without unduly limiting the shape domain and without reducing the quality of the interaction that the designer is used to with his conventional tools (paper and pencil)? In order to answer these questions, it is necessary to know what kind of activities are carried out by the designer and which representations are sufficient to capture the relevant information. Without restricting other aspects of design, our main interest will be in this information processing: the process of design is the translation of information in the form of requirements, constraints and experience into potential solutions that are considered by the designer to meet required performance characteristics [Luckman, 1967]. Design methodology is concerned with the development and analysis of design methods and design representations. Design methods are techniques and procedures that sustain and enhance the design process, and design representations are sources of data for describing attributes and relationships possessed by objects and which allow the evaluation of useful properties of objects. In Archer[1968] a logical model is proposed for the design process and design activities. In the following sections, we seek to extend this model by adding design representations that are able to capture the relevant design information and support the necessary manipulations.

Design representations

1.2 Systematic methods Design methodology has been influenced during the 1960s by research in problem solving, computer techniques and management theory [Cross, 1984]. It was the generally accepted idea that design could benefit from systematic methods taken from these disciplines. Central to the systematic methods approach was a twofold decomposition of the design process: a decomposition of design activities into analysis, synthesis and evaluation, and a decomposition of the complex design problem into simpler sub-problems that could be solved with appropriate tools and methods. This decomposition was based on the assumption that there is a tool for each substage, whether it is an abstract mathematical method from operational research or a concrete tool such as prototyping. Some tools are used in the synthesis phase of design, others are used in the development and evaluation phase to simulate and evaluate the design concept and its embodiment. The decomposition of the design problem into elementary subtasks and into subproblems enhances the use of these tools. In a second step, the solutions obtained could then be combined into an optimal solution. Archer[1968] formulates on the basis of these assumptions a logical model of the design process that has the following components: the design program, the systematic model and the operational model. The design program describes the design process and the design activities through the different phases of the design process, such as analysis, sketch design, preliminary design, prototyping and production. The systematic model, or disciplinary model, models the functional properties of the design with respect to aesthetics, costs, manufacture, strength, etc.. It can be viewed as a parametrised formulation of a sub-problem, a system to generate solutions. The operational model uses a systematic model, in combination with analogues, to measure and to optimise the performance of the design with respect to specific functions. Analogues are alpha-numeric, mathematical, graphical or threedimensional representations of the design product. In each phase of the design process, the design problem is decomposed into sub-problems and brought to a solution by an appropriate operational model (see fig. 1.1). The operational model (which can be seen as an evaluation process) applies a systematic model in combination with an analogue to evaluate the systematic model and to find a (local) optimum solution. As the design process proceeds, the systematic model is refined and the conception of the solution grows. Among the analogues, drawings and three-dimensional models are particularly important tools for the designer. In the synthesis phase, sketches and drawings are used to conceptualise and visualise ideas and design proposals. In the development phase, renderings are used to give a realistic impression of the product, and technical drawings to document it for machining and assembly. Moreover, sketches and renderings record the design process itself: the portfolio of sketches and drawings are a registration of the choices made and steps taken during the design process. The designer can return to these documented activities in a later phase or, if desired, can explore alternatives in a subsequent design study. Besides these obvious uses, Archer points to the role of analogue: drawings and models are used to

Design representations

Real world Operational model Analogues 0m0 i

TIT

"^;1tf"
Smj

"i

fettl ^kM
FFF^ Il i i h , ' 1' i
r*=rz phase 7

Systematic model Design program-^\-~~ Problems Design process

m
W '-

~^E

Di 7

^E

ny^_Jt^L-^-n^4^
phase 2 phase 3

Figure 1.1. Logical model of design process.

simulate the performance of the design in certain aspects. They allow the designer to study the configuration of components, the assembly and construction of parts, and the functional and aesthetic quality of the product. 1.3 Types of design representations Although Archer's logical model of the design process proposes a useful scheme for design activities (processes), no special methods or techniques (other than conventional methods) have been suggested to make this scheme operational in order to improve the traditional design practice. Further, in design methodology, interest moved from the structure of the design process to the structure of design itself, i.e. the psychological and logical aspects of the design activity. Also, important elements of the systematic methods, such as a thorough analysis of the design problem before synthesis and evaluation, were replaced by other procedures emphasising the creative and generator-conjecture aspects of design. However, there seems to be no specific reason to discard Archer's logical model as long as the proposed structure of the design process supports creative activities and does not supplant them. A systematic approach to design and the use of design representations may even support the creative activities. In this context it is worthwhile to notice that drawing and model making (in the traditional sense) is also a creative process. It stimulates the generation of new ideas and may gradually lead to solutions that were not or even could not have been envisaged before hand. The translation and conversion of ideas in visual concepts may very well be a major source of inspiration. A second observation teaches us that there is an essential difference between the synthesis of a design and its evaluation. A design concept may be very well

Design representations

analysed in terms of a systematic model. Given the basic solution, the design may then be optimised with respect to that concept. In the synthesis phase, however, no systematic model can guide the designer. The best he can get are some hints in the form of 'issues' that come from his analysis of the problem and that give some direction to his search. Here the word search best describes design in this phase. The search, however, is made much easier if design representations can easily be created, evaluated and modified. For optimal search, fast response and freedom of manipulation is essential. The generation of concepts and the gradual improvement of the design embodiment involves a repeated regeneration of drawings and models. From this point of view most design activities arc concerned with information processing of geometric and graphical data. It is here that the computer, as an information processing machine, enters the design practice. With the computer, it is easy to input, store and retrieve data and to display this information, whether text, graphics, or three-dimensional shape data, on a graphics display, a plotter, or a numerical controlled milling machine. With this computer or rather CAD system, the designer can analyse data, convert them into different representations and use them to check performances, to simulate the visual appearance and to document the design product for production. Preferably, the product information is maintained in the system and can be used repeatedly for different applications, instead of redrawing or reshaping the model over and over again. However, in order to store and retrieve the data quickly and to handle the data automatically, it has to be structured. To make Archer's logical model operational for this purpose, three design representations are proposed: a design process representation, a functional model and arepresentationalmodel (see fig. 1.2). The design process representation documents the design program and stores all relevant information concerning the requirements, intermediate proposals, results of analysis, etc.. The functional model describes the product in functional components that can be evaluated by the operational model. The functional model is a conception of the solution as described by the systematic model. The representational model describes the product, its geometry and material specification, explicitly, or implicitly by procedures to produce the product. The representational model may be derived from the functional model, because it is the explicit formulation of the 'conceptual' solution. The representational model serves two purposes: it describes the solution and it may function as an analogue (computer model) or may be used to generate analogues (for instance graphics). This double role makes its use very efficient. These three designrepresentationsare the carriers of information for both the design and the design process. The basic issue concerning the use of computers in design is whether these design representations can be modelled successfully in CAD.

Design representations 7

Real world Operational model Analogues Om,

rrr
Rm,

Om-,

'lit
V
Rm->

*rttf
*3

a
I

^=E

Representational model Functional model Design process | representation r


i

Rm3

TE
Fm.

Fm-,

XL
Fm3

Design program-* Problems Design process ! p/?ase 7

l-p-d,^ FFp-d.,^ ^ f i ^
p/iase / p/iase 3

Figure 1.2. Design representations. 1.4 CAD-representations A Computer-Aided Design and Computer-Aided Manufacturing (CAD/CAM) system is an information processing system for the design and production of industrial products. Central to this information processing is the input, storage and interrogation of the product data that describe the product and its manufacturing specification. The product data are stored in the product model. Because the product model serves as the intermediary for all activities on the product data, its structure is basic in maintaining the integrity and consistency of the product data. Further, the product model has to support the communication between different partners who enter and interrogate the data, and application programs that use data from the product model to analyse, document or manufacture the product The information described in a technical drawing is two-fold: it is a geometric description of the product specified in the cross-sections by dimensioning and tolerancing, and secondly, it is the specification of the material and the manufacture in the form of the symbols and text to instruct the production planning and quality control. The central issue in CAD/CAM is the modelling of all this information in a product model inside the computer [Wesley, 1980]. For some time, the paradigm in CAD has been to replace the engineering drawing by a complete threedimensional geometric description of the product. This geometric model would then serve as the central data base for all inquiries, whether for design analysis or for production and assembly purposes. At first this approach seemed adequate, because sufficient information could be derived from the geometric model to

Design representations

calculate views and cross-sections of the model, to calculate mass properties and to feed a numerical controlled milling machine. Later, however, it turned out that for a large range of other inquiries the elementary geometric information did not provide enough clues to cope with all situations. For example, from a purely geometric description, it is often hard to re-interpret a shape to be a cylindrical hole that can be drilled instead of a free-form region that should be milled. If it was the intention of the designer to drill a hole at that position, then that information should be kept with the model and be available for interrogation. Further, all this additional information of a technical drawing is difficult to attach to the geometric model. Within the international standardisation bodies (PDES.STEP), product data representations are being developed that provide a more comprehensive product modelling approach than only the. geometric description of the product [PDES, 1986]. The main advantages of this approach are the storage of all data concerning the design process into a conceptual model, and of the functional description of the product into an assembly model. The conceptual model stores all project information, including planning and cost calculations. Further, it provides an infra-structure and an information modelling method (meta-model) for inter-system communication. It also contains the more specific product data infonnation such as the assembly model and the geometric model. The assembly model is a hierarchy of components, each described by a set of features. A feature is an abstraction of some area of interest on a part [PDDI, 1984], such as holes, rims, depressions. See [Faux, 1986] for a recent overview of feature modelling. Bach feature has one or several meanings attached to it, each relevant for a certain application area. An application program translates a feature into an entity relevant to its own functional context, or it converts features into features that are specific for that application, for instance, design features into manufacturing features. Feature modelling aims at the description of the functional aspects and relations between components, such as dimensioning and tolerancing, design constraints and assembly specifications. However, the feature description encompasses also a geometric description of the part. Thus, if desired a geometric model can be derived from the feature description by converting the procedural description of the features into a geometric description. 1.5 Discussion and conclusions Interest in systematic methods for design has resulted in the analysis of the design as a multi-staged process, and in the recognition that design representations (descriptions and models of the design product) are important development tools for the industrial designer. For a systematic design process, three design representations are relevant: the design process representation, the functional model, and therepresentationalmodel. The design process representation records the design process, the functional model is used to analyse the perfonnances of the design and the representational model

Design representations

documents the design embodiment. These three design representations are covered to a great extent by the three CAD design representations, the conceptual model, the assembly model, and the geometric model (see fig. 1.3).

logical model design process

design representations

I CAD representations

CAD techniques

design program - design process representation drawings 3-d models


i

conceptual model

information modelling computer graphics numerical control, etc. _ solid modelling feature modelling

analogues

drawings 3-d models geometric model assembly model

\_

, systematic

representational model
t

functional model

Figure 1.3. Overview of design representations.

To use these models as tools, the designer must be able to enter and manipulate these representations in'an easy and effective way. Central to this issue is the quality of the interface between the designer and the system. This quality is to a large extent dependent on the interaction of the designer with the representational model, the geometric description of the desiga This interaction has two aspects: the input and definition of the geometric model, and the display of the model. Effective design requires powerful and easy to use input methods. Solid modelling has improved on existing methods by offering a volume modelling approach, freeing the user from the tedious task of specifying a large number of coordinates. However, more powerful and sophisticated specification techniques are still needed. Also model specification has to be brought into the conceptualisation phase to allow easy definition and manipulation of design concepts. A great deal of improvement to existing techniques will have to be realised for the interaction between designer and machine to be optimised. The second aspect of the interaction between the designer and the system is the display of the geometric model, the subject of this thesis. The display of geometric models serves three purposes: input of the model, viewing for inspection and analysis, and high-quality rendering for the purpose of presentation. These three types of visualisation show different trade-offs between speed and image quality. Input requires direct feedback, while high-quality rendering is less critical with respect to time, because image quality is most important. However, for viewing there is a need for image generation that is both fast and good in image quality. In

10

Design representations

addition to the rendering quality, the time to generate pictures is also dependent on the complexity of the model. It is therefore worthwhile to study methods and techniques for displaying complex three-dimensional objects within a reasonable time. As an introduction, the following chapter discusses standard modelling and display techniques for solid models and, in subsequent chapters, techniques to improve the efficiency of these methods are presented.

Solid modelling

11

2. Solid modelling Geometric modelling is concerned with the input, storage and interrogation of geometric data, specifically for the description of products to be designed and manufactured. Several geometric representation schemes are used in CAD/CAMsystems. Among these, solid modelling aims at a complete and unambiguous representation of rigid solid objects. A central method in solid modelling is Constructive Solid Geometry (CSG) which defines objects as combinations of primitive solids. These primitive solids can internally be described with an exact or with an approximated boundary, i.e. as solids bounded with well-behaved (smooth) surfaces or as polyhedra with a faceted boundary. The use of these representations is discussed here in the context of visualisation of the model for interactive input and viewing, and high-quality rendering.
2.1 Geometric representations

The geometric modeller is the part of a CAD/CAM system that processes geometric data representations of objects. To be useful within an application area, the modeller should meet the following requirements: The geometric coverage, i.e. the range of shapes that can be represented, should be adequate for the area of application. The system should provide easy-to-use and efficient tools for creating and editing these models. The geometric representations should be reliable and efficient, i.e. the stored information should provide accurate answers to geometric queries within a reasonable time.

To meet die reliability requirement, die geometricrepresentationsand me operations (algorithmic procedures) that manipulate these representations (without interference of the user) should maintain the integrity of the model, i.e. each representation should be valid and complete. For a formal discussion on geometric representations see [Requicha, 1980]. Three geometric modelling methods are used in CAD: wire-frame modelling, surface modelling and solid modelling. A wire-frame model is the most elementary: the object is represented by a set of contour or cross-sectional curves (fig. 2.1b). The wire-frame model is sufficient to provide the information for a wire-frame drawing of the object which, for instance, may be used for the interactive input of die model. However, the absence of an unambiguous description of the boundary of die solid limits the use of this method for other applications.

12

Solid modelling

a e
a. object b. wire-frame c. surface model d. solid model

Figure 2.1. The three main representations in geometric modelling: wire frame model, surface model and solid model.

The second method, surface modelling, defines an object as a collection of surface elements that describe the boundary of the object (fig. 2.1c). The volume is here defined implicitly. Several types of surface elements can be used: polygons ( flat surfaces bounded by straight lines), analytical surfaces (for instance parts of spherical and cylindrical surfaces) and more general free-form surfaces (for instance parametric surfaces, such as defined by the Bezier and B-spline method). The shape domain is fairly unrestricted, being only limited by the effort needed to input complex shapes. Most CAD/CAM-systems nowadays are based on surface modelling. Surface models provide a more complete description than wire-frame models, but because the model is constructed by adding together parts of the boundary under control of the user, the result may be an invalid - and hence unmachinable - object. Both the need to keep the geometric model consistent under geometric operations, and the desirability of offering the user a more hierarchical approach to the definition of the geometric model, have created an increasing interest in solid modelling techniques. Solid modelling offers a volume modelling approach: the user is provided with a set of elementary volumes and a set of transformations and operations that can be performed on them (fig. 2.1d). The transformations and operations are used to position and to combine the volumes to form composite solids. The set of transformations comprises translation, rotation, scaling, and skewing. The set of operations includes the Boolean operations union, difference, and intersection, which corresponds with adding volumes, subtracting volumes and taking the common part of two volumes (fig. 2.2). Constructive Solid Geometry (CSG) embodies this 'constructive' approach in its most explicit form.

Solid modelling

13

AuB a. union

A-B b. difference

8-A

AnB c. intersection

Figure 2.2. Boolean operations: union, difference and intersection.

The elementary volumes may be defined in terms of polygons or analytical surfaces, but whatever basic surfaces are used, they should be complete, consistent and valid object descriptions. If the basic volumes are consistent, the system guarantees that the composite solid resulting from its operations is also consistent, thereby freeing the user from having to check it for non-existence or other deficiences. Although the basic volume modelling approach is shared by all solid modellers, the internal representation of the geometric model differs widely among systems. Also within one system often more than one representation is usually maintained. According to the main internal representation, modellers are classified as CSG, boundary or volumetric modellers.
2.2 Constructive Solid Geometry

Constructive Solid Geometry (CSG) defines objects by applying transformations and Boolean operations to elementary volumes, such as block, sphere, cylinder and cone [Requicha, 1980]. The CSG defined object is internally represented as a binary tree (CSG-tree). The primitive solids are positioned at the leaves and the internal (composite) nodes contain the Boolean operations; transformations can be stored both at the leave nodes as well as at the internal nodes. The internal nodes represent the subsolids defined by performing the transformations and the set operation of that node to its two subsolids. The root node represents the resulting composite object (fig. 2.3). The modelling range of the CSG representation is the set of solids that can be generated by combining primitive solids; it is thus dependent on the set of available primitive solids. A standard repertoire of primitives is offered by primitive instancing: solids are instances of pre-defined elementary volumes, such as block, sphere, cone and cylinder (fig. 2.4a). A powerful extension is formed by the 'sweep' primitives (fig. 2.4b). The sweep primitive is the volume that is swept by a base plane, bounded by a 2-D curve (contour), that is moved along a 3-D curve (trajectory). Scaling and rotation of the contour during the translation further enlarge the shape domain. Specific instances are: - Translational sweep: the contour is a curve and the trajectory is a line; this

14

Solid modelling

A = block 20 12 6 B = block 16 8 8 move B 2 -1 C = cylinder K 10 move C z -2 Object = A - IBnCl a. commands

/\ i /\
B

b. CSG-tree

i&
c. primitive solids d. positioned e. resulting object

Figure 2.3. Example of CSG representation.

method models extrusion-shapes. - Rotational sweep: the contour is a curve and the trajectory is a circle; this models rotational-symmetric shapes. - General sweep: both the contour and trajectory are general curves; this models a large family of profiles (fig. 2.5a). Bending can be modelled by using free-form curves for the trajectory. Rotation of the contour leads to twisted shapes (see also [Post and Klok, 1986]).

A basic primitives

b. sweep

c. free-form

Figure 2.4. Primitive solids.

Solid modelling

IS

A related method is lofting, also referred to as skinning or general duct surfaces. Instead of one contour that is swept along a trajectory, several contours are spanned along a central spine [Tiller, 1983]. The surface of the object interpolates these contours (fig. 2.5b). More general-curved surface elements that may be part of a solid are blends, roundings and free-form surfaces (fig. 2.4c). Some of these shapes result from shape operators that locally add or subtract material. In [Varady and Pratt, 1984] an overview is given of these shape operations. Most of them, however, are difficult to incorporate in a solid modelling scheme because of the difficulty of guaranteeing the integrity of the resulting solid.

a. sweep Figure 2.5. Sweep and lofting.

b. lofting

The CSG representation can be entered by alpha-numeric specification of the primitives, transformations and operations (fig. 2.3a). Alternatively, a graphics interface may be used to select items from a menu and position primitives interactively. Additional modelling facilities may be provided in the form of libraries, history files that can be edited [Takala, 1985], or design process representations [Chiyokura and Kimura, 1985]. Further, special languages have been developed for procedural modelling. For an example see [van Wijk, 1986]. The combination of graphical and procedural modelling, together with new developments in user interface management systems, feature modelling and programming languages, offers a new and challenging area of research and opens new opportunities to improve the design and manipulation of the geometric model, mentioned in section 1.5. 2.3 Internal representations Internally, the primitive solids are converted into one of the following representations: a halfspace model, a boundary model or a volumetric model. The CSGrepresentation is a suitable representation for the input of the model but, because it is defined as a combination of solids (or halfspaces), no explicit boundary or volumetric information is available. To obtain this information, the CSG

16

Solid modelling

(halfspace) model is converted into one single boundary or volumetric representation. 23.1 Halfspace models Halfspace models are formed by a combination of halfspaces (fig. 2.6). A halfspace is defined by an unbounded surface that divides space into an object-side (material) and a non-object side (empty).

H=

hlnh2nh3nhi

object = h,nh2 nh3nht, nhsnh6 b. halfspace model 13D)

a. halfspace model (2D) Figure 2.6. Halfspace modelling.

A linear halfspace is an unbounded volume of which each point satisfies the linear equation ax+by+cz+d S 0. A finite solid is defined by the Boolean combination of four or more linear halfspaces. Replacing every occurrence of a primitive in the CSG-tree by its halfspace subtree gives rise to a CSG halfspace model, a CSG-tree of only halfspaces. 23.2 Boundary representations Surface models are formed by constructing a closed boundary of surface elements, e.g. polygons (fig. 2.7). Boundary models are surface models that satisfy two additional constraints: the integrity of the surface (the connectivity of the surface elements) and the integrity of the solid (two surfaces are not allowed to intersect, except at a common edge) have to be preserved. For a detailed discussion on these 'local' and 'global' properties, see [Mantyla, 1983]. Generally, the boundary representation is defined as an hierarchical data structure of faces, edges and vertices. The vertices defined by coordinate triples, represent the geometric part of the data. The 'topology' is defined by references from object to faces, and from faces to vertices. Additional references, e.g. from face to face, can be included in the data-structure to improve the efficiency of geometric inquiries. A well-known example is the winged-edge representation [Baumgart, 1975]. The boundary modelling scheme was introduced by Braid[1973] and Baumgart[1975] and theoretically founded by the contributions of Requicha[1980], Tilove[1980] and Mantyla[1982].

Solid modelling

17

H
a. polygon b. polygon model

object

zlq.^.Pj.Pi.Ps.Pt)

Figure 2.7. Polygon modelling.

The composite CSG-rep can be converted into a (single) boundary representation by a boundary evaluation. This conversion is performed by splitting intersecting faces of primitive solids and classifying these as 'on' or 'off to determine whether they belong to the composite solid or not. Finally, the faces that classify as 'on' are merged into a new boundary representation (see fig. 2.9a). 233 Volumetric representations A volumetric representation is created by a decomposition of the solid into regular volume elements, usually cubes (fig. 2.8). The elementary form of this Spatial Enumeration (SE-rep) or block model, is a spatial array of 'voxels', volume elements of the same size.

a. volume element

b. spatial enumeration

Figure 2.8. Volumetric representation.

A more compact representation can be obtained by an adaptive binary or octary recursive subdivision of object space, resulting in a bintree and octree representation

18

Solid modelling

[Meagher, 1982], [Samet and Tamminen, 1985]. Here the object is represented as a tree of which each leaf node corresponds to a region of three-dimensional space that is classified as 'in' or 'out' the object Volumetric modellers find their natural application where the basic input is the output from a scanner that samples data on a regular grid, such as in computer tomography. A CSG object can be converted into a volumetric representation by a 'spatial evaluation'. Object space is subdivided into regular volume elements. Next these are classified as 'in' or 'out' with respect to the individual primitives of the CSG object. The individual classifications are then combined according to the CSG-tree. Depending on the spatial subdivision strategy, adjacent cells with the same classification can be merged into larger blocks (fig. 2.9b). A more efficient version of this conversion algorithm interrogates the CSG object with a bundle of parallel rays, and converts the intersection trajectories of these rays into rows of 'voxels' [Lee and Requicha, 1982].

a. boundary representation

b volumetric

representation

Figure 2.9 Boundary and volumetric representation (object of fig. 2.3).

Both the boundary and volumetric representations are typically data-oriented representations, in that all geometric information is converted into its most basic form: faces, edges and vertices, or regular volume elements. With these conversions, all higher order surface information is lost and it is difficult to recreate this information again from the data. It is therefore good practice to maintain a CSG representation along with a boundary or volumetric representation. 23.4 Faceted models Boundary and halfspace models may consist of curved surfaces defined by quadratic, cubic and higher-order implicit or parametric equations. With these exact mathematical representations, the boundary is described with well-behaved (smooth) surfaces (surfaces with at least first derivative continuity). The numerical representation is compact; a limited number of coefficients is sufficient to describe fairly complex shapes and their properties. However, the processing may be rather complex, and different for each type of surface. Curved

Solid modelling

19

surfaces can be approximated within a certain tolerance by polygons or linear halfspaces. Linear approximations of curved surfaces are less compact but easier to process than higher-order surface descriptions, although the usually large number of surface elements may pose a problem of its own. An inherent drawback of linear approximations is the 'faceted' appearance of surfaces that were intended to be smooth. This faceted appearance can only be partly camouflaged for the eye by smooth shading, a technique to interpolate an intensity shade over a polygon in a way that suggests a curved surface. 2.4 Visualisation of the solid model The model can be visualised with line drawings and shaded pictures. Line drawings of different views of the object are a suitable representation for graphical interaction on the model: by relating points in different views, three-dimensional data about vertices, edges and faces can be input. A drawback of line drawings is their insufficient representation of depth, and therefore additional depth cues (motion, intensity modulation, hidden-line removal, etc.) have to be added to give an unambiguous view of the model. Shaded pictures give a more realistic impression, but they require more processing, i.e. for calculating the visible surfaces. There are two different drawing techniques for shaded pictures: projective methods and ray tracing. Projective methods are based on the drawing analogue: surface contours are projected on the image plane and the interior area is set to the calculated shading intensity of the object. Ray tracing is based on the camera analogue: for every point of the image plane the light intensity received from the scene is calculated. Ray tracing effectively models optical effects, such as mirroring reflections, cast shadows and transparency with refraction, but it is slow. Projective methods lack the image quality of ray tracing, but are an order of magnitude faster. 2.4.1 Projective algorithms Central to all projective hidden-surface methods are the projection and scan-conversion of the surface elements (fig. 2.10). The vertices and edges are projected on the image screen by a perspective projection and the

Figure 2.10. Projective hidden-surface algorithm.

20

Solid modelling

intersection intervals of the scan-lines are calculated and set to the appropriate shading intensity. Alternative methods are sampling of the surface and subdividing the surface until surface elements cover only one pixel. The visible surfaces are determined by a depth-sort: elements nearer in depth have a visual priority over elements at a greater distance of the viewpoint. The different projective hidden-surface algorithms can be characterised by the sorting order applied on the surface elements [Sutherland et al., 1974]. In scan-line algorithms, a list of active surface elements is updated before a sorting is applied to find the visible elements for a part of a scanline. The depth-buffer (z-buffer) algorithm renders the surface elements in object order and performs a depth sort at each pixel by comparing the depth of the element with the depth value in a depth buffer. Initially, all pixels in the depth buffer are set to a maximum depth value. Next, the surface elements are scan-converted and for each pixel covered, the depth of the element is compared with the depth value in the depth buffer. If the depth value of a surface element is smaller than the corresponding buffer value for that pixel, then the pixel is rendered and the new depth value is written in the buffer. List priority algorithms render the surface elements in increasing priority order (back-to-front) into the frame buffer with the socalled painter's algorithm (overwriting earlier rendered elements). The depth priority algorithm sorts the surface elements dynamically for each different viewpoint [Newell et al., 1972]. Nearly real-time performances have been obtained with (eye-point independent) fixed order techniques, such as cluster ordering [Schumacker, 1969], and BSP-trees [Fuchs et al., 1983]. Real-time performances are within reach for projective algorithms implemented on VLSI-based hardware display systems [Clark, 1982], [Fuchs et al., 1985]. 2.4.2 Ray tracing Ray tracing [Whitted, 1980] is a very elegant hidden-surface algorithm that has provided some of the finest examples of image synthesis in raster graphics. The 'point-by-point' approach of ray tracing was first described by Appel[1968] and Goldstein and Nagel [1971], Central to the algorithm is the ray object intersection calculation. For every pixel of the image plane that is located between the eye and the scene, a ray is cast from the eye point through the pixel into the scene, and a search is made for intersections with objects (fig. 2.11). After finding die intersection with an object, the correct intensity or colour is calculated and assigned to the pixel. If no intersection is found the pixel is set to die background colour. To model the light conditions of an environment, light sources are simulated and the shading of the surfaces is calculated based on the intensity of the light and the colours and reflection properties of the surfaces [Blinn, 1977]. For calculating mirroring reflections and transparency with refraction, the ray is followed after reflection or deflection on the surface of the object, in search of other objects that contribute to the intensity or colour of the first surface by mirroring, etc. (fig. 2.11). With the same technique cast shadows can be calculated. Additional rays (secondary rays) are cast from the first intersection point and directed to the light sources; if the rays intersect other parts of the object or other objects, the surface is hidden from the light source; no direct light is reflected and die surface is in the shadow.

Solid modelling

21

CV light source

ray for shadow test ray for transparency

ray for mirroring

image plane eye point Figure 2.11. Ray tracing,

2.43 Display ofCSG models For display of a solid model, the CSG representation can first be converted into a boundary or volumetric representation, which can then be displayed with standard hidden-surface algorithms. However, this conversion may be time consuming, and it is often more efficient to combine the CSG evaluation with the hidden-surface removal, i.e. the surface elements are classified together with the visibility calculation. The evaluation method for this approach is similar to the spatial evaluation, except that surface elements are classified. The hiddensurface algorithm samples the object with a bundle of rays or lines of projection and for each ray or line the surfaces of the intersected primitives are classified to determine whether they are part of the boundary of the resulting solid or not. The nearest surface in depth that classifies as 'on' the composite object is rendered. See section 4.1 for a detailed description of these techniques. 2.5 Solid modelling with faceted primitives Hidden-surface algorithms have been developed through the 1960s and 1970s for different types of surface and solid models, but only in 1982 was the first algorithm for direct display of CSG models published by Roth, a CSG ray tracing algorithm which uses exact representations of the primitive solids [Roth, 1982]. A year later Atherton published another important algorithm, a CSG scan-line algorithm that uses polygon primitives [Atherton, 1983]. These two algorithms can be combined with an user-interface for the following scenario for the design and visualisation of solid models:

22

Solid modelling

- The solid model is specified via a graphics interface or, alternatively, specified via a procedural language; line drawings are used for interaction. - The model is viewed with a projective hidden-surface algorithm, for instance the CSG scan-line algorithm. - A high-quality rendering picture is generated with a ray tracing algorithm. For an implementation of this scenario see [Steenbrugge, 1986], [Bronsvoort et al., 1985], [Bronsvoort, 1986] and [van Wijk, 1984a, 1984b, 1986]. This scenario shares some features with 'previewing'. Previewing facilities involve a trade-off between processing time and image quality. They are used to improve the responsetimefor specifying modelling and shading parameters, for instance, the use of wire-frame pictures for model input, and faceted modelling for fast shading [Atherton, 1983], [Jansen and van Wrjk, 1983]. Certain aspects (modelling or shading) can be optimised while using simplified calculations for the other aspects. Previewing thus provides an 'analogue' for the desired result. Further, pictures generated only partially or at a lower image resolution may be sufficient for interpretation, and so improve the interaction. Also default settings and the use of meaningful specification modes for the input of 'modelling', 'viewing' and 'shading' parameters may reduce the processing and improve the interaction [van Wijk et al., 1985]. The research described in this thesis further explores this scenario, in particular the use of linear approximation for the display of solid models. The model can be displayed with different faceting tolerances both for a preview as well as for an accurate rendering. Further, linear approximation is of interest because of its fairly unrestricted shape domain and its uniform processing; different types of procedural and analytical defined models may be added to the system, without altering the scan-conversion and sorting procedures, and only requiring a conversion algorithm for the linear approximation. For hidden-surface algorithms, the line-surface intersection (for ray tracing) and the scan-conversion (for projective algorithms) are most important. Higherorder surfaces are difficult to intersect and even more difficult to scan-convert. Linear approximations are simple to intersect and to scan-convert, but the large number of surface elements usually severely reduces the overall efficiency. This leads us to the central research question of this thesis: given the fairly unrestricted shape domain of linear approximations, and the fact that a large number of polygons are necessary to give comparable image quality with that given by exact representations, what techniques can be developed to process the large number of polygons more efficiently. Two approaches are presented. In part 2, special data structures and algorithms are proposed for efficient processing of models defined with a large number of polygons. In part 3, a CSG depth-buffer algorithm is described for the display of linear halfspace models. The use of this algorithm in combination with recentlydeveloped VLSI-based display systems brings the display of linear CSG models within nearly real-time. Further, a multi-processor version based on a subdivision approach is proposed. Part 4 summarises the results and conclusions.

Part 2 Display of. CSG polygon models

A solid modelling approach is presented based on polygon approximation of primitive solids and the use of three additional data structures: a filter for processing recursively subdivided surfaces, a CSG buffer for the intermediate storage of CSG classifications and a polygon database that can be accessed by a spatial index. Algorithms are given for the definition of the primitive solids and their conversion into polygon models, and for the interactive viewing and high-quality rendering of the CSG model, and for the conversion of the CSG model into boundary and volumetric representations.

Faceted modelling

25

3. Faceted modelling Solid modelling is concerned with the geometric description of three-dimensional objects. To be useful within a CAD/CAM system, solid modelling techniques should be able to model and process product geometries within a reasonable time. In this context, geometric complexity poses a problem. This is certainly true for the envisaged application area, industrial design, where products with curved surfaces often occur. One method to reduce complexity is to decompose the object into several more elementary volumes, as in Constructive Solid Geometry (CSG). The processing can further be simplified by approximating the curved surfaces of the primitives with polygons. This eliminates the complex processing of quadratic and higher order surfaces but poses a new problem in processing the resulting large number of polygons (typically 10,000 to 100,000). In the following sections, three data structures are proposed to process these large number of polygons more efficiently.
3.1 Internal and external data structures

Boundary models implicitly describe three-dimensional solids by enumerating the surface elements that constitute the boundary. Although a list of surface elements (each surface element may be denned with a list of vertices) is sufficient to define a boundary representation, often additional information on connectivity relations between elements is stored in a hierarchical data structure to enhance operations on the boundary. A well-known example is the winged-edge data structure [Baumgart, 1975]. This type of data structure can be denoted as 'internal' to the model, in that it specifies connectivity relations (the topology) between elements of the model. There is also a class of data structures that stores (intermediate) evaluated (geometric) properties of the model. This type of data structure can be denoted as 'external' to the model. Ideally, it would permit the processing of the model in a sequential way with an algorithm that acts like a filter, collecting and passing data from the model into a data structure that serves as a buffer. Both approaches have their advantages, and occasionally they are used in combination [Mantyla and Tamminen, 1983], but for models with 10,000 or more polygons, the amount of data and of processing needed to maintain an internal data structure will exceed manageable limits in both memory requirements and processing time. For this reason, the internal structures are here kept to a minimum and three external data structures are proposed instead. This chapter deals with the definition of the primitive solids and their conversion into polygon models. This conversion may locally destroy the integrity of the surface. An integrity filter is applied to restore the integrity of the polygon meshes. In chapter 4, a CSG-buffer and list structure is introduced that stores intermediate results of CSG classification tests. As a result, CSG coherence can be exploited. Further, it permits the intermediate storage and referencing of this information, thereby enabling a stepwise evaluation of the CSG model for the algorithms of chapter 5. In chapter 5, a spatial subdivision method is applied for enhancing the hidden-surface and conversion algorithms.

26

Faceted modelling

3.2 Faceted primitives

The CSG model is input by specifying the CSG-tree and the dimensions and position of the primitive solids. These input representations (name of primitive type and parameter list) are internally converted into polygon models. 3.2.1 Input representations Primitive instancing provides a standard set of primitive solids: sphere, cylinder, block and cone. However, with these primitives only a limited shape domain is covered. Sweeping provides a powerful extension of this domain. The following describes the implementation of sweeping in the modelling system described in this thesis. A sweep object is defined by the form that is swept by the transformation of a contour (a closed planar 2D curve) along a trajectory, in general a 3D space curve (fig. 3.1). The contour is kept orthogonal to the local tangent to the trajectory. / \
i "4VLCL

/
u

contour V

/ v Y ~ ~ -

z\ Itrajectory \base plane

Figure 3.1. Sweep definition.

The trajectory is defined in terms of a parametric vector function: T(r) = 0,(r), ty(r), tz(r)), r{ <, r Z
rj

As r goes from rt to r;-, the components trace out the trajectory. The closed 2D curve that is swept along the trajectory can also be defined parametrically relative to its own u-v coordinate system.
C~(S ) = (Cu (S ), Cv (S ) ) , Si S Sj

The u-v coordinate system is kept orthogonal to the trajectory. This leaves one degree of freedom, because it still can rotate around the local tangent to the trajectory (fig. 3.1). To orientate the contour, v is chosen to align with the projection of

Faceted modelling

27

the positive y-axis of the contour base plane on the u-v plane. For the trajectory intervals where the projection of the y-axis coincides with the direction of the trajectory, the orientation is interpolated. Other methods proposed by Klok[1986] are a rotation minimising sweep and a sweep based on the Frenet system, where the discontinuity in the rotation of the Frenet frame at points of inflection of the trajectory is removed. The sweep definition is further generalised by a rotation and a scaling of the contour in its own u-v coordinate system. The user defines the object by specifying four design curves: a contour, a trajectory, a rotation function and a scaling function. Each design curve can be a linear, quadratic or cubic B-spline curve. The rotation and scaling functions are dependent on the trajectory parameter r, which is functionally related to the arc-length of the trajectory. Some instances of this sweep definition are depicted in fig. 3.2.
contour

trajectory 1 scale 0

8
O

&

scale 1

scale 2

scale 3

trajectory 2 scale 1

scale 2,3

&=>

trajectory 3 scale 1

scale 2,3 Figure 3.2. Repertoire of sweep-defined shapes (O-constant, 1-linear, 2-quadratic, 3-cubic). Some combinations of design curves may generate self-intersecting surfaces, thereby destroying the integrity of the solid. The same applies for other feasible shapegeneration schemes, such as lofting and free-form surface definitions. For these schemes, additional techniques are required to handle the problems of orientation,

28

Faceted modelling

tangency, continuity and self-intersection. These are beyond the scope of this project. 3.2.2 Linear approximation The input representations are internally converted into polygon models. The sphere, cylinder and cone are approximated by a regular mesh of polygons, the resolution of which is dependent on the required accuracy (see plate 1). The sweep-defined solids and free-form surfaces are approximated by a polygon mesh created by an adaptive subdivision of the surfaces. The sweep object is first subdivided into 'surface patches' in the following way. The contour and the trajectory are denned by B-spline curves. These curves can be subdivided into segments, each described by a piecewise-polynomial representation. If the number of contour segments is n and the number of trajectory segments is m than the 'swept surface' of the sweep object can be subdivided into n*m surface patches, a patch for each combination of a contour and a trajectory segment. The boundary of the sweep object is closed with additional patches at the base plane and at the cap plane (fig. 3.3). An example is shown on plate 2.

trajectory segment

\ll-^"^"J~Jlsurface patch

contour segment Figure 3.3. Sweep-defined object.

Each surface patch is processed by the procedure Subdivide (algorithm 3.1). Subdivide operates via the procedure Segment on two 'segment trees', one for the contour segment and one for the trajectory segment. A segment tree is a binary tree of which the root node corresponds to the whole segment, and the left and right subnodes of intermediate nodes correspond to its left and right half segment. The procedure Segment passes references of these nodes to Subdivide and dynamically creates additional subnodes if requested by Subdivide. At each node of the segment tree, the coefficients of the spline segment are stored. The spline segment is subdivided with the Catmull-subdivision algorithm [Catmull, 1974]. The function of Subdivide is to pass the node pointers of the segment trees to its subprocedures. Subdivide recursively calls itself four times until all segments satisfy the faceting tolerance. In procedure Flat, the plane equation of a plane through three of the corner points is calculated. If the midpoint and the fourth

Faceted modelling

29

procedure Subdivide(cep,tep:segmentpointer); {cep and tep are pointers to segment tree for contour and t r a j e c t o r y Makepatch calculates the four cornerpoints of a surface element with information from the segment t r e e Flat i s a function that t e s t s whether the surface element i s within the faceting tolerance} var p cepl,cep2,tepl,tep2 : surfaceelement; : segmentpointer;

begin Makepatch(p,cep,tep); if not F l a t ( p ) then begin {subdivide patch in four subpatches} Segment(cep,cepl,cep2); {if necessary subdivide segment} Segment(tep,tepi,tep2); {and expand the segment trees} S u b d i v i d e ( c e p l . t e p l ) ; {pass segment pointers to subpatch} Subdivide(cep2,tep1); Subdivide(cepl,tep2); Subdivide(cep2,tep2) end e l s e Output(p) end; {Subdivide}

Algorithm 3.1. Subdivide. corner point are within the tolerance distance, then the patch is approximated with a polygon, which in fact is a quadrilateral. Otherwise the patch is further subdivided. If the surface patch is not defined by a sweep procedure but as a bicubic parametric patch, then the standard Catmull-subdivision technique for patches is applied until the subpatches satisfy the same flatness criterion. The linear approximation may destroy the integrity of the model in two ways. First, the integrity of the polygon mesh may be lost, but this can be repaired with the algorithm to be discussed in the following chapter. Second, the polygons are not guaranteed to be flat. This can only be overcome by describing the polygons by parametric surface definitions, but this requires additional processing for certain applications. In the following, the inaccuracy of the polygon (within the faceting tolerance) will be accepted, because in practical cases it does not lead to deficiencies.
3.3 Integrity checking*

As a result of the adaptive subdivision the density of surface elements (polygons) varies over the surface, and the length of edges of neighbouring surface elements * This section was developed in cooperation with Matkku Tamminen, Helsinki University of Technology, Finland.

30

Faceted modelling

43 3 M 41

44 42

a. recursive subdivision

b. subdivided patch

; 2 %*
o o o o 41 42 1,3 U, c. quadtree representation

DF = 11,2,3(41,1,2,43,1,4

d. DF - representation

Figure 3.4. Subdivision of a surface.

may differ. This may result in 'cracks' - small empty areas between adjoining elements (fig. 3.4). Cracks cannot be accepted in solid modelling, because they destroy the integrity of the surface. Cracks can be mended by recognising and inspecting neighbouring elements. However, this requires an explicit tree structure to describe the state of the subdivision [Carlson, 1982], or a data structure for all the vertices linked into the subdivision network [Sabella and Wozny, 1983]. Since the number of elements may be large (tens of thousands of polygons), it is worthwhile to look at an alternative structure such as that depicted in fig. 3.5. In the proposed system, a surface processor produces a sequential list (file) of elements in a given order. The element list is then traversed in the same order, in the surface processor itself, or as a separate process by an integrity filter that adjusts the coordinates of vertices (for instance M in fig. 3.4) to be identical in each adjoining element. Ideally, the integrity filter should not require large and complex internal data structures.

Faceted modelling

31

patch

patch subdivision

integrity fitter

surface elements

Figure 3.5. System structure based on an integrity filter.

Recursive surface subdivision is similar to the construction of a quadtree. Both divide space (parameter or image space) recursively until each leaf meets a certain criterion. The result of the process can be recorded explicitly in a 4-ary tree when the tree structure or interleaf processing is required. The quadtree need not be represented by the traditional explicit pointer based tree structure, but can also be represented with a linear quadtree [Kawaguchi and Endo, 1980]. In a linear quadtree the tree stmaure is implicit by the ordering of the nodes or the addresses of leaves in a sequential list. In [Samet and Tamminen, 1984] efficient methods have been developed for traversing linear quadtree representations of two dimensional images to determine geometric properties such as perimeter and connected components. Here these algorithms and data structures are applied to the integrity problem of recursive subdivision meshes.

v-list

^f^'-v;

1
;' v;:i

a.

-hst

ii w m$
:

11

IP
V/y///
:

.'/'i ';}. .''

:.;.':

:'

: . / ! ' ; ;

..v.-.'--.-..;! . -.. ... .i

Figure 3.6. Moving edgelists. Cross-hatched area is processed, dotted area is active.

32

Faceted modelling

33.1 Subdivision mesh integrity checking The integrity algorithm is applied to parametric surface patches (defined by bicubic patch formulations or by sweep procedures) divided into surface elements, (as described in the previous section). A patch quadtree is formed by subdividing a surface recursively into four sub-elements until some criterion of well-formedness is met by each surface element. A node in the patch tree has four sides (N,E,S,W) and four corners (SW,SE,NW,NE). A linear tree representation is created by a preorder traversal of the patch tree. The traversal yields a string over the alphabet '(','L' corresponding respectively to internal nodes and leaves. This string is called a DF-expression (Depth-First) [Kawaguchi and Endo, 1980]. Its ordering of nodes is equal to that of the actual recursive subdivision procedure. For the surface of fig. 3.4 this representation becomes (LLL(LLLL. To each 'L' a description of the geometry of the surface element (e.g. the x, y and z-coordinates of its corner points) is appended. The task of surface mesh integrity checking is to process the preorder traversal of a patch tree, and to make each vertex lie on the border of the neighbouring element.

procedure Traverse(s : elementsize; var up,vp : edgepolnter); var upl.vpl p : edgepolnter; : surfaceelementpointer;

begin Readsurfaceelement(p); if not leaf(p) then begin upl^up; vpl:=vp; {save start} Traverse(s/2,up,vp); Traverse(s/2,up,vpl); Traverse(s/2,upl,vp); Traverse(s/2,upl.vpl) end else begin Increment(up,s,p); {process u-list} Increment(vp,s,p); {process v-list} up:"Next(up); {return pointer to next element) vp:=Next(vp) end end; {Traverse}

Algorithm 3.2. Traverse.

The algorithm works on a data structure consisting of two lists of edges, the uedgelist and the v-edgelist. Every edge points to two vertices, a start vertex and an

Faceted modelling

33

end vertex. Additionally, information about one of the neighbouring leaves (regions) can be included in an edge record. The elements of the edgelists form an edgechain that is moved over the parameter space by the algorithm. The u-edgelist consists of the horizontal elements of the chain and die v-edgelist of the vertical ones (fig. 3.6). Each contains at most 2" active edges at any moment (n is maximum level of subdivision). The algorithm starts by initialising the two lists to contain one element: the southern border of die parameter space forms the u-list and the western border the v-list (fig. 3.6a). Surface elements are processed in depth-first order and for every one the edgechains are updated to incorporate the new element in the part of the image that has already been processed. Its properties are stored for later reference. After processing three elements, die situation of fig. 3.6d is reached. The white area consists of leaves yet to be processed, the dotted area of the active surface elements and the cross hatched part of the elements are already output. All information between die processed and unprocessed parts of die surface is conveyed via the edge chains. Note that edges and surface elements are processed in a way that minimises intermediate storage and that the data is stored in a relatively simple data structure. All computations are located along die active edgechain.
procedure Increment (var edge : edgepointer; s : elementsize; p : surfaceelementpointer);
begin if s > Size(edge) then Adjustvertices(edge,s) { adjust smaller elements to the new element and output the surface elements that are completely processed, combine the edge elements into one edge with size s, return pointer to this edge } else if s < Size(edge) then Splitedge(edge,s,p) { split edge to accomodate smaller new element, adjust vertex to edge, output processed surface elements, and return edge neighboring the new element} else Outputsurfaceelements(edge); (only output processed elements} Moveedge(edge,p ) { move edge to opposite side of element, in case of u-list :W to E by replacing SW and NW by SE and NE, in case of v-list :S to N by replacing SW and SE by NW and NE} end; {Increment} Algorithm 3.3 Increment.

33.2 Moving edgelists The algorithm consists of tiiree parts. An initialisation procedure creates u- and v-border lists containing one element of widdi M. Procedure Traverse (algorithm 3.2) traverses die DF-representation of a patch quadtree. Its main function is to provide, at each call to its sub-procedures, a pointer to die part of die u- and v-lists bordering to die W and S side of that subtree. It calls itself

34

Faceted modelling

four times recursively at each internal node, and at each leaf node it calls procedure Increment twice to perform the actual updating of the active borders and the collection of vertices of the current surface element. The purpose of procedure Increment (algorithm 3.3) is to process all the active edge elements bordering an edge of a new leaf. If the new edge is larger than its neighbour, the vertices of the neighbouring nodes are adjusted to the new leaf and the different edgelist elements are merged into one (fig. 3.7a).

a. edge element < surface element

b. edge element > surface element

Figure 3.7. Processing of edge.

If the new edge is narrower than its neighbour, then the end of the edge is 'snapped on to' the neighbour by computing a point lying on the neighbour edge. Further, this element of the edgelist is split into two smaller edges of which one is the edge of the new leaf (fig. 3.7b). After this processing, the edgelist-element is moved to the other side of the leaf.' The algorithm does not output surface elements in DF-order. Surface elements are retained as long as any of their edges belong to the active border. Thus the data structure consists of all the edges and vertices of the patches lying directly to the S and W directions of active borders. This is illustrated by fig. 3.8.

a. state after processing element 3

b. state after processing element 41

Figure 3.8. Processing of surface elements.

Faceted modelling

35

Surface element 3 has been processed and the processing continues with element 41. The dashed line represents the active border. The u-side of 41 is wider than elements 233 and 234 meaning that a vertex will be adjusted to the S-side of 41. The v-side of 41 is narrower than element 3. This means that a vertex of 41 is adjusted to align with the side of 3. After processing element 41, elements 233 and 234 are never needed again so that they are output and their inactive vertices discarded. Figure 3.8b shows the situation after processing 41. The polygons resulting from the linear approximation were not guaranteed to be flat. The corrections on the polygons may further reduce the accuracy, and therefore an additional subdivision may be needed. 33.3 Analysis and empirical results The time required to traverse the DFrepresentation of a patch tree is clearly 0(L), where L is the number of patches. This holds because no searching is required in the algorithm. The space complexity of the present algorithm depends on the maximal number of edges simultaneously active and the maximum number of patches connected to the edgelists.

a. surface with cracks

b. surface after integrity checking

Figure 3.9. Example surface.

The number of edges is usually of the same order of magnitude as the number of patches that would intersect some line u=u 0 or v=v 0 . The space requirements thus seem to depend on the square root of the total number of patches. In practice space requirements are somewhat difficult to determine a priori. Some results of an implementation of the algorithm for the surface shown in fig. 3.9a (before integrity checking) and fig. 3.9b (after integrity checking) are summarised in table 3.1. Table 3.1 shows the total number of surface elements and vertices generated at various tolerances and the maximal amount of vertices actually stored in the data structures of the algorithm.

36

Faceted modelling

Tolerance Surface elements Vertices Maximal number of surface elements stored Maximal number of vertices stored Processing time (PDP 11/44 CPU sec)

.1

.05

.01

.001 4093 4478

49 78 16 38 10

103 145 23 51
0.24

442 549 50 115


1.02

142 327
11.04

Table 3.1. Statistics for integrity filter for B-spline patch of fig. 3.9.

The integrity filter processes individual patches. For a surface model with several patches, a wire-frame model is first created of the edges of the patches. Each edge is an edgelist of edge-segments corresponding to the size of the largest element of the two neighbouring surface elements of that edge. The edges from this wireframe model are taken by Traverse as the initial edgelists. If the integrity filter and the polygon conversion (section 3.2) are implemented as one pass, each vertex can be generated only once and the moving edgelist passes the references of the vertices to the neighbouring elements. The resulting polygon representation contains an identifier of the primitive to which it belongs, a plane equation and references to its vertices.

CSG evaluation

37

4. CSG evaluation Central to the boundary and spatial evaluation of CSG models is the classification of the surface and volume elements of the primitives against the composite object (CSG evaluation for short). The CSG evaluation consumes only a minor fraction of the total processing time for display of CSG models. However, this ratio may change with large models and with parallel processing. Several methods to improve the efficiency of the CSG evaluation are described and compared.
4.1 Introduction

Central to the spatial evaluation of the CSG model is the ray-object classification. If the object is a single (convex) primitive solid, then the intersection of a ray with the object results in two intersection points; one intersection point with the forward-facing part of the boundary and one with the backward-facing part. (A surface is forward-facing if at every point the normal outward from the primitive solid makes an angle greater than 90 degrees with the ray through that point, the positive ray direction being from the eye point to intersection). For CSG objects with more primitives, the ray intersection yields a number of intersection points (fig. 4.1a), and additional investigations are necessary to classify these points as 'in' (including 'on') or 'out' the resulting composite object. There are two methods to determine the intersection with the resulting object: by interval-object membership classification and by point-object membership classification [Tilove, 1980]. With the first, the resulting ray-object classification is found by combining the individual ray-primitive classification intervals according to the CSG-tree (see fig. 4.1c). The ray is divided by the intersection points with a primitive solid into intervals that can be classified as 'in' if the interval is inside the primitive (including the 'on' cases) and 'out' if the interval is outside the primitive. The tree is traversed in postorder, and at each composite node the intervals of the left and right subtree are merged, taking into account the Boolean operation of that composite node. The classification at the root gives the resulting ray-object intersection. The second method is based on point-object membership classification: each point in space can be classified as 'in' or 'out' of a CSG object by classifying the point with respect to the primitive solids and combining the individual pointprimitive classifications according to the set operations in the CSG-tree. A point on a projection line (through a pixel and the eye point) can be classified with respect to a primitive solid by testing (with depth comparisons) whether the point is 'in' the primitive or 'out' the primitive. A point is 'in' (a convex primitive) if it is both behind (or on) the forward-facing boundary and in front of (or on) the backwardfacing boundary of the primitive (seen from the eye point). The individual point-primitive classifications can be combined with a CSGtree traversal. For each leaf node the point is classified as 'in' or 'out' with respect to the primitive solid at that leaf node, and at each composite node the left and right classifications are combined according to the Boolean operators at that composite node. The classification at the root gives the 'in' or 'out' classification of the

38

CSG evaluation

t A
4 5

/ \
B C

a. ray-primitive intersections

b. CSG definition

>

4-=~.A B . C . BnC A-(BnC)


out out

1 f
B

iS

c_

out out

out out A " out

in

c.

ray interval classification

d. point classification

Figure 4.1. Ray-object classification.

point with respect to the resulting composite object. To avoid unnecessary classifications, the intersection points along the ray can be sorted or be generated in the appropriate order, and each intersection point is successively evaluated with a CSG-tree traversal until the first intersection point with the composite object is found (see fig. 4. Id). Instead of determining all the pointprimitive classifications at each point anew, the information whether a point is inside a primitive solid can be preserved while the points are processed along the ray. At the ray origin the classification of all primitives is assumed to be 'out'. If an intersection point is met moving along the ray from the origin, the classification of the corresponding primitive is inverted. Thus, if an odd number of intersections, possibly including the test point, is met with a primitive, the test point is 'in' the primitive, for zero or an even number of intersections, the test point is 'out'. We shall refer to this condition as the status of the primitives. Infig.4. Id the ray intervals are labelled with the primitives that are 'in' for that interval. Starting at the origin of the ray, each following point along the ray is evaluated until a point is found that classifies as 'in'; this is the first intersection point of the ray with the composite object.

CSG evaluation

39

The first method has been used in the CSG conversion algorithm of Lee and Requicha[1982] and in the CSG ray tracing algorithm of Roth[1982]. The second method, attributed to Boyse in [Lee and Requicha, 1982], is applied in the CSG scan-line algorithm of Atherton [1983] and in the CSG ray tracing algorithm of Plunkett and Bailey [1985]. The CSG evaluation consumes only a minor fraction of the total processing time for display of CSG models. However, this ratio may change with large models and with parallel processing. With parallel implementations (multi-processing, vector processing or dedicated logic) the time to calculate and sort the intersection points is considerably reduced, making it worthwhile to improve the efficiency of the CSG evaluation, as has been done in [Sato et al., 1985] with the status tree evaluation method, and in [Plunkett and Bailey, 1985] by performing the CSG evaluation in parallel for several rays. In [Bronsvoort, 1986] the same status tree technique for the CSG evaluation is applied in a CSG scan-line algorithm in combination with other efficiency techniques such as partial backface removal and active span list coherence. For the point classification method the number of CSG-tree evaluations and the time to perform a CSG-tree traversal are crucial for efficiency. In the following sections, three methods will be discussed to improve this efficiency. First, the CSG-tree can be reduced in size by pruning primitives from the CSG-tree whose contribution can be determined a priori. This is the subject of section 4.2. Secondly, the CSG-tree traversal can be reduced by limiting the traversal to those primitives that actually contribute to the evaluation. This is the subject of section 4.3. In section 4.4, a CSG-tree evaluation method with bitwise operations is presented. Thirdly, the number of CSG-tree traversal? can be reduced by utilising earlier traversal results. This type of object coherence is called CSG coherence in [Atherton, 1983]. It is the subject of section 4.5. The CSG-tree traversal and CSG coherence methods are implemented and compared. The results are presented in section 4.6. 4.2 Tree-pruning For any given part of the image, not all primitives might contribute to the object. For these parts, the CSG-tree traversal can be reduced by pruning the CSG-tree. Pruning [Woodwark and Quinlan, 1982] is the elimination of subtrees whose classification ('in' or 'out') can be determined a priori. When one of the subtrees of a composite node classifies as 'in' or 'out', as a result the composite node can be classified as 'in' or 'out' or be replaced by the other subtree, according to the rules of table 4.1.

40

CSG evaluation

operation union

left

right TREE TREE

result

IN OUT
TREE TREE

IN
TREE

IN OUT
TREE TREE

IN
TREE NOT TREE

difference

IN OUT
TREE TREE

IN OUT
TREE TREE

OUT OUT
TREE TREE

intersection

IN OUT
TREE TREE

OUT
TREE

IN OUT

OUT

Table 4.1. Rules for CSG-tree pruning.

The entry TREE in table 4.1 denotes the subtree whose value cannot be detennined a priori and the result TREE means that the classification of the node depends on the classification of that subtree (fig. 4.2).

U n B subtree

B= 'out' out

U subtree

subtree

Figure 4.2. Pruning of a CSG-tree.

A related principle is that a primitive only influences the classification of a primitive with which it intersects. As long as a ray is inside a particular primitive, the remaining primitives that do not intersect it, cannot contribute to the classification and can therefore be removed from the tree (fig. 4.3). The reduced tree is valid within the volume of the primitive. If the ray leaves the primitive, another primitive, if any, can be taken as the space enclosure, and a new reduced tree is calculated. A more formal definition of this concept of active zones can be found in [Rossignac and Voelcker, 1986].

CSG evaluation

41

Object

CSG-tree = A-(BDC) Outside A CSG-tree = nil B CSG-tree = A C CSG-tree = A Inside

A
A /
B

n \
C

A B C

CSG-tree = -|(BnC) CSG-tree = A-C CSG-tree = A-B

Figure 4.3. CSG-tree pruning.

In most algorithms, the 'in' or 'out' are not defined relatively to the object boundary but in the context of a regular image-space subdivision [Woodwark and Quinlan, 1982], [Samet and Tamminen, 1985], or within box enclosures [Bronsvoort et al., 1984], [Sears and Middletich, 1984]. See for an example fig. 4.4.

CSG-tree: A-(BnC)

pruned CSG-tree: A

image subdivision

pruned CSG-tree: empty

Figure 4.4. Image subdivision and CSG-tree pruning.

Whether tree pruning is done as a preprocessing operation or dynamically depends largely on the context. A reason to implement tree pruning as a preprocessing operation is that it may reduce the processing of primitives. Operations such as projection and intersection calculations can sometimes be skipped for parts of the model. In the following sections, we seek to minimise the CSG-tree traversal and the number of CSG traversals, given the size of the CSG-tree. 4.3 CSG-tree traversal methods 43.1 Standard tree traversal The standard CSG-tree traversal to classify a point traverses the CSG-tree in postorder, and applies at each composite node the Boolean operation of that node to the classification of the left and right sub-trees. The traversal path is given in fig. 4.S.

42

CSG evaluation

tree traversal o leaf node 'out' leaf node 'in'

CSG-object:

A-(BnC)

Figure 4.5. Standard CSG-tree traversal.

The rules for the Boolean operations on the subtree classifications are given in table 4.2.
operation union left right result

IN OUT

difference

IN OUT

intersection

IN OUT

IN OUT IN OUT IN OUT IN OUT IN OUT IN OUT

IN IN IN OUT OUT IN OUT OUT IN OUT OUT OUT

Table 4.2. Rules for standard CSG-tree traversal.

43.2 Early out In some cases the result of a Boolean operation is dependent on the classification of only one of the subtrees. For instance, if for a Boolean union operation one subtree classifies as 'in', then there is no need to examine the other subtree. For the Boolean intersection operation, both subtrees must be 'in' for a ray interval to yield an 'in' result for the composite node. If one subtree is found to be 'out', the result will be 'out', independently of the status of the other subtree. Using 'early out' [Roth, 1982] converts the rules and the algorithm into those given in table 4.3.

CSG evaluation

43

operation union

left

right

result

IN OUT IN

difference

IN OUT IN OUT IN OUT

intersection

OUT IN OUT

IN IN OUT OUT IN OUT IN OUT OUT

Table 4.3. Rules for CSG-tree traversal with 'early out'.

Fig. 4.6 gives the new traversal path for the example also used in fig. 4.5.

4'' e

Figure 4.6. CSG-tree traversal with 'early out'.

43.3 Positional coding As can be seen from the example, it is still possible that subtrees are traversed that do not have any leaf node that classifies as 'in'. With some extra testing, the traversal can be limited to only those subtrees that have one or more leaf nodes that classify as 'in'. To guide the traversal, the nodes of the tree are coded with values (path codes) that correspond with their position in the tree. The codes are integer values in the range [0..2 n ], where n corresponds with the depth of the CSG-tree. The leaf nodes are coded by the following procedure. At the creation of the tree, the total range is passed to the root node. Descending the tree, at each composite node the mid-value is calculated and the left half of the range is passed to the left subnode and the right half is passed to the right subnode. Additionally, the mid-value (value 1) and the maximum value of the range (value2) are stored at the composite node. A leaf is coded with the minimum value of the range passed to it. The primitive is coded via a table look-up with the value of its leaf node. The values at the composite nodes are used to guide the search for a leaf node: if the value of the leaf node searched for is < valuel, then the leaf is in the left subtree; else if it is S value2 it is in the right subtree; otherwise, when it is > value2, it is in a (right) subtree branching higher in the tree.

44

CSG evaluation

Prior to the tree traversal, the primitives that classify as 'in' are sorted on their positional code. The tree traversal starts with the search for (the code of) the first leaf node. At every composite node this code is compared with the values to determine whether one of the subtrees has to be processed (whether the code searched for is in the left or right subtree). If a leaf is found, the code of the next point becomes the code searched for and the procedure is continued. Fig. 4.7 gives the tree traversal for the example.

jam
A

/ \
\
C

0 0 B

Figure 4.7. CSG-tree traversal with positional coding.

An additional code larger than the maximum of the range, is used to force a direct out. If a subtree is skipped for reason of early out, the primitives with positional codes within that range can also be skipped until a primitive is found with a code larger than value2. This test is indicated as 'update' in table 4.4. The sorting of the primitives on their codes guarantees that the leaf nodes are visited in the treetraversal order.

value! left

operation union difference

value2

right

update

result

IN

T F T F T F T F T F T F

YES IN OUT IN OUT IN OUT YES YES

intersection

OUT

union

difference intersection

IN IN OUT IN IN IN OUT OUT IN OUT OUT OUT OUT OUT OUT

Table 4.4. Rules for CSG-tree traversal with positional coding.

CSG evaluation

45

43.4 Status tree Another efficient tree-traversal technique is the status-tree method [Sato et al., 1985]. The status tree is an extended CSG-tree that stores at each composite node a pointer to its father node, and the status of the node as a result of previous evaluations. The tree traversal can now be limited to those parts that are subject to change (see fig. 4.8).

_ in

/A ,
/ ^
o

B Figure 4.8. Status tree.

Initially, all nodes are 'out'. When a primitive is intersected, the status information is updated starting at its leaf node and moving up the tree, the status of the composite nodes is re-examined (according to the rules of table 4.5) until no change occurs or the root is reached. A change at die root indicates an 'in' classification of that intersection point.

operation

status

left

right

change status continue traversal

union

IN

IN OUT

^ .
IN OUT IN OUT IN OUT

difference

OUT IN OUT
IN OUT

IN

OUT
intersection

IN

OUT
Table 4.5. Status-tree traversal.

NO NO YES YES YES NO YES NO YES YES NO NO

Fig. 4.8 shows the traversal in the example for the status tree method and fig. 4.9 shows the traversal paths of the different methods for a ray object intersection with four intersection points. The first three points are 'out' and the fourth point is the first object intersection.

46

CSG evaluation

tc n

-' ,H\
ra.' >n*

i7\
4
Qs n

A
o n o

A
n,ou(

" /K\
2. B-in

/\
o B C n

" A
o n

* /\
4

A
3.A-in

tH/

.fr\
\f\\

&' \ B C

iQ'

#\
/ - \

/\
/ - \

o B C

/\.
/''\
OUT

o -yOut * B C njtn

/A\
' ~ \

* A

* A

'/ \

'

A
i. C-out

#i

B C

//\

B C

/fa\
* //%
B C

BC

/A\
B C

* AW
B C

A.
A

BC

BC

M\
/A\

M\
/A\

A
///\

ft

'' \ q B C a. standard

'' \ 0 B C b. early out

'*' o B C c. positional coding

o B C d. status tree

Figure 4.9. Tree-traversal methods. 4.4 CSG-tree evaluation by bitwise operations

Note that the status of the primitives and subsolids only refers to the 'in' or 'out' classification of the primitives and subsolids for a particular ray interval. The result of the tree traversal for an interval is therefore only dependent on the 'in' or 'out' classification of the primitives for that interval and not on the order the primitives are intersected. We can therefore represent the status of the primitives for each interval by a bit-string representing the 'in' and 'out' classification for every primitive by a '1' and '0'. The CSG evaluation can now be performed on (a copy of) this bit-string with bitwise operations in two ways: bit-sequential and bit-parallel. 4.4.1 Bit-sequential For the bit-sequential method the CSG-tree is traversed in postorder and at each node a bitwise operation is performed on the bits of the left and right sub-tree. The bitwise operations are given in table 4.6.

CSG evaluation

47

Boolean operation union A u B difference A - B A n B intersection

bitwise operation "("A 6 , -B) inclusive OR A & -B A & B AND

&

logical AND one's complement

Table 4.6. Bitwise Boolean operations.

The intermediate results are stored on a stack. Clearly, only n bits are necessary for the stack if n is the level of the tree (fig. 4.10).

CSG tree

stack n n-1
status A = 1 status B = 1 status C = 0 'out' = 0 stack[n] ~ status A stack[n-l] = status B stack[n-ll = stack[n-l] & status C stack[n] = stack[n] & "stack[n-l]

A
A n /\ B C
'in' - 1

H3
1 0

Figure 4.10. CSG evaluation with bitwise operations. The stack is used for intermediate storage. The result of the evaluation is in stack[n] (most significant bit).

The bitwise CSG evaluation method can be used in the context of VLSI-based hardware display systems (see part 3). 4.4.2 Bit-parallel Instead of bit-sequential the CSG-tree evaluation can also be done bit-parallel. The basic idea is that all nodes on one level of the CSG-tree can be evaluated in parallel by performing one Boolean operation on the status bit-string of the nodes of the next lower level with a shifted version of the same string (fig. 4.11).

48

CSG evaluation

&
0 1 1 0 1

1 1 0 1 1 0 1 1 0 0

o _L o _ g _
&

Figure 4.11. Bit-parallel evaluation. CSG-tree evaluation by a bitwise operation for each level (only intersection operations). For a correct result, the bit-string should represent a fully-developed tree, that is, the length of the bit-string at level n of the tree is of length 2" (fig. 4.12).

Object / " \ A n / \ B C

/ \
/ \

& / \
B C

Status : |

Figure 4.12. Fully-developed CSG-tree. Further, the three different Boolean operations should be converted into one type of bitwise operation. The Boolean union and difference operation are therefore converted into a Boolean intersection operation (AND) by inverting both of the operand bits for the union and only the right bit for the difference operation, before and after the AND operation. See table 4.6. This is done with an exclusive OR operation on these bits with the bits depicted in table 4.7.

operation union difference intersection empty

leftnode

rightnode

1 0 0 1

1 1 0 1

Table 4.7. Conversion rules for operations. For the union operation both bits are complemented, for the difference operation only the right node bit. Table 4.8 shows the correctness of these operations.

CSG e v a l u a t i o n

49

operation union

R = status left right 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1 1

R =R ~P left right 1 0 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 0 1 1

R = R & (Rl) R = R " P left left 1 0 0 0 0 1 0 0 0 0 0 1 0 1 1 1 0 1 0 0 0 0 0 1

difference

intersection

Table 4.8. Result of bitwise operations (" = exclusive OR).

In the first columns, all possible combinations of status bits and Boolean operations are depicted. The second column shows the result of the conversion. The third column shows the result of the AND operation; only the left column of bits is shown, because these bits hold the result and the right node bits are not important any more and can be discarded. Finally, some of the bits (only for the union operation) are inverted again to give the correct result. See table 4.8. For the evaluation of a tree, the procedure is as follows. Initially, the status bit-string is copied to bitstring R (to save the status information). Three bitwise operations are now sufficient to evaluate each level of the CSG-tree. The operands are the contents of R and the bit-string P, where P represents the conversion bits for the Boolean operations on one level of the tree. The bit-string P is created according to the conversion bits of table 4.7. The operations are: - a bitwise exclusive OR with P on R, - a bitwise AND on R with R shifted 2 ( m _ 1 ) positions (for level m) to the left, - a bitwise exclusive OR with P on R. Table 4.8 shows the results of the bitwise operations. The same cycle is repeated for each level of the tree. The result at the root is a 0 or a 1 in bit n of R (fig. 4.13).

50

CSG evaluation

Object

B C R :

Status :

I1I0 i | 0 | 1| 0 0 0 0
R - Status R - R * P

/
A
B

\ n
/ \
C

Bit-pattern P

1 0 0.

P =

P -

1 1

R = R & (Rl) R = R *P R = R ~P R - R S (R2) R - R *P

0 1 0 0 0 0 0 1 , 1 , 0 0 0 T l T l 0 0 0 l 1 1 l

x 7

A,B,C

A.(BnC)

A-(BDC)

Figure 4.13. Example of bit-parallel CSG-tree evaluation. A and C are 'in', B is 'out'. The contents of Status is copied into R and for each level of the tree, three bitwise operations ate performed. The result is in the most significant bit of R.

If the number of bits is larger than the word size of the processor, then the tree must be evaluated in parts that are combined at the top of the tree. 4.5 Exploiting CSG coherence In addition to optimising the CSG-tree traversal, the processing can be reduced by exploiting object coherence between pixels, scan-lines and images. The result of a complete ray classification can be stored in a list: every element of the list represents an intersection point with a primitive solid and its classification. The list can be re-used for a subsequent ray classification by reading the list. If for a subsequent ray, the order of the primitives changes, or a new primitive is encountered, the list has to be updated. Obviously, the number of changes to accommodate all sequences that appear for one object is very large. Therefore to exploit CSG coherence, a buffer is needed that stores all the sequences in a compact way. In the following sections, this CSG-buffer will be introduced stepwise. 45.1 First point Most of the tree evaluations are done for the first intersection point. When this point is classified as 'in' no additional points have to be classified for that ray, because for display algorithms we are only interested in the first intersection point with the CSG object. The classification of the first intersection point is independent of other primitives and can be calculated for each primitive in advance (only the leaf node of the intersected primitive in the CSG-tree will be 'in'). This evaluation will be carried out a large number of times, 'in' or 'out'. Precomputation of a lookup table is sufficient to avoid these tree evaluations.

CSG evaluation

51

4.5.2 One list The results of the classifications of a sequence of intersection points along a ray can be stored in a list. For each intersection point, there is an element in the list that stores the identifier of the primitive and die 'in' or 'out' classification of that intersection point.

ray 1 2 3

ray 1

3 ||

ray 1 2 3

rayl.2 )C\out\i~\B\IrT^~\A\out\:\~\C\in

ray 3 \C\out\+~\B\out\-\--\c]tF\\A\in | |

Figure 4.14. One list. In the example of fig. 4.14, four intersection points have to be classified for ray 1 before an 'in' interval is met The list is created incrementally and with every classified intersection point a list element is added to the list. For ray 2 it is sufficient to access the list, because the sequence of primitives is the same. Thus as long as the identifiers of the primitives correspond to the identifiers of the list elements, the classification can be read from the list Only when the sequence of intersection points changes from one point to the next do the new points have to be classified and a new list made. In the example, the order changes when the ray leaves primitive C earlier than it intersects primitive A, and thus the list has to be updated (ray 3). When one list is maintained the classifications of earlier processed sequences are lost. When all sequences are stored in separate lists, the number of lists will be very large and it will be difficult to retrieve earlier processed sequences. To avoid these problems, the lists are combined into one list structure. 4.5.3 List structure The list structure is a tree-like data structure that records all possible sequences in an efficient way by combining lists and providing access to each sequence starting at one root. As long as the sequence of intersections for successive rays remains the same, one list is sufficient When the sequence changes, the list branches to accommodate the changes. A possible implementation is

52

CSG evaluation

depicted in fig. 4.15.

root

order of intersection 1
A I B out
I

in

A | in
I

out

B\out

A \out

T\

in

C\ out

~A\ in
I

Figure 4.15. List structure.

The root of the list structure is an array of pointers. The index in this array is the primitive identifier of the first intersected primitive. Initially, the pointers are null. For the first intersection point of a primitive, a list element is created and the pointer in the root array is updated to point to that element. The result of the CSG evaluation and the primitive number are stored in that element. For the second intersection point, a second element is created and linked to the first one, and so on. The lists are accessed by updating a pointer, called the list pointer. For the first intersection point of a ray, a lookup is done in the root array and the list pointer is initialised to point to the list (if any) that starts with the primitive identifier of that intersection point. For every following point, the list pointer is updated one position in the list and, if necessary, a search is done for the primitive in the branches or if it is not found, a new branch is created. The position in the list always corresponds to the depth order in the list of intersection points. A more compact representation of the list structure is possible: for a certain position in the list, the order of the preceding elements is not important because only the active primitives determine the result of that specific interval. Lists thus might branch back or be joined with other sequences. 45.4 CSG-bvffer. So far, we have processed one pixel or scan-line segment with one pointer at a time. With a slight change, the list structure can be used for scanconverting a CSG model in the frame buffer for several pixels in parallel. If there is a pointer buffer for one scan-line (one pointer for each pixel) or a pointer buffer for the total image, and we have a list of depth ordered surface elements (polygons)

CSG evaluation

53

of the primitives, men the surface elements can be rendered in decreasing priority order (front-to-back) into the buffer one by one.

m~m
depth - ordered polygons CSG- buffer C S G list structure

Figure 4.16. CSG-buffer. Initially, all the pointers in the buffer are null. For all pixels that are covered by a surface element, the pointer is updated to point to the corresponding list element. If the element returns the value 'in' for the CSG-tree evaluation, the shading intensity of the surface element is rendered in the frame buffer for that pixel. All further processing can be omitted for that pixel. After some time, pointers may point to different levels in the list structure depending on the number of surface elements that have been tested (see 4.16).

in

1
fi
out
i -

in
I

C out D

B out _E

A out

out
i -

in 1

Figure 4.17. List structure with backward pointers. If a new element is added to the list a new tree evaluation has to be performed.

54

CSG evaluation

For the CSG evaluation it is necessary to know which intersection points have been processed. This information is available in the list structure. Adding backwards pointers to the list elements makes it possible to retrieve this information by tracing back the list of processed primitives (fig. 4.17). See algorithm 4.1 for an implementation.
function CSGclassification(var pntr : listelementpointer; prim : primitivenumber): boolean; { pntr = CSGbuffer(pixel), CSGbuffer is an array of pointers (pntr) to listelements, prim is primitive number of intersected/projected surface. Newelement(prim,backwardpntr,downpntr) creates a new list element, classifies the element (stored in the field valid), and returns pointer to element. The downpointer is for linking the branches. A listelement also has a forward pointer (next) that is set to nil. Newbranch inserts a new element at the head of the branches. } var pntrloc : listelementpointer; begin if pntr nil then begin if rootarray(prim) = nil then (first classification of prim} rootarray(prim):= Newelement(prim,nil,nil) ; pntr:= rootarray(prim) end else if Valid(pntr) then CSGclassification:= false {already set} else begin if Next(pntr) = nil then pntr:= Newelement(prim,pntr,nil) else (search in branches} begin pntrloc:= Next(pntr); while (Prim(pntrloc) <> prim) and (Down(pntrloc) <> nil) do pntrloc:= Down(pntrloc); {take next linked branch} if Prim(pntrloc) = prim then pntr:= pntrloc else {prim not found, make new branch} begin {link new element to be first branch} Newbranch(pntr.Newelement(prim,pntr,Next(pntr))); pntr:= Next(pntr) end end; CSGclassification:= Valid(pntr) end end; {CSGclassification}

Algorithm 4.1. Processing of list structure. For every new viewpoint or model update, the CSG-buffer has to be initialised. The CSG list structure, however, is only dependent on the CSG-tree definition. The

CSG evaluation

55

information in the list structure can be used for different views and different (geometric) primitive definitions, although in most cases new combinations of primitives will be added to the list structure.
4.6 Experiments and conclusions

4.6.7 Experiments To measure the performance of the methods, the CSG-tree traversal algorithms were coded in the C language. The listed processing times do not include the time for the intersection and for the shading calculations. The tests are performed on a 68000-based micro computer system. The test objects are a carburettor (plate 7), a car (terrain-vehicle) (plate 8) and a house (plate 9), all of moderate complexity, but with different distributions of Boolean operations. The efficiency of the CSG-tree evaluation and the CSG list structure can be measured in time and memory use. The size of the CSG list structure depends on the number of primitives and the type and position of the Boolean operations in the CSG-tree. In extreme cases, the lists may grow long, but in most cases the Boolean union operations dominate the CSG-tree, keeping the lists short.

Object Number of primitives Boolean operations union difference intersection CSG coherence total number of rays rays with intersection points number of sequences different sequences (= number of primitive combinations) Number of evaluations all intersection points first point coherence one list coherence list structure

carburettor 22

car 118

house 91

11 10 0

97 17 3

87 3 0

262144 219451 19227 218

262144 231536 21706 705

262144 261904 11579 107

383150 163719 17685 393

316579 85144 19385 1647

276579 14325 1322 141

Table 4.9. Statistics.

The examples give some indication of the number of tree evaluations and the number of list elements in the CSG list structure (table 4.9). The test results show that one list (first point included) is enough to obtain a good result. With a complete

56

CSG evaluation

list structure the number of CSG-tree evaluations is reduced to a minimum, and the list processing dominates the processing time. In fact the number of evaluations is so small that the influence of the chosen CSG-tree evaluation method almost disappears. The processing times are listed in table 4.10.

Object

Carburettor

Car 0L 99 96 54 56 47 43 LS 86 86 52 53 52 51 AP FP 0L LS

House

AP
Tree traversal Standard Early out Position, cod. Statue tree Bitparallel Standard Status tree

FP 325 305 202 218

AP
1383 1292

FP

0L 60 59 24 26 29 24

LS 55 55 27 28 28 27

774 722 348 349

2853 1103 2654 1030

294 109 278 108 343 146 65 64 399 122 60 64 501 140 75 43 70 62

171 163 241 37 353 40 79 29

311 147 243 104

1885

1256

352

300

(AP - All Points, FP = First Point, O L = One List, LS - List structure). Table 4.10. Processing times of tree traversal and coherence methods (in CPU seconds).

The standard tree traversal performs a complete evaluation for each point. The status-tree method only updates local changes of status. For the bitwise operations the two methods would be identical if the length of the bit-string was not limited to 32 bits. The results show that the bit-parallel evaluation is slightly faster than the comparable standard and status-tree traversal method. 4.6.2 Conclusions For standard software implementations both the status-tree traversal and the traversal with position coding are efficient. However, most important is the use of coherence. A combination of 'first point' and 'one list' produces a 90% reduction. The status-tree and positional-code techniques may not be suitable for some parallel processing systems because the tree traversal may be different for each ray (pixel). Moreover, the status tree must be stored for every ray. For such systems, the bit-parallel CSG-tree traversal will be the most efficient.

Display and conversion algorithms

57

5. Display and conversion algorithms Following the description of the definition of the polygon models and the CSG evaluation techniques in the previous section, the thud data structure, a spatial subdivision method, is discussed in this section. The spatial subdivision provides a pre-sorting of the data and a method to localise the data by position. The method is used for a CSG projective and ray tracing algorithm and its use for two conversion algorithms is outlined. /
5.1 Spatial subdivision

Hidden-surface algorithms can be divided into projective and ray tracing algorithms. For projective algorithms, the surface elements are projected onto the image plane into one direction (opposite to the viewing direction) and benefit can be obtained from sorting and coherence techniques. With ray tracing, the 'primary ray' is directed into the viewing direction, but additional 'secondary rays' are cast into different directions as a result of reflection, refraction or shadow tests. As a result, coherence is lost and sorting techniques have to be replaced by search techniques for finding possible intersections. For complex models, both the sorting and the searching can be time consuming, and a preprocessing and/or an additional data structure is needed to enhance the sort and search. 5.1.1 Enclosing box method A first candidate technique is a hierarchy of enclosing boxes [Clark, 1976]. Given the bounding boxes of the volumes, a tree of enclosing boxes is created with the bounding boxes of the primitives at the leaves and at every intermediate node a bounding box that encloses the boxes of its subtrees. If, for instance, an object is tested for intersection with a ray, first the enclosing box of the object is tested. If the ray misses the box, then there is no ray-object intersection. If the ray intersects the box, the hierarchy is recursively descended and the boxes of the subnodes are tested, and so on (see fig. 5.1).

Figure 5.1. Hierarchy of enclosing boxes.

58

Display and conversion algorithms

At a leaf of the hierarchy, the primitive is tested for intersection. Enclosing boxes can also be used for a depth-first ordering. A simple implementation uses rectangular boxes oriented towards the view direction. More elaborated implementations incorporate arbitrarily oriented boxes and multiple types of bounding volumes [Weghorst et al., 1984], [Kay and Kajiya, 1986]. For models with a large number of polygons, the hierarchical enclosing box method tends to become inefficient: if a primitive contains more than a few hundred polygons, the ray intersection with that primitive becomes quite laborious. In [Rubin and Whitted, 1980], the enclosing box hierarchy is therefore extended down to the polygon level. Because of the great amount of data involved in a complete expanded tree, the tree is dynamically expanded when needed for the ray intersection. Another (hybrid) approach is a recursive binary subdivision of the object box [Rubin and Whitted, 1980]. 5.1.2 Spatial subdivision A second approach is the use of spatial subdivision methods: the object space is subdivided into regular 'cells' and the objects or polygons are classified according to their position in these cells. A simple implementation divides the object space in a rectangular grid or cell structure, and stores the objects or polygons that are contained in a cell in a 'bucket' related to that cell. A number of methods have been developed that differ in the type of cell structure, two of which are: - Fixed or adaptive cell structures. In the adaptive variant, the cell structure accommodates the spatial distribution of the items (fig. 5.2).

Figure 5.2. Spatial subdivision. A useful scheme is to set a limit on the maximum number of items in a cell. When the number of items exceeds this maximum, the cell is divided and the contents of the cell redistributed over the new cells. - Regular or arbitrarily sized cells.

Display and conversion algorithms

59

Both versions are described by Rubin and Whitted[1981]. The arbitrarily sized cells are created by (adaptively) dividing parent cells according to a load balancing strategy. See also [Dipp and Swensen, 1984]. The methods may also differ in the access method to the data: by tree traversal or by index in a directory. With tree traversal, the object space is recursively subdivided and the subdivision hierarchy is represented by a tree (bintree or octree). The object data is accessed by traversing the tree until the desired leaf node is found where the data can be accessed. The spatial directory provides a direct access to the data. 5.1.3 Spatial directory The EXCELL method of Tamminen[1981] is a spatial index (directory) to an adaptive cell structure created by a recursive binary subdivision. Data is stored in buckets related to the cells of the subdivision. The spatial directory can access the buckets directly. An address computation on the coordinates of a point yields the index in the directory where the bucket identifier can be found.

Figure 5.3. Cell structure.

The cell structure is created by an adaptive recursive subdivision in such a way that each bucket contains no more than a certain maximum amount of polygons. Initially, there is one empty cell, one empty bucket and one entry in the directory. The procedure Insert (algorithm 5.1) inputs polygons and stores them in the bucket. When the maximum number of elements that can be stored in one bucket is exceeded, the cell is subdivided and the polygons are re-divided over the two cells and stored in the corresponding buckets (fig. 5.4). The cell structure is thus locally subdivided. At the same time, the directory is subdivided globally to accommodate the maximum resolution of the cell structure. For each bucket there is at least one

60

Display and conversion algorithms

procedure Insert(pntr : elementpointer; {pointer to data} point : vectorpointer; {test point} dir : directory); { inserts reference (pntr) in bucket of cell where point is located; directory is record that contains an array of type cell; cell is a variant record for subdirectory or bucket; Newpoint calculates coordinates of point relative to subdirectory box.} var done : boolean;

begin done:= false; while not done do with dir(Index(point)) do if celltype = directory Chen begin Insert(pntr,Newpoint(point,cellbox),subdirectory); done:= true end else {celltype is bucket} If bucket .size maxsize then begin {subdivide bucket} if directorylevel = bucket.level then if directorylevel = maxdirlevel then done:= Putinoverflow(bucket, pntr) else Subdividedirectory(dir); if not done then Subdividebucket(dir(Index(point))) {subdivide and re-sort elements over the two buckets} end else done:= Putin(bucket,pntr) end; {Insert}

Algorithm 5.1. Insert for a two level directory.

pointer in the directory, and for partitions that are locally not subdivided to the maximum depth, more than one index in the directory is available. To avoid an explosion of the directory size, the cell structure is subdivided until a maximum depth level (resolution). Overflow buckets are used to store the additional data for a cell. Further, for large models, a two-level directory is used. A more detailed description of the EXCELL method and its use for ray tracing and block model conversion is given in [Tamminen et al., 1984], where also is shown that the subdivision method gives a constant time performance for ray tracing. An octree like structure is used by Glassner[1984] with the same results. Because we seek to find methods to process large polygon models, the constant time performance of the subdivision methods is more attractive than the logarithmic search of the enclosing box method. In the following sections, the spatial subdivision is used as a 3D bucket sort for a projective algorithm, as a spatial subdivision method for localising the high-chance candidates for the ray intersection in

Display and conversion algorithms

61

.a
6. ', c'

.a
'.

.a
'c '.

.a _1_L

cell structure directory [>J

'd

'd

r ih i i iniM]Uk5S5s \ b | d |c,e|
I 2 3

buckets

W.i

Ia|
5

Figure 5.4. Creation of subdivision.

a CSG ray tracing algorithm, and for localising the object data (polygons) that are relevant for a subnode evaluation in the block model conversion and boundary evaluation. 5.2 CSG list priority algorithm List priority algorithms render surface elements in order of increasing priority into a frame buffer, using the painter's algorithm. The depth priority version sorts the surface elements dynamically for each different viewpoint [Newell et al., 1972]. Real-time performances have been obtained with a fixed priority ordering [Schumacker, 1969], [Fuchs et al., 1983]. The methods are based on a preprocessing phase in which the surface elements are stored in clusters. This reduces the processing for a viewpoint dependent sorting. With a spatial index for the polygon database, a similar pre-ordered collection of polygons (independent of the viewpoint) is obtained.

bucket retrieval in depth order

polygon depth-sort

scan-conversion CSG-test

Figure 5.S. Scheme of list priority algorithm.

The display algorithm is as follows (fig. S.S). Because of the binary partitioning of the cell structure, the output order of the buckets is easily established. Cells behind and outside the viewing cone are discarded. Polygons in cells that are partly inside the window are clipped. The vertices are transformed to eye space coordinates and for each bucket the polygons are sorted in depth order. There may be priority conflicts between polygons of different primitives, because primitives may

62

Display and conversion algorithms

overlap. To avoid these conflicts, the polygons are clipped against each other. This can be done in a pre-processing (done only once but the number of polygons strongly increases) or during the sort.
procedure L i s t p r i o r i t y ( d i r : d i r e c t o r y ; eyepoint : v e c t o r ) ; { CSGclassification i s algorithm 4.1 Morecell8 r e t r i e v e s buckets in correct depth order } var nextcell : c e l l ; {bucket} begin while Morecells(dir,eyepoint,nextcell) do i f Inwindow(nextcell) then with nextcell.bucket do begin Sortpolygons; {and c l i p in case of overlap} for each polygon do for each pixel do {covered by polygon} if CSGclassification(CSGbuffer(pixel),Primnr(polygon)) then Setpixel(pixel,Shadingintensity(polygon)) end end; {Listpriority}
Algorithm 5.2. List priority algorithm.

CSG classifications are done with the CSG buffer and list structure described in section 4.5. In contrast to the standard list priority algorithm, the polygons are rendered in decreasing priority order (front-to-back) into the frame buffer. Each polygon is scan-converted and for each pixel covered by the polygon, the pointer in the CSG-buffer is updated (processing of a new intersection point in the ray tracing terminology). If the list structure indicates that the polygon is 'in' for that pixel, its colour is set in the frame buffer (see also fig. 4.16). A difficulty arises with coincident faces. For a correct result, both faces have to considered for the CSG evaluation. If there are two coincident faces, one of the two is processed first. If that face turns out to be valid and is drawn, a fault arises if if the second one (that is not tested) would have made the total result invalid. Another drawback of the depth sort is that it takes excessive processing to remove all priority conflicts, e.g. overlap tests, polygon splitting. A method to correct the problem of coincident faces and to avoid excessive preprocessing is to use a depthbuffer. Coincident faces and intermingled polygons can then be detected. However, if three polygons are involved in the sorting error, there is no guarantee that the correct order can be determined, because only one depth value is stored. 5.2.1 Experiments To obtain an indication of the performance, the algorithm has been implemented on a 68000 micro-processor without a floating point processor. The memory requirements are excessive due to the CSG-buffer, depth buffer and the polygon data base.

Display and conversion algorithms

63

The processing times for the scan-conversion are dependent on the image size and the model complexity. The time to sort the polygons is linearly dependent on the number of polygons, since the time required to sort a bucket is constant and the number of buckets is linearly dependent on the number of polygons. It may therefore be expected that the total time for rendering is also linear dependent on the number of polygons.

b 2.0 1.0 0.5 0.25 a. b. c. d.

1 96 144 192 256 457 769 1164 1753 20.15 34.45 55.45 80.48 2.48 4.40 6.58 9.98 1. 2. 3. 4. 5. 6. 0.82 1.35 2.08 3.33 5.58 7.10 8.82 11.20 4.59 5.67 6.98 8.64 17.08 22.20 28.20 36.93

Subpicture of plate 3 Modelling tolerance Initial number of polygons Number of polygons after pre-processing

Preprocessing Vertex transformation Bucket retrieval and polygon sort Scan-conversion and CSG test Depth-buffer test Total 2+3+4+5 incl. buffer initialisation excl. graphics write

Subpicture size 256*256 Max. bucketsize 24 polygons

Table 5.1. Processing times for CSG list priority algorithm

To get a realistic impression of the drawing times for complex models (more than 10,000 polygons) the figures of table S.1 could have to be multiplied with a factor of 50-100. Even if the hardware situation is taken in account, it is clear that the processing times of this implementation of the list priority algorithm are no improvement on the reported scan-line algorithms [Crocker, 1984]. Compared with the scan-line algorithms, the list priority algorithm might be more suited for large polygon models residing in secondary storage, because of the 3D cell-oriented processing. 5.3 CSG ray tracing algorithm As explained in section S.1, the spatial subdivision structure is specially suitable for enhancing the ray tracing algorithm. The ray is first intersected with the cellstructure to find the cells that are intersected by the ray, and then each cell is tested sequentially for ray intersections with the polygons in the cells. The spatial subdivision method differs from the hierarchical enclosing box method in that the cell structure is space oriented where as the box structure is object oriented; further, with the hierarchical box method, the ray intersection proceeds top-down in contrast with the local access for the spatial subdivision method. The ray tracing algorithm for the hierarchical box method descends the

64

Display and conversion algorithms

hierarchical tree and tests the ray for intersection with the boxes of the subnodes. Subtrees that fail to pass the box test can be discarded. At the leaf nodes the ray is intersected with the primitive solids, and returning up the tree, the intersection intervals of die left and right subtree are merged. The ray classification of the root gives the final ray-object intersection intervals. The ray tracing algorithm for the cell structure proceeds by local access. First the intersection of the ray with the total structure is calculated and the cells are stepwise traversed by calculating me intersection of the ray with me cell planes and determining which cell is traversed next. The spatial index (directory) is used to access the polygons that are contained in the cell. See fig. 5.6a and algorithm 5.3.

procedure Raytrace(dir : directory; ray : raysegment); {directory of cell partitioning and record with ray parameters; ray.point is query point} begin while Inbox(dlr.box,ray.point) do with dir(Index(ray.point)) do if (celltype directory) then Raytrace(subdirectory,ray) else {datacell} begin Raycell(bucket,ray); {tests polygons for intersection} Updateray(cellbox,ray) {calculates the intersection point of the ray with the cell planes and finds new query point in next cell} end end; {Raytrace}

Algorithm 5.3. Standard traversal of cell structure.

The index in the directory is found by an address computation on the coordinates of a query point (for all points within a cell, the address computation function gives the same index value). A similar method is described in [Fujimoto et al., 1986] for traversing an octree space subdivision: a neighbour finding technique on the basis of octree indexes. Both methods are better than the method described in [Glassner, 1984], which classifies each point by descending the complete octree.

Display and conversion algorithms

65

w
a. standard ray traversal Figure 5.6. Ray traversal methods.

b. recursive ray traversal

Another method is feasible: a tree traversal method for the cell structure. This method uses a cell structure that is created by a binary subdivision. This recursive ray traversal method intersects the cell structure and recursively subdivides the ray and proceeds with the partitioning (collection of cells) first intersected. If the ray interval only intersects a single cell then the polygons in that cell arc tested for intersection with the ray. See fig. 5.6b and algorithm 5.4.
procedure Raytrace(dir range ray directory; directoryrange; raysegment); {ray parameters}

var rayl,ray2 : raysegment; first, second : directoryrange; begin if Rayincell(dir,range,ray) then if not uniform(range) then {range covers more than one cell) begin {subdivide again} Clipray(dir,range,first,second,ray,ray 1,ray2); {clips ray and splits directory range in first and second intersected partitioning of cell structure} Raytrace(dir,first,rayl); {first intersected partition) Raytrace(dir,second,ray2) {second intersected partition} end else {ray intersects one cell} with dir(Min(range)) do if celltype - directory then Raytrace(subdirectory,subdirectoryrange,ray) else Raycell(bucket,ray) end; {Raytrace) Algorithm 5.4. Recursive traversal of cell structure.

66

Display and conversion algorithms

ray percentage

12

16

number of cells intersected

Figure 5.7. Number of cells traversed by ray before object of plate 5b is intersected or cell structure is left.

Both algorithms have been implemented but no clear differences in performance could be found: the average number of cells traversed for each ray is more than two or three, which would be beneficial for the sequential traversal, but it is not large enough to justify the initial cost of the recursive ray traversal (fig. 5.7).
time son

16

20

2i

max. bucket size

Figure 5.8. Processing times in CPU minutes for cell traversal, polygon intersection and shading for objects of plate 5b modelled with 1300 polygons, subpicture resolution 256*256.

Display and conversion algorithms

67

The total processing time for the ray tracing breaks down into the following components: cell traversal, polygon intersection and shading. Their contributions are depicted in fig. 5.8, which shows that the intersection is still the major timeconsuming activity. The constant time performance is confirmed by the results of fig. 5.9.

time loo

200

too

1000.

2000

3000

WOO

5000

number of polygons

Figure 5.9. Constant time peifoimance in CPU minutes for object of plate 7d, subpicture resolution 256*256.

Unfortunately, the constant time is constantly very high. 53.1 Item-buffer Both the projective and a ray tracing algorithm can share the same CSG list structure. An additional efficiency can be obtained by the use of an item-buffer [Weghorst et al., 1984] that can be added to the CSG-buffer. The itembuffer stores for each pixel a pointer to the surface element that is visible for that pixel. The item-buffer is created by a projective hidden surface algorithm and reduces the search for the first intersected surface element in the ray tracing algorithm to a simple look-up in the buffer. When analytically defined primitives are used, the CSG-buffer itself can serve as an item-buffer because the primitive number is stored in the CSG list structure and can be retrieved with the list pointer (section 4.5). For primitives defined as polygon models, the item-buffer stores a pointer to the polygon that yields the first (valid) intersection point. For standard polygon models we can now proceed to cast additional rays that are offsprings from the 'primary' ray to calculate shadow and to simulate mirroring reflections and transparency with refraction (see fig. 5.10).

68

Display and conversion algorithms

secondary ray

primary ray

^<^Z//

objects A-B

Figure 5.10. Item buffer.

For CSG models we need to know the CSG status (whether the starting point of the 'secondary' ray is within any primitive or not). This information is also stored in the CSG list structure. This information can be retrieved by following the backward pointers and thus the list can be expanded for the secondary rays.

1. Only primary rays 2. With shadowing 3. With shadowing and mirroring reflections

15.70 22.36 29.58

0.32 6.95 14.20

0.59 1.23 1.83

0.32 0.96 1.55

81.88 109.06 140.35

18.12 46.18 76.55

a. Average no. of polygons tested for each ray without/with item buffer. b. Average no. of polygons intersected per ray without/with item buffer. c. Processing time without/with item buffer for picture size 256*256, (532 polygons after pre-processing). ~Table 5.2. Processing times ray tracing with item buffer in CPU mimutes for object of plate 6d 5.4 Conversions

CSG hidden-surface algorithms are efficient for displaying the object during the design phase of the CSG model. But when a static model is used for animation and simulation it may be worthwhile to carry out a preprocessing that converts the CSG model into a surface model that can be displayed in nearly real-time with polygon shading hardware. Also for some CAD applications, more explicit geometric and volumetric information is needed, which can be obtained by a spatial or boundary evaluation. Finally, in order to compress the data base, it may be desirable to convert sub-models into a single component that can be used again as a primitive. Because the data structures described in the previous sections can also be used for a complete conversion of the CSG model, outlines of two conversion algorithms are given here too.

Display and conversion algorithms

69

5.4.1 Block model conversion A block model representation is created by a decomposition of the object into rectangular blocks. Usually an adaptive spatial subdivision method is used resulting in an octree representation for the 8-ary subdivision, and in a bintree for a binary space subdivision strategy. The DF-representation (Depth-First) is a compact linear representation of the block model, and for many applications this linear, pointerless representation is sufficient [Tamminen and Samet, 1984]. In [Lee and Requicha, 1982], a block model conversion for CSG representations is given based on an intersection of the object with a bundle of parallel rays and conversion of the ray-object intersection intervals into arrays of volume elements that are merged into a block model. In [Tamminen et al., 1984] the block model is created by converting a boundary representation into a hierarchical block model using a spatial subdivision method. The object space is subdivided either until the cell is not intersected by a face of the boundary, or the maximum resolution is reached. A point-in-polyhedron test labels the node as 'in' or 'out'. In [Tamminen and Samet, 1984], the boundary representation is directly converted into a DF representation of a bintree. The algorithm consists of two phases. First, the faces are one by one converted into a linear bintree and merged. Secondly, the 'empty' internal nodes are set to 'full' with a component labelling technique. In [Samet and Tamminen, 1985], a CSG halfspace model is evaluated with a bintree method. Object space is recursively subdivided and for each cell the CSG-tree is pruned, until a cell classifies as 'in' or 'out', or the maximum resolution is reached. In that case an additional ray classification is done. The algorithm described here combines different aspects of these methods. It converts a CSG polygon model into a DF bintree representation using a spatial binary subdivision method. Initially, the CSG polygon model is stored in the spatial index, as described in the previous section. This gives a first level of space subdivision. A second level of subdivision is applied in the following way. The cells of the binary space subdivision are traversed in DF-order and the cells are tested by ray classification. If the classification is not uniform (i.e. the cell is intersected by the boundary of the composite object), the cell is recursively subdivided and the classification is repeated on the subcells. If the maximum level of subdivision is reached the cell is classified as 'in' or 'out' on basis of the position of the center point of the cell. The ray classification is made efficient by accumulating the CSG evaluation results of earlier processed nodes in the CSG-buffer. The CSG-buffer performs here the same function as the moving edgelist of section 3.3. It stores intermediate results that are passed to neighbouring cells of the DF-representation. The information is here only moved into one direction: the direction of the rays. The rays form a bundle aligned with one of the axes of the spatial subdivision. The size of the CSG-buffer is n*n if the maximum resolution of the block model is n*n*n. 5.4.2 Boundary model conversion For the boundary evaluation, the intersecting polygons in each bucket belonging to different primitives are split. The next step is to classify the polygons as 'on' or 'not on' the boundary of the composite object by a ray classification. If the polygon does not belong to the boundary,

70

Display and conversion algorithms

the polygon can be removed. The result is a set of polygons that form a surface model, which can be used again as a primitive solid. Again, the classification can be made efficient by using the CSG-buffer. However, since the CSG-buffer has afixedresolution,some of the surface elements may be too small for the resolution of the buffer: no ray hits the element. These non-classified elements can be classified by vertex classification: elements that share a vertex with a classified element, will have the same classification.
5.5 System overview and conclusions

The algorithms described in the chapter 3, 4 and 5, can be combined to form the system depicted in fig. 5.11. The CSG representation is specified by the user. This CSG definition is stored in the CSG-tree. The primitives are converted into polygon models, and these are input in the spatial directory.

interactive input

, | . i
i i
i

primitives CSG i
i i

approximation I integrity filter I

interactive viewing

I ,
1 1

CSG list priority algorithm I item-buffer


J, 1

<! <' <


spatial index polygon data base

l high-quality rendering i \
I

CSG-buffer
I

CSG ray tracing algorithm

user interface

system

Figure 5.11. System overview.

During the projective display and ray tracing, the CSG classifications are stored in the list structure (CSG-buffer). As long as the CSG definition is not changed, the information in the list structure can be re-used. The item buffer is set by the projective algorithm and can be used by the ray tracing algorithm, if the same viewing parameters are used. Although the system heavily relies on pre-processing and coherence, the overall performance of the system is not sufficient to handle very large numbers of polygons. To be useful for these complex models, the algorithms will have to be improved or be implemented on more powerful hardware systems.

Part 3 Display of CSG halfspace models

The CSG depth-buffer algorithm is a hidden-surface algorithm for the display of solid models defined with Constructive Solid Geometry. Both the visibility calculation and the CSG classification are performed by simple depth comparisons at the pixel level. This makes this algorithm particularly suitable for implementation on VLSI-based hardware display systems, which have processing capabilities at the pixel memories. In its most straightforward implementation, the CSG depth-buffer requires a considerable amount of processing and intermediate storage. The processing can be reduced by a preprocessing that determines for each primitive the active part of the CSG-tree. The intermediate storage can be reduced by a restructuring of the CSG-tree. A tree traversal algorithm is presented that combines these different techniques and gives within a wide range any desired trade-off between processing and memory use. The algorithm can also be used, in combination with a subdivision method, for logic-enhanced pixel-square systems or multi-processor systems. The techniques are applied for the display of CSG halfspace models.

CSG depth-buffering techniques

73

6. CSG depth-buffering techniques The depth-buffer algorithm is a projective display algorithm that performs the hidden-surface removal by depth comparisons at the pixel level. CSG objects can be displayed with the depth-buffer algorithm by performing additional depth comparisons on the surfaces of the primitive solids. In its basic form, the algorithm requires a large amount of buffer memory and a large number of depth comparisons. Methods are described in this chapter that reduce the number of comparisons and the memory requirements. A tree traversal algorithm is presented that allows, within a wide range, any desired trade-off between memory use and processing.
6.1 Introduction

The depth-buffer algorithm is an elegant and simple projective hidden-surface algorithm that displays all types of surfaces that can be scan-converted or subdivided [Catmull, 1974]. The algorithm operates on a depth-buffer and a frame-buffer. The depth-buffer stores the depth value for each pixel and the frame-buffer stores the shading intensity value. The depth-buffer is initialised to a maximum depth and the frame-buffer to the background colour. The surfaces are rendered in object order, and for each pixel that is covered by a surface, a depth comparison is done on the value in the depth-buffer: if the depth value of the surface is smaller than the value in die buffer, the pixel is rendered and the depth value of the surface is written in the buffer, overwriting the old value. The processing can be reduced by dividing the surfaces of the objects into forward-facing and backward-facing faces. For non-composite solids only the forward facing faces have to processed. For CSG objects, additional tests have to be done to determine which surfaces contribute to the composite solid and which surfaces of primitives are removed by difference or intersection operations. Now also backward-facing faces may be visible due to these operations. Each point of a surface can be classified by comparing it with die surfaces of the other primitives involved in the CSG definition (see section 4.1). For the depth-buffer algorithm this leads to die procedure that a surface is compared with die surfaces of other primitives before it is rendered in die framebuffer with die standard depth-buffer algorithm. The basic algorithm scan-converts (or subdivides) die surfaces of die primitives, and for each pixel me deptfi values of the forward-facing and die backward-facing surfaces of the primitives are stored in the buffer. The next step is to classify each point by a CSG-tree traversal. The CSG-tree is traversed in postorder and at each leaf node die depth of die test point is compared widi the depdi values of die forward-facing and backward-facing faces of die primitive at mat leaf node. This classifies die point as 'in' or 'out'. At each composite node, die classifications of its left and right subtree are combined according to die Boolean operator at diat node. The classification at die root gives die classification for the test point This algorithm correctly processes coincident faces of two or more primitives. For a certain depdi value all primitives are classified successively and thus all coincident points are involved in die total classification. For a solid, zero or an even

74

CSG depth-buffering techniques

number of depth values (projected surface elements) are needed for each pixel. To find the correct number of depth values in all cases, the (convex) solid is decomposed into a set of forward-facing surface elements and a set of backward-facing elements. The set of forward-facing surface elements yields the first and the set of backward-facing elements yields the second intersection point. Coincident points of forward-facing (or backward-facing) surface elements are taken as one intersection, while coincident points of a forward and a backward-facing element are taken as a double intersection. The basic algorithm requires the depth values of all faces at each pixel to be known and for the classification of a surface the depth value of the surface has to be compared with the depth values of all other primitives. Clearly, this algorithm requires an enormous amount of buffer memory and a large number of depth comparisons. The algorithm can be improved in the following ways. The number of depth comparisons can be reduced by limiting the tree traversal to those primitives that are related in the CSG-tree, i.e. have a common difference or intersection operator in the tree, and which geometrically overlap. An image subdivision may further contribute to the reduction of the classification tests. These notions are further explored in section 6.2. The storage of depth values can be reduced by regenerating the depth values at the moment when they are needed. This might seem expensive but for VLSIbased hardware systems (to be discussed in chapter 7), the processing is very fast and memory is the limiting factor. Even if all depth values are generated on the fly, the intermediate classifications of the tree traversal have still to be stored if the pixel are processed pixel parallel. These classifications can be stored as bits in a bitstring that serves as a stack. Clearly, n bits are necessary for the stack, if n is the level of the tree (see also fig. 4.10 of section 4.4). It is possible to eliminate this storage almost completely by a restructuring of the CSG-tree, again at the cost of extra processing for the primitives. This is discussed in section 6.3. Finally, in section 6.4, a CSG-tree traversal algorithm is described that combines the different techniques, and adapts the tree restructuring to the available memory. 6.2 Active tree The CSG object is internally represented by a binary tree (CSG-tree) with the Boolean operators (union, difference and intersection) at the composite nodes and the primitive solids at the leaf nodes. See fig. 6.1a for an example. The CSG-tree can be converted into a positive form by replacing the difference operator at each node by the intersection operator and replacing the right subtree by its complement. A -B = A p , B

CSG depth-buffering techniques

75

By applying de Morgan's laws


A \jB =A p,B

A r\B

=A {JB

recursively to the complemented subtree, a CSG-tree consisting of Boolean intersection and union operators only is obtained that has primitives or complemented primitives (ie. voids) at the leaves (fig. 6.1b).

/ \ E / \
"

/ \
F

/
p

u /.\

/ D
P

A
/ B

/ \ /E \ 'F
n \
A

C a. C'SO-tree

u / \

C D b. positive tree

U-tree

\.
0

/ \ B / \
C

/ \ . \ I
F

PJ1ZJL B

d. I- tree and active tree

Figure 6.1. CSG-tree and tree restructuring.

For a chosen primitive, e.g. P in fig. 6.1b, the CSG-tree can then be re-ordered into a Boolean combination of that primitive with two subtrees. One subtree (the I-tree) forms an intersection with the primitive, and together they form a union combination with the second subtree (the U-tree) (see fig. 6.1c). The I-tree and U-tree describe the 'active zones' for the primitive P [Rossignac and Voelcker, 1986]. When the object is rendered with a depth-buffer test, the U-tree is not needed for the classification of a primitive, because union operations are automatically taken care of by the depth test. For the CSG depth-buffer algorithm, only the part of the primitive inside the I-tree contributes to the composite object and need be rendered.

76

CSG depth-buffering techniques

A primitive's I-tree can be reduced by pruning those primitives from it that either do not intersect the primitive at all or surround it completely, because their contribution can be determined a priori. This is done in a preprocessing stage and can be implemented with an overlap test on the bounding boxes in object space, using the following properties of the union and intersection operators: in out in out {J {_J (~\ (~) tree in tree* tree tree-* tree tree-* out

Here 'tree' stands for the other subtree of the composite node. The result 'tree' means that the classification is determined by the other subtree, in which case the composite node reduces to that subtree. The I-tree can be reduced further by observing that for any given part of an image, not all I-tree primitives necessarily contribute to the intersection. Division of image space into segments and processing primitives on a segment-by-segment basis therefore offers the possibility of an additional reduction in processing. The pruning is done by finding which primitives are active in a segment (by means of image-space bounding boxes) and accordingly reducing their I-trees for that segment (see also section 4.2). The reduced I-tree is called the active tree. Note that a primitive without an I-tree can be rendered in the depth-buffer directly; however, a primitive with an empty active tree must not be rendered, since the intersection is null. For the CSG evaluation, only the visible part of the boundary of the primitive has to be tested. The forward-facing part of the primitive is the visible part unless the primitive is complemented, in that case the backward-facing part is the visible part. Whether the boundary at a pixel is inside the active tree is determined by a tree-traversal method as described in the previous section. After the classification, for each primitive, those pixels covered by the surface that classify as 'in' are rendered using a standard depth-buffer test. 6.3 Tree restructuring A drawback of the algorithm is the need to reserve a certain number of bits of the image memory for the stack of the CSG-tree traversal. This can be overcome by a restructuring of the CSG-tree [Thomas, 1983], [Okino et al., 1984], [Goldfeather et al, 1986]. 63.1 Sum-of-products form Any CSG-tree can be converted into a sum-of-products form, that is a union of subtrees with only Boolean intersection operations,
O

u n Py
i j=\

CSG depth-buffering techniques

77

where a primitive or
P

U=

its complement at a leaf node

m(i) = is the number of primitives in product i A positive CSG-tree can be converted in this form by the following substitution:
A A n <B u c> = < n 5> u

C A

n o

Let us denote the display operation by D, where D(object)denotes the part of the object that is to be rendered. To render the union of products, it suffices to render the products with a depth-buffer algorithm. D(object) = D J O P) = v j 0 < n * V = n11 ( n ' y ) where min stands for: take for each pixel the nearest point in depth. Each product can be rendered by displaying the valid parts of the primitive boundaries, i.e. those parts that are contained in the product (~\ Pi;.

oen Pij) = u (D(pik) n n pa c* *pa >)


= min (D(Pik) n
*-'

m(i')

m(i)

m(i)

n ' y C a * p y ))
;=i

For each primitive, the contribution is the sum of the contributions of all its products, and thus for the total object the rendering is equal to D(object) = rninmin(D(P,) p , C\pjk
()
">(j)

(pi*pjk))

where now i is the index for the primitives, n(i) is the number of products for primitive i (the number of products that contain the primitive i), and m(j) is the number of primitives contained in the product j . Each primitive can be rendered by scan-converting for each product the visible parts of the primitive and disabling those parts that are not contained in the product. For projective display only the part of the boundary of a primitive that is directed towards the viewpoint can be visible.

78

CSG depth-buffering techniques

D(Pf) ifP is primitive


D(P) = '

. D (Pb) if P is complement of primitive where P* and Pb denote the collections of forward-facing and backward-facing faces of P. For a detailed description of possible implementations see [Thomas, 1983] and [Goldfeather et al., 1986]. The tree restructuring algorithm eliminates the evaluation tests at the cost of rendering the primitives multiple times. The size of the sum of products form depends largely on the number of Boolean intersection and difference operators in the top part of the tree. The worst case is a tree of intersection operations with pairwise unioned primitives at the leaves; this gives 22<-"~1^ terms for 2" primitives. In practice, however, union operators dominate at the top of a CSG-tree, because, in general, larger objects are assemblies (unions) of smaller parts. 63.2 Tree pruning The active tree concept can be validated by observing that the processing can be reduced by avoiding the rendering of empty products. A product contributes to the rendering of P, if all primitives in the product at least partly overlap P. This means that the rendering of P is dependent on those primitives that share a Boolean intersection operation with P in the original tree and (at least partially) overlap with P. The primitives that satisfy these requirements will be called active primitives for P. To eliminate empty product forms, for each primitive P a new CSG-tree is calculated in a preprocessing step that only contains the active primitives. All nonactive primitives are pruned from the tree according to the following pruning rules: out \j tree = tree out (~>i tree = out The resulting tree is the active CSG-tree for P. Restructuring the total CSG-tree on basis of the active trees leads to
(<) m(J)

D{object) = min min (D(P,) n

C\ p'jk Vi * Fik ) )

where r^P'jk denotes a product resulting from the active CSG-tree of P,-. 6.4 A tree traversal algorithm In this section, a new version of the CSG depth-buffer algorithm will be derived that integrates the tree restructuring and tree pruning of sections 6.2 and 6.3 with the tree traversal method described in section 6.1. The basic idea is that the tree restructuring (and the corresponding tree expansion) can be simulated by additional (sub)tree traversals.

CSG depth-buffering techniques

79

To clarify the concept, the following example will be used. Figure 6.2a shows a CSG-tree. From this tree the active tree is derived for the primitive P (fig. 6.2b). Tree restructuring gives the sum of products form (fig. 6.2c). The primitive P can now be rendered by scan-converting, with a depth-buffer test, those parts of the boundary of P that are inside the different products (fig. 6.2d).

/
u

n X u t> R p

"

/ / \
w " T Q

\
/>

/ \
n

/\
S

\
u R S

/\

/\

a. CSG-tree

b. Active tree

n PQS

n n POT PRS

n PRT

D(P)= (DIP) u (DIP) ulDIP) u (DIP)

n n n n

OS) OT) RS) RT)

c. Restructured tree

d. Display operations for P

Figure 6.2. Tree restructuring and tree traversal.

Instead of restructuring the tree, each primitive combination (product) can also be found by a specific traversal through the tree: each product represents a unique combination of sub-products of the union operations. The tree traversal is guided by the following rules: - At each composite node with a Boolean union operation, only one of die subtrees at a time is visited, - At each composite node with a Boolean intersection operation both subtrees are visited. At each node, a Boolean variable (falseAnie) records the status information that indicates which subtree still has to be visited. If the tree (fig. 6.2b) is traversed in postorder, the order of the primitives in the product is the same as indicated in fig. 6.2d.

80

CSG depth-buffering techniques

Initially, the status of all nodes is cleared. The tree traversal for the first product starts by descending the left most branch of the tree (see figure 6.2). After processing leaf node Q, the tree is ascended (for the union operations only one subtree is processed at a time), and the right subtree of the Boolean intersection operation is descended. Primitive S is processed and marked (the processing refers to the scanconversion or subdivision mentioned in section 6.1). In the next traversal, Q and T are processed. Now the composite node of S and T can be set. (If a composite node is set, the status variables of its subnodes can be cleared). For Q now all combinations have been processed, Q is set and the status information of the right subnodes (in this case the composite node of S and T) is cleared. In the next tree traversal, R is visited and the same combinations are found for R. After processing these combinations, both the left and right subtrees are set and all products are found. The algorithm combines the tree traversal algorithm (section 6.1) with the tree restructuring of section 6.3, in the sense that processing of the primitives is minimised when a stack (bits of a bit-string or an array of booleans) can be used for the tree evaluation, and memory use is minimised (minimal 3 bits) with the tree restructuring or the tree traversal method described in this section. Also a combination of both methods can be used: the top part of the tree is processed with a stack and subtrees are processed with a repeated tree traversal. If the number of available bits (per pixel) is m, and the depth of the tree is n then for - m = 3; for each product the tree is traversed to find the required combination of primitives and the surface is rendered (for the 'in' pixels) into the frame-buffer with the standard depth-buffer test. - m = 4; for each product the tree is traversed, but the results are summed; the primitive is rendered only once with the standard depth-buffer test in the framebuffer; - 5 <,m < n; m-3 bits are used for the first (m-3) levels of the tree; the number of primitives that are scan-converted more than once decreases with an increasing number of bits; - m = n; the tree is traversed only once for a primitive; - m > /I; m-n bits are not used. For instance for m = 3, the depth value of primitive P is written into a first depthbuffer. Bit 3 of the stack is set to 'in' ('1') (see fig. 6.3a). Then for each primitive in a product, the depth-value of P is compared with its front-facing and backward-facing faces to test whether it is 'in' or 'out' the primitive. The depth value of the forward-facing faces of the primitive is rendered and compared with the depth value of P. If P is the one in front it classifies as 'out' and a '0' is written into bit 2 of the stack, otherwise an ' 1 ' is written into bit 2. If P is in front of the backward-facing faces of the primitive, an ' 1 ' is written in bit 1 and otherwise a '0'. Next, bit 1 and bit 2 are combined with a logical AND because for P to be 'in', the primitive should be both behind the forward-facing and in front of the backward-facing faces of a primitive. The result is AND-ed with bit 3 because to

CSG depth-buffering techniques

81

initialisation

0 1

0 1

s p f b

: sum : product : forward-facing : backward -facing

I I I I
J 2 1

I II I I
< 3 2 1

I I I I II
5 i 3 2 1

p f

s p f

W'

s p

m- 3

b. m = 4

c. m> 4

Figure 6.3. Memory use for tree traversal.

be 'in' for a product, P should be 'in' for all primitives in that product If all primitives are processed, P is rendered in the (second) depth-buffer for all pixels that classify as 'in' (have a ' 1 ' in bit 3). Then the stack is initialised again and the following product is processed. For m = 4, the results of different products can be summed in bit 4 (see fig. 6.3b), because P has only to be 'in' for one product. Bit 4 is initialised to '0'. For m > 4, additional bits can be used to store intermediate results of the tree traversal; for each available bit, the classification of the left node of a composite node can be stored while the right subtree is being processed (fig. 6.3c). Within a wide range, any trade-off between speed and memory can be chosen. Minimal memory use may be desired for logic-enhanced frame buffer systems and optimal speed may be desired for scan-line systems. The tree traversal method described may be used in that case to prevent overflow. In table 6.1 the number of depth comparisons/scan-conversions are given for the object of plate 8a. The table shows that the processing of the active tree can be

number of available bits for stack number of scan-conversions 118 primitive 151 number of depth-buffer tests 236 number of scan-conversions of primitives in active trees for depth comparison with primitives. (scan-conversion of both forward and backward-facing boundaries).

118 118 118 118 118 118 118 118 118 118 118 118 236 140 131 123 123 123

Table 6.1. Rendering versus memory trade-off for object of plate 8a with 118 primitive solids.

82

CSG depth-buffering techniques

reduced with 50% if there is enough memory compared to the minimum of 3 bits. Further, it shows that only a limited number of bits are sufficient to render large and complex models most efficiently.

Hardware implementations

$3

7. Hardware implementations The CSG depth-buffer algorithm is a very elegant algorithm and because all operations can be reduced to simple depth comparisons at the pixel level, it is very suitable for implementation in VLSI-based hardware systems. In combination with image subdivision, the algorithm is also suitable for display of CSG objects with a multi-processor system. Both implementations are described in the following sections. 7.1 Introduction Projective display of three-dimensional objects involves a sequence of transformations, clipping and scanning operations known as the 'viewing pipeline' [Foley and van Dam, 1982]. Parts of this viewing pipeline have been implemented in VLSIbased hardware systems to obtain nearly real-time performances [Clark, 1982]. Most of these systems are based on the depth-buffer (z-buffer) algorithm, because the depth sort at the pixel level fits best in a pipe-line approach. A drawback of these systems is that they can only display objects defined with a boundary representation and not objects defined as a combination of elementary volumes (Constructive Solid Geometry). An interesting development are the so-called logic-enhanced scan-line systems and logic-enhanced frame-buffer systems [Thomas, 1983], [Fuchs et al., 1985], which provide additional logic to the pixel memories to perform logical computations at the pixel level. This makes it possible to use these systems for the display of objects defined with Constructive Solid Geometry [Thomas, 1983], [Goldfeather et al., 1986]. An overview of these systems is given in section 7.2. Linear halfspaces are naturally handled by these systems, but the large number of halfspaces needed to approximate curved surfaces reduce the performance. In section 7.3, a faceted halfspace representation is described for rendering linear halfspace models more efficiently. The processing of a halfspace model can further be reduced by applying an image subdivision and a pruning of the halfspace model. An implementation for a multi-processor system is given in section 7.4.
7.2 Display systems

VLSI techniques have made possible the design of logic-enhanced frame-buffer systems with parallel processing capabilities down to the pixel level. With these systems several billion pixel operations can be performed per second in order to generate raster images in real time. In this section, these systems are briefly described. 7.2.1 Logic-enhanced frame buffer systems Prominent examples of the logicenhanced frame-buffer systems are the Pixel-planes and Pixel-powers system [Fuchs et al., 1985], [Goldfeather and Fuchs, 1986]. The Pixel-planes system consists of two components: an arithmetic preprocessor, the Linear Expression Evaluator, composed of two binary multiplier trees, and a matrix of pixel-processors with associated pixel-memories (fig. 7.1). The arithmetic preprocessor receives from the host

84

Hardware implementations

A.B.C

Ax/n-Byp* C

linear expression evaluator

DDDDGDDD DDDDDDDD DDDDDDDD DDDDDDDD I DDDDDDDD 1 DDDDDDDD


Ax*Bly*2hCAx+B(y+1)+C^S Ax+By+C -Ax*B(y-1j*C-~ one-bit ALU

R.G.B

*UA

r\_

pixel processors and memories

lA<Z.Ax+C- (

enable}- bit

memory

Figure 7.1. Pixel-planes system.

computer die three coefficients of a linear expression F(x,y) = Ax+By+C and evaluates this expression bit-sequentially and parallel for every pixel. The x and y value refer to the screen coordinates of the pixel. At each pixel a simple pixel-processor is located that contains a one-bit ALU, an Enable bit, and a 72 bit memory. The enable register controls write access, allowing each pixel to determine whether its current memory contents can be overwritten. Logical operations and comparisons of values can be performed in the ALU by a one-bit adder. For the programmer, the Pixel-planes system is a frame-buffer that accepts a linear expression as input and evaluates this expression for all pixels simultaneously. With the ability to perform bitwise operations at the pixel-processors, a large number of complicated rendering and shading calculations can be performed for polygon models [Fuchs et al., 1985]. A convex polygon, for instance, is scanconverted by the following procedure: - encode the edges of the polygon in linear equations of the form F(x,y) = Ax+By+C = 0, and test the sign of F at each pixel; set a disable bit at all pixels located at the non-polygon side of the edges, - encode the polygon plane and the shading intensity in a linear equation and write the depth and the intensity in the pixel-memories that are still enabled. Hidden surfaces are removed with a depth-buffer test First, the depth value of a polygon is compared with the value in the pixel memory and the pixel is disabled if

Hardware implementations

85

the current value is smaller that the depth of the test polygon. Second, the depth value is broadcast again and written in the memories that are still enabled. 7.2.2 Scan-line systems The Pixel-planes system incorporates a complete framebuffer. With high speed parallel processing the size of the frame-buffer can be reduced to one or a few virtual scan-line buffers: the processing is done in line with the raster refresh and from a limited number of scan-line buffers all scan-lines are refreshed. A similar binary multiplier-tree concept as in Pixel-planes can be applied here for the parallel evaluation of linear expressions. Alternatively, a systolic scheme can be devised to perform incremental computations at every pixel location [Gharachorloo and Pottle, 1985], (fig. 7.2).

1
1
processor 0

pixel controller pixel memory

pixel refresh

processor 1

processor 2

processor n-1

processor n

Figure 7.2. Systolic array of pixel processors (n= 511 or 1023).

Every pixel processor performs a similar action on the data before the data is passed to the neighbouring pixel processor. Pixel intensity values are broadcast in the opposite direction. Only the first processor communicates with the host. Similar rendering algorithms can be used as for the Pixel-planes machine. Additionally, an active polygon list is maintained to limit the processing to those polygons that are active on the processed scan-line. 7.2.3 Pixel-square system The frame-buffer system requires a complete framebuffer memory with associated logic. With the scan-line systems, the memory requirements are strongly reduced, but the processing has to be done within the video refresh rate. An intermediate approach is a logic-enhanced pixel-square system. A typical system would cover 8*8 or 16*16 pixels. The image is subdivided and the sub-segments are rendered sequentially, and the intensities are then passed to a frame-buffer. The hardware scheme could be a host, a divider, a renderer and a frame-buffer (fig. 7.3).
7.3 CSG halfspace models

CSG defined objects can be displayed on these systems with the CSG depth-buffer algorithm, described in chapter 6.

86

Hardware implementations

modeller

divider

renderer

frame buffer

Figure 7.3. Pixel-square system.

73.1 Implementation of the CSG depth-buffer algorithm The CSG depth-buffer algorithm requires two depth-buffers, one for storing and comparing the depth of surface elements for the CSG classification and one for the depth sort. The processing for each pixel (in parallel) is as follows. For a primitive the forward-facing surface elements are scan-converted into the first depth-buffer. The surface elements are classified by a CSG-tree traversal. For each leaf node the forward- and backward-facing parts of the boundary of the primitive at that node are scanconverted for comparison with the depth value of the test primitive. (The surfaces of the primitives are thus repeatedly scan-converted, which might seem expensive but in fact is very cheap in these logic-enhanced frame buffer systems). At the composite nodes the classification of the left and right subtrees are combined with bitwise operations in the pixel processor. These classifications are done for each pixel independently and in parallel. The result is stored as '0' or ' 1 ' in the pixel memory. For the tree traversal, three or more bits can be used, dependent on the available pixel memory. Pixels that classify as 'in' are rendered with the standard depth-buffer test. 7.3.2 Half space models Solids can be defined as boundary models by dividing its surface into faces, that can be represented by polygons or curved surface elements. Alternatively, solids can be defined by a composition tree of halfspaces, each described by an equation of the form (x,y,z) < 0. A CSG model can be converted into a halfspace model by replacing in the CSG-tree every occurrence of a primitive solid by its subtree of halfspaces. Solids bounded with curved surfaces can be approximated with Boolean combinations of linear halfspaces. For an accurate approximation a large number of halfspaces is needed. The linear halfspace is naturally handled with the logicenhanced systems, but the large number of halfspaces and the large number of CSG evaluations needed to find the actual surface elements reduce the performance. This can be improved by detecting in the CSG-tree subtrees that contain only Boolean intersections or only Boolean union operations. A subtree of Boolean intersections describes a convex surface and can berepresentedby the Boolean intersection of all the halfspaces of the subtree (fig. 7.4a). A subtree with only Boolean union operations describes a concave surface and can be represented by the Boolean union of all the halfspaces of the subtree (fig. 7.4b). Further, these complete sets can be decomposed into a set of forward-facing halfspaces and a set of backward-facing halfspaces.

Hardware implementations

87

T ^

a. convex-max

6. concave-min

Figure 7.4. Sets of halfspaces.

These simple combinations of halfspaces can be rendered by applying the convex^max/concave-min depth-buffer test [Thomas, 1983], [Shiroma et al., 1982]. If the Boolean intersection of a set of forward-facing halfspaces is scan-converted into a depth-buffer, then the boundary of the solid at a certain pixel is the halfspace with the maximum depth-value. This follows from the Boolean intersection operation (fig. 7.4a). For the Boolean union of a set of forward-facing halfspaces, the boundary of the solid at a certain pixel is formed by the halfspace with the minimum depth-value (fig. 7.4b). The min and max criteria reverse for the backward cases (table 7.1).

forward forward backward backward

intersection union intersection union

convex-max concave-min concave-min convex-max

Table 7.1. Rules for intersecting sets.

The CSG halfspace model is converted into a CSG model with sets of halfspaces as basic primitives. Each set represents a linear approximation of a curved halfspace and can be described as a "faceted halfspace". This conversion is done only once during model definition. Prior to scan-conversion a viewpoint dependent preprocessing decomposes the sets into forward-facing sets and backward-facing sets. This last preprocessing is simple and can also be done on the fly.

88

Hardware implementations

73.3 Image subdivision For pixel-square systems and multi-processor systems (see following section) that process individual 'image segments', the processing can be reduced by a pruning of the halfspace models. The pruning is achieved by comparing the depth-values at the corner points of image segments, again using the convex-max/concave-min rule.

*/!_
A//B

f
b. for convex - max: both are active

a. for convex-max: A is not active

Figure 7.5. Pruning of halfspaces. Thus with a forward-facing convex set, if a halfspace is in front of a neighbouring halfspace at all comer points of an image subdivision then it is not visible for that image segment. For instance, in the 2D example of fig. 7.5a, a 1 < b 1 and a2 < bl, so A is not 'active' and does not contribute to the rendering of the surface for that segment, while in 7.5b, a 1 < b 1 and a 2 > b 2, both A and B are active. 7.4 A multi-processor Implementation* 7.4.1 Introduction The VLSI-based hardware systems described in the previous sections display fairly complex objects in nearly real-time. However, the speed performance of these systems is not important in all applications. High-quality shading, including texture mapping, sophisticated reflection models, and anti-aliasing, may also be required. Further, in CAD display of three-dimensional objects is often used in combination with an interactive user interface for geometric modelling. In Sutherland[1986], a multi-processor system is described that provides support for a visual programming environment of high quality, based on a 24-bit deep framebuffer hosted in a processor array (fig. 7.6). The image-memory organisation is interleaved, ie. each node is responsible for the storage and display of one pixel within a pixel-square [Fuchs and Johnson, 1979] (see fig. 7.7). Typical sizes of the processor array are 3JC3, 3X4 or 4x4. For display refresh, the image is read directly from the processor nodes. To enable fast pixel transfer every time a part of the image is moved, the processors are interconnected to obtain a wide interprocessor * This section was developed in cooperation with dr. R.J. Sutherland, University of Glasgow, Scotland.

Hardware implementations

89

high-speed channel

application processors port

JH
control bus

display management processor

port

dual-port RAM

user processor

port processor array lixij

to mouse, keyboard, etc. Figure 7.6. Overview of multi-processor system.

communications bandwidth. The system is especially appropriate for imageoriented applications using full-colour antialiased displays of moderate resolution and reasonably good interartive perfonnance. Here the use of such a system is considered for the display of solid models.

..Ji^JL^^JL^L..

.30000
3,4 | | 3,7

3.2 t.2

3.3 i.3

3.4 | | 3.1 4,4 || 4,7

<X||M

IIII 11'I ;l 7.7;! 7,2'i 7.3 7,4

Figure 7.7 Display memory interleaving for a 4x4 array.

90

Hardware implementations

A multi-processor implementation of ray tracing can be expected to give a speed-up proportional to the number of processors, especially if the model data can be replicated among the processors. An interleaved memory organisation guarantees that the processing load will be equally divided among all processors. Projective hidden-surface algorithms are more complicated. In general, such algorithms are an order of magnitude faster than ray-tracing ones; this efficiency is obtained by applying sorting and coherence techniques prior to and/or during the scan-conversion of the surface elements. However, in a multi-processor implementation, a reduction of coherence may occur if image segmentation is used to distribute the processing over the various processor nodes. Also, since an object will not always be evenly distributed over image space, a load-sharing principle must be introduced to balance the load distribution among the nodes [Sato et al., 1985]. The resulting communication overhead can further reduce the efficiency for complex models. A load-distribution method has been proposed for an interleaved frame-buffer system enhanced with a splitter-tree of processors [Parke, 1980]. Each processor reduces the data passed to subsidiary nodes by means of successive image-space subdivision. The leaf nodes broadcast the data to an array of image processors that simultaneously render the data into the interleaved frame buffer using a depth-buffer algorithm. A similar image-space subdivision strategy is employed here, but the system architecture differs from the above in that the same processors do both the splitting and the rendering. Objects are displayed with the CSG depth-buffer algorithm described in section 6.1. The algorithm is made efficient by three types of pruning. First, the image is subdivided into segments, and for each segment the non-active primitives are pruned from the CSG-tree as in [Bronsvoort et al., 1984]. Secondly, each image segment is further subdivided into subsegments, and for each subsegment, the non-active halfspaces are pruned from the primitives as described in section 7.3. These two pruning techniques are comparable to the halfspace pruning applied in [Woodwark and Quinlan, 1982] and [Samet and Tamminen, 1985], but image space is subdivided in this case into two dimensions instead of three. Thirdly, the number of depth comparisons for the classification of a primitive is reduced by calculating the active trees for each primitive as described in section 6.2. 7.4.2 The algorithm The processing is performed as follows. The viewing transformation is applied to the model in the display-management processor and an I-tree is produced for each primitive. Processing continues in three stages. Firstly, image space is subdivided into segments by 4-8 binary subdivisions; for each image segment in turn, the active primitives and their active trees are found, and after a first pruning of the halfspaces, the relevant halfspace data is then broadcast to all nodes in the processor array and stored there. Secondly, each processor-array node determines the active halfspaces for a unique subsegment within the current segment (second pruning), and this information (the lists of active halfspaces) is then shared among all the nodes either by sequential broadcasting on the control bus (if allowed) or by means of the interprocessor communication network.

Hardware implementations

91

Lastly, the nodes simultaneously render their respective portions of each subsegment in turn until the segment is complete. This is done using the halfspace data already stored in the nodes. Because of the interleaved display memory, each node effectively renders a 'low resolution' image of the segment. This guarantees that the rendering load is evenly distributed over the nodes. The rendering can be done pixel-serial, in scan-line order, or taking the segment as a whole. The exact strategy will depend on the amount of data involved (e.g. the depth complexity) and the processing required at the pixel level (e.g. texture mapping and anti-aliasing). This process is repeated for each segment until all segments are done. 7.4.3 Simulation results To verify whether the subdivision successfully reduces the number of active halfspaces, the algorithm has been implemented in a test program simulating a 4x4 array on a standard single-microprocessor (68000) system. Table 7.2 gives the statistics for the average number of primitives and halfspaces remaining after the first and second subdivisions, using a moderatelycomplex model consisting of a carburettor built from 22 primitives (the test picture is the lower-right one of plate 7 and has a resolution of 256x256 pixels).

Subdivision number of s u b d i v i s i o n s f i r s t number of segments number of subsegments Primitives t o t a l number of p r i m i t i v e s average number per segment average number of comparisons

level

4 16 256
22
10.0 13.0

6 64
1024

8 256
4096

22 , 3 6. , 1 8.
2042 , 8 110.

22 5.4
7.1

Halfspaces t o t a l number of h a l f s p a c e s ! 042 314.8 a v . n o . per segment ( a f t e r f i r s t pruning) a v . n o . per subsegment ( a f t e r second pruning) 81.6

39. , 0

2042 46.9 25.4

Table 7.2. Pruning statistics for different levels of subdivision. The test picture is the lowerright subpicture of plate 7, resolution 256x256. The model consists of 2042 linear halfspaces.

These statistics show that the subdivision successfully reduces the number of active halfspaces. In table 7.3, the halfspace pruning and scan-conversion statistics are given for three different model tolerances. The first subdivision is 6 levels, so the second subdivision gives 64x16 subsegments, ie. 1024 in total. The given processing times (in CPU seconds) are indicative only, since the program was not specifically coded for efficiency.

92

Hardware implementations

Halfspace pruning number of halfspaces In model average number per segment average number per subsegment Processing time halfspaces transformation first pruning second pruning (1/16) scan conversion (1/16) communication primitives tree pruning CSG-classification (1/16) depth-sort (1/16) total

1258 74. 0 31. 9

2042 110. 8 39. 0

3876 191.4 52.0

6.4 12.8 2.4 32.6 0.2 0.6 29.1 5.6 89.7

10.2 20.3 3.4 34.5 0.3 0.6 27.6 5.6 102.5

19.0 38.0 5.4 42.3 0.5 0.6 28.3 5.6 139.7

Table 7.3. Pruning statistics for different model tolerances. The test picture is the lower-right subpicture of plate 7, resolution 256x256. Image subdivision: 64 image segments and 1024 sub-segments. Processing times in CPU seconds.

7.4.4 Discussion It is difficult to compare the algorithm with a multi-processor CSG scan-line algorithm [Sato et al., 1985]. Although the performance of the CSG depth-buffer algorithm is linear with respect to model complexity, the algorithm is more brute-force than the CSG scan-line algorithm and will thus be slower for models of moderate complexity. Only if the overhead of sorting and distributing data over the processor nodes increases faster with model complexity in the scanline algorithm, would the depth-buffer algorithm outperform it. The halfspace approach may be advantageous over polygon modelling because polygon scan-conversion may be more expensive when relatively few pixels are covered by each polygon (which will be the case with complex models). Further, the amount of data needed for a polygon model is greater than for a comparable halfspace representation. The major advantage of the depth-buffer algorithm is its flexibility. Given a suitable subdivision/pruning test and scan-conversion algorithm, every surface element or halfspace representation can be processed. Further, the depth-buffer algorithm allows primitives to be processed in object order. This is essential for complex surfaces, which can only be scan-converted by surface subdivision or by sampling, and for texture mapping. Lastly, not all primitives need be stored permanently. The CSG classification can be done on a primitive-by-primitive basis and at any one time only the depth values of the primitives in the current active tree need be present (or be regenerated). Several techniques are available to further improve the performance. For instance, a reduction of the scan-conversion and CSG classifications can be achieved

Hardware implementations

93

by yet another use of image subdivision, where the picture is first drawn at a low resolution and the image is then stepwise refined only at points where intensity values differ [Roth, 1982], [Jansen and van Wijk, 1983]. 7.4.5 Conclusions A CSG depth-buffer algorithm has been presented for a multiprocessor system with an interleaved image memory organisation. In the absence of both the brute force of a custom VLSI approach and the efficiency of sorting and coherence techniques, efficiency is obtained by two subdivisions and associated pruning. The first subdivision reduces the number of primitives for each image segment and hence the amount of buffer storage and the complexity of the CSG evaluation. The second subdivision reduces the number of active halfspaces for each subsegment and hence the cost of scan-conversion. The CSG depth-buffer algorithm is quite flexible and can easily be adapted to more complex shading models, texture mapping, and other halfspace and surface representations. The hardware architecture described is sufficiently flexible to accommodate these algorithms.

Part 4 Conclusions

In this section, the results of part 2 and part 3 are reviewed. The question of section 2.5 is reconsidered again: is there a system that offers both a highly interactive interface for the input of the model, and fast viewing and high-quality rendering for the visualisation of the solid model. Given the rather specific character of VLSIbased hardware systems, it is likely that a multi-processor system will provide the best solution for the short-term. The system may include both faceted and exactly defined primitives and may have a depth-buffer algorithm for projective display and a ray tracing algorithm enhanced with a spatial subdivision method for high-quality rendering.

Conclusions

97

8. Conclusions In this section a short summary is given of the techniques presented, some conclusions are drawn and recommendations for subsequent research are given.
8.1 Solid modelling and industrial design

Modelling and industrial design are two closely connected activities. Before a product can actually be made, the design goes through several design phases and at each stage the design has to be visualised and documented. The central role of modelling in design poses the question of what methods and techniques can be employed to support and improve these modelling activities. It is apparent now that CAD techniques offer virtually unlimited possibilities for the description and manipulation of design representations and for the evaluation and eventually for the production of the design. The volume modelling approach offered by solid modelling provides the user with a high-level interface for the geometric specification of objects. To be effective as a design tool, solid modelling should offer a large shape domain and routines for fast and high quality rendering of the object The geometric complexity of shapes normally encountered in industrial design poses a difficult problem in this context. The method explored in this thesis, linear approximation, describes curved surfaces with polygons or with linear halfspaces. This simplifies the processing but introduces an additional problem in storing and processing the large number of polygons or halfspaces. Two approaches have been explored in this thesis: the use of additional data structures and the use of more dedicated hardware display systems. The data structures described in part 2, do improve the efficiency and bring nearly constant or linear time performances, but these constant times are still unacceptably long for use within design. The depth-buffer algorithm described in part 3 is a very elegant algorithm, and it lends itself to the display of different surface representations. Because of its brute-force character, it is not so suited for use with a single processor workstation, but implemented on logic-enhanced frame buffer systems, it can display CSG models within nearly real-time. The degree to which these systems will be of practical use will depend to a great extent on their availability. In the short run, multi-processor systems are easier to realise. They provide the same software capabilities as single processor systems, in addition to parallel processing capabilities.
8.2 Further research

An interesting question is whether the algorithms of part 2 and part 3 can be combined within one system. The following options are open for investigation. It is difficult to bring free-form objects within the range of CSG halfspace models. Convex and concave 'regions' (parts of the boundary) can be separately described by Boolean combinations of halfspaces, but it is difficult to combine convex and concave regions within a single CSG halfspace model. Polygon models do not have this limitation, but require additional data and processing of the vertices

98

Conclusions

and edges. A polygon-halfspace representation is feasible, in which convex and concave regions are described by halfspace combinations bounded by planes of neighbouring regions. In a pre-processing, these regions are coded, and during the application of the model, the regions are processed as 'faceted polygons'. Experimental tests suggests considerable efficiency gains for both the ray tracing and the depth-buffer algorithm. Ray tracing enhanced with a spatial subdivision method and the CSG depthbuffer algorithm are suitable for the display of both faceted and exact representations. Faceted representations will always be needed to describe complex procedural models, but exact representations can be used, for example, for quadratic and cubic surfaces. A system that would support both representations would be most desirable. The multi-processor configuration described in section 7.4 offers a highlyinteractive full-colour workstation. Implementation of both a projective and a ray tracing algorithm that could fully benefit from the parallel processing capabilities of such a system, would produce a powerful CAD workstation.

References

99

References Appel, A.A. [1968], Some techniques for shading machine renderings of solids, SJCC 1968, AFIPS Conf. Proc. Vol. 32, 37-45. Archer, L.B. [1965], Systematic methods for designers, Hie Design Council, London. Also in: Cross[1984], 57-82. Archer, L.B. [1968], An overview of the structure of the design process. In: Proc. of The Design Methods Group, First International Conference, June, 285-307. Atherton, P.R. [1983], A scan-line hidden surface removal procedure for constructive solid geometry. Computer Graphics 17(3):73-82, Siggraph83. Baumgart, B.G. [1975], A polyhedron representation for computer vision. AFIPS Conf. Proc. NCC 44, 589-596. Blinn, J.F. [1977], Models of light reflection for computer synthesized pictures, Computer graphics ll(2):229-234, Siggraph77. Braid, LC. [1973], Designing with volumes, Ph.D. Dissertation, Univ. of Cambridge. (2nd ed. Cantab press, 1974). Braid, LC. [1975], The synthesis of solids bounded by many faces, Comm. of the ACM 18(4):209-216. Bronsvoort, W.F., Wijk, J.J. van, Jansen, F.W. [1984], Two methods for improving the efficiency of ray casting in solid modelling, Computer-Aided Design 16(l):51-55. Bronsvoort, W.F., HokJF., Post, F.H. [1985], PLAMO: an interaction-oriented solid modelling system with shaded images, Reports of the Department of Mathematics and Informatics, no 85-25, Delft University of Technology. Bronsvoort, W.F. [1986], Techniques for reducing Boolean evaluation time in CSG scan-line algorithms, Computer-Aided Design 18(10):533-538. Carlson, W.E. [1982], An algorithm and data structure for 3D object synthesis using surface patch intersections, Computer Graphics 16(3):255-264, Siggraph82. Catmull, E.E. [1974], A subdivision algorithm for computer display of curved surfaces, Thesis, Univ. of Utah Computer Sci. Dept, UTEC-CSc-74-133. Chiyokura, H., Kimura, F. [1985], A method of representing the solid design process, IEEE Computer Graphics and Applications 5(4):32-41. Clark, J.H. [1976], Hierarchical geometric models for visible surface algorithms. Communications of the ACM 19(10):547-554. Clark, J. [1982], The geometric engine: a VLSI geometry system for graphics, Computer Graphics 16(3): 127-133, Siggraph82. Cook, R.L., Porter.T., CarpenterJL. [1984], Distributed ray tracing, Computer Graphics 18(3):137-145, Siggraph84. Crocker, G.A. [1984], Invisibility coherence for faster scan-line hidden surface algorithms, Computer Graphics 18(3):95-102, Siggraph84. Cross, N. [1984], Developments in design methodology, John Wiley & Sons, Chichester. Demetrescu, S. [1985], High speed image rasterization using scan-line access memories, Proc. 1985 Chapel Hill conference on very large scale integration. Computer Science Press, Inc. Dipp, M., Swensen, J. [1984], An adaptive subdivision algorithm and parallel architecture for realistic image synthesis. Computer Graphics 18(3):149-158, Siggraph84. Faux, I.D. [1986], Reconciliation of design and manufacturing requirements for product description data using functional primitive part features, R-86-ANC/GM/PP-01.1, CAMI, Arlington, USA.

100

References

Foley, J.D., van Dam, A. [1982], Fundamentals of interactive computer graphics, Addison Wesley Publishing Company, Reading(Massachusetts). Fuchs, H. and Johnson, B. [1979], An expandable multi-processor architecture for video graphics, Proc. 6th ACM-IEEE Symposium on Computer Architecture, 58-67. Fuchs, H., Poulton, J. [1981], Pixel-Planes: a VLSI-oriented design for a raster graphics engine, VLSI Design 2(3):20-28. Fuchs, H., Abram, G.D., Grant, E.D. [1983], Near real-time shaded display of rigid objects, Computer Graphics 17(3):65-72. Fuchs, R , Goldfeather, J., Hultquist, J.P., Spach, S., Austin, J.D., Brooks Jr., P.P., Eyles, J.G., Poulton, J. [1985], Fast spheres, shadows, textures, transparencies, and image enhancements in pixel-planes, Computer Graphics 19(3):111-120, Siggraph85. Fujimoto, A, Tanaka, T., Iwata, K. [1986], ARTS: accelerated ray-tracing system, IEEE Computer Graphics and Applications 6(4):16-26. Gharachorloo, N., Pottle, C. [1985], Super buffer: a systolic VLSI graphics engine for real time raster image generation, Proc. 1985 Chapel Hill conference on very large scale integration. Computer Science Press, Inc., 33-44. Glassner, A.S. [1984], Space subdivision for fast ray tracing, IEEE Computer Graphics and Applications 4(10): 15-22. Goldfeather, J., Fuchs, H. [1986], Quadratic surface rendering on a logic-enhanced framebuffer memory, IEEE Computer Graphics and Applications 6(l):48-58. Goldfeather, J., Hultquist, J.P.M, Fuchs, H. [1986], Fast constructive solid geometry in the pixel-powers graphics system. Computer Graphics 20(4): 107-116, Siggraph86. Goldstein, E., Nagel, R. [1971], 3D visual simulation, Simulation 16(1):25-31. Jansen, F.W., van Wijk, J.J. [1983], Fast previewing techniques in raster graphics. Proceedings Eurographics'83, 195-202, Elseviers Science Publ., Amsterdam. Kawaguchi, E., Endo, T. [1980], On a method of binary picture representation and its application in data compression, IEEE Transactions on Pattern Analysis and Machine Intelligence 5, 27-35. Kay.T.L., Kajiya, T.J. [1986], Ray tracing complex scenes, Computer Graphics 20(4):269278. Klok, F. [1986], Two moving coordinate frames for sweeping along a 3D trajectory. Computer Aided Geometric Design 3(3):217-229. Koistinen, P., Tamminen, M., Samet, H. [1985], Viewing solid models by bintree conversion, Proceedings Eurographics'85, 147-157, Elseviers Science Publishers, Amsterdam. Lee, Y.T., Requicha, A.A.G. [1982], Algorithms for computing the volume and other integral properties of solids. II. A family of algorithms based on representation conversion and cellular approximation, Communications of the ACM 25(9):642-650. Luckman, J, [1967], An approach to the management of design. Operational Research Quaterly, 18(4):345-358. MAGI, (Mathematical Applications Group, Inc.) [1968], 3-D simulated graphics, Datamation 2. Mantyla, M. [1982], An inversion algorithm for geometric models, Computer Graphics 16(3):51-59, Siggraph'82. Marityla, M., Tamminen, M. [1983], Localized set operations for solid modeling, Computer Graphics 17(3):279-288, Siggraph83. Mantyla, M. [1983], Computational topology: a study of topological manipulations and interrogations in computer graphics and geometric modeling, Thesis, Acta Polytechnica

References

101

Scandinavica Ma 37, Helsinki. Meagher, D., [1982], Geometric modeling using octree encoding. Computer Graphics and Image Processing 19(2): 129-147. Newell, M.E., Newell, R.G., Sancha, T.L. [1972], A new approach to the shaded picture problem. Proceedings ACM National Conference, 443-450. Newman, W.M., Sproull, R.F. [1979], Principles of interactive computer graphics, 2nd ed., McGraw-Hill. New York. Okino, N., Kakazu, Y., Morimoto, M. [1984], Extended depth-buffer algorithms for hiddensurface visualization, IEEE Computer Graphics and Applications 4(5):79-88. Parke, F.I. [1980], Simulation and expected performance analysis of multiple processor zbuffer systems. Computer Graphics 14(4):48-56. PDES [1986], Final report of the PDES logical layer initiation task, submitted by J.C. Kelly, Sandria National Laboratories. PDDI [1984], Product definition data interface, system specification document. DR-84-GM05, CAM-L Arlington, USA. Plunkett, D.J., Bailey, M.I. [1985], The vectorization of a ray tracing algorithm for improved execution speed, IEEE Computer Graphics and Applications 5(8):53-60. PostJ'.H., Klok, F. [1986], Deformations of sweep objects in solid modelling, Proc. Eurographics'86, 103-114, Elsevier Science Publ., Amsterdam. Potmesil, M. [1982], Generating three-dimensional surface models of solid objects from multiple projections. IPL-TR-033, Image Processing Lab. Rensselaer Polytechnic Institute, New York. Requicha, A.A.G. [1980], Representations for rigid solids: theory, methods, and systems, ACM Computing Surveys 12(4):437-464. Rossignac, J.R., Voelcker, H.B. [1986], Active zones in constructive solid geometry for redundancy and interference detection, IBM Research report RC 11991, IBM Research, Yorktown Heights, NY. Rossignac, J.R., Requicha, A.A.G. [1986], Depth-buffering display techniques for constructive solid geometry, IEEE Computer Graphics and Applications, 6(9):29-39. Roth, S.D. [1982], Ray casting for modeling solids, Computer Graphics and Image Processing 18(2): 109-144. Rubin, S.M., Whirled, T. [1980], A 3-dimensionaI representation for fast rendering of complex scenes. Computer Graphics 14(3):110-116. Siggraph80. Sabella, P., Wozny, M.J. [1983], Towards fast color-shaded images of CAD/CAM geometry, IEEE Computer Graphics and Applications 3(11):60-71. Samet, H., Tamminen, M. [1984], Computing geometric properties of images represented by linear quadtrees, IEEE Transactions on Pattern Analysis and Machine Intelligence 7(2):229-240. Samet, H., Tamminen, M. [1985], Bintree, CSG-trees and time, Computer Graphics 19(3): 121-130, Siggraph85. Sato, H., Ishii, M., Sato, K.. Bcesaka, M., Ishihata, H., Kakimoto, M., Hirota, K., Inoue, K. [1985], Fast image generation of constructive solid geometry using a cellular array processor, Computer Graphics 19(3):95-102, Siggraph85. Schumacker, R.A., Brand, B., Gilliland, M., Sharp, W. [1969], Study for applying computer generated images to visual simulation, AFHRL-TR-69-14, US Airforce Human Resources Laboratory. Sears, K.H., Middletich, A.E. [1984], Set-theoretic volume model evaluation and picture-

102

References

plane coherence. IEEE Computer Graphics and Applications 4(3):41-46. Shiroma, Y., Okino, N., Kakazu, Y. [1982], Research on 3-D geometric modeling by sweep primitives, Proceedings CAD'82 conference, 671-680. Steenbrugge E.F. van [1986], GISMO : an interactive graphics input method for CSG models, Graduation assignment report (in Dutch), TNO-BBC, Delft. Sutherland, I.E., Sproull, R.F., Schumacker, R.A. [1974], A characterization of ten hiddensurface algorithms, ACM Computing Surveys 6(1): 1-55. Sutherland, R.J. [1986], A multiprocessor architecture for high-quality interactive displays, Proceedings Eurographics'86, 265-277, Elsevier Science Publ., Amsterdam. Takala, T. [1985], User interface management system with geometric modelling capabilities: a CAD systems framework, IEEE Computer Graphics and Applications 5(4):42-50. Tamminen, M. [1981], The EXCELL method for efficient geometric access to data. Thesis, Acta Polytechnica Scandinavica, Ma 34, Helsinki. Tamminen, M., Karonen, O., Mantyla, M. [1984], Ray-casting and block model conversion using a spatial index, Computer-Aided Design 16(4):203-208. Tamminen.M., Samet, H. [1984], Efficient octree conversion by connectivity labeling, Computer graphics 18(3):43-51, Siggraph'84. Thomas, A.L. [1983], Geometric modeling and display primitives towards specialised hardware, Computer Graphics 17(3):299-310, Siggraph83. Tiller, W. [1983], Rational B-splines for curve and surface representation, IEEE Computer Graphics and Applications 3(9):61-69. Tilove, R.B. [1980], Set membership classification: a unified approach to geometric intersection problems, IEEE Transaction on Computers, C-29(10):874-883. Varady, T., Pratt, M.J. [1984], Design techniques for the definition of solid objects with freeform geometry, Computer Aided Geometric Design l(3):207-225. Weghorst, H., Hooper, G., Greenberg, D.P. [1984], Improved computational methods for ray tracing, ACM Transactions on Graphics 3(l):52-69. Wesley, M.A. [1980], Construction and use of geometric models. In: Computer aided design, modelling, systems engineering, CAD-systems, Lecture notes in Computer Science no. 89, ed. J. Encarnacao, Springer Verlag, 79-136. Whitted, T. [1980], An improved illumination model for shaded display. Communications of the ACM 23(6):343-349. Whitted, T., Weimer, D.M. [1981], A software test-bed for the development of 3-D raster graphics systems, Computer Graphics 15(3):271-277, Siggraph81. Woodwark, J.R., Quinlan, K.M. [1982], Reducing the effect of complexity on volume model evaluation, Computer-Aided Design 14(2):89-95. Wijk, J.J. van [1984a], Ray tracing objects defined by sweeping planar cubic splines, ACM Transactions on Graphics 3(3):223-237. Wijk, J.J. van [1984b], Ray tracing objects defined by sweeping a sphere, Proceedings Eurographics'84 Conference, 73-82, Elseviers Science Publ., Amsterdam. Wijk, J.J. van, Jansen, F.W., Bronsvoort, W.F. [1985], Some issues in designing user interfaces to 3D raster graphics. Computer Graphics Forum 4(1):5-10. Wijk, J.J. van [1986], On new types of solid models and their visualization with ray tracing, PhD Thesis, Delft University Press.

Solid modelling with faceted primitives

103

Summary

Solid modeling with faceted primitives

Computer Aided Design and Computer Graphics techniques are valuable tools in industrial design for the design and visualisation of objects. For the internal representation of the geometry of objects, several geometric modelling schemes are used. One approach, Constructive Solid Geometry (CSG), models objects as combinations of primitive solids. The subject of research in this project is a CSG representation where the surfaces of the primitives are approximated with flat surface elements (facets). Techniques to improve the efficiency of the display of models with a large number of these surface elements have been developed. Two approaches have been taken. The first approach is based on the use of additional data structures to enhance the processing, sorting and search of these surface elements. Further, a method is presented to store intermediate results of the logical computations needed for the processing of CSG representations. These methods are applied to a CSG polygon modelling system. The second approach aims at the development of algorithms for multiprocessor systems and VLSI-based display systems. The central method is a CSG depth-buffer algorithm. A tree traversal method is introduced that combines several techniques to reduce the processing and memory use. The methods have been applied to a CSG halfspace modelling system.

104

Solid modelling with faceted primitives

Samenvatting Solid modelling met gefacetteerde basis vormen Computer-Aided Design (CAD) and Computer Graphics technieken vormen een belangrijk hulpmiddel voor het ontwerpen en het visualiseren van drie-dimensionale objekten. Diverse technieken zijn gangbaar voor het geometrische beschrijven van objekten. Constructive Solid Geometry (CSG) is een methode waarbij de ontwerper de vorm kan opbouwen met een aantal gegeven basisvormen. Het onderwerp van dit proefschrift is een CSG beschrijving waarbij de oppervlakken van de basisvormen zijn benaderd met platte vlakjes (facetten). Complexe objekten tellen een zeer groot aantal van deze vlakjes. Technieken zijn ontwikkeld om het tekenen van deze vormen te versnellen. Twee methoden zijn onderzocht. De eerste betreft het gebruik van extra data strukturen om het verwerken, sorteren en opzoeken van deze oppervlakte elementjes te versnellen. Verder is een data struktuur ontwikkeld die het aantal logische operaties die nodig zijn voor het verwerken van CSG representaties aanmerkelijk reduceert. Deze technieken zijn toegepast in een CSG modellerings programma, gebaseerd op polygon modelling. De tweede methode is gericht op het gebruik van multi-processor en VLSI display systemen. De centrale methode is een CSG depth-buffer algorithm. Een tree traversal methode is ontwikkeld die meerdere technieken combineert voor het reduceren van de rekentijd en de benodigde geheugenruimte. Deze technieken zijn toegepast in een CSG modellerings programma, gebaseerd op halfspace modelling.

Solid modelling with faceted primitives

105

Curriculum vitae Frederik Willem Jansen werd geboren op 21 oktober 1950 te Amsterdam. Hij doorliep de HBS-B aan het Chr. Lyceum in 't Gooi te Hilversum en behaalde in 1968 het HBS-B diploma. Hij studeerde een jaar Werktuigbouwkunde aan de Technische Hogeschool Delft en behaalde in mei 1969 het PI-examen. Daarna vervolgde hij zijn studie aan de afdeling Industrile Vormgeving. Zijn afstudeeronderwerp ging over het gebruik van de computer voor bet beschrijven en tekenen van vormen. Een onderdeel van dit afstudeerwerk betrof het ontwikkelen van een B-spline surface modelling pakket. In september 1975 legde hij het ingenieursexamen met lof af. Hij werkte vier jaar als industrieel ontwerper o.a. als projektleider huishoudelijke apparaten bij de Koninklijke Fabriek Inventum te Bilthoven. Sinds 1979 is hij werkzaam bij de vakgroep Vormgeving, afdeling Industrieel Ontwerpen van de Technische Universiteit te Delft, aanvankelijk als wetenschappelijk medewerker, vanaf 1985 als Universitair Hoofddocent Ontwerptechnieken, met als onderwerp de ontwikkeling van computer technieken voor het industrieel ontwerpen.

106

Solid modelling with faceted primitives

Acknowledgements

I have been very fortunate to find a stimulating scientific environment within the University, TNO-IBBC and the international graphics community. First of all, I would like to thank my promotors, Prof. W.H. Crouwel and Prof. dr. D.J. McConalogue and my collegues, drs. Wim Bronsvoort and dr. ir. Jack van Wijk, who helped the TUD Geometric Modelling Project to get started and to realise its intentions and aims. I would like to thank Ir. F.P Tolman and the CAD group at the research institute, TNO-IBBC, for their support and cooperation and for providing me with a Geminu/Microdutch system for the programming work and a laser printer for the printing of these thesis. Finally, I would like to acknowledge the contributions to this thesis by many collegues, in particular Dr. Robert Sutherland (University of Glasgow, Scotland) and Dr. Markku Tamminen (Helsinki University of Technology). I am very indebted to Markku Tamminen for his friendship and cooperation over the years. Most of the ideas described in this report originate from the stimulating discussions that were carried on almost daily on the electronic mail between Helsinki and Delft.

Solid modelling with faceted primitives

107

1. Wire-frame drawing of primitives.

2. Wire-firame drawing of sweep object.

3. Two cylinders at different modelling accuracy.

4. Boolean operations.

I
5. Primitive solids.

6. Projective display and ray tracing.

$^EE

108

Solid modelling with faceted primitives

The pictures on the back cover are: Plate 7. Carburettor. Plate 8. Car. Plate 9. Rietveld house.

The car is a forrester's vehicle (quadractor) designed by R. Hartman for Vicon, Agricultural Machinery, Nieuw-Vennep, Holland. The Rietveld house is the Rietveld-Schrder house at Utrecht (Copyright c/o Beeldrecht Amsterdam). The pictures of plate 7, 8 and 9 (back cover) are modelled by Hans Kuhlmann and Jaco Band.

Вам также может понравиться