NATIONAL TECHNICAL UNIVERSITY OF ATHENS DEPARTMENT OF NAVAL ARCHITECTURE AND MARINE ENGINEERING SHIP ? DESIGN LABORAT ORY A Quadratic-Programming Method for Removing Shape-Failures from Tensor-Product B-spline Surfaces by P.D. Kaklis and G.D. Koras (1) Athens, July 1998. The authors were partially supported by the HCM-Project FAIRSHAPE (CHRX-CT94-0522) and the Greek General Secretariat for Research and Technology (Programme: ENE-91-E-635) (1) A Quadratic-Programming Method for Removing Shape-Failures from Tensor-Product B-spline Surfaces P.D. Kaklis (2) and G.D. Koras (3) Abstract. We rst study the e ect caused, on the local shape of a tensor-product B-spline surface, by the movement of a subset of its control net. We then propose two (2) discrete approaches for removing shape failures from such surfaces, without altering them more than is needed. The second approach is a simple Quadratic-Programming method, that is suitable for restoring the shape of almost shape-preserving tensorproduct B-spline surfaces. The performance of this method is tested and discussed for three industrial surfaces. 1 Introduction In all domains of applications, where design of surfaces is taking place, it is frequently the case that, for engineering or aesthetics reasons, a convex (or concave) surface is sought for. Large portions of the wing and the body of an aircraft, the bulbous bow of a tanker and the entire hull of a sailing yacht are typical examples of surfaces, where convexity is an important shape feature. This problem can become trickier when dealing with almost at, but desirably convex, surfaces - the roof of a car is a typical example of such a surface. Less frequent, but also occurring in practice, is the Associate Professor, address: National Technical University of Athens, Department of Naval Architecture and Marine Engineering, Ship-Design Laboratory, 9 Heroon Polytechneiou Street, GR-157 73 Zografou, Athens, Greece, E-mail address: kaklis@deslab.ntua.gr. (3) Graduate Student, address: as above, E-mail address:gkoras@deslab.ntua.gr. (2) 1 case when a portion of a surface has to be non-convex; the part of a car fender near the wind-shield can serve as an example of this case. Therefore, robust and ecient tools, that ensure the shape of a surface would be very useful to the CAD/CAM designer. Two of the most popular surface representations in CAGD, are the tensor-product Bezier and B-spline representations. Nevertheless, it is only rather recently that the pertinent literature can provide the interested CAD/CAM user with conditions on the control net of the surface that are not so stringent (see, e.g., [Schelske '84]) and suce to guarantee local convexity / concavity on a two-dimensional subset of its domain of de nition; see [Floater '94], [Juttler '96]. Putting aside the question on the degree of necessity of these conditions, it is not clear whether they can be easily implemented in CAD/CAM practice, either because they are non-linear (quadratic in the case of [Floater '94]) or because their number may explode (see x2.3 in [Juttler '96]). In this work we develop and test a Quadratic-Programming method for removing shape failures from an almost shape-preserving tensor-product B-spline surface, while staying close to it. Our method is discrete, in the sense that shape-restoration is taking place over a discrete grid of points that extends over the failure region. Furthermore, it is approximate, for it employs the linearized, with respect to the given surface, set of necessary and sucient conditions that guarantee shape-preservation over the speci ed grid of points. The rest of the paper is divided into ve (5) sections. In x2 we introduce a set of new notions, that help us to study the e ect caused, on the local shape of a tensorproduct B-spline surface, by the movement of a subset of its control vertices; see Defs. 1, 2. Section 3 contains the formulation of the, so-to-say continuous, problem (P ), its discrete version (Pdiscr) and the Quadratic-Programming problem (Pdiscr QP), which is obtained by linearizing the constraints of the minimization problem (Pdiscr). The performance of a (Pdiscr QP)-based shape-restoration scheme with three industrial surfaces, is presented and discussed in detail in x4. The paper concludes with x5, 2 which outlines the directions of our current and future work towards extending and improving the method presented here. 2 Preliminary Notions In this section, we rst collect some notational preliminaries and standard formulae from the areas of tensor-product B-spline surfaces and di erential geometry of surfaces. Next, we introduce, in the form of de nitions, a set of notions which quantify the e ect caused on the local shape of a tensor-product B-spline surface, by the movement of a set of its control vertices; see Defs. 1,2. Adopting the notation employed in [Farin '93], a tensor-product B-spline surface s(u; v), composed of Lu Lv polynomial patches and of degree m n, can be written as : s(u; v) = X X Lu +m?1 Lv +n?1 j =0 i=0 fNim (u)gLi=0u+m?1, fNjn(v)gjL=0v +n?1 (4) dij Nim (u)Njn(v); (u; v) 2 ; (2.1) where are one-dimensional B-spline bases. From now on, and unless stated otherwise, we will assume that (i; j ) ranges over the set: I = f(i; j ); i = 0(1)Lu + m ? 1; j = 0(1)Lv + n ? 1g: (2.2) The local shape of a regular surface s(u; v) in the neighbourhood of a point p = s(~u; v~), (~u; v~) 2 , can be fully characterized with the aid of the Gaussian, K (~u; v~), and mean curvature, H (~u; v~), de ned by the well known formulae: uu )(nsvv ) ? (nsuv ) K (u; v) = ((ns (2.3) susu )(sv sv ) ? (susv ) ; 2 2 u ) ? 2(nsuv )(su sv ) + (nsuu )(sv sv ) : H (u; v) = (nsvv )(sus2(( s s )(s s ) ? (s s ) ) u u v v u v 2 (2.4) Here, u? and v? subscripts denote di erentiation with respect to the corresponding parameterer and n = (su ^ sv )=(ksu ^ sv k) (2.5) Throughout this paper, we conform to the following notational convention: vectors and matrices are denoted by bold-type lower-case and bold-type upper-case letters, respectively. (4) 3 is the normal on the surface, ab and a ^ b denoting the inner- and the cross-product between the vectors a and b, correspondingly. The local shape of s(u; v) at p = s(~u; v~) may then be classi ed according to the signs of K (~u; v~) and H (~u; v~). More speci cally, we shall say that s(u; v) is locally convex (concave) at p if and only if K (~u; v~) is non-negative and H (~u; v~) is non-negative (non-positive). Furthermore, adopting the terminology of [Koenderink & van Doorn '92], we shall say that s(u; v) is locally saddleridge (saddle-rut) if and only if K (~u; v~) is non-positive and H (~u; v~) is non-negative (non-positive). If, in the above, non-negativity (non-positivity) is replaced by positivity (negativity) then the surface will be called strictly locally convex / concave / saddleridge / saddle-rut. In the sequel we introduce a set of notions, that are helpful for comprehending the e ect, caused by the movement of a speci c control point, say dIJ , on the shape of a tensor-product B-spline surface s(u; v) at a speci c point on it, say s(~u; v~). Let us start by de ning the notions of parabolic and minimal loci. De nition 1. The parabolic (minimal) loci of dIJ with respect to a parametric point (~u; v~) 2 , consists of all possible locations of dIJ , for which the Gaussian (mean) curvature of s(u; v), evaluated at (~u; v~), vanishes. Let s(u; v) be twice continuously di erentiable. Decomposing the right-hand side of (2.1) as s(u; v) = dIJ NIm (u)NJn(v) + dij Nim (u)Njn(v); (2.6) X i;j i;j )6=(I;J ) ( and substituting into formula (2.3), we nd, after some straightforward calculus, that the parabolic loci of dIJ constitute a quadric in IE , de ned by: 3 p(dIJ ; u~; v~) = q (~u; v~) + qT (~u; v~)dIJ + dTIJ Q (~u; v~)dIJ = 0; 0 2 1 (2.7) where q (u; v) / q (u; v) / Q (u; v) is a scalar / vector / matrix polynomial of rather high degree with respect to (u; v). The surface p(dIJ ; u~; v~) = 0 separates the so-called elliptic DG+ from the hyperbolic domain DG? , where K (~u; v~) is positive and negative, 0 1 2 4 respectively. Working similarly with (2.1) and (2.4), we can prove that the minimal loci of dIJ form a cubicoid in IE , de ned by: 3 m(dIJ ; u~; v~) = h (~u; v~)+dTIJ h (~u; v~)+dTIJ H (~u; v~)dIJ +dTIJ h (~u; v~)(dTIJ dIJ ) = 0; (2.8) 0 1 2 3 where h (u; v) / h or (u; v) / H (u; v) is a scalar / vector / matrix polynomial, of rather high degree. Finally, the surface m(dIJ ; u~; v~) = 0 separates the domain DM+ from DM? , where H (~u; v~) is positive and negative, respectively. 0 1 3 2 Obviously, when dIJ moves within the intersection of DG+ and DM+ (DM? ), the surface s(u; v) is strictly locally convex (concave) at s(~u; v~). Similarly when it moves within the intersection of DG? and DM+ (DM? ), the surface is strictly locally saddle-ridge (saddlerut). In order to include simply locally convex / concave / saddle-ridge / saddle-rut surfaces as well, DG and DM should be rendered closed by \appending" to them the parabolic and the minimal loci of dIJ , respectively. Therefore, we state: De nition 2. Let DG0 = DG [fp(dIJ ; u~; v~) = 0g and DM0 = DM [fm(dIJ ; u~; v~) = 0g. The domains DG0+ \ DM+0 =? and DG0? \ DM+0 =? will be referred to as the convex / concave and saddle-ridge / saddle-rut domain of dIJ , with respect to the parametric point (~u; v~), correspondingly. In direct analogy with the case of one control vertex, one can easily extend the notions of Defs. 1,2 for a set of control vertices fdij ; (i; j ) 2 I! g, where I! is a subset of I . Then, the various loci and domains become subsets of IE r , where r denotes the number of elements of I! , and the parabolic (minimal) loci of fdij ; (i; j ) 2 I! g, with respect to a parametric point (~u; v~) 2 , constitute now a multi-quadric (multi-cubicoid) in IE r . Finally, one further generalization of these notions is to de ne them for a discrete set of parametric points f(~u ; v~ ); = 1(1)s)g. This extension can be done quite naturally, for example, if D is the convex domain of the control-vertex set fdij ; (i; j ) 2 I! g, with respect to the parametric point (~u ; v~ ), then the sought-for generalization is but the s intersection D . 3 3 \ =1 5 3 The problem and two discrete versions of it As stated in the introduction, the problem that this work addresses is the modi cation of an almost shape-preserving tensor-product B-spline surface, so that shape-failure areas are removed. This modi cation should be kept to a minimum, so that the already convex \correct-shaped" parts of the surface, are as less a ected as possible. This problem can be stated as follows: Problem (P ). Let s (u; v) = X dij Nim(u)Njn(v), (u; v) 2 , be a given tensorproduct B-spline surface, henceforth referred to as the reference surface, which exhibits a shape-failure over a subdomain ! of . Construct a surface s(u; v) = dij Nim (u)Njn(v), i;j which is free from any shape-failure in ! and stays as close as possible to the reference surface s (u; v). (0) (0) i;j X (0) This work adopts a discrete approach for handling problem (P ). More speci cally, it proposes to modify a user-speci ed subset of control vertices of the reference surface, so that the resulting surface possesses the correct local shape, at a user-speci ed set of parametric points, while the modi ed control vertices stay as close as possible to the corresponding vertices of the reference surface. This approach leads, with the aid of the notions introduced in the previous section, to the so-called discrete version (Pdiscr) of (P ), which can be formulated as below. Problem (Pdiscr). Let be given a subset I! of I and a set of parametric points C = f(~u ; v~ ); = 1(1)sg in , henceforth referred to as the parametric constrained points, while their images on the surface will be referred to as the surface constrained points. Furthermore, let D be the convex / concave / saddle-ridge / saddle-rut domain of V = fdij ; (i; j ) 2 I! g with respect to C . Modify the elements of V , henceforth referred to as the free control points, so that the modi ed set V = fdij ; (i; j ) 2 I! g is contained in D and minimizes the quantity kdij ? dij k . (0) (0) (0) (0) X (0) (0) 2 i;j )2I! ( (Pdiscr) is a constrained minimization problem, comprising a quadratic objective func6 tion and the constraints: p (V ; u~ ; v~ ) ()0; m (V ; u~ ; v~ ) ()0; = 1(1)s; (0) (0) (3.1) p (V ; u~ ; v~ ) = 0 (m (V ; u~ ; v~ ) = 0) denoting the parabolic (minimal) loci of the control vertices V of the reference surface, with respect to (~u ; v~ ). Appealing again to the previous section, it is clear that the above inequalities are non-linear, more accurately the rst / second set of inequalities (3.1) is multi-quadratic/multi-cubicoid with respect to the co-ordinates of the control vertices of V . Thus (Pdiscr) is a nonlinear programming problem, in general. (0) (0) Assume now that the given reference surface almost has the desired shape, which is a frequently occurring case in the CAD/CAM practice. It is then legitimate to expect that the surface can take the desired shape, by slightly perturbing its control points. This can be expressed analytically by setting: dij = dij + dij ; (i; j ) 2 I! ; (3.2) (0) substituting into the inequalities (3.1) and linearizing the latter with respect to the perturbations dij . Let pl (dij ; (i; j ) 2 I! ; u~ ; v~ ) be the sought-for linearization of p (V = fdij + dij ; (i; j ) 2 I! g; u~ ; v~ ), and analogously for ml (dij ; (i; j ) 2 I! ; u~ ; v~ ). Using these linearizations, (Pdiscr) becomes a Quadratic-Programming problem, formulated as below: (0) (0) (0) (0) Problem (Pdiscr QP). Let V = fdij ; (i; j ) 2 I! g. Minimize: X i;j )2I! ( kdij k ; 2 (3.3) subject to the linear constraints: pl (V ; u~ ; v~ ) ()0; ml (V ; u~ ; v~ ) ()0; = 1(1)s: (0) (0) (3.4) The numerical performance of a shape-restoration scheme, based on (Pdiscr QP), is presented and discussed in the forthcoming section. 7 4 Numerical experience with the Quadratic-Programming discrete version (Pdiscr QP ) is numerically solved with the aid of the NAg Fortran routine E04NCF, which handles linearly- constrained linear least-squares problems and convex quadraticprogramming problems; see [NAg '90]. This routine is called by a surface-fairing program, embedded into the Surface Design Library (SDL), that is being developed in the Ship-Design Laboratory of NTUA by the second of the authors. SDL, which is being, so far, implemented on a Silicon Graphics Indy system (technical characteristics: R5000, 200 MHz, 64MB), o ers CAGD and Computer Graphics functionalities. The interface of SDL enables the user to select any number of free control points and surface constrained points, and prescribe at the latter the desired sign of Gaussian and/or mean curvature. Numerical experience suggests that the surface constrained points should form a grid, that extends over the shape failure region. As for the selection of free control points, it is advisable to pick those that in uence the selected parametric constrained points as much as possible. In this way, the desired result can be achieved at the expense of the smallest possible movement of the control net of the reference surface. Before presenting the numerical performance of (Pdiscr QP) in the context of three examples, a general comment is due: the so-far obtained numerical experience supports the assertion that the linearized constraints (3.4) are not capable of ensuring the validity of their non-linear counterparts (3.1), even when the reference surface exhibits small shape aws. In most cases, the control net, obtained by solving (Pdiscr QP), still leaves the surface with a shape-failure region. Nevertheless, this area is, in all cases we have seen, smaller than the initial one, while the absolute value of the Gaussian/mean curvature therein, diminishes. Therefore, the surface is closer to having the correct shape and it is safe to assume that a re-run of the optimization procedure (with the same free and constrained points) will force the surface to come even closer to being 8 aw-free, since it will set o with a better initial approximation of the desired solution. This may be counterbalanced by the unwanted e ect of creating new shape-failure regions in the neighbourhood of the \healed" surface constrained points. In most cases, however, after a small number of iterations (usually three or four), we end up with tiny shape-failure regions, in which the absolute value of the Gaussian curvature is very small. It is reasonable to presume that these tiny aw regions can be removed with the aid of (Pdiscr), only. We now proceed to present, in detail, the numerical performance of (Pdiscr QP) with three reference surfaces originating from an automotive industry. In all three cases, the reference surface is a C bicubic B-spline surface with boundary knots of multiplicity three (3), which implies that the surface interpolates its boundary control points . 2 (5) In the rst example the reference surface is a part of the roof of a car, and should be convex. As it is seen from Figs. 1a and 3a, the reference surface exhibits regions of negative Gaussian and mean curvature, indicated by black colour. To eliminate the principal saddle region in the middle, we selected twenty (20) surface constrained points along its extent (see the gray bullets in Fig. 2). At these points the Gaussian curvature is negative and has an order of magnitude equal to 10? . Seeking a convex surface, we chose to constrain both the Gaussian and the mean curvature to be positive at these points. As free control points we chose those which have maximum in uence on the selected surface constrained points, i.e. their B-spline-function multipliers achieve a maximum over at least one of the parametric constrained points. This selection process resulted in eight (8) free control points, depicted as light gray bullets in Fig. 2. 8 The so obtained (Pdiscr QP ) consists of twenty-four (24 = 3 8) unknowns, since the free control points can move in all directions, and forty (40 = 2 20) linear constraints. The CPU-time, required by the NAg routine E04NCF to yield the results shown in Figs. Note that the B-spline notation adopted by authors other than Farin, requires boundary knots of multiplicity four (4), for a bicubic surface to have this property. (5) 9 1b and 3b, is 0.11 secs. These gures imply that the whole shape-failure region has been removed, however, a detailed numerical report indicates that at ve (5) surface constrained points, the Gaussian curvature remains negative, though having a very low order of magnitude (= 10? ). A re-run of the optimization process yielded a surface with positive Gaussian curvature at all surface constrained points. Note that mean curvature was already positive after the rst iteration, and remained so. 10 As far as the deviation of the free control points, from their initial positions, is concerned, its maximum value (occurring at the sixth, starting from the left, free control point) is 1:2594 mm, while its mean value is 0:6364 mm. The overall dimensions of the surface are 1610 500 86 mm, which means that the deviations are rather small. It should be noted, however, that the direction of movement of all free control points was roughly parallel to the vertical axis, so deviations should be compared to the height of the surface, which is 86 mm. The process, described above, has been also applied on the small saddle regions, appearing near the boundary of the reference surface; see Fig. 1a. Each time, a few surface constrained points were picked in the region under question, and the nearby boundary control points were chosen to be free. Due to the multiplicity of the boundary knots, these control points, have stronger in uence on the surface constrained points. As a result, the method behaves better, in that smaller movements of the free control points are adequate to induce the desired result. The nal result is depicted in Fig. 1c. The second example, deals with a part of a car motor-hood, which, again, should be convex. In this case the reference surface exhibits, not numerous but rather large, shape-failure areas. We selected one hundred (100) surface constrained points (see gray bullets in Fig. 4a), which form a rather coarse grid over the shape-failure region in the middle, and thirty-six (36) free control points (see black bullets in Fig. 4a). After solving the so-resulting (Pdiscr QP), consisting of 108 unknowns and 200 constraints, 10 we got the surface depicted in Fig. 4b. It is readily seen that the shape-failure region decreased in size but is still large. It required two more runs of the optimization procedure to get the surfaces shown in Figs. 4c and 4d. The last one exhibits very small shape-failure areas. The CPU times for these three runs were 2.42, 0.31 and 0.44 secs, respectively. Repeating this process, for the other shape-failure regions, we nally arrived at the surface of Fig. 4e, which exhibits very small failure areas. The maximum / mean deviation of the free control points was 0:4298 / 0:1040 mm, while the dimensions of the surface are: 160 85 74 mm. In the examples presented so far, the herein proposed method succeeded in signi cantly reducing the extent of non-convex regions in reference surfaces, that were desired to be convex. Nevertheless, it can be the case, that the designer wants to eliminate convex regions from a surface. The third example we present (see Figs. 5), deals with a reference surface generated in a preliminary stage of the design of a car's fender. It is desired that, as far as its local shape is concerned, the surface is divided in two regions: The upper-right region, with K < 0, H > 0, and the, larger, lower-left region, with K > 0, H > 0. The reference surface exhibits shape failures in both of these regions. Following steps similar to those taken in the previous examples, we managed to leave the surface with tiny shape-failure areas; see Fig. 5b. 5 Current and Further Work We are currently working towards improving the method, presented in the preceding sections, along two directions. First, automatize, as much as possible, the processes of selecting surface constrained points and free control points. Second, enrich the objective functional of (Pdiscr QP ) with a fairness-measure term that should not, however, violate the quadratic character of the problem. A reasonable candidate for such an enrichment is the so-called thin-plate-energy functional and its variances; see, e.g., [Hagen et al. '93], [Lott & Pullin '88]. Regarding now future work, we are intending 11 to investigate the convergence properties of the scheme, as the grid of the surface parametric points becomes more and more dense, as well as study its e ect on the exterior of the failure region. 12 References [Farin '93] G. Farin, Curves and surfaces for Computer Aided Geometric Design, Academic Press, Boston, (1993). [Floater '94] M. Floater, \A weak condition for the convexity of tensor-product Bezier and B-spline surfaces", Advances in Computational Mathematics, 2 (1994) 67-80. [Hagen et al. '93] H. Hagen, St. Hahmann, G.P. Bonneau, \Variational Surface Design and Surface Interrogation", in Eurographics '93, R.J. Hubbold, R. Juan (eds.), Blackwell Publishers, vol. 12, pp. C-447 - C-459. [Juttler '96] B. Juttler, \Linear sucient convexity conditions for parametric tensor-product Bezier and B-spline surface patches", Technical Report, Technische Hochschule Darmstadt, Germany (1996). [Koenderink & van Doorn '92] J. Koenderink, A. van Doorn, \Surface Shape and Curvature Scales", Image and Vision Computing, 10 (1992) 557-565. [Lott & Pullin '88] N.J. Lott, D.I. Pullin, \Method for Fairing B-spline Surfaces", Computer Aided Design, 20 (1988) 597-604. [NAg '90] The NAg Fortran Library Manual - Mark 14, (1st ed.) NAG Ltd., UK(1990). [Schelske '84] H.J. Schelske, \Lokale Glattung segmentierter Bezierkurven und Bezier achen". Dissertation, Technische Hochschule Darmstadt, Germany (1984). 13 (a) (b) (d) (c) Fig. 1: The Gaussian curvature of: (a) the reference surface, (b) the surface after removing the shape-failure area in the middle, (c) the surface after repeated iterations of the method. (d) The color map. Fig. 2: The Gaussian curvature of the reference surface in Fig. 1a (after zooming into the shape-failure area), with the constrained points (gray bullets) and the free control points (light gray bullets). 14 (a) (b) (d) (c) Fig. 3: Same as in Fig. 1, for the mean curvature. 15 (a) (b) (c) (d) (f) (e) Fig. 4: The Gaussian curvature of: (a) the reference surface, (b,c,d) the surface after three iterations on the shape-failure area in the middle, (e) the surface after repeated applications of the method, on the upper-right corner of the surface. (f) The color map. 16 (a) (c) (b) Fig. 5: The Gaussian curvature of: (a) the reference surface, (b) the surface after repeated applications of the method. (c) The color map. 17