# On the CAD-compatible conversion of S-patches

S-patches have many nice mathematical properties. It is known since their first appearance, that any regular S-patch can be exactly converted into a trimmed rational Bézier surface. This is a big advantage compared to other multi-sided surface representations that have to be approximated for exporting them into CAD/CAM systems. The actual conversion process, however, remained at a theoretical level, with bits and pieces scattered in multiple publications. In this paper we review the entirety of the algorithm, and investigate it from a practical aspect.

## Authors

• 5 publications
• ### A multi-sided generalization of the C^0 Coons patch

Most multi-sided transfinite surfaces require cross-derivatives at the b...
02/26/2020 ∙ by Péter Salvi, et al. ∙ 0

• ### Toric degenerations of Bezier patches

The control polygon of a Bezier curve is well-defined and has geometric ...
06/25/2010 ∙ by Luis David Garcia-Puente, et al. ∙ 0

• ### A Protocol to Convert Infrastructure Data from Computer-Aided Design (CAD) to Geographic Information Systems (GIS)

While many municipalities and organizations see value in converting infr...
06/25/2020 ∙ by Eric Sergio Boria, et al. ∙ 0

• ### On the Efficiency of Strategies for Subdividing Polynomial Triangular Surface Patches

In this paper, we investigate the efficiency of various strategies for s...
06/13/2006 ∙ by Jean Gallier, et al. ∙ 0

• ### The k-conversion number of regular graphs

Given a graph G=(V,E) and a set S_0⊆ V, an irreversible k-threshold conv...
12/08/2018 ∙ by C. M. Mynhardt, et al. ∙ 0

• ### Injectivity of 2D Toric Bézier Patches

Rational Bézier functions are widely used as mapping functions in surfac...
06/15/2011 ∙ by Frank Sottile, et al. ∙ 0

• ### G^1 hole filling with S-patches made easy

S-patches have been around for 30 years, but they are seldom used, and a...
02/25/2020 ∙ by Péter Salvi, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

S-patches offer a mathematically perfect generalization of Bézier surfaces to any number of sides. The three-sided S-patch – the Bézier triangle – is widely adopted, but there is yet no standard representation for surfaces with more than four sides.

The lack of success for S-patches is likely due to their complex control net structure, and the large number of control points. These, as it turns out, can be (partially) solved by the automatic generation of the control network using only boundary constraints [7].

Another common issue with

-sided surface representations is the conversion to tensor product patches, which is crucial for processing models in CAD/CAM systems. Usually some fitting method is used, which either creates

quadrilaterals sharing a central vertex [5], or a larger four-sided region with approximated trimming curves. The former does not ensure continuity inside the patch, while the latter has an inherent asymmetry, as well as parameterization issues [9].

Here S-patches seem to have an advantage: it is shown in the original paper [4] that any regular S-patch can be exactly converted into a trimmed rational Bézier surface. The algorithm for this has not been described in detail, however, so in our article we will go through all the required steps.

In Section 2 we will briefly review the related publications. In Section 3 we will define the S-patch both in itself, and as the composition of Bézier simplexes. Then the conversion process is described in Section 4. An example and the discussion of some practical issues conclude the paper.

## 2 Previous Work

S-patches were first published by Loop and DeRose [4] in 1989, but the techniques needed for the conversion process were developed earlier: see Ramshaw’s wonderful book [6] on blossoming, and DeRose’s paper [1] on the composition of Bézier simplexes. A more efficient variation [2] of the latter was developed a few years later.

In the following sections, we will try to connect the dots, and insert a few missing pieces (notably the polarization of Wachspress coordinates in Section 4.1.1), hopefully making tensor product conversion easy to understand and implement.

## 3 S-patches

An -sided S-patch111This paper deals only with regular S-patches, as only these have the required properties for conversion. is defined over a regular -gon, parameterized by Wachspress barycentric coordinates  [3]. Its control points are labeled by non-negative integers whose sum is the depth222Sometimes also referred to as the degree, since the boundaries of an S-patch are Bézier curves of degree . of the surface (). We will use the notation for the set of all such labels, and for one particular label. The norm of a label is its sum, i.e., .

The surface point corresponding to a domain point with barycentric coordinates is defined as

 S(λ)=∑s∈Ln,dPs⋅Bds(λ)=∑s∈Ln,dPs⋅(ds)⋅n∏i=1λsii, (1)

where are Bernstein polynomials, and

 (ds)=d!∏ni=1si! (2)

are their multinomial coefficients.

### 3.1 S-patches as Bézier simplexes

An -dimensional simplex has vertices (e.g. in 2D a triangle, in 3D a tetrahedron). Any point can be uniquely expressed by the affine combination of these vertices:

 p=n∑i=1λiVi,n∑i=1λi=1. (3)

The coefficients are called the barycentric coordinates of relative to the simplex.

A Bézier simplex of dimension and degree is a polynomial mapping from the barycentric coordinates relative to an -dimensional simplex, given in Bernstein form:

 ∑s∈Ln,dPs⋅Bds(λ), (4)

where are called the control points of the Bézier simplex. We can see that this is the same as Eq. (1), i.e., the S-patch is a Bézier simplex that maps from an -dimensional simplex to 3D, restricted to the embedded domain polygon (the generalized barycentric coordinates).

Let us introduce the following notations for a Bézier simplex :

• : # of arguments (i.e., domain simplex dimension + 1)

• : degree

• : dimension of the control points

These form the characteristic triple . For example, for an -sided S-patch of depth , .

## 4 Conversion to trimmed Bézier patches

According to the original paper [4], any -sided S-patch of depth can be converted into an -sided rational S-patch of depth . Also, a four-sided S-patch of depth can be converted into a tensor product Bézier patch of degree .

Consequently, the conversion is done in two stages. First the -sided S-patch is replaced with a four-sided one (Section 4.1), then the tensor product form is computed (Section 4.2), resulting in a surface of degree .

### 4.1 Conversion to quadrilateral S-patches

The Wachspress coordinates of an -sided regular polygon have the form

 λi(p)=∏j≠i−1,iDj(p)∑nk=1∏j≠k−1,kDj(p), (5)

where is the signed distance of from the -th side.

When is given by barycentric coordinates, this can also be expressed as a rational Bézier simplex , that maps from a 2D simplex to a simplex of dimension . This is not an obvious result, since Eq. (5) involves Euclidean distances. For the exact construction, and the handling of rational simplexes, see Section 4.1.1.

It is also shown that is pseudoaffine, i.e., it has an affine left inverse . With this, we can write

 S∘Wn=S∘Wn∘(W−14∘W4)=(S∘Wn∘W−14)∘W4. (6)

In other words, the four-sided version of the -sided depth S-patch is the composition of three Bézier simplexes, with the following characteristic triples: , , and .

Let us see how to generate control points for each of these Bézier simplexes. Since we will have to work with barycentric coordinates relative to some simplex, define the canonical simplex as the canonical basis and the origin. In 2D, this will be the triangle , , , so the barycentric coordinates for a point will be .

The Bézier simplex defines the vertices of the four-sided domain in the plane. Since the tensor product patch will be defined on , we will use the same square as the image of the 3D simplex. Thus the control points of are:

 P1000 =(0,1,0), P0100 =(1,1,−1), P0010 =(1,0,0), P0001 =(0,0,1). (7)

Getting the control points of needs a bit more work, see the next section.

The control points of are just the control points of the original -sided S-patch. The astute reader must have noticed that . This is because is rational, and the composition algorithm needs to be also in homogenized barycentric form (see below).

#### 4.1.1 Polarization of the Wachspress coordinates

Homogeneous coordinates are normally represented by adding an extra “weight” coordinate, so , and projection works by dividing with the weight. With Bézier simplexes, we use another type of homogenization, that allows us to use the simplex composition algorithm as it is, even for the rational case: we take the barycentric coordinates (relative to some simplex) and use them as “normal” coordinates in a higher dimension.

If we use the canonical simplex, an point has the barycentric coordinates , so in general the homogenized form will be . Projection is done by dividing with the sum of all coordinates.

The homogenized form of Wachspress coordinates is thus . We will work out the Bézier simplex coordinates for this by using its blossom or polarization. For any homogeneous polynomial of degree , there is a symmetric multilinear function of arguments that agrees with it on its diagonal:

 q(u1,…,ud) =q(uπ1,…,uπd), (8) q(u1,…,αuk1+βuk2,…,ud) =αq(u1,…,uk1,…,ud) +βq(u1,…,uk2,…,ud), (9) q(u,…,u) =Q(u). (10)

Eq. (8) shows symmetry for permutations, Eq. (9) multilinearity, and Eq. (10) the diagonal agreement.

The rational Bézier simplex control points for are easily computed from its polarization:

 PQs=q(V1,…,V1s1,V2,…,V2s2,…,Vn,…,Vnsn), (11)

where are the vertices of the domain simplex.

The blossom of Wachspress coordinates for a regular -gon is given as

 q(p1,…,pn−2)i=1(n−2)!⋅∑π∈Π(n−2)n−2∏k=1j≠i−1,iDj(pπk), (12)

where is the set of permutations of , and in the product runs from to while goes from to skipping and . Now Eq. (11) can be used to compute the coordinates of .

The exact position and rotation of the -sided polygon affect the quality of the generated control net. A good choice is to use cyclic polygons on the circle that has its origin at , and a radius of .

#### 4.1.2 Simplex composition

Now that all three of the Bézier simplexes are well-defined, we can turn our attention to their composition. Let and denote Bézier simplexes, and . Then

 ϕ(H)=(nG,dF⋅dG,δF), (13)

and the control points are given by

 PHs=∑|s1|+|s2|+⋯+|sdF|=dGs1+s2+⋯+sdF=s(dGs1)⋯(dGsdF)(dF⋅dGs)Δ0nF(PGs1,…,PGsdF), (14)

where

is a multi-index or vector of length

consisting entirely of zeros, and

 Δs(p1,…,pk)={∑nFi=1pi1PFs+eiif k=1,∑nFi=1pikΔs+ei(p1,…,pk−1),otherwise. (15)

Here is the -th coordinate of , and is the multi-index with the -th position increased by one.

#### 4.1.3 Efficient composition algorithm

The equations shown in the previous section, when implemented naïvely, are highly inefficient. DeRose et al. [2] show an algorithm for computing it in a less computationally intensive manner. It is based on caching the results of the recursive calls to , and using the fact that is symmetric in its arguments.

The pseudocode is shown in Algorithm 1. Here next() is the next multi-index in a lexicographical ordering, e.g. , returning after the last element ( in the example). Since is now computed only for this lexicographical permutation of its arguments, its result is multiplied by divided by the factorials of the argument multiplicities (built up by the variable ).

The above paper suggests the use of arrays for the control points, indexed by the lexicographical order of the multi-index labels. A conceptually simpler alternative is the use of a dictionary data structure (a hash table) that maps control point positions to their labels. Our experiments show that this is actually even faster, as the hash function is cheaper to compute than the lexicographical index.

#### 4.1.4 Change of coordinates

The homogenized control points computed above have the form . To convert these to the usual homogeneous coordinates , we just need to replace the last coordinate by the sum of all coordinates.

### 4.2 Conversion to tensor product form

A (rational or non-rational) quadrilateral S-patch of depth has the tensor product Bézier patch form

 ^S(u,v)=d∑i=0d∑j=0CijBdi(u)Bdj(v) (16)

with the control points

 Cij=∑ss2+s3=is3+s4=j(ds)(di)(d)jPs. (17)

## 5 Example

Figure 1 shows a 5-sided S-patch of depth 5, converted into a -degree tensor product rational Bézier patch. The example model was generated by the ribbon-based algorithm of the author [7].

## 6 Discussion

We have seen how S-patches are transformed into trimmed Bézier patches. Let us now look at some practical issues.

### 6.1 Efficiency

The algorithm in Section 4.1.3 is still computationally demanding. Converting a 5-sided S-patch of depth 8 took more than 5 minutes on a 2.8GHz processor. There is a much faster approach – see the upcoming paper of the author [8].

### 6.2 Triangles

Three-sided S-patches, i.e., Bézier triangles, are converted into simple polynomial patches, since computing the barycentric coordinates do not involve rational polynomials. Note however, that there are alternative methods for the quadrilateral transformation of a triangular patch, see e.g. Warren’s domain deformation method [10].

### 6.3 Control net quality

One issue with the conversion is that the quadrilateral control grid may have outlier control points or spikes near the corners. This is because the denominator of Wachspress coordinates vanish on a circle around the domain, and these singularities undermine the stability of these areas.

## Conclusion

The S-patch representation of multi-sided surfaces could be an important asset in a modeling toolbox. It can be used to fill holes or create smooth vertex blends, and then it can be exported to CAD/CAM systems as a trimmed Bézier patch, without losing precision, thus making it possible to create perfectly watertight models. In this paper we have reviewed the steps required for the quadrilateral conversion, and discussed some related questions.

## Acknowledgements

This work was supported by the Hungarian Scientific Research Fund (OTKA, No. 124727). The author thanks Tamás Várady for his valuable comments.

## References

• [1] Tony D. DeRose. Composing Bézier simplexes. ACM Transactions on Graphics, 7(3):198–221, 1988.
• [2] Tony D. DeRose, Ronald N. Goldman, Hans Hagen, and Stephen Mann. Functional composition algorithms via blossoming. ACM Transactions on Graphics, 12(2):113–135, 1993.
• [3] Kai Hormann and Michael S. Floater. Mean value coordinates for arbitrary planar polygons. Transactions on Graphics, 25(4):1424–1441, 2006.
• [4] Charles T. Loop and Tony D. DeRose. A multisided generalization of Bézier surfaces. ACM Transactions on Graphics, 8(3):204–234, 1989.
• [5] Les A. Piegl and Wayne Tiller. Filling -sided regions with NURBS patches. The Visual Computer, 15(2):77–89, 1999.
• [6] Lyle Ramshaw. Blossoming: A connect-the-dots approach to splines. Digital Equipment Corporation, Palo Alto, 1987.
• [7] Péter Salvi. hole filling with S-patches made easy. In

Proceedings of the 12th Conference of the Hungarian Association for Image Processing and Pattern Recognition

, 2019.
• [8] Péter Salvi, Tamás Várady, and Alyn Rockwood. Notes on the CAD-compatible conversion of multi-sided surfaces. Computer-Aided Design and Applications (submitted), 2020.
• [9] Márton Vaitkus and Tamás Várady. Parameterizing and extending trimmed regions for tensor-product surface fitting. Computer-Aided Design, 104:125–140, 2018.
• [10] Joe Warren. Creating multisided rational Bézier surfaces using base points. ACM Transactions on Graphics, 11(2):127–139, 1992.