Conversion of B-rep CAD models into globally G1 triangular splines

Clough-Tocher


Introduction
Traditional computer aided design (CAD) systems rely on boundary representations (B-reps), meaning that CAD models are described in terms of their outer shells rather than as solids.The standard CAD representation of surfaces is that of non-uniform rational B-splines (NURBS) (Piegl and Tiller, 1995), an extension of B-splines capable of exactly representing, among other shapes, conic arcs in the univariate case and quadric patches in the case of bivariate tensor-product NURBS.However, the inherent topological restriction of tensor products means that only topological disks, cylinders or tori can be represented using a single NURBS patch.Other, more complex shapes need to be covered using multiple patches which are trimmed against each other and then topologically stitched in the resulting B-rep.
While this allows one to model shapes of arbitrary manifold topology, the fact that the intersection curve of two NURBS patches is not, in general, a NURBS curve means that CAD models are not geometrically watertight, i.e., not even C 0 continuous.The true intersection curves are only approximated by NURBS (trimming) curves.The resulting gaps (or overlaps) can be kept below machine precision and thus do not pose major problems when manufactured.However, in the context of analysis and simulation, this causes major issues (Marussig and Hughes, 2018).
One solution is to mesh the CAD model to obtain a piece-wise linear and watertight representation for a finite element (FEM) computation.However, with the advent of isogeometric analysis (IgA) (Cottrell et al., 2009), which promotes the use of exact geometry and suggests to use the same basis functions used to describe the shape also for spanning the solution space, various geometry conversion methods have been investigated to turn CAD models into higher-order (i.e., not simply piece-wise linear) analysis-suitable representations.
However, existing conversion methods suffer from one of the following two shortcomings.The resulting global continuity is not better than C 0 (Kosinka and Cashman, 2015;Massarwi et al., 2018), or the representation of choice is not directly CAD compatible (Shen et al., 2014(Shen et al., , 2016b)).
In contrast, we provide a method based on Clough-Tocher (Clough and Tocher, 1965) and Shirman-Séquin (Shirman and Séquin, 1991) macro-elements which converts B-rep CAD models into globally tangent-plane (G 1 ) continuous triangular splines.As only cubic and quartic Bézier triangles (Farin, 1986) are produced, the converted surface is CAD compatible.Although the visual improvement over the C 0 method of Kosinka and Cashman (2015) is often marginal, the main advantage of our approach is that it provides exact G 1 smoothness, which is important in downstream applications such as analysis and simulation, for example in the context of enhanced FEM (Sevilla et al., 2011).
We review and discuss existing conversion methods in Section 2. The building blocks of our approach are described in Section 3. The necessary preprocessing of data sampled from CAD models is discussed in Section 4. Section 5 covers our main contribution, i.e., how to generate a globally tangent-plane continuous approximation of an input B-rep CAD model.Our results are presented in Section 6.As we offer several variants of the conversion method, we provide a discussion in Section 7. The paper is concluded in Section 8.

Related work
The widely adopted standard of representing CAD models as B-reps using trimmed and stitched NURBS patches inevitably produces non-watertight geometries.This has prompted investigations into better representation methods and related conversion techniques, especially in the context of isogeometric analysis (Marussig and Hughes, 2018).
These conversions are either exact, meaning that the geometry remains intact but also non-watertight, or approximate.The former class of exact techniques is represented by untrimming (Elber and Kim, 2014;Massarwi et al., 2018).While this ensures that the converted patches are no longer trimmed, the continuity of the CAD model inevitably does not change.
The latter class of approximate techniques necessarily modify the input geometry, but the resulting conversion error is typically controllable and often confined to regions near the B-rep edges (trimming curves).Existing techniques include conversion to Catmull-Clark (Shen et al., 2014) and Loop (Shen and Kosinka, 2016) subdivision surfaces.An improved variant in which regions away from the trimming curves can be kept unmodified was recently presented in Shen et al. (2016b).These techniques offer globally G 1 approximations, but are not directly CAD-compatible due to the lack of closed-form representations in irregular regions.A closely related method converts CAD models into T-splines (Sederberg et al., 2008), but again, T-splines rely on subdivision or approximate G 1 conditions near irregular regions.
A promising approach to tackle the trimming problem is based on watertight Boolean operations (Urick et al., 2019).While it produces watertight models, the placement of extraordinary points and feature lines in the method remains a manual task.
CAD models can be converted into collections of curved triangles.This approach was taken in Xia and Qian (2017), which also offers a volumetric counterpart.However, their construction is based on the Clough-Tocher-Hsieh split (Clough and Tocher, 1965) and parametric continuity, and thus produces globally only C 0 results.An earlier technique based on Clough-Tocher splines appeared in Kosinka and Cashman (2015).This offers CAD-compatible patches, but in general results in only C 0 continuity across but also near B-rep edges.
To remedy this, we present a technique based on polynomial Bézier triangles and the Shirman-Séquin construction (Shirman and Séquin, 1991) to enhance existing Clough-Tocher techniques such that globally tangent-plane continuous models are obtained.

Preliminaries
We start by introducing basic concepts including Bézier triangles and continuity conditions between them.Then we discuss the Clough-Tocher construction and the Shirman-Séquin construction.

Bézier triangles
(1) Any polynomial p of total degree at most d defined on T can be expressed in the Bernstein-Bézier form with the multi-index i = (i, j, k), |i| = i + j + k, and i, j, k ≥ 0. Generalising this functional setting to the parametric one, a Bézier patch P is obtained in the form with control points P i ∈ R 3 , associated with the barycentric coordinates i/d, forming a triangular control net.An example in the cubic case is shown in Fig. 1.Bézier triangles can be degree elevated (Farin, 1986) via where i k is the k-th element of i and I k is the k-th row of the d × d identity matrix.Degree elevation of boundary control points reduces to degree elevation for Bézier curves.

Continuity conditions
Consider the situation sketched in Fig. 1.The C 1 continuity conditions between two cubic Bézier triangles P and

P
and their respective triangles in parameter space T (v 0 , v 1 , v 2 ) and T (v 1 , v 3 , v 2 ) are, along with the trivial C 0 conditions of shared edge control points, given by P012 = τ 0 P 102 + τ 1 P 012 + τ 2 P 003 , P111 = τ 0 P 111 + τ 1 P 021 + τ 2 P 012 , P210 = τ 0 P 120 + τ 1 P 030 + τ 2 T 021 , (5) where (τ 0 , τ 1 , τ 2 ) are the barycentric coordinates of v 3 with respect to T , i.e., G 1 continuity is typically less restrictive compared to C 1 continuity (Peters, 2002): two Bézier triangles meet at a common boundary curve with G 1 continuity if the common tangent plane along that curve varies continuously.Let (v) be the common boundary curve of Bézier triangles P and P , and let ∂ P (v) and ∂ P (v) express cross-boundary derivatives of the respective triangles along (v).A sufficient and necessary condition for G 1 continuity is given by the co-planarity of the three tangent vectors ∂ (v), ∂ P (v) and ∂ This condition can be expressed in terms of three scalar functions α(v), β(v) and γ (v): To solve the problem of G 1 continuity between Bézier triangles, we exploit these three functions, as we detail below.

The method of Chiyokura & Kimura
The method of Chiyokura and Kimura (1983), also called the CK-method, is a method that joins two tensor-product Bézier patches with G 1 continuity by only taking into account shared positional and normal data, which makes it a fully local method.It was later generalised to cover also triangular patches (Longhi, 1985), and that is the version we now recall.
Consider the situation depicted in Fig. 2 where an actual patch A is connected to a basis patch B, here understood as a ribbon given by two rows of control points.The b i vectors belong to B, c i are vectors of the cubic control polygon defining the common boundary edge, and a i belong to A. Further, b 0 and b 3 are unit vectors orthogonal to c 0 and c 2 , respectively, and lie in the tangent planes defined by the normals of the end-points of the shared edge.The first row of control points from the boundary, i.e., those pointed to by a i , are quartic control points obtained by degree elevation; see Equation (4).
Equation ( 6) is then reformulated to: such that the actual patch is joined with G 1 continuity to the basis patch.To solve this equation, we first express a 0 and a 3 as and set It is then assumed that ∂ B is only quadratic and that vectors b 1 and b 2 can be determined by linear interpolation as All combined, this leads to Ultimately, the connection to the basis patch can be done using data from the common boundary only.The method is applied to both sides separately, and thus both sides are connected to the same basis patch and therefore the actual patches join with G 1 continuity.

The Clough-Tocher construction
In situations where a single patch with a parametrisation is given, as is the case with B-rep patches, one can employ the Clough-Tocher construction (Clough and Tocher, 1965) to turn this patch into a C 1 collection of cubic (macro-)triangles.We now recall the main steps in this conversion process; more details can be found in Kosinka and Cashman (2015).
To start with, a suitable triangulation of the parametric domain of the patch is constructed so that the corresponding triangular mesh in 3D with vertex positions sampled from the patch provides a satisfactory approximation.Many methods can be used for this purpose, including for example Tristano et al. (1998); Busaryev et al. (2009); Shen et al. (2016a), and by suitable we mean that the triangulation should meet the criteria imposed by a given application, such as various tolerances on triangle and approximation quality.The examples in this paper rely on the CADfix product (International TechneGroup Ltd., 2019) to import CAD models and generate the required triangulation (and also gradients as described below).The CADfix meshing process is similar to that of Kallmann et al. (2004), based on incremental constrained Delaunay triangulation.Each of the generated vertices is, on top of its parameter value v i , equipped with its position P i in 3D on the input patch p, as well as the gradient ∇P i with respect to the parametrisation of p.In order to interpolate this data with a C 1 cubic triangular spline, each of the generated triangles is split into three (cubic) micro-triangles, giving rise to macro-elements.In our examples, the barycentre is used as the split point, although other options are possible (Schumaker and Speleers, 2010;Kosinka and Cashman, 2015).
The Clough-Tocher construction, which generates a cubic triangle over each micro-triangle, then proceeds in three steps.First, the macro-triangle vertex control points are set to their corresponding P i , and the macro-edge control points are computed, using the notation of Fig. 3, left, according to to interpolate also the gradients.The C 1 continuity conditions of Equation ( 5) are used to compute with the index i ∈ {0, 1, 2} understood cyclically (modulo 3).
Secondly, the micro-triangle central control points Q 01 , Q 12 , and Q 20 are set according to one of the many variants of the Clough-Tocher construction; see Kosinka and Cashman (2015) for an overview.In our paper, we make use of two variants of the construction.One that uses additional gradients sampled at the midpoints of edges (Kosinka and Cashman, 2015, Section 3.6), and the original Clough-Tocher variant (Clough and Tocher, 1965), (Kosinka and Cashman, 2015, Section 3.1) as specified below.
Thirdly, the remaining control points are computed, again via the C 1 continuity conditions.This yields In this manner, C 1 continuity is guaranteed across macro-patch boundaries as well as micro-patch boundaries.It also ensures interpolation of the input positions and gradients.
As the Clough-Tocher construction relies on a parametrisation, it does not work on surfaces of arbitrary manifold topology.When B-rep patches having different parametrisations meet at a shared B-rep edge, their gradients will, in general, not match.This may then result in discontinuities at the seam.To remedy this, Kosinka and Cashman (2015) proposed to move some of the control points at the seam such that the geometry becomes C 0 , namely by snapping them to the control points of a cubic approximation of the B-rep edge.While this procedure creates watertight results, some micro-and macro-edges become C 0 internally (as the C 1 conditions are violated by this adjustment), and there is no simple, non-degenerate way of adjusting the control points differently in order to obtain G 1 continuity at the seams using only cubic (macro-)triangles.
Consequently, a different construction needs to be used near B-rep edges if one is to obtain a globally G 1 result.

The Shirman-Séquin construction
The Shirman-Séquin construction (Shirman andSéquin, 1991, 1987) is similar to the original Clough-Tocher construction as it is also based on the same split of the domain triangle.The main difference is that the Shirman-Séquin construction is fully geometric and uses quartic Bézier triangles instead of cubic ones.As such, it can overcome the parametric and thus topological restrictions of Clough-Tocher splines.
The Shirman-Séquin construction makes use of the CK-method (Chiyokura and Kimura, 1983) (see Section 3.3) to guarantee tangent-plane continuity of adjacent (macro-)triangles.The construction takes as input a macro-triangle with cubic Bézier curves on its three edges.In our context, it is assumed that all cubic edges incident with a vertex of the mesh meet there with a shared tangent plane.
Consider the patch layout and labelling as shown in Fig. 3, right.The positions of I i1 are set according to Equation ( 8).
These are then degree raised to Îi1 = (P i + 3I i1 ) /4 (not shown in the figure), and used in the CK-method to determine all L i,i+1 and K i,i+1 .These points are in turn used to complete the construction using combinations of 'cubic' and 'quartic' control points and finally All boundary curves, micro and macro, are then fully degree raised to quartics to obtain a quartic Bézier triangle on each of the micro-triangles.In essence, the Shirman-Séquin construction is a combination of the method of Chiyokura & Kimura and Farin's method (Farin, 1982).The CK-method is used to create G 1 joins at macro-edges and Farin's method is used to create G 1 joins at micro-edges of the macro-elements.
We now have all the ingredients needed to proceed to our CAD model conversion method.

Preprocessing
Consider a CAD model described by one or more (trimmed) B-rep patches.As described in Section 3.4, the Clough-Tocher construction combined with a suitable error-driven triangulation method is used to turn the CAD model into a C −1 collection of C 1 -continuous Clough-Tocher splines (Kosinka and Cashman, 2015), each described over its own parameter domain.
At the same time, the corresponding approximated B-rep edges are described as C 1 -connected cubic Bézier curves whose end-points coincide with the vertices of the polyline approximations of the B-rep edges, and which also interpolate the Brep edge derivatives there.The vertices of these polylines of course appear in the overall triangulation, but the Bézier curves do not necessarily exactly coincide with the piece-wise cubic edges of the Clough-Tocher splines; see Fig. 4, left.
Each B-rep edge also comes with the information of whether it should be treated as a sharp edge (with C 0 continuity across it) or as a smooth edge (with G 1 continuity).If this information is not provided or in the case of a vanishing crease, we rely on the normal vector information provided by the B-rep patches (topologically) incident with that B-rep edge: if the angle between the normals of the two incident patches meeting at a vertex is below a threshold, the part of the edge near that vertex is considered smooth, and sharp otherwise.Sharp B-rep edges (topologically) meet at sharp B-rep vertices.
As we aim for triangles of a minimal degree, we keep all the internal (macro-)triangles obtained by the Clough-Tocher construction intact, and only apply the Shirman-Séquin construction near the B-rep edges, replacing some of the cubic triangles with quartic ones.But even for smooth edges, the boundary data sampled from the CAD model needs to be adjusted first to ensure that the construction can be applied.

G 1 -compatible boundary
As mentioned in Section 3.4, the Clough-Tocher method is capable of guaranteeing only C 0 , and in general not higher, continuity near B-rep edges, even after adjusting some of the control points of the micro-triangles incident with the edge.This holds even in the case when the gradients at the B-rep vertices span the same tangent plane; this is due to the parametric nature of the method.
Therefore, we need to ensure common tangential data along the shared B-rep edge so that the Shirman-Séquin method can be applied.This translates into the requirement of having shared normals at all the vertices of a smooth B-rep edge.
To achieve this, we propose a two-step adjustment procedure.In the first step we determine an adjusted normal vector for all shared vertices which lie on the common boundary curve, and in the second step we ensure that all curves meeting at such a vertex respect this normal.We address the most common configuration first; other configurations are covered in Section 4.2.
Consider the situation sketched in Fig. 4, right.A vertex P on the B-rep edge (shown in grey) also corresponds to two positions, P 1 and P 2 , on the two B-rep patches (topologically) meeting there.The two gradients sampled at these positions from the patches give rise to, in general, two different normals, n 1 and n 2 .We simply average these two normals to obtain a NURBS curve and is thus approximated by a NURBS B-rep edge (grey).But as this B-rep edge does not, in general, lie on either of the two patches, it is in turn approximated by two trimming curves (red and blue), one on either patch.Right: The situation at a vertex P of the B-rep edge (grey).Due to the (unavoidable) inexactness of the trimming curves (red and blue), P corresponds to two, in general distinct, points, P 1 and P 2 , one on either of the patches N 1 and N 2 .The smaller grey control points are determined using the derivative of the original B-rep edge at P, and similarly for the red and blue control points along the two trimming curves.The other red and blue points come from the constrained triangulations of the two patches and the Clough-Tocher construction on both sides.As the patch normals n 1 and n 2 at resp.P 1 and P 2 do not, in general, agree mutually or with the B-rep edge, they need to be adjusted to n. (For interpretation of the colours in the figure(s), the reader is referred to the web version of this article.)n 0 (not shown in the figure), but again due to CAD tolerances, this normal is not in general perpendicular to the B-rep edge at P. Therefore, we project n 0 onto the normal plane of the B-rep edge there, and obtain the final n.This same projection step is also needed for the normals of sharp edges, as it still might not agree with the B-rep edge.The same procedure, but without the averaging step, is applied to vertices that lie on a B-rep edge that is determined to be sharp.In this case its normal vector can be directly projected onto the normal plane of the B-rep curve.
In the second step, we 'snap' the red and blue points aligned with the edge onto the associated grey points; this is shown by the grey ellipses in Fig. 4, right.This is essentially the same adjustment as in Kosinka and Cashman (2015), and ensures C 0 continuity.
Further, we have to ensure that also the other (straight) edges emanating from P are orthogonal to n.To this end, we project the remaining points topologically edge-connected to P (note that this includes also connections to P 1 and P 2 ) onto the plane defined by P and n.This way, we optimally respect the gradients defined at the P-vertices in the sense that the projected control points are an affine transformation of their initially set positions on either side.The data now satisfy the G 1 assumptions of the Shirman-Séquin construction.

Other vertex configurations
Naturally, other configurations than that shown in Fig. 4 can arise.If P is an internal B-rep edge vertex, its valency can differ from that shown, and the adjustment needs to be applied in slightly different ways.At T-junctions and at vertices where two smooth B-rep edges meet transversally (X-junctions), the adjusted normal n is taken to be the vector perpendicular to the two incident B-rep directions.In these cases the vertex normal is uniquely defined by the B-rep edges meeting at the vertex.
At B-rep vertices marked (or judged to be) smooth (by design) with higher valencies or at vertices where the unique normals of adjacent patches are slightly off, n is determined by a least square fit.Still, this means that the B-rep edges have to be adjusted at these high valency points, by projecting, as above, the edge-connected control points of P onto the plane defined by the least squares fit.
Finally, sharp B-rep edges keep their two separate normals n 1 and n 2 (or more at sharp corners of higher valency).It may thus seem sufficient to use the Clough-Tocher construction in such sharp cases.But alas, the control point adjustment to reach C 0 continuity also ruins C 1 continuity across the micro-edges near this adjustment, as already observed in Kosinka and Cashman (2015).Therefore, we use the Shirman-Séquin construction also at sharp B-rep edges.This ensures that only the sharp edges are C 0 , and the splines are at least G 1 everywhere else.

Conversion to Shirman-Séquin splines
After the boundary adjustment, all the data is prepared for G 1 (or on demand C 0 ) interpolation.We now have several options.The first and obvious one is to use the Shirman-Séquin construction globally.This is of course realisable, but it is computationally cheaper and in general preferable to use lower-degree triangles where possible.
Note that we can categorise the triangles incident with B-rep edges in the CAD model triangulation into two groups: those with two (or more vertices) on the boundary, called 2-connected triangles, or those with just one vertex on the boundary, dubbed 1-connected triangles.All other (non-boundary) triangles are processed using the Clough-Tocher construction, and are thus only (piece-wise) cubic.
All 1-connected triangles can potentially also be turned into Clough-Tocher macro-elements, simply because the two-step adjustment does not ruin their internal C 1 continuity.The situation of the 2-connected triangles is different: the Clough-Tocher construction cannot be used due to the boundary normal adjustment step and the above mentioned topological restrictions.The Shirman-Séquin construction cannot be used naïvely either: the CK-method expects a basis patch as the cross-boundary derivative.For a 1-connected triangle a cross-boundary derivative has already been defined by the adjacent (micro-)triangle(s) of a Clough-Tocher construction and this is in general different from the one constructed in the CKmethod.
In the initial step of all new constructions, the boundary of each macro-triangle is set using the same procedure as with the standard Clough-Tocher macro elements.This means that for each boundary triangle a cubic Bézier control polygon has been defined.Similarly, the points I i1 (see Equation ( 8)) can be computed.With this all necessary data is available to start creating the Shirman-Séquin splines and to create G 1 connection between them using the CK-method.As said before, for the 2-connected triangles it is not possible to use this method to connect to adjacent Clough-Tocher macro-elements.Therefore, we design an alternative G 1 method to handle 2-connected triangles connected to Clough-Tocher elements.

An alternative G 1 method
Consider again the situation shown in Fig. 2, but this time imagine that patch B is a cubic Bézier triangle for which all control point positions have already been defined.Here, we encounter a 'master-slave' situation.The basis patch of the CK-method does not, in general, agree with the tangent plane of an arbitrary cubic Bézier triangle along (u), and so we need to proceed differently.
The first two rows of control points of B, the master, are used to construct a cross-boundary derivative ∂ B (v) of B along (v).We are free to choose the direction of the derivative, as long as it is transversal with respect to the edge, such as the orthogonal direction to the edge in parameter space.However, to ensure invariance of the construction with respect to vertex indexing and affine reparametrisations, we take it to be the direction given by the parametric midpoint of the shared edge and the opposite vertex in parameter space.Using the notation of Section 3.1, this direction is given by The corresponding transversal derivative is quadratic and given by three control vectors, which we denote by d 0 , d 1 , and d 2 .
Turning back to Equation (6), we obtain α(v) where B 2 i (v) and B 3 i (v) are the univariate quadratic and cubic Bernstein polynomials, respectively.We choose the functions β and γ to be linear polynomials, just as in Equation ( 7), and set α(v) ≡ 1.Then we determine the coefficients β 0 , β 1 and γ 0 , γ 1 by solving Equation ( 9) with v = 0 and v = 1, i.e., by solving a 0 = β 0 d 0 + γ 0 c 0 and The sought-after vectors a 1 and a 2 can then be found via This in turn gives the quartic control points, shown as diamonds in Fig. 2, of A, the slave, such that it connects to B with G 1 continuity.Note that it is in general impossible to obtain A as a cubic patch.Indeed, modifying the left-hand side of Equation ( 9) to α(v) 2 i=0 B 2 i (v)a i admits no solution for generic input data as then only a 1 remains as an over-constrained freedom when a 0 and a 2 are given.
It is now apparent that we have two options near B-rep edges.One option is to convert the whole strip of 2-connected and 1-connected triangles into a Shirman-Séquin spline strip.We call this approach 'full-strip'.The other option is to do this only to the 2-connected triangles.As a saw-tooth-like layout becomes apparent in this case, we call this approach 'sawtooth'.Fig. 5 illustrates this.The saw-tooth pattern contains only the red triangles, whereas the full-strip pattern contains both the red and blue triangles.
We now detail these two options, assuming that the boundary data has been made compatible for G 1 conditions by the boundary adjustment technique described in Section 4.

Full-strip
In the full-strip option, we convert all 2-connected triangles into complete Shirman-Séquin splines.This requires the use of the CK-method on all three macro-edges of each triangle, including the side incident to the B-rep edge.This same step is applied to the adjacent micro-triangles of an adjacent patch, on the other side of the B-rep edge, and if they share their normal data, G 1 continuity is ensured.
The 1-connected triangles are only partly constructed using the Shirman-Séquin technique.This is because the boundary data of the micro-triangles connecting to the 'inner' Clough-Tocher macro-elements can simply be degree elevated.All 1-connected triangles possess a micro-triangle, shown in dark blue in Fig. 5, incident with an inner Clough-Tocher macroelement.The other micro-triangles are shown in light blue.
And so first, all the dark-blue micro-triangles are partly computed using the Clough-Tocher construction up to the part where the midpoints Q i,i+1 are determined (Section 3.4).At this point this data determines a fully C 1 cross-boundary derivative and we can degree elevate these data to quartic.Then the light-blue triangles are constructed using the CKmethod as in the normal construction of a Shirman-Séquin macro-element.The degree elevation step ensures that the micro-triangle retains its C 1 continuity across the macro-element boundary.In principle, it is also possible to use the alternative G 1 method instead, but this will change the type of achieved continuity for the dark blue micro-triangles (Fig. 5).

Saw-tooth
In the saw-tooth option, we want to minimise the number of quartic triangles used, and so we only modify the 2connected triangles, all others are processed as Clough-Tocher macro-elements.We can process the 1-connected triangles as ordinary Clough-Tocher elements because the only adjustment made to its control points in the normal adjustment step respects the gradient at the boundary vertex.Therefore all 1-connected triangles can still be connected with C 1 continuity with all other 1-connected triangles emanating from the same vertex.The 2-connected triangles should be processed as Shirman-Séquin macro-elements, as their control points may have been adjusted to coincide with the B-rep edge.
The slight complication here is that the CK-method cannot be applied to connect the light-red micro-triangles to their adjacent light-blue triangles as the latter ones do not conform to the basis patch construction.Therefore, the method of Section 5.1 is used to construct the inner control points of the light-red micro-triangles.
The entire construction of the saw-tooth pattern can be summarised as follows.First, all Clough-Tocher macro-elements are constructed as usual.Then only after this, we start with the construction of the Shirman-Séquin patches for all 2connected triangles.For all macro-patch edges at the B-rep edge (shown in dark red in Fig. 5) the standard CK-method is used.For all other edges (connection between light-red and light-blue triangles), a G 1 connection is made to the actual adjacent cubic Bézier triangle of the Clough-Tocher macro-element.After this the Shirman-Séquin macro-elements are complete.
We can push this saw-tooth option further, by insisting that only the 2-connected micro-triangles (dark red) are quartic, all other remain cubic.This is possible by performing a secondary split, and we discuss it briefly now for the sake of completeness.

Saw-tooth: secondary split
In this option, we replace each 2-connected micro-triangle by a Shirman-Séquin macro-element.We first perform the Clough-Tocher spline construction as usual, but we do this without adjusting the boundary control points to maintain C 1 continuity away from the B-rep edge.Then we replace the 2-connected micro-triangles with Shirman-Séquin macro-elements.
We proceed as follows.First, we can now safely adjust the boundary control points to ensure C 0 continuity across the B-rep edge.Now, the macro-edges of the 2-connected micro-triangle are G 1 compatible and we can proceed by applying the  CK-method for the macro-patch boundaries and the method of Section 5.1 for G 1 joins with the adjacent micro-triangles of the initial split.
In corner cases where two edges of a single macro-triangle come from B-rep edges, i.e., two of its micro-triangles are 2-connected, the common micro-triangle boundary also uses the CK-method.This is the case because potentially both of the macro-triangle boundaries can have shifted control points after boundary adjustment.This behaviour can be clearly observed in the corners of the two different sphere octants depicted in Fig. 7, fourth column, and is described in Section 6.1.

Results
In this section we present several results to show the capabilities of the new conversion method; see Fig. 6.We also compare the results obtained using the three variants of the method: full-strip, saw-tooth, and secondary split.We use simple and academic examples to illustrate the method, but also more complicated CAD models to show its utility.

Sphere octants
In this first example, we connect two octants of a sphere.In this case, we do not have to resort to using boundary normal adjustment as both the positions and the tangent planes at the sampled vertices along the common edge are shared.
Although the two octants, their sampling, and their parametrisations are fully symmetric, the gradients computed on the octants at the shared vertices do not agree.This means that the Clough-Tocher construction, even after the edge control point adjustment (Kosinka and Cashman, 2015), yields a C 0 conversion result only, as can be clearly seen from the broken reflection lines in the bottom left image in Fig. 7.The maximum normal deviation between the two octants along their shared edge is approximately 2.65 degrees; thus the composite Clough-Tocher surface does not meet the 0.1 degree tolerance of standard CAD systems.Kosinka and Cashman (2015).Note the jumps in reflections lines, indicating that the adjustment ruined some of the internal C 1 continuity.Bottom row, left to right: Full-strip, saw-tooth and secondary split; fully G 1 variants of our conversion method.Fig. 9. Reflection lines on two trimmed NURBS patches (part of a car model) converted to a triangular spline using the standard Clough-Tocher method.Top row, left to right: A smooth rendering of the trimmed NURBS patches, Clough-Tocher patches with the boundary adjustment of Kosinka and Cashman (2015), Clough-Tocher patches with boundary adjustment of Kosinka and Cashman (2015) and triangulation showing the difference in normal vector; blue indicates no deviation in normal vector and red indicates high deviation.Note the jumps in reflections lines, indicating that the adjustment ruined internal C 1 continuity.Bottom row, left to right: Full-strip, saw-tooth and secondary split; fully G 1 variants of our conversion method.
In order to obtain a globally G 1 result, the conversion variants presented in Section 5 are used to modify the Clough-Tocher (micro/macro-)triangles near the shared B-rep edge.The expected G 1 continuity of the spline is verified by the C 0 continuity of the reflection lines across the shared edge of the two octants, shown in the bottom row of Fig. 7.

Boundary adjustment
Now, we investigate the effects of the boundary normal adjustment as described in Section 4. First of all, we describe the ways in which our boundary normal adjustment lets us preserve internal G 1 continuity within a single B-rep patch.A single patch of a car model is shown in Fig. 8.We compare our G 1 techniques to the C 0 strategy of Kosinka and Cashman (2015).
C 0 continuity is guaranteed by adjusting the control points of the macro-patch boundary edges to make them coincide with those of the B-rep edge itself.As discussed above, our techniques proceed differently, namely by applying the boundary normal adjustment and ensuring that the tangent plane of the triangular spline contains the tangent of the B-rep edge.In this way, C 0 continuity can be achieved without changing the tangent plane at the B-rep edge vertices, and it also creates the possibility of satisfying G 1 continuity conditions, in our case through the use of Shirman-Séquin macro-elements.

Table 1
The approximation error between a (densely triangulated) CAD model and its approximation with triangular splines, using different methods at B-rep edges.All models have been scaled to unit bounding-box diameter.

Torus
Sphere In Fig. 8, we can see a single trimmed NURBS patch converted into a C 1 Clough-Tocher spline using the variant of the algorithm that uses extra sampled mid-edge gradients (Kosinka and Cashman, 2015, Section 3.6).We apply the C 0 adjustment of Kosinka and Cashman (2015) and our three different techniques using Shirman-Séquin macro-and microelements with the boundary normal adjustment.Having used the boundary adjustment in this case allows us to guarantee a common tangent plane for the B-rep edge and the macro-elements which lie on the boundary.In this case, our method and its variants show large improvements with respect to continuity and visual quality as the rather large triangles connected to the boundary now connect smoothly to the internal triangles, in contrast to the pure Clough-Tocher method.
Our methods are also able to achieve smooth results for two patches trimmed along a shared edge.In Fig. 9 we show one such situation, where along the whole B-rep edge the tangent plane of the sampled surface does not agree with the tangents of the common B-rep edge.This leads to G 1 discontinuities (that is, the tangent plane does not vary continuously) across the edge when applying the C 0 control point adjustment of Kosinka and Cashman (2015).By applying the normal adjustment along the common edge, a common tangent plane can be determined for both spline surfaces on each side of the edge.Then the Shirman-Séquin macro-and micro-elements can ensure G 1 continuity.
To emphasise the necessity of the normal adjustment step we visualise the differences in angles between the normal vectors along the common edge of adjacent triangles in the resulting spline surfaces in Fig. 10.As can be seen, the normal adjustment step already improves the normal error in some situations without resorting to the G 1 methods.For the G 1 method we can see that without the boundary adjustment there are still some defects present around B-rep edges.Applying All the shown B-rep edges are marked as smooth and the boundary normal adjustment technique has been used to guarantee that they all meet with tangent-plane continuity at shared vertices.Without this adjustment, it is in general impossible to guarantee G 1 continuity, but C 0 continuity across B-rep edges and G 1 continuity internally can still be satisfied, as already described above.
As can be seen in Fig. 11, the techniques show varying levels of preservation of the original C 1 Clough-Tocher spline.The secondary-split saw-tooth technique again shows rapidly varying reflection lines around the central vertex.It is thus doubtful whether the resulting surface actually improves, at least visually, on a C 0 equivalent which achieves only approximate G 1 continuity.The other two techniques, full-strip and saw-tooth, produce better results in this case; observe the C 0 reflection lines running across the B-rep edges.
Finally, Fig. 6 shows the result of applying our conversion process to a full CAD model, in this case that of a car composed of 42 B-rep patches.Note that for the generation of the images in this figure the saw-tooth variation was used.

Approximation error
We have also looked at the approximation error of the three methods.We are interested in the maximum error between a densely triangulated representation of an input CAD model and its approximation using the original Clough-Tocher approximation (denoted CT o in Kosinka and Cashman (2015)), and the full-strip, saw-tooth and secondary-split techniques.The results are listed in Table 1.The base triangulation of the sphere octant and the torus model contain only 64 triangles each.We also include a complex model of a Formula 1 front wing (last column).Its genus is 18; it contains as many as 14 small bolt holes obtained by trimming (see the inset), and several fillet patches.
It is apparent that the approximation error remains approximately the same even when using the new G 1 methods.In some cases we even observe a lower approximation error than with the method of Kosinka and Cashman (2015).This could be due to the increased continuity internally.At B-rep edge vertices, the tangent planes of the Shirman-Séquin macroelements are co-planar with the actual sampled gradients from the underlying NURBS patches, and this might make the G 1 approximation at these vertices closer to the input CAD model than the C 0 construction of Kosinka and Cashman (2015).As the C 0 construction makes only control points of adjacent patches coincide, this step in general changes the normal vector(s).
When increasing the number of sample points, i.e., we increase the density of the triangulation, we observe a decrease in approximation error.Table 2 shows the approximation errors obtained using two different triangulations of the same B-rep model.We observe a decrease of the approximation error when using each of the three new constructions, and the error remains approximately the same as when using the ordinary Clough-Tocher method.

Performance
The addition of Shirman-Séquin macro-elements on and around the boundaries of the trimmed patches might increase the computation time of the spline conversion process; the introduced macro elements are composed of quartic Bézier triangles as opposed to the original cubic setting with the Clough-Tocher elements.We have already explored the trade-off between continuity and visual quality by introducing the three different strategies at the boundaries.The different strategies also affect the efficiency of the methods.The full-strip strategy and the secondary-split strategy are fully local, meaning that the constructions can be computed fully in parallel and are therefore very efficient.
For the saw-tooth strip strategy, the Shirman-Séquin elements cannot be constructed concurrently with the Clough-Tocher elements as their construction depends on their neighbouring macro-elements.In principle it should be possible to construct them fully locally by supplying parametric data of adjacent triangles.Then it is possible to construct the adjacent cross-boundary tangent functions independently to ensure G 1 continuity.
We have measured the performance of the construction of the spline surfaces for all the considered techniques.The performance measurements were done on the car mesh (as shown in Fig. 6) consisting of 42 B-rep patches.The B-rep patches have been further triangulated into a total of 3233 triangles which provide the topology of the triangular spline surfaces.On average the construction of the ordinary Clough-Tocher spline surface took 0.09235 seconds, whereas 0.121, 0.108, and 0.123 seconds were the averages recorded for the full-strip, saw-tooth, and secondary split techniques, respectively.Although the new G 1 methods may seem complex in their constructions, they do not have any significant overhead with respect to only using Clough-Tocher macro-elements.

Discussion
To fully benefit from the presented techniques, the CAD models need to satisfy certain smoothness conditions, or they need to be slightly adjusted.We say 'slightly' here as it is expected that when an edge is marked as (or deemed) smooth, the normal vectors on either side of it are expected to be different only up to a tolerance offered by the CAD system of choice.Thus, the B-rep edge and its vicinity already satisfy approximate G 1 conditions.
If multiple B-rep edges cross or terminate at a vertex, then the tangents of these edges have to lie in a common tangent plane.Even with least squares approximation of the normal, it is generally impossible to guarantee G 1 continuity without having to adjust the boundary curves to agree with the new normal.
In some of our results, it may seem that there is very little improvement over the C 0 method of Kosinka and Cashman (2015).And visually and error-wise, this is certainly true.However, our method ensures exact G 1 continuity of the resulting triangular splines, even for CAD models of arbitrary manifold topology (encoded in their B-reps).This means that our results are suitable for direct use in isogeometric analysis.The fact that we do not directly provide C 1 results, but 'only' G 1 results, is not an obstacle (Groisser and Peters, 2015).
We have also investigated the triangular Gregory patch (Longhi, 1985) as an alternative to the Shirman-Séquin macroelement.However, this element does not provide any obvious advantages apart from being a single triangular element as opposed to being composed of three micro-triangles.Gregory patches are rational, which unnecessarily complicates the calculation of derivatives and normals.Moreover, according to our experiments, they are visually nearly indistinguishable from the Shirman-Séquin macro-elements as their boundary conditions are also set using the method of Chiyokura & Kimura.
The full-strip conversion strategy causes the biggest visual changes compared to the original Clough-Tocher approximation among the three variants of our technique.Naturally, this is because it replaces more macro-elements compared to the other techniques, but it also changes more of the cross-boundary data, whereas in the case of the saw-tooth variants most of the original cross-boundary derivatives are respected.In some cases, this produces rather different surfaces, which can appear much smoother than the original Clough-Tocher approximation.In general, the full-strip macro-elements have more noticeable changes of directions in their reflection line visualisations.
The secondary split technique can show rapid changes in the highlight lines near B-rep edges, as can be seen in Fig. 7, but the changes are only confined to these micro-triangles.The micro-triangle is much smaller, compared to triangles that are changed in the other techniques, and consists out of three quartic micro-triangles.Therefore, the surface can change quite rapidly within these triangles.In this respect the normal saw-tooth technique provides the best benefits out of all three techniques.It respects the original (internal) C 1 Clough-Tocher approximation, and at the same time remains visually reasonable.
Naturally, the generated results heavily depend on the initial triangulation of the input CAD model.Yet another aspect is the choice of the split-point of the (macro-)triangles.And a further freedom is the choice of the Clough-Tocher variant used.We experimented with various combinations and the main observations made were fully in line with those in Kosinka and Cashman (2015).Thus, we do not go into this in more detail, but suffice it to say that all possible combinations still lead to globally G 1 results and the exact settings and initial triangulation can be selected to best fit the application at hand.

Conclusion
We have presented several methods to improve existing conversion techniques for converting trimmed CAD models into triangular spline surfaces.While existing methods offer only C 0 continuity across generic B-rep edges, our solution converts a whole CAD model into a G 1 -continuous triangular spline.The results are analysis-suitable and CAD-compatible approximations.
All our techniques require an intermediate step of boundary normal adjustment in which a new normal vector is found and the data near B-rep edges is made G 1 -compatible.
The three variants of our method rely on the Shirman-Séquin macro-elements.These are utilised either on a full strip of 1-and 2-connected boundary triangles (full-strip), on 2-connected triangles (saw-tooth), or only on 2-connected microtriangles (secondary split).The three techniques have varying levels of preservation of the original Clough-Tocher conversion.The full-strip variant is the most invasive, followed by the replacement of 2-connected macro-and micro-triangles.
The presented techniques are efficient as they only need to be applied around B-rep edges and are not much more intensive to compute than the ordinary Clough-Tocher techniques.

Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Fig. 1 .
Fig. 1.The control net of a cubic triangular Bézier patch P with control point labels.A section of the control net of an adjacent C 0 -connected patch P is also shown; control points P 003 , P 012 , P 021 , and P 030 are shared.

Fig. 2 .
Fig. 2. The local G 1 method of Chiyokura & Kimura, connecting two Bézier triangles.The arrows show the vectors involved in the computation.The points marked by diamonds are 'quartic' control vertices obtained by degree elevation.

Fig. 4 .
Fig. 4. Left: Two NURBS B-rep patches, N 1 and N 2 , intersecting along a curve.The true intersection curve (dotted) cannot, in general, be represented as

Fig. 5 .
Fig. 5.A schematic view of the 1-connected (light and dark blue) and 2-connected (light and dark red) macro-triangles.The control points of the cubic Bézier curves forming the approximated B-rep edge are also shown.

Fig. 6 .
Fig. 6.The full conversion process and results.From left to right: Input triangulation of B-rep model, the control net after conversion to a composite Clough-Tocher and Shirman-Séquin triangular spline using the saw-tooth technique, smooth shading and reflection lines on the result, and a visualisation of the error with respect to the original B-rep model (blue is zero error and red is global error maximum of 0.00018168 relative to the unit bounding box diagonal.).The colour of the control nets signifies the method used to calculate the control data.Purple corresponds to the Clough-Tocher method, blue to the method of Chiyokura & Kimura, and red to the alternative G 1 method presented in Section 5.1.

Fig. 7 .
Fig. 7.A comparison on a simple model composed of two sphere octants having separate parametrisations.Both octants have been uniformly sampled using 16 triangles.In the top row we show Phong shading and Bézier control nets, and in the bottom row we show the reflection lines on the octants after conversion.The colour of the control nets signifies the method used to calculate the control data.Purple corresponds to the Clough-Tocher method, blue to the method of Chiyokura & Kimura, and red to the alternative G 1 method presented in Section 5.1.

Fig. 8 .
Fig. 8. Reflection lines on a trimmed NURBS patch (part of a car model) converted to a triangular spline using the Clough-Tocher variant with additional gradients sampled at edge midpoints.Top row, left to right: The input triangulation of the trimmed NURBS patch, Clough-Tocher patches, Clough-Tocher patches with the boundary adjustment ofKosinka and Cashman (2015).Note the jumps in reflections lines, indicating that the adjustment ruined some of the internal C 1 continuity.Bottom row, left to right: Full-strip, saw-tooth and secondary split; fully G 1 variants of our conversion method.

Fig. 10 .
Fig. 10.Visualisation of the difference between normal vectors of neighbouring triangles of the spline surfaces along their shared edges.From left to right, top to bottom: Clough-Tocher with control point adjustment, Clough-Tocher with control point adjustment and normal adjustment, saw-tooth Shirman-Séquin and saw-tooth Shirman-Séquin with normal adjustment.The original Clough-Tocher construction was used in these examples.

Fig. 11 .
Fig. 11.A challenging example: Reflection lines over a meeting point of several trimmed NURBS patches which have been converted to triangular splines using the Clough-Tocher variant with additional gradients sampled at edge midpoints.Top row, left to right: The smooth rendering of the trimmed NURBS patches, Clough-Tocher patches with the boundary adjustment of Kosinka and Cashman (2015) and triangulation showing the difference in normal vector.Bottom row, left to right: The full-strip, saw-tooth, and secondary-split variants of our method.

Table 2
The approximation error between a (densely triangulated) CAD model and its two spline approximations differing in triangle counts, using different methods at B-rep edges.All models have been scaled to unit bounding-box diameter.