An approach to geometric modeling of solids bounded by sculptured surfaces

An approach to geometric modeling of solids bounded by sculptured surfaces

Comput.&GraphicsVol. ll, No. 2, pp. 113-120, 1987 0097-8493/87 $3.00+.00 © 1987 Pergamon Journals Ltd. Printed in Great Britain. C o m p u t e r G ...

3MB Sizes 0 Downloads 26 Views

Comput.&GraphicsVol. ll, No. 2, pp. 113-120, 1987

0097-8493/87 $3.00+.00 © 1987 Pergamon Journals Ltd.

Printed in Great Britain.

C o m p u t e r G r a p h i c s in I n d i a

AN APPROACH TO GEOMETRIC MODELING OF SOLIDS BOUNDED BY SCULPTURED SURFACES K. N. RAMACHANDRANNAIR and R. SANKAR Department of Computer Science, University of Poona, Pune---411 007, lndiat Abstract--ln this paper we present the design and implementation of a geometric modeling system for modeling solids bounded by sculptured surfaces. The three most important solid representation schemes-constructive solid geometry, boundary representation, and octree representation--are combined together in our system in such a way that the resulting scheme enjoys many of the advantages of its individual schemes. We also developed algorithms for conversion of objects from their boundary representation to octree representation, and for the boundary evaluation of octree encoded objects. The system was implemented on a DEC 1090 computer in PASCAL, and we have presented a simple illustrative example to show the use of the system to create solid objects bounded by sculptured surfaces. I. I N T R O D U C T I O N

Computer-aided design and manufacturing (CAD/ CAM) systems for mechanical engineering applications rely very heavily on computer representations of the shape of the solid objects being designed and manufactured using these systems. Though there are a number of schemes available for representing shape information, the more commonly used schemes are constructive solid geometry (CSG), boundary representation, and octree representation schemes. Each of these schemes has its advantages and disadvantages, but none of them is superior to others in all respects Ill. Our interest is in the representation of shapes of solid objects covered by sculptured surfaces, and for that we present here a new approach to shape representation that combines all the above mentioned schemes in such a way that the resulting scheme enjoys many of the advantages of the individual schemes but does not suffer from their disadvantages. 2. OVERVIEW OF THE SYSTEM In a geometric modeling system there are two ways of incorporating two representation schemes in the system. One method is to have a multiple representation scheme in which every object in the system has two representations. Another method is to combine suitably two representation schemes to obtain a single hybrid scheme. In our system we have made use of both these techniques, resulting in a dual representation scheme in which one representation is a CSG-boundary hybrid scheme and the other the octree representation scheme. Since we have to represent solids bounded by sculptured surfaces in our system, incorporation of a boundary representation scheme becomes a necessity. The pure CSG scheme with a fixed number of primitives will not be able to represent the infinite variety of solids bounded by sculptured surfaces. An approximate representation of these solids by octrees to a very ~fThis work was carded out when the authors were at the Department of Computer Science & Engineering, Indian Institute of Technology, Kanpur, India. C A G II:2-D

113

high degree of accuracy will require several thousand modes in it so that human users can not directly create them. The type of boundary representation we have chosen to represent sculptured solids is the CatmullClarke surface [2]. The essence of this procedure is to first construct a control polygon which roughly has the shape of the desired solid and then to use a refinement procedure to derive from this control polygon the actual shape of the solid. The refinement procedure is a generalization of the subdivision procedure of B-spline surfaces over rectangular meshes [3] to meshes with arbitrary topology. The ability to use nonrectangular meshes helps in defining the entire boundary of a solid object with a single mesh. Intuitively, an application of the refinement procedure is similar to cutting off the sharp corners and edges of the control mesh to produce a smoother mesh. After repeated applications of the refinement procedure the solid obtained will have continuity of the second order except at a few isolated points [4]. The shape of the solid resembles the shape of the control mesh. This property is useful for interactive shape modification by the user. Since the solid derived from the control mesh is very smooth, it cannot be used to represent objects which have sharp edges along which there is no tangent continuity. One way to overcome this problem is to define such solids as the result of Boolean operations performed on two or more smooth solids. This idea leads us to the use of a CSG-like scheme in which the leaf nodes are solids defined by the Catmull-Clarke procedure over a single control mesh. This is one of the solid representation schemes in our system. The user can define sohd objects using this representation. Since both interactive shape modification and Boolean operations are available at his disposal, the user enjoys a lot of flexibility in building up the desired shape. To make it convenient for the user to specify boundary representation of objects, the system provides some support. There are some predefined meshes of simple shape such as cube and tetrahedron available in the system. The user can incrementally modify them to incorporate more details and change the shape by two types of operations. One set of operations, such as insertion and deletion of vertices, edges, and faces,

•114

K.N. RAMACHANDRANNAIRand R. SANKAR

changes the topology of the object. The operation of moving existing vertices changes the geometry of the object. The main difficulty with the CSG-boundary hybrid scheme described above is in performing boundary evaluation of objects represented by that scheme. This is especially true when we would like to define the solid in terms of a B-spline surface where the mesh is rectangular, either originally or after some refinements, instead of using the refined control mesh as an approximation to this surface. The main difficulties are finding the curve of intersection of two B-spline surfaces and then representing this curve of intersection and portions of the B-spline surface patches bounded by such curves in a way suitable for further processing in the Boolean operations to be performed at higher levels. In order to avoid these problems we take an alternate approach of using an auxiliary representation by pctrees. First we convert the leaf nodes of the CSGboundary representation of solids by Catmull-Clark method to the octree representation, and then all the required Boolean operations are performed on these octrees to get a single octree representing the entire solid object. As a part of this system we developed such a conversion procedure. The display ofthe entire object is done using its octree representation. Even though there are many display algorithms available for octrees [5, 6, 7], they are all suitable for shaded display devices only. We had only line drawing display devices available and so we were compelled to develop a new boundary evaluation algorithm for octrees and display the boundary after hidden line elimination. There is one precaution we have to make while converting from the CSG-boundary hybrid representation to the octree representation. The algorithm for applying

geometric transformations on octrees are approximate and involve heavy computation compared to the corresponding operations on boundary representation. Hence it is better to perform geometric transformations with boundary representations rather than with octrees. In order to do this we have to push the geometric transformations at higher level nodes of the CSG tree down to the last but one level, i.e., when it applies directly to the leaf nodes. This can be easily done by composing the transformations and distributing them over Boolean operations. This does not lead to any inefficiency in conversion. In a pure CSG scheme with simple primitives, if such a technique is applied, then there will be a need to convert different instances of the same primitive by separate applications of the conversion procedure. But in our system the leaf nodes of the CSG tree are themselves fairly complicated objects that are independently designed by the user and hence there is no chance of any of them getting repeated in the tree. So the conversion procedure is applied to one shape only once. The entire solid representation scheme described above is schematically depicted in the block diagram shown in Fig. 1. Some of the advantages of this new scheme are the following. First of all it is easy for the user to specify the desired shape. Since ~ e Boolean operations are available he can split the object into a number of convenient parts. Each of these parts can be designed independently. Fine adjustment of the shape of the portion of the object defined by a single control mesh can he achieved by interactively modifying the topology and geometry of the control mesh and immediately observing the corresponding changes in the refined mesh approximating the solid. Of the three types of processings performed on objectsmgeo-

SOLID

ANSFOR

¥ ,,

TREE

Fig. 1. Block diagram of the proposed geometric modeling system.

f

Modeling of sofids bounded by sculptured surfaces metric transformations, Boolean operations, and generation of display--the first two are performed on ~ a t representation of objects for which it is best suited. The third one, display, is somewhat difficult mainly becausewe have only line drawing displays available. O n the whole we were able to combine the three best available sofid representation schemes together in such •a way that their advantages are exploited in this hybrid scheme. The main disadvantages of this scheme arc associated with the octrec representation. First of all,the storage requirement is very large if an object is to be represented to a very fine resolution. Secondly, when the octree has a fine resolution the algorithm associated with it like the conversion from boundary to octree and the display of octree are very slow. The storage problem has been alleviated to some extent by using pointedess array representation of octrees. Recently some efficient algorithms for conversion of objects from their boundary representations to octree representations were published [8, 9]. The incorporation of these algorithms in our system will further improve its performance. 3. SOME ALGORITHMIC DETAILS

At the time of implementing our system, techniques were available in the published literature that could take care of all its components except the conversion of boundary representation of primitives to their octree representation and the boundary evaluation of octree encoded objects. In this section we give some details of the algorithms we developed for these two problems.

3.1. Conversion of primitives from boundary representation to oclree representation In the present implementation of our system a plane approximation of the primitive solid obtained by refining its control mesh once or twice is used as its representation. We have not used B-spline surfaces to define portions of the boundary of the solid where the mesh is rectangular. All the primitives created in the system lie within the universal cube corresponding to the root node of octrees in the system. The basic step in the conversion algorithm is the classification of a cube as inside, outside, or on (i.e., partially inside and partially outside) with respect to the primitive solid being converted. Assuming for the present that this classification algorithm is available, the conversion algorithm works as follows. First, we classify the universal cube with respect to the primitive. If it is fully inside or fully outside the primitive, then the octree has the root node only and it is full or empty as the case may be. But if the universal cube is partially inside and partially outside the primitive then the root node of the octree is a mixed node and each of its eight sons are created by recursively applying the classification procedure to each of the octants of the universal cube. The subdivision procedure is carried out for all mixed nodes up to a certain fixed level determined by the accuracy requirements. At the lowest level mixed nodes are also treated as full nodes.

115

Classification of a cube as inside, outside, or on with respect to a primitive solid is done by classifying its faces as inside, outside, or on with respect to the same primitive. If all the faces of the cube are inside then the cube itself is inside. If all the faces are outside then the cube may be outside or it may be enclosing the primitive. The ambiguity can be resolved by testing the smallest box with faces parallel to the coordinate plane that enclose the solid, against the cube being classified. If one face of the cube is partially inside and partially outside the primitive then the cube is partially inside and partially outside the primitive. Also, if one face is inside and another face is outside then the cube is partially inside and partially outside. Classification of one face of the cube against the primitive is essentially a two dimensional problem. If we find the cross section of the primitive by the plane of the face, then we get a polygon, and the face classification problem is equivalent to classifying the square face with respect to the cross sectional polygon. The classification of the square with respect to the polygon can be performed by classifying the edges of the polygon with respect to the square for which clipping algorithms of computer graphics can be used [10]. In our system we implemented the algorithm described above after incorporating many speed-up procedures. Still it was too slow to be used in interactive sessions. Instead of trying to improve it, we feel, we should now make use of some of the more efficient algorithms for this problem published recently to which we had referred to earlier. 3.2. Boundary evaluation of octree encoded objects Many algorithms for octrees are generalizations of the corresponding algorithms for quadtrees. Though a boundary evaluation algorithm is available for quadtrees [I 1], it is not easily generalizable to octrees, and hence we developed a new algorithm for the boundary evaluation of octrees. We describe the algorithm for quadtrees; its generalization to octrees is obvious. Before the boundary evaluation algorithm is described, we introduce some definitions and notations. To represent a two dimensional region by a quadtree, we first enclose the region within a square called the universal square. If the region is either empty or is the entire square, then it is represented by a quadtree with a single node, which is either empty or full as the case may be. Otherwise, the quadtree representing the region has a root node that is a mixed node. The root node has four sons which are obtained by the procedure described above to the four quadrants of the universal square. The subdivision procedure is carried out to a certain level determined by the accuracy requirement and at the lowest level partially filled squares are also treated as full. If N is a mixed node in a quadtree, the four quadrants to which N is subdivided are N0o, No1, Nip and Nl~ as shown in Fig. 2. To be precise, if N denotes the square area

{(x,y)la< x
116

K. N. RAMACHANDRAN NAIR and R. SANKAR

TOP

then

Ni j = { (x, y)]a + ih/2 < x < a + (i + 1)h/2, b+jh/2
i=0,1,

j=0,1.

The four sides of a square are labelled left, right, bottom and top as shown in Figure 3. Suppose the region ABCDEFGHIJA shown in Fig. 4 is defined by a quadtree. Then the boundary of this region consists of the edges AB, BC, CD, DE, EF, FG, GH, HI, H and JA. With respect to the mixed node of the quadtree defining this entire region, we call the edges BC, CD, FG, GH and HI inner edges and the remainingedges, outer edges. The outer edges are again classified as bottom edges, top edges, left edges and right edges, depending on which side of the square they lie. In the current example, AB is the only bottom edge, EF a n d / J are top edges, JA is the only left edge, and DE is the only fight edge. For a quadtree node N the set of bottom edges, top edges, left edges, and fight edges of the region defined by Nare denoted by Bn(N), Br(N), BL(N) and BR(N), respectively. The set of inner edges of N is denoted by B:(N). The boundary of N is the set B~(N) U Br(N) U BL(N) U Bn(N) O Bt(N) and we evaluate this boundary for a given quadtree. Our boundary evaluation algorithm is a recursive procedure. When the procedure is at a node N of the quadtree, it evaluates the boundary of the region defined by Ninto its separate components Bt(W), Br(N), BB(N), BL(N) and Ba(N). If N is a leaf node this evaluation procedure is simple. In the case of empty nodes all these components are null. In the case of full nodes Bt(N) is null, and BL(N), BR(N), Bn(N) Br(N) are, respectively, the entire left, right, bottom and top edges of the square region corresponding to N. IfNis a mixed node then the procedure recursively evaluates the boundary of the four quadrants Noo, No,, N~o and N~, of the node N. After evaluating the boundary of a node its internal component is immediately inserted into a list and its external components are passed to higher level nodes. When a node N receives the outer boundary of its components, they are combined together to form the inner and outer boundaries of N as follows:

Bt(N) = ((Br(Noo) U BT(N,o))A(Ba(No~) U Bn(N~, ))) LJ ((BR(Noo)k3 BR(Nol))A(BL(N,o) kJ BL(NH))),

LEFT

RIGHT

BOTTOM Fig. 3. The four sides of a quadtree node.

XAY= (X- Y)U(Y-X) BL(N) = BL(Noo) U Bz(No,) BR(N) = B~(NIo) U BR(N, ,) BB(N) = BB(Noo)U Bn(N,o) Br(N) = Br(No,) O B r(NI,). The inner boundary is immediately inserted into the list of boundary edges of the entire quadtree. The outer boundary of N consisting OfBL(N), BAN), Bn(N), and BT(N) is passed on to higher level nodes. At the root node of the quadtree the edges of the outer boundary of the node are also inserted into the list of boundary edges and the algorithm terminates. In the algorithm described above it is required to perform Boolean operations on portions of the boundary like BL(N), B~(M), Ba(N) and BT(N). In order to perform the Boolean operations conveniently, the boundary segments are represented by binary trees using a technique similar to the one used in octrees and quadtrees. In this representation, subsets of a line segment are approximated by repeatedly subdividing the line segment until the segments so generated are fully inside the concerned subset, fully outside it, or are too small for further subdivision. The boundary edges of the quadtree can be obtained from their binary trees representation by a procedure similar to the boundary evaluation procedure for quadtrees. If we consider a set of disjoint line segments as a subset of the real line with its usual topology, then the boundary of this subset is just the set of end points

where A denotes the symmetric difference i.e., J

l

F

H

N01

N11

N00

NI0 A

Fig. 2. The four quadrants of a mixed node of a quadtree.

E

G

B

Fig. 4. An example of a region represented by a quadtree.

Modeling of sofids bounded by sculptured surfaces of the segments in the set. A boundary evaluation procedure similar to the one used for quadtrees will be able to determine this set of points. After that they can be sorted and pairs of points taken from this sorted listcan be connected together to form the edges. In the example given in Fig. 5 the subset ofinterestisAB, CD, EF. It has a binary tree representation shown in Fig. 6. The boundary evaluation procedure will determine the boundary points of this subset as C, D, F, E, B, A in that order. After sorting,the order becomes A, B, C, D, E, Fand hence the set consistsof the segments AB, C D and EF. The generalization of this algorithm to octrees is straight forward. In the case of leaf nodes of an octrec the boundary evaluation is simple. In the case of a mixed node, we firstrecursively evaluate the boundaries of the eight sons of the mixed node. The boundaries of the eight octants corresponding to the eight sons of the mixed node are combined together in a manner similar to that of quadtrees. Portions of the boundary along the inner faceswhich touch each other are combined together by symmetric difference and forms the inner component of the boundary of the mixed node. The portion of the boundary of the mixed node in each ofits six outer faces are obtained by combining with the union operation the boundaries along these faces of the four relevant octants. This boundary evaluation algorithm visits each node of the octree just once and hence the run time complexity of the algorithm is proportional to the total number of nodes in the octree. 4. IMPLEMENTATIONDETAILS The geometric modelling system described in the preceeding sections was implemented on the DEC System 1090 [ 12]. The only graphics equipment available were Tektronix 4006 and Tektronix 4010 terminals. The programs were written in the language PASCAL. This language was chosen because of its excellent data structure facilities, provision for dynamic storage allocation, and the ability to write recursive programs. Creation of primitives is done by a highly interactive program with menus and prompts. The conversion of primitives from boundary representation to octree representation, and the display of octree encoded objects were not fast enough to be done in interactive sessions. The total size of source programs was six thousand lines of PASCAL. For the sake of illustration, we present here a simple example of a solid object built using our system. The object is the union of seven components and Fig. 7 shows the refined meshes corresponding to the seven components positioned at their appropriate locations. Figure 8 shows, from a different viewpoint, the seven control meshes that were used to create the seven com-

[: A

B

. . C. . . .D

E

Fig. 5. A regular subset of the real line.

F

:]

117

Fig. 6. Binary tree representation of the subset shown in Fig. 5. ponents of the object. ARer converting each of the seven components from their boundary representation to octree representation, the union operation was performed on these octree representations to get a single octree representation of the entire object. Boundary evaluation and hidden line elimination were applied on this octree representation to get line drawings of the entire object. Figures 9, 10 and 11 show line drawings ofthis object represented by octrees with four, five and six levels respectively. The creation of the control meshes, their refinemerits, and the union operations on octree representation of various components of the object were all done interactively without much delay in response. Conversion of all the seven components took a total of 35 minutes 46 seconds of CPU time. The smallest component was converted in 41 seconds, and the largest component in 15 minutes 7 seconds. The single octree representation with six levels for the entire object had 8281 nodes in it. Out of these 1035 nodes were mixed, 3118 nodes were full, and 4128 nodes were empty. The boundary evaluation and back face elimination for a particular view took one minute and 13 seconds, and there were 1331 potentially visible faces in the object. The hidden line elimination algorithm required 4 minutes and 33 seconds. 5. CONCLUSIONS In this paper we presented the design and implementation of a geometric modelling system for solids bounded by sculptured surfaces. The use of the modeler was demonstrated by creating an illustrative example. It is clear from our experience so far with the system that it is possible to create, modify, and display solids bounded by sculptured surfaces using this system. We have not considered any applications of the modeler in the present work since the use of computer models of solids for analyzing their properties and for automatically manufacturing them can be done independent of the development of the model. We feel that our system compares favourably with some similar systems developed recently [13, 14]. The major achievement of our system is that it has combined three important solid representation

i 18

K . N . RAMACHANDRAN NAIR and R. SANKAR

Fig, 7. An example of a solid object chosen to illustrate the use our geometric modeler.

/

,/



)

...,

,

ik<:

..... : . . . . - - -

~%.

~ f -

:

. ./

,,

;

Fig. 8. The combined view of the control meshes used to create the object shown in Fig. 7.

Modeling of solids bounded by sculptured surfaces

Fig. 9. Line drawing of the object shown in Fig. 7 represented by a single octree with four levels.

Fig. 10. Line drawing of the object shown in Fig. 7 represented by a single octree with five levels.

119

120

K.N. RAMACHANDRANNAIRand R. SANKAR



~.~.~-~

~,~ -~.,.

Fig. 11. Line drawing of the object shown in Fig. 7 represented by a single octree with six levels.

schemes--constructive solid geometry (CSG), boundary representation, and octree representation--in such a way that the resulting system enjoys many of the advantages of these individual representation schemes. We developed an algorithm for the conversion of boundary representation of primitives to their octree representation, though more efficient algorithms for this problem were recently published. We also developed a new algorithm for the boundary evaluation of octree encoded objects. To the best of our knowledge, at the time of implementing our system there was no algorithm available for this problem. In the present work we concentrated only on solids bounded by sculptured surfaces. If it is possible to combine these techniques with the already available techniques for modeling nonsculptured solids [15], then it will be possible to incorporate some of these ideas in practical geometric modelling systems. REFERENCES 1. A.A.G. Requicha, Representations of rigid solids-theory methods, and systems. Comp Surveys 12, 437--464(1980). 2. E. Catmull and J. Clarke, Recursively defined B-spline surfaces on arbitrary topological meshes. CAD 10, 350355 (1978). 3. E. Cohen, T. Lyche and R. Riesenfeld,Discrete B-Splines and subdivision techniques in computer aided geometric design and computer graphics. Comp. Graphics & Image Processings 14, 87-I11 (1980).

4. D. Doo and M. A. Sabin, Behaviour of recursivedivision surfaces near extraordinary points. CAD 10, 356-360 (1978). 5. L. J. Doctor and J. G. Torbarg, Display techniques for octree encoded objects. IEEE Comp. Graphics & Applications 1, 29-38 (1980). 6. D. Meagner, Geometric modeling using octree encoding. Comp. Graphics & Image Processing19, 129-149 (1982). 7. K. Yamagnehi, T. L. Kunii, K. Fujimura and H. Toriya, Octree related data structures and algorithms. IEEE Comp. Graphics & Applications 4, 53-59 (1984). 8. M. Tamminen and H. Samet, Efficientoctree conversion by connectivity labeling. Computer Graphics lg, 43-51 (1984). 9. H. Samet and M. Tamminen, Bintrees, CSG trees, and time. Computer Graphics 19, 121-130 (1985). 10. W. M. Newman and R. F. Sproul, Principlesoflnteractive Computer Graphics, McGraw-Hill, New York (1973). 11. C. R. Dyer, A. Rosenfeld and H. Samet, Region representation: boundary codes from quadtrees. CACM 23, 171-179 (1980). 12. K. N. R. Nair, An approach to geometric modeling of solids bounded by sculptured surfaces. Ph.D. Thesis, I.I.T. Kanpur (1985). 13. H. Chiyokura and F. Kimura, Design of solids with free from surfaces. Computer Graphics 17, 289-298 (1983). 14. Y. E. Kalay, Modeling polyhedral solids bounded by multicurved parametric surfaces. CAD 15, 141-146 (1983). 15. J. W. Boyse, Preliminary design of a geometric modeler. Res. Pub. GMR-2768, Comp. So. Dept., General Motors Research Laboratories, Warren, Michigan (1978).