1 Introduction

There exists a wide range of fields in which problems involving the fitting of datasets including regions with missing or poor-quality information -or the more general of image reconstruction- arise. Among these fields we can mention, for example, engineering problems (Hu et al. 2012; Wang and Hu 2013), 3D scanning with applications to archaeology, CAGD, Earth Sciences or image reconstruction (Li and Li 2010; Ju 2009; Wang and Hung 2012), physics (Yang et al. 2017; Dong and Cao 2015), computer vision in robotics (Carr et al. 2001; Caselles et al. 2008), etc.

A particular case of the above-referred research field is the one of filling the hole of a given surface, i.e., of determining a patch reconstructing a piece of a surface that for some reason is unknown or not properly defined. Several works regarding this specific topic define the filling patch to join the surface to be filled with some smoothness conditions and minimizing some quantity related to the geometrical shape or to a physical feature of the patch to, somehow, obtain a simple and fair filling [see e.g. (Caselles et al. 2008; Fortes et al. 2011; Zhong et al. 2021] and references therein). Nevertheless, these approaches based on the minimization of some quantity often lead to ‘flat’ patches, unable to retrieve complex shapes or even be faithful to the shape of the original surface to be filled. A simple example is the one of filling the hole on the top of a semisphere or a cone: depending on which the role of the filling patch is meant to be, we may want it to be somehow minimal, or we may want it to be faithful to the holed surface, or even more generally, to adapt to some specific prescribed shape or geometrical feature. Some papers in the literature develop techniques to overcome the problem of the flatness of the filling patches that some methods provide, like biharmonic optimization (Smurygin and Zhurbin 2015); transfinite interpolation (Dyken and Floater 2009); algorithms to handle weakly defined control points by means of B-spline surfaces (Weiss et al. 2002); or functionals involving some geometric features required for the filling patch, like Fortes et al. (2015) or Fortes and Medina (2022), where the patch is forced to somehow ‘inherit’ the shape of the surface to be filled, or Fortes et al. (2017), where a volume condition over the filling patch is imposed. Most of the additional geometrical constraints imposed with the aim that the filling patches be faithful to a prescribed shape or pattern are linear, in the sense that the associated problems lead to determinate linear systems. Nevertheless, filling patches fulfilling non-linear constraints are also useful in several researching fields like image processing, where curvature constraints are used to develop some models [see e.g. (Ambrosio and Masnou 2003; Goldluecke and Cremers 2011; Schoenemann et al. 2009) and references therein], or biological problems, where area constraints are considered in the frame of biological cell membranes [see e.g. (Colli and Laurençot 2012) and references therein].

In this paper, we consider the problem of defining fair filling patches under the two specific non-linear constraints pointed out above: having a prescribed area and having prescribed values of the mean curvature at some points. In both cases, we consider the filling patches to be quadratic Powell-Sabin splines, which allows us not only to join both the patch and the original holed surface with \(\mathcal {C}^1\)-smoothness, but also to simplify the expressions of the area and of the mean curvature of the filling patches insofar as both geometrical features can be expressed in terms of the coefficients of the expansion of the quadratic Powell-Sabin splines in the basis of the corresponding vectorial space. Another reason to consider quadratic splines is related to the fact that increasing the degree or the smoothness of the fitting splines implies handling much larger linear systems that are worse conditioned, adding further to the difficulty of solving them numerically. Besides, in the case of the area constraint, we consider Bézier techniques that will allow us to approximate the quadratic Powell-Sabin splines by means of triangular patches, leading to simpler expressions of the area. Moreover, we develop an ad-hoc algorithm to determine an optimum value of the area that the filling patch is expected to have when there is no prescribed value of the area. The joint implementation of both, Bézier approximation and determination of the optimum area, allows us to translate the filling problem with area constraint into a system of linear and quadratic equations, that have been already highly explored in the literature. Therefore, not only do we fill under an arbitrary area constraint, but we also lean on results in quadratic equations to obtain area-constrained ‘optimum’ filling patches.

It is worth to mention that the systems of equations associated to the constraints considered in this paper are non-linear, infinite filling patches fulfilling such constraints can be found, but of course not all of them are fair enough. To get proper filling patches we will look for the ones minimizing a relative error balancing the bending energy of the filling patch -in order to get surfaces with no roughness or irregularities- and the non-linear constraint considered.

The outline of the paper is as follows: In Sect. 2 we give a brief description of all the preliminaries and basic concepts that will be used throughout the work and we describe the general frame of the problem to be considered. In Sect. 3 we introduce the main tools used to handle the non-linear systems arisen. In Sects. 4 and 5 we consider the non-linear area and mean curvature constraints, respectively. In both cases, we give numerical and graphical results and we include an analysis of the numerical methods leading to the best results. In Sect. 4 we also include the method to determine an optimum value of the area of the filling patch when there is no particular value to impose. Finally, we end by presenting some concluding remarks.

2 Preliminaries

2.1 The Powell-Sabin triangulation

Let \(D\subset \mathbb {R}^2\) be a polygonal domain (an open, non-empty, connected set) in such a way that \(\overline{D}\) admits a \(\Delta ^1\)-type triangulation (see Fig. 1 left), defined as the ones induced by integer translates of \(x=0, y=0\) and \(x+y=0\) [see e.g. (Davydov et al. 1998)]. Given a \(\Delta ^1\)-triangulation \(\mathcal {T}\) of \(\overline{D},\) we will consider the associated Powell-Sabin triangulation \(\mathcal {T}_6\) of \(\mathcal {T}\) [see e.g. (Laghchim-Lahlou and Sablonnière 1996)], which is obtained by joining an appropriate interior point \(\Omega _T\) of each \(T\in \mathcal {T}\) to the vertices of T and to the interior points \(\Omega _{T'}\) of the neighbouring triangles \(T'\in \mathcal {T}\) of T. When T has a side lying on the boundary of D, the point \(\Omega _T\) is joined to the mid-point of this side, to the vertices of T and to the interior points \(\Omega _{T'}\) of the neighbouring triangles \(T'\in \mathcal {T}\) of T. Hence, the six micro-triangles inside any \(T\in \mathcal {T}\) have the point \(\Omega _T\) as a common vertex. There are several ways to consider appropriates points \(\Omega _T\) (Powell and Sabin 1977), nevertheless, a good choice (Sablonnière 1987) is considering \(\Omega _T\) to be the incenter of T, for all \(T\in \mathcal {T}\) (see Fig. 1).

Fig. 1
figure 1

\(\Delta ^1\)-triangulation (left) and associated Powell-Sabin sub-triangulation (right)

It is well known (Powell and Sabin 1977) that given the values of a function f (defined on \(\overline{D}\)) and the ones of its first partial derivatives at all the knots of \(\mathcal {T}\), there exists a unique S in the spline space

$$\begin{aligned} \mathcal {S}_2^1(D,\mathcal {T}_6)=\left\{ S\in \mathcal {C}^1(D): S\vert _{T'}\in \mathbb {P}_{2}(T')\quad \forall \; T'\in \mathcal {T}_6\right\} , \end{aligned}$$

where \(\mathbb {P}_2\) stands for the space of bivariate polynomials of total degree at most two, such that the values of S and the ones of its first partial derivatives coincide with those of f at all the knots of \({\mathcal {T}}\).

2.2 The hole-filling problem

To later present the techniques developed to fill holes by means of non-linear constraints, we first introduce the general notation that will be considered throughout the paper.

Let H (the hole) be a connected and nonempty subset of D (see Fig. 2, left) such that \(\partial D\cap \partial H=\varnothing ,\) where \(\partial X\) stands for the boundary of the set X. If H was not connected, the techniques developed to fill one connected hole would be applied to each of the connected components of H. Let \(\mathcal {T}\) be a \(\Delta ^1\)-type triangulation of \(\overline{D}\), with associated Powell-Sabin triangulation \(\mathcal {T}_6\), and consider

$$\begin{aligned} H^*=\bigcup _{T\in \{T\in \mathcal {T}: T\cap H\ne \varnothing \}}T. \end{aligned}$$

\(H^*\) is a polygonal domain surrounding H (see Fig. 2, middle). The reason to extend the original hole H to the polygonal one \(H^*\) is because the filling patches to be considered are splines defined over triangulations. Of course, \(H^*\) tends to H as the triangulation \(\mathcal {T}\) becomes finer, which, furthermore, must be fine enough to have \(\partial D\cap \partial H^*=\varnothing .\) Let us consider the \(\Delta ^1\)-type triangulation \(\mathcal {T}_{D-H^*}=\{T\in \mathcal {T}:T\subset D-H^*\}\) of \(\overline{D}-{\mathop {H^*}\limits ^{\circ }}\), with associated Powell-Sabin sub-triangulation \((\mathcal {T}_{D-H^*})_6=\{T\in \mathcal {T}_6:T\subset D-H^*\}\), and, analogously, let us consider the \(\Delta ^1\)-type triangulation \(\mathcal {T}_{H^*}=\{T\in \mathcal {T}:T\subset H^*\}\) of \(H^*\) with associated Powell-Sabin subtriangulation \((\mathcal {T}_{H^*})_6=\{T\in \mathcal {T}_6:T\subset H^*\}.\) Let

$$\begin{aligned}{} & {} \mathcal {S}_2^1\left( D-H^*\right) \equiv \mathcal {S}_2^1\left( D-H^*,(\mathcal {T}_{D-H^*})_6\right) =\left\{ v\vert _{D-H^*}:v\in \mathcal {S}_2^1(D,\mathcal {T}_6)\right\} \quad \text{ and }\\{} & {} \mathcal {S}_2^1\left( H^*\right) \equiv \mathcal {S}_2^1\left( H^*,(\mathcal {T}_{H^*})_6\right) =\left\{ v\vert _{H^*}:v\in \mathcal {S}_2^1(D,\mathcal {T}_6)\right\} \end{aligned}$$

be the spaces of the Powell-Sabin splines of \(\overline{D}-{\mathop {H^*}\limits ^{\circ }}\) and \(H^*\) associated to the triangulations \(\mathcal {T}_{D-H^*}\) and \(\mathcal {T}_{H^*}\), respectively.

The problem we are going to consider in this work is:

Problem

Let \(f:D-H\longrightarrow \mathbb {R}\) be a function. We want to fill the hole in the graphic of f over \(H^*\) by means of a \(\mathcal {C}^1\)-function

$$\begin{aligned} \begin{array}{rcl} \widetilde{f}:D&{}\longrightarrow &{} \mathbb {R}\\ x&{}\mapsto &{}\left\{ \begin{array}{ccl} s_f&{} \text{ if } &{}x\in D-H^*\\ \sigma _{s_f}&{} \text{ if } &{}x\in H^*\end{array}\right. \end{array} \end{aligned}$$
(1)

in such a way that:

  1. i)

    \(\widetilde{f}=s_f\) be as close as possible to f over \(D-H^*\);

  2. ii)

    \(\widetilde{f}=\sigma _{s_f}\) fills the hole of f over \(H^*\) with some desired geometric non-linear properties.

Function \(s_f\) over \(D-H^*\) is the only one [see (Barrera et al. 2008a), Proposition 1] minimizing the ‘energy functional’ defined on \(\mathcal {S}_2^1(D,\mathcal {T}_6)\) by

$$\begin{aligned} \mathcal {J}_1(v) = < \rho (v-f)>_{q}^2 + \tau _1|v|_{1,D-H^*}^2+\tau _2|v|_{2,D-H^*}^2, \end{aligned}$$
(2)

where \(|v|_{m,D-H^*}=\left( \sum _{|\beta |=m}\int _{D-H^*}\partial ^{\beta }u(x)^{2}dx\right) ^{1/2}\); \(\rho \) is the evaluation operator \(\rho (v)=(v(p_1),\dots ,v(p_q)); \mathcal {P}=\{p_1,\dots ,p_q\}\) is a subset of points in \(D- H^*;\) \(\tau _1\ge 0\) and \(\tau _2>0.\) The first term of \(\mathcal {J}_1\) measures how well v approximates the dataset \(\{f(p_i)\}_{i=1}^{q}\) (in the least squares sense), while the second and the third ones represent the ‘minimal energy condition’. In Barrera et al. (2008a) it is shown that \(s_f\) can be expressed as \( s_f=\sum _{i=1}^{\ell }\beta _i\gamma _i,\) where \(\{\gamma _1,\dots ,\gamma _{\ell }\}\) is a basis of \(\mathcal {S}_2^1(D-H^*),\) and \(\varvec{\beta }=(\beta _i)_{i=1}^{\ell }\) is the unique solution of the linear system \(A{\textbf {X}}=b,\) where

$$\begin{aligned} A=\left( <\rho (\gamma _i),\rho (\gamma _j)>_q+\sum _{m=1}^2\tau _m(\gamma _i,\gamma _j)_{m}\right) _{i,j=1}^{\ell } \end{aligned}$$

and \( b=\left( <\rho (f),\rho (\gamma _i)>_q\right) _{i=1}^{\ell }.\)

On the other hand, the filling patch \(\sigma _{s_f}\) over \(H^*\) will be defined to fulfill three conditions: First, it must join \(s_f\) with class \(\mathcal {C}^1\). To this end, \(\sigma _{s_f}\) must belong to the set \(\mathcal {S}_2^1(H^*_{s_f})=\{v\in \mathcal {S}_2^1(H^*):\varphi (v)=\varphi (s_f)\}\), where \(\varphi (v)=(\varphi _i(v))_{i=1}^{3s},\) with

$$\begin{aligned} \varphi _i(v)=v(t_i),\quad \varphi _{s+i}(v)=\displaystyle {\frac{\partial v}{\partial x}}(t_i),\quad \varphi _{2s+i}(v)=\displaystyle {\frac{\partial v}{\partial y}}(t_i),\quad \text{ for } i=1,\dots ,s, \end{aligned}$$

and \(\{t_1,\dots ,t_s\}\) are the knots of \(\mathcal {T}\) laying on the boundary of \(H^*\) (see Fig. 2, right).

Fig. 2
figure 2

Hole H, surrounding polygonal hole \(H^*\) and boundary knots of \(H^*\)

Secondly, \(\sigma _{s_f}\) is required to minimize the functional \(\mathcal {J}_2:\mathcal {S}_2^1(H^*_{s_f})\rightarrow \mathbb {R}\) defined by

$$\begin{aligned} \mathcal {J}_{2}(v)=\lambda _0 |v|_{1,H^*}^2+|v|_{2,{H^*}}^2, \end{aligned}$$
(3)

where \(|v|_{m,H^*}=\left( \sum _{|\beta |=m}\int _{H^*}\partial ^{\beta }u(x)^{2}dx\right) ^{1/2}\) and \(\lambda _0\ge 0\), i.e., we want to control the bending energy of \(\sigma _{s_f}\) in such a way that its graphics does not have roughness or irregularities. In Theorem 1 of (Fortes et al. 2011) it is shown that there exists a unique \(\sigma _{s_f}\in \mathcal {S}_2^1(H^*_{s_f})\) minimizing \(\mathcal {J}_2\) which has the expression

$$\begin{aligned} \sigma _{s_f}=\sum _{i=1}^{3s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\alpha _{j} w_j, \end{aligned}$$
(4)

where \(\mathcal {B}_{\partial H^*}=\{w_i^0\}_{i=1}^{3s}\) are the functions of the usual Hermite basis of \(\mathcal {S}_2^1(H^*)\) associated to the boundary knots \(\{t_i\}_{i=1}^s\), i.e., the ones verifying

$$\begin{aligned} \varphi (w_i^0)=(0,\dots ,0,\overset{i^{th})}{1},0,\dots ,0)\quad \text{ for } i\in \{1,\dots ,3s\}; \end{aligned}$$

\(\{w_1^0,\dots ,w_{3s}^0,w_{1},\dots ,w_{n}\}\) is the extension of \(\mathcal {B}_{\partial H^*}\) to the usual Hermite basis of \(\mathcal {S}_2^1(H^*)\) and the vector \(\varvec{\alpha }=(\alpha _j)_{j=1}^{n}\) is the solution of the system of linear equations

$$\begin{aligned} \displaystyle \left\{ \begin{array}{c} f_1(\varvec{\alpha })=\displaystyle \sum _{j=1}^nb^{(1)}_j\alpha _j=d_1\\ \vdots \\ f_n(\varvec{\alpha })=\displaystyle \sum _{j=1}^nb^{(n)}_j\alpha _j=d_n \end{array}\right. , \end{aligned}$$
(5)

where

$$\begin{aligned} \left\{ \begin{array}{l} b_j^{(t)}=\lambda _0(w_j,w_t)_{1,{H^*}}+(w_j,w_t)_{2,{H^*}},\\ d_t=-\displaystyle \sum _{i=1}^{3s}\varphi _i(s_f)\left( \lambda _0(w_i^0,w_t)_{1,{H^*}}+(w_i^0,w_t)_{2,{H^*}}\right) ,\end{array}\right. \end{aligned}$$

for \(t=1,\dots ,n.\) For the sake of simplicity, we will also consider the matrix form of (5):

$$\begin{aligned} M_n\varvec{\alpha }=\textbf{b}_n, \end{aligned}$$
(6)

where

$$\begin{aligned} M_n=\left( b_j^{(i)}\right) _{i,j=1}^n\quad \text{ and } \quad \textbf{b}_n=(d_1,\dots ,d_n)^T, \end{aligned}$$

and \(^T\) denotes the transposition operation.

Finally, we will impose \(\sigma _{s_f}\) to fulfill N additional geometrical constraints, which will lead to the N additional non-linear equations

$$\begin{aligned} f_{n+i}(\varvec{\alpha })=d_{n+i},\qquad i=1,\dots ,N. \end{aligned}$$
(7)

To obtain the filling patch \(\sigma _{s_f},\) we will handle simultaneously the equation systems (6)–(7). In Sects. 4 and 5 we consider particular cases for \(f_{n+i}\).

3 Solving non-linear equations systems with optimization techniques

The solution of a system of non-linear equations has close connections with non-linear optimization problems. In fact, it is well known that the solution of

$$g_i(x)=0,\, i=1,\ldots ,m$$

is the global minimum of \(\Vert g(x)\Vert \), with \(g(x)=(g_1(x),\ldots ,g_m(x))\).

With this motivation, to carry out the experiments reported in Sects. 4 and 5, we have considered different reformulations of the original non-linear system of equations as an optimization problem. In all cases, \(g_i(\varvec{\alpha })=f_i(\varvec{\alpha })-d_i\) for all \(i=1,\dots ,n+N,\) and \(\mu \in (0,1)\).

  • Reformulation \(\mathcal {O}_1\):

    The most natural way of addressing the non-linear systems of equations is by solving it directly:

    $$\begin{aligned} \left( \mu g_1(\varvec{\alpha }),\dots ,\mu g_n(\varvec{\alpha }),(1-\mu )g_{n+1}(\varvec{\alpha }),\dots ,(1-\mu )g_{n+N}(\varvec{\alpha })\right) =\textbf{0}. \end{aligned}$$
    (8)

    Variants can consider the absolute value of components,

    $$\begin{aligned} \left( \mu |g_1(\varvec{\alpha })|,\,\dots ,\mu |g_n(\varvec{\alpha })|,\,(1-\mu )|g_{n+1}(\varvec{\alpha })|,\dots ,(1-\mu )|g_{n+N}(\varvec{\alpha })|\right) =\textbf{0}, \end{aligned}$$
    (9)

    or penalize componentwise errors,

    $$\begin{aligned} \left( \mu g_1^2(\varvec{\alpha }),\dots ,\mu g_n^2(\varvec{\alpha }),(1-\mu )g_{n+1}^2(\varvec{\alpha }),\dots ,(1-\mu )g_{n+N}^2(\varvec{\alpha })\right) =\textbf{0}. \end{aligned}$$
    (10)

    The parameter \(\mu \) allows to allocate different weights to the linear and to the nonlinear constraints. For solving these systems of non-linear equations, we considered the functions lsqnonlin and fsolve, from the Optimization toolbox of  Matlab Matlab (2022), and knitro_nlneqs and knitro_nlnlsq, from  Knitro Knitro (2022).

  • Reformulation \(\mathcal {O}_2\):

    Inspired by the above-mentioned relation between the solution of systems of equations and optimization problems, the different equations can be scalarized into a single function that needs to be minimized:

    $$\begin{aligned} \mu \sum _{i=1}^n|g_i(\varvec{\alpha })|+(1-\mu )\sum _{j=1}^N|g_{n+j}(\varvec{\alpha })|. \end{aligned}$$

    Penalizing deviations by squaring them also removes the non smoothness associated with the previous function, promoting the success of derivative-based solvers in addressing the problem:

    $$\begin{aligned} \mu \sum _{i=1}^ng_i^2(\varvec{\alpha })+(1-\mu )\sum _{j=1}^Ng_{n+j}^2(\varvec{\alpha }). \end{aligned}$$

    In this case, function knitro_nlp from  Knitro Knitro (2022), GlobalSearch from the Global Optimization toolbox of  Matlab Matlab (2022), and the solvers SID-PSM Custódio and Vicente (2007); Custódio et al. (2010) and GLODS Custódio and Madeira (2015) were considered. The last two are derivative-free optimization solvers, thus more likely to succeed in the formulation using the absolute value. Additionally, GLODS and GlobalSearch are global optimization solvers, allowing a more thorough exploration of the variable space.

  • Reformulation \(\mathcal {O}_3\):

    The solution of the system of nonlinear equations can also be regarded as a multiobjective optimization problem:

    $$\begin{aligned} \min {\left\{ |g_i(\varvec{\alpha })|,|g_{n+j}(\varvec{\alpha })|\right\} _{i=1}^n\;}_{j=1}^N. \end{aligned}$$

    However, considering that n and N can be large, the linear and the nonlinear constraints were independently aggregated, thus generating the biobjective problem:

    $$\begin{aligned} \min \left( \sum _{i=1}^n |g_i(\varvec{\alpha })|,\sum _{j=1}^N |g_{N+j}(\varvec{\alpha })|\right) . \end{aligned}$$

    A simple variant penalizes the errors, by squaring each one of the components:

    $$\begin{aligned} \min \left( \sum _{i=1}^n g_i^2(\varvec{\alpha }),\sum _{j=1}^N g_{N+j}^2(\varvec{\alpha })\right) . \end{aligned}$$

    There are not too many solvers available to address biobjective optimization problems. We considered BoostDMS Brás and Custódio (2020), MultiGLODS Custódio and Madeira (2018), and paretosearch Matlab (2022), the last from the Global Optimization toolbox of Matlab. In general, rather than a single point, the solution of a multiobjective optimization problem is a set of points, which constitutes the Pareto front of the problem. If the solution of the non-linear system of equations is unique, then the Pareto front will be a singleton. Usually, that will not happen and a solution needs to be selected from the final approximation to the Pareto front. The parameter \(\mu \) can be used for scalarization of the Pareto points, as in reformulation \(\mathcal {O}_2\), allowing the selection of a single solution.

  • Reformulation \(\mathcal {O}_4\):

    Finally, a Chebyshev formulation can be considered by minimizing the worst component of the system of non-linear equations:

    $$\begin{aligned} \min {\max \left\{ \mu \left| g_i(\varvec{\alpha })\right| ,(1-\mu )\left| g_{n+j}(\varvec{\alpha })\right| \right\} _{i=1}^n\;}_{j=1}^N. \end{aligned}$$

    As usual, deviations can be penalized:

    $$\begin{aligned} \min \max {\left\{ \mu g_i^2(\varvec{\alpha }),(1-\mu )g_{n+j}^2(\varvec{\alpha })\right\} _{i=1}^n\;}_{j=1}^N. \end{aligned}$$

    In this case, solvers SID-PSM Custódio and Vicente (2007); Custódio et al. (2010), GLODS Custódio and Madeira (2015), functions GlobalSearch and fminimax from  Matlab Matlab (2022), and knitro_nlp from  Knitro Knitro (2022) were attempted to solve the problem.

Observe that, with exception of the multiobjective solvers (paretosearch, BoostDMS, and MultiGLODS), with the aim of solving the non-linear system (6)–(7), all solvers were provided with an initialization vector \(\hat{\varvec{\alpha }}=(\hat{\alpha }_1,\dots ,\hat{\alpha }_n)\). To this end, let \(\{\xi _i\}_{i=1}^{\frac{n}{3}}\) be the set of knots of \(\mathcal {T}\) laying in the interior of \(H^*\) and let \(\{w_{3(i-1)+t}\}_{t=1}^3\) be the usual Hermite basis functions of \(\mathcal {S}_2^1(H^*)\) associated to the knot \(\xi _i\), for \(i=1,\dots ,\frac{n}{3}.\) Then, any \(\sigma =\sum _{i=1}^{3\,s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\alpha _{j}w_j\in \mathcal {S}_2^1(H^*_{s_f})\) verifies

$$\begin{aligned} \left\{ \begin{array}{l} \alpha _{3(i-1)+1}=\sigma (\xi _i)\\ \alpha _{3(i-1)+2}=\frac{\partial \sigma }{\partial x}(\xi _i)\\ \alpha _{3(i-1)+3}=\frac{\partial \sigma }{\partial y}(\xi _i) \end{array}\right. \qquad \text{ for } i=1,\dots ,\frac{n}{3}. \end{aligned}$$

On this basis, we have considered the initialization vector \(\hat{\varvec{\alpha }}\) to be

$$\begin{aligned} \left\{ \begin{array}{l} \hat{\alpha }_{3(i-1)+1}=\hat{h}(\xi _i)\\ \hat{\alpha }_{3(i-1)+2}=\frac{\partial \hat{h}}{\partial x}(\xi _i)\\ \hat{\alpha }_{3(i-1)+3}=\frac{\partial \hat{h}}{\partial y}(\xi _i) \end{array}\right. \qquad \text{ for } i=1,\dots ,\frac{n}{3}, \end{aligned}$$

where \(\hat{h}\) is the filling function of the test function h when considering the \(\mathcal {C}^1\)-basic filling method developed in Fortes et al. (2011), i.e., somehow we lean on the ‘basic’ \(\mathcal {C}^1\)-filling \(\hat{h}=\sum _{i=1}^{3s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\hat{\alpha }_{j}w_j\) to obtain filling patches fulfilling the additional non-linear constraints.

4 Filling patches satisfying an area constraint

In this section, we consider the particular case of determining minimal energy-filling patches fulfilling the additional non-linear constraint of having a prescribed area, i.e., we want the graphic of the filling \(\sigma _{s_f}\) defined in (1) to have a given area \(\mathcal {A}\) over \(H^*\). The expression of the area \(Area(\sigma )\) of the graphic of a function \(\sigma \in \mathcal {S}_2^1(H^*_{s_f})\) is not easy to handle as it implies to consider a great number of integrals of square roots of quadratic functions over triangles. Hence, we will consider the unique non-linear \(f_{n+1}\) in (7) to be a suitable approximation of \(Area(\sigma )\) and \(d_{n+1}\) to be the prescribed area \(\mathcal {A}\). The values \(\{f_i(\varvec{\alpha })-d_i\}_{i=1}^n\) in (5) and \(d_{n+1}\) in (7) are strongly dependent insofar as high prescribed area values \(\mathcal {A}\) will of course increase the bending energy of \(\sigma \), moving the values \(\{f_i(\varvec{\alpha })\}_{i=1}^n\) away from being the ‘minimal’ \(\{d_i\}_{i=1}^n\). Anyway, fixed the prescribed area \(\mathcal {A}\), we are still interested in minimizing the bending energy of \(\sigma \), i.e. in minimizing \(\{f_i(\varvec{\alpha })-d_i\}_{i=1}^n\), in order to obtain a filling patch \(\sigma _{s_f}\) as smooth as possible, without roughness or irregularities. In this frame, the role of the parameter \(\mu \) appearing in the objective functions \(\mathcal {O}_i\) introduced in Sect. 3, balancing the weight given to the linear part \(\{g_i(\varvec{\alpha })\}_{i=1}^n\) and to the non-linear one \(g_{n+1}(\varvec{\alpha })\) is quite trascendental as it should lead to a proper balanced pair bending energy-area.

For the sake of clarity, we will divide this section into several subsections: the first three handle the questions of estimating suitable values of \(\mu , f_{n+1}\) and prescribed \(\mathcal {A}\), respectively. In the two final sections, we present the general setting under which the experiments have been carried out and the numerical results, respectively.

4.1 Estimation of the optimum parameter \(\mu \)

To be able to estimate ‘optimal’ values of \(\mu \), we have considered 1600 functions \( \sigma =\sum _{i=1}^{3\,s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\alpha _{j}w_j\in \mathcal {S}_2^1(H^*_{s_f})\), where each \(\alpha _j\) has been randomly chosen in the interval \([-2.5,2.5]\). For each one of these functions \(\sigma \) we have computed its bending energy \(\mathcal {J}_{2}(\sigma )\) (3) and its area, and we have considered the point \((Area(\sigma ),\mathcal {J}_{2}(\sigma )).\) To shorten this procedure, the bending energy \(\mathcal {J}_2(\sigma )\) has been computed by means of a numerical integration formula, exact for splines of order two, that evaluates in three points. In Fig. 3 we show the cloud of points obtained for the triangulation \(\mathcal {T}\) and the polygonal \(H^*\) shown in Fig. 2 right. These provide an insight of how the balance of the bending energy-area is. Next, given a prescribed value of the area \(\mathcal {A},\) we compute an estimation \(E(\mathcal {A})\) of which the bending energy associated with this area is expected to be by means of a quadratic regression function E (in red in Fig. 3). Then, the value of the parameter \(\mu \) considered to be optimum is the one verifying \(\mu \, E(\mathcal {A})=(1-\mu )\mathcal {A}\) in order that the linear part \(\{g_i(\varvec{\alpha })\}_{i=1}^n\) in (5), regarding the bending energy, and the non-linear one \(g_{n+1}(\varvec{\alpha })\), regarding the area constraint, have the same weight in the objective functions \(\mathcal {O}_i\) considered, i.e.

$$\begin{aligned} \mu ^{opt}=\frac{\mathcal {A}}{\mathcal {A}+E(\mathcal {A})}. \end{aligned}$$
Fig. 3
figure 3

Quadratic regression for the cloud of points \((Area(\sigma ),\mathcal {J}_{2}(\sigma ))\)

In Tables 1, 2, 3, 4, 5 and 6 we give the values of the optimum parameters associated with the different experiments carried out. It can be observed that the higher the value of the prescribed area is, the less the optimum value of the parameter \(\mu \) is. This is reasonable insofar as the bending energy of a function \(\sigma \in \mathcal {S}_2^1(H^*_{s_f})\) grows faster than its area and, therefore, higher values of \(\mathcal {A}\) require lower weights of the bending energy to achieve an equilibrium between them.

4.2 Approximation \(f_{n+1}\) of the area expression

To obtain a suitable approximation \(f_{n+1}\) of the area \(Area(\sigma )\) of a filling patch \(\sigma \in \mathcal {S}_2^1(H^*_{s_f})\), we will use the concept of the B\(\acute{e}\)zier control net and its elevations of a bivariate polynomial. A thorough development of the control nets and of the properties that we will use in this work can be found in Farin (1986). For completeness, we briefly describe its construction. Given a triangle T, it is well-known that the Bernstein polynomials of degree \(m\ge 1\) over T, defined as

$$\begin{aligned} B^m_{\varvec{\lambda }}(\varvec{\tau })=\frac{m!}{\lambda _1!\lambda _2!\lambda _3!}\tau _1^{\lambda _1}\tau _2^{\lambda _2}\tau _3^{\lambda _3},\quad \varvec{\tau }\in [0,1]^3,\quad \varvec{\lambda }\ge 0, \end{aligned}$$

where \(\varvec{\tau }=(\tau _1,\tau _2,\tau _3)\) are baricentric coordinates with respect to T (the multi-index notation \(\varvec{\lambda }=(\lambda _1,\lambda _2,\lambda _3)\in \mathbb {Z}^3\) is used, \(|\varvec{\lambda }|=\lambda _1+\lambda _2+\lambda _3=m,\) and \(\varvec{\lambda }\ge 0\) indicates that \(\lambda _i\ge 0\) for \(i=1,2,3\)), form a partition of the unity over T and constitute a basis for \(\mathbb {P}_m(T).\) For any \(p\in \mathbb {P}_m(T)\), the unique representation

$$\begin{aligned} p=\sum _{|\varvec{\lambda }|=m, \varvec{\lambda }\ge 0}b_{\varvec{\lambda }}B^m_{\varvec{\lambda }}, \end{aligned}$$

is called the Bernstein-B\(\acute{e}\)zier representation of p with respect toT. The coefficients \(b_{\varvec{\lambda }}\) are called the B\(\acute{e}\)zier ordinates of p. The points \(\{(\xi ^{m}_{\varvec{\lambda }},b_{\varvec{\lambda }})\}_{\begin{array}{c} |\varvec{\lambda }|=m \\ \varvec{\lambda }\ge 0 \end{array}},\) where \(\xi ^{m}_{\varvec{\lambda }}\) are the B\(\acute{e}\)zier triangle points of order m of T, defined as the ones having barycentric coordinates \(\left( \frac{\lambda _1}{m},\frac{\lambda _2}{m},\frac{\lambda _3}{m}\right) \) (see Fig. 4), are called the B\(\acute{e}\)zier control points of p,  and the linear interpolant \(\mathcal {B}\) of the Bézier control points is called the B\(\acute{e}\)zier control net of p (see Fig. 4 right). The values of the Bézier control net coincide with the ones of p at the vertices of T and, moreover, the control net is tangent to the graphic of p at these points (see Fig. 4 right).

Fig. 4
figure 4

Bézier triangle points of orders 2, 3 and 4,  and control net of \(p\in \mathbb {P}_2(T)\)

If \(p\in \mathbb {P}_2\), then \(p\in \mathbb {P}_{2+i}\) for all \(i\ge 1,\) and hence it can be written as

$$\begin{aligned} p=\sum _{|\varvec{\lambda }|=2,\varvec{\lambda }\ge 0}b_{\varvec{\lambda }}B^2_{\varvec{\lambda }}= \sum _{|\varvec{\mu }|=2+i,\varvec{\mu }\ge 0}b^{(i)}_{\varvec{\mu }}B^{2+i}_{\varvec{\mu }}, \end{aligned}$$

where

$$\begin{aligned} {b_{\varvec{\mu }}^{(i)}=\sum _{|\varvec{\lambda }|=2,\varvec{\lambda }\ge 0}\frac{\left( \begin{array}{c}\mu _1\\ \lambda _1\end{array}\right) \left( \begin{array}{c}\mu _2\\ \lambda _2\end{array}\right) \left( \begin{array}{c}\mu _3\\ \lambda _3\end{array}\right) }{\left( \begin{array}{c}2+i\\ 2\end{array}\right) }b_{\varvec{\lambda }}}. \end{aligned}$$
(11)

The \(i^{th}\)-elevation \(\mathcal {B}^{(i)}\) of the B\(\acute{e}\)zier control net of p, defined as the linear interpolant of the control points \( \{(\xi ^{(2+i)}_{\varvec{\mu }},b^{(i)}_{\varvec{\mu }})\}_{\begin{array}{c} |\varvec{\mu }|=2+i\\ |\varvec{\mu }|\ge 0 \end{array}},\) lies in the convex hull of \(\mathcal {B}^{(k)}\) for all \(k=0,\dots ,i-1\) (we adopt the convention \(\mathcal {B}^{(0)}\equiv \mathcal {B}\)), is tangent to p at the vertices of T,  and verifies \(\lim _{i\rightarrow +\infty }\mathcal {B}^{(i)}=p\).

Now, with the aim to obtain a filling patch over the polygonal hole \(H^*\) whose graphic has a prescribed area \(\mathcal {A}\), we will consider the next process. Given a generic function \( \sigma =\sum _{i=1}^{3\,s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\alpha _{j}w_j\in \mathcal {S}_2^1(H^*_{s_f}),\) let us consider the control net \(\mathcal {B}_{\sigma _T}\equiv \mathcal {B}^{(0)}_{\sigma _T}\) of each of the quadratic polynomials \(\sigma _T\equiv \sigma \vert _{T}\), for \(T\in \left( \mathcal {T}_{H^*}\right) _6\); let \(\mathcal {B}^{(i)}_{\sigma _T}\) be the \(i^{th}\)-elevation of \(\mathcal {B}_{\sigma _T}\) for \(i\ge 1;\) and let \(\mathcal {B}^{(i)}_{\sigma }\) be the \(\mathcal {C}^0\)-surface obtained by joining all the \(\mathcal {B}^{(i)}_{\sigma _T}\), for \(T\in \left( \mathcal {T}_{H^*}\right) _6\), in such a way that

$$\begin{aligned} Area(\mathcal {B}^{(i)}_{\sigma })=\sum _{T\in \left( \mathcal {T}_{H^*}\right) _6}Area\left( \mathcal {B}^{(i)}_{\sigma _T}\right) . \end{aligned}$$

Since \(\lim _{i\rightarrow +\infty }\mathcal {B}^{(i)}_{\sigma _T}=\sigma _T,\) we have

$$\begin{aligned}{} & {} Area(\sigma )=\sum _{T\in \left( \mathcal {T}_{H^*}\right) _6}Area\left( \sigma _T\right) =\sum _{T\in \left( \mathcal {T}_{H^*}\right) _6}Area\left( \lim _{i\rightarrow +\infty }\mathcal {B}^{(i)}_{\sigma _T} \right) =\\{} & {} \quad \sum _{T\in \left( \mathcal {T}_{H^*}\right) _6}\lim _{i\rightarrow +\infty }Area\left( \mathcal {B}^{(i)}_{\sigma _T} \right) = \lim _{i\rightarrow +\infty }\sum _{T\in \left( \mathcal {T}_{H^*}\right) _6}Area\left( \mathcal {B}^{(i)}_{\sigma _T} \right) = \lim _{i\rightarrow +\infty }Area(\mathcal {B}^{(i)}_{\sigma }). \end{aligned}$$

If for any elevation level k we consider a function \(\sigma ^{k}\in \mathcal {S}_2^1(H^*_{s_f})\) verifying \(Area(\mathcal {B}^{(k)}_{\sigma ^{k}})=\mathcal {A},\) then \(Area(\lim _{k\rightarrow +\infty }\sigma ^{k})=\mathcal {A}.\) Therefore, for any elevation level k, we will consider

$$\begin{aligned} f_{n+1}(\varvec{\alpha })=Area(\mathcal {B}^{(k)}_{\sigma ^{k}}), \end{aligned}$$
(12)

i.e., \(\sigma ^{k}\) will be a function whose \(k^{th}\)-elevation of its control net has area \(\mathcal {A}\).

It is worth mentioning that the Bézier ordinates of a polynomial \(p\in \mathbb {P}_2(T)\) can be obtained by means of the expressions

$$\begin{aligned} \left\{ \begin{array}{l} b_{\varvec{\lambda }}= p(\xi ^2_{\varvec{\lambda }}),\text { for } \varvec{\lambda }\in \{(2,0,0),(0,2,0),(0,0,2)\}, \\ b_{110}=\frac{1}{2}\left( 4p(\xi ^2_{110})-b_{200}-b_{020}\right) ,\\ b_{101}= \frac{1}{2}\left( 4p(\xi ^2_{101})-b_{200}-b_{002}\right) , \\ b_{011}= \frac{1}{2}\left( 4p(\xi ^2_{011})-b_{020}-b_{002}\right) .\end{array}\right. \end{aligned}$$

This fact, together with (11), allows us to obtain the expression of the vertices of any of the triangular patches of \(\mathcal {B}^{(k)}_{\sigma ^k}\) in terms of the unknowns \(\varvec{\alpha }\). As a consequence, if we express the area of each triangular patch in terms of the coordinates of their vertices, we get that \(f_{n+1}\) has an expression of the form

$$\begin{aligned} f_{n+1}(\varvec{\alpha })=\sum _{t=1}^{\ell }\sqrt{c_{00}^{(t)}+\sum _{i=1}^nc^{(t)}_{0i}\alpha _i+\sum _{i,j=1}^nc^{(t)}_{ij}\alpha _i\alpha _j}, \end{aligned}$$
(13)

where \(\ell \equiv \ell (k)\) is the number of triangular patches in \(\mathcal {B}^{(k)}_{\sigma ^k}\).

4.3 Estimation of optimum area

All non-linear systems (6)–(7) associated to the experiments presented in this section have been carried out by means of the different formulations and solvers presented in Sect. 3. We have also considered different values of the prescribed area \(\mathcal {A}\) to be set equal to \(d_{n+1}\) in (7). Nevertheless, we have found it appropriate to include a numerical procedure in order to estimate an optimum value of \(\mathcal {A}\) when there is no particular value to impose.

This numerical procedure consists of estimating the optimum value of the area that each of the triangles of the k-elevation of the control net of the filling patch \(\sigma _{s_f}\) must have by means of an extrapolation based on the values of the areas of the triangles of the k-elevation of the control net of \({s_f}\) over \(D-H^*\), i.e., we use known values of area of pieces of \(s_f\) over \(D-H^*\) to estimate values of area of pieces of \(\sigma _{s_f}\) over \(H^*\). More precisely, let us denote by \(\mathcal {N}^{(k)}_{D-H^*}\) (resp. \(\mathcal {N}^{(k)}_{H^*}\)) the subtriangulation of \((\mathcal {T}_{D-H^*})_6\) (resp. \((\mathcal {T}_{H^*})_6\)) given by the Bézier triangles points of order k of all the triangles of \((\mathcal {T}_{D-H^*})_6\) (resp. \((\mathcal {T}_{H^*})_6\)). In Fig. 5 left and middle we show the subtriangulations \(\mathcal {N}^{(2)}_{D-H^*}\) and \(\mathcal {N}^{(2)}_{H^*}\) for the triangulation \(\mathcal {T}^5\). The procedure is as follows:

  • (i) Let C be the centroid of the polygonal hole \( H^*\) (in Fig. 5 right we show \(H^*\) and its centroid for the hole defined in (17) and shown in Fig. 2).

  • (ii) For any triangle \(T\in \mathcal {N}^{(k)}_{D-H^*}\), we consider a point \(p_T=(x_T,y_T)\), where \(x_T\) is the distance from the incenter \(C_T\) of T to C and \(y_T\) is the area of \(s_f\) over T.

  • (iii) With the cloud of points given in the previous step, we estimate the value of the optimum area \(\mathcal {A}^{opt}_T\) of the filling patch \(\sigma _{s_f}\) over each \(T\in \mathcal {N}^{(k)}_{H^*}\) by evaluating the least squares regression of the cloud of points on the distance from the incenter of each of the triangles of the triangulation \(\mathcal {N}^{(k)}_{H^*}\) to C.

Fig. 5
figure 5

Subtriangulations \(\mathcal {N}^{(2)}_{D-H^*}\) and \(\mathcal {N}^{(2)}_{H^*}\) for \(\mathcal {T}^5\) and \(H^*\) with its centroid C

In Fig. 6 we show, for \(k=2\) and for both test functions \(h_1\) and \(h_2\), the cloud of points defined in ii) above (blue dots), and the points (\(\Vert C_T-C\Vert _2,\mathcal {A}^{opt}_T\)) (red dots) for each triangle \(T\in \mathcal {N}^{(2)}_{H^*}\), where \(\Vert \cdot \Vert _2\) stands for the usual Euclidean norm in \(\mathbb {R}^2\). The optimum value \(\mathcal {A}^{opt}\) of the prescribed area to consider is then the sum of the estimated areas of \(\sigma _{s_f}\) over all the triangles in \(\mathcal {N}^{(k)}_{H^*}\), i.e.

$$\begin{aligned} \mathcal {A}^{opt}=\sum _{T\in \mathcal {N}^{(k)}_{H^*}}\mathcal {A}^{opt}_T. \end{aligned}$$
(14)
Fig. 6
figure 6

Estimation of optimum areas for Franke’s (left) and semisphere (right) functions

In Tables 1 and 4 we give the values of \(\mathcal {A}^{opt}\) for each one of the experiments considered. One important advantage of considering optimum values of the area over each one of the triangles of \(\mathcal {N}^{(k)}_{H^*}\) is that Equation (13) becomes separable and quadratic, i.e., imposing \(\sigma _{s_f}\) to have a prescribed value \(\hat{d}_{t}\) of the area over each one of the triangles \(T_t\) of \(\mathcal {N}^{(k)}_{H^*}\), for \(t=1,\dots ,\ell \), instead of a global value of the area all over \(H^*\), leads to \(\ell \) independent quadratic equations

$$\begin{aligned} c_{00}^{(t)}+\sum _{i=1}^{{ n}}c^{(t)}_{0i}\alpha _i+\sum _{i,j=1}^{{ n}}c^{(t)}_{ij}\alpha _i\alpha _j=\hat{d}^{\,2}_{t},\qquad t=1,\dots ,\ell , \end{aligned}$$
(15)

which can be equivalently written as

$$\begin{aligned} c_{00}^{(t)}+ {c_0^{(t)}}\cdot \varvec{\alpha }+\varvec{\alpha }^T C^{(t)}\varvec{\alpha }=\hat{d}^{\,2}_{t}, \end{aligned}$$

where \( {c_0^{(t)}}=\left( c_{01}^{(t)},\dots , c_{0{ n}}^{(t)}\right) \); the (ij)-element of \(C^{(t)}\) is \(\frac{c_{ij}^{(t)}}{2}\) if \(i\ne j\) and \( c_{ii}^{(t)}\) if \(i=j\). Problem (6)–(15) can now be restated as finding \(\varvec{\alpha }\) that satifies

$$\begin{aligned} \left\{ \begin{array}{rcl} M_{n} \varvec{\alpha }- \textbf{b}_{n} &{}=&{} 0 \\ c_{00}^{(1)}+ {c_0^{(1)}}\cdot \varvec{\alpha }+ \varvec{\alpha }^T C^{(1)}\varvec{\alpha }-\hat{d}^{\,2}_{1} &{}=&{} 0\\ c_{00}^{(2)} + {c_0^{(2)}}\cdot \varvec{\alpha }+ \varvec{\alpha }^T C^{(2)}\varvec{\alpha }-\hat{d}^{\,2}_{2} &{}=&{} 0\\ &{}\vdots \\ c_{00}^{\ell } + {c_0^{(\ell )}}\cdot \varvec{\alpha }+ \varvec{\alpha }^T C^{(\ell )}\varvec{\alpha }-\hat{d}^{\,2}_{\ell } &{}=&{} 0. \end{array}\right. \end{aligned}$$
(16)

This new explicit reformulation has theoretical and practical implications. On one hand, it allows for a better understanding of the underlying geometry since it describes the arrangement of intersecting lines and ellipses. More importantly, it sheds light on the nonconvexity of the problem due to the presence of these equality quadratic constraints. Also, given that the problem is inherently infeasible, solving (16) has to be thought in terms of minimizing an infeasibility measure of the constraints. Having a geometrical interpretation can help choosing an appropiate merit function that measures infeasibility and the best optimization solver to use. On the other hand, a nice property of explicit quadratic constrains is that solvers have access to first- and second-order derivatives practically at no computational cost, If \(q(x) = 1/2\; x^T Q x + c^Tx - d = 0\) is a quadratic constraint, then \(\nabla _{\!x}\, q(x) = Qx+c\) and \(\nabla ^2_{\!xx}\, q(x)=Q\) are the first- and second-order derivatives respectively. Thus, dedicated quadratically-constrained solvers by design exploit the explicitly revealed structure in (16), as we will see in the experimental part.

4.4 Numerical and graphical examples settings

All examples of filling patches under area constraints presented in this section, except the last one, have been carried out over the domain \(D=(0,1)\times (0,1)\); with the hole H defined implicitly by

$$\begin{aligned} H=\left\{ (x,y)\in \mathbb {R}^2:\frac{\left( x-0.5\right) ^2}{0.225^2}+\frac{\left( y-0.5\right) ^2}{0.225^2}\le 1\right\} , \end{aligned}$$
(17)

shown in Fig. 2 left, and with the \(\Delta ^1\)-type triangulations \(\mathcal {T}^m\) of \(\overline{D}\) defined as the ones associated to uniform partitions of [0, 1] into m subintervals, for \(m=5,9\) (\(\mathcal {T}^5\) is shown in Fig. 2). The smoothing parameters in the functional (2) have been chosen to be \(\tau _1=10^{-4}\) and \(\tau _2=10^{-5}.\) These values have been checked to lead to proper fitting functions \(s_f\) over \(D-H^*\)—a deep study on how to choose these parameters values was undertaken in Barrera et al. (2008b)—, while the smoothing parameter in functional (3) has been taken to be \(\lambda _0= 10\) in order to give the same weight to the semi norms \(|\cdot |_1\) and \(|\cdot |_2\) over \(D-H^*\) and over \(H^*\) in the functionals (2) and (3), respectively. We have considered two test functions, whose graphics are shown in Fig. 7:

  • \(\cdot \) Franke’s function:

    $$\begin{aligned} h_1(x,y)= & {} 0.75e^{-\frac{(9x-2)^2+(9y-2)^2}{4}}+ 0.75e^{-\frac{(9x+1)}{10}-\frac{(9y+1)^2}{49}}+\\{} & {} 0.5e^{-\frac{(9y-7)^2+(9x-3)^2}{4}}- 0.2e^{-(9y-4)^2-(9x-7)^2}; \end{aligned}$$
  • \(\cdot \) Semisphere function:

    $$\begin{aligned} h_2(x,y)=\left\{ \begin{array}{cll} \sqrt{\left( \frac{1}{2}\right) ^2-\left( x-\frac{1}{2}\right) ^2-\left( y-\frac{1}{2}\right) ^2}&{} \text{ if } &{} \left( x-\frac{1}{2}\right) ^2+\left( y-\frac{1}{2}\right) ^2\le \left( \frac{1}{2}\right) ^2\\ 0&{}&{} \text{ otherwise } \end{array}\right. . \end{aligned}$$
Fig. 7
figure 7

Franke’s function (left) and semisphere (right)

4.5 Numerical results

To check the feasibility of the proposed method, we will consider, for both test functions, three different values of the prescribed area: the optimal one \(\mathcal {A}^{opt}\), obtained with the method previously developed (14), and another two values \(\mathcal {A}^{+}\) and \(\mathcal {A}^{++}\), greater than \(\mathcal {A}^{opt}\). All experiments have been carried out over the triangulations \(\mathcal {T}^5\) and \(\mathcal {T}^9\) and with the elevations \(k=0,4,7\) of the control net. We will denote by

$$\begin{aligned} \sigma ^{(k)}_{h_i,\mathcal {A}}=\sum _{i=1}^{3s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\hat{\alpha }_{j}w_j\in \mathcal {S}_2^1(H^*_{s_f}) \end{aligned}$$

the best solution of (6)–(7) when handling the test function \(h_i\) with prescribed area \(\mathcal {A}\) and for the non-linear \(f_{n+1}\) as in (12), where the ‘best solution’ \(\hat{\varvec{\alpha }}=(\hat{\alpha }_1,\dots ,\hat{\alpha }_n)\) has been considered to be the one minimizing the relative error

$$\begin{aligned} E_r(\varvec{\alpha })=\frac{\left( \mathcal {J}_{2}\left( \sum _{i=1}^{3s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\alpha _{j}w_j\right) -\mathcal {J}_{2}(\sigma _{s_f})\right) ^2}{\mathcal {J}_{2}(\sigma _{s_f})^2}+\frac{(f_{n+1}({\varvec{\alpha }})-\mathcal {A})^2}{\mathcal {A}^2}, \end{aligned}$$
(18)

where \(\sigma _{s_f}\in \mathcal {S}_2^1(H^*_{s_f})\), defined in (4), is the unique spline in \( \mathcal {S}_2^1(H^*_{s_f})\) minimizing the bending energy \(\mathcal {J}_{2}\), i.e., \(\sigma _{s_f}\) is the \(\mathcal {C}^1\)-‘minimum’ filling patch of \(s_f\), in such a way that the first summand of (18) gives a measure of the relative bending energy of the spline \(\sum _{i=1}^{3s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\alpha _{j}w_j\) with respect to the minimum one, while the second summand is a measure of the relative error associated with the area constraint. Therefore, somehow we define the best solution to be the one exhibiting an equilibrium between a relative minimal bending energy and a relative minimal error with respect to the area \(\mathcal {A}\) to be achieved. Of course, as expected, we obtain very bad results for values of \(\mathcal {A}\) lower than a certain quantity (in fact, \(\mathcal {A}\) cannot be less than the area of the polygonal \(H^*\), these experiments result in very high values of \(\frac{(f_{n+1}({\varvec{\alpha }})-\mathcal {A})^2}{\mathcal {A}^2}\)). In Tables 1, 2 and 3, we show results for Franke’s function \(h_1\), while in Tables 4, 5 and 6, we show results for semisphere’s function \(h_2\). In all cases, we give the area \(A(\sigma ^{(k)}_{h_i,\mathcal {A}})\) of the best solution \(\sigma ^{(k)}_{h_i,\mathcal {A}}\). In Tables 1 and 4 we also include an estimation of the relative error

$$\begin{aligned} E=\frac{\sum _{s=1}^{1500}\left( h_i(a_s)-\sigma ^{(k)}_{h_i,\mathcal {A}^{opt}}(a_s)\right) ^2}{\sum _{s=1}^{1500}h_i(a_s)^2}, \end{aligned}$$

where \(\{a_1,\dots ,a_{1500}\}\) are random points in \(H^*\), when filling both test functions with the ‘optimum’ splines \(\sigma ^{(k)}_{h_i,\mathcal {A}^{opt}}\) obtained with the optimal area constraint \(\mathcal {A}^{opt},\) as well as the exact area of the test function \(A(h_i)\) over \(H^*\).

Table 1 Numerical results for Franke’s test function for \(\mathcal {A}=\mathcal {A}^{\text {opt}}\)
Table 2 Numerical results for Franke’s test function for \(\mathcal {A}=\mathcal {A}^+=0.8\)
Table 3 Numerical results for Franke’s test function for \(\mathcal {A}=\mathcal {A}^{++}=1.8\)
Table 4 Numerical results for semisphere’s test function for \(\mathcal {A}=\mathcal {A}^{\text {opt}}\)
Table 5 Numerical results for semisphere’s test function for \(\mathcal {A}=\mathcal {A}^+=0.7\)
Table 6 Numerical results for semisphere’s test function for \(\mathcal {A}=\mathcal {A}^{++}=1.3\)

It is well known that the higher the elevation level of the control net of a bivariate quadratic polynomial is, the better its area approximates the area of the polynomial. All our experiments showcase this behaviour and can be observed that the relative error E decreases and the area constraint is better satisfied as the elevation level k increases.

We can also observe that the results obtained from triangulation \(\mathcal {T}^9\) are better than the ones associated to \(\mathcal {T}^5\). Of course, this is also reasonable since disposing of a higher dimensional spline space where to look for filling patches must lead to better results. Although, of course, raising dimensions turns into higher computational costs.

In the case \(\mathcal {A}=\mathcal {A}^{\text {opt}}\), the best results, reported in Tables 1 and 4 and in Figs. 8 and 9 left, have been obtained when considering the non-linear system of separable equations (6)–(15). In practical terms, Problem (16) can be numerically solved using interior point (or barrier) methods (IPM) (Wächter and Biegler 2006; Byrd et al. 2000, 1997; Conn et al. 2000; Gould et al. 2001). IPM define a family of iterative methods that can solve convex or nonconvex nonlinear programming problems of the form

$$\begin{aligned} \underset{\varvec{\alpha }\in R^n}{\min }\ \quad f(\varvec{\alpha }), \quad \text {subject to } \quad c(\varvec{\alpha })=0, \end{aligned}$$
(19)

where \(f(\varvec{\alpha }):\mathbb {R}^n \rightarrow \mathbb {R}\) is the objective function and \(c(\varvec{\alpha }):\mathbb {R}^n\rightarrow \mathbb {R}^m\) describes a set of \(m\ge 0\) constraints. The algorithm consists of outer and inner loops. Given that (19) has no inequalities nor bound constraints, in the outer loop a sequence of (unconstrained) problems similar to

$$\begin{aligned} \underset{\varvec{\alpha }\in \mathbb {R}^n}{\min }&\quad \phi (\varvec{\alpha }) := f(\varvec{\alpha }) - \lambda ^T c(\varvec{\alpha }) \end{aligned}$$

are solved where \(\lambda \) is a Lagrange multiplier vector. These problems are generally solved using Newton’s method and thus require to solve a linear system of equations involving the Hessian of the Lagrangian of (19) to find a suitable descent direction. For our case and since we are interested in finding a feasible point, there is no objective function and the constraints function \(c(\varvec{\alpha })=0\) is described in (16). Only linear and quadratic constraints are involved and the Hessian of the Lagrangian contains a block of constant elements. Quadratically constrained IPM methods exploit this fact and can keep a factorization of this block without the need to refactorize at each outer iteration. The inner loop consists of a line search using e.g. exact penalty functions or filter methods (Wächter and Biegler 2006).

State-of-the-art IPM solvers such as NAG’s e04st [40] or IpOpt Wächter and Biegler (2006) solve problem (16) by finding a feasible point. In this case, the inner iteration linesearch minimizes a merit function, \(\text {f}_{\text {I}}(\varvec{\alpha })\), defined as a metric that measures infeasibility. Many metrics have been proposed, each with its own advantage. Sparsity-preserving \(\ell _1\)-norm, Euclidean \(\ell _2\)-norm or weighted variants of the previous two are all quite commonplace. We use an \(\ell _1\)-norm and the merit function chosen is \(\text {f}_{\text {I}}(\varvec{\alpha }) = \sum _{i=1}^{\ell }\, |c^i(\varvec{\alpha })|\). This choice for \(\text {f}_{\text {I}}(\varvec{\alpha })\) matches with the implemented one in the solvers e04st and IpOpt Wächter and Biegler (2006), with the former one used in the experimentation. It is worth mentioning that both implemententations achieve the best performance by making use of the first- and second-order derivatives. Tables 1 and 4 report results for the numerical experimentation using the e04st solver.

On the other hand, regarding the case \(\mathcal {A}\ne \mathcal {A}^{\text {opt}}\), formulations \(\mathcal O_1\), which directly attempt to solve the system of non-linear equations, are the most successful ones, when solved by fsolve, from Matlab, or knitro_nlneqs, from Knitro. It is worthy to mention that for high values of the prescribed area \(\mathcal {A}\), the minimal bending energy condition is much harder to fulfill, since the unique solution of the linear system (6) is naturally associated to a low value of \(\mathcal {A}\). From this point of view, we find it reasonable that the best results in the case \(\mathcal {A}=\mathcal {A}^{++}\) are obtained by considering the minimization of \(\{(f_i(x)-d_i)^2\}_{i=1}^n\) rather than the one of \(\{f_i(x)-d_i\}_{i=1}^n\) or \(\{|f_i(x)-d_i|\}_{i=1}^n\), as it happens in the case \(\mathcal {A}=\mathcal {A}^+\). In fact, the results obtained for \(\mathcal {A}=\mathcal {A}^+\) by means of the solution of the system

$$\begin{aligned} \min {\left\{ (\mu ^{\text {opt}})^2 (f_i(\varvec{\alpha })-d_i)^2,(1-\mu ^{\text {opt}})^2(f_{n+1}(\varvec{\alpha })-\mathcal {A}^+)^2\right\} _{i=1}^n\;}=\textbf{0} \end{aligned}$$

are worse than the ones obtained with (8) and (9). Similarly, the results obtained for \(\mathcal {A}=\mathcal {A}^{++}\) by solving the system

$$\begin{aligned} \left( \sqrt{\mu ^{\text {opt}}} \left( f_1(\varvec{\alpha })-d_1\right) ,\dots ,\sqrt{\mu ^{\text {opt}}} \left( f_n(\varvec{\alpha })-d_n\right) ,\sqrt{1-\mu ^{\text {opt}}}\left( f_{n+1}(\varvec{\alpha })-\mathcal {A}^{++}\right) \right) =\textbf{0} \end{aligned}$$

or

$$\begin{aligned} \left( \sqrt{\mu ^{\text {opt}}} \left| f_1(\varvec{\alpha })-d_1\right| ,\dots ,\sqrt{\mu ^{\text {opt}}} \left| f_n(\varvec{\alpha })-d_n\right| ,\sqrt{1-\mu ^{\text {opt}}}\left| f_{n+1}(\varvec{\alpha })-\mathcal {A}^{++}\right| \right) =\textbf{0} \end{aligned}$$

are worse than the ones obtained with 10. These facts show that obtaining good results depends not only on the value of \(\mu ^{\text {opt}}\) but also on the formulation considered.

In Fig. 8 above we show the graphics of the filling patches \(\sigma ^{(7)}_{h_1,\mathcal {A}}\) of Franke’s function obtained for triangulation \(\mathcal {T}^9\) and for the three different prescribed values of \(\mathcal {A}\) considered in Tables 1, 2 and 3, respectively. In Fig. 8 below we show the graphics of the global reconstructed functions (1) all over D. Figure 9 follows the same pattern for the semisphere’s function. In the case of the semisphere, due to the symmetry of its graphic around the top point \((0.5,0.5,h_2(0.5,0.5)),\) we have obtained, in all experiments, two different kinds of solutions: the ones leading to filling patches ‘above’ the graphic of the semisphere and the ones leading to filling patches ‘below’ the graphic. Since the components \(\{\alpha _{3(i-1)+1}\}_{i=1}^{n/3}\) of any solution \(\varvec{\alpha }\) of (6)–(7) are exactly the values of the filling patch \(\sigma _{s_f}\) at the knots of the triangulation \(\mathcal {T}\) lying in the interior of \(H^*\), it is easy to decide whether a solution is desirable or not. In the examples provided in this section we have chosen the solutions leading to filling patches ‘above’ the graphic of the semisphere to somehow keep its shape. Obviously, another solution leading to ‘sunked’ filling patches can be considered.

Fig. 8
figure 8

Franke’s filling patches with prescribed areas in \(\mathcal {T}^9\) for \(k=7\)

Fig. 9
figure 9

Semisphere’s filling patches with prescribed areas in \(\mathcal {T}^9\) for \(k=7\)

To end this section, we have considered an example over a hole \(H_0\) with a more complex geometry. This hole, whose graphic is shown in Fig. 10 left, is inspired by the one considered in Chapter XI.4 of Arcangéli et al. (2004). This last example has also been carried out over the domain \(D=(0,1)\times (0,1)\), for Franke’s test function, and for the smoothing parameters \(\tau _1=10^{-4}\) and \(\tau _2=10^{-5}\) in the functional (2), and \(\lambda _0= 10\) in the functional (3). In order to obtain a surrounding \(H_0^*\) close enough to \(H_0\), we have considered the triangulation \(\mathcal {T}^{25}\) of \(\overline{D}\). To perform this example, we have directly considered the non-linear system of separable equations (6)–(15), which in the previous ones led to the best filling patches. Numerical results of this experiment are reported in Table 7, while the filling patch is shown in Fig. 10 right. As in the previous examples, Table 7 shows that the relative error decreases and the area constraint are better satisfied as the elevation level k increases.

Fig. 10
figure 10

Hole \(H_0\), surrounding polygonal hole \(H_0^*\), and Franke’s filling patch in \(\mathcal {T}^{25}\) for \(k=7\)

Table 7 Numerical results for Franke’s test function for \(\mathcal {A}=\mathcal {A}^{\text {opt}},\) hole \(H_0\) and \(\mathcal {T}^{25}\)

5 Filling patches satisfying curvature constraints

In this section, we consider the problem of determining minimal energy-filling patches with prescribed values of the mean curvature at some interior points of \(H^*\). Let us recall that the mean curvature of a bivariate function at a point (xy) is defined as

$$\begin{aligned} \mathcal {K}=\frac{\partial _{xx}(1+\partial _{y}^2)-2\partial _x\partial _y\partial _{xy}+\partial _{yy}(1+\partial _{x}^2)}{2\left( 1+\partial _{x}^2+\partial _{y}^2\right) ^{3/2}}, \end{aligned}$$

where \(\partial _x, \partial _y, \partial _{xx}, \partial _{xy}\) and \(\partial _{yy}\) represent the first and second orders partial derivatives operators. So, if \(\{\chi _q\}_{q=1}^{\ell }\) is a set of points in \({\mathop {H^*}\limits ^{\circ }}\) in which we want the filling patch to have prescribed values \(\mathcal {K}=\{\mathcal {K}_q\}_{q=1}^{\ell }\) of the mean curvature, we will have to handle the non-linear system (6)–(7) where, for each \(q=1,\dots ,\ell ,\) the function \(f_{n+q}\) in (7) has an expression of the form

$$\begin{aligned} f_{n+q}(\varvec{\alpha })=\frac{\sum _{i,j,k=0}^{{{n}}}D^{{{q}}}_{ijk}\alpha _i\alpha _j\alpha _k}{2\left( 1+\sum _{i,j=0}^{{{n}}}F_{ij}^{{{q}}}\alpha _i\alpha _j\right) ^{3/2}}, \end{aligned}$$

where we adopt the convention \(\alpha _0=1\), and \(d_{n+q}=\mathcal {K}_q\).

Contrary to what happens in the area constraint case, since mean curvature is a local geometrical concept, we cannot expect to obtain any regression function providing a kind of dependence between the values \(\{f_i(\varvec{\alpha })-d_i\}_{i=1}^n\) in (5) and the prescribed \(\{\mathcal {K}_q\}_{q=1}^{\ell }\). In fact, it is easy to define a function having zero mean curvature at one point with a very high bending energy. Bending energy is expected to take values much higher than the prescribed ones of the mean curvature and, therefore, the values of the parametes \(\mu \) in the objective functions considered must necessarily be low to get a properly balanced bending energy-mean curvature.

We have carried out experiments with both test functions Franke (\(h_1\)) and semisphere (\(h_2\)) and, in all cases, the best solution \(\sigma _{h_i,\mathcal {K}}\in \mathcal {S}_2^1(H^*_{s_f})\) associated to prescribed values of the mean curvature \(\mathcal {K}\) has been considered to be the one minimizing the relative error

$$\begin{aligned} \frac{\left( \mathcal {J}_{2}\left( \sum _{i=1}^{3s}\varphi _i(s_f)w_i^0+\sum _{j=1}^{n}\alpha _{j}w_j\right) -\mathcal {J}_{2}(s_f)\right) ^2}{\mathcal {J}_{2}(s_f)^2}+\sum _{q=1}^{\ell }\frac{(f_{n+q}({\varvec{\alpha }})-\mathcal {K}_q)^2}{\mathcal {K}_q^2}, \end{aligned}$$

where \(\sigma _{s_f}\in \mathcal {S}_2^1(H^*_{s_f})\), defined in (4), is the unique spline in \( \mathcal {S}_2^1(H^*_{s_f})\) minimizing the bending energy \(\mathcal {J}_{2}\). All the experiments in this section have been performed with the parameters values \(\mu =10^{-1},10^{-4},10^{-7}\), being the best results in all cases the ones associated to \(\mu =10^{-4}\).

In Fig. 11 we present results for Franke’s function \(h_1\) over the triangulation \(\mathcal {T}^5\) when imposing mean curvature \(\mathcal {K}_1=0\) at the point \(\chi _1=(0.5,0.5)\) -central point in the graphics-. We show the graphic of \(\sigma _{h_1,\mathcal {K}_1}\) (left), the one of the global reconstructed function (right) and the values of the mean curvature at \(\chi _1\) of \(h_1\), of the \(\mathcal {C}^1\)-minimal filling of \(h_1\) obtained just minimizing functional \(\mathcal {J}_2\) (4), and of the function \(\sigma _{h_1,\mathcal {K}_1}\).

Fig. 11
figure 11

Franke’s filling results with prescribed mean curvature at one point

In Fig. 11 we observe that, although the mean curvature of \(\sigma _{h_1,\mathcal {K}_1}\) at (0.5, 0.5) is closer to the prescribed \(\mathcal {K}_1=0\) than the ones of Franke’s function and of its \(\mathcal {C}^1\)-filling, it is still a little bit far from being 0. This is due to the fact that we have considered the coarse triangulation \(\mathcal {T}^5\). To improve this result, in Fig. 12 we consider Franke’s function over the finer triangulation \(\mathcal {T}^{22}\) when imposing mean curvature \(\mathcal {K}_1=0\) and \(\mathcal {K}_2=0\) at the points \(\chi _1=(0.36,0.5)\) and \(\chi _2=(0.64,0.5)\).

Fig. 12
figure 12

Franke’s filling results with prescribed mean curvature at two points

Following the same pattern that for Franke’s function, in Fig. 13 and in Table 8 we show the results for different prescribed values \(\mathcal {K}_1\) of the mean curvature for the semisphere at the point \(\chi _1=(0.5,0.5)\), while in Fig. 14 and in Table 9 we show the results for different prescribed values \(\mathcal {K}_1\) and \(\mathcal {K}_2\) of the mean curvature for the semisphere at the points \(\chi _1=(0.36,0.5)\) and \(\chi _2=(0.64,0.5)\), respectively.

Fig. 13
figure 13

Semisphere’s filling patches with prescribed mean curvature at one point

Table 8 Numerical results for semisphere’s with prescribed curvature at one point
Fig. 14
figure 14

Semisphere’s filling results with prescribed mean curvature at two points

Table 9 Numerical results for semisphere’s with prescribed curvature at two points

Once all experiments have been carried out, we have found that for prescribed values of the mean curvature closest to the exact ones of the functions to be filled (semisphere with prescribed \(\mathcal {K}_1=0\), \(\mathcal {K}_1=-5\) and \(\mathcal {K}_1=\mathcal {K}_2=-5\)), the best results are obtained by means of the solver knitro-nlneqs, using reformulation \(\mathcal {O}_1\), which treats directly the nonlinear system of equations, considering the absolute value of the different components (9). For prescribed values of the mean curvature farthest to the exact ones (the remaining experiments), the best results are obtained by means of GlobalSearch, when considering reformulation \(\mathcal {O}_4\), again considering the absolute value of the different components. We point out that solver GlobalSearch aims at global optimization, allowing a better exploration of the variable space.

6 Conclusions

We have developed a method to reconstruct holes in a given surface or, more generally, in a given dataset. The filling patch joins the original surface with \(\mathcal {C}^1\)-smoothness and it is defined as a spline of bivariate polynomials of total degree at most two, leading to minimum possible computational costs insofar as no lower degree allows to obtain \(\mathcal {C}^1\)-splines. Moreover, the filling patch is required to be a proper approximation of a non-linear system composed of two types of equations: the first ones (linear) control the fairness of the filling patch, while the second ones control non-linear features, as the area or the mean curvature. To obtain the filling patch, some reformulations of the original non-linear system and some solvers to address biobjective optimization problems are considered. In the particular case of the area constraint, we develop a method to estimate optimum values of the weight to be given to each one of the geometric characteristic (fairness and non-linear constraint) to be handled, as well as a method to estimate the optimal area to be imposed. The numerical and graphical examples presented show the effectiveness of the numerical methods proposed. Regarding the area constraint, experiments carried out show that the filling patch associated with the optimum value of the area is better achieved when the original non-linear system is reformulated in terms of several disaggregated equations numerically solved by means of interior point methods. While, in the general case, reformulations directly attempting to solve the system of non-linear equations are the most successful ones, when solved by fsolve, from Matlab, or knitro_nlneqs, from Knitro. Regarding the mean curvature constraint we also found that solvers and reformulations leading to the best results depend on the value of the mean curvature imposed. More precisely, solver knitro-nlneqs and reformulation \(\mathcal {O}_1\) work better for prescribed values closer to the exact ones, while for farthest values the best results are obtained by means of GlobalSearch, when considering reformulation \(\mathcal {O}_4\).